File tree Expand file tree Collapse file tree 4 files changed +21
-17
lines changed Expand file tree Collapse file tree 4 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import { useColorScheme } from 'react-native' ;
2
3
import { NavigationContainer } from '@react-navigation/native' ;
3
4
import { createStackNavigator } from '@react-navigation/stack' ;
4
5
import { SafeAreaView , StatusBar , StyleSheet } from 'react-native' ;
5
6
import { RootSiblingParent } from 'react-native-root-siblings' ;
6
- import { ThemeProvider } from '@uiw/react-native' ;
7
-
7
+ import { ThemeProvider , theme } from '@uiw/react-native' ;
8
8
import { stackPageData } from './routes' ;
9
9
10
10
const Stack = createStackNavigator ( ) ;
@@ -16,11 +16,13 @@ const styles = StyleSheet.create({
16
16
} ) ;
17
17
18
18
const App = ( ) => {
19
+ const colorScheme = useColorScheme ( ) ;
20
+ console . log ( 'colorScheme' , colorScheme ) ;
19
21
return (
20
22
< RootSiblingParent >
21
23
< SafeAreaView style = { styles . block } >
22
24
< StatusBar barStyle = "dark-content" />
23
- < ThemeProvider >
25
+ < ThemeProvider theme = { colorScheme === 'light' ? { ... theme . lightTheme } : { ... theme . darkTheme } } >
24
26
< NavigationContainer >
25
27
< Stack . Navigator initialRouteName = "Home" >
26
28
< Stack . Screen
Original file line number Diff line number Diff line change 1
1
import { useMemo } from 'react' ;
2
+ import { usePersistFn } from 'ahooks' ;
2
3
import dayjs , { Dayjs } from 'dayjs' ;
3
4
import { ItemValue } from '../../../Picker/components/WheelPicker/type' ;
4
5
import { CascadePickerItemProps , DatePickerPropsBase } from './type' ;
@@ -319,8 +320,8 @@ export default function useDatePicker({
319
320
} ;
320
321
321
322
return {
322
- getValueCols : getValueCols ,
323
- onValueChange : onValueChange ,
323
+ getValueCols : usePersistFn ( getValueCols ) ,
324
+ onValueChange : usePersistFn ( onValueChange ) ,
324
325
} ;
325
326
}
326
327
Original file line number Diff line number Diff line change 1
- import { useEffect , useRef } from 'react' ;
1
+ import { useEffect } from 'react' ;
2
2
import { BackHandler } from 'react-native' ;
3
- import { useSafeState } from 'ahooks' ;
3
+ import { useSafeState , usePersistFn } from 'ahooks' ;
4
+ import { useLatest } from '../utils/hooks' ;
4
5
import dayjs from 'dayjs' ;
5
6
import { DatePickerPropsBase , ModalPickerProps } from './components/date-picker/type' ;
6
7
7
- function useLatest < T > ( value : T ) {
8
- const ref = useRef < T > ( value ) ;
9
- ref . current = value ;
10
-
11
- return ref ;
12
- }
13
-
14
8
export default function useDatePicker ( {
15
9
onClosed,
16
10
onChange,
@@ -52,8 +46,8 @@ export default function useDatePicker({
52
46
53
47
return {
54
48
date,
55
- handleChange : handleChange ,
56
- handleOk : handleOk ,
57
- handleClose : handleClose ,
49
+ handleChange : usePersistFn ( handleChange ) ,
50
+ handleOk : usePersistFn ( handleOk ) ,
51
+ handleClose : usePersistFn ( handleClose ) ,
58
52
} ;
59
53
}
Original file line number Diff line number Diff line change @@ -47,3 +47,10 @@ export function usePropsValue<T>(options: Options<T>) {
47
47
} ) ;
48
48
return [ stateRef . current , setState ] as const ;
49
49
}
50
+
51
+ export function useLatest < T > ( value : T ) {
52
+ const ref = useRef < T > ( value ) ;
53
+ ref . current = value ;
54
+
55
+ return ref ;
56
+ }
You can’t perform that action at this time.
0 commit comments