metatext/Shared/Views/PostingReadingPreferencesView.swift

57 lines
2.6 KiB
Swift
Raw Normal View History

2020-08-07 10:14:14 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
2020-08-07 10:59:48 +00:00
struct PostingReadingPreferencesView: View {
@StateObject var viewModel: PostingReadingPreferencesViewModel
2020-08-07 10:14:14 +00:00
var body: some View {
Form {
2020-08-07 10:59:48 +00:00
Section {
2020-08-07 10:14:14 +00:00
Toggle("preferences.use-preferences-from-server",
2020-08-07 10:59:48 +00:00
isOn: $viewModel.preferences.useServerPostingReadingPreferences)
}
Section(header: Text("preferences.posting")) {
2020-08-07 10:14:14 +00:00
VStack(alignment: .leading) {
Text("preferences.posting-default-visiblility")
Picker("", selection: $viewModel.preferences.postingDefaultVisibility,
content: {
Text("status.visibility.public").tag(Status.Visibility.public)
Text("status.visibility.unlisted").tag(Status.Visibility.unlisted)
Text("status.visibility.private").tag(Status.Visibility.private)
})
.pickerStyle(SegmentedPickerStyle())
}
Toggle("preferences.posting-default-sensitive",
isOn: $viewModel.preferences.postingDefaultSensitive)
}
2020-08-07 10:59:48 +00:00
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
2020-08-07 10:14:14 +00:00
Section(header: Text("preferences.reading")) {
VStack(alignment: .leading) {
Text("preferences.reading-expand-media")
Picker("", selection: $viewModel.preferences.readingExpandMedia,
content: {
Text("preferences.expand-media.default").tag(MastodonPreferences.ExpandMedia.default)
Text("preferences.expand-media.show-all").tag(MastodonPreferences.ExpandMedia.showAll)
Text("preferences.expand-media.hide-all").tag(MastodonPreferences.ExpandMedia.hideAll)
})
.pickerStyle(SegmentedPickerStyle())
}
Toggle("preferences.reading-expand-spoilers",
isOn: $viewModel.preferences.readingExpandSpoilers)
}
2020-08-07 10:59:48 +00:00
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
2020-08-07 10:14:14 +00:00
}
2020-08-07 10:59:48 +00:00
.navigationTitle("preferences.posting-reading")
2020-08-07 10:14:14 +00:00
.alertItem($viewModel.alertItem)
}
}
2020-08-12 07:37:14 +00:00
#if DEBUG
2020-08-07 10:59:48 +00:00
struct PostingReadingPreferencesViewView_Previews: PreviewProvider {
2020-08-07 10:14:14 +00:00
static var previews: some View {
2020-08-07 10:59:48 +00:00
PostingReadingPreferencesView(viewModel: .development)
2020-08-07 10:14:14 +00:00
}
}
2020-08-12 07:37:14 +00:00
#endif