Cleanup code

This commit is contained in:
Shadowfacts 2019-07-27 21:43:08 -04:00
parent 2afe98cf77
commit 1e8ba5000b
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 65 additions and 35 deletions

View File

@ -13,23 +13,46 @@ struct AdvancedPrefsView : View {
var body: some View { var body: some View {
List { List {
Section(footer: Text("This option is only supported for Pleroma and Mastodon instances with formatting enabled. On all other instances, formatting symbols will remain in the unformatted plain text.").lineLimit(nil)) { formattingSection
Picker(selection: _statusContentType.binding, label: Text("Post Content Type")) { automationSection
ForEach(StatusContentType.allCases, id: \.self) { type in }.listStyle(.grouped)
Text(type.displayName).tag(type) .navigationBarTitle(Text("Advanced"))
}//.navigationBarTitle("Post Content Type") }
// see FB6838291
}
}
Section(header: Text("AUTOMATION")) { var formattingFooter: some View {
NavigationLink(destination: SilentActionPrefs()) { Text("This option is only supported for Pleroma and Mastodon instances with formatting enabled. On all other instances, formatting symbols will remain in the unformatted plain text.").lineLimit(nil)
Text("Silent Action Permissions") }
}
var formattingSection: some View {
Section(footer: formattingFooter) {
Picker(selection: _statusContentType.binding, label: Text("Post Content Type")) {
ForEach(StatusContentType.allCases, id: \.self) { type in
Text(type.displayName).tag(type)
}//.navigationBarTitle("Post Content Type")
// see FB6838291
} }
} }
.listStyle(.grouped) }
.navigationBarTitle(Text("Advanced"))
var automationSection: some View {
Section(header: Text("AUTOMATION")) {
NavigationLink(destination: SilentActionPrefs()) {
Text("Silent Action Permissions")
}
}
}
}
extension StatusContentType {
var displayName: String {
switch self {
case .plain:
return "Plain"
case .markdown:
return "Markdown"
case .html:
return "HTML"
}
} }
} }

View File

@ -15,29 +15,36 @@ struct BehaviorPrefsView : View {
var body: some View { var body: some View {
List { List {
Section { section1
Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) { section2
ForEach(Status.Visibility.allCases, id: \.self) { visibility in }.listStyle(.grouped)
HStack { .navigationBarTitle(Text("Behavior"))
Image(systemName: visibility.imageName) }
Text(visibility.displayName)
} var section1: some View {
.tag(visibility) Section {
}//.navigationBarTitle("Default Post Visibility") Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) {
// navbar title on the ForEach is currently incorrectly applied when the picker is not expanded, see FB6838291 ForEach(Status.Visibility.allCases, id: \.self) { visibility in
} HStack {
Toggle(isOn: _automaticallySaveDrafts.binding) { Image(systemName: visibility.imageName)
Text("Automatically Save Drafts") Text(visibility.displayName)
} }
.tag(visibility)
}//.navigationBarTitle("Default Post Visibility")
// navbar title on the ForEach is currently incorrectly applied when the picker is not expanded, see FB6838291
} }
Section { Toggle(isOn: _automaticallySaveDrafts.binding) {
Toggle(isOn: _openLinksInApps.binding) { Text("Automatically Save Drafts")
Text("Open Links in Apps") }
} }
}
var section2: some View {
Section {
Toggle(isOn: _openLinksInApps.binding) {
Text("Open Links in Apps")
} }
} }
.listStyle(.grouped)
.navigationBarTitle(Text("Behavior"))
} }
} }