Massive/Switch.tsx

37 lines
814 B
TypeScript
Raw Normal View History

import {Platform, Pressable} from 'react-native'
import {Switch as PaperSwitch, Text, useTheme} from 'react-native-paper'
2022-10-31 04:22:08 +00:00
import {MARGIN} from './constants'
2022-09-26 03:10:13 +00:00
export default function Switch({
value,
onValueChange,
onPress,
children,
}: {
2022-10-31 04:22:08 +00:00
value?: boolean
onValueChange: (value: boolean) => void
onPress: () => void
children: string
2022-09-26 03:10:13 +00:00
}) {
const {colors} = useTheme()
2022-09-26 03:10:13 +00:00
return (
<Pressable
onPress={onPress}
style={{
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'center',
marginBottom: Platform.OS === 'ios' ? MARGIN : null,
2022-09-26 03:10:13 +00:00
}}>
<PaperSwitch
color={colors.primary}
2022-09-26 03:10:13 +00:00
style={{marginRight: MARGIN}}
value={value}
onValueChange={onValueChange}
/>
<Text>{children}</Text>
</Pressable>
2022-10-31 04:22:08 +00:00
)
2022-09-26 03:10:13 +00:00
}