react-native-varia 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/components/{ui/Accordion.tsx → Accordion.tsx} +55 -27
  2. package/lib/components/{ui/Badge.tsx → Badge.tsx} +12 -6
  3. package/lib/components/{ui/Button.tsx → Button.tsx} +18 -6
  4. package/lib/components/{ui/Checkbox.tsx → Checkbox.tsx} +22 -4
  5. package/lib/components/{ui/CircleProgress.tsx → CircleProgress.tsx} +7 -3
  6. package/lib/components/{ui/Divider.tsx → Divider.tsx} +7 -3
  7. package/lib/components/{ui/Drawer.tsx → Drawer.tsx} +73 -25
  8. package/lib/components/{ui/Field.tsx → Field.tsx} +12 -6
  9. package/lib/components/{ui/FloatingAction.tsx → FloatingAction.tsx} +15 -4
  10. package/lib/components/{ui/GradientBackground.tsx → GradientBackground.tsx} +1 -1
  11. package/lib/components/{ui/GradientText.tsx → GradientText.tsx} +15 -5
  12. package/lib/components/{ui/IconWrapper.tsx → IconWrapper.tsx} +2 -2
  13. package/lib/components/{ui/Input.tsx → Input.tsx} +11 -6
  14. package/lib/components/{ui/Link.tsx → Link.tsx} +7 -7
  15. package/lib/components/{ui/Modal.tsx → Modal.tsx} +42 -13
  16. package/lib/components/{ui/NumberInput.tsx → NumberInput.tsx} +44 -23
  17. package/lib/components/{ui/RadioGroup.tsx → RadioGroup.tsx} +35 -6
  18. package/lib/components/{ui/ReText.tsx → ReText.tsx} +1 -1
  19. package/lib/components/{ui/Select.tsx → Select.tsx} +61 -8
  20. package/lib/components/Slider.tsx +500 -0
  21. package/lib/components/{ui/Slideshow.tsx → Slideshow.tsx} +12 -3
  22. package/lib/components/{ui/Switch.tsx → Switch.tsx} +15 -3
  23. package/lib/components/{ui/Text.tsx → Text.tsx} +2 -2
  24. package/lib/components/{ui/Toast.tsx → Toast.tsx} +14 -3
  25. package/lib/components/context/Field.tsx +4 -2
  26. package/lib/varia/types.ts +6 -0
  27. package/lib/varia/utils.ts +7 -0
  28. package/package.json +1 -1
  29. package/lib/components/ui/Slider.tsx +0 -498
  30. package/lib/components/ui/context/Field.tsx +0 -27
  31. /package/lib/components/{ui/Spinner.tsx → Spinner.tsx} +0 -0
@@ -1,11 +1,15 @@
1
1
  import React, {ReactNode, useState} from 'react'
2
- import {View, Pressable} from 'react-native'
2
+ import {View, Pressable, TextStyle, StyleProp} from 'react-native'
3
3
  import Animated from 'react-native-reanimated'
4
4
  import {LinearTransition} from 'react-native-reanimated'
5
5
  import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
6
6
  import Text from './Text'
7
- import {AccordionStyles, AccordionDefaultVariants} from '../../theme/Accordion'
7
+ import {
8
+ AccordionStyles,
9
+ AccordionDefaultVariants,
10
+ } from '../../theme/Accordion.recipe'
8
11
  import {AlignSelf, Flex, PalettesWithNestedKeys} from '../../style/varia/types'
12
+ import {ViewStyle} from 'react-native'
9
13
 
10
14
  const AnimatedView = Animated.createAnimatedComponent(View)
11
15
  type AccordionVariants = UnistylesVariants<typeof AccordionStyles>
@@ -18,6 +22,10 @@ type AccordionItemProps = AccordionVariants & {
18
22
  isOpen?: boolean
19
23
  onToggle?: () => void
20
24
  scrollViewRef?: any
25
+ itemContainerStyles?: StyleProp<ViewStyle>
26
+ headerStyles?: StyleProp<ViewStyle>
27
+ headerTitleStyles?: StyleProp<TextStyle>
28
+ innerContentStyles?: StyleProp<ViewStyle>
21
29
  }
22
30
 
23
31
  type AccordionGroupRootProps = AccordionVariants & {
@@ -26,6 +34,11 @@ type AccordionGroupRootProps = AccordionVariants & {
26
34
  allowMultiple?: boolean
27
35
  flex?: Flex
28
36
  alignSelf?: AlignSelf
37
+ colorPalette?: PalettesWithNestedKeys
38
+ itemContainerStyles?: StyleProp<ViewStyle>
39
+ headerStyles?: StyleProp<ViewStyle>
40
+ headerTitleStyles?: StyleProp<TextStyle>
41
+ innerContentStyles?: StyleProp<ViewStyle>
29
42
  }
30
43
 
31
44
  export const AccordionGroup = {
@@ -41,6 +54,11 @@ function AccordionGroupRoot({
41
54
  allowMultiple = false,
42
55
  flex = 1,
43
56
  alignSelf = 'auto',
57
+ colorPalette = 'accent',
58
+ itemContainerStyles,
59
+ headerStyles,
60
+ headerTitleStyles,
61
+ innerContentStyles,
44
62
  }: AccordionGroupRootProps) {
45
63
  const [openKeys, setOpenKeys] = useState<Set<string>>(
46
64
  () => new Set(defaultOpenKeys),
@@ -73,6 +91,11 @@ function AccordionGroupRoot({
73
91
  isOpen,
74
92
  variant,
75
93
  size,
94
+ colorPalette,
95
+ itemContainerStyles,
96
+ headerStyles,
97
+ headerTitleStyles,
98
+ innerContentStyles,
76
99
  onToggle: () => toggleItem(key),
77
100
  })
78
101
  })
@@ -80,7 +103,10 @@ function AccordionGroupRoot({
80
103
  return (
81
104
  <View
82
105
  testID="varia-accordion-group-root"
83
- style={styles.groupContainer(flex, alignSelf)}>
106
+ style={[
107
+ // AccordionStyles.groupContainer(colorPalette)
108
+ styles.groupContainer(flex, alignSelf),
109
+ ]}>
84
110
  {items}
85
111
  </View>
86
112
  )
@@ -95,6 +121,10 @@ function AccordionGroupItem({
95
121
  isOpen = false,
96
122
  onToggle,
97
123
  itemKey,
124
+ itemContainerStyles,
125
+ headerStyles,
126
+ headerTitleStyles,
127
+ innerContentStyles,
98
128
  }: AccordionItemProps) {
99
129
  AccordionStyles.useVariants({variant, size, active: isOpen})
100
130
  return (
@@ -102,21 +132,36 @@ function AccordionGroupItem({
102
132
  testID={`varia-accordion-group-item-${itemKey}`}
103
133
  layout={LinearTransition.duration(150)}
104
134
  style={[
105
- styles.itemContainer,
106
135
  AccordionStyles.itemContainer(colorPalette),
136
+ itemContainerStyles,
137
+ styles.itemContainer,
107
138
  ]}>
108
139
  <Pressable
109
140
  testID={`varia-accordion-group-header-${itemKey}`}
110
141
  onPress={onToggle}
111
- style={[styles.header, AccordionStyles.header(colorPalette)]}>
112
- <Text style={AccordionStyles.headerTitle(colorPalette)}>{title}</Text>
142
+ style={[
143
+ AccordionStyles.header(colorPalette),
144
+ headerStyles,
145
+ styles.header,
146
+ ]}>
147
+ <Text
148
+ style={[
149
+ AccordionStyles.headerTitle(colorPalette),
150
+ headerTitleStyles,
151
+ ]}>
152
+ {title}
153
+ </Text>
113
154
  </Pressable>
114
155
 
115
156
  {isOpen && (
116
- <View
117
- style={styles.contentContainer}
118
- testID={`varia-accordion-group-content-${itemKey}`}>
119
- <View style={styles.innerContent}>{children}</View>
157
+ <View testID={`varia-accordion-group-content-${itemKey}`}>
158
+ <View
159
+ style={[
160
+ AccordionStyles.innerContent(colorPalette),
161
+ innerContentStyles,
162
+ ]}>
163
+ {children}
164
+ </View>
120
165
  </View>
121
166
  )}
122
167
  </AnimatedView>
@@ -133,9 +178,6 @@ const styles = StyleSheet.create({
133
178
  },
134
179
  }),
135
180
  itemContainer: {
136
- borderWidth: 1,
137
- borderRadius: 6,
138
- marginVertical: 8,
139
181
  overflow: 'hidden',
140
182
  _web: {
141
183
  _classNames: 'accordion-item-container-base',
@@ -147,18 +189,4 @@ const styles = StyleSheet.create({
147
189
  _classNames: 'accordion-header-base',
148
190
  },
149
191
  },
150
- headerText: {
151
- fontSize: 16,
152
- color: 'blue',
153
- _web: {
154
- _classNames: 'accordion-header-text-base',
155
- },
156
- },
157
- contentContainer: {},
158
- innerContent: {
159
- padding: 12,
160
- _web: {
161
- _classNames: 'accordion-item-content-base',
162
- },
163
- },
164
192
  })
@@ -1,4 +1,4 @@
1
- import {Text, View, ViewStyle, StyleProp} from 'react-native'
1
+ import {Text, View, ViewStyle, StyleProp, TextStyle} from 'react-native'
2
2
  import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
3
3
  import {BadgeStyles, BadgeDefaultVariants} from '../../theme/Badge.recipe'
4
4
  import {ReactNode} from 'react'
@@ -20,6 +20,8 @@ type BadgeProps = BadgeVariants & {
20
20
  backgroundColor?: string
21
21
  color?: string
22
22
  mixins?: StyleProp<ViewStyle>
23
+ containerStyles?: StyleProp<ViewStyle>
24
+ textStyles?: StyleProp<TextStyle>
23
25
  }
24
26
 
25
27
  const Badge = ({
@@ -32,6 +34,8 @@ const Badge = ({
32
34
  x,
33
35
  y,
34
36
  mixins,
37
+ containerStyles,
38
+ textStyles,
35
39
  }: BadgeProps) => {
36
40
  BadgeStyles.useVariants({
37
41
  variant,
@@ -46,12 +50,13 @@ const Badge = ({
46
50
  <View
47
51
  testID="varia-badge"
48
52
  style={[
49
- styles.badge,
50
- styles.badgeAbsolute(x, y),
51
53
  BadgeStyles.container(colorPalette),
52
54
  mixins && mixins,
55
+ containerStyles,
56
+ styles.badgeAbsolute(x, y),
57
+ styles.badge,
53
58
  ]}>
54
- <Text style={[styles.text, BadgeStyles.text(colorPalette)]}>
59
+ <Text style={[BadgeStyles.text(colorPalette), textStyles, styles.text]}>
55
60
  {displayedContent}
56
61
  </Text>
57
62
  </View>
@@ -60,11 +65,12 @@ const Badge = ({
60
65
  <View
61
66
  testID="varia-badge"
62
67
  style={[
63
- styles.badge,
64
68
  BadgeStyles.container(colorPalette),
65
69
  mixins && mixins,
70
+ containerStyles,
71
+ styles.badge,
66
72
  ]}>
67
- <Text style={[styles.text, BadgeStyles.text(colorPalette)]}>
73
+ <Text style={[BadgeStyles.text(colorPalette), textStyles, styles.text]}>
68
74
  {displayedContent}
69
75
  </Text>
70
76
  </View>
@@ -1,4 +1,10 @@
1
- import {StyleProp, Text, TouchableOpacity, ViewStyle} from 'react-native'
1
+ import {
2
+ StyleProp,
3
+ Text,
4
+ TextStyle,
5
+ TouchableOpacity,
6
+ ViewStyle,
7
+ } from 'react-native'
2
8
  import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
3
9
  import {ButtonStyles, ButtonDefaultVariants} from '../../theme/Button.recipe'
4
10
  import {useMemo} from 'react'
@@ -35,7 +41,8 @@ type ButtonProps = ButtonVariants & {
35
41
  size?: number
36
42
  }
37
43
  mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[]
38
- style?: StyleProp<ViewStyle>
44
+ containerStyles?: StyleProp<ViewStyle>
45
+ textStyles?: StyleProp<TextStyle>
39
46
  }
40
47
 
41
48
  const Button = ({
@@ -52,7 +59,8 @@ const Button = ({
52
59
  textAdjustment = 'singleLine',
53
60
  icon,
54
61
  mixins,
55
- style,
62
+ containerStyles,
63
+ textStyles,
56
64
  }: ButtonProps) => {
57
65
  ButtonStyles.useVariants({
58
66
  size,
@@ -104,10 +112,10 @@ const Button = ({
104
112
  role="button"
105
113
  activeOpacity={activeOpacity}
106
114
  style={[
107
- styles.container(flex, maxWidth),
108
115
  ButtonStyles.container(colorPalette),
109
116
  mixins && mixins,
110
- style,
117
+ containerStyles,
118
+ styles.container(flex, maxWidth),
111
119
  ]}
112
120
  onPress={onPress}
113
121
  disabled={disabled || loading}>
@@ -119,7 +127,11 @@ const Button = ({
119
127
  {text && (
120
128
  <Text
121
129
  {...getTextProps()}
122
- style={[styles.text, ButtonStyles.text(colorPalette)]}>
130
+ style={[
131
+ ButtonStyles.text(colorPalette),
132
+ textStyles,
133
+ styles.text,
134
+ ]}>
123
135
  {text}
124
136
  </Text>
125
137
  )}
@@ -1,5 +1,12 @@
1
1
  import React, {useCallback} from 'react'
2
- import {View, Text, Pressable} from 'react-native'
2
+ import {
3
+ View,
4
+ Text,
5
+ Pressable,
6
+ ViewStyle,
7
+ StyleProp,
8
+ TextStyle,
9
+ } from 'react-native'
3
10
  import {StyleSheet} from 'react-native-unistyles'
4
11
  import {UnistylesVariants} from 'react-native-unistyles'
5
12
  import {
@@ -17,6 +24,9 @@ type CheckboxProps = CheckboxVariants & {
17
24
  colorPalette?: PalettesWithNestedKeys
18
25
  checked: boolean
19
26
  onCheckedChange: (checked: boolean) => void
27
+ containerStyles?: StyleProp<ViewStyle>
28
+ checkContainerStyles?: StyleProp<ViewStyle>
29
+ checkboxLabelStyles?: StyleProp<TextStyle>
20
30
  }
21
31
 
22
32
  function Checkbox({
@@ -26,6 +36,9 @@ function Checkbox({
26
36
  colorPalette = 'accent',
27
37
  variant = CheckboxDefaultVariants.variant,
28
38
  size = CheckboxDefaultVariants.size,
39
+ containerStyles,
40
+ checkContainerStyles,
41
+ checkboxLabelStyles,
29
42
  }: CheckboxProps) {
30
43
  CheckboxStyles.useVariants({variant, size, checked})
31
44
 
@@ -52,13 +65,18 @@ function Checkbox({
52
65
  return (
53
66
  <Pressable
54
67
  testID="varia-checkbox-container"
55
- style={[styles.container, CheckboxStyles.container(colorPalette)]}
68
+ style={[
69
+ CheckboxStyles.container(colorPalette),
70
+ containerStyles,
71
+ styles.container,
72
+ ]}
56
73
  onPress={handlePress}>
57
74
  <View
58
75
  testID="varia-check-container"
59
76
  style={[
60
- styles.checkContainer,
61
77
  CheckboxStyles.checkContainer(colorPalette),
78
+ checkContainerStyles,
79
+ styles.checkContainer,
62
80
  ]}>
63
81
  {isChecked && (
64
82
  <Check testID="varia-check" size={checkSize} color={checkColor} />
@@ -66,7 +84,7 @@ function Checkbox({
66
84
  </View>
67
85
  <Text
68
86
  testID="varia-checkbox-label"
69
- style={CheckboxStyles.label(colorPalette)}>
87
+ style={[CheckboxStyles.label(colorPalette), checkboxLabelStyles]}>
70
88
  {children}
71
89
  </Text>
72
90
  </Pressable>
@@ -1,5 +1,5 @@
1
1
  import {useEffect} from 'react'
2
- import {TextStyle, View, ViewStyle} from 'react-native'
2
+ import {StyleProp, TextStyle, View, ViewStyle} from 'react-native'
3
3
  import Animated, {
4
4
  Easing,
5
5
  interpolate,
@@ -40,6 +40,8 @@ interface CircleProgressProps {
40
40
  flex?: ViewStyle['flex']
41
41
  width?: ViewStyle['width']
42
42
  height?: ViewStyle['height']
43
+ containerStyles?: StyleProp<ViewStyle>
44
+ childStyles?: StyleProp<ViewStyle>
43
45
  }
44
46
 
45
47
  const BaseCircleProgress = ({
@@ -59,6 +61,8 @@ const BaseCircleProgress = ({
59
61
  flex = 1,
60
62
  width = '100%',
61
63
  height,
64
+ containerStyles,
65
+ childStyles,
62
66
  }: CircleProgressProps) => {
63
67
  const resolvedSize = circleProgressTokens.variants.size[size]
64
68
 
@@ -116,7 +120,7 @@ const BaseCircleProgress = ({
116
120
  })
117
121
 
118
122
  return (
119
- <View style={styles.container(flex, width, height)}>
123
+ <View style={[containerStyles, styles.container(flex, width, height)]}>
120
124
  <Svg
121
125
  width="100%"
122
126
  height="100%"
@@ -147,7 +151,7 @@ const BaseCircleProgress = ({
147
151
  animatedProps={animatedProps}></AnimatedCircle>
148
152
  </G>
149
153
  </Svg>
150
- <View style={styles.childContainer}>{children}</View>
154
+ <View style={[childStyles, styles.childContainer]}>{children}</View>
151
155
  </View>
152
156
  )
153
157
  }
@@ -1,4 +1,4 @@
1
- import {View} from 'react-native'
1
+ import {View, ViewStyle, StyleProp} from 'react-native'
2
2
  import {StyleSheet} from 'react-native-unistyles'
3
3
  import {PalettesWithNestedKeys, ThemeColors} from '../../style/varia/types'
4
4
  import {resolveColor} from '../../style/varia/utils'
@@ -9,20 +9,24 @@ const Divider = ({
9
9
  axis = 'y',
10
10
  margin = 0,
11
11
  colorPalette = 'accent',
12
+ containerStyles,
13
+ dividerStyles,
12
14
  }: {
13
15
  color?: ThemeColors
14
16
  size?: number
15
17
  axis?: 'x' | 'y'
16
18
  margin?: number
17
19
  colorPalette?: PalettesWithNestedKeys
20
+ containerStyles?: StyleProp<ViewStyle>
21
+ dividerStyles?: StyleProp<ViewStyle>
18
22
  }) => {
19
23
  return (
20
24
  <View
21
25
  testID="varia-divider-container"
22
- style={styles.container(size, axis, margin)}>
26
+ style={[styles.container(size, axis, margin), containerStyles]}>
23
27
  <View
24
28
  testID="varia-divider"
25
- style={[styles.divider(color, colorPalette, size, axis)]}
29
+ style={[styles.divider(color, colorPalette, size, axis), dividerStyles]}
26
30
  />
27
31
  </View>
28
32
  )
@@ -9,8 +9,10 @@ import React, {
9
9
  import {
10
10
  Dimensions,
11
11
  Keyboard,
12
+ StyleProp,
12
13
  TouchableWithoutFeedback,
13
14
  View,
15
+ ViewStyle,
14
16
  } from 'react-native'
15
17
  import {Gesture, GestureDetector} from 'react-native-gesture-handler'
16
18
  import Animated, {
@@ -46,15 +48,25 @@ type DrawerVariants = UnistylesVariants<typeof DrawerStyles>
46
48
  type DrawerContextType = DrawerVariants & {
47
49
  colorPalette: PalettesWithNestedKeys
48
50
  overlayOpacity: SharedValue<number>
51
+ positionerStyles?: StyleProp<ViewStyle>
52
+ overlayStyles?: StyleProp<ViewStyle>
53
+ sliderStyles?: StyleProp<ViewStyle>
49
54
  }
50
55
 
51
56
  type DrawerRootProps = DrawerVariants & {
52
57
  colorPalette?: PalettesWithNestedKeys
53
58
  children?: React.ReactNode
54
59
  zIndex?: ZIndex
60
+ positionerStyles?: StyleProp<ViewStyle>
61
+ overlayStyles?: StyleProp<ViewStyle>
62
+ sliderStyles?: StyleProp<ViewStyle>
55
63
  }
56
64
 
57
65
  const DrawerContext = createContext<DrawerContextType | null>(null)
66
+ export const DrawerGestureContext = createContext<null | ReturnType<
67
+ typeof Gesture.Pan
68
+ >>(null)
69
+
58
70
  const useDrawer = () => {
59
71
  const ctx = useContext(DrawerContext)
60
72
  if (!ctx)
@@ -67,6 +79,9 @@ const DrawerRoot = ({
67
79
  variant = DrawerTokens.defaultProps.variant,
68
80
  zIndex,
69
81
  children,
82
+ positionerStyles,
83
+ overlayStyles,
84
+ sliderStyles,
70
85
  }: DrawerRootProps) => {
71
86
  DrawerStyles.useVariants({variant})
72
87
 
@@ -77,8 +92,18 @@ const DrawerRoot = ({
77
92
  variant,
78
93
  overlayOpacity,
79
94
  zIndex,
95
+ positionerStyles,
96
+ overlayStyles,
97
+ sliderStyles,
80
98
  }),
81
- [colorPalette, variant, zIndex],
99
+ [
100
+ colorPalette,
101
+ variant,
102
+ zIndex,
103
+ positionerStyles,
104
+ overlayStyles,
105
+ sliderStyles,
106
+ ],
82
107
  )
83
108
 
84
109
  return (
@@ -95,7 +120,7 @@ const DrawerPositioner = ({
95
120
  direction: 1 | -1
96
121
  axis: 'x' | 'y'
97
122
  }) => {
98
- const {variant} = useDrawer()
123
+ const {variant, positionerStyles} = useDrawer()
99
124
  DrawerStyles.useVariants({variant})
100
125
 
101
126
  type WithDirection = {direction?: 1 | -1; axis?: 'x' | 'y'}
@@ -113,8 +138,9 @@ const DrawerPositioner = ({
113
138
  return (
114
139
  <HStack
115
140
  style={[
116
- styles.positioner,
117
141
  DrawerStyles.positioner,
142
+ positionerStyles,
143
+ styles.positioner,
118
144
  {
119
145
  justifyContent:
120
146
  axis === 'y'
@@ -141,7 +167,7 @@ const AnimatedTouchable = Animated.createAnimatedComponent(
141
167
  const AnimatedView = Animated.createAnimatedComponent(View)
142
168
 
143
169
  const DrawerOverlay = ({onPress}: {onPress?: () => void}) => {
144
- const {colorPalette, overlayOpacity, variant} = useDrawer()
170
+ const {colorPalette, overlayOpacity, variant, overlayStyles} = useDrawer()
145
171
  DrawerStyles.useVariants({variant})
146
172
  const visible = useSharedValue(0)
147
173
 
@@ -165,9 +191,10 @@ const DrawerOverlay = ({onPress}: {onPress?: () => void}) => {
165
191
  <AnimatedTouchable onPress={onPress}>
166
192
  <AnimatedView
167
193
  style={[
194
+ DrawerStyles.overlay(colorPalette),
195
+ overlayStyles,
168
196
  StyleSheet.absoluteFillObject,
169
197
  displayOverlayStyle,
170
- DrawerStyles.overlay(colorPalette),
171
198
  {pointerEvents: 'auto'},
172
199
  ]}
173
200
  />
@@ -189,6 +216,8 @@ type InternalDrawerSliderProps = {
189
216
  ref?: React.RefObject<DrawerRef | null>
190
217
  externalTranslate?: SharedValue<number>
191
218
  zIndex?: ZIndex
219
+ snapThreshold?: number
220
+ snapThresholdMode?: 'relative' | 'absolute'
192
221
  }
193
222
 
194
223
  export type DrawerSliderProps = Omit<
@@ -214,8 +243,10 @@ const DrawerSliderInternal = ({
214
243
  externalTranslate,
215
244
  ref,
216
245
  zIndex,
246
+ snapThreshold = 0.5,
247
+ snapThresholdMode = 'relative',
217
248
  }: InternalDrawerSliderProps) => {
218
- const {variant, colorPalette, overlayOpacity} = useDrawer()
249
+ const {variant, colorPalette, overlayOpacity, sliderStyles} = useDrawer()
219
250
 
220
251
  DrawerStyles.useVariants({variant})
221
252
 
@@ -422,14 +453,28 @@ const DrawerSliderInternal = ({
422
453
  return
423
454
  }
424
455
 
456
+ // const forwardsThreshold =
457
+ // (points[context.value.snapPoint] +
458
+ // points[context.value.snapPoint + 1]) /
459
+ // 2
460
+ // const backwardsThreshold =
461
+ // (points[context.value.snapPoint] +
462
+ // points[context.value.snapPoint - 1]) /
463
+ // 2
464
+
465
+ const current = points[context.value.snapPoint]
466
+ const next = points[context.value.snapPoint + 1]
467
+ const prev = points[context.value.snapPoint - 1]
468
+
425
469
  const forwardsThreshold =
426
- (points[context.value.snapPoint] +
427
- points[context.value.snapPoint + 1]) /
428
- 2
470
+ next != null ? current + (next - current) * snapThreshold : current
471
+
429
472
  const backwardsThreshold =
430
- (points[context.value.snapPoint] +
431
- points[context.value.snapPoint - 1]) /
432
- 2
473
+ prev != null
474
+ ? snapThresholdMode === 'absolute'
475
+ ? current + (prev - current) * (1 - snapThreshold)
476
+ : current + (prev - current) * snapThreshold
477
+ : current
433
478
 
434
479
  if (translation * direction < 0) {
435
480
  if (
@@ -467,19 +512,22 @@ const DrawerSliderInternal = ({
467
512
  })
468
513
 
469
514
  return (
470
- <GestureDetector gesture={slideGesture}>
471
- <AnimatedView
472
- ref={viewRef}
473
- onLayout={onLayout}
474
- style={[
475
- styles.slider(zIndex || ZINDEXES.drawer),
476
- blockAnimatedStyle,
477
- DrawerStyles.slider(colorPalette),
478
- {pointerEvents: 'auto'},
479
- ]}>
480
- {children}
481
- </AnimatedView>
482
- </GestureDetector>
515
+ <DrawerGestureContext.Provider value={slideGesture}>
516
+ <GestureDetector gesture={slideGesture}>
517
+ <AnimatedView
518
+ ref={viewRef}
519
+ onLayout={onLayout}
520
+ style={[
521
+ DrawerStyles.slider(colorPalette),
522
+ sliderStyles,
523
+ styles.slider(zIndex || ZINDEXES.drawer),
524
+ blockAnimatedStyle,
525
+ {pointerEvents: 'auto'},
526
+ ]}>
527
+ {children}
528
+ </AnimatedView>
529
+ </GestureDetector>
530
+ </DrawerGestureContext.Provider>
483
531
  )
484
532
  }
485
533
 
@@ -7,7 +7,7 @@ import FieldContext, {
7
7
  FieldVariants,
8
8
  useField,
9
9
  } from './context/Field'
10
- import {StyleProp, View, ViewStyle} from 'react-native'
10
+ import {StyleProp, TextStyle, View, ViewStyle} from 'react-native'
11
11
  import {StyleSheet} from 'react-native-unistyles'
12
12
 
13
13
  type FieldRootProps = FieldVariants & {
@@ -15,7 +15,8 @@ type FieldRootProps = FieldVariants & {
15
15
  error?: string
16
16
  colorPalette?: PalettesWithNestedKeys
17
17
  flex?: number
18
- style?: StyleProp<ViewStyle>
18
+ containerStyles?: StyleProp<ViewStyle>
19
+ labelStyles?: StyleProp<TextStyle>
19
20
  }
20
21
 
21
22
  const FieldRoot = ({
@@ -25,7 +26,8 @@ const FieldRoot = ({
25
26
  size = DefaultFieldVariants.size,
26
27
  colorPalette = 'accent',
27
28
  flex = 0,
28
- style,
29
+ containerStyles,
30
+ labelStyles,
29
31
  }: FieldRootProps) => {
30
32
  FieldStyles.useVariants({size})
31
33
 
@@ -34,6 +36,7 @@ const FieldRoot = ({
34
36
  variant,
35
37
  size,
36
38
  colorPalette,
39
+ labelStyles,
37
40
  }
38
41
 
39
42
  FieldStyles.useVariants({variant, size})
@@ -42,9 +45,9 @@ const FieldRoot = ({
42
45
  <View
43
46
  testID="varia-field-root"
44
47
  style={[
45
- styles.root(flex),
46
48
  FieldStyles.root(colorPalette),
47
- style && style,
49
+ containerStyles && containerStyles,
50
+ styles.root(flex),
48
51
  ]}>
49
52
  <FieldContext.Provider value={contextValue}>
50
53
  {children}
@@ -65,6 +68,7 @@ const FieldLabel = ({children, ...props}: FieldLabelProps) => {
65
68
  size,
66
69
  variant,
67
70
  colorPalette = 'accent',
71
+ labelStyles,
68
72
  } = {
69
73
  ...useField(),
70
74
  ...props,
@@ -73,7 +77,9 @@ const FieldLabel = ({children, ...props}: FieldLabelProps) => {
73
77
  FieldStyles.useVariants({variant, size})
74
78
 
75
79
  return (
76
- <Text testID="varia-field-label" style={FieldStyles.label(colorPalette)}>
80
+ <Text
81
+ testID="varia-field-label"
82
+ style={[FieldStyles.label(colorPalette), labelStyles]}>
77
83
  {children}
78
84
  </Text>
79
85
  )