Skip to content

Commit 87c3feb

Browse files
authored
Merge pull request #5921 from EdgeApp/jon/fix/light-mode
Jon/fix/light mode
2 parents e0a6aad + c5f2f63 commit 87c3feb

13 files changed

Lines changed: 174 additions & 280 deletions

File tree

src/__tests__/scenes/__snapshots__/SettingsScene.test.tsx.snap

Lines changed: 2 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -5265,206 +5265,6 @@ exports[`SettingsScene should render SettingsScene 1`] = `
52655265
</View>
52665266
</View>
52675267
</View>
5268-
<BVLinearGradient
5269-
colors={
5270-
[
5271-
452984831,
5272-
452984831,
5273-
]
5274-
}
5275-
endPoint={
5276-
{
5277-
"x": 1,
5278-
"y": 0.5,
5279-
}
5280-
}
5281-
locations={null}
5282-
startPoint={
5283-
{
5284-
"x": 0,
5285-
"y": 0.5,
5286-
}
5287-
}
5288-
style={
5289-
[
5290-
{
5291-
"borderBottomColor": "rgba(255, 255, 255, .1)",
5292-
"borderBottomWidth": 1,
5293-
"height": 1,
5294-
},
5295-
{
5296-
"margin": 11,
5297-
},
5298-
]
5299-
}
5300-
/>
5301-
<View
5302-
accessibilityState={
5303-
{
5304-
"busy": undefined,
5305-
"checked": undefined,
5306-
"disabled": false,
5307-
"expanded": undefined,
5308-
"selected": undefined,
5309-
}
5310-
}
5311-
accessibilityValue={
5312-
{
5313-
"max": undefined,
5314-
"min": undefined,
5315-
"now": undefined,
5316-
"text": undefined,
5317-
}
5318-
}
5319-
accessible={false}
5320-
collapsable={false}
5321-
focusable={true}
5322-
hitSlop={11}
5323-
onClick={[Function]}
5324-
onResponderGrant={[Function]}
5325-
onResponderMove={[Function]}
5326-
onResponderRelease={[Function]}
5327-
onResponderTerminate={[Function]}
5328-
onResponderTerminationRequest={[Function]}
5329-
onStartShouldSetResponder={[Function]}
5330-
style={
5331-
{
5332-
"alignItems": "center",
5333-
"backgroundColor": "rgba(255, 255, 255, 0)",
5334-
"flexDirection": "row",
5335-
"marginBottom": 1,
5336-
"minHeight": 67,
5337-
"opacity": 1,
5338-
"padding": 11,
5339-
}
5340-
}
5341-
>
5342-
<Text
5343-
allowFontScaling={false}
5344-
style={
5345-
{
5346-
"color": "#FFFFFF",
5347-
"flexGrow": 1,
5348-
"flexShrink": 1,
5349-
"fontFamily": "Quicksand-Regular",
5350-
"fontSize": 22,
5351-
"paddingHorizontal": 11,
5352-
"textAlign": "left",
5353-
}
5354-
}
5355-
>
5356-
Light Mode
5357-
</Text>
5358-
<View>
5359-
<View
5360-
collapsable={false}
5361-
jestAnimatedProps={
5362-
{
5363-
"value": {},
5364-
}
5365-
}
5366-
jestAnimatedStyle={
5367-
{
5368-
"value": {
5369-
"opacity": 0,
5370-
},
5371-
}
5372-
}
5373-
jestInlineStyle={
5374-
[
5375-
{
5376-
"aspectRatio": 1,
5377-
"position": "absolute",
5378-
"width": "100%",
5379-
"zIndex": 1,
5380-
},
5381-
]
5382-
}
5383-
nativeID="49"
5384-
pending={false}
5385-
style={
5386-
[
5387-
{
5388-
"aspectRatio": 1,
5389-
"position": "absolute",
5390-
"width": "100%",
5391-
"zIndex": 1,
5392-
},
5393-
{
5394-
"opacity": 0,
5395-
},
5396-
]
5397-
}
5398-
>
5399-
<ActivityIndicator
5400-
color="#00f1a2"
5401-
style={
5402-
{
5403-
"height": 34,
5404-
"marginHorizontal": 11,
5405-
}
5406-
}
5407-
/>
5408-
</View>
5409-
<View
5410-
collapsable={false}
5411-
jestAnimatedProps={
5412-
{
5413-
"value": {},
5414-
}
5415-
}
5416-
jestAnimatedStyle={
5417-
{
5418-
"value": {
5419-
"opacity": 1,
5420-
},
5421-
}
5422-
}
5423-
jestInlineStyle={{}}
5424-
nativeID="50"
5425-
pending={false}
5426-
style={
5427-
[
5428-
{
5429-
"opacity": 1,
5430-
},
5431-
]
5432-
}
5433-
>
5434-
<View
5435-
pointerEvents="none"
5436-
style={
5437-
{
5438-
"marginHorizontal": 11,
5439-
"padding": 0,
5440-
}
5441-
}
5442-
>
5443-
<RCTSwitch
5444-
accessibilityRole="switch"
5445-
onChange={[Function]}
5446-
onResponderTerminationRequest={[Function]}
5447-
onStartShouldSetResponder={[Function]}
5448-
onTintColor="#00f1a2"
5449-
style={
5450-
[
5451-
{
5452-
"height": 31,
5453-
"width": 51,
5454-
},
5455-
{
5456-
"backgroundColor": "#888888",
5457-
"borderRadius": 16,
5458-
},
5459-
]
5460-
}
5461-
tintColor="#888888"
5462-
value={false}
5463-
/>
5464-
</View>
5465-
</View>
5466-
</View>
5467-
</View>
54685268
</View>
54695269
</View>
54705270
<BVLinearGradient
@@ -5634,7 +5434,7 @@ exports[`SettingsScene should render SettingsScene 1`] = `
56345434
},
56355435
]
56365436
}
5637-
nativeID="51"
5437+
nativeID="49"
56385438
pending={false}
56395439
style={
56405440
[
@@ -5675,7 +5475,7 @@ exports[`SettingsScene should render SettingsScene 1`] = `
56755475
}
56765476
}
56775477
jestInlineStyle={{}}
5678-
nativeID="52"
5478+
nativeID="50"
56795479
pending={false}
56805480
style={
56815481
[

src/actions/DeviceSettingsActions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { makeReactNativeDisklet } from 'disklet'
33
import {
44
asDeviceSettings,
55
type DefaultScreen,
6-
type DeviceSettings
6+
type DeviceSettings,
7+
type ThemeMode
78
} from '../types/types'
89

910
const disklet = makeReactNativeDisklet()
@@ -71,8 +72,8 @@ export const writeForceLightAccountCreate = async (
7172
return await writeDeviceSettings(updatedSettings)
7273
}
7374

74-
export const writeIsLightTheme = async (isLightTheme: boolean) => {
75-
return await writeDeviceSettings({ ...deviceSettings, isLightTheme })
75+
export const writeThemeMode = async (themeMode: ThemeMode) => {
76+
return await writeDeviceSettings({ ...deviceSettings, themeMode })
7677
}
7778

7879
/**

src/app.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import NetInfo from '@react-native-community/netinfo'
99
import * as Sentry from '@sentry/react-native'
1010
import { Buffer } from 'buffer'
1111
import { asObject, asString } from 'cleaners'
12-
import { InteractionManager, LogBox } from 'react-native'
12+
import { Appearance, InteractionManager, LogBox } from 'react-native'
1313
import { getVersion } from 'react-native-device-info'
1414
import RNFS from 'react-native-fs'
1515

@@ -285,16 +285,37 @@ if (ENV.DEBUG_THEME) {
285285
})
286286
}
287287

288+
// Theme initialization and system theme listener
288289
initDeviceSettings()
289290
.then(() => {
290-
const { isLightTheme } = getDeviceSettings()
291-
// Only change theme if light mode is enabled (dark is already the default)
292-
if (isLightTheme) {
291+
const { themeMode } = getDeviceSettings()
292+
293+
// Apply theme based on mode setting at startup
294+
let shouldUseLightTheme = false
295+
if (themeMode === 'light') {
296+
shouldUseLightTheme = true
297+
} else if (themeMode === 'system') {
298+
shouldUseLightTheme = Appearance.getColorScheme() !== 'dark'
299+
}
300+
// Only change theme if light mode is needed (dark is already the default)
301+
if (shouldUseLightTheme) {
293302
// Defer until after React render cycle completes
294303
InteractionManager.runAfterInteractions(() => {
295304
changeTheme(config.lightTheme)
296305
})
297306
}
307+
308+
// Global listener for OS theme changes (active when themeMode is 'system')
309+
Appearance.addChangeListener(({ colorScheme }) => {
310+
const { themeMode: currentMode } = getDeviceSettings()
311+
if (currentMode === 'system') {
312+
InteractionManager.runAfterInteractions(() => {
313+
const newTheme =
314+
colorScheme === 'dark' ? config.darkTheme : config.lightTheme
315+
changeTheme(newTheme)
316+
})
317+
}
318+
})
298319
})
299320
.catch(err => {
300321
console.log(err)

src/components/cards/GiftCardDisplayCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ const getStyles = cacheStyles((theme: Theme) => ({
249249
pendingText: {
250250
fontSize: theme.rem(0.875),
251251
fontFamily: theme.fontFaceMedium,
252-
...theme.embossedTextShadow
252+
...theme.embossedTextShadow,
253+
color: theme.giftCardText
253254
}
254255
}))

src/components/icons/IconBadge.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ const getStyles = cacheStyles((theme: Theme) => {
8383
justifyContent: 'center'
8484
},
8585
textIos: {
86+
color: theme.badgeText,
8687
fontSize: theme.rem(0.5) - 1,
8788
fontFamily: theme.fontFaceBold,
8889
marginLeft: 2,
8990
marginRight: 1
9091
},
9192
textAndroid: {
93+
color: theme.badgeText,
9294
fontSize: theme.rem(0.5) - 1,
9395
fontFamily: theme.fontFaceBold,
9496
marginTop: 1.5,
@@ -98,7 +100,7 @@ const getStyles = cacheStyles((theme: Theme) => {
98100
width: theme.rem(0.15),
99101
height: theme.rem(0.15),
100102
borderRadius: theme.rem(0.15 / 2),
101-
backgroundColor: theme.primaryText
103+
backgroundColor: theme.badgeText
102104
}
103105
}
104106
})

0 commit comments

Comments
 (0)