@holper/react-native-holper-storybook 0.6.85 → 0.6.86
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,26 +1,27 @@
|
|
|
1
|
-
import React, {useRef, useState} from 'react';
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {View, Image} from 'react-native';
|
|
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 {Colors} from '../../configs/constants';
|
|
8
|
+
import { Colors } from '../../configs/constants';
|
|
9
9
|
import style from './style';
|
|
10
10
|
|
|
11
|
-
const DeckSwiper = ({data, inverted, nextText, onChange, onFinish}) => {
|
|
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
|
-
const renderDots = () =>
|
|
17
|
-
data.map((d, i) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const renderDots = () =>
|
|
17
|
+
data.map((d, i) => (
|
|
18
|
+
<Entypo
|
|
19
|
+
name='dot-single'
|
|
20
|
+
size={36}
|
|
21
|
+
key={`dot-${i}`}
|
|
22
|
+
style={style[index === i ? 'dotSelected' : 'dot']}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<>
|
|
@@ -36,14 +37,18 @@ const DeckSwiper = ({data, inverted, nextText, onChange, onFinish}) => {
|
|
|
36
37
|
<View style={style.imageContainer}>
|
|
37
38
|
<Image
|
|
38
39
|
style={style.imageResponsive}
|
|
39
|
-
source={
|
|
40
|
+
source={card.image}
|
|
40
41
|
progressiveRenderingEnabled
|
|
41
42
|
resizeMode='contain'
|
|
42
43
|
/>
|
|
43
44
|
</View>
|
|
44
45
|
<View style={style.textContainer}>
|
|
45
|
-
<Text size='extra-large' style={style.title}>
|
|
46
|
-
|
|
46
|
+
<Text size='extra-large' style={style.title}>
|
|
47
|
+
{card.title}
|
|
48
|
+
</Text>
|
|
49
|
+
<Text size='large' align='center'>
|
|
50
|
+
{card.description}
|
|
51
|
+
</Text>
|
|
47
52
|
</View>
|
|
48
53
|
</View>
|
|
49
54
|
);
|
|
@@ -52,11 +57,11 @@ const DeckSwiper = ({data, inverted, nextText, onChange, onFinish}) => {
|
|
|
52
57
|
setFinished(true);
|
|
53
58
|
onFinish();
|
|
54
59
|
}}
|
|
55
|
-
onSwipedRight={index => {
|
|
60
|
+
onSwipedRight={(index) => {
|
|
56
61
|
setIndex(index - 1);
|
|
57
62
|
onChange(index - 1);
|
|
58
63
|
}}
|
|
59
|
-
onSwipedLeft={index => {
|
|
64
|
+
onSwipedLeft={(index) => {
|
|
60
65
|
setIndex(index + 1);
|
|
61
66
|
onChange(index + 1);
|
|
62
67
|
}}
|
|
@@ -71,11 +76,12 @@ const DeckSwiper = ({data, inverted, nextText, onChange, onFinish}) => {
|
|
|
71
76
|
>
|
|
72
77
|
{!finished && (
|
|
73
78
|
<>
|
|
74
|
-
<View style={style.dotsContainer}>
|
|
75
|
-
{renderDots()}
|
|
76
|
-
</View>
|
|
79
|
+
<View style={style.dotsContainer}>{renderDots()}</View>
|
|
77
80
|
<View style={style.container}>
|
|
78
|
-
<Button
|
|
81
|
+
<Button
|
|
82
|
+
variant={inverted ? 'inverted' : 'primary'}
|
|
83
|
+
onPress={() => swiper.current.swipeLeft()}
|
|
84
|
+
>
|
|
79
85
|
<Text color='white'>{nextText}</Text>
|
|
80
86
|
</Button>
|
|
81
87
|
</View>
|
|
@@ -90,22 +96,23 @@ DeckSwiper.defaultProps = {
|
|
|
90
96
|
data: [],
|
|
91
97
|
inverted: false,
|
|
92
98
|
nextText: ' ',
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
onfinish: () => {
|
|
96
|
-
}
|
|
99
|
+
useUri: false,
|
|
100
|
+
onChange: () => {},
|
|
101
|
+
onfinish: () => {},
|
|
97
102
|
};
|
|
98
103
|
|
|
99
104
|
DeckSwiper.propTypes = {
|
|
100
|
-
data: PropTypes.arrayOf(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
data: PropTypes.arrayOf(
|
|
106
|
+
PropTypes.shape({
|
|
107
|
+
image: PropTypes.string,
|
|
108
|
+
title: PropTypes.string,
|
|
109
|
+
description: PropTypes.string,
|
|
110
|
+
})
|
|
111
|
+
),
|
|
105
112
|
inverted: PropTypes.bool,
|
|
106
113
|
nextText: PropTypes.string,
|
|
107
114
|
onChange: PropTypes.func,
|
|
108
|
-
onFinish: PropTypes.func
|
|
115
|
+
onFinish: PropTypes.func,
|
|
109
116
|
};
|
|
110
117
|
|
|
111
118
|
export default DeckSwiper;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import PropTypes from
|
|
2
|
-
import React from
|
|
3
|
-
import { View, TextInput, Text } from
|
|
4
|
-
import style from
|
|
5
|
-
import { Colors } from
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View, TextInput, Text } from 'react-native';
|
|
4
|
+
import style from './style';
|
|
5
|
+
import { Colors } from '../../configs/constants';
|
|
6
6
|
|
|
7
7
|
const Input = ({
|
|
8
8
|
variant,
|
|
@@ -59,22 +59,22 @@ const Input = ({
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
Input.defaultProps = {
|
|
62
|
-
variant:
|
|
62
|
+
variant: 'default',
|
|
63
63
|
disabled: false,
|
|
64
64
|
leftIcon: null,
|
|
65
65
|
leftIconWide: false,
|
|
66
66
|
showLabel: false,
|
|
67
|
-
label:
|
|
67
|
+
label: '',
|
|
68
68
|
count: false,
|
|
69
69
|
rightIcon: null,
|
|
70
|
-
value:
|
|
70
|
+
value: '',
|
|
71
71
|
maxLength: 100,
|
|
72
|
-
size:
|
|
72
|
+
size: 'fixed',
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
Input.propTypes = {
|
|
76
|
-
variant: PropTypes.oneOf([
|
|
77
|
-
size: PropTypes.oneOf([
|
|
76
|
+
variant: PropTypes.oneOf(['default', 'completed', 'error']),
|
|
77
|
+
size: PropTypes.oneOf(['fixed', 'fit']),
|
|
78
78
|
disabled: PropTypes.bool,
|
|
79
79
|
leftIcon: PropTypes.node,
|
|
80
80
|
leftIconWide: PropTypes.bool,
|