Remove custom color calculation from Switch
This commit is contained in:
parent
7b403050f3
commit
b68f903a1c
18
Switch.tsx
18
Switch.tsx
|
@ -1,10 +1,6 @@
|
||||||
import {useMemo} from 'react'
|
|
||||||
import {Pressable} from 'react-native'
|
import {Pressable} from 'react-native'
|
||||||
import {Switch as PaperSwitch, Text, useTheme} from 'react-native-paper'
|
import {Switch as PaperSwitch, Text, useTheme} from 'react-native-paper'
|
||||||
import {CombinedDarkTheme, CombinedDefaultTheme} from './App'
|
|
||||||
import {colorShade} from './colors'
|
|
||||||
import {MARGIN} from './constants'
|
import {MARGIN} from './constants'
|
||||||
import useDark from './use-dark'
|
|
||||||
|
|
||||||
export default function Switch({
|
export default function Switch({
|
||||||
value,
|
value,
|
||||||
|
@ -18,19 +14,6 @@ export default function Switch({
|
||||||
children: string
|
children: string
|
||||||
}) {
|
}) {
|
||||||
const {colors} = useTheme()
|
const {colors} = useTheme()
|
||||||
const dark = useDark()
|
|
||||||
|
|
||||||
const track = useMemo(() => {
|
|
||||||
if (dark)
|
|
||||||
return {
|
|
||||||
false: CombinedDarkTheme.colors.placeholder,
|
|
||||||
true: colorShade(colors.primary, -40),
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
false: CombinedDefaultTheme.colors.placeholder,
|
|
||||||
true: colorShade(colors.primary, -40),
|
|
||||||
}
|
|
||||||
}, [dark, colors.primary])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<Pressable
|
||||||
|
@ -41,7 +24,6 @@ export default function Switch({
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}}>
|
}}>
|
||||||
<PaperSwitch
|
<PaperSwitch
|
||||||
trackColor={track}
|
|
||||||
color={colors.primary}
|
color={colors.primary}
|
||||||
style={{marginRight: MARGIN}}
|
style={{marginRight: MARGIN}}
|
||||||
value={value}
|
value={value}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user