Skip to content

Commit b86c1cc

Browse files
theme: Update naming for night/dark, default/light
As mentioned in issue #4009, this changes how the theme of the app is described. It changes all instances of 'default' to 'light' and 'night' to 'dark'. Fixes #5169.
1 parent f6fd683 commit b86c1cc

File tree

14 files changed

+34
-35
lines changed

14 files changed

+34
-35
lines changed

src/common/Popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type Props = $ReadOnly<{|
4646
export default function Popup(props: Props): Node {
4747
const themeContext = useContext(ThemeContext);
4848
// TODO(color/theme): find a cleaner way to express this
49-
const isDarkTheme = useGlobalSelector(state => getGlobalSettings(state).theme !== 'default');
49+
const isDarkTheme = useGlobalSelector(state => getGlobalSettings(state).theme !== 'light');
5050
return (
5151
<View style={[{ backgroundColor: themeContext.backgroundColor }, styles.popup]}>
5252
<View style={isDarkTheme && styles.overlay}>{props.children}</View>

src/common/ZulipStatusBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getGlobalSession, getGlobalSettings } from '../selectors';
1414
type BarStyle = React$ElementConfig<typeof StatusBar>['barStyle'];
1515

1616
export const getStatusBarColor = (backgroundColor: string | void, theme: ThemeName): string =>
17-
backgroundColor ?? (theme === 'night' ? 'hsl(212, 28%, 18%)' : 'white');
17+
backgroundColor ?? (theme === 'dark' ? 'hsl(212, 28%, 18%)' : 'white');
1818

1919
export const getStatusBarStyle = (statusBarColor: string): BarStyle =>
2020
foregroundColorFromBackground(statusBarColor) === 'white' /* force newline */
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* @flow strict-local */
22
import { getStatusBarColor } from '../ZulipStatusBar';
33

4-
const themeNight = 'night';
5-
const themeDefault = 'default';
4+
const themeDark = 'dark';
5+
const themeLight = 'light';
66

77
describe('getStatusBarColor', () => {
88
test('returns specific color when given, regardless of theme', () => {
9-
expect(getStatusBarColor('#fff', themeDefault)).toEqual('#fff');
10-
expect(getStatusBarColor('#fff', themeNight)).toEqual('#fff');
9+
expect(getStatusBarColor('#fff', themeLight)).toEqual('#fff');
10+
expect(getStatusBarColor('#fff', themeDark)).toEqual('#fff');
1111
});
1212

1313
test('returns color according to theme for default case', () => {
14-
expect(getStatusBarColor(undefined, themeDefault)).toEqual('white');
15-
expect(getStatusBarColor(undefined, themeNight)).toEqual('hsl(212, 28%, 18%)');
14+
expect(getStatusBarColor(undefined, themeLight)).toEqual('white');
15+
expect(getStatusBarColor(undefined, themeDark)).toEqual('hsl(212, 28%, 18%)');
1616
});
1717
});

src/nav/ZulipNavigationContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export default function ZulipAppContainer(props: Props): Node {
3636

3737
const themeContext = useContext(ThemeContext);
3838

39-
const BaseTheme = themeName === 'night' ? DarkTheme : DefaultTheme;
39+
const BaseTheme = themeName === 'dark' ? DarkTheme : DefaultTheme;
4040

4141
const theme = {
4242
...BaseTheme,
43-
dark: themeName === 'night',
43+
dark: themeName === 'dark',
4444
colors: {
4545
...BaseTheme.colors,
4646
primary: themeContext.color,

src/reduxTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export type RealmState = {|
349349
// TODO: Stop using the 'default' name. Any 'default' semantics should
350350
// only apply the device level, not within the app. See
351351
// https://github.com/zulip/zulip-mobile/issues/4009#issuecomment-619280681.
352-
export type ThemeName = 'default' | 'night';
352+
export type ThemeName = 'light' | 'dark';
353353

354354
/** What browser the user has set to use for opening links in messages.
355355
*

src/settings/SettingsScreen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export default function SettingsScreen(props: Props): Node {
3535
const { navigation } = props;
3636

3737
const handleThemeChange = useCallback(() => {
38-
dispatch(setGlobalSettings({ theme: theme === 'default' ? 'night' : 'default' }));
38+
dispatch(setGlobalSettings({ theme: theme === 'light' ? 'dark' : 'light' }));
3939
}, [theme, dispatch]);
4040

4141
return (
4242
<Screen title="Settings">
43-
<SwitchRow label="Night mode" value={theme === 'night'} onValueChange={handleThemeChange} />
43+
<SwitchRow label="Dark mode" value={theme === 'dark'} onValueChange={handleThemeChange} />
4444
<SwitchRow
4545
label="Open links with in-app browser"
4646
value={shouldUseInAppBrowser(browser)}

src/settings/__tests__/settingsReducer-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ describe('settingsReducer', () => {
7676
test('changes value of a key', () => {
7777
const action = deepFreeze({
7878
type: SET_GLOBAL_SETTINGS,
79-
update: { theme: 'night' },
79+
update: { theme: 'dark' },
8080
});
8181

8282
const expectedState = {
8383
...baseState,
84-
theme: 'night',
84+
theme: 'dark',
8585
};
8686

8787
const actualState = settingsReducer(baseState, action);

src/settings/settingsReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const initialState: SettingsState = {
1515
//
1616

1717
language: 'en',
18-
theme: 'default',
18+
theme: 'light',
1919
browser: 'default',
2020
experimentalFeaturesEnabled: false,
2121
markMessagesReadOnScroll: 'always',

src/start/IosCompliantAppleAuthButton/Custom.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ const styles = createStyleSheet({
2323
borderRadius: 22,
2424
overflow: 'hidden',
2525
},
26-
nightFrame: {
26+
darkFrame: {
2727
backgroundColor: 'black',
2828
},
29-
dayFrame: {
29+
lightFrame: {
3030
backgroundColor: 'white',
3131
borderWidth: 1.5,
3232
borderColor: 'black',
3333
},
3434
text: {
3535
fontSize: 16,
3636
},
37-
nightText: {
37+
darkText: {
3838
color: 'white',
3939
},
40-
dayText: {
40+
lightText: {
4141
color: 'black',
4242
},
4343
});
@@ -57,13 +57,13 @@ type Props = $ReadOnly<{|
5757
*/
5858
export default function Custom(props: Props): Node {
5959
const { style, onPress, theme } = props;
60-
const logoSource = theme === 'default' ? appleLogoBlackImg : appleLogoWhiteImg;
60+
const logoSource = theme === 'light' ? appleLogoBlackImg : appleLogoWhiteImg;
6161
const frameStyle = [
6262
styles.frame,
63-
theme === 'default' ? styles.dayFrame : styles.nightFrame,
63+
theme === 'light' ? styles.lightFrame : styles.darkFrame,
6464
style,
6565
];
66-
const textStyle = [styles.text, theme === 'default' ? styles.dayText : styles.nightText];
66+
const textStyle = [styles.text, theme === 'light' ? styles.lightText : styles.darkText];
6767

6868
return (
6969
<View style={frameStyle}>

src/start/IosCompliantAppleAuthButton/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function IosCompliantAppleAuthButton(props: Props): Node {
5656
<AppleAuthentication.AppleAuthenticationButton
5757
buttonType={AppleAuthentication.AppleAuthenticationButtonType.SIGN_IN}
5858
buttonStyle={
59-
theme === 'default'
59+
theme === 'light'
6060
? AppleAuthentication.AppleAuthenticationButtonStyle.WHITE_OUTLINE
6161
: AppleAuthentication.AppleAuthenticationButtonStyle.BLACK
6262
}

0 commit comments

Comments
 (0)