react-native-app-onboard 0.1.9 → 0.2.1
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 +89 -7
- package/lib/commonjs/components/CustomPages.js +31 -55
- package/lib/commonjs/components/CustomPages.js.map +1 -1
- package/lib/commonjs/components/OnboardingPages.js +63 -79
- package/lib/commonjs/components/OnboardingPages.js.map +1 -1
- package/lib/commonjs/components/Page.js +8 -3
- package/lib/commonjs/components/Page.js.map +1 -1
- package/lib/commonjs/components/Pagination.js +75 -13
- package/lib/commonjs/components/Pagination.js.map +1 -1
- package/lib/commonjs/components/Swiper.js +58 -85
- package/lib/commonjs/components/Swiper.js.map +1 -1
- package/lib/commonjs/components/button.js +3 -1
- package/lib/commonjs/components/button.js.map +1 -1
- package/lib/commonjs/context/OnboardingContext.js +101 -21
- package/lib/commonjs/context/OnboardingContext.js.map +1 -1
- package/lib/commonjs/hooks/useOnboarding.js +1 -1
- package/lib/commonjs/hooks/useOnboarding.js.map +1 -1
- package/lib/commonjs/index.js +33 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/color.js +308 -0
- package/lib/commonjs/utils/color.js.map +1 -0
- package/lib/commonjs/utils/persistence.js +51 -0
- package/lib/commonjs/utils/persistence.js.map +1 -0
- package/lib/module/components/CustomPages.js +31 -55
- package/lib/module/components/CustomPages.js.map +1 -1
- package/lib/module/components/OnboardingPages.js +64 -79
- package/lib/module/components/OnboardingPages.js.map +1 -1
- package/lib/module/components/Page.js +8 -3
- package/lib/module/components/Page.js.map +1 -1
- package/lib/module/components/Pagination.js +76 -14
- package/lib/module/components/Pagination.js.map +1 -1
- package/lib/module/components/Swiper.js +59 -86
- package/lib/module/components/Swiper.js.map +1 -1
- package/lib/module/components/button.js +3 -1
- package/lib/module/components/button.js.map +1 -1
- package/lib/module/context/OnboardingContext.js +102 -22
- package/lib/module/context/OnboardingContext.js.map +1 -1
- package/lib/module/hooks/useOnboarding.js +1 -1
- package/lib/module/hooks/useOnboarding.js.map +1 -1
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/color.js +299 -0
- package/lib/module/utils/color.js.map +1 -0
- package/lib/module/utils/persistence.js +42 -0
- package/lib/module/utils/persistence.js.map +1 -0
- package/lib/typescript/src/components/CustomPages.d.ts +6 -2
- package/lib/typescript/src/components/CustomPages.d.ts.map +1 -1
- package/lib/typescript/src/components/OnboardingPages.d.ts +6 -2
- package/lib/typescript/src/components/OnboardingPages.d.ts.map +1 -1
- package/lib/typescript/src/components/Page.d.ts +2 -0
- package/lib/typescript/src/components/Page.d.ts.map +1 -1
- package/lib/typescript/src/components/Pagination.d.ts +9 -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.map +1 -1
- package/lib/typescript/src/context/OnboardingContext.d.ts +9 -0
- package/lib/typescript/src/context/OnboardingContext.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnboarding.d.ts +3 -0
- package/lib/typescript/src/hooks/useOnboarding.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +13 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/color.d.ts +18 -0
- package/lib/typescript/src/utils/color.d.ts.map +1 -0
- package/lib/typescript/src/utils/persistence.d.ts +31 -0
- package/lib/typescript/src/utils/persistence.d.ts.map +1 -0
- package/package.json +12 -6
- package/src/components/CustomPages.tsx +62 -69
- package/src/components/OnboardingPages.tsx +86 -89
- package/src/components/Page.tsx +8 -2
- package/src/components/Pagination.tsx +117 -29
- package/src/components/Swiper.tsx +65 -87
- package/src/components/button.tsx +6 -1
- package/src/context/OnboardingContext.tsx +145 -26
- package/src/hooks/useOnboarding.tsx +1 -3
- package/src/index.tsx +16 -1
- package/src/types/index.ts +13 -0
- package/src/utils/color.ts +284 -0
- package/src/utils/persistence.ts +58 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Animated","StyleSheet","React","useOnboarding","Button","Pagination","props","isDone","dots","Array","from","length","numberOfScreens","_","i","width","createElement","style","styles","pagination","backgroundColor","paginationContainerStyle","buttons","leftButton","buttonLeftContainerStyle","showSkip","hasSkipPosition","
|
|
1
|
+
{"version":3,"names":["View","Pressable","Animated","StyleSheet","React","setAlpha","useOnboarding","Button","Pagination","props","isDone","currentPage","progress","scrollTo","previousPage","dots","Array","from","length","numberOfScreens","_","i","width","showPrevious","createElement","style","styles","pagination","backgroundColor","paginationContainerStyle","buttons","leftButton","buttonLeftContainerStyle","onPress","buttonTextStyle","previousLabelStyle","buttonStyle","previousButtonContainerStyle","label","previousLabel","showSkip","hasSkipPosition","onSkip","skipLabelStyle","skipButtonContainerStyle","skipLabel","paginationStyle","accessible","accessibilityRole","accessibilityValue","min","max","now","progressTrack","color","mirror","progressBarStyle","progressFill","progressBarFillStyle","dotsContainer","dotsContainerStyle","map","inputRange","dotOpacity","animatedValue","interpolate","outputRange","extrapolate","dotProps","dotsAreTappable","accessibilityLabel","accessibilityState","selected","dot","key","opacity","_extends","hitSlop","rightButton","buttonRightContainerStyle","showNext","onNext","nextLabel","nextLabelStyle","nextButtonContainerStyle","showDone","onDone","doneLabel","doneLabelStyle","doneButtonContainerStyle","create","flexDirection","justifyContent","alignItems","height","paddingVertical","paddingHorizontal","borderRadius","marginHorizontal","flex","overflow","text","fontSize","transform","scaleX"],"sourceRoot":"../../../src","sources":["components/Pagination.tsx"],"mappings":";AAAA,SACEA,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,UAAU,QAIL,cAAc;AACrB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,aAAa,QAAQ,wBAAwB;AACtD,SAASC,MAAM,QAAQ,UAAU;AAwCjC,OAAO,SAASC,U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,CAAC;EACDI,IAAI,EAAE;IACJC,QAAQ,EAAE;EACZ,CAAC;EACDxE,OAAO,EAAE;IACPqE,IAAI,EAAE;EACR,CAAC;EACDrB,WAAW,EAAE;IACXe,UAAU,EAAE;EACd,CAAC;EACD9D,UAAU,EAAE;IACV8D,UAAU,EAAE;EACd,CAAC;EACDtC,MAAM,EAAE;IACNgD,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAC5B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,101 +1,74 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { OnboardingPages } from './OnboardingPages';
|
|
3
4
|
import { CustomPages } from './CustomPages';
|
|
4
|
-
import { Animated } from 'react-native';
|
|
5
|
+
import { Animated, I18nManager } from 'react-native';
|
|
5
6
|
import { useOnboarding } from '../hooks/useOnboarding';
|
|
6
7
|
export const Swiper = props => {
|
|
7
|
-
|
|
8
|
+
// `scrollX` is always JS-driven because the background-color interpolation
|
|
9
|
+
// cannot run on the native thread. When `useNativeDriver` is enabled we also
|
|
10
|
+
// keep `nativeScrollX`, driven natively, for transform/opacity animations
|
|
11
|
+
// (the pagination dots), and mirror its offset onto `scrollX` via a JS
|
|
12
|
+
// listener so the color interpolation keeps working.
|
|
13
|
+
const scrollX = React.useMemo(() => new Animated.Value(0), []);
|
|
14
|
+
const nativeScrollX = React.useMemo(() => new Animated.Value(0), []);
|
|
15
|
+
const nativeDriverEnabled = props.useNativeDriver ?? false;
|
|
16
|
+
const dotsAnimatedValue = nativeDriverEnabled ? nativeScrollX : scrollX;
|
|
17
|
+
|
|
18
|
+
// Direction handling: default to the device direction. We only mirror
|
|
19
|
+
// manually (via scaleX) when the requested direction differs from the
|
|
20
|
+
// device's — when they match, React Native already lays the row out
|
|
21
|
+
// correctly and an extra flip would double-invert it.
|
|
22
|
+
const rtl = props.rtl ?? I18nManager.isRTL;
|
|
23
|
+
const mirror = rtl !== I18nManager.isRTL;
|
|
8
24
|
const {
|
|
9
|
-
|
|
25
|
+
setFlatListRef,
|
|
10
26
|
setCurrentPage,
|
|
11
27
|
currentPage,
|
|
12
28
|
numberOfScreens,
|
|
13
29
|
nextPage,
|
|
14
|
-
scrollEnabled
|
|
30
|
+
scrollEnabled,
|
|
31
|
+
pauseAutoPlay
|
|
15
32
|
} = useOnboarding();
|
|
33
|
+
const onScroll = React.useMemo(() => nativeDriverEnabled ? Animated.event([{
|
|
34
|
+
nativeEvent: {
|
|
35
|
+
contentOffset: {
|
|
36
|
+
x: nativeScrollX
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}], {
|
|
40
|
+
useNativeDriver: true,
|
|
41
|
+
listener: event => scrollX.setValue(event.nativeEvent.contentOffset.x)
|
|
42
|
+
}) : Animated.event([{
|
|
43
|
+
nativeEvent: {
|
|
44
|
+
contentOffset: {
|
|
45
|
+
x: scrollX
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}], {
|
|
49
|
+
useNativeDriver: false
|
|
50
|
+
}), [nativeDriverEnabled, nativeScrollX, scrollX]);
|
|
51
|
+
|
|
52
|
+
// Stop autoplay as soon as the user takes manual control of the slider.
|
|
53
|
+
const onScrollBeginDrag = React.useCallback(() => pauseAutoPlay(), [pauseAutoPlay]);
|
|
54
|
+
const shared = {
|
|
55
|
+
setFlatListRef,
|
|
56
|
+
scrollX,
|
|
57
|
+
dotsAnimatedValue,
|
|
58
|
+
onScroll,
|
|
59
|
+
onScrollBeginDrag,
|
|
60
|
+
setPage: setCurrentPage,
|
|
61
|
+
currentPage,
|
|
62
|
+
numberOfScreens,
|
|
63
|
+
nextPage,
|
|
64
|
+
scrollEnabled,
|
|
65
|
+
mirror
|
|
66
|
+
};
|
|
16
67
|
if (props.children) {
|
|
17
|
-
return /*#__PURE__*/React.createElement(CustomPages, {
|
|
18
|
-
customFooter: props.customFooter,
|
|
19
|
-
showPagination: props.showPagination,
|
|
20
|
-
flatListRef: flatListRef,
|
|
21
|
-
scrollX: scrollX,
|
|
22
|
-
setPage: setCurrentPage,
|
|
23
|
-
scrollEnabled: scrollEnabled,
|
|
24
|
-
currentPage: currentPage,
|
|
25
|
-
numberOfScreens: numberOfScreens,
|
|
26
|
-
nextPage: nextPage,
|
|
27
|
-
showDone: props.showDone,
|
|
28
|
-
showNext: props.showNext,
|
|
29
|
-
onDone: props.onDone,
|
|
30
|
-
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
31
|
-
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
32
|
-
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
33
|
-
skipButtonPosition: props.skipButtonPosition,
|
|
34
|
-
paginationContainerStyle: props.paginationContainerStyle,
|
|
35
|
-
paginationPosition: props.paginationPosition,
|
|
36
|
-
nextLabel: props.nextLabel,
|
|
37
|
-
skipLabel: props.skipLabel,
|
|
38
|
-
doneLabel: props.doneLabel,
|
|
39
|
-
showSkip: props.showSkip,
|
|
40
|
-
onSkip: props.onSkip,
|
|
41
|
-
scrollAnimationDuration: props.scrollAnimationDuration,
|
|
42
|
-
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
43
|
-
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
44
|
-
dotsContainerStyle: props.dotsContainerStyle,
|
|
45
|
-
doneLabelStyle: props.doneLabelStyle,
|
|
46
|
-
skipLabelStyle: props.skipLabelStyle,
|
|
47
|
-
nextLabelStyle: props.nextLabelStyle,
|
|
48
|
-
width: props.width,
|
|
49
|
-
color: props.color,
|
|
50
|
-
useNativeDriver: props.useNativeDriver,
|
|
51
|
-
imageContainerStyle: props.imageContainerStyle,
|
|
52
|
-
containerStyle: props.containerStyle,
|
|
53
|
-
titleContainerStyle: props.titleContainerStyle,
|
|
54
|
-
titleStyle: props.titleStyle,
|
|
55
|
-
subtitleStyle: props.subtitleStyle,
|
|
56
|
-
swap: props.swap
|
|
57
|
-
}, props.children);
|
|
68
|
+
return /*#__PURE__*/React.createElement(CustomPages, _extends({}, props, shared), props.children);
|
|
58
69
|
}
|
|
59
|
-
return /*#__PURE__*/React.createElement(OnboardingPages, {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
flatListRef: flatListRef,
|
|
63
|
-
scrollX: scrollX,
|
|
64
|
-
setPage: setCurrentPage,
|
|
65
|
-
currentPage: currentPage,
|
|
66
|
-
paginationPosition: props.paginationPosition,
|
|
67
|
-
nextPage: nextPage,
|
|
68
|
-
showSkip: props.showSkip,
|
|
69
|
-
onDone: props.onDone,
|
|
70
|
-
pages: props.pages || [],
|
|
71
|
-
width: props.width,
|
|
72
|
-
showNext: props.showNext,
|
|
73
|
-
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
74
|
-
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
75
|
-
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
76
|
-
skipLabelStyle: props.skipLabelStyle,
|
|
77
|
-
skipButtonPosition: props.skipButtonPosition,
|
|
78
|
-
showPagination: props.showPagination,
|
|
79
|
-
color: props.color,
|
|
80
|
-
onSkip: props.onSkip,
|
|
81
|
-
swap: props.swap,
|
|
82
|
-
scrollEnabled: scrollEnabled,
|
|
83
|
-
nextLabel: props.nextLabel,
|
|
84
|
-
skipLabel: props.skipLabel,
|
|
85
|
-
doneLabel: props.doneLabel,
|
|
86
|
-
scrollAnimationDuration: props.scrollAnimationDuration,
|
|
87
|
-
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
88
|
-
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
89
|
-
dotsContainerStyle: props.dotsContainerStyle,
|
|
90
|
-
doneLabelStyle: props.doneLabelStyle,
|
|
91
|
-
nextLabelStyle: props.nextLabelStyle,
|
|
92
|
-
useNativeDriver: props.useNativeDriver,
|
|
93
|
-
imageContainerStyle: props.imageContainerStyle,
|
|
94
|
-
containerStyle: props.containerStyle,
|
|
95
|
-
titleContainerStyle: props.titleContainerStyle,
|
|
96
|
-
titleStyle: props.titleStyle,
|
|
97
|
-
subtitleStyle: props.subtitleStyle,
|
|
98
|
-
paginationContainerStyle: props.paginationContainerStyle
|
|
99
|
-
});
|
|
70
|
+
return /*#__PURE__*/React.createElement(OnboardingPages, _extends({}, props, shared, {
|
|
71
|
+
pages: props.pages || []
|
|
72
|
+
}));
|
|
100
73
|
};
|
|
101
74
|
//# sourceMappingURL=Swiper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","OnboardingPages","CustomPages","Animated","useOnboarding","Swiper","props","scrollX","
|
|
1
|
+
{"version":3,"names":["React","OnboardingPages","CustomPages","Animated","I18nManager","useOnboarding","Swiper","props","scrollX","useMemo","Value","nativeScrollX","nativeDriverEnabled","useNativeDriver","dotsAnimatedValue","rtl","isRTL","mirror","setFlatListRef","setCurrentPage","currentPage","numberOfScreens","nextPage","scrollEnabled","pauseAutoPlay","onScroll","event","nativeEvent","contentOffset","x","listener","setValue","onScrollBeginDrag","useCallback","shared","setPage","children","createElement","_extends","pages"],"sourceRoot":"../../../src","sources":["components/Swiper.tsx"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,WAAW,QAAQ,eAAe;AAC3C,SACEC,QAAQ,EACRC,WAAW,QAGN,cAAc;AACrB,SAASC,aAAa,QAAQ,wBAAwB;AAGtD,OAAO,MAAMC,MAAiC,GAAIC,KAAK,IAAK;EAC1D;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAGR,KAAK,CAACS,OAAO,CAAC,MAAM,IAAIN,QAAQ,CAACO,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAC9D,MAAMC,aAAa,GAAGX,KAAK,CAACS,OAA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IACPM,iBAAiB;IACjBW,QAAQ;IACRO,iBAAiB;IACjBG,OAAO,EAAEhB,cAAc;IACvBC,WAAW;IACXC,eAAe;IACfC,QAAQ;IACRC,aAAa;IACbN;EACF,CAAC;EAED,IAAIV,KAAK,CAAC6B,QAAQ,EAAE;IAClB,oBACEpC,KAAA,CAAAqC,aAAA,CAACnC,WAAW,EAAAoC,QAAA,KAAK/B,KAAK,EAAM2B,MAAM,GAC/B3B,KAAK,CAAC6B,QACI,CAAC;EAElB;EAEA,oBAAOpC,KAAA,CAAAqC,aAAA,CAACpC,eAAe,EAAAqC,QAAA,KAAK/B,KAAK,EAAM2B,MAAM;IAAEK,KAAK,EAAEhC,KAAK,CAACgC,KAAK,IAAI;EAAG,EAAE,CAAC;AAC7E,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,9 @@ import React from 'react';
|
|
|
3
3
|
export const Button = props => {
|
|
4
4
|
return typeof props.label === 'string' ? /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
5
5
|
onPress: props.onPress,
|
|
6
|
-
style: props.buttonStyle
|
|
6
|
+
style: props.buttonStyle,
|
|
7
|
+
accessibilityRole: "button",
|
|
8
|
+
accessibilityLabel: props.label
|
|
7
9
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
8
10
|
style: [styles.text, {
|
|
9
11
|
color: props.color || 'white'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","Text","TouchableOpacity","React","Button","props","label","createElement","onPress","style","buttonStyle","styles","text","color","buttonTextStyle","SkipButton","top","left","position","undefined","right","skipButton","create","pagination","flexDirection","justifyContent","alignItems","height","paddingVertical","paddingHorizontal","dot","width","borderRadius","backgroundColor","marginHorizontal","dotsContainer","flex","fontSize","buttons","minWidth","rightButton","paddingRight","leftButton","paddingLeft","zIndex"],"sourceRoot":"../../../src","sources":["components/button.tsx"],"mappings":"AAAA,SACEA,UAAU,EACVC,IAAI,EACJC,gBAAgB,QAIX,cAAc;AACrB,OAAOC,KAAK,MAAM,OAAO;AAUzB,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC5C,OAAO,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,gBACpCH,KAAA,CAAAI,aAAA,CAACL,gBAAgB;
|
|
1
|
+
{"version":3,"names":["StyleSheet","Text","TouchableOpacity","React","Button","props","label","createElement","onPress","style","buttonStyle","accessibilityRole","accessibilityLabel","styles","text","color","buttonTextStyle","SkipButton","top","left","position","undefined","right","skipButton","create","pagination","flexDirection","justifyContent","alignItems","height","paddingVertical","paddingHorizontal","dot","width","borderRadius","backgroundColor","marginHorizontal","dotsContainer","flex","fontSize","buttons","minWidth","rightButton","paddingRight","leftButton","paddingLeft","zIndex"],"sourceRoot":"../../../src","sources":["components/button.tsx"],"mappings":"AAAA,SACEA,UAAU,EACVC,IAAI,EACJC,gBAAgB,QAIX,cAAc;AACrB,OAAOC,KAAK,MAAM,OAAO;AAUzB,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC5C,OAAO,OAAOA,KAAK,CAACC,KAAK,KAAK,QAAQ,gBACpCH,KAAA,CAAAI,aAAA,CAACL,gBAAgB;IACfM,OAAO,EAAEH,KAAK,CAACG,OAAQ;IACvBC,KAAK,EAAEJ,KAAK,CAACK,WAAY;IACzBC,iBAAiB,EAAC,QAAQ;IAC1BC,kBAAkB,EAAEP,KAAK,CAACC;EAAM,gBAEhCH,KAAA,CAAAI,aAAA,CAACN,IAAI;IACHQ,KAAK,EAAE,CACLI,MAAM,CAACC,IAAI,EACX;MACEC,KAAK,EAAEV,KAAK,CAACU,KAAK,IAAI;IACxB,CAAC,EACDV,KAAK,CAACW,eAAe;EACrB,GAEDX,KAAK,CAACC,KACH,CACU,CAAC,GAEnBD,KAAK,CAACC,KACP;AACH,CAAC;AAED,OAAO,MAAMW,UAAU,GACrBZ,KAEC,IACE;EACH,MAAMK,WAAW,GAAG;IAClBQ,GAAG,EAAE,EAAE;IACPC,IAAI,EAAEd,KAA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pB0B,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Dimensions } from 'react-native';
|
|
2
|
+
import { AccessibilityInfo, Animated, Dimensions } from 'react-native';
|
|
3
3
|
export const OnboardingContext = /*#__PURE__*/React.createContext(undefined);
|
|
4
4
|
export const OnboardingProvider = ({
|
|
5
5
|
children,
|
|
6
|
-
width
|
|
6
|
+
width: widthProp,
|
|
7
7
|
numberOfScreens,
|
|
8
|
-
scrollEnabled
|
|
8
|
+
scrollEnabled,
|
|
9
|
+
onPageChange,
|
|
10
|
+
scrollAnimationDuration,
|
|
11
|
+
autoPlay = false,
|
|
12
|
+
autoPlayInterval = 3000,
|
|
13
|
+
loop = false
|
|
9
14
|
}) => {
|
|
15
|
+
const width = widthProp ?? Dimensions.get('window').width;
|
|
10
16
|
const getProgress = page => {
|
|
11
17
|
return Math.round((page + 1) / numberOfScreens * 100);
|
|
12
18
|
};
|
|
@@ -15,40 +21,114 @@ export const OnboardingProvider = ({
|
|
|
15
21
|
const [isDone, setIsDone] = React.useState(false);
|
|
16
22
|
const [enableScroll, setEnableScroll] = React.useState(scrollEnabled);
|
|
17
23
|
const flatListRef = React.useRef(null);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const setFlatListRef = React.useCallback(node => {
|
|
25
|
+
flatListRef.current = node;
|
|
26
|
+
}, []);
|
|
27
|
+
// Tracks the latest page so timers/animations read a fresh value without
|
|
28
|
+
// needing to be recreated on every page change.
|
|
29
|
+
const currentPageRef = React.useRef(0);
|
|
30
|
+
const [isAutoPlaying, setIsAutoPlaying] = React.useState(autoPlay);
|
|
31
|
+
|
|
32
|
+
// Keep autoplay in sync if the `autoPlay` prop is toggled after mount.
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
setIsAutoPlaying(autoPlay);
|
|
35
|
+
}, [autoPlay]);
|
|
36
|
+
|
|
37
|
+
// Dedicated value used to honor a custom scrollAnimationDuration. FlatList's
|
|
38
|
+
// own animated scroll has a fixed, platform-controlled duration, so when a
|
|
39
|
+
// duration is requested we drive the offset manually via this value.
|
|
40
|
+
const scrollAnim = React.useMemo(() => new Animated.Value(0), []);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
const id = scrollAnim.addListener(({
|
|
43
|
+
value
|
|
44
|
+
}) => {
|
|
45
|
+
var _flatListRef$current;
|
|
46
|
+
(_flatListRef$current = flatListRef.current) === null || _flatListRef$current === void 0 || _flatListRef$current.scrollToOffset({
|
|
47
|
+
offset: value,
|
|
48
|
+
animated: false
|
|
28
49
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
const
|
|
33
|
-
if (flatListRef.current
|
|
50
|
+
});
|
|
51
|
+
return () => scrollAnim.removeListener(id);
|
|
52
|
+
}, [scrollAnim]);
|
|
53
|
+
const animateToOffset = React.useCallback((offset, animated) => {
|
|
54
|
+
if (!flatListRef.current) return;
|
|
55
|
+
if (animated && scrollAnimationDuration) {
|
|
56
|
+
scrollAnim.stopAnimation();
|
|
57
|
+
scrollAnim.setValue(width * currentPageRef.current);
|
|
58
|
+
Animated.timing(scrollAnim, {
|
|
59
|
+
toValue: offset,
|
|
60
|
+
duration: scrollAnimationDuration,
|
|
61
|
+
useNativeDriver: false
|
|
62
|
+
}).start();
|
|
63
|
+
} else {
|
|
34
64
|
flatListRef.current.scrollToOffset({
|
|
35
|
-
offset
|
|
36
|
-
animated
|
|
65
|
+
offset,
|
|
66
|
+
animated
|
|
37
67
|
});
|
|
68
|
+
}
|
|
69
|
+
}, [scrollAnim, scrollAnimationDuration, width]);
|
|
70
|
+
const setCurrentPage = React.useCallback(index => {
|
|
71
|
+
setPage(index);
|
|
72
|
+
currentPageRef.current = index;
|
|
73
|
+
setProgress(Math.round((index + 1) / numberOfScreens * 100));
|
|
74
|
+
setIsDone(index === numberOfScreens - 1);
|
|
75
|
+
onPageChange === null || onPageChange === void 0 || onPageChange(index);
|
|
76
|
+
// No-op when no screen reader is active; announces the page otherwise.
|
|
77
|
+
AccessibilityInfo.announceForAccessibility(`Page ${index + 1} of ${numberOfScreens}`);
|
|
78
|
+
}, [numberOfScreens, onPageChange]);
|
|
79
|
+
const nextPage = React.useCallback((animated = true) => {
|
|
80
|
+
const current = currentPageRef.current;
|
|
81
|
+
if (current < numberOfScreens - 1) {
|
|
82
|
+
animateToOffset(width * (current + 1), animated);
|
|
83
|
+
setCurrentPage(current + 1);
|
|
84
|
+
} else if (loop) {
|
|
85
|
+
animateToOffset(0, animated);
|
|
86
|
+
setCurrentPage(0);
|
|
87
|
+
}
|
|
88
|
+
}, [numberOfScreens, loop, width, animateToOffset, setCurrentPage]);
|
|
89
|
+
const previousPage = React.useCallback((animated = true) => {
|
|
90
|
+
const current = currentPageRef.current;
|
|
91
|
+
if (current > 0) {
|
|
92
|
+
animateToOffset(width * (current - 1), animated);
|
|
93
|
+
setCurrentPage(current - 1);
|
|
94
|
+
} else if (loop) {
|
|
95
|
+
animateToOffset(width * (numberOfScreens - 1), animated);
|
|
96
|
+
setCurrentPage(numberOfScreens - 1);
|
|
97
|
+
}
|
|
98
|
+
}, [numberOfScreens, loop, width, animateToOffset, setCurrentPage]);
|
|
99
|
+
const scrollTo = React.useCallback((index, animated = true) => {
|
|
100
|
+
if (index >= 0 && index < numberOfScreens) {
|
|
101
|
+
animateToOffset(index * width, animated);
|
|
38
102
|
setCurrentPage(index);
|
|
39
103
|
}
|
|
40
|
-
};
|
|
104
|
+
}, [numberOfScreens, width, animateToOffset, setCurrentPage]);
|
|
105
|
+
const pauseAutoPlay = React.useCallback(() => setIsAutoPlaying(false), []);
|
|
106
|
+
const resumeAutoPlay = React.useCallback(() => setIsAutoPlaying(autoPlay), [autoPlay]);
|
|
107
|
+
|
|
108
|
+
// Autoplay timer. Recreated whenever the page changes so it always advances
|
|
109
|
+
// from the current position; pauses when the user interacts with the slider.
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (!isAutoPlaying || numberOfScreens <= 1) return;
|
|
112
|
+
if (!loop && currentPage >= numberOfScreens - 1) return;
|
|
113
|
+
const timer = setTimeout(() => nextPage(true), autoPlayInterval);
|
|
114
|
+
return () => clearTimeout(timer);
|
|
115
|
+
}, [isAutoPlaying, currentPage, numberOfScreens, autoPlayInterval, loop, nextPage]);
|
|
41
116
|
const contextValue = {
|
|
42
117
|
scrollEnabled: enableScroll,
|
|
43
118
|
enableScroll: setEnableScroll,
|
|
119
|
+
width,
|
|
44
120
|
currentPage,
|
|
45
121
|
numberOfScreens,
|
|
46
122
|
nextPage,
|
|
123
|
+
previousPage,
|
|
47
124
|
setCurrentPage,
|
|
48
125
|
flatListRef,
|
|
126
|
+
setFlatListRef,
|
|
49
127
|
scrollTo,
|
|
50
128
|
progress,
|
|
51
|
-
isDone
|
|
129
|
+
isDone,
|
|
130
|
+
pauseAutoPlay,
|
|
131
|
+
resumeAutoPlay
|
|
52
132
|
};
|
|
53
133
|
return /*#__PURE__*/React.createElement(OnboardingContext.Provider, {
|
|
54
134
|
value: contextValue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Dimensions","OnboardingContext","createContext","undefined","OnboardingProvider","children","width","
|
|
1
|
+
{"version":3,"names":["React","AccessibilityInfo","Animated","Dimensions","OnboardingContext","createContext","undefined","OnboardingProvider","children","width","widthProp","numberOfScreens","scrollEnabled","onPageChange","scrollAnimationDuration","autoPlay","autoPlayInterval","loop","get","getProgress","page","Math","round","currentPage","setPage","useState","progress","setProgress","isDone","setIsDone","enableScroll","setEnableScroll","flatListRef","useRef","setFlatListRef","useCallback","node","current","currentPageRef","isAutoPlaying","setIsAutoPlaying","useEffect","scrollAnim","useMemo","Value","id","addListener","value","_flatListRef$current","scrollToOffset","offset","animated","removeListener","animateToOffset","stopAnimation","setValue","timing","toValue","duration","useNativeDriver","start","setCurrentPage","index","announceForAccessibility","nextPage","previousPage","scrollTo","pauseAutoPlay","resumeAutoPlay","timer","setTimeout","clearTimeout","contextValue","createElement","Provider"],"sourceRoot":"../../../src","sources":["context/OnboardingContext.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,iBAAiB,EACjBC,QAAQ,EACRC,UAAU,QAEL,cAAc;AAwCrB,OAAO,MAAMC,iBAAiB,gBAAGJ,KAAK,CAACK,aAAa,CAElDC,SAAS,CAAC;AAEZ,OAAO,MAAMC,kBAAqD,GAAGA,CAAC;EACpEC,QAAQ;EACRC,KAAK,EAAEC,SAAS;EAChBC,eAAe;EACfC,aAAa;EACbC,YAAY;EACZC,uBAAuB;EACvBC,QAAQ,GAAG,KAAK;EAChBC,gBAAgB,GAAG,IAAI;EACvBC,IAAI,GAAG;AACT,CAAC,KAAK;EACJ,MAAMR,KAAK,GAAGC,SAAS,IAAIP,UAAU,CAACe,GAAG,CAAC,QAAQ,CAAC,CAACT,KAAK;EACzD,MAAMU,WAAW,GAAIC,IAAY,IAAK;IACpC,OAAOC,IAAI,CAACC,KAAK,CAAE,CAACF,IAAI,GAAG,CAAC,IAAIT,eAAe,GAAI,GAAG,CAAC;EACzD,CAAC;EAED,MAAM,CAACY,WAAW,EAAEC,OAAO,CAAC,GAAGxB,KAAK,CAACyB,QAAQ,CAAC,CAAC,CAAC;EAChD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAG3B,KAAK,CAACyB,QAAQ,CAACN,WAAW,CAAC,CAAC,CAAC,CAAC;EAC9D,MAAM,CAACS,MAAM,EAAEC,SAAS,CAAC,GAAG7B,KAAK,CAACyB,QAAQ,CAAC,KAAK,CAAC;EACjD,MAAM,CAACK,YAAY,EAAEC,eAAe,CAAC,GAAG/B,KAAK,CAACyB,QAAQ,CACpDb,aACF,CAAC;EACD,MAAMoB,WAAW,GAAGhC,KAAK,CAACiC,MAAM,CAAkB,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AAC;EAC1E,MAAM4B,cAAc,GAAGpE,KAAK,CAACmC,WAAW,CACtC,MAAMK,gBAAgB,CAACzB,QAAQ,CAAC,EAChC,CAACA,QAAQ,CACX,CAAC;;EAED;EACA;EACAf,KAAK,CAACyC,SAAS,CAAC,MAAM;IACpB,IAAI,CAACF,aAAa,IAAI5B,eAAe,IAAI,CAAC,EAAE;IAC5C,IAAI,CAACM,IAAI,IAAIM,WAAW,IAAIZ,eAAe,GAAG,CAAC,EAAE;IACjD,MAAM0D,KAAK,GAAGC,UAAU,CAAC,MAAMN,QAAQ,CAAC,IAAI,CAAC,EAAEhD,gBAAgB,CAAC;IAChE,OAAO,MAAMuD,YAAY,CAACF,KAAK,CAAC;EAClC,CAAC,EAAE,CACD9B,aAAa,EACbhB,WAAW,EACXZ,eAAe,EACfK,gBAAgB,EAChBC,IAAI,EACJ+C,QAAQ,CACT,CAAC;EAEF,MAAMQ,YAAmC,GAAG;IAC1C5D,aAAa,EAAEkB,YAAY;IAC3BA,YAAY,EAAEC,eAAe;IAC7BtB,KAAK;IACLc,WAAW;IACXZ,eAAe;IACfqD,QAAQ;IACRC,YAAY;IACZJ,cAAc;IACd7B,WAAW;IACXE,cAAc;IACdgC,QAAQ;IACRxC,QAAQ;IACRE,MAAM;IACNuC,aAAa;IACbC;EACF,CAAC;EAED,oBACEpE,KAAA,CAAAyE,aAAA,CAACrE,iBAAiB,CAACsE,QAAQ;IAAC3B,KAAK,EAAEyB;EAAa,GAC7ChE,QACyB,CAAC;AAEjC,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ import { OnboardingContext } from '../context/OnboardingContext';
|
|
|
3
3
|
export const useOnboarding = () => {
|
|
4
4
|
const context = React.useContext(OnboardingContext);
|
|
5
5
|
if (!context) {
|
|
6
|
-
throw new Error('
|
|
6
|
+
throw new Error('useOnboarding must be used within an OnboardingProvider');
|
|
7
7
|
}
|
|
8
8
|
return context;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","OnboardingContext","useOnboarding","context","useContext","Error"],"sourceRoot":"../../../src","sources":["hooks/useOnboarding.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,8BAA8B;AAEhE,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAACH,iBAAiB,CAAC;EACnD,IAAI,CAACE,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,
|
|
1
|
+
{"version":3,"names":["React","OnboardingContext","useOnboarding","context","useContext","Error"],"sourceRoot":"../../../src","sources":["hooks/useOnboarding.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,8BAA8B;AAEhE,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAMC,OAAO,GAAGH,KAAK,CAACI,UAAU,CAACH,iBAAiB,CAAC;EACnD,IAAI,CAACE,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,yDAAyD,CAAC;EAC5E;EACA,OAAOF,OAAO;AAChB,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Swiper } from './components
|
|
2
|
+
import { Swiper } from './components';
|
|
3
3
|
import { OnboardingProvider } from './context/OnboardingContext';
|
|
4
4
|
export { useOnboarding } from './hooks/useOnboarding';
|
|
5
|
+
export { createOnboardingStorage, hasCompletedOnboarding, markOnboardingComplete, resetOnboarding } from './utils/persistence';
|
|
5
6
|
export function Onboarding(props) {
|
|
6
7
|
var _props$pages;
|
|
7
8
|
const numberOfScreens = React.Children.count(props.children);
|
|
8
9
|
return /*#__PURE__*/React.createElement(OnboardingProvider, {
|
|
10
|
+
width: props.width,
|
|
9
11
|
scrollEnabled: props.scrollEnabled,
|
|
12
|
+
onPageChange: props.onPageChange,
|
|
13
|
+
scrollAnimationDuration: props.scrollAnimationDuration,
|
|
14
|
+
autoPlay: props.autoPlay,
|
|
15
|
+
autoPlayInterval: props.autoPlayInterval,
|
|
16
|
+
loop: props.loop,
|
|
10
17
|
numberOfScreens: numberOfScreens || ((_props$pages = props.pages) === null || _props$pages === void 0 ? void 0 : _props$pages.length) || 0
|
|
11
18
|
}, /*#__PURE__*/React.createElement(Swiper, props, props.children));
|
|
12
19
|
}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Swiper","OnboardingProvider","useOnboarding","Onboarding","props","_props$pages","numberOfScreens","Children","count","children","createElement","scrollEnabled","pages","length"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"names":["React","Swiper","OnboardingProvider","useOnboarding","createOnboardingStorage","hasCompletedOnboarding","markOnboardingComplete","resetOnboarding","Onboarding","props","_props$pages","numberOfScreens","Children","count","children","createElement","width","scrollEnabled","onPageChange","scrollAnimationDuration","autoPlay","autoPlayInterval","loop","pages","length"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,kBAAkB,QAAQ,6BAA6B;AAGhE,SAASC,aAAa,QAAQ,uBAAuB;AAGrD,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,sBAAsB,EACtBC,eAAe,QACV,qBAAqB;AAG5B,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAE;EAAA,IAAAC,YAAA;EACjD,MAAMC,eAAe,GAAGX,KAAK,CAACY,QAAQ,CAACC,KAAK,CAACJ,KAAK,CAACK,QAAQ,CAAC;EAC5D,oBACEd,KAAA,CAAAe,aAAA,CAACb,kBAAkB;IACjBc,KAAK,EAAEP,KAAK,CAACO,KAAM;IACnBC,aAAa,EAAER,KAAK,CAACQ,aAAc;IACnCC,YAAY,EAAET,KAAK,CAACS,YAAa;IACjCC,uBAAuB,EAAEV,KAAK,CAACU,uBAAwB;IACvDC,QAAQ,EAAEX,KAAK,CAACW,QAAS;IACzBC,gBAAgB,EAAEZ,KAAK,CAACY,gBAAiB;IACzCC,IAAI,EAAEb,KAAK,CAACa,IAAK;IACjBX,eAAe,EAAEA,eAAe,MAAAD,YAAA,GAAID,KAAK,CAACc,KAAK,cAAAb,YAAA,uBAAXA,YAAA,CAAac,MAAM,KAAI;EAAE,gBAE7DxB,KAAA,CAAAe,aAAA,CAACd,MAAM,EAAKQ,KAAK,EAAGA,KAAK,CAACK,QAAiB,CACzB,CAAC;AAEzB","ignoreList":[]}
|