Skip to content

Commit f2027a2

Browse files
authored
Fix for automatic colorScheme in the sample (#205)
Fix for automatic colorScheme in the Android sample
1 parent fba747a commit f2027a2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sample/src/App.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
2323

2424
import type {PropsWithChildren, ReactNode} from 'react';
2525
import React, {useEffect, useState} from 'react';
26-
import {Appearance, Linking, StatusBar} from 'react-native';
26+
import {Linking, StatusBar} from 'react-native';
2727
import {
2828
Link,
2929
NavigationContainer,
@@ -77,8 +77,6 @@ const config: Configuration = {
7777
},
7878
};
7979

80-
Appearance.setColorScheme('light');
81-
8280
export type RootStackParamList = {
8381
Catalog: undefined;
8482
CatalogScreen: undefined;

sample/src/context/Theme.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ export const ThemeProvider: React.FC<
170170
useState<ColorScheme>(defaultValue);
171171

172172
const setColorScheme = useCallback((colorScheme: ColorScheme) => {
173-
if (colorScheme !== ColorScheme.automatic) {
173+
if (colorScheme === ColorScheme.automatic) {
174+
Appearance.setColorScheme(null);
175+
} else {
174176
Appearance.setColorScheme(
175177
colorScheme === ColorScheme.dark ? 'dark' : 'light',
176178
);

0 commit comments

Comments
 (0)