From 471d3459a6293d241525b53a80d41d9dbce39173 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 2 Feb 2023 23:29:44 -0500 Subject: [PATCH] Apply non-pure-black dark mode to preferences screen --- .../Screens/Preferences/About/AboutView.swift | 4 ++++ .../Preferences/AcknowledgementsView.swift | 1 + .../Preferences/AdvancedPrefsView.swift | 13 ++++++++--- .../Preferences/AppearancePrefsView.swift | 6 ++++- .../Preferences/BehaviorPrefsView.swift | 7 +++++- .../Preferences/ComposingPrefsView.swift | 7 +++++- .../Screens/Preferences/MediaPrefsView.swift | 4 +++- .../OppositeCollapseKeywordsView.swift | 4 +++- .../Screens/Preferences/PreferencesView.swift | 23 +++++++++++++++++++ .../Preferences/SwipeActionsPrefsView.swift | 10 ++++++++ .../Preferences/Tip Jar/TipJarView.swift | 8 +++++-- .../Preferences/WellnessPrefsView.swift | 8 ++++++- 12 files changed, 84 insertions(+), 11 deletions(-) diff --git a/Tusker/Screens/Preferences/About/AboutView.swift b/Tusker/Screens/Preferences/About/AboutView.swift index 7ca9d52e..b7e34ac5 100644 --- a/Tusker/Screens/Preferences/About/AboutView.swift +++ b/Tusker/Screens/Preferences/About/AboutView.swift @@ -42,6 +42,7 @@ struct AboutView: View { } } } + .listRowBackground(Color.appGroupedCellBackground) Section { Link("Website", destination: URL(string: "https://vaccor.space/tusker")!) @@ -67,7 +68,10 @@ struct AboutView: View { Link("Source Code", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker")!) Link("Issue Tracker", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker/issues")!) } + .listRowBackground(Color.appGroupedCellBackground) } + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .sheet(isPresented: $isShowingMailSheet) { MailSheet(logData: logData) } diff --git a/Tusker/Screens/Preferences/AcknowledgementsView.swift b/Tusker/Screens/Preferences/AcknowledgementsView.swift index 675322cd..7eceb771 100644 --- a/Tusker/Screens/Preferences/AcknowledgementsView.swift +++ b/Tusker/Screens/Preferences/AcknowledgementsView.swift @@ -14,6 +14,7 @@ struct AcknowledgementsView: View { Text(text) .padding(.horizontal, 16) } + .appGroupedScrollBackgroundIfAvailable() .navigationTitle("Acknowledgements") } diff --git a/Tusker/Screens/Preferences/AdvancedPrefsView.swift b/Tusker/Screens/Preferences/AdvancedPrefsView.swift index 32ee8d7f..6e0a2fe6 100644 --- a/Tusker/Screens/Preferences/AdvancedPrefsView.swift +++ b/Tusker/Screens/Preferences/AdvancedPrefsView.swift @@ -23,7 +23,8 @@ struct AdvancedPrefsView : View { errorReportingSection cachingSection } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle(Text("Advanced")) } @@ -50,6 +51,7 @@ struct AdvancedPrefsView : View { // see FB6838291 } } + .listRowBackground(Color.appGroupedCellBackground) } var cloudKitSection: some View { @@ -74,7 +76,9 @@ struct AdvancedPrefsView : View { Text(String(describing: cloudKitStatus!)) } } - }.task { + } + .listRowBackground(Color.appGroupedCellBackground) + .task { CKContainer.default().accountStatus { status, error in if let error { Logging.general.error("Unable to get CloudKit status: \(String(describing: error))") @@ -99,6 +103,7 @@ struct AdvancedPrefsView : View { .lineLimit(nil) } } + .listRowBackground(Color.appGroupedCellBackground) } var cachingSection: some View { @@ -120,7 +125,9 @@ struct AdvancedPrefsView : View { s += AttributedString("\nMastodon cache size: \(ByteCountFormatter().string(fromByteCount: mastodonCacheSize))") } return Text(s) - }.task { + } + .listRowBackground(Color.appGroupedCellBackground) + .task { imageCacheSize = [ ImageCache.avatars, .headers, diff --git a/Tusker/Screens/Preferences/AppearancePrefsView.swift b/Tusker/Screens/Preferences/AppearancePrefsView.swift index 280247bb..3cb22c6e 100644 --- a/Tusker/Screens/Preferences/AppearancePrefsView.swift +++ b/Tusker/Screens/Preferences/AppearancePrefsView.swift @@ -33,7 +33,8 @@ struct AppearancePrefsView : View { accountsSection postsSection } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle(Text("Appearance")) } @@ -65,6 +66,7 @@ struct AppearancePrefsView : View { .onReceive(appearanceChangePublisher) { _ in NotificationCenter.default.post(name: .themePreferenceChanged, object: nil) } + .listRowBackground(Color.appGroupedCellBackground) } private var accountsSection: some View { @@ -76,6 +78,7 @@ struct AppearancePrefsView : View { Text("Hide Custom Emoji in Usernames") } } + .listRowBackground(Color.appGroupedCellBackground) } private var postsSection: some View { @@ -103,6 +106,7 @@ struct AppearancePrefsView : View { .navigationTitle("Trailing Swipe Actions") } } + .listRowBackground(Color.appGroupedCellBackground) } } diff --git a/Tusker/Screens/Preferences/BehaviorPrefsView.swift b/Tusker/Screens/Preferences/BehaviorPrefsView.swift index 96251c63..6bc39932 100644 --- a/Tusker/Screens/Preferences/BehaviorPrefsView.swift +++ b/Tusker/Screens/Preferences/BehaviorPrefsView.swift @@ -18,7 +18,8 @@ struct BehaviorPrefsView: View { linksSection contentWarningsSection } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle(Text("Behavior")) } @@ -28,6 +29,7 @@ struct BehaviorPrefsView: View { Text("Require Confirmation Before Reblogging") } } + .listRowBackground(Color.appGroupedCellBackground) } private var timelineSection: some View { @@ -38,6 +40,7 @@ struct BehaviorPrefsView: View { } header: { Text("Timeline") } + .listRowBackground(Color.appGroupedCellBackground) } private var linksSection: some View { @@ -52,6 +55,7 @@ struct BehaviorPrefsView: View { Text("Always Use Reader Mode in In-App Safari") }.disabled(!preferences.useInAppSafari) } + .listRowBackground(Color.appGroupedCellBackground) } private var contentWarningsSection: some View { @@ -68,6 +72,7 @@ struct BehaviorPrefsView: View { Text(preferences.expandAllContentWarnings ? "Collapse Posts with Keywords in CWs" : "Expand Posts with Keywords in CWs") } } + .listRowBackground(Color.appGroupedCellBackground) } } diff --git a/Tusker/Screens/Preferences/ComposingPrefsView.swift b/Tusker/Screens/Preferences/ComposingPrefsView.swift index a6a6c137..dc07e984 100644 --- a/Tusker/Screens/Preferences/ComposingPrefsView.swift +++ b/Tusker/Screens/Preferences/ComposingPrefsView.swift @@ -19,7 +19,8 @@ struct ComposingPrefsView: View { replyingSection writingSection } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle("Composing") } @@ -51,6 +52,7 @@ struct ComposingPrefsView: View { } footer: { Text("When starting a reply, Tusker will use your preferred visibility or the visibility of the post to which you're replying, whichever is narrower.") } + .listRowBackground(Color.appGroupedCellBackground) } var composingSection: some View { @@ -62,6 +64,7 @@ struct ComposingPrefsView: View { Text("Require Attachment Descriptions") } } + .listRowBackground(Color.appGroupedCellBackground) } var replyingSection: some View { @@ -75,6 +78,7 @@ struct ComposingPrefsView: View { Text("Mention Reblogger") } } + .listRowBackground(Color.appGroupedCellBackground) } var writingSection: some View { @@ -83,6 +87,7 @@ struct ComposingPrefsView: View { Text("Show @ and # on Keyboard") } } + .listRowBackground(Color.appGroupedCellBackground) } } diff --git a/Tusker/Screens/Preferences/MediaPrefsView.swift b/Tusker/Screens/Preferences/MediaPrefsView.swift index aa84b4e0..d358b52b 100644 --- a/Tusker/Screens/Preferences/MediaPrefsView.swift +++ b/Tusker/Screens/Preferences/MediaPrefsView.swift @@ -15,7 +15,8 @@ struct MediaPrefsView: View { List { viewingSection } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle("Media") } @@ -42,6 +43,7 @@ struct MediaPrefsView: View { Text("Show Uncropped Media Inline") } } + .listRowBackground(Color.appGroupedCellBackground) } } diff --git a/Tusker/Screens/Preferences/OppositeCollapseKeywordsView.swift b/Tusker/Screens/Preferences/OppositeCollapseKeywordsView.swift index 9cb844ff..1930d86a 100644 --- a/Tusker/Screens/Preferences/OppositeCollapseKeywordsView.swift +++ b/Tusker/Screens/Preferences/OppositeCollapseKeywordsView.swift @@ -37,9 +37,11 @@ struct OppositeCollapseKeywordsView: View { FocusableTextField(placeholder: "Add Keyword", text: $valueToAdd, becomeFirstResponder: $makeAddFieldFirstResponder, onCommit: self.addKeyword) } + .listRowBackground(Color.appGroupedCellBackground) } .animation(.default, value: keywords.map(\.id)) - .listStyle(GroupedListStyle()) + .listStyle(.grouped) + .appGroupedScrollBackgroundIfAvailable() } .onAppear(perform: updateAppearance) .navigationBarTitle(preferences.expandAllContentWarnings ? "Collapse Post CW Keywords" : "Expand Post CW Keywords") diff --git a/Tusker/Screens/Preferences/PreferencesView.swift b/Tusker/Screens/Preferences/PreferencesView.swift index aec06876..e1e05c35 100644 --- a/Tusker/Screens/Preferences/PreferencesView.swift +++ b/Tusker/Screens/Preferences/PreferencesView.swift @@ -24,8 +24,14 @@ struct PreferencesView: View { aboutSection } .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle("Preferences") .navigationBarTitleDisplayMode(.inline) + .onAppear { + if #unavailable(iOS 16.0) { + UITableView.appearance(whenContainedInInstancesOf: [PreferencesNavigationController.self]).backgroundColor = .appGroupedBackground + } + } } private var accountsSection: some View { @@ -84,6 +90,7 @@ struct PreferencesView: View { } header: { Text("Accounts") } + .listRowBackground(Color.appGroupedCellBackground) } private var preferencesSection: some View { @@ -107,6 +114,7 @@ struct PreferencesView: View { Text("Advanced") } } + .listRowBackground(Color.appGroupedCellBackground) } private var aboutSection: some View { @@ -121,6 +129,7 @@ struct PreferencesView: View { AcknowledgementsView() } } + .listRowBackground(Color.appGroupedCellBackground) } func logoutPressed() { @@ -128,6 +137,20 @@ struct PreferencesView: View { } } +extension View { + @available(iOS, obsoleted: 16.0) + @ViewBuilder + func appGroupedScrollBackgroundIfAvailable() -> some View { + if #available(iOS 16.0, *) { + self + .scrollContentBackground(.hidden) + .background(Color.appGroupedBackground) + } else { + self + } + } +} + //#if DEBUG //struct PreferencesView_Previews : PreviewProvider { // static var previews: some View { diff --git a/Tusker/Screens/Preferences/SwipeActionsPrefsView.swift b/Tusker/Screens/Preferences/SwipeActionsPrefsView.swift index b10fd63e..77017d70 100644 --- a/Tusker/Screens/Preferences/SwipeActionsPrefsView.swift +++ b/Tusker/Screens/Preferences/SwipeActionsPrefsView.swift @@ -42,6 +42,7 @@ class SwipeActionsPrefsViewController: UIViewController, UICollectionViewDelegat override func loadView() { let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in var config = UICollectionLayoutListConfiguration(appearance: .insetGrouped) + config.backgroundColor = .appGroupedBackground if dataSource.sectionIdentifier(for: sectionIndex) == .selected { config.headerMode = .supplementary } @@ -59,6 +60,15 @@ class SwipeActionsPrefsViewController: UIViewController, UICollectionViewDelegat config.image = UIImage(systemName: item.systemImageName) cell.contentConfiguration = config cell.accessories = [.reorder(displayed: .always)] + cell.configurationUpdateHandler = { cell, state in + var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state) + if state.isHighlighted || state.isSelected { + config.backgroundColor = .appSelectedCellBackground + } else { + config.backgroundColor = .appGroupedCellBackground + } + cell.backgroundConfiguration = config + } } let dataSource = UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in return collectionView.dequeueConfiguredReusableCell(using: listCell, for: indexPath, item: itemIdentifier) diff --git a/Tusker/Screens/Preferences/Tip Jar/TipJarView.swift b/Tusker/Screens/Preferences/Tip Jar/TipJarView.swift index 694b1969..8556a8bb 100644 --- a/Tusker/Screens/Preferences/Tip Jar/TipJarView.swift +++ b/Tusker/Screens/Preferences/Tip Jar/TipJarView.swift @@ -26,8 +26,12 @@ struct TipJarView: View { @StateObject private var observer = UbiquitousKeyValueStoreObserver() var body: some View { - productsView - .overlay { + ZStack { + Color.appGroupedBackground + .edgesIgnoringSafeArea(.all) + + productsView + if showConfetti { ConfettiView() .transition(.opacity.animation(.default)) diff --git a/Tusker/Screens/Preferences/WellnessPrefsView.swift b/Tusker/Screens/Preferences/WellnessPrefsView.swift index 57434271..5b232d2b 100644 --- a/Tusker/Screens/Preferences/WellnessPrefsView.swift +++ b/Tusker/Screens/Preferences/WellnessPrefsView.swift @@ -19,7 +19,8 @@ struct WellnessPrefsView: View { disableInfiniteScrolling hideDiscover } - .listStyle(InsetGroupedListStyle()) + .listStyle(.insetGrouped) + .appGroupedScrollBackgroundIfAvailable() .navigationBarTitle(Text("Digital Wellness")) } @@ -29,6 +30,7 @@ struct WellnessPrefsView: View { Text("Favorite and Reblog Counts in Conversations") } } + .listRowBackground(Color.appGroupedCellBackground) } private var notificationsMode: some View { @@ -39,6 +41,7 @@ struct WellnessPrefsView: View { } } } + .listRowBackground(Color.appGroupedCellBackground) } private var grayscaleImages: some View { @@ -47,6 +50,7 @@ struct WellnessPrefsView: View { Text("Grayscale Images") } } + .listRowBackground(Color.appGroupedCellBackground) } private var disableInfiniteScrolling: some View { @@ -55,6 +59,7 @@ struct WellnessPrefsView: View { Text("Disable Infinite Scrolling") } } + .listRowBackground(Color.appGroupedCellBackground) } private var hideDiscover: some View { @@ -63,6 +68,7 @@ struct WellnessPrefsView: View { Text("Hide Discover Section") } } + .listRowBackground(Color.appGroupedCellBackground) } }