diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index b948c631..cfff61c2 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -13,23 +13,46 @@ struct AdvancedPrefsView : View { var body: some View { 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)) { - 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 - } - } - - Section(header: Text("AUTOMATION")) { - NavigationLink(destination: SilentActionPrefs()) { - Text("Silent Action Permissions") - } + formattingSection + automationSection + }.listStyle(.grouped) + .navigationBarTitle(Text("Advanced")) + } + + var formattingFooter: some View { + 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) + } + + 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" + } } } diff --git a/Tusker/Screens/Preferences/BehaviorPrefsView.swift b/Tusker/Screens/Preferences/BehaviorPrefsView.swift index 7fcb1c9e..a7b971d0 100644 --- a/Tusker/Screens/Preferences/BehaviorPrefsView.swift +++ b/Tusker/Screens/Preferences/BehaviorPrefsView.swift @@ -15,29 +15,36 @@ struct BehaviorPrefsView : View { var body: some View { List { - Section { - Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) { - ForEach(Status.Visibility.allCases, id: \.self) { visibility in - HStack { - Image(systemName: visibility.imageName) - 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 - } - Toggle(isOn: _automaticallySaveDrafts.binding) { - Text("Automatically Save Drafts") - } + section1 + section2 + }.listStyle(.grouped) + .navigationBarTitle(Text("Behavior")) + } + + var section1: some View { + Section { + Picker(selection: _defaultPostVisibility.binding, label: Text("Default Post Visibility")) { + ForEach(Status.Visibility.allCases, id: \.self) { visibility in + HStack { + Image(systemName: visibility.imageName) + 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: _openLinksInApps.binding) { - Text("Open Links in Apps") - } + Toggle(isOn: _automaticallySaveDrafts.binding) { + Text("Automatically Save Drafts") + } + } + } + + var section2: some View { + Section { + Toggle(isOn: _openLinksInApps.binding) { + Text("Open Links in Apps") } } - .listStyle(.grouped) - .navigationBarTitle(Text("Behavior")) } }