Mode non-pure-black dark mode stuff to dedicated modifiers

This commit is contained in:
Shadowfacts 2023-02-06 18:42:55 -05:00
parent 4ea2dff8f1
commit 04ca932a01
20 changed files with 121 additions and 116 deletions

View File

@ -299,6 +299,7 @@
D6C3F4F7298ED7F70009FCFF /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */; }; D6C3F4F7298ED7F70009FCFF /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */; };
D6C3F4F9298EDBF20009FCFF /* ConversationTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */; }; D6C3F4F9298EDBF20009FCFF /* ConversationTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */; };
D6C3F4FB299035650009FCFF /* TrendsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4FA299035650009FCFF /* TrendsViewController.swift */; }; D6C3F4FB299035650009FCFF /* TrendsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4FA299035650009FCFF /* TrendsViewController.swift */; };
D6C3F5172991C1A00009FCFF /* View+AppListStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */; };
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; }; D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */; }; D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */; };
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */; }; D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */; };
@ -712,6 +713,7 @@
D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; }; D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationTree.swift; sourceTree = "<group>"; }; D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationTree.swift; sourceTree = "<group>"; };
D6C3F4FA299035650009FCFF /* TrendsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendsViewController.swift; sourceTree = "<group>"; }; D6C3F4FA299035650009FCFF /* TrendsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendsViewController.swift; sourceTree = "<group>"; };
D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+AppListStyle.swift"; sourceTree = "<group>"; };
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; }; D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; }; D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; };
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; }; D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; };
@ -1309,6 +1311,7 @@
D63CC70F2911F1E4000E19DE /* UIScrollView+Top.swift */, D63CC70F2911F1E4000E19DE /* UIScrollView+Top.swift */,
D61F758F29353B4300C0B37F /* FileManager+Size.swift */, D61F758F29353B4300C0B37F /* FileManager+Size.swift */,
D61F75AC293AF39000C0B37F /* Filter+Helpers.swift */, D61F75AC293AF39000C0B37F /* Filter+Helpers.swift */,
D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */,
); );
path = Extensions; path = Extensions;
sourceTree = "<group>"; sourceTree = "<group>";
@ -2246,6 +2249,7 @@
D6E426B325337C7000C02E1C /* CustomEmojiImageView.swift in Sources */, D6E426B325337C7000C02E1C /* CustomEmojiImageView.swift in Sources */,
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */, D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,
D61F75B3293BD89C00C0B37F /* UpdateFilterService.swift in Sources */, D61F75B3293BD89C00C0B37F /* UpdateFilterService.swift in Sources */,
D6C3F5172991C1A00009FCFF /* View+AppListStyle.swift in Sources */,
D65B4B6A297777D900DABDFB /* StatusNotFoundView.swift in Sources */, D65B4B6A297777D900DABDFB /* StatusNotFoundView.swift in Sources */,
D6412B0924B0291E00F5412E /* MyProfileViewController.swift in Sources */, D6412B0924B0291E00F5412E /* MyProfileViewController.swift in Sources */,
D601FA5D297B2E6F00A8E8B5 /* ConversationCollectionViewController.swift in Sources */, D601FA5D297B2E6F00A8E8B5 /* ConversationCollectionViewController.swift in Sources */,

View File

@ -0,0 +1,48 @@
//
// View+AppListStyle.swift
// Tusker
//
// Created by Shadowfacts on 2/6/23.
// Copyright © 2023 Shadowfacts. All rights reserved.
//
import SwiftUI
import Combine
extension View {
@ViewBuilder
func appGroupedListBackground(container: UIAppearanceContainer.Type, applyBackground: Bool = true) -> some View {
if #available(iOS 16.0, *) {
if applyBackground {
self
.scrollContentBackground(.hidden)
.background(Color.appGroupedBackground.edgesIgnoringSafeArea(.all))
} else {
self
.scrollContentBackground(.hidden)
}
} else {
self
.onAppear {
UITableView.appearance(whenContainedInInstancesOf: [container]).backgroundColor = .appGroupedBackground
}
}
}
func appGroupedListRowBackground() -> some View {
self.modifier(AppGroupedListRowBackground())
}
}
private struct AppGroupedListRowBackground: ViewModifier {
@Environment(\.colorScheme) private var colorScheme
func body(content: Content) -> some View {
if colorScheme == .dark, !Preferences.shared.pureBlackDarkMode {
content
.listRowBackground(Color.appGroupedCellBackground)
} else {
content
}
}
}

View File

@ -328,7 +328,7 @@ struct ComposeView: View {
} }
} }
private extension View { extension View {
@available(iOS, obsoleted: 16.0) @available(iOS, obsoleted: 16.0)
@ViewBuilder @ViewBuilder
func scrollDismissesKeyboardInteractivelyIfAvailable() -> some View { func scrollDismissesKeyboardInteractivelyIfAvailable() -> some View {

View File

@ -16,7 +16,6 @@ struct AddHashtagPinnedTimelineRepresentable: UIViewControllerRepresentable {
@Binding var pinnedTimelines: [PinnedTimeline] @Binding var pinnedTimelines: [PinnedTimeline]
func makeUIViewController(context: Context) -> UIHostingController<AddHashtagPinnedTimelineView> { func makeUIViewController(context: Context) -> UIHostingController<AddHashtagPinnedTimelineView> {
UITableView.appearance(whenContainedInInstancesOf: [UIViewControllerType.self]).backgroundColor = .appGroupedBackground
return UIHostingController(rootView: AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines)) return UIHostingController(rootView: AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines))
} }
@ -49,6 +48,8 @@ struct AddHashtagPinnedTimelineView: View {
var body: some View { var body: some View {
NavigationView { NavigationView {
list list
.listStyle(.grouped)
.appGroupedListBackground(container: AddHashtagPinnedTimelineRepresentable.UIViewControllerType.self)
.navigationTitle("Add Hashtag") .navigationTitle("Add Hashtag")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.searchable(text: $viewModel.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: Text("Search for hashtags")) .searchable(text: $viewModel.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: Text("Search for hashtags"))
@ -89,7 +90,7 @@ struct AddHashtagPinnedTimelineView: View {
.listRowBackground(EmptyView()) .listRowBackground(EmptyView())
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.listStyle(.grouped) .listStyle(.grouped)

View File

@ -31,15 +31,10 @@ struct CustomizeTimelinesList: View {
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
NavigationStack { NavigationStack {
navigationBody navigationBody
.scrollContentBackground(.hidden)
.background(Color.appGroupedBackground)
} }
} else { } else {
NavigationView { NavigationView {
navigationBody navigationBody
.onAppear {
UITableView.appearance(whenContainedInInstancesOf: [UIHostingController<CustomizeTimelinesView>.self]).backgroundColor = .appGroupedBackground
}
} }
.navigationViewStyle(.stack) .navigationViewStyle(.stack)
} }
@ -56,7 +51,7 @@ struct CustomizeTimelinesList: View {
private var navigationBody: some View { private var navigationBody: some View {
List { List {
PinnedTimelinesView(accountPreferences: mastodonController.accountPreferences) PinnedTimelinesView(accountPreferences: mastodonController.accountPreferences)
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
Toggle(isOn: $preferences.hideReblogsInTimelines) { Toggle(isOn: $preferences.hideReblogsInTimelines) {
@ -68,7 +63,7 @@ struct CustomizeTimelinesList: View {
} header: { } header: {
Text("Home Timeline") Text("Home Timeline")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
filtersForEach(unexpiredFilters) filtersForEach(unexpiredFilters)
@ -82,7 +77,7 @@ struct CustomizeTimelinesList: View {
} header: { } header: {
Text("Active Filters") Text("Active Filters")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
if !expiredFilters.isEmpty { if !expiredFilters.isEmpty {
Section { Section {
@ -90,10 +85,11 @@ struct CustomizeTimelinesList: View {
} header: { } header: {
Text("Expired Filters") Text("Expired Filters")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedListBackground(container: UIHostingController<CustomizeTimelinesList>.self)
.navigationTitle(Text("Customize Timelines")) .navigationTitle(Text("Customize Timelines"))
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {

View File

@ -72,7 +72,7 @@ struct EditFilterView: View {
filter.title = newValue filter.title = newValue
})) }))
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
Section { Section {
@ -97,7 +97,7 @@ struct EditFilterView: View {
} }
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
if mastodonController.instanceFeatures.filtersV2 { if mastodonController.instanceFeatures.filtersV2 {
@ -122,7 +122,7 @@ struct EditFilterView: View {
} }
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
ForEach(FilterV1.Context.allCases, id: \.rawValue) { context in ForEach(FilterV1.Context.allCases, id: \.rawValue) { context in
@ -144,9 +144,10 @@ struct EditFilterView: View {
} header: { } header: {
Text("Contexts") Text("Contexts")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.scrollContentBackgroundIfAvailable() .appGroupedListBackground(container: UIHostingController<CustomizeTimelinesList>.self)
.scrollDismissesKeyboardInteractivelyIfAvailable()
.navigationTitle(create ? "Add Filter" : "Edit Filter") .navigationTitle(create ? "Add Filter" : "Edit Filter")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
@ -213,20 +214,6 @@ private struct FilterContextToggleStyle: ToggleStyle {
} }
} }
private extension View {
@available(iOS, obsoleted: 16.0)
@ViewBuilder
func scrollContentBackgroundIfAvailable() -> some View {
if #available(iOS 16.0, *) {
self
.scrollContentBackground(.hidden)
.background(Color.appGroupedBackground)
} else {
self
}
}
}
//struct EditFilterView_Previews: PreviewProvider { //struct EditFilterView_Previews: PreviewProvider {
// static var previews: some View { // static var previews: some View {
// EditFilterView() // EditFilterView()

View File

@ -43,15 +43,10 @@ struct MuteAccountView: View {
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
NavigationStack { NavigationStack {
navigationViewContent navigationViewContent
.scrollContentBackground(.hidden)
.background(Color.appGroupedBackground)
} }
} else { } else {
NavigationView { NavigationView {
navigationViewContent navigationViewContent
.onAppear {
UITableView.appearance(whenContainedInInstancesOf: [UIHostingController<MuteAccountView>.self]).backgroundColor = .appGroupedBackground
}
} }
.navigationViewStyle(.stack) .navigationViewStyle(.stack)
} }
@ -90,7 +85,7 @@ struct MuteAccountView: View {
Text("This user's posts will be hidden from your timeline. You can still receive notifications from them.") Text("This user's posts will be hidden from your timeline. You can still receive notifications from them.")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
Picker(selection: $duration) { Picker(selection: $duration) {
@ -105,7 +100,7 @@ struct MuteAccountView: View {
Text("The mute will automatically be removed after the selected time.") Text("The mute will automatically be removed after the selected time.")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Button(action: self.mute) { Button(action: self.mute) {
if isMuting { if isMuting {
@ -120,8 +115,9 @@ struct MuteAccountView: View {
} }
} }
.disabled(isMuting) .disabled(isMuting)
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.appGroupedListBackground(container: UIHostingController<MuteAccountView>.self)
.alertWithData("Erorr Muting", data: $error, actions: { error in .alertWithData("Erorr Muting", data: $error, actions: { error in
Button("OK") {} Button("OK") {}
}, message: { error in }, message: { error in

View File

@ -42,7 +42,7 @@ struct AboutView: View {
} }
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
Link("Website", destination: URL(string: "https://vaccor.space/tusker")!) Link("Website", destination: URL(string: "https://vaccor.space/tusker")!)
@ -68,10 +68,10 @@ struct AboutView: View {
Link("Source Code", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker")!) 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")!) Link("Issue Tracker", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker/issues")!)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.sheet(isPresented: $isShowingMailSheet) { .sheet(isPresented: $isShowingMailSheet) {
MailSheet(logData: logData) MailSheet(logData: logData)
} }

View File

@ -14,7 +14,7 @@ struct AcknowledgementsView: View {
Text(text) Text(text)
.padding(.horizontal, 16) .padding(.horizontal, 16)
} }
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationTitle("Acknowledgements") .navigationTitle("Acknowledgements")
} }

View File

@ -24,7 +24,7 @@ struct AdvancedPrefsView : View {
cachingSection cachingSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle(Text("Advanced")) .navigationBarTitle(Text("Advanced"))
} }
@ -51,7 +51,7 @@ struct AdvancedPrefsView : View {
// see FB6838291 // see FB6838291
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
var cloudKitSection: some View { var cloudKitSection: some View {
@ -77,7 +77,7 @@ struct AdvancedPrefsView : View {
} }
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
.task { .task {
CKContainer.default().accountStatus { status, error in CKContainer.default().accountStatus { status, error in
if let error { if let error {
@ -103,7 +103,7 @@ struct AdvancedPrefsView : View {
.lineLimit(nil) .lineLimit(nil)
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
var cachingSection: some View { var cachingSection: some View {
@ -126,7 +126,7 @@ struct AdvancedPrefsView : View {
} }
return Text(s) return Text(s)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
.task { .task {
imageCacheSize = [ imageCacheSize = [
ImageCache.avatars, ImageCache.avatars,

View File

@ -49,7 +49,7 @@ struct AppearancePrefsView : View {
postsSection postsSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle(Text("Appearance")) .navigationBarTitle(Text("Appearance"))
} }
@ -81,7 +81,7 @@ struct AppearancePrefsView : View {
.onReceive(appearanceChangePublisher) { _ in .onReceive(appearanceChangePublisher) { _ in
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil) NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var accountsSection: some View { private var accountsSection: some View {
@ -93,7 +93,7 @@ struct AppearancePrefsView : View {
Text("Hide Custom Emoji in Usernames") Text("Hide Custom Emoji in Usernames")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var postsSection: some View { private var postsSection: some View {
@ -121,7 +121,7 @@ struct AppearancePrefsView : View {
.navigationTitle("Trailing Swipe Actions") .navigationTitle("Trailing Swipe Actions")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }

View File

@ -19,7 +19,7 @@ struct BehaviorPrefsView: View {
contentWarningsSection contentWarningsSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle(Text("Behavior")) .navigationBarTitle(Text("Behavior"))
} }
@ -29,7 +29,7 @@ struct BehaviorPrefsView: View {
Text("Require Confirmation Before Reblogging") Text("Require Confirmation Before Reblogging")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var timelineSection: some View { private var timelineSection: some View {
@ -40,7 +40,7 @@ struct BehaviorPrefsView: View {
} header: { } header: {
Text("Timeline") Text("Timeline")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var linksSection: some View { private var linksSection: some View {
@ -55,7 +55,7 @@ struct BehaviorPrefsView: View {
Text("Always Use Reader Mode in In-App Safari") Text("Always Use Reader Mode in In-App Safari")
}.disabled(!preferences.useInAppSafari) }.disabled(!preferences.useInAppSafari)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var contentWarningsSection: some View { private var contentWarningsSection: some View {
@ -72,7 +72,7 @@ struct BehaviorPrefsView: View {
Text(preferences.expandAllContentWarnings ? "Collapse Posts with Keywords in CWs" : "Expand Posts with Keywords in CWs") Text(preferences.expandAllContentWarnings ? "Collapse Posts with Keywords in CWs" : "Expand Posts with Keywords in CWs")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }

View File

@ -20,7 +20,7 @@ struct ComposingPrefsView: View {
writingSection writingSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle("Composing") .navigationBarTitle("Composing")
} }
@ -52,7 +52,7 @@ struct ComposingPrefsView: View {
} footer: { } 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.") 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) .appGroupedListRowBackground()
} }
var composingSection: some View { var composingSection: some View {
@ -64,7 +64,7 @@ struct ComposingPrefsView: View {
Text("Require Attachment Descriptions") Text("Require Attachment Descriptions")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
var replyingSection: some View { var replyingSection: some View {
@ -78,7 +78,7 @@ struct ComposingPrefsView: View {
Text("Mention Reblogger") Text("Mention Reblogger")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
var writingSection: some View { var writingSection: some View {
@ -87,7 +87,7 @@ struct ComposingPrefsView: View {
Text("Show @ and # on Keyboard") Text("Show @ and # on Keyboard")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }

View File

@ -16,7 +16,7 @@ struct MediaPrefsView: View {
viewingSection viewingSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle("Media") .navigationBarTitle("Media")
} }
@ -43,7 +43,7 @@ struct MediaPrefsView: View {
Text("Show Uncropped Media Inline") Text("Show Uncropped Media Inline")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }

View File

@ -23,8 +23,8 @@ struct OppositeCollapseKeywordsView: View {
ZStack { ZStack {
// the background from the grouped ListStyle clips to the safe area, so when the keyboard is hiding/showing // the background from the grouped ListStyle clips to the safe area, so when the keyboard is hiding/showing
// the color behind it can be seen, which looks odd // the color behind it can be seen, which looks odd
Color(UIColor.secondarySystemBackground) // Color(UIColor.secondarySystemBackground)
.edgesIgnoringSafeArea(.bottom) // .edgesIgnoringSafeArea(.bottom)
List { List {
Section(footer: Text("A post matches if its content warning contains the text of a keyword, ignoring case.")) { Section(footer: Text("A post matches if its content warning contains the text of a keyword, ignoring case.")) {
@ -37,11 +37,11 @@ struct OppositeCollapseKeywordsView: View {
FocusableTextField(placeholder: "Add Keyword", text: $valueToAdd, becomeFirstResponder: $makeAddFieldFirstResponder, onCommit: self.addKeyword) FocusableTextField(placeholder: "Add Keyword", text: $valueToAdd, becomeFirstResponder: $makeAddFieldFirstResponder, onCommit: self.addKeyword)
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.animation(.default, value: keywords.map(\.id)) .animation(.default, value: keywords.map(\.id))
.listStyle(.grouped) .listStyle(.grouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
} }
.onAppear(perform: updateAppearance) .onAppear(perform: updateAppearance)
.navigationBarTitle(preferences.expandAllContentWarnings ? "Collapse Post CW Keywords" : "Expand Post CW Keywords") .navigationBarTitle(preferences.expandAllContentWarnings ? "Collapse Post CW Keywords" : "Expand Post CW Keywords")

View File

@ -24,14 +24,9 @@ struct PreferencesView: View {
aboutSection aboutSection
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle("Preferences") .navigationBarTitle("Preferences")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.onAppear {
if #unavailable(iOS 16.0) {
UITableView.appearance(whenContainedInInstancesOf: [PreferencesNavigationController.self]).backgroundColor = .appGroupedBackground
}
}
} }
private var accountsSection: some View { private var accountsSection: some View {
@ -90,7 +85,7 @@ struct PreferencesView: View {
} header: { } header: {
Text("Accounts") Text("Accounts")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var preferencesSection: some View { private var preferencesSection: some View {
@ -114,7 +109,7 @@ struct PreferencesView: View {
Text("Advanced") Text("Advanced")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var aboutSection: some View { private var aboutSection: some View {
@ -129,7 +124,7 @@ struct PreferencesView: View {
AcknowledgementsView() AcknowledgementsView()
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
func logoutPressed() { func logoutPressed() {
@ -137,20 +132,6 @@ 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 //#if DEBUG
//struct PreferencesView_Previews : PreviewProvider { //struct PreferencesView_Previews : PreviewProvider {
// static var previews: some View { // static var previews: some View {

View File

@ -20,7 +20,7 @@ struct WellnessPrefsView: View {
hideTrends hideTrends
} }
.listStyle(.insetGrouped) .listStyle(.insetGrouped)
.appGroupedScrollBackgroundIfAvailable() .appGroupedListBackground(container: PreferencesNavigationController.self)
.navigationBarTitle(Text("Digital Wellness")) .navigationBarTitle(Text("Digital Wellness"))
} }
@ -30,7 +30,7 @@ struct WellnessPrefsView: View {
Text("Favorite and Reblog Counts in Conversations") Text("Favorite and Reblog Counts in Conversations")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var notificationsMode: some View { private var notificationsMode: some View {
@ -41,7 +41,7 @@ struct WellnessPrefsView: View {
} }
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var grayscaleImages: some View { private var grayscaleImages: some View {
@ -50,7 +50,7 @@ struct WellnessPrefsView: View {
Text("Grayscale Images") Text("Grayscale Images")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var disableInfiniteScrolling: some View { private var disableInfiniteScrolling: some View {
@ -59,7 +59,7 @@ struct WellnessPrefsView: View {
Text("Disable Infinite Scrolling") Text("Disable Infinite Scrolling")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
private var hideTrends: some View { private var hideTrends: some View {
@ -68,7 +68,7 @@ struct WellnessPrefsView: View {
Text("Hide Trends") Text("Hide Trends")
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
} }

View File

@ -34,7 +34,7 @@ struct ReportAddStatusView: View {
ReportStatusView(status: status, mastodonController: mastodonController) ReportStatusView(status: status, mastodonController: mastodonController)
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.modifier(ScrollBackgroundModifier()) .modifier(ScrollBackgroundModifier())
} else { } else {

View File

@ -47,7 +47,7 @@ struct ReportSelectRulesView: View {
.foregroundColor(selectedRuleIDs.contains(rule.id) ? .accentColor : .clear) .foregroundColor(selectedRuleIDs.contains(rule.id) ? .accentColor : .clear)
} }
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.withAppBackgroundIfAvailable() .withAppBackgroundIfAvailable()
.navigationTitle("Rules") .navigationTitle("Rules")

View File

@ -31,22 +31,12 @@ struct ReportView: View {
var body: some View { var body: some View {
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
NavigationStack { NavigationStack {
ZStack { navigationViewContent
// .background doesn't work because it somehow changes color when the keyboard appears .scrollDismissesKeyboard(.interactively)
Color.appGroupedBackground
.edgesIgnoringSafeArea(.all)
navigationViewContent
.scrollContentBackground(.hidden)
.scrollDismissesKeyboard(.interactively)
}
} }
} else { } else {
NavigationView { NavigationView {
navigationViewContent navigationViewContent
.onAppear {
UITableView.appearance(whenContainedInInstancesOf: [UIHostingController<ReportView>.self]).backgroundColor = .appGroupedBackground
}
} }
.navigationViewStyle(.stack) .navigationViewStyle(.stack)
} }
@ -104,14 +94,14 @@ struct ReportView: View {
} header: { } header: {
Text("Reason") Text("Reason")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
ComposeTextView(text: $report.comment, placeholder: Text("Add any additional comments")) ComposeTextView(text: $report.comment, placeholder: Text("Add any additional comments"))
.backgroundColor(.clear) .backgroundColor(.clear)
.listRowInsets(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8)) .listRowInsets(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
ForEach(report.statusIDs, id: \.self) { id in ForEach(report.statusIDs, id: \.self) { id in
@ -129,14 +119,14 @@ struct ReportView: View {
} footer: { } footer: {
Text("Attach posts to your report to provide additional context for moderators.") Text("Attach posts to your report to provide additional context for moderators.")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Section { Section {
Toggle("Forward", isOn: $report.forward) Toggle("Forward", isOn: $report.forward)
} footer: { } footer: {
Text("You can choose to anonymously forward your report to the moderators of **\(account.url.host!)**.") Text("You can choose to anonymously forward your report to the moderators of **\(account.url.host!)**.")
} }
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
Button(action: self.sendReport) { Button(action: self.sendReport) {
if isReporting { if isReporting {
@ -149,8 +139,10 @@ struct ReportView: View {
} }
} }
.disabled(isReporting) .disabled(isReporting)
.listRowBackground(Color.appGroupedCellBackground) .appGroupedListRowBackground()
} }
.listStyle(.insetGrouped)
.appGroupedListBackground(container: UIHostingController<ReportView>.self, applyBackground: true)
.alertWithData("Error Reporting", data: $error, actions: { error in .alertWithData("Error Reporting", data: $error, actions: { error in
Button("OK") {} Button("OK") {}
}, message: { error in }, message: { error in