[iOS] [CodeHealth] SwiftUI listBackgroundColor modifier warning fixes (#35165)

Removes the custom `listBackgroundColor` modifier which was no longer needed and replaces all instances with the expected `scrollContentBackground`/`background` modifiers
This commit is contained in:
Kyle Hickinson
2026-04-02 18:08:13 +02:00
committed by GitHub
parent 2a9104b7ff
commit 4e1fcd989d
50 changed files with 110 additions and 76 deletions
@@ -380,7 +380,8 @@ public struct AIChatAdvancedSettingsView: View {
}
}
}
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.insetGrouped)
}
@@ -55,7 +55,8 @@ struct AIChatDefaultModelView: View {
}
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.insetGrouped)
.navigationTitle(Strings.AIChat.defaultModelViewTitle)
.sheet(isPresented: $isPresentingPaywallPremium) {
@@ -96,7 +96,8 @@ private struct CertificateView: View {
content
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
Button(Strings.done) {
@@ -122,7 +122,8 @@ struct PageZoomSettingsView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.listStyle(.insetGrouped)
}
@@ -123,7 +123,8 @@ extension PrivacyReportsView {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
Spacer()
}
@@ -113,7 +113,8 @@ struct PrivacyReportAllTimeListsView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
private var websitesList: some View {
@@ -137,7 +138,8 @@ struct PrivacyReportAllTimeListsView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
var body: some View {
@@ -109,7 +109,8 @@ struct RecentlyClosedTabsView: View {
}
.environment(\.defaultMinListHeaderHeight, 0)
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
init(tabManager: TabManager? = nil) {
@@ -94,7 +94,8 @@ private struct BasicStringInputView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(coreSwitch.displayString)
.onAppear {
// SwiftUI bug, has to wait a bit
@@ -147,7 +148,8 @@ private struct BasicPickerInputView: View {
.pickerStyle(.inline)
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(coreSwitch.displayString)
.onAppear {
// SwiftUI bug, has to wait a bit
@@ -215,7 +217,8 @@ private struct CustomSwitchInputView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle("Custom Switch")
.onAppear {
// SwiftUI bug, has to wait a bit
@@ -482,7 +485,8 @@ struct BraveCoreDebugSwitchesView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitle("BraveCore Switches")
}
}
@@ -44,7 +44,8 @@ struct BraveSearchDebugMenu: View {
Text(String(describing: storageTypes))
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.onAppear(perform: loadRecords)
}
@@ -36,7 +36,8 @@ struct BraveSearchDebugMenuDetail: View {
)
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
private var cookieNames: String {
@@ -22,7 +22,8 @@ struct BraveWalletDebugMenu: View {
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle("Brave Wallet Debug")
.navigationBarTitleDisplayMode(.inline)
}
@@ -142,7 +142,8 @@ struct SandboxInspectorView: View {
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle("Sandbox Inspector")
.navigationBarTitleDisplayMode(.inline)
.onAppear(perform: getNodes)
@@ -59,7 +59,8 @@ struct FilterListAddURLView: View {
)
}
.animation(.easeInOut, value: errorMessage)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.insetGrouped)
.navigationTitle(Strings.Shields.customFilterList)
.navigationBarTitleDisplayMode(.inline)
@@ -133,7 +133,8 @@ struct ManageWebsiteDataView: View {
.listRowBackground(Color(.braveBackground))
}
.listStyle(.plain)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.environment(\.editMode, $editMode)
.overlay(
Group {
@@ -65,7 +65,8 @@ struct PrivacyReportSettingsView: View {
}
.navigationTitle(Strings.PrivacyHub.privacyReportsTitle)
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
}
@@ -35,7 +35,8 @@ struct WebsiteRedirectsSettingsView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.urlRedirectsSettings)
}
}
@@ -136,7 +136,8 @@ struct PrivateTabsView: View {
}
.navigationBarTitle(Strings.TabsSettings.privateTabsSettingsTitle)
.navigationBarTitleDisplayMode(.inline)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
}
@@ -38,7 +38,8 @@ private struct ChannelListView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.listStyle(.grouped)
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.environment(\.defaultMinListRowHeight, 0)
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.BraveNews.channelsTitle)
@@ -66,7 +66,8 @@ struct FollowingListView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
}
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.grouped)
.environment(\.defaultMinListRowHeight, 0)
.navigationTitle(Strings.BraveNews.followingTitle)
@@ -218,7 +218,8 @@ public struct NewsSettingsView: View {
}
.listStyle(.insetGrouped)
.animation(.default, value: searchDelegate.isEditing)
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.BraveNews.braveNews)
.navigationBarTitleDisplayMode(.inline)
.onChange(of: searchDelegate.query) { _, query in
@@ -114,7 +114,8 @@ struct SearchResultsView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.overlay(
Group {
if results.isEmpty, urlQuery == nil {
@@ -43,7 +43,8 @@ private struct SourceListView: View {
}
}
.environment(\.defaultMinListRowHeight, 44)
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.grouped)
.navigationTitle(Strings.BraveNews.popularSourcesTitle)
.navigationBarTitleDisplayMode(.inline)
@@ -68,7 +68,8 @@ private struct SourceSuggestionsView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.environment(\.defaultMinListRowHeight, 44)
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.listStyle(.grouped)
.navigationTitle(Strings.BraveNews.suggestedTitle)
.navigationBarTitleDisplayMode(.inline)
@@ -197,7 +197,8 @@ public struct BraveNewsDebugSettingsView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle("Brave News QA Settings")
.navigationBarTitleDisplayMode(.inline)
.animation(.default, value: fileList)
@@ -1,21 +0,0 @@
// Copyright 2022 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
import Foundation
import SwiftUI
extension View {
/// Sets the background color of a List when using iOS 16 which is no longer backed by `UITableView`, thus
/// not respecting `UIAppearance` overrides
@available(
iOS,
introduced: 14.0,
deprecated: 16.0,
message: "Use `scrollContentBackground` and `background` directly"
)
public func listBackgroundColor(_ color: Color) -> some View {
return self.scrollContentBackground(.hidden).background(color)
}
}
@@ -53,7 +53,8 @@ struct AccountSelectionRootView: View {
}
}
}
.listBackgroundColor(Color(uiColor: WalletV2Design.containerBackground))
.scrollContentBackground(.hidden)
.background(Color(uiColor: WalletV2Design.containerBackground))
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
}
@@ -113,7 +113,8 @@ struct AccountDetailsView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItemGroup(placement: .cancellationAction) {
@@ -176,7 +176,8 @@ struct MarketView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.background(
NavigationLink(
isActive: Binding(
@@ -209,7 +209,8 @@ struct NFTDetailView: View {
}
}
}
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.onChange(
of: nftDetailStore.nftMetadata,
perform: { newValue in
@@ -102,7 +102,8 @@ struct NetworkSelectionRootView: View {
}
}
}
.listBackgroundColor(Color(uiColor: WalletV2Design.containerBackground))
.scrollContentBackground(.hidden)
.background(Color(uiColor: WalletV2Design.containerBackground))
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -290,7 +290,8 @@ struct AddCustomAssetView: View {
}
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.onChange(
of: selectedTokenType,
perform: { _ in
@@ -159,7 +159,8 @@ struct EditUserAssetsView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.animation(.default, value: tokenStores)
.navigationTitle(Strings.Wallet.editVisibleAssetsButtonTitle)
.navigationBarTitleDisplayMode(.inline)
@@ -47,7 +47,8 @@ struct SelectAccountTokenView: View {
accountSections
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.searchable(
text: $store.query,
placement: .navigationBarDrawer(displayMode: .always)
@@ -110,7 +110,8 @@ struct EditGasFeeView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.Wallet.editGasTitle)
.alert(isPresented: $isShowingAlert) {
@@ -54,7 +54,8 @@ struct EditNonceView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.Wallet.advancedSettingsTransaction)
.alert(isPresented: $isShowingAlert) {
@@ -143,7 +143,8 @@ struct EditPermissionsView: View {
.listRowBackground(Color(.braveGroupedBackground))
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.Wallet.editPermissionsTitle)
.alert(isPresented: $isShowingAlert) {
@@ -282,7 +282,8 @@ struct EditPriorityFeeView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.Wallet.maxPriorityFeeTitle)
.alert(isPresented: $isShowingAlert) {
@@ -72,7 +72,8 @@ struct BuyProviderSelectionView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
}
}
.navigationBarTitleDisplayMode(.inline)
@@ -218,7 +218,8 @@ struct BuyTokenView: View {
}
.environment(\.defaultMinListHeaderHeight, 0)
.environment(\.defaultMinListRowHeight, 0)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.Wallet.buy)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -337,7 +337,8 @@ struct SendTokenView: View {
) {
}
}
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.environment(\.defaultMinListHeaderHeight, 0)
.environment(\.defaultMinListRowHeight, 0)
.alert(isPresented: $isShowingError) {
@@ -611,7 +611,8 @@ struct SwapCryptoView: View {
unsupportedSwapChainSection
}
}
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.environment(\.defaultMinListHeaderHeight, 0)
.environment(\.defaultMinListRowHeight, 0)
.navigationTitle(Strings.Wallet.swap)
@@ -222,7 +222,8 @@ struct SuggestedNetworkView: View {
.accessibility(hidden: sizeCategory.isAccessibilityCategory)
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
.overlay(
@@ -202,7 +202,8 @@ struct EditSiteConnectionView: View {
.padding(.vertical)
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.Wallet.editSiteConnectionScreenTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -169,7 +169,8 @@ public struct NewSiteConnectionView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(Strings.Wallet.newSiteConnectScreenTitle)
.toolbar {
@@ -255,7 +256,8 @@ public struct NewSiteConnectionView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.Wallet.newSiteConnectScreenTitle)
.navigationBarTitleDisplayMode(.inline)
}
@@ -440,7 +440,8 @@ struct NetworkDetailsView: View {
}
}
}
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitle(navigationTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -145,7 +145,8 @@ struct DappsSettings: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(
String.localizedStringWithFormat(Strings.Wallet.dappsSettingsNavTitle, coin.localizedTitle)
)
@@ -297,7 +298,8 @@ private struct SiteConnectionDetailView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
@@ -161,7 +161,8 @@ struct NetworkListView: View {
}
}
.listStyle(.insetGrouped)
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.Wallet.transactionDetailsNetworkTitle)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
@@ -48,7 +48,8 @@ public struct Web3SettingsView: View {
}
}
.listStyle(InsetGroupedListStyle())
.listBackgroundColor(Color(UIColor.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.navigationTitle(Strings.Wallet.web3)
.navigationBarTitleDisplayMode(.inline)
.background(
@@ -88,7 +88,8 @@ struct CredentialDetailView: View {
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
.foregroundColor(Color(braveSystemName: .textPrimary))
.listBackgroundColor(Color(.braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(UIColor.braveGroupedBackground))
.toolbar {
ToolbarItemGroup(placement: .confirmationAction) {
Button {
@@ -159,7 +159,8 @@ public struct CredentialListView: View {
prompt: Text(Strings.CredentialProvider.searchBarPrompt)
)
.listStyle(.insetGrouped)
.listBackgroundColor(Color(uiColor: .braveGroupedBackground))
.scrollContentBackground(.hidden)
.background(Color(uiColor: .braveGroupedBackground))
.toolbar {
ToolbarItemGroup(placement: .cancellationAction) {
Button(Strings.CredentialProvider.cancelButtonTitle) {