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 {
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
}
}
formattingSection
automationSection
}.listStyle(.grouped)
.navigationBarTitle(Text("Advanced"))
}
Section(header: Text("AUTOMATION")) {
NavigationLink(destination: SilentActionPrefs()) {
Text("Silent Action Permissions")
}
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"
}
}
}

View File

@ -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"))
}
}