1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-11 08:55:54 +01:00
metatext-app-ios-iphone-ipad/Views/PostingReadingPreferencesView.swift

62 lines
2.6 KiB
Swift
Raw Normal View History

2020-08-07 12:14:14 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
2020-08-31 01:33:11 +02:00
import class Mastodon.Status
2020-08-31 01:59:49 +02:00
import struct Mastodon.Preferences
2020-09-01 09:33:49 +02:00
import ViewModels
2020-08-07 12:14:14 +02:00
2020-08-07 12:59:48 +02:00
struct PostingReadingPreferencesView: View {
@StateObject var viewModel: PostingReadingPreferencesViewModel
2020-08-07 12:14:14 +02:00
var body: some View {
Form {
2020-08-07 12:59:48 +02:00
Section {
2020-08-07 12:14:14 +02:00
Toggle("preferences.use-preferences-from-server",
2020-08-07 12:59:48 +02:00
isOn: $viewModel.preferences.useServerPostingReadingPreferences)
}
Section(header: Text("preferences.posting")) {
2020-08-07 12:14:14 +02: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 12:59:48 +02:00
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
2020-08-07 12:14:14 +02:00
Section(header: Text("preferences.reading")) {
VStack(alignment: .leading) {
Text("preferences.reading-expand-media")
Picker("", selection: $viewModel.preferences.readingExpandMedia,
content: {
2020-08-31 01:59:49 +02: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 12:14:14 +02:00
})
.pickerStyle(SegmentedPickerStyle())
}
Toggle("preferences.reading-expand-spoilers",
isOn: $viewModel.preferences.readingExpandSpoilers)
}
2020-08-07 12:59:48 +02:00
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
2020-08-07 12:14:14 +02:00
}
2020-08-07 12:59:48 +02:00
.navigationTitle("preferences.posting-reading")
2020-08-07 12:14:14 +02:00
.alertItem($viewModel.alertItem)
}
}
2020-08-12 09:37:14 +02:00
#if DEBUG
2020-09-01 09:33:49 +02:00
import PreviewViewModels
2020-08-07 12:59:48 +02:00
struct PostingReadingPreferencesViewView_Previews: PreviewProvider {
2020-08-07 12:14:14 +02:00
static var previews: some View {
2020-09-01 09:33:49 +02:00
PostingReadingPreferencesView(viewModel: .mock())
2020-08-07 12:14:14 +02:00
}
}
2020-08-12 09:37:14 +02:00
#endif