Use inset list style for preferences on iOS 14

This commit is contained in:
Shadowfacts 2020-09-15 20:46:49 -04:00
parent be5a4c03a6
commit 02135aa0de
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 33 additions and 14 deletions

View File

@ -16,7 +16,8 @@ struct AdvancedPrefsView : View {
formattingSection formattingSection
automationSection automationSection
cachingSection cachingSection
}.listStyle(GroupedListStyle()) }
.insetOrGroupedListStyle()
.navigationBarTitle(Text("Advanced")) .navigationBarTitle(Text("Advanced"))
} }
@ -44,7 +45,7 @@ struct AdvancedPrefsView : View {
} }
var cachingSection: some View { var cachingSection: some View {
Section(header: Text("Caching")) { Section(header: Text("Caching"), footer: Text("Clearing caches will restart the app.")) {
Button(action: clearCache) { Button(action: clearCache) {
Text("Clear Mastodon Cache") Text("Clear Mastodon Cache")
}.foregroundColor(.red) }.foregroundColor(.red)

View File

@ -33,7 +33,7 @@ struct AppearancePrefsView : View {
accountsSection accountsSection
postsSection postsSection
} }
.listStyle(GroupedListStyle()) .insetOrGroupedListStyle()
.navigationBarTitle(Text("Appearance")) .navigationBarTitle(Text("Appearance"))
} }

View File

@ -14,7 +14,9 @@ struct BehaviorPrefsView: View {
var body: some View { var body: some View {
List { List {
linksSection linksSection
}.listStyle(GroupedListStyle()).navigationBarTitle(Text("Behavior")) }
.insetOrGroupedListStyle()
.navigationBarTitle(Text("Behavior"))
} }
var linksSection: some View { var linksSection: some View {

View File

@ -16,7 +16,9 @@ struct ComposingPrefsView: View {
List { List {
composingSection composingSection
replyingSection replyingSection
}.listStyle(GroupedListStyle()).navigationBarTitle("Composing") }
.insetOrGroupedListStyle()
.navigationBarTitle("Composing")
} }
var composingSection: some View { var composingSection: some View {

View File

@ -14,7 +14,9 @@ struct MediaPrefsView: View {
var body: some View { var body: some View {
List { List {
viewingSection viewingSection
}.listStyle(GroupedListStyle()).navigationBarTitle("Media") }
.insetOrGroupedListStyle()
.navigationBarTitle("Media")
} }
var viewingSection: some View { var viewingSection: some View {

View File

@ -15,7 +15,7 @@ struct PreferencesView: View {
// workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button // workaround: the navigation view is provided by MyProfileTableViewController so that it can inject the Done button
// NavigationView { // NavigationView {
List { List {
Section { Section(header: Text("Accounts")) {
ForEach(localData.accounts, id: \.accessToken) { (account) in ForEach(localData.accounts, id: \.accessToken) { (account) in
Button(action: { Button(action: {
NotificationCenter.default.post(name: .activateAccount, object: nil, userInfo: ["account": account]) NotificationCenter.default.post(name: .activateAccount, object: nil, userInfo: ["account": account])
@ -75,7 +75,7 @@ struct PreferencesView: View {
} }
} }
} }
.listStyle(GroupedListStyle()) .insetOrGroupedListStyle()
.navigationBarTitle(Text("Preferences"), displayMode: .inline) .navigationBarTitle(Text("Preferences"), displayMode: .inline)
// } // }
} }
@ -85,6 +85,17 @@ struct PreferencesView: View {
} }
} }
extension View {
@ViewBuilder
func insetOrGroupedListStyle() -> some View {
if #available(iOS 14.0, *) {
self.listStyle(InsetGroupedListStyle())
} else {
self.listStyle(GroupedListStyle())
}
}
}
#if DEBUG #if DEBUG
struct PreferencesView_Previews : PreviewProvider { struct PreferencesView_Previews : PreviewProvider {
static var previews: some View { static var previews: some View {

View File

@ -14,7 +14,7 @@ struct SilentActionPrefs : View {
List(Array(preferences.silentActions.keys), id: \.self) { source in List(Array(preferences.silentActions.keys), id: \.self) { source in
SilentActionPermissionCell(source: source) SilentActionPermissionCell(source: source)
} }
.listStyle(GroupedListStyle()) .insetOrGroupedListStyle()
// .navigationBarTitle("Silent Action Permissions") // .navigationBarTitle("Silent Action Permissions")
// see FB6838291 // see FB6838291
} }

View File

@ -15,7 +15,8 @@ struct WellnessPrefsView: View {
List { List {
showFavAndReblogCountSection showFavAndReblogCountSection
notificationsModeSection notificationsModeSection
}.listStyle(GroupedListStyle()) }
.insetOrGroupedListStyle()
.navigationBarTitle(Text("Digital Wellness")) .navigationBarTitle(Text("Digital Wellness"))
} }