|
1 | | -import { |
2 | | - DEFAULT_DARK_COLOR, |
3 | | - DEFAULT_LIGHT_COLOR, |
4 | | - FOCUSED_SLOT_HEIGHT, |
5 | | - SLOT_HEIGHT, |
6 | | -} from '../constants'; |
| 1 | +import type { StyleProp, ViewStyle } from 'react-native'; |
| 2 | +import { FOCUSED_SLOT_HEIGHT, SLOT_HEIGHT } from '../constants'; |
| 3 | +import { theme } from '../theme'; |
7 | 4 | import type { UseSlotBorderStylesProps } from '../types'; |
| 5 | +import { useThemeColor } from './use-theme-color'; |
8 | 6 |
|
9 | 7 | export function useSlotBorderStyles({ |
10 | 8 | isFocused, |
11 | 9 | isFirst, |
12 | 10 | isLast, |
13 | | -}: UseSlotBorderStylesProps) { |
| 11 | +}: UseSlotBorderStylesProps): StyleProp<ViewStyle> { |
| 12 | + const darkBorder = useThemeColor({ |
| 13 | + light: theme.colorBlack, |
| 14 | + dark: theme.colorWhite, |
| 15 | + }); |
| 16 | + const lightBorder = useThemeColor({ |
| 17 | + light: theme.colorLightGrey, |
| 18 | + dark: theme.colorDarkGrey, |
| 19 | + }); |
| 20 | + |
14 | 21 | return { |
15 | 22 | height: isFocused ? FOCUSED_SLOT_HEIGHT : SLOT_HEIGHT, |
16 | | - borderColor: isFocused ? DEFAULT_DARK_COLOR : DEFAULT_LIGHT_COLOR, |
17 | | - borderTopWidth: 2, |
18 | | - borderBottomWidth: 2, |
19 | | - borderLeftWidth: isFocused || isFirst ? 2 : 1, |
20 | | - borderRightWidth: isFocused || isLast ? 2 : 1, |
21 | | - borderTopLeftRadius: isFirst ? 8 : 0, |
22 | | - borderTopRightRadius: isLast ? 8 : 0, |
23 | | - borderBottomLeftRadius: isFirst ? 8 : 0, |
24 | | - borderBottomRightRadius: isLast ? 8 : 0, |
| 23 | + borderColor: isFocused ? darkBorder : lightBorder, |
| 24 | + borderTopWidth: theme.space2, |
| 25 | + borderBottomWidth: theme.space2, |
| 26 | + borderLeftWidth: isFocused || isFirst ? theme.space2 : theme.space1, |
| 27 | + borderRightWidth: isFocused || isLast ? theme.space2 : theme.space1, |
| 28 | + borderTopLeftRadius: isFirst ? theme.borderRadius8 : theme.borderRadius0, |
| 29 | + borderTopRightRadius: isLast ? theme.borderRadius8 : theme.borderRadius0, |
| 30 | + borderBottomLeftRadius: isFirst ? theme.borderRadius8 : theme.borderRadius0, |
| 31 | + borderBottomRightRadius: isLast ? theme.borderRadius8 : theme.borderRadius0, |
25 | 32 | }; |
26 | 33 | } |
0 commit comments