Skip to content

Commit a5b6d0f

Browse files
authoredMar 12, 2025
Add FXIOS-11547 Limit iOS 15 - iOS 17 devices to Light mode only App Icons in the App Icon Selection screen (#25219)
* For <iOS 17, do not adapt the app icons displayed in the app icon selection tool since those users have no way to actually change to the Dark Mode icons.
1 parent 5b705b9 commit a5b6d0f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
 

‎BrowserKit/Sources/Common/Theming/ThemeType.swift

+11
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44

55
import Foundation
66
import UIKit
7+
import SwiftUI
78

89
public enum ThemeType: String {
910
case light = "normal" // This needs to match the string used in the legacy system
1011
case dark
1112
case privateMode
1213
case nightMode
1314

15+
/// Returns the SwiftUI ColorScheme for this theme (e.g. to use for image asset selection).
16+
public var colorScheme: ColorScheme {
17+
switch self {
18+
case .light:
19+
return ColorScheme.light
20+
case .dark, .nightMode, .privateMode:
21+
return ColorScheme.dark
22+
}
23+
}
24+
1425
public func getInterfaceStyle() -> UIUserInterfaceStyle {
1526
return switch self {
1627
case .dark, .nightMode, .privateMode: .dark

‎firefox-ios/Client/Frontend/Settings/AppIconSelection/AppIconView.swift

+27
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct AppIconView: View, ThemeApplicable {
1616
// FIXME FXIOS-11472 Improve our SwiftUI theming
1717
@Environment(\.themeManager)
1818
var themeManager
19+
@State var currentTheme: Theme = LightTheme()
1920
@State private var themeColors: ThemeColourPalette = LightTheme().colors
2021

2122
struct UX {
@@ -25,6 +26,8 @@ struct AppIconView: View, ThemeApplicable {
2526
static let itemPaddingVertical: CGFloat = 2
2627
static let appIconSize: CGFloat = 50
2728
static let appIconBorderWidth: CGFloat = 1
29+
static let appIconLightBackgroundColor = Color.white
30+
static let appIconDarkBackgroundColor = UIColor(rgb: 33).color
2831
}
2932

3033
var selectionImageAccessibilityLabel: String {
@@ -59,6 +62,15 @@ struct AppIconView: View, ThemeApplicable {
5962
}
6063
}
6164

65+
/// Devices prior to iOS 18 cannot change their icon display mode with their system settings
66+
var forceLightTheme: Bool {
67+
if #available(iOS 18, *) {
68+
return false
69+
} else {
70+
return true
71+
}
72+
}
73+
6274
private func button(for image: UIImage) -> some View {
6375
Button(action: {
6476
setAppIcon(appIcon)
@@ -68,6 +80,20 @@ struct AppIconView: View, ThemeApplicable {
6880
Image(uiImage: image)
6981
.resizable()
7082
.frame(width: UX.appIconSize, height: UX.appIconSize)
83+
// Note: Do not fallback to the current app theme, because the user can view settings in the private mode
84+
// theme, but app icons can only be Light or Dark
85+
.background(
86+
forceLightTheme
87+
? UX.appIconLightBackgroundColor
88+
: UX.appIconDarkBackgroundColor
89+
)
90+
// Pre iOS 18, force Light mode for the icons since users will only ever see Light home screen icons
91+
// Note: This fix does not work on iOS15 but it's a small user base
92+
.colorScheme(
93+
forceLightTheme
94+
? ColorScheme.light
95+
: currentTheme.type.colorScheme
96+
)
7197
.cornerRadius(UX.cornerRadius)
7298
.overlay(
7399
// Add rounded border
@@ -91,6 +117,7 @@ struct AppIconView: View, ThemeApplicable {
91117
}
92118

93119
func applyTheme(theme: Theme) {
120+
self.currentTheme = theme
94121
self.themeColors = theme.colors
95122
}
96123
}

0 commit comments

Comments
 (0)
Failed to load comments.