alambre 1.0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/components/animations/ToggleLightDark.d.ts +18 -0
- package/dist/components/animations/ToggleLightDark.js +106 -0
- package/dist/components/animations/animado/AnimadoText.d.ts +3 -0
- package/dist/components/animations/animado/AnimadoText.js +12 -0
- package/dist/components/animations/animado/AnimadoView.d.ts +3 -0
- package/dist/components/animations/animado/AnimadoView.js +12 -0
- package/dist/components/animations/animado/use-animado.d.ts +10 -0
- package/dist/components/animations/animado/use-animado.js +34 -0
- package/dist/components/animations/reanimated/Circle.d.ts +3 -0
- package/dist/components/animations/reanimated/Circle.js +57 -0
- package/dist/components/animations/reanimated/Pop.d.ts +3 -0
- package/dist/components/animations/reanimated/Pop.js +18 -0
- package/dist/components/animations/reanimated/Shake.d.ts +1 -0
- package/dist/components/animations/reanimated/Shake.js +37 -0
- package/dist/components/animations/reanimated/StyledAnimation.d.ts +6 -0
- package/dist/components/animations/reanimated/StyledAnimation.js +57 -0
- package/dist/components/base/SafeAreaView.d.ts +3 -0
- package/dist/components/base/SafeAreaView.js +6 -0
- package/dist/components/base/SubTitle.d.ts +3 -0
- package/dist/components/base/SubTitle.js +11 -0
- package/dist/components/base/Text.d.ts +3 -0
- package/dist/components/base/Text.js +4 -0
- package/dist/components/base/Title.d.ts +3 -0
- package/dist/components/base/Title.js +11 -0
- package/dist/components/base/View.d.ts +3 -0
- package/dist/components/base/View.js +6 -0
- package/dist/components/base/index.d.ts +6 -0
- package/dist/components/base/index.js +6 -0
- package/dist/components/base/input/buttons/BorderButton.d.ts +8 -0
- package/dist/components/base/input/buttons/BorderButton.js +20 -0
- package/dist/components/base/input/buttons/index.d.ts +1 -0
- package/dist/components/base/input/buttons/index.js +1 -0
- package/dist/components/icons/Arrow.d.ts +9 -0
- package/dist/components/icons/Arrow.js +43 -0
- package/dist/components/icons/Cross.d.ts +8 -0
- package/dist/components/icons/Cross.js +37 -0
- package/dist/components/icons/Moon.d.ts +3 -0
- package/dist/components/icons/Moon.js +47 -0
- package/dist/components/icons/Sun.d.ts +3 -0
- package/dist/components/icons/Sun.js +60 -0
- package/dist/components/icons/Tick.d.ts +8 -0
- package/dist/components/icons/Tick.js +37 -0
- package/dist/components/icons/base/Circle.d.ts +3 -0
- package/dist/components/icons/base/Circle.js +22 -0
- package/dist/components/icons/base/Line.d.ts +3 -0
- package/dist/components/icons/base/Line.js +24 -0
- package/dist/components/icons/base/Path.d.ts +9 -0
- package/dist/components/icons/base/Path.js +29 -0
- package/dist/components/icons/base/index.d.ts +3 -0
- package/dist/components/icons/base/index.js +3 -0
- package/dist/components/icons/index.d.ts +8 -0
- package/dist/components/icons/index.js +8 -0
- package/dist/components/icons/utils.d.ts +11 -0
- package/dist/components/icons/utils.js +10 -0
- package/dist/components/navigator/NavigatorBody.d.ts +20 -0
- package/dist/components/navigator/NavigatorBody.js +73 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/use-icon-animation.d.ts +3 -0
- package/dist/hooks/use-icon-animation.js +24 -0
- package/dist/hooks/use-stack.d.ts +6 -0
- package/dist/hooks/use-stack.js +17 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +13 -0
- package/dist/providers/create-config-provider.d.ts +9 -0
- package/dist/providers/create-config-provider.js +39 -0
- package/dist/providers/create-lang-provider.d.ts +11 -0
- package/dist/providers/create-lang-provider.js +38 -0
- package/dist/providers/create-light-dark-provider.d.ts +12 -0
- package/dist/providers/create-light-dark-provider.js +41 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +5 -0
- package/dist/providers/navigator-provider.d.ts +3 -0
- package/dist/providers/navigator-provider.js +54 -0
- package/dist/providers/toast-provider/context.d.ts +3 -0
- package/dist/providers/toast-provider/context.js +2 -0
- package/dist/providers/toast-provider/index.d.ts +2 -0
- package/dist/providers/toast-provider/index.js +2 -0
- package/dist/providers/toast-provider/provider.d.ts +3 -0
- package/dist/providers/toast-provider/provider.js +11 -0
- package/dist/providers/toast-provider/toast-body.d.ts +3 -0
- package/dist/providers/toast-provider/toast-body.js +97 -0
- package/dist/providers/toast-provider/types.d.ts +31 -0
- package/dist/providers/toast-provider/types.js +1 -0
- package/dist/providers/toast-provider/use-toast.d.ts +2 -0
- package/dist/providers/toast-provider/use-toast.js +8 -0
- package/dist/providers/toast-provider/value.d.ts +3 -0
- package/dist/providers/toast-provider/value.js +36 -0
- package/dist/types/actions.d.ts +4 -0
- package/dist/types/actions.js +1 -0
- package/dist/types/animado.d.ts +16 -0
- package/dist/types/animado.js +1 -0
- package/dist/types/default-react.d.ts +14 -0
- package/dist/types/default-react.js +1 -0
- package/dist/types/hooks.d.ts +17 -0
- package/dist/types/hooks.js +1 -0
- package/dist/types/icons.d.ts +15 -0
- package/dist/types/icons.js +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +6 -0
- package/dist/types/navigator.d.ts +22 -0
- package/dist/types/navigator.js +1 -0
- package/dist/utils/storage.d.ts +2 -0
- package/dist/utils/storage.js +18 -0
- package/index.ts +8 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marcos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# alambre
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ColorValue } from 'react-native';
|
|
2
|
+
import type { DefaultReact } from '../../types';
|
|
3
|
+
type Colors = {
|
|
4
|
+
background?: ColorValue;
|
|
5
|
+
border?: ColorValue;
|
|
6
|
+
circle?: ColorValue;
|
|
7
|
+
};
|
|
8
|
+
type ThemeColors = {
|
|
9
|
+
light?: Colors;
|
|
10
|
+
dark?: Colors;
|
|
11
|
+
};
|
|
12
|
+
type ToggleProps = DefaultReact.ViewProps & {
|
|
13
|
+
toggle: () => void;
|
|
14
|
+
setLeft?: boolean;
|
|
15
|
+
colors?: ThemeColors;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: ({ setLeft, toggle, colors, ...props }: ToggleProps) => import("react").JSX.Element;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { View, StyleSheet, Pressable } from 'react-native';
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedProps, useAnimatedStyle, withTiming, interpolateColor, withSpring, } from 'react-native-reanimated';
|
|
4
|
+
import Svg from 'react-native-svg';
|
|
5
|
+
import Sun from '../icons/Sun';
|
|
6
|
+
import Moon from '../icons/Moon';
|
|
7
|
+
import { AnimatedCircle } from '../icons/utils';
|
|
8
|
+
const RADIUS = 13;
|
|
9
|
+
const getColorConfig = (colors) => {
|
|
10
|
+
const { light = {}, dark = {} } = colors !== null && colors !== void 0 ? colors : {};
|
|
11
|
+
const safe = (c, fallback) => typeof c === 'string' ? c : fallback;
|
|
12
|
+
return {
|
|
13
|
+
light: {
|
|
14
|
+
background: safe(light.background, '#fff'),
|
|
15
|
+
border: safe(light.border, '#222'),
|
|
16
|
+
circle: safe(light.circle, '#222'),
|
|
17
|
+
},
|
|
18
|
+
dark: {
|
|
19
|
+
background: safe(dark.background, '#222'),
|
|
20
|
+
border: safe(dark.border, '#fff'),
|
|
21
|
+
circle: safe(dark.circle, '#fff'),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default ({ setLeft = true, toggle, colors = {}, ...props }) => {
|
|
26
|
+
// Default colors.
|
|
27
|
+
const { light, dark } = getColorConfig(colors);
|
|
28
|
+
// Hooks.
|
|
29
|
+
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
30
|
+
const [side, setSide] = useState(setLeft ? 1 : 0);
|
|
31
|
+
// Animation values.
|
|
32
|
+
const cx = useSharedValue(0);
|
|
33
|
+
const r = useSharedValue(0);
|
|
34
|
+
const progress = useSharedValue(setLeft ? 1 : 0);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setSide(setLeft ? 0 : 1);
|
|
37
|
+
}, [setLeft]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
progress.value = withSpring(side);
|
|
40
|
+
const offset = 73;
|
|
41
|
+
const leftOffset = offset;
|
|
42
|
+
const rightOffset = 300 - offset;
|
|
43
|
+
const { width, height } = size;
|
|
44
|
+
cx.value = withTiming(side === 0 ? leftOffset : rightOffset, { duration: 400 });
|
|
45
|
+
r.value = withTiming((width / height) * RADIUS, { duration: 300 });
|
|
46
|
+
}, [cx, progress, r, side, size]);
|
|
47
|
+
// Set width and circle variables.
|
|
48
|
+
const onLayout = (e) => {
|
|
49
|
+
const { width, height } = e.nativeEvent.layout;
|
|
50
|
+
setSize({ width, height });
|
|
51
|
+
};
|
|
52
|
+
// On press events.
|
|
53
|
+
const onBegin = () => (r.value = withTiming(r.value * 1.25, { duration: 200 }));
|
|
54
|
+
const onFinalize = () => {
|
|
55
|
+
const change = side === 0 ? 1 : 0;
|
|
56
|
+
setSide(change);
|
|
57
|
+
toggle();
|
|
58
|
+
};
|
|
59
|
+
// Animated props.
|
|
60
|
+
const circleAnimatedProps = useAnimatedProps(() => ({
|
|
61
|
+
cx: cx.value,
|
|
62
|
+
r: r.value,
|
|
63
|
+
fill: interpolateColor(progress.value, [0, 1], [light.circle, dark.circle]),
|
|
64
|
+
}));
|
|
65
|
+
const containerStyle = useAnimatedStyle(() => ({
|
|
66
|
+
backgroundColor: interpolateColor(progress.value, [0, 1], [light.background, dark.background]),
|
|
67
|
+
borderColor: interpolateColor(progress.value, [0, 1], [light.border, dark.border]),
|
|
68
|
+
}));
|
|
69
|
+
const drawAnimation = (v) => withTiming(v, { duration: 1700 });
|
|
70
|
+
return (<Pressable onPressIn={onBegin} onPressOut={onFinalize} {...props}>
|
|
71
|
+
<Animated.View onLayout={onLayout} style={[styles.container, containerStyle]}>
|
|
72
|
+
<Svg width="100%" height="100%" viewBox={'0 0 300 100'} style={styles.svg}>
|
|
73
|
+
<AnimatedCircle animatedProps={circleAnimatedProps} cy={50} opacity={0.4} fill={setLeft ? light.circle : dark.circle}/>
|
|
74
|
+
</Svg>
|
|
75
|
+
<View style={styles.row}>
|
|
76
|
+
<Sun drawIt={side === 0} style={styles.icon} iconAnimation={{ drawAnimation }}/>
|
|
77
|
+
<Moon drawIt={side === 1} style={styles.icon} iconAnimation={{ drawAnimation }}/>
|
|
78
|
+
</View>
|
|
79
|
+
</Animated.View>
|
|
80
|
+
</Pressable>);
|
|
81
|
+
};
|
|
82
|
+
const styles = StyleSheet.create({
|
|
83
|
+
container: {
|
|
84
|
+
width: '100%',
|
|
85
|
+
height: '100%',
|
|
86
|
+
borderRadius: 25,
|
|
87
|
+
borderWidth: 2,
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
},
|
|
91
|
+
svg: {
|
|
92
|
+
...StyleSheet.absoluteFillObject,
|
|
93
|
+
zIndex: 0,
|
|
94
|
+
},
|
|
95
|
+
row: {
|
|
96
|
+
...StyleSheet.absoluteFillObject,
|
|
97
|
+
flexDirection: 'row',
|
|
98
|
+
justifyContent: 'space-around',
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
zIndex: 1,
|
|
101
|
+
},
|
|
102
|
+
icon: {
|
|
103
|
+
height: '60%',
|
|
104
|
+
aspectRatio: 1,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import useAnimado from './use-animado';
|
|
4
|
+
export default ({ style, text, animation, ...props }) => {
|
|
5
|
+
const { animatedStyle, animateTo, } = useAnimado(style);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
animateTo(style, animation);
|
|
8
|
+
}, [animateTo, animation, style]);
|
|
9
|
+
return (<Animated.Text style={[style, animatedStyle]} {...props}>
|
|
10
|
+
{text}
|
|
11
|
+
</Animated.Text>);
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Animated from 'react-native-reanimated';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import useAnimado from './use-animado';
|
|
4
|
+
export default ({ style, animation, children, ...props }) => {
|
|
5
|
+
const { animatedStyle, animateTo, } = useAnimado(style);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
animateTo(style, animation);
|
|
8
|
+
}, [animateTo, animation, style]);
|
|
9
|
+
return (<Animated.View style={[style, animatedStyle]} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</Animated.View>);
|
|
12
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { State } from '../../../types/animado';
|
|
2
|
+
declare const _default: (initialState: State) => {
|
|
3
|
+
animatedStyle: {
|
|
4
|
+
backgroundColor: string;
|
|
5
|
+
borderColor: string;
|
|
6
|
+
color: string;
|
|
7
|
+
};
|
|
8
|
+
animateTo: (setNextState: State, animation?: (value: number) => number) => void;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useSharedValue, useAnimatedStyle, withTiming, interpolateColor, } from 'react-native-reanimated';
|
|
3
|
+
const filterTargets = (state) => {
|
|
4
|
+
const flat = StyleSheet.flatten(state);
|
|
5
|
+
const { backgroundColor, borderColor, color } = flat;
|
|
6
|
+
return { backgroundColor, borderColor, color };
|
|
7
|
+
};
|
|
8
|
+
export default (initialState) => {
|
|
9
|
+
const targets = filterTargets(initialState);
|
|
10
|
+
const prevState = useSharedValue(targets);
|
|
11
|
+
const nextState = useSharedValue(targets);
|
|
12
|
+
const progress = useSharedValue(0);
|
|
13
|
+
const defaultAnimation = (v) => withTiming(v, { duration: 300 });
|
|
14
|
+
const animateTo = (setNextState, animation = defaultAnimation) => {
|
|
15
|
+
prevState.value = nextState.value;
|
|
16
|
+
nextState.value = filterTargets(setNextState);
|
|
17
|
+
progress.value = 0;
|
|
18
|
+
progress.value = animation(1);
|
|
19
|
+
};
|
|
20
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
21
|
+
const from = prevState.value;
|
|
22
|
+
const to = nextState.value;
|
|
23
|
+
const interpolate = (from = 'transparent', to = 'transparent') => (interpolateColor(progress.value, [0, 1], [String(from), String(to)]));
|
|
24
|
+
return {
|
|
25
|
+
backgroundColor: interpolate(from.backgroundColor, to.backgroundColor),
|
|
26
|
+
borderColor: interpolate(from.borderColor, to.borderColor),
|
|
27
|
+
color: interpolate(from.color, to.color),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
animatedStyle,
|
|
32
|
+
animateTo,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import 'react-native-gesture-handler';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
import Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming, } from 'react-native-reanimated';
|
|
5
|
+
import { Gesture, GestureDetector, } from 'react-native-gesture-handler';
|
|
6
|
+
const INITIAL = { translationX: 0, translationY: 0 };
|
|
7
|
+
const DELETE = { translationX: 100, translationY: 100 };
|
|
8
|
+
export default function App() {
|
|
9
|
+
const pressed = useSharedValue(false);
|
|
10
|
+
const deletePosition = useSharedValue(false);
|
|
11
|
+
const offset = useSharedValue(INITIAL);
|
|
12
|
+
const pan = Gesture.Pan()
|
|
13
|
+
.onBegin(() => {
|
|
14
|
+
pressed.value = true;
|
|
15
|
+
})
|
|
16
|
+
.onChange(({ translationX, translationY }) => {
|
|
17
|
+
deletePosition.value =
|
|
18
|
+
translationX >= DELETE.translationX
|
|
19
|
+
|| translationY >= DELETE.translationY;
|
|
20
|
+
offset.value = { translationX, translationY };
|
|
21
|
+
})
|
|
22
|
+
.onFinalize(() => {
|
|
23
|
+
offset.value = withSpring(INITIAL);
|
|
24
|
+
pressed.value = false;
|
|
25
|
+
deletePosition.value = false;
|
|
26
|
+
});
|
|
27
|
+
const animatedStyles = useAnimatedStyle(() => ({
|
|
28
|
+
backgroundColor: withSpring(deletePosition.value
|
|
29
|
+
? 'red'
|
|
30
|
+
: pressed.value
|
|
31
|
+
? '#FFE04B'
|
|
32
|
+
: '#B58DF1'),
|
|
33
|
+
transform: [
|
|
34
|
+
{ scale: withTiming(pressed.value ? 1.2 : 1) },
|
|
35
|
+
{ translateX: withSpring(offset.value.translationX) },
|
|
36
|
+
{ translateY: withSpring(offset.value.translationY) },
|
|
37
|
+
],
|
|
38
|
+
}));
|
|
39
|
+
return (<View style={styles.container}>
|
|
40
|
+
<GestureDetector gesture={pan}>
|
|
41
|
+
<Animated.View style={[styles.circle, animatedStyles]}/>
|
|
42
|
+
</GestureDetector>
|
|
43
|
+
</View>);
|
|
44
|
+
}
|
|
45
|
+
const styles = StyleSheet.create({
|
|
46
|
+
container: {
|
|
47
|
+
flex: 1,
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
height: '100%',
|
|
51
|
+
},
|
|
52
|
+
circle: {
|
|
53
|
+
height: 120,
|
|
54
|
+
width: 120,
|
|
55
|
+
borderRadius: 500,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Button } from 'react-native';
|
|
2
|
+
import Animated, { LinearTransition, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
3
|
+
export default ({ children, ...props }) => {
|
|
4
|
+
const scale = useSharedValue(1);
|
|
5
|
+
const handlePress = () => {
|
|
6
|
+
scale.value = withSpring(scale.value + 0.2);
|
|
7
|
+
};
|
|
8
|
+
return (<Animated.View layout={LinearTransition.springify()} style={{
|
|
9
|
+
transform: [
|
|
10
|
+
{
|
|
11
|
+
scale,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
}} {...props}>
|
|
15
|
+
{children}
|
|
16
|
+
<Button onPress={handlePress} title="Click me"/>
|
|
17
|
+
</Animated.View>);
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function App(): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Animated, { useSharedValue, withTiming, useAnimatedStyle, withRepeat, withSequence, withSpring, } from 'react-native-reanimated';
|
|
2
|
+
import { View, Button, StyleSheet } from 'react-native';
|
|
3
|
+
export default function App() {
|
|
4
|
+
const offset = useSharedValue(0);
|
|
5
|
+
const style = useAnimatedStyle(() => ({
|
|
6
|
+
transform: [{ translateX: offset.value }],
|
|
7
|
+
}));
|
|
8
|
+
const OFFSET = 40;
|
|
9
|
+
const TIME = 250;
|
|
10
|
+
const handlePress = () => {
|
|
11
|
+
offset.value = withSequence(
|
|
12
|
+
// start from -OFFSET
|
|
13
|
+
withTiming(-OFFSET, { duration: TIME / 2 }),
|
|
14
|
+
// shake between -OFFSET and OFFSET 5 times
|
|
15
|
+
withRepeat(withTiming(OFFSET, { duration: TIME }), 5, true),
|
|
16
|
+
// go back to 0 at the end
|
|
17
|
+
withSpring(0));
|
|
18
|
+
};
|
|
19
|
+
return (<View style={styles.container}>
|
|
20
|
+
<Animated.View style={[styles.box, style]}/>
|
|
21
|
+
<Button title="shake" onPress={handlePress}/>
|
|
22
|
+
</View>);
|
|
23
|
+
}
|
|
24
|
+
const styles = StyleSheet.create({
|
|
25
|
+
container: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
},
|
|
30
|
+
box: {
|
|
31
|
+
width: 100,
|
|
32
|
+
height: 100,
|
|
33
|
+
margin: 50,
|
|
34
|
+
borderRadius: 15,
|
|
35
|
+
backgroundColor: '#b58df1',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View, Text } from 'react-native';
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, withRepeat, } from 'react-native-reanimated';
|
|
4
|
+
const duration = 2000;
|
|
5
|
+
export default ({ width }) => {
|
|
6
|
+
const defaultAnim = useSharedValue(width / 2 - 160);
|
|
7
|
+
const linear = useSharedValue(width / 2 - 160);
|
|
8
|
+
const animatedDefault = useAnimatedStyle(() => ({
|
|
9
|
+
transform: [{ translateX: defaultAnim.value }],
|
|
10
|
+
}));
|
|
11
|
+
const animatedChanged = useAnimatedStyle(() => ({
|
|
12
|
+
transform: [{ translateX: linear.value }],
|
|
13
|
+
}));
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
linear.value = withRepeat(
|
|
16
|
+
// highlight-next-line
|
|
17
|
+
withTiming(-linear.value, {
|
|
18
|
+
duration,
|
|
19
|
+
easing: Easing.back(3),
|
|
20
|
+
}), -1, true);
|
|
21
|
+
defaultAnim.value = withRepeat(
|
|
22
|
+
// highlight-next-line
|
|
23
|
+
withTiming(-defaultAnim.value, {
|
|
24
|
+
duration,
|
|
25
|
+
}), -1, true);
|
|
26
|
+
}, [defaultAnim, linear]);
|
|
27
|
+
return (<View style={styles.container}>
|
|
28
|
+
<Animated.View style={[styles.box, animatedDefault]}>
|
|
29
|
+
<Text style={styles.text}>inout</Text>
|
|
30
|
+
</Animated.View>
|
|
31
|
+
<Animated.View style={[styles.box, animatedChanged]}>
|
|
32
|
+
<Text style={styles.text}>linear</Text>
|
|
33
|
+
</Animated.View>
|
|
34
|
+
</View>);
|
|
35
|
+
};
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
container: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
},
|
|
42
|
+
box: {
|
|
43
|
+
height: 80,
|
|
44
|
+
width: 80,
|
|
45
|
+
margin: 20,
|
|
46
|
+
borderWidth: 1,
|
|
47
|
+
borderColor: '#b58df1',
|
|
48
|
+
borderRadius: 20,
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
},
|
|
52
|
+
text: {
|
|
53
|
+
color: '#b58df1',
|
|
54
|
+
textTransform: 'uppercase',
|
|
55
|
+
fontWeight: 'bold',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native';
|
|
2
|
+
import type { PressableProps } from '../../../../types/default-react';
|
|
3
|
+
type BorderButtonProps = PressableProps & {
|
|
4
|
+
label: string;
|
|
5
|
+
textStyle: TextStyle;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: ({ label, textStyle, onPressIn, onPressOut, ...props }: BorderButtonProps) => import("react").JSX.Element;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Pressable } from 'react-native';
|
|
2
|
+
import { useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
3
|
+
import AnimadoText from '../../../animations/animado/AnimadoText';
|
|
4
|
+
export default ({ label, textStyle, onPressIn, onPressOut, ...props }) => {
|
|
5
|
+
const scale = useSharedValue(1);
|
|
6
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
7
|
+
transform: [{ scale: scale.value }],
|
|
8
|
+
}));
|
|
9
|
+
const handlePressIn = (e) => {
|
|
10
|
+
scale.value = withSpring(0.75);
|
|
11
|
+
onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(e);
|
|
12
|
+
};
|
|
13
|
+
const handlePressOut = (e) => {
|
|
14
|
+
scale.value = withSpring(1);
|
|
15
|
+
onPressOut === null || onPressOut === void 0 ? void 0 : onPressOut(e);
|
|
16
|
+
};
|
|
17
|
+
return (<Pressable onPressIn={handlePressIn} onPressOut={handlePressOut} {...props}>
|
|
18
|
+
<AnimadoText text={label} style={[textStyle, animatedStyle]}/>
|
|
19
|
+
</Pressable>);
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BorderButton } from './BorderButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BorderButton } from './BorderButton';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ColorValue } from 'react-native';
|
|
2
|
+
import type { IconstTypes } from '../../types';
|
|
3
|
+
type ArrowProps = IconstTypes.BaseIcon & {
|
|
4
|
+
drawIt?: boolean;
|
|
5
|
+
color: ColorValue;
|
|
6
|
+
lineWidth: number;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: ({ drawIt, color, lineWidth, rotation, style, ...props }: ArrowProps) => import("react").JSX.Element;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Svg from 'react-native-svg';
|
|
2
|
+
import Line from './base/Line';
|
|
3
|
+
import { View } from '../base';
|
|
4
|
+
const body = {
|
|
5
|
+
x1: 20, y1: 50,
|
|
6
|
+
// --------- //
|
|
7
|
+
x2: 180, y2: 50,
|
|
8
|
+
};
|
|
9
|
+
const arrowUp = {
|
|
10
|
+
x1: 130, y1: 0,
|
|
11
|
+
// --------- //
|
|
12
|
+
x2: 180, y2: 50,
|
|
13
|
+
};
|
|
14
|
+
const arrowDown = {
|
|
15
|
+
x1: 130, y1: 100,
|
|
16
|
+
// --------- //
|
|
17
|
+
x2: 180, y2: 50,
|
|
18
|
+
};
|
|
19
|
+
export default ({ drawIt = false, color, lineWidth, rotation = 0, style, ...props }) => {
|
|
20
|
+
const baseConfig = {
|
|
21
|
+
stroke: color,
|
|
22
|
+
strokeWidth: lineWidth,
|
|
23
|
+
};
|
|
24
|
+
const rotationTransform = {
|
|
25
|
+
transform: [{ rotate: `${rotation}deg` }],
|
|
26
|
+
};
|
|
27
|
+
return (<View style={[style, rotationTransform]} {...props}>
|
|
28
|
+
<Svg height='100%' width='100%' viewBox='0 0 200 100'>
|
|
29
|
+
<Line line={{
|
|
30
|
+
...body,
|
|
31
|
+
...baseConfig,
|
|
32
|
+
}} drawIt={drawIt}/>
|
|
33
|
+
<Line line={{
|
|
34
|
+
...arrowUp,
|
|
35
|
+
...baseConfig,
|
|
36
|
+
}} drawIt={drawIt}/>
|
|
37
|
+
<Line line={{
|
|
38
|
+
...arrowDown,
|
|
39
|
+
...baseConfig,
|
|
40
|
+
}} drawIt={drawIt}/>
|
|
41
|
+
</Svg>
|
|
42
|
+
</View>);
|
|
43
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IconstTypes } from '../../types';
|
|
2
|
+
import type { ColorValue } from 'react-native';
|
|
3
|
+
type CrossProps = IconstTypes.BaseIcon & {
|
|
4
|
+
color?: ColorValue;
|
|
5
|
+
lineWidth?: number;
|
|
6
|
+
};
|
|
7
|
+
declare const _default: ({ drawIt, color, lineWidth, rotation, iconAnimation, style, ...props }: CrossProps) => import("react").JSX.Element;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Svg from 'react-native-svg';
|
|
2
|
+
import Line from './base/Line';
|
|
3
|
+
import { View } from '../base';
|
|
4
|
+
import { svgBaseConfig } from './utils';
|
|
5
|
+
export default ({ drawIt = true, color = 'black', lineWidth = 3, rotation = 0, iconAnimation, style, ...props }) => {
|
|
6
|
+
const baseLineConfig = {
|
|
7
|
+
stroke: color,
|
|
8
|
+
strokeWidth: lineWidth,
|
|
9
|
+
};
|
|
10
|
+
const topLeft = {
|
|
11
|
+
line: {
|
|
12
|
+
...baseLineConfig,
|
|
13
|
+
x1: 10, y1: 10,
|
|
14
|
+
x2: 90, y2: 90,
|
|
15
|
+
},
|
|
16
|
+
drawIt,
|
|
17
|
+
iconAnimation,
|
|
18
|
+
};
|
|
19
|
+
const bottomLeft = {
|
|
20
|
+
line: {
|
|
21
|
+
...baseLineConfig,
|
|
22
|
+
x1: 90, y1: 10,
|
|
23
|
+
x2: 10, y2: 90,
|
|
24
|
+
},
|
|
25
|
+
drawIt,
|
|
26
|
+
iconAnimation,
|
|
27
|
+
};
|
|
28
|
+
const rotationTransform = {
|
|
29
|
+
transform: [{ rotate: `${rotation}deg` }],
|
|
30
|
+
};
|
|
31
|
+
return (<View style={[style, rotationTransform]} {...props}>
|
|
32
|
+
<Svg {...svgBaseConfig}>
|
|
33
|
+
<Line {...topLeft}/>
|
|
34
|
+
<Line {...bottomLeft}/>
|
|
35
|
+
</Svg>
|
|
36
|
+
</View>);
|
|
37
|
+
};
|