react-native-app-onboard 0.1.3 → 0.1.5
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/README.md +13 -0
- package/lib/commonjs/components/CustomPages.js +16 -2
- package/lib/commonjs/components/CustomPages.js.map +1 -1
- package/lib/commonjs/components/OnboardingPages.js +23 -10
- package/lib/commonjs/components/OnboardingPages.js.map +1 -1
- package/lib/commonjs/components/Pagination.js +6 -3
- package/lib/commonjs/components/Pagination.js.map +1 -1
- package/lib/commonjs/components/Swiper.js +11 -1
- package/lib/commonjs/components/Swiper.js.map +1 -1
- package/lib/commonjs/components/button.js +20 -1
- package/lib/commonjs/components/button.js.map +1 -1
- package/lib/commonjs/context/OnboardingContext.js +2 -2
- package/lib/commonjs/context/OnboardingContext.js.map +1 -1
- package/lib/module/components/CustomPages.js +16 -2
- package/lib/module/components/CustomPages.js.map +1 -1
- package/lib/module/components/OnboardingPages.js +23 -10
- package/lib/module/components/OnboardingPages.js.map +1 -1
- package/lib/module/components/Pagination.js +6 -3
- package/lib/module/components/Pagination.js.map +1 -1
- package/lib/module/components/Swiper.js +11 -1
- package/lib/module/components/Swiper.js.map +1 -1
- package/lib/module/components/button.js +18 -0
- package/lib/module/components/button.js.map +1 -1
- package/lib/module/context/OnboardingContext.js +2 -2
- package/lib/module/context/OnboardingContext.js.map +1 -1
- package/lib/typescript/src/components/CustomPages.d.ts.map +1 -1
- package/lib/typescript/src/components/OnboardingPages.d.ts.map +1 -1
- package/lib/typescript/src/components/Pagination.d.ts +4 -0
- package/lib/typescript/src/components/Pagination.d.ts.map +1 -1
- package/lib/typescript/src/components/Swiper.d.ts.map +1 -1
- package/lib/typescript/src/components/button.d.ts +3 -0
- package/lib/typescript/src/components/button.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/CustomPages.tsx +19 -4
- package/src/components/OnboardingPages.tsx +52 -28
- package/src/components/Pagination.tsx +8 -1
- package/src/components/Swiper.tsx +10 -0
- package/src/components/button.tsx +26 -0
- package/src/context/OnboardingContext.tsx +2 -2
- package/src/types/index.ts +4 -0
|
@@ -27,7 +27,11 @@ type FooterProps = {
|
|
|
27
27
|
buttonLeftContainerStyle?: StyleProp<ViewStyle>;
|
|
28
28
|
dotsContainerStyle?: StyleProp<ViewStyle>;
|
|
29
29
|
doneLabelStyle?: StyleProp<TextStyle>;
|
|
30
|
+
hasSkipPosition?: boolean;
|
|
30
31
|
skipLabelStyle?: StyleProp<TextStyle>;
|
|
32
|
+
skipButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
33
|
+
nextButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
34
|
+
doneButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
31
35
|
nextLabelStyle?: StyleProp<TextStyle>;
|
|
32
36
|
paginationPosition?: 'top' | 'bottom';
|
|
33
37
|
onDone?: () => void;
|
|
@@ -56,10 +60,11 @@ export function Pagination(props: FooterProps) {
|
|
|
56
60
|
props.buttonLeftContainerStyle,
|
|
57
61
|
]}
|
|
58
62
|
>
|
|
59
|
-
{props.showSkip && (
|
|
63
|
+
{props.showSkip && !props.hasSkipPosition && (
|
|
60
64
|
<Button
|
|
61
65
|
onPress={props.onSkip}
|
|
62
66
|
buttonTextStyle={props.skipLabelStyle}
|
|
67
|
+
buttonStyle={props.skipButtonContainerStyle}
|
|
63
68
|
label={props.skipLabel || 'Skip'}
|
|
64
69
|
/>
|
|
65
70
|
)}
|
|
@@ -99,6 +104,7 @@ export function Pagination(props: FooterProps) {
|
|
|
99
104
|
onPress={props.onNext}
|
|
100
105
|
label={props.nextLabel || 'Next'}
|
|
101
106
|
buttonTextStyle={props.nextLabelStyle}
|
|
107
|
+
buttonStyle={props.nextButtonContainerStyle}
|
|
102
108
|
/>
|
|
103
109
|
)}
|
|
104
110
|
{isDone && props.showDone && (
|
|
@@ -106,6 +112,7 @@ export function Pagination(props: FooterProps) {
|
|
|
106
112
|
onPress={props.onDone}
|
|
107
113
|
label={props.doneLabel || 'Done'}
|
|
108
114
|
buttonTextStyle={props.doneLabelStyle}
|
|
115
|
+
buttonStyle={props.doneButtonContainerStyle}
|
|
109
116
|
/>
|
|
110
117
|
)}
|
|
111
118
|
</View>
|
|
@@ -30,6 +30,10 @@ export const Swiper: React.FC<OnboardingProps> = (props) => {
|
|
|
30
30
|
showDone={props.showDone}
|
|
31
31
|
showNext={props.showNext}
|
|
32
32
|
onDone={props.onDone}
|
|
33
|
+
skipButtonContainerStyle={props.skipButtonContainerStyle}
|
|
34
|
+
nextButtonContainerStyle={props.nextButtonContainerStyle}
|
|
35
|
+
doneButtonContainerStyle={props.doneButtonContainerStyle}
|
|
36
|
+
skipButtonPosition={props.skipButtonPosition}
|
|
33
37
|
>
|
|
34
38
|
{props.children}
|
|
35
39
|
</CustomPages>
|
|
@@ -51,6 +55,12 @@ export const Swiper: React.FC<OnboardingProps> = (props) => {
|
|
|
51
55
|
pages={props.pages || []}
|
|
52
56
|
width={props.width}
|
|
53
57
|
showNext={props.showNext}
|
|
58
|
+
skipButtonContainerStyle={props.skipButtonContainerStyle}
|
|
59
|
+
nextButtonContainerStyle={props.nextButtonContainerStyle}
|
|
60
|
+
doneButtonContainerStyle={props.doneButtonContainerStyle}
|
|
61
|
+
skipLabelStyle={props.skipLabelStyle}
|
|
62
|
+
skipButtonPosition={props.skipButtonPosition}
|
|
63
|
+
showPagination={props.showPagination}
|
|
54
64
|
color={props.color}
|
|
55
65
|
onSkip={props.onSkip}
|
|
56
66
|
/>
|
|
@@ -36,6 +36,28 @@ export const Button = (props: ButtonProps) => {
|
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export const SkipButton = (
|
|
40
|
+
props: ButtonProps & {
|
|
41
|
+
position?: 'top-left' | 'top-right';
|
|
42
|
+
}
|
|
43
|
+
) => {
|
|
44
|
+
const buttonStyle = {
|
|
45
|
+
top: 20,
|
|
46
|
+
left: props.position === 'top-left' ? 30 : undefined,
|
|
47
|
+
right: props.position === 'top-right' ? 30 : undefined,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Button
|
|
52
|
+
label={props.label || 'Skip'}
|
|
53
|
+
onPress={props.onPress}
|
|
54
|
+
buttonStyle={[styles.skipButton, buttonStyle, props.buttonStyle]}
|
|
55
|
+
buttonTextStyle={props.buttonTextStyle}
|
|
56
|
+
color={props.color}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
39
61
|
const styles = StyleSheet.create({
|
|
40
62
|
pagination: {
|
|
41
63
|
flexDirection: 'row',
|
|
@@ -71,4 +93,8 @@ const styles = StyleSheet.create({
|
|
|
71
93
|
alignItems: 'flex-start',
|
|
72
94
|
paddingLeft: 30,
|
|
73
95
|
},
|
|
96
|
+
skipButton: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
zIndex: 10,
|
|
99
|
+
},
|
|
74
100
|
});
|
|
@@ -55,13 +55,13 @@ export const OnboardingProvider: React.FC<OnboardingProviderProps> = ({
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const nextPage = (animated: boolean = true) => {
|
|
58
|
-
if (flatListRef.current) {
|
|
58
|
+
if (flatListRef.current && currentPage < numberOfScreens - 1) {
|
|
59
59
|
flatListRef.current.scrollToOffset({
|
|
60
60
|
offset: width * (currentPage + 1),
|
|
61
61
|
animated: animated,
|
|
62
62
|
});
|
|
63
|
+
setCurrentPage(currentPage + 1);
|
|
63
64
|
}
|
|
64
|
-
setCurrentPage(currentPage + 1);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
const scrollTo = (index: number, animated: boolean = true) => {
|
package/src/types/index.ts
CHANGED
|
@@ -20,6 +20,10 @@ export type OnboardingProps = {
|
|
|
20
20
|
dotsContainerStyle?: StyleProp<ViewStyle>;
|
|
21
21
|
doneLabelStyle?: StyleProp<TextStyle>;
|
|
22
22
|
skipLabelStyle?: StyleProp<TextStyle>;
|
|
23
|
+
skipButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
24
|
+
nextButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
25
|
+
doneButtonContainerStyle?: StyleProp<ViewStyle>;
|
|
26
|
+
skipButtonPosition?: 'top-left' | 'top-right';
|
|
23
27
|
nextLabelStyle?: StyleProp<TextStyle>;
|
|
24
28
|
containerStyle?: StyleProp<ViewStyle>;
|
|
25
29
|
imageContainerStyle?: StyleProp<ViewStyle>;
|