Skip to content

Commit

Permalink
Uplift of #25693 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Sep 23, 2024
1 parent 08f7ddf commit 0aaba96
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ private struct ShortcutProvider: IntentTimelineProvider {
}

private struct ShortcutLink<Content: View>: View {
@Environment(\.widgetRenderingMode) private var renderingMode

var url: String
var text: String
var image: Content
Expand Down Expand Up @@ -106,8 +108,8 @@ private struct ShortcutLink<Content: View>: 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
)
}
)
Expand Down Expand Up @@ -189,6 +191,8 @@ extension WidgetShortcut {
}

private struct ShortcutsView: View {
@Environment(\.widgetRenderingMode) private var renderingMode

var slots: [WidgetShortcut]

var body: some View {
Expand All @@ -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
)
}
)
Expand Down
2 changes: 2 additions & 0 deletions ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private struct StatView: View {
Spacer()
Image("brave-icon-no-bg")
.resizable()
.widgetAccentedRenderingModeFullColor()
.aspectRatio(contentMode: .fit)
.frame(height: 24)
.unredacted()
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions ios/brave-ios/App/BraveWidgets/StatsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private struct StatsView: View {
Spacer()
Image("brave-icon-no-bg")
.resizable()
.widgetAccentedRenderingModeFullColor()
.aspectRatio(contentMode: .fit)
.frame(height: 24)
}
Expand All @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -136,6 +141,7 @@ private struct TopNewsListView: View {
.overlay(
Image(uiImage: image)
.resizable()
.widgetAccentedRenderingModeFullColor()
.aspectRatio(contentMode: .fill)
)
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
Expand Down
1 change: 1 addition & 0 deletions ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private struct WidgetTopNewsView: View {
if let image = entry.image {
Image(uiImage: image)
.resizable()
.widgetAccentedRenderingModeFullColor()
.aspectRatio(contentMode: .fill)
.overlay(
LinearGradient(
Expand Down
16 changes: 16 additions & 0 deletions ios/brave-ios/App/BraveWidgets/WidgetAccentable.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}
4 changes: 4 additions & 0 deletions ios/brave-ios/App/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -235,6 +236,7 @@
27D7FF7129BA78820096DD93 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Localizable.strings; sourceTree = "<group>"; };
27DB270728BE9CAE005CB7AC /* LockScreenFavoriteWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LockScreenFavoriteWidget.swift; sourceTree = "<group>"; };
27DD1330284FDAFB004E1E1F /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = Shortcuts/fr.lproj/BrowserIntents.strings; sourceTree = "<group>"; };
27E0E2132CA01629001DA292 /* WidgetAccentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetAccentable.swift; sourceTree = "<group>"; };
27E30417284FDB57009A07F2 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "Shortcuts/pt-BR.lproj/BrowserIntents.strings"; sourceTree = "<group>"; };
27EDE18129A7D98000F34870 /* Debug (AppStore).entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Debug (AppStore).entitlements"; sourceTree = "<group>"; };
27EDE18229A7DA0E00F34870 /* Debug-AppStore.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Debug-AppStore.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -707,6 +709,7 @@
272947DF29C8DE4300BF2FDC /* News Topics */,
27444B6929831B9E002E1EBE /* Development Assets */,
CA0391DA271E12D9000EB13C /* Entitlements */,
27E0E2132CA01629001DA292 /* WidgetAccentable.swift */,
2713FCD72A96429100398A57 /* WidgetBackground.swift */,
27A28ED428C00C19001466A4 /* LockScreenShortcutWidget.swift */,
27DB270728BE9CAE005CB7AC /* LockScreenFavoriteWidget.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down

0 comments on commit 0aaba96

Please sign in to comment.