forked from jfilter/react-native-onboarding-swiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomButtons.js
109 lines (101 loc) · 2.61 KB
/
CustomButtons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { Image, View } from 'react-native';
import React from 'react';
import { Button } from 'react-native-elements';
import Onboarding from 'react-native-onboarding-swiper';
const Square = ({ isLight, selected }) => {
let backgroundColor;
if (isLight) {
backgroundColor = selected ? 'rgba(0, 0, 0, 0.8)' : 'rgba(0, 0, 0, 0.3)';
} else {
backgroundColor = selected ? '#fff' : 'rgba(255, 255, 255, 0.5)';
}
return (
<View
style={{
width: 6,
height: 6,
marginHorizontal: 3,
backgroundColor,
}}
/>
);
};
const backgroundColor = isLight => (isLight ? 'blue' : 'lightblue');
const color = isLight => backgroundColor(!isLight);
const Done = ({ isLight, ...props }) => (
<Button
title={'Done'}
buttonStyle={{
backgroundColor: backgroundColor(isLight),
}}
containerViewStyle={{
marginVertical: 10,
width: 70,
backgroundColor: backgroundColor(isLight),
}}
textStyle={{ color: color(isLight) }}
{...props}
/>
);
const Skip = ({ isLight, skipLabel, ...props }) => (
<Button
title={'Skip'}
buttonStyle={{
backgroundColor: backgroundColor(isLight),
}}
containerViewStyle={{
marginVertical: 10,
width: 70,
}}
textStyle={{ color: color(isLight) }}
{...props}
>
{skipLabel}
</Button>
);
const Next = ({ isLight, ...props }) => (
<Button
title={'Next'}
buttonStyle={{
backgroundColor: backgroundColor(isLight),
}}
containerViewStyle={{
marginVertical: 10,
width: 70,
backgroundColor: backgroundColor(isLight),
}}
textStyle={{ color: color(isLight) }}
{...props}
/>
);
const CustomButtons = () => (
<Onboarding
DotComponent={Square}
NextButtonComponent={Next}
SkipButtonComponent={Skip}
DoneButtonComponent={Done}
titleStyles={{ color: 'blue' }} // set default color for the title
pages={[
{
backgroundColor: '#fff',
image: <Image source={require('./images/circle.png')} />,
title: 'Onboarding',
subtitle: 'Done with React Native Onboarding Swiper',
titleStyles: { color: 'red' }, // overwrite default color
},
{
backgroundColor: '#fe6e58',
image: <Image source={require('./images/square.png')} />,
title: 'The Title',
subtitle: 'This is the subtitle that sumplements the title.',
},
{
backgroundColor: '#999',
image: <Image source={require('./images/triangle.png')} />,
title: 'Triangle',
subtitle: "Beautiful, isn't it?",
},
]}
/>
);
export default CustomButtons;