generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathAdvancedSettingsScreen.swift
66 lines (57 loc) · 2.42 KB
/
AdvancedSettingsScreen.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// Copyright 2022-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE 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)
}
}
}
.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)
}
}
}