react-native-varia 0.0.1 → 0.2.1
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.
- package/bin/cli.js +35 -18
- package/lib/components/Badge.tsx +31 -32
- package/lib/components/Button.tsx +20 -20
- package/lib/components/Checkbox.tsx +95 -0
- package/lib/components/CircleProgress.tsx +56 -66
- package/lib/components/Field.tsx +137 -0
- package/lib/components/GradientBackground.tsx +17 -18
- package/lib/components/GradientText.tsx +25 -64
- package/lib/components/IconWrapper.tsx +32 -25
- package/lib/components/Input.tsx +66 -68
- package/lib/components/Link.tsx +14 -28
- package/lib/components/Modal.tsx +197 -97
- package/lib/components/NewSelect.tsx +202 -0
- package/lib/components/NumberInput.tsx +226 -0
- package/lib/components/RadioGroup.tsx +195 -0
- package/lib/components/ReText.tsx +53 -87
- package/lib/components/Select.tsx +272 -0
- package/lib/components/SelectOld.tsx +153 -0
- package/lib/components/Slider.tsx +32 -40
- package/lib/components/Slideshow.tsx +174 -261
- package/lib/components/SlidingDrawer.tsx +216 -265
- package/lib/components/Spinner.tsx +21 -12
- package/lib/components/Switch.tsx +133 -180
- package/lib/components/Switchold.tsx +174 -0
- package/lib/components/Text.tsx +36 -83
- package/lib/components/layoutTest.tsx +74 -0
- package/lib/patterns/index.tsx +143 -202
- package/lib/theme/Badge.recipe.tsx +44 -39
- package/lib/theme/Button.recipe.tsx +139 -48
- package/lib/theme/Checkbox.recipe.tsx +121 -0
- package/lib/theme/CircleProgress.recipe.tsx +16 -22
- package/lib/theme/Field.recipe.tsx +66 -0
- package/lib/theme/GradientBackground.recipe.tsx +7 -20
- package/lib/theme/GradientText.recipe.tsx +42 -28
- package/lib/theme/IconWrapper.recipe.tsx +10 -85
- package/lib/theme/Input.recipe.tsx +76 -83
- package/lib/theme/Link.recipe.tsx +16 -43
- package/lib/theme/Modal.recipe.tsx +59 -21
- package/lib/theme/NumberInput.recipe.tsx +191 -0
- package/lib/theme/RadioGroup.recipe.tsx +163 -0
- package/lib/theme/ReText.recipe.tsx +4 -7
- package/lib/theme/Select.recipe.tsx +121 -0
- package/lib/theme/Slider.recipe.tsx +97 -181
- package/lib/theme/Slideshow.recipe.tsx +24 -102
- package/lib/theme/SlidingDrawer.recipe.tsx +21 -59
- package/lib/theme/Spinner.recipe.tsx +28 -3
- package/lib/theme/Switch.recipe.tsx +75 -54
- package/lib/theme/Text.recipe.tsx +66 -8
- package/lib/theme/animations.tsx +13 -0
- package/lib/varia/colorPalettes/amber.ts +54 -0
- package/lib/varia/colorPalettes/blue.ts +54 -0
- package/lib/varia/colorPalettes/bronze.ts +54 -0
- package/lib/varia/colorPalettes/brown.ts +54 -0
- package/lib/varia/colorPalettes/crimson.ts +55 -0
- package/lib/varia/colorPalettes/cyan.ts +54 -0
- package/lib/varia/colorPalettes/gold.ts +54 -0
- package/lib/varia/colorPalettes/grass.ts +54 -0
- package/lib/varia/colorPalettes/green.ts +54 -0
- package/lib/varia/colorPalettes/indigo.ts +54 -0
- package/lib/varia/colorPalettes/iris.ts +54 -0
- package/lib/varia/colorPalettes/jade.ts +54 -0
- package/lib/varia/colorPalettes/lime.ts +55 -0
- package/lib/varia/colorPalettes/mauve.ts +54 -0
- package/lib/varia/colorPalettes/mint.ts +54 -0
- package/lib/varia/colorPalettes/neutral.ts +54 -0
- package/lib/varia/colorPalettes/olive.ts +54 -0
- package/lib/varia/colorPalettes/orange.ts +54 -0
- package/lib/varia/colorPalettes/pink.ts +54 -0
- package/lib/varia/colorPalettes/plum.ts +54 -0
- package/lib/varia/colorPalettes/purple.ts +56 -0
- package/lib/varia/colorPalettes/red.ts +55 -0
- package/lib/varia/colorPalettes/ruby.ts +56 -0
- package/lib/varia/colorPalettes/sage.ts +56 -0
- package/lib/varia/colorPalettes/sand.ts +56 -0
- package/lib/varia/colorPalettes/sky.ts +56 -0
- package/lib/varia/colorPalettes/slate.ts +56 -0
- package/lib/varia/colorPalettes/teal.ts +56 -0
- package/lib/varia/colorPalettes/tomato.ts +56 -0
- package/lib/varia/colorPalettes/violet.ts +56 -0
- package/lib/varia/colorPalettes/yellow.ts +56 -0
- package/lib/varia/defaultTheme.ts +174 -0
- package/lib/varia/mixins.ts +223 -0
- package/lib/varia/textStyles.ts +48 -0
- package/lib/varia/types.ts +277 -0
- package/lib/varia/utils.ts +283 -0
- package/package.json +1 -1
|
@@ -1,286 +1,243 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { StyleSheet, UnistylesVariants } from 'react-native-unistyles';
|
|
1
|
+
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
|
2
|
+
import React, {useImperativeHandle} from 'react'
|
|
3
|
+
import {StyleSheet, UnistylesVariants} from 'react-native-unistyles'
|
|
5
4
|
import Animated, {
|
|
6
5
|
useAnimatedStyle,
|
|
7
6
|
useSharedValue,
|
|
8
7
|
withSpring,
|
|
9
8
|
withTiming,
|
|
10
9
|
type SharedValue,
|
|
11
|
-
} from 'react-native-reanimated'
|
|
12
|
-
import {runOnJS} from 'react-native-worklets'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// } from '../style/styles/types';
|
|
19
|
-
// import { useTokens } from '../style/useTokens';
|
|
20
|
-
import {SlidingDrawerTokens, SlidingDrawerStyles} from '../theme/SlidingDrawer.recipe';
|
|
10
|
+
} from 'react-native-reanimated'
|
|
11
|
+
import {runOnJS} from 'react-native-worklets'
|
|
12
|
+
import {
|
|
13
|
+
SlidingDrawerTokens,
|
|
14
|
+
SlidingDrawerStyles,
|
|
15
|
+
} from '../theme/SlidingDrawer.recipe'
|
|
16
|
+
import {PalettesWithNestedKeys} from '../style/varia/types'
|
|
21
17
|
|
|
22
18
|
export type SlidingDrawerRef = {
|
|
23
|
-
snapTo: (point: number) => void | null
|
|
24
|
-
expand: () => void | null
|
|
25
|
-
collapse: () => void | null
|
|
26
|
-
}
|
|
19
|
+
snapTo: (point: number) => void | null
|
|
20
|
+
expand: () => void | null
|
|
21
|
+
collapse: () => void | null
|
|
22
|
+
}
|
|
27
23
|
|
|
28
|
-
type SlidingDrawerVariants = UnistylesVariants<typeof SlidingDrawerStyles
|
|
24
|
+
type SlidingDrawerVariants = UnistylesVariants<typeof SlidingDrawerStyles>
|
|
29
25
|
|
|
30
26
|
type SlidingDrawerProps = SlidingDrawerVariants & {
|
|
31
|
-
|
|
32
|
-
animation?: keyof typeof SlidingDrawerTokens.variants.animation
|
|
33
|
-
flex?: number
|
|
34
|
-
direction?: 1 | -1
|
|
35
|
-
onCollapse?: () => void
|
|
36
|
-
onExpand?: () => void
|
|
37
|
-
onSnap?: (point: number) => void
|
|
38
|
-
snapPoints: number[]
|
|
39
|
-
axis: 'y' | 'x'
|
|
40
|
-
allowGestures?: boolean
|
|
41
|
-
overlay?: boolean
|
|
42
|
-
children?: React.ReactNode
|
|
43
|
-
|
|
44
|
-
// mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[];
|
|
45
|
-
ref?: React.RefObject<SlidingDrawerRef>;
|
|
27
|
+
colorPalette?: PalettesWithNestedKeys
|
|
28
|
+
animation?: keyof typeof SlidingDrawerTokens.variants.animation
|
|
29
|
+
flex?: number
|
|
30
|
+
direction?: 1 | -1
|
|
31
|
+
onCollapse?: () => void
|
|
32
|
+
onExpand?: () => void
|
|
33
|
+
onSnap?: (point: number) => void
|
|
34
|
+
snapPoints: number[]
|
|
35
|
+
axis: 'y' | 'x'
|
|
36
|
+
allowGestures?: boolean
|
|
37
|
+
overlay?: boolean
|
|
38
|
+
children?: React.ReactNode
|
|
39
|
+
ref?: React.RefObject<SlidingDrawerRef>
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
const SlidingDrawer = ({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const context: SharedValue<{
|
|
90
|
-
position: any;
|
|
91
|
-
snapPoint: number;
|
|
92
|
-
}> = useSharedValue({
|
|
93
|
-
position: points[0], // Default position
|
|
94
|
-
snapPoint: 0, // Default snapPoint
|
|
95
|
-
});
|
|
43
|
+
colorPalette = 'accent',
|
|
44
|
+
variant = SlidingDrawerTokens.defaultProps.variant,
|
|
45
|
+
animation = SlidingDrawerTokens.defaultProps.animation,
|
|
46
|
+
flex = 0,
|
|
47
|
+
direction = 1,
|
|
48
|
+
onCollapse,
|
|
49
|
+
onExpand,
|
|
50
|
+
onSnap,
|
|
51
|
+
snapPoints,
|
|
52
|
+
axis,
|
|
53
|
+
allowGestures = true,
|
|
54
|
+
overlay = false,
|
|
55
|
+
children,
|
|
56
|
+
ref,
|
|
57
|
+
}: SlidingDrawerProps) => {
|
|
58
|
+
SlidingDrawerStyles.useVariants({
|
|
59
|
+
variant,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const points = snapPoints.map(point => point * direction)
|
|
63
|
+
|
|
64
|
+
const translate = useSharedValue(points[0])
|
|
65
|
+
|
|
66
|
+
const context: SharedValue<{
|
|
67
|
+
position: any
|
|
68
|
+
snapPoint: number
|
|
69
|
+
}> = useSharedValue({
|
|
70
|
+
position: points[0],
|
|
71
|
+
snapPoint: 0,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const changeDisplay = useSharedValue('none')
|
|
75
|
+
const opacity = useSharedValue(0)
|
|
76
|
+
|
|
77
|
+
const VELOCITY_THRESHOLD = 2000
|
|
78
|
+
|
|
79
|
+
const updateCurrentSnapPoint = (snapPoint: number) => {
|
|
80
|
+
'worklet'
|
|
81
|
+
context.value = {position: context.value.position, snapPoint}
|
|
82
|
+
}
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
const animations = {
|
|
85
|
+
withSpring,
|
|
86
|
+
withTiming,
|
|
87
|
+
}
|
|
99
88
|
|
|
100
|
-
|
|
89
|
+
const animationVariant = SlidingDrawerTokens.variants.animation[animation]
|
|
101
90
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
context.value = { position: context.value.position, snapPoint };
|
|
105
|
-
};
|
|
91
|
+
const snapTo = (destination: number) => {
|
|
92
|
+
'worklet'
|
|
106
93
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
94
|
+
if (animationVariant && animationVariant.type) {
|
|
95
|
+
translate.value = animations[animationVariant.type](
|
|
96
|
+
points[destination],
|
|
97
|
+
animationVariant.props,
|
|
98
|
+
)
|
|
99
|
+
updateCurrentSnapPoint(destination)
|
|
100
|
+
onSnap && runOnJS(onSnap)(destination)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
const expand = () => {
|
|
105
|
+
snapTo(points.length - 1)
|
|
106
|
+
if (overlay) {
|
|
107
|
+
showOverlay()
|
|
108
|
+
}
|
|
109
|
+
onExpand && runOnJS(onExpand)()
|
|
110
|
+
}
|
|
115
111
|
|
|
116
|
-
|
|
112
|
+
const isCollapsed = () => {
|
|
113
|
+
'worklet'
|
|
114
|
+
return context.value.snapPoint === 0
|
|
115
|
+
}
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const collapse = () => {
|
|
118
|
+
snapTo(0)
|
|
119
|
+
if (overlay) {
|
|
120
|
+
hideOverlay()
|
|
121
|
+
}
|
|
122
|
+
onCollapse && runOnJS(onCollapse)()
|
|
123
|
+
}
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
const hideOverlay = () => {
|
|
126
|
+
'worklet'
|
|
127
|
+
changeDisplay.value = 'none'
|
|
128
|
+
opacity.value = withTiming(0, {duration: 200})
|
|
129
|
+
}
|
|
130
|
+
const showOverlay = () => {
|
|
131
|
+
'worklet'
|
|
132
|
+
changeDisplay.value = 'flex'
|
|
133
|
+
opacity.value = withTiming(1, {duration: 200})
|
|
134
|
+
}
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
useImperativeHandle(ref, () => ({
|
|
137
|
+
expand,
|
|
138
|
+
collapse,
|
|
139
|
+
snapTo,
|
|
140
|
+
isCollapsed,
|
|
141
|
+
}))
|
|
142
|
+
|
|
143
|
+
const slideGesture = Gesture.Pan()
|
|
144
|
+
.enabled(allowGestures)
|
|
145
|
+
.onBegin(() => {
|
|
146
|
+
context.value.position = translate.value
|
|
147
|
+
})
|
|
148
|
+
.onUpdate(event => {
|
|
149
|
+
const delta = axis === 'y' ? event.translationY : event.translationX
|
|
150
|
+
translate.value = delta + (context.value.position ?? 0)
|
|
151
|
+
})
|
|
152
|
+
.onEnd(({velocityX, velocityY, translationX, translationY}) => {
|
|
153
|
+
const velocity = axis === 'y' ? velocityY : velocityX
|
|
154
|
+
const translation = axis === 'y' ? translationY : translationX
|
|
155
|
+
|
|
156
|
+
const forwardsThreshold =
|
|
157
|
+
(points[context.value.snapPoint] +
|
|
158
|
+
points[context.value.snapPoint + 1]) /
|
|
159
|
+
2
|
|
160
|
+
const backwardsThreshold =
|
|
161
|
+
(points[context.value.snapPoint] +
|
|
162
|
+
points[context.value.snapPoint - 1]) /
|
|
163
|
+
2
|
|
164
|
+
|
|
165
|
+
if (translation * direction < 0) {
|
|
166
|
+
if (
|
|
167
|
+
((direction === 1 && translate.value < forwardsThreshold) ||
|
|
168
|
+
(direction === -1 && translate.value > forwardsThreshold) ||
|
|
169
|
+
velocity * direction < -VELOCITY_THRESHOLD) &&
|
|
170
|
+
context.value.snapPoint < points.length - 1
|
|
171
|
+
) {
|
|
172
|
+
snapTo(context.value.snapPoint + 1)
|
|
173
|
+
} else {
|
|
174
|
+
snapTo(context.value.snapPoint)
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
if (
|
|
178
|
+
((direction === 1 && translate.value > backwardsThreshold) ||
|
|
179
|
+
(direction === -1 && translate.value < backwardsThreshold) ||
|
|
180
|
+
velocity * direction > VELOCITY_THRESHOLD) &&
|
|
181
|
+
context.value.snapPoint > 0
|
|
182
|
+
) {
|
|
183
|
+
snapTo(context.value.snapPoint - 1)
|
|
184
|
+
} else {
|
|
185
|
+
snapTo(context.value.snapPoint)
|
|
186
|
+
}
|
|
136
187
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const isCollapsed = () => {
|
|
141
|
-
'worklet';
|
|
142
|
-
return context.value.snapPoint === 0;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const collapse = () => {
|
|
146
|
-
snapTo(0);
|
|
188
|
+
})
|
|
189
|
+
.onFinalize(() => {
|
|
147
190
|
if (overlay) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onCollapse && runOnJS(onCollapse)();
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const hideOverlay = () => {
|
|
154
|
-
'worklet';
|
|
155
|
-
changeDisplay.value = 'none';
|
|
156
|
-
opacity.value = withTiming(0, { duration: 200 });
|
|
157
|
-
};
|
|
158
|
-
const showOverlay = () => {
|
|
159
|
-
'worklet';
|
|
160
|
-
changeDisplay.value = 'flex';
|
|
161
|
-
opacity.value = withTiming(1, { duration: 200 });
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
useImperativeHandle(ref, () => ({
|
|
165
|
-
expand,
|
|
166
|
-
collapse,
|
|
167
|
-
snapTo,
|
|
168
|
-
isCollapsed,
|
|
169
|
-
}));
|
|
170
|
-
|
|
171
|
-
// const endLimit = direction === 1 ? points[0] : points[points.length - 1];
|
|
172
|
-
|
|
173
|
-
const slideGesture = Gesture.Pan()
|
|
174
|
-
.enabled(allowGestures)
|
|
175
|
-
.onBegin(() => {
|
|
176
|
-
context.value.position = translate.value;
|
|
177
|
-
})
|
|
178
|
-
.onUpdate((event) => {
|
|
179
|
-
const delta = axis === 'y' ? event.translationY : event.translationX;
|
|
180
|
-
translate.value = delta + (context.value.position ?? 0);
|
|
181
|
-
})
|
|
182
|
-
.onEnd(({ velocityX, velocityY, translationX, translationY }) => {
|
|
183
|
-
const velocity = axis === 'y' ? velocityY : velocityX;
|
|
184
|
-
const translation = axis === 'y' ? translationY : translationX;
|
|
185
|
-
|
|
186
|
-
const forwardsThreshold =
|
|
187
|
-
// @ts-ignore
|
|
188
|
-
(points[context.value.snapPoint] +
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
points[context.value.snapPoint + 1]) /
|
|
191
|
-
2;
|
|
192
|
-
const backwardsThreshold =
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
(points[context.value.snapPoint] +
|
|
195
|
-
// @ts-ignore
|
|
196
|
-
points[context.value.snapPoint - 1]) /
|
|
197
|
-
2;
|
|
198
|
-
|
|
199
|
-
if (translation * direction < 0) {
|
|
200
|
-
if (
|
|
201
|
-
// @ts-ignore
|
|
202
|
-
((direction === 1 && translate.value < forwardsThreshold) ||
|
|
203
|
-
// @ts-ignore
|
|
204
|
-
(direction === -1 && translate.value > forwardsThreshold) ||
|
|
205
|
-
velocity * direction < -VELOCITY_THRESHOLD) &&
|
|
206
|
-
context.value.snapPoint < points.length - 1
|
|
207
|
-
) {
|
|
208
|
-
snapTo(context.value.snapPoint + 1);
|
|
209
|
-
} else {
|
|
210
|
-
snapTo(context.value.snapPoint);
|
|
211
|
-
}
|
|
191
|
+
if (isCollapsed()) {
|
|
192
|
+
hideOverlay()
|
|
212
193
|
} else {
|
|
213
|
-
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
((direction === 1 && translate.value > backwardsThreshold) ||
|
|
216
|
-
// @ts-ignore
|
|
217
|
-
(direction === -1 && translate.value < backwardsThreshold) ||
|
|
218
|
-
velocity * direction > VELOCITY_THRESHOLD) &&
|
|
219
|
-
context.value.snapPoint > 0
|
|
220
|
-
) {
|
|
221
|
-
snapTo(context.value.snapPoint - 1);
|
|
222
|
-
} else {
|
|
223
|
-
snapTo(context.value.snapPoint);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
})
|
|
227
|
-
.onFinalize(() => {
|
|
228
|
-
if (overlay) {
|
|
229
|
-
if (isCollapsed()) {
|
|
230
|
-
hideOverlay();
|
|
231
|
-
} else {
|
|
232
|
-
showOverlay();
|
|
233
|
-
}
|
|
194
|
+
showOverlay()
|
|
234
195
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
],
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
;
|
|
282
|
-
|
|
283
|
-
export default SlidingDrawer;
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
const blockAnimatedStyle = useAnimatedStyle(() => {
|
|
200
|
+
return {
|
|
201
|
+
transform: [
|
|
202
|
+
{[axis === 'y' ? 'translateY' : 'translateX']: translate.value},
|
|
203
|
+
],
|
|
204
|
+
} as any
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
const displayOverlayStyle = useAnimatedStyle(() => {
|
|
208
|
+
return {
|
|
209
|
+
display: changeDisplay.value,
|
|
210
|
+
opacity: opacity.value,
|
|
211
|
+
} as any
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<>
|
|
216
|
+
{overlay && (
|
|
217
|
+
<Animated.View
|
|
218
|
+
style={[
|
|
219
|
+
{
|
|
220
|
+
...StyleSheet.absoluteFillObject,
|
|
221
|
+
},
|
|
222
|
+
displayOverlayStyle,
|
|
223
|
+
SlidingDrawerStyles.backdrop(colorPalette),
|
|
224
|
+
]}
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
<GestureDetector gesture={slideGesture}>
|
|
228
|
+
<Animated.View
|
|
229
|
+
style={[
|
|
230
|
+
styles.container(flex, direction, axis, SlidingDrawerTokens),
|
|
231
|
+
blockAnimatedStyle,
|
|
232
|
+
SlidingDrawerStyles.container(colorPalette),
|
|
233
|
+
]}>
|
|
234
|
+
{children}
|
|
235
|
+
</Animated.View>
|
|
236
|
+
</GestureDetector>
|
|
237
|
+
</>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
export default SlidingDrawer
|
|
284
241
|
|
|
285
242
|
const styles = StyleSheet.create({
|
|
286
243
|
container: (flex, direction, axis, slidingDrawerTokens): any => ({
|
|
@@ -291,17 +248,11 @@ const styles = StyleSheet.create({
|
|
|
291
248
|
flex: flex === 0 ? 1 : flex,
|
|
292
249
|
height: '100%',
|
|
293
250
|
width: '100%',
|
|
294
|
-
backgroundColor: slidingDrawerTokens.defaultProps.backgroundColor,
|
|
295
|
-
borderRadius: slidingDrawerTokens.defaultProps.borderRadius,
|
|
296
251
|
alignItems: 'center',
|
|
297
252
|
justifyContent: 'flex-start',
|
|
298
|
-
|
|
299
|
-
zIndex: 5,
|
|
300
|
-
// variants: {
|
|
301
|
-
// colorScheme: slidingDrawerTokens.variants.colorScheme,
|
|
302
|
-
// },
|
|
253
|
+
zIndex: 100,
|
|
303
254
|
}),
|
|
304
|
-
customStyle:
|
|
255
|
+
customStyle: style => ({
|
|
305
256
|
...style,
|
|
306
257
|
}),
|
|
307
|
-
})
|
|
258
|
+
})
|
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActivityIndicator,
|
|
3
|
-
ColorValue,
|
|
4
3
|
type ActivityIndicatorProps,
|
|
5
4
|
type StyleProp,
|
|
6
5
|
type ViewStyle,
|
|
7
6
|
} from 'react-native'
|
|
8
7
|
import {withUnistyles} from 'react-native-unistyles'
|
|
9
|
-
import {ThemeColors} from '../style/types'
|
|
8
|
+
import {PalettesWithNestedKeys, ThemeColors} from '../style/varia/types'
|
|
10
9
|
import {SpinnerTokens} from '../theme/Spinner.recipe'
|
|
10
|
+
import {resolveColor} from '../style/varia/utils'
|
|
11
|
+
import {SpinnerStyles} from '../theme/Spinner.recipe'
|
|
12
|
+
import {UnistylesVariants} from 'react-native-unistyles'
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
size
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
type SpinnerVariants = UnistylesVariants<typeof SpinnerStyles>
|
|
15
|
+
type SpinnerProps = SpinnerVariants &
|
|
16
|
+
Omit<ActivityIndicatorProps, 'size'> & {
|
|
17
|
+
color?: ThemeColors
|
|
18
|
+
style?: StyleProp<ViewStyle>
|
|
19
|
+
mixins?: StyleProp<ViewStyle> | StyleProp<ViewStyle>[]
|
|
20
|
+
colors: any
|
|
21
|
+
colorPalette?: PalettesWithNestedKeys
|
|
22
|
+
}
|
|
19
23
|
|
|
20
24
|
const BaseSpinner = ({
|
|
21
|
-
size = SpinnerTokens.defaultProps.size,
|
|
25
|
+
size = SpinnerTokens.defaultProps.size as SpinnerProps['size'],
|
|
22
26
|
color = SpinnerTokens.defaultProps.color,
|
|
23
27
|
style,
|
|
24
28
|
mixins,
|
|
25
29
|
colors,
|
|
30
|
+
colorPalette = 'accent',
|
|
26
31
|
...props
|
|
27
32
|
}: SpinnerProps) => {
|
|
28
|
-
const resolvedColor = color
|
|
33
|
+
const resolvedColor = resolveColor(color, colors, colorPalette)
|
|
34
|
+
|
|
35
|
+
SpinnerStyles.useVariants({
|
|
36
|
+
size,
|
|
37
|
+
})
|
|
29
38
|
|
|
30
39
|
return (
|
|
31
40
|
<ActivityIndicator
|
|
32
41
|
color={resolvedColor}
|
|
33
|
-
size={
|
|
42
|
+
size={SpinnerStyles.base.width}
|
|
34
43
|
{...props}
|
|
35
44
|
style={[style && style, mixins && mixins]}
|
|
36
45
|
/>
|