Skip to content

Commit e02e10b

Browse files
committed
refactor: rename "device colors" to "Dynamic Theme"
1 parent ca8dfef commit e02e10b

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

example/src/DrawerItems.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Portal,
1717
} from 'react-native-paper';
1818

19-
import { deviceColorsSupported, isWeb } from '../utils';
19+
import { dynamicThemeSupported, isWeb } from '../utils';
2020
import { useExampleTheme } from './hooks/useExampleTheme';
2121
import { PreferencesContext } from './PreferencesContext';
2222

@@ -103,7 +103,7 @@ function DrawerItems() {
103103
if (!preferences) throw new Error('PreferencesContext not provided');
104104

105105
const {
106-
toggleShouldUseDeviceColors,
106+
toggleShouldUseDynamicTheme,
107107
toggleTheme,
108108
toggleRtl: toggleRTL,
109109
toggleCollapsed,
@@ -114,7 +114,7 @@ function DrawerItems() {
114114
collapsed,
115115
rtl: isRTL,
116116
theme: { dark: isDarkTheme },
117-
shouldUseDeviceColors,
117+
shouldUseDynamicTheme,
118118
} = preferences;
119119

120120
const _handleToggleRTL = () => {
@@ -181,12 +181,12 @@ function DrawerItems() {
181181
</Drawer.Section>
182182

183183
<Drawer.Section title="Preferences">
184-
{deviceColorsSupported ? (
185-
<TouchableRipple onPress={toggleShouldUseDeviceColors}>
184+
{dynamicThemeSupported ? (
185+
<TouchableRipple onPress={toggleShouldUseDynamicTheme}>
186186
<View style={styles.preference}>
187-
<Text variant="labelLarge">Use device colors *</Text>
187+
<Text variant="labelLarge">Use Dynamic Theme</Text>
188188
<View pointerEvents="none">
189-
<Switch value={shouldUseDeviceColors} />
189+
<Switch value={shouldUseDynamicTheme} />
190190
</View>
191191
</View>
192192
</TouchableRipple>

example/src/PreferencesContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ export const PreferencesContext = React.createContext<{
88
toggleCollapsed: () => void;
99
toggleCustomFont: () => void;
1010
toggleRippleEffect: () => void;
11-
toggleShouldUseDeviceColors?: () => void;
11+
toggleShouldUseDynamicTheme?: () => void;
1212
theme: Theme;
1313
rtl: boolean;
1414
collapsed: boolean;
1515
customFontLoaded: boolean;
1616
rippleEffectEnabled: boolean;
17-
shouldUseDeviceColors?: boolean;
17+
shouldUseDynamicTheme?: boolean;
1818
} | null>(null);

example/src/index.native.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
2020
import DrawerItems from './DrawerItems';
2121
import { PreferencesContext } from './PreferencesContext';
2222
import App from './RootNavigator';
23-
import { deviceColorsSupported } from '../utils';
23+
import { dynamicThemeSupported } from '../utils';
2424
import {
2525
CombinedDefaultTheme,
2626
CombinedDarkTheme,
@@ -45,7 +45,7 @@ export default function PaperExample() {
4545
InitialState | undefined
4646
>();
4747

48-
const [shouldUseDeviceColors, setShouldUseDeviceColors] =
48+
const [shouldUseDynamicTheme, setShouldUseDynamicTheme] =
4949
React.useState(true);
5050
const [isDarkMode, setIsDarkMode] = React.useState(false);
5151
const [rtl, setRtl] = React.useState<boolean>(
@@ -56,12 +56,12 @@ export default function PaperExample() {
5656
const [rippleEffectEnabled, setRippleEffectEnabled] = React.useState(true);
5757

5858
const theme = React.useMemo(() => {
59-
if (deviceColorsSupported && shouldUseDeviceColors) {
59+
if (dynamicThemeSupported && shouldUseDynamicTheme) {
6060
return isDarkMode ? DynamicDarkTheme : DynamicLightTheme;
6161
}
6262

6363
return isDarkMode ? DarkTheme : LightTheme;
64-
}, [isDarkMode, shouldUseDeviceColors]);
64+
}, [isDarkMode, shouldUseDynamicTheme]);
6565

6666
React.useEffect(() => {
6767
const restoreState = async () => {
@@ -128,8 +128,8 @@ export default function PaperExample() {
128128

129129
const preferences = React.useMemo(
130130
() => ({
131-
toggleShouldUseDeviceColors: () =>
132-
setShouldUseDeviceColors((oldValue) => !oldValue),
131+
toggleShouldUseDynamicTheme: () =>
132+
setShouldUseDynamicTheme((oldValue) => !oldValue),
133133
toggleTheme: () => setIsDarkMode((oldValue) => !oldValue),
134134
toggleRtl: () => setRtl((rtl) => !rtl),
135135
toggleCollapsed: () => setCollapsed(!collapsed),
@@ -140,14 +140,14 @@ export default function PaperExample() {
140140
collapsed,
141141
rtl,
142142
theme,
143-
shouldUseDeviceColors,
143+
shouldUseDynamicTheme: shouldUseDynamicTheme,
144144
}),
145145
[
146146
rtl,
147147
theme,
148148
collapsed,
149149
customFontLoaded,
150-
shouldUseDeviceColors,
150+
shouldUseDynamicTheme,
151151
rippleEffectEnabled,
152152
]
153153
);

example/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export default function PaperExample() {
110110
rippleEffectEnabled,
111111
// noop for web, specified to avoid type errors
112112
toggleRtl: noop,
113-
toggleShouldUseDeviceColors: noop,
113+
toggleShouldUseDynamicTheme: noop,
114114
rtl: false,
115-
shouldUseDeviceColors: false,
115+
shouldUseDynamicTheme: false,
116116
}),
117117
[theme, collapsed, customFontLoaded, rippleEffectEnabled]
118118
);

example/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,5 +1433,5 @@ export const restaurantsData = [
14331433
},
14341434
];
14351435

1436-
export const deviceColorsSupported =
1436+
export const dynamicThemeSupported =
14371437
Platform.OS === 'android' && (Platform.Version as number) >= 31;

0 commit comments

Comments
 (0)