@@ -16,6 +16,7 @@ struct AppIconView: View, ThemeApplicable {
16
16
// FIXME FXIOS-11472 Improve our SwiftUI theming
17
17
@Environment ( \. themeManager)
18
18
var themeManager
19
+ @State var currentTheme : Theme = LightTheme ( )
19
20
@State private var themeColors : ThemeColourPalette = LightTheme ( ) . colors
20
21
21
22
struct UX {
@@ -25,6 +26,8 @@ struct AppIconView: View, ThemeApplicable {
25
26
static let itemPaddingVertical : CGFloat = 2
26
27
static let appIconSize : CGFloat = 50
27
28
static let appIconBorderWidth : CGFloat = 1
29
+ static let appIconLightBackgroundColor = Color . white
30
+ static let appIconDarkBackgroundColor = UIColor ( rgb: 33 ) . color
28
31
}
29
32
30
33
var selectionImageAccessibilityLabel : String {
@@ -59,6 +62,15 @@ struct AppIconView: View, ThemeApplicable {
59
62
}
60
63
}
61
64
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
+
62
74
private func button( for image: UIImage ) -> some View {
63
75
Button ( action: {
64
76
setAppIcon ( appIcon)
@@ -68,6 +80,20 @@ struct AppIconView: View, ThemeApplicable {
68
80
Image ( uiImage: image)
69
81
. resizable ( )
70
82
. 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
+ )
71
97
. cornerRadius ( UX . cornerRadius)
72
98
. overlay (
73
99
// Add rounded border
@@ -91,6 +117,7 @@ struct AppIconView: View, ThemeApplicable {
91
117
}
92
118
93
119
func applyTheme( theme: Theme ) {
120
+ self . currentTheme = theme
94
121
self . themeColors = theme. colors
95
122
}
96
123
}
0 commit comments