@holper/react-native-holper-storybook 0.6.10 → 0.6.11
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.
|
@@ -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,
|