@holper/react-native-holper-storybook 0.6.9 → 0.6.12
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/lib/components/DeckSwiper/index.js +31 -29
- package/lib/components/DeckSwiper/style.js +5 -5
- package/lib/components/SwipeablePanel/index.js +10 -2
- package/lib/components/SwipeablePanel/style.js +1 -1
- package/lib/components/Text/index.js +1 -1
- package/lib/components/Text/style.js +3 -0
- package/lib/configs/loadFonts.js +4 -4
- package/package.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useRef, useState} from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import {View, Image} from 'react-native';
|
|
4
4
|
import Swiper from 'react-native-deck-swiper';
|
|
5
5
|
import Entypo from 'react-native-vector-icons/Entypo';
|
|
6
6
|
import Text from '../Text';
|
|
7
7
|
import Button from '../Button';
|
|
8
|
-
import {
|
|
8
|
+
import {Colors} from '../../configs/constants';
|
|
9
9
|
import style from './style';
|
|
10
10
|
|
|
11
|
-
const DeckSwiper = ({
|
|
11
|
+
const DeckSwiper = ({data, inverted, nextText, onChange, onFinish}) => {
|
|
12
12
|
const swiper = useRef(null);
|
|
13
13
|
const [finished, setFinished] = useState(false);
|
|
14
14
|
const [index, setIndex] = useState(0);
|
|
15
15
|
|
|
16
16
|
const renderDots = () => (
|
|
17
|
-
data.map((d,i) => <Entypo
|
|
17
|
+
data.map((d, i) => <Entypo
|
|
18
18
|
name='dot-single'
|
|
19
19
|
size={36}
|
|
20
20
|
key={`dot-${i}`}
|
|
21
|
-
style={style[index === i ? 'dotSelected': 'dot']}
|
|
21
|
+
style={style[index === i ? 'dotSelected' : 'dot']}
|
|
22
22
|
/>)
|
|
23
23
|
);
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ const DeckSwiper = ({ data, inverted, nextText, onChange, onFinish }) => {
|
|
|
28
28
|
ref={swiper}
|
|
29
29
|
cards={data}
|
|
30
30
|
renderCard={(card) => {
|
|
31
|
-
if(!card) {
|
|
31
|
+
if (!card) {
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
return (
|
|
@@ -42,23 +42,23 @@ const DeckSwiper = ({ data, inverted, nextText, onChange, onFinish }) => {
|
|
|
42
42
|
/>
|
|
43
43
|
</View>
|
|
44
44
|
<View style={style.textContainer}>
|
|
45
|
-
<Text size='large' style={style.title}>{card.title}</Text>
|
|
46
|
-
<Text align='center'>{card.description}</Text>
|
|
45
|
+
<Text size='extra-large' style={style.title}>{card.title}</Text>
|
|
46
|
+
<Text size='large' align='center'>{card.description}</Text>
|
|
47
47
|
</View>
|
|
48
48
|
</View>
|
|
49
|
-
)
|
|
49
|
+
);
|
|
50
50
|
}}
|
|
51
51
|
onSwipedAll={() => {
|
|
52
52
|
setFinished(true);
|
|
53
53
|
onFinish();
|
|
54
54
|
}}
|
|
55
55
|
onSwipedRight={index => {
|
|
56
|
-
setIndex(index-1);
|
|
57
|
-
onChange(index-1);
|
|
56
|
+
setIndex(index - 1);
|
|
57
|
+
onChange(index - 1);
|
|
58
58
|
}}
|
|
59
59
|
onSwipedLeft={index => {
|
|
60
|
-
setIndex(index+1);
|
|
61
|
-
onChange(index+1);
|
|
60
|
+
setIndex(index + 1);
|
|
61
|
+
onChange(index + 1);
|
|
62
62
|
}}
|
|
63
63
|
cardIndex={index}
|
|
64
64
|
backgroundColor={Colors.white}
|
|
@@ -69,18 +69,18 @@ const DeckSwiper = ({ data, inverted, nextText, onChange, onFinish }) => {
|
|
|
69
69
|
goBackToPreviousCardOnSwipeRight={true}
|
|
70
70
|
childrenOnTop
|
|
71
71
|
>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
{!finished && (
|
|
73
|
+
<>
|
|
74
|
+
<View style={style.dotsContainer}>
|
|
75
|
+
{renderDots()}
|
|
76
|
+
</View>
|
|
77
|
+
<View style={style.container}>
|
|
78
|
+
<Button variant={inverted ? 'inverted' : 'primary'} onPress={() => swiper.current.swipeLeft()}>
|
|
79
|
+
<Text color='white'>{nextText}</Text>
|
|
80
|
+
</Button>
|
|
81
|
+
</View>
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
84
84
|
</Swiper>
|
|
85
85
|
</>
|
|
86
86
|
);
|
|
@@ -90,8 +90,10 @@ DeckSwiper.defaultProps = {
|
|
|
90
90
|
data: [],
|
|
91
91
|
inverted: false,
|
|
92
92
|
nextText: ' ',
|
|
93
|
-
onChange: () => {
|
|
94
|
-
|
|
93
|
+
onChange: () => {
|
|
94
|
+
},
|
|
95
|
+
onfinish: () => {
|
|
96
|
+
}
|
|
95
97
|
};
|
|
96
98
|
|
|
97
99
|
DeckSwiper.propTypes = {
|
|
@@ -104,6 +106,6 @@ DeckSwiper.propTypes = {
|
|
|
104
106
|
nextText: PropTypes.string,
|
|
105
107
|
onChange: PropTypes.func,
|
|
106
108
|
onFinish: PropTypes.func
|
|
107
|
-
}
|
|
109
|
+
};
|
|
108
110
|
|
|
109
111
|
export default DeckSwiper;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
|
+
import {Colors} from '../../configs/constants';
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {height, width} = Dimensions.get('window');
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
container: {
|
|
@@ -22,8 +22,8 @@ export default {
|
|
|
22
22
|
alignItems: 'center',
|
|
23
23
|
},
|
|
24
24
|
imageContainer: {
|
|
25
|
-
width: width -
|
|
26
|
-
height: height / 2.
|
|
25
|
+
width: width - 90,
|
|
26
|
+
height: height / 2.3,
|
|
27
27
|
},
|
|
28
28
|
imageResponsive: {
|
|
29
29
|
height: undefined,
|
|
@@ -45,6 +45,7 @@ const SwipeablePanel = ({
|
|
|
45
45
|
const LARGE_PANEL_HEIGHT = (screenHeight - offset) - calcMarginTop(); // This is the margin top
|
|
46
46
|
const MEDIUM_PANEL_HEIGHT = 400; // Fixed height
|
|
47
47
|
|
|
48
|
+
const [closeButtonClicked, setCloseButtonClicked] = useState(false);
|
|
48
49
|
const [status, setStatus] = useState(STATUS.LARGE);
|
|
49
50
|
const [animatedValueY, setAnimatedValueY] = useState(LARGE_PANEL_HEIGHT);
|
|
50
51
|
const pan = useRef(new Animated.ValueXY({x: 0, y: LARGE_PANEL_HEIGHT})).current;
|
|
@@ -152,7 +153,10 @@ const SwipeablePanel = ({
|
|
|
152
153
|
</View>
|
|
153
154
|
|
|
154
155
|
{closeButton && (
|
|
155
|
-
<TouchableOpacity onPress={
|
|
156
|
+
<TouchableOpacity onPress={() => {
|
|
157
|
+
setCloseButtonClicked(true);
|
|
158
|
+
onClose();
|
|
159
|
+
}} style={style.closeButton}>
|
|
156
160
|
<Ionicons name='close-outline' size={20} color={Colors.darkblue}/>
|
|
157
161
|
</TouchableOpacity>
|
|
158
162
|
)}
|
|
@@ -163,7 +167,11 @@ const SwipeablePanel = ({
|
|
|
163
167
|
isPlaying={true}
|
|
164
168
|
duration={closeAfterSeconds}
|
|
165
169
|
colors={Colors.green}
|
|
166
|
-
onComplete={
|
|
170
|
+
onComplete={() => {
|
|
171
|
+
if (!closeButtonClicked) {
|
|
172
|
+
onClose();
|
|
173
|
+
}
|
|
174
|
+
}}
|
|
167
175
|
size={40}
|
|
168
176
|
strokeWidth={4}
|
|
169
177
|
>
|
|
@@ -33,7 +33,7 @@ Text.defaultProps = {
|
|
|
33
33
|
Text.propTypes = {
|
|
34
34
|
color: PropTypes.oneOf(['dark', 'light', 'lighter', 'white', 'green', 'red', 'yellow', 'violet']),
|
|
35
35
|
variant: PropTypes.oneOf(['default', 'lowercase', 'uppercase']),
|
|
36
|
-
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'extra-large']),
|
|
36
|
+
size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'extra-large', 'huge']),
|
|
37
37
|
weight: PropTypes.oneOf(['regular', 'bold', 'semiBold']),
|
|
38
38
|
align: PropTypes.oneOf(['left', 'right', 'center', 'justify']),
|
|
39
39
|
style: RNText.propTypes.style,
|
package/lib/configs/loadFonts.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Font from 'expo-font';
|
|
2
2
|
|
|
3
|
-
export const loadFonts = [
|
|
4
|
-
asyncLoadFont
|
|
5
|
-
];
|
|
6
|
-
|
|
7
3
|
export const asyncLoadFont = Font.loadAsync({
|
|
8
4
|
poppins_bold: require('../assets/fonts/Poppins-Bold.ttf'),
|
|
9
5
|
poppins_regular: require('../assets/fonts/Poppins-Regular.ttf'),
|
|
10
6
|
poppins_semiBold: require('../assets/fonts/Poppins-SemiBold.ttf')
|
|
11
7
|
});
|
|
8
|
+
|
|
9
|
+
export const loadFonts = [
|
|
10
|
+
asyncLoadFont
|
|
11
|
+
];
|