Commit 66f9e491 authored by XieZhiXiong's avatar XieZhiXiong

feat: 搬运主题相关

parent af6ca198
......@@ -11,12 +11,14 @@
import React from 'react';
import RootNavigationContainer from './routers/RootNavigationContainer';
import { storage } from './utils/storage';
import useColorScheme from './hooks/useColorScheme';
//创建全局属性,任意位置都可以调用该实例
global.storage = storage;
const App = () => {
return <RootNavigationContainer />;
const colorScheme = useColorScheme();
return <RootNavigationContainer colorScheme={colorScheme} />;
};
export default App;
import {
ColorSchemeName,
useColorScheme as _useColorScheme,
} from 'react-native';
// The useColorScheme value is always either light or dark, but the built-in
// type suggests that it can be null. This will not happen in practice, so this
// makes it a bit easier to work with.
export default function useColorScheme(): NonNullable<ColorSchemeName> {
return _useColorScheme() as NonNullable<ColorSchemeName>;
}
import * as React from 'react';
import { ColorSchemeName } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { RootStackParamList } from './types';
import { ROUTERS as SCREEN } from './routers';
import Theme from '../constants/theme';
const RootStack = createNativeStackNavigator<RootStackParamList>();
const SCREEN_NAMES = Object.keys(SCREEN) as (keyof typeof SCREEN)[];
const RootNavigationContainer = () => {
interface Iprops {
colorScheme: ColorSchemeName;
}
const RootNavigationContainer: React.FC<Iprops> = props => {
const { colorScheme } = props;
const CurrentTheme = () => {
/** 默认模板名称 */
const themeName = 'science';
if (colorScheme === 'dark') {
// return Theme.dark
}
return Theme[themeName];
};
return (
<NavigationContainer>
<NavigationContainer theme={CurrentTheme()}>
<RootStack.Navigator
screenOptions={{
headerTitleAlign: 'center',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment