metatext-app-ios-iphone-ipad/Views/StartupAndSyncingPreference...

53 lines
1.8 KiB
Swift
Raw Normal View History

2020-10-27 04:01:12 +01:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
import ViewModels
struct StartupAndSyncingPreferencesView: View {
@StateObject var identityContext: IdentityContext
2020-10-27 04:01:12 +01:00
var body: some View {
Form {
Section(header: Text("preferences.startup-and-syncing.home-timeline")) {
Picker("preferences.startup-and-syncing.position-on-startup",
2021-01-26 01:06:35 +01:00
selection: $identityContext.appPreferences.homeTimelineBehavior) {
2020-10-27 04:01:12 +01:00
ForEach(AppPreferences.PositionBehavior.allCases) { option in
Text(option.localizedStringKey).tag(option)
}
}
}
Section(header: Text("preferences.startup-and-syncing.notifications-tab")) {
Picker("preferences.startup-and-syncing.position-on-startup",
2021-01-26 01:06:35 +01:00
selection: $identityContext.appPreferences.notificationsTabBehavior) {
2020-10-27 04:01:12 +01:00
ForEach(AppPreferences.PositionBehavior.allCases) { option in
Text(option.localizedStringKey).tag(option)
}
}
}
}
}
}
extension AppPreferences.PositionBehavior {
var localizedStringKey: LocalizedStringKey {
switch self {
case .rememberPosition:
return "preferences.startup-and-syncing.remember-position"
case .syncPosition:
return "preferences.startup-and-syncing.sync-position"
case .newest:
return "preferences.startup-and-syncing.newest"
}
}
}
#if DEBUG
import PreviewViewModels
struct StartupAndSyncingPreferencesView_Previews: PreviewProvider {
static var previews: some View {
StartupAndSyncingPreferencesView(identityContext: .preview)
2020-10-27 04:01:12 +01:00
}
}
#endif