diff --git a/ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift b/ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift index c21116a4f0e3..b10e8597aa37 100644 --- a/ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift @@ -54,6 +54,7 @@ struct FaviconImage: View { var body: some View { Image(uiImage: image) .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(1, contentMode: .fit) .frame(maxWidth: .infinity, maxHeight: .infinity) .clipped() @@ -65,6 +66,7 @@ private struct NoFavoritesFoundView: View { var body: some View { VStack { Image("brave-icon") + .widgetAccentedRenderingModeFullColor() .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) Text(Strings.Widgets.noFavoritesFound) .multilineTextAlignment(.center) diff --git a/ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift b/ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift index 957875e7661d..4b017a2c6ac6 100644 --- a/ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift @@ -78,6 +78,8 @@ private struct ShortcutProvider: IntentTimelineProvider { } private struct ShortcutLink: View { + @Environment(\.widgetRenderingMode) private var renderingMode + var url: String var text: String var image: Content @@ -106,8 +108,8 @@ private struct ShortcutLink: View { .foregroundColor(Color(UIColor.braveLabel)) .frame(maxWidth: .infinity, maxHeight: .infinity) .background( - Color(UIColor.braveBackground) - .clipShape(ContainerRelativeShape()) + renderingMode == .accented ? Color.white.opacity(0.1) : Color(UIColor.braveBackground), + in: .containerRelative ) } ) @@ -189,6 +191,8 @@ extension WidgetShortcut { } private struct ShortcutsView: View { + @Environment(\.widgetRenderingMode) private var renderingMode + var slots: [WidgetShortcut] var body: some View { @@ -203,13 +207,15 @@ private struct ShortcutsView: View { Text(Strings.Widgets.shortcutsEnterURLButton) } icon: { Image("brave-logo-no-bg-small") + .widgetAccentedRenderingModeFullColor() } .foregroundColor(Color(UIColor.braveLabel)) .frame(maxWidth: .infinity) .frame(height: 44) .background( - Color(UIColor.braveBackground) - .clipShape(ContainerRelativeShape()) + renderingMode == .accented + ? Color.white.opacity(0.1) : Color(UIColor.braveBackground), + in: .containerRelative ) } ) diff --git a/ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift b/ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift index 91d3e67c6bf3..cd80539e5117 100644 --- a/ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift @@ -78,6 +78,7 @@ private struct StatView: View { Spacer() Image("brave-icon-no-bg") .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(contentMode: .fit) .frame(height: 24) .unredacted() @@ -86,6 +87,7 @@ private struct StatView: View { Text(verbatim: entry.statData.value) .font(.system(size: 40)) .foregroundColor(Color(entry.statData.color)) + .widgetAccentable() Text(verbatim: entry.statData.name) .font(.system(size: 17)) .bold() diff --git a/ios/brave-ios/App/BraveWidgets/StatsWidget.swift b/ios/brave-ios/App/BraveWidgets/StatsWidget.swift index 319032aeea02..52e63b9c4a7b 100644 --- a/ios/brave-ios/App/BraveWidgets/StatsWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/StatsWidget.swift @@ -65,6 +65,7 @@ private struct StatsView: View { Spacer() Image("brave-icon-no-bg") .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(contentMode: .fit) .frame(height: 24) } @@ -78,6 +79,7 @@ private struct StatsView: View { Text(verbatim: placeholderOrPrivacyRedaction ? "-" : data.value) .font(.system(size: 32.0)) .foregroundColor(Color(data.color)) + .widgetAccentable() .minimumScaleFactor(0.5) .lineLimit(1) .unredacted() diff --git a/ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift b/ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift index b711cf0d995a..e8685b9e73dd 100644 --- a/ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift @@ -69,6 +69,7 @@ private struct TopNewsListWidgetProvider: TimelineProvider { } private struct TopNewsListView: View { + @Environment(\.widgetRenderingMode) private var widgetRenderingMode @Environment(\.pixelLength) var pixelLength @Environment(\.widgetFamily) var widgetFamily var entry: TopNewsListEntry @@ -78,6 +79,7 @@ private struct TopNewsListView: View { HStack(spacing: 4) { Image("brave-icon-no-bg") .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(contentMode: .fit) .frame(width: 16, height: 16) Text(Strings.Widgets.braveNews) @@ -106,7 +108,10 @@ private struct TopNewsListView: View { if let topics = entry.topics, !topics.isEmpty { VStack(alignment: .leading, spacing: widgetFamily == .systemLarge ? 12 : 8) { headerView - .background(Color(.braveGroupedBackground)) + .background( + widgetRenderingMode == .accented + ? Color.white.opacity(0.1) : Color(.braveGroupedBackground) + ) VStack(alignment: .leading, spacing: 8) { ForEach(topics.prefix(widgetFamily == .systemLarge ? 5 : 2)) { topic in HStack { @@ -136,6 +141,7 @@ private struct TopNewsListView: View { .overlay( Image(uiImage: image) .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(contentMode: .fill) ) .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) diff --git a/ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift b/ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift index 1eca11c9a454..f9807b36b3ad 100644 --- a/ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift +++ b/ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift @@ -208,6 +208,7 @@ private struct WidgetTopNewsView: View { if let image = entry.image { Image(uiImage: image) .resizable() + .widgetAccentedRenderingModeFullColor() .aspectRatio(contentMode: .fill) .overlay( LinearGradient( diff --git a/ios/brave-ios/App/BraveWidgets/WidgetAccentable.swift b/ios/brave-ios/App/BraveWidgets/WidgetAccentable.swift new file mode 100644 index 000000000000..0321dba6aaec --- /dev/null +++ b/ios/brave-ios/App/BraveWidgets/WidgetAccentable.swift @@ -0,0 +1,16 @@ +// Copyright 2024 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 SwiftUI + +extension Image { + func widgetAccentedRenderingModeFullColor() -> some View { + if #available(iOS 18.0, *) { + return self.widgetAccentedRenderingMode(.fullColor) + } else { + return self + } + } +} diff --git a/ios/brave-ios/App/Client.xcodeproj/project.pbxproj b/ios/brave-ios/App/Client.xcodeproj/project.pbxproj index 5b90a8a9b9e2..2024baff4f22 100644 --- a/ios/brave-ios/App/Client.xcodeproj/project.pbxproj +++ b/ios/brave-ios/App/Client.xcodeproj/project.pbxproj @@ -48,6 +48,7 @@ 27D7FF7329BB816E0096DD93 /* PrivateCDN in Frameworks */ = {isa = PBXBuildFile; productRef = 27D7FF7229BB816E0096DD93 /* PrivateCDN */; }; 27D972E628BD4D9900DDCF79 /* BraveNews in Frameworks */ = {isa = PBXBuildFile; productRef = 27D972E528BD4D9900DDCF79 /* BraveNews */; }; 27DB270828BE9CB4005CB7AC /* LockScreenFavoriteWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27DB270728BE9CAE005CB7AC /* LockScreenFavoriteWidget.swift */; }; + 27E0E2142CA0162D001DA292 /* WidgetAccentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27E0E2132CA01629001DA292 /* WidgetAccentable.swift */; }; 27E998272B7BE1BC00D9ECF7 /* BraveCore in Frameworks */ = {isa = PBXBuildFile; productRef = 27E998262B7BE1BC00D9ECF7 /* BraveCore */; }; 27F4439F2135E11200296C58 /* ShareExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 27F443952135E11200296C58 /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 27F443AD2135E25300296C58 /* ShareToBraveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F443AC2135E25300296C58 /* ShareToBraveViewController.swift */; }; @@ -235,6 +236,7 @@ 27D7FF7129BA78820096DD93 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Localizable.strings; sourceTree = ""; }; 27DB270728BE9CAE005CB7AC /* LockScreenFavoriteWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenFavoriteWidget.swift; sourceTree = ""; }; 27DD1330284FDAFB004E1E1F /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Shortcuts/fr.lproj/BrowserIntents.strings; sourceTree = ""; }; + 27E0E2132CA01629001DA292 /* WidgetAccentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetAccentable.swift; sourceTree = ""; }; 27E30417284FDB57009A07F2 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "Shortcuts/pt-BR.lproj/BrowserIntents.strings"; sourceTree = ""; }; 27EDE18129A7D98000F34870 /* Debug (AppStore).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Debug (AppStore).entitlements"; sourceTree = ""; }; 27EDE18229A7DA0E00F34870 /* Debug-AppStore.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Debug-AppStore.xcconfig"; sourceTree = ""; }; @@ -707,6 +709,7 @@ 272947DF29C8DE4300BF2FDC /* News Topics */, 27444B6929831B9E002E1EBE /* Development Assets */, CA0391DA271E12D9000EB13C /* Entitlements */, + 27E0E2132CA01629001DA292 /* WidgetAccentable.swift */, 2713FCD72A96429100398A57 /* WidgetBackground.swift */, 27A28ED428C00C19001466A4 /* LockScreenShortcutWidget.swift */, 27DB270728BE9CAE005CB7AC /* LockScreenFavoriteWidget.swift */, @@ -1245,6 +1248,7 @@ CA0391FB271E143F000EB13C /* StatsWidget.swift in Sources */, 2713FCD82A96429600398A57 /* WidgetBackground.swift in Sources */, CA0391F8271E143F000EB13C /* ShortcutsWidget.swift in Sources */, + 27E0E2142CA0162D001DA292 /* WidgetAccentable.swift in Sources */, 27DB270828BE9CB4005CB7AC /* LockScreenFavoriteWidget.swift in Sources */, 441A6360272445F9001492C3 /* StatDataModel.swift in Sources */, 2F4A572529E608CC003454F8 /* BrowserIntents.intentdefinition in Sources */,