From 85dfef87ab8be42016fb146b4cc2fe0589a83fb1 Mon Sep 17 00:00:00 2001 From: Jaz Date: Tue, 16 May 2023 23:06:08 -0700 Subject: Use a three-state radio button for color mode --- src/view/shell/Drawer.tsx | 135 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 114 insertions(+), 21 deletions(-) (limited to 'src/view/shell/Drawer.tsx') diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index ea2153789..2c7c65247 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -1,6 +1,7 @@ import React, {ComponentProps} from 'react' import { Linking, + Pressable, SafeAreaView, StyleProp, StyleSheet, @@ -125,10 +126,13 @@ export const DrawerContent = observer(() => { Linking.openURL(FEEDBACK_FORM_URL) }, [track]) - const onColorModePress = React.useCallback(() => { - track('Menu:ItemClicked', {url: '#cycleColorMode'}) - store.shell.setColorMode(nextColorMode()) - }, [track, store]) + const onColorModePress = React.useCallback( + (mode: string) => { + track('Menu:ItemClicked', {url: '#cycleColorMode'}) + store.shell.setColorMode(mode) + }, + [track, store], + ) // rendering // = @@ -291,23 +295,33 @@ export const DrawerContent = observer(() => { {!isWeb && ( - - } - strokeWidth={2} - /> - + + + Set color theme + + + + + + + )} { ) }) +interface SelectableBtnProps { + current: string + value: string + label: string + left?: boolean + right?: boolean + onChange: (v: string) => void +} + +function SelectableBtn({ + current, + value, + label, + left, + right, + onChange, +}: SelectableBtnProps) { + const pal = usePalette('default') + const palPrimary = usePalette('inverted') + return ( + onChange(value)} + accessibilityRole="button" + accessibilityLabel={value} + accessibilityHint={`Set color theme to ${value}`}> + + {label} + + + ) +} + const styles = StyleSheet.create({ view: { flex: 1, @@ -502,6 +555,46 @@ const styles = StyleSheet.create({ marginRight: 6, }, + colorModeText: { + marginLeft: 10, + marginBottom: 6, + }, + + selectableBtns: { + flexDirection: 'row', + marginLeft: 10, + }, + selectableBtn: { + flexDirection: 'row', + justifyContent: 'center', + borderWidth: 1, + borderLeftWidth: 0, + paddingHorizontal: 10, + paddingVertical: 10, + }, + selectableBtnLeft: { + borderTopLeftRadius: 8, + borderBottomLeftRadius: 8, + borderLeftWidth: 1, + }, + selectableBtnRight: { + borderTopRightRadius: 8, + borderBottomRightRadius: 8, + }, + + btn: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + width: '100%', + borderRadius: 32, + padding: 14, + backgroundColor: colors.gray1, + }, + toggleBtn: { + paddingHorizontal: 0, + }, + footer: { flexDirection: 'row', justifyContent: 'space-between', -- cgit 1.4.1