Files
letro-ios/ElementX/Sources/Screens/Settings/AvancedOptionsScreen/View/AdvancedSettingsScreen.swift
Mauro Romito f7c7cf23ed UserPreference now supports closure based default
and you can also force the defaults to be always used through a subscription
2025-03-21 15:41:39 +01:00

76 lines
2.9 KiB
Swift

//
// Copyright 2022-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
// Please see LICENSE files in the repository root for full details.
//
import Compound
import SwiftUI
struct AdvancedSettingsScreen: View {
@ObservedObject var context: AdvancedSettingsScreenViewModel.Context
var body: some View {
Form {
Section {
ListRow(label: .plain(title: L10n.commonAppearance),
kind: .picker(selection: $context.appAppearance,
items: AppAppearance.allCases.map { (title: $0.name, tag: $0) }))
ListRow(label: .plain(title: L10n.actionViewSource,
description: L10n.screenAdvancedSettingsViewSourceDescription),
kind: .toggle($context.viewSourceEnabled))
ListRow(label: .plain(title: L10n.screenAdvancedSettingsSharePresence,
description: L10n.screenAdvancedSettingsSharePresenceDescription),
kind: .toggle($context.sharePresence))
ListRow(label: .plain(title: L10n.screenAdvancedSettingsMediaCompressionTitle,
description: L10n.screenAdvancedSettingsMediaCompressionDescription),
kind: .toggle($context.optimizeMediaUploads))
.onChange(of: context.optimizeMediaUploads) {
context.send(viewAction: .optimizeMediaUploadsChanged)
}
// TODO: Waiting for designs and copies
ListRow(label: .plain(title: "hide avatars",
description: ""),
kind: .toggle($context.hideInviteAvatars))
ListRow(label: .plain(title: "hide media",
description: ""),
kind: .toggle($context.hideTimelineMedia))
}
}
.compoundList()
.navigationTitle(L10n.commonAdvancedSettings)
.navigationBarTitleDisplayMode(.inline)
}
}
private extension AppAppearance {
var name: String {
switch self {
case .system:
return L10n.commonSystem
case .light:
return L10n.commonLight
case .dark:
return L10n.commonDark
}
}
}
// MARK: - Previews
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
static var previews: some View {
NavigationStack {
AdvancedSettingsScreen(context: viewModel.context)
}
}
}