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: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 33 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,9 @@ struct MediaPrefsView: View {
var body: some View {
List {
viewingSection
}.listStyle(GroupedListStyle()).navigationBarTitle("Media")
}
.insetOrGroupedListStyle()
.navigationBarTitle("Media")
}
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
// NavigationView {
List {
Section {
Section(header: Text("Accounts")) {
ForEach(localData.accounts, id: \.accessToken) { (account) in
Button(action: {
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)
// }
}
@ -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
struct PreferencesView_Previews : PreviewProvider {
static var previews: some View {

View File

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

View File

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