Brandon Presley
a69bfd62a6
This greatly reduces our lines of code. Also I thought it might improve performance to address #135 but it didn't make any difference.
37 lines
799 B
TypeScript
37 lines
799 B
TypeScript
import {Platform, Pressable} from 'react-native'
|
|
import {Switch as PaperSwitch, Text, useTheme} from 'react-native-paper'
|
|
import {MARGIN} from './constants'
|
|
|
|
export default function Switch({
|
|
value,
|
|
onChange,
|
|
onPress,
|
|
children,
|
|
}: {
|
|
value?: boolean
|
|
onChange: (value: boolean) => void
|
|
onPress: () => void
|
|
children: string
|
|
}) {
|
|
const {colors} = useTheme()
|
|
|
|
return (
|
|
<Pressable
|
|
onPress={onPress}
|
|
style={{
|
|
flexDirection: 'row',
|
|
flexWrap: 'wrap',
|
|
alignItems: 'center',
|
|
marginBottom: Platform.OS === 'ios' ? MARGIN : null,
|
|
}}>
|
|
<PaperSwitch
|
|
color={colors.primary}
|
|
style={{marginRight: MARGIN}}
|
|
value={value}
|
|
onValueChange={onChange}
|
|
/>
|
|
<Text>{children}</Text>
|
|
</Pressable>
|
|
)
|
|
}
|