metatext/Views/PostingReadingPreferencesView.swift

62 lines
2.7 KiB
Swift
Raw Normal View History

2020-08-07 10:14:14 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
2020-08-30 23:33:11 +00:00
import class Mastodon.Status
2020-08-30 23:59:49 +00:00
import struct Mastodon.Preferences
2020-09-01 07:33:49 +00:00
import ViewModels
2020-08-07 10:14:14 +00:00
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: {
2020-08-30 23:59:49 +00:00
Text("preferences.expand-media.default").tag(Preferences.ExpandMedia.default)
Text("preferences.expand-media.show-all").tag(Preferences.ExpandMedia.showAll)
Text("preferences.expand-media.hide-all").tag(Preferences.ExpandMedia.hideAll)
2020-08-07 10:14:14 +00:00
})
.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-09-01 07:33:49 +00:00
import PreviewViewModels
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-09-08 02:12:38 +00:00
PostingReadingPreferencesView(viewModel: .init(identification: .preview))
2020-08-07 10:14:14 +00:00
}
}
2020-08-12 07:37:14 +00:00
#endif