diff options
Diffstat (limited to 'src/alf/util')
-rw-r--r-- | src/alf/util/flatten.ts | 3 | ||||
-rw-r--r-- | src/alf/util/platform.ts | 25 | ||||
-rw-r--r-- | src/alf/util/useColorModeTheme.ts | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/src/alf/util/flatten.ts b/src/alf/util/flatten.ts new file mode 100644 index 000000000..448716a08 --- /dev/null +++ b/src/alf/util/flatten.ts @@ -0,0 +1,3 @@ +import {StyleSheet} from 'react-native' + +export const flatten = StyleSheet.flatten diff --git a/src/alf/util/platform.ts b/src/alf/util/platform.ts new file mode 100644 index 000000000..544f5480b --- /dev/null +++ b/src/alf/util/platform.ts @@ -0,0 +1,25 @@ +import {Platform} from 'react-native' + +export function web(value: any) { + return Platform.select({ + web: value, + }) +} + +export function ios(value: any) { + return Platform.select({ + ios: value, + }) +} + +export function android(value: any) { + return Platform.select({ + android: value, + }) +} + +export function native(value: any) { + return Platform.select({ + native: value, + }) +} diff --git a/src/alf/util/useColorModeTheme.ts b/src/alf/util/useColorModeTheme.ts new file mode 100644 index 000000000..79cebc139 --- /dev/null +++ b/src/alf/util/useColorModeTheme.ts @@ -0,0 +1,10 @@ +import {useColorScheme} from 'react-native' + +import * as persisted from '#/state/persisted' + +export function useColorModeTheme( + theme: persisted.Schema['colorMode'], +): 'light' | 'dark' { + const colorScheme = useColorScheme() + return (theme === 'system' ? colorScheme : theme) || 'light' +} |