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
|
@@ -10,32 +10,29 @@ export const CustomPages = ({
|
|
|
10
10
|
showNext = true,
|
|
11
11
|
...props
|
|
12
12
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, props.skipButtonPosition && props.showSkip && /*#__PURE__*/React.createElement(SkipButton, {
|
|
16
|
-
buttonTextStyle: props.skipLabelStyle,
|
|
17
|
-
buttonStyle: props.skipButtonContainerStyle,
|
|
18
|
-
position: props.skipButtonPosition,
|
|
19
|
-
onPress: props.onSkip,
|
|
20
|
-
label: props.skipLabel
|
|
21
|
-
}), showPagination && props.paginationPosition === 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, props.customFooter && props.customFooter({
|
|
22
|
-
nextPage: props.nextPage
|
|
23
|
-
}), !props.customFooter && /*#__PURE__*/React.createElement(Pagination, {
|
|
13
|
+
const pageWidth = props.width || width;
|
|
14
|
+
const paginationProps = {
|
|
24
15
|
color: '#fff',
|
|
25
16
|
backgroundColor: '#333',
|
|
26
|
-
width:
|
|
17
|
+
width: pageWidth,
|
|
27
18
|
onNext: props.nextPage,
|
|
28
19
|
onSkip: props.onSkip,
|
|
29
20
|
onDone: props.onDone,
|
|
30
21
|
showDone: props.showDone,
|
|
31
|
-
|
|
22
|
+
showPrevious: props.showPrevious,
|
|
23
|
+
animatedValue: props.dotsAnimatedValue,
|
|
32
24
|
showSkip: props.showSkip,
|
|
33
25
|
numberOfScreens: props.numberOfScreens,
|
|
34
26
|
skipLabel: props.skipLabel,
|
|
35
|
-
showNext
|
|
27
|
+
showNext,
|
|
36
28
|
nextLabel: props.nextLabel,
|
|
29
|
+
previousLabel: props.previousLabel,
|
|
37
30
|
doneLabel: props.doneLabel,
|
|
38
31
|
hasSkipPosition: !!props.skipButtonPosition,
|
|
32
|
+
paginationStyle: props.paginationStyle,
|
|
33
|
+
progressBarStyle: props.progressBarStyle,
|
|
34
|
+
progressBarFillStyle: props.progressBarFillStyle,
|
|
35
|
+
dotsAreTappable: props.dotsAreTappable,
|
|
39
36
|
paginationContainerStyle: props.paginationContainerStyle,
|
|
40
37
|
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
41
38
|
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
@@ -44,28 +41,34 @@ export const CustomPages = ({
|
|
|
44
41
|
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
45
42
|
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
46
43
|
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
44
|
+
previousButtonContainerStyle: props.previousButtonContainerStyle,
|
|
47
45
|
skipLabelStyle: props.skipLabelStyle,
|
|
46
|
+
previousLabelStyle: props.previousLabelStyle,
|
|
48
47
|
nextLabelStyle: props.nextLabelStyle,
|
|
49
48
|
paginationPosition: props.paginationPosition
|
|
50
|
-
}
|
|
51
|
-
|
|
49
|
+
};
|
|
50
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
51
|
+
style: [styles.container]
|
|
52
|
+
}, props.skipButtonPosition && props.showSkip && /*#__PURE__*/React.createElement(SkipButton, {
|
|
53
|
+
buttonTextStyle: props.skipLabelStyle,
|
|
54
|
+
buttonStyle: props.skipButtonContainerStyle,
|
|
55
|
+
position: props.skipButtonPosition,
|
|
56
|
+
onPress: props.onSkip,
|
|
57
|
+
label: props.skipLabel
|
|
58
|
+
}), showPagination && props.paginationPosition === 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, props.customFooter && props.customFooter({
|
|
59
|
+
nextPage: props.nextPage
|
|
60
|
+
}), !props.customFooter && /*#__PURE__*/React.createElement(Pagination, paginationProps)), /*#__PURE__*/React.createElement(Animated.FlatList, {
|
|
61
|
+
ref: node => props.setFlatListRef(node),
|
|
52
62
|
data: React.Children.toArray(props.children),
|
|
53
63
|
horizontal: true,
|
|
54
64
|
pagingEnabled: true,
|
|
55
65
|
showsHorizontalScrollIndicator: false,
|
|
56
66
|
scrollEnabled: props.scrollEnabled,
|
|
57
|
-
onScroll:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
x: props.scrollX
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}], {
|
|
64
|
-
useNativeDriver: false
|
|
65
|
-
}),
|
|
66
|
-
scrollEventThrottle: 1,
|
|
67
|
+
onScroll: props.onScroll,
|
|
68
|
+
onScrollBeginDrag: props.onScrollBeginDrag,
|
|
69
|
+
scrollEventThrottle: 16,
|
|
67
70
|
onMomentumScrollEnd: event => {
|
|
68
|
-
const pageIndex = Math.round(event.nativeEvent.contentOffset.x /
|
|
71
|
+
const pageIndex = Math.round(event.nativeEvent.contentOffset.x / pageWidth);
|
|
69
72
|
props.setPage(pageIndex || 0);
|
|
70
73
|
},
|
|
71
74
|
keyExtractor: (_, index) => index.toString(),
|
|
@@ -82,34 +85,7 @@ export const CustomPages = ({
|
|
|
82
85
|
}
|
|
83
86
|
}), showPagination && props.paginationPosition !== 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, props.customFooter && props.customFooter({
|
|
84
87
|
nextPage: props.nextPage
|
|
85
|
-
}), !props.customFooter && /*#__PURE__*/React.createElement(Pagination,
|
|
86
|
-
color: '#fff',
|
|
87
|
-
backgroundColor: '#333',
|
|
88
|
-
width: width,
|
|
89
|
-
onNext: props.nextPage,
|
|
90
|
-
onSkip: props.onSkip,
|
|
91
|
-
onDone: props.onDone,
|
|
92
|
-
showDone: props.showDone,
|
|
93
|
-
animatedValue: props.scrollX,
|
|
94
|
-
showSkip: props.showSkip,
|
|
95
|
-
numberOfScreens: props.numberOfScreens,
|
|
96
|
-
skipLabel: props.skipLabel,
|
|
97
|
-
nextLabel: props.nextLabel,
|
|
98
|
-
showNext: showNext,
|
|
99
|
-
doneLabel: props.doneLabel,
|
|
100
|
-
paginationContainerStyle: props.paginationContainerStyle,
|
|
101
|
-
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
102
|
-
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
103
|
-
dotsContainerStyle: props.dotsContainerStyle,
|
|
104
|
-
doneLabelStyle: props.doneLabelStyle,
|
|
105
|
-
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
106
|
-
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
107
|
-
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
108
|
-
skipLabelStyle: props.skipLabelStyle,
|
|
109
|
-
hasSkipPosition: !!props.skipButtonPosition,
|
|
110
|
-
paginationPosition: props.paginationPosition,
|
|
111
|
-
nextLabelStyle: props.nextLabelStyle
|
|
112
|
-
})));
|
|
88
|
+
}), !props.customFooter && /*#__PURE__*/React.createElement(Pagination, paginationProps)));
|
|
113
89
|
};
|
|
114
90
|
const styles = StyleSheet.create({
|
|
115
91
|
container: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Dimensions","Animated","StyleSheet","React","Pagination","SkipButton","width","get","CustomPages","showPagination","showNext","props","
|
|
1
|
+
{"version":3,"names":["View","Dimensions","Animated","StyleSheet","React","Pagination","SkipButton","width","get","CustomPages","showPagination","showNext","props","pageWidth","paginationProps","color","backgroundColor","onNext","nextPage","onSkip","onDone","showDone","showPrevious","animatedValue","dotsAnimatedValue","showSkip","numberOfScreens","skipLabel","nextLabel","previousLabel","doneLabel","hasSkipPosition","skipButtonPosition","paginationStyle","progressBarStyle","progressBarFillStyle","dotsAreTappable","paginationContainerStyle","buttonRightContainerStyle","buttonLeftContainerStyle","dotsContainerStyle","doneLabelStyle","skipButtonContainerStyle","nextButtonContainerStyle","doneButtonContainerStyle","previousButtonContainerStyle","skipLabelStyle","previousLabelStyle","nextLabelStyle","paginationPosition","createElement","style","styles","container","buttonTextStyle","buttonStyle","position","onPress","label","Fragment","customFooter","FlatList","ref","node","setFlatListRef","data","Children","toArray","children","horizontal","pagingEnabled","showsHorizontalScrollIndicator","scrollEnabled","onScroll","onScrollBeginDrag","scrollEventThrottle","onMomentumScrollEnd","event","pageIndex","Math","round","nativeEvent","contentOffset","x","setPage","keyExtractor","_","index","toString","renderItem","item","cloneElement","currentPage","create","flex","justifyContent","alignItems","screen","pagination","flexDirection","paddingVertical","paddingHorizontal","dot","height","borderRadius","margin","dotsContainer"],"sourceRoot":"../../../src","sources":["components/CustomPages.tsx"],"mappings":"AAAA,SACEA,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,UAAU,QAIL,cAAc;AACrB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,cAAc;AAEzC,SAASC,UAAU,QAAQ,UAAU;AAErC,MAAM;EAAEC;AAAM,CAAC,GAAGN,UAAU,CAACO,GAAG,CAAC,QAAQ,CAAC;AAyB1C,OAAO,MAAMC,WAAW,GAAGA,CAAC;EAC1BC,cAAc,GAAG,IAAI;EACrBC,QAAQ,GAAG,IAAI;EACf,GAAGC;AACa,CAAC,KAAK;EACtB,MAAMC,SAAS,GAAGD,KAAK,CAACL,KAAK,IAAIA,KAAK;EAEtC,MAAMO,eAAe,GAAG;IACtBC,KAAK,EAAE,MAAM;IACbC,eAAe,EAAE,MAAM;IACvBT,KAAK,EAAEM,SAAS;IAChBI,MAAM,EAAEL,KAAK,CAACM,QAAQ;IACtBC,MAAM,EAAEP,KAAK,CAACO,MAAM;IACpBC,MAAM,EAAER,KAAK,CAACQ,MAAM;IACpBC,QAAQ,EAAET,KAAK,CAACS,QAAQ;IACxBC,YAAY,EAAEV,KAAK,CAACU,YAAY;IAChCC,aAAa,EAAEX,KAAK,CAACY,iBAAiB;IACtCC,QAAQ,EAAEb,KAAK,CAACa,QAAQ;IACxBC,eAAe,EAAEd,KAAK,CAACc,eAAe;IACtCC,SAAS,EAAEf,KAAK,CAACe,SAAS;IAC1BhB,QAAQ;IACRiB,SAAS,EAAEhB,KAAK,CAACgB,SAAS;IAC1BC,aAAa,EAAEjB,KAAK,CAACiB,aAAa;IAClCC,SAAS,EAAElB,KAAK,CAACkB,SAAS;IAC1BC,eAAe,EAAE,CAAC,CAACnB,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AK,CAACc,eAAe;QACtCR,QAAQ,EAAEN,KAAK,CAACM,QAAQ;QACxBqE;MACF,CACF,CAAC;IACH;EAAE,CACH,CAAC,EAED7E,cAAc,IAAIE,KAAK,CAACqC,kBAAkB,KAAK,KAAK,iBACnD7C,KAAA,CAAA8C,aAAA,CAAA9C,KAAA,CAAAuD,QAAA,QACG/C,KAAK,CAACgD,YAAY,IACjBhD,KAAK,CAACgD,YAAY,CAAC;IAAE1C,QAAQ,EAAEN,KAAK,CAACM;EAAS,CAAC,CAAC,EACjD,CAACN,KAAK,CAACgD,YAAY,iBAAIxD,KAAA,CAAA8C,aAAA,CAAC7C,UAAU,EAAKS,eAAkB,CAC1D,CAEA,CAAC;AAEX,CAAC;AAED,MAAMsC,MAAM,GAAGjD,UAAU,CAAC0F,MAAM,CAAC;EAC/BxC,SAAS,EAAE;IACTyC,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd,CAAC;EACDC,MAAM,EAAE;IACN1F,KAAK;IACLwF,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBhF,eAAe,EAAE;EACnB,CAAC;EACDkF,UAAU,EAAE;IACVC,aAAa,EAAE,KAAK;IACpBH,UAAU,EAAE,QAAQ;IACpBI,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrB9F;EACF,CAAC;EACD+F,GAAG,EAAE;IACHC,MAAM,EAAE,EAAE;IACVhG,KAAK,EAAE,EAAE;IACTiG,YAAY,EAAE,CAAC;IACfxF,eAAe,EAAE,MAAM;IACvByF,MAAM,EAAE;EACV,CAAC;EACDC,aAAa,EAAE;IACbP,aAAa,EAAE,KAAK;IACpBL,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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); }
|
|
2
|
-
import React, {
|
|
3
|
-
import
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { getBrightness, lighten, darken } from '../utils/color';
|
|
4
4
|
import { Animated, StyleSheet, Dimensions } from 'react-native';
|
|
5
5
|
import { Pagination } from './Pagination';
|
|
6
6
|
import { OnboardingPage } from './Page';
|
|
@@ -13,122 +13,102 @@ export const OnboardingPages = ({
|
|
|
13
13
|
showNext = true,
|
|
14
14
|
...props
|
|
15
15
|
}) => {
|
|
16
|
-
|
|
17
|
-
const backgroundColorAnim = useRef(new Animated.Value(0)).current;
|
|
18
|
-
const [previousPage, setPreviousPage] = React.useState(0);
|
|
16
|
+
const pageWidth = props.width || width;
|
|
19
17
|
const currentPage_ = props.pages[props.currentPage];
|
|
20
|
-
const currentBackgroundColor = (currentPage_ === null || currentPage_ === void 0 ? void 0 : currentPage_.backgroundColor)
|
|
21
|
-
const isLight =
|
|
22
|
-
const footerBackgroundColor = isLight ?
|
|
23
|
-
const color =
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, props.skipButtonPosition && props.showSkip && /*#__PURE__*/React.createElement(SkipButton, {
|
|
40
|
-
buttonTextStyle: props.skipLabelStyle,
|
|
41
|
-
buttonStyle: props.skipButtonContainerStyle,
|
|
42
|
-
position: props.skipButtonPosition,
|
|
43
|
-
label: props.skipLabel,
|
|
44
|
-
onPress: props.onSkip
|
|
45
|
-
}), props.paginationPosition === 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, showPagination && props.customFooter && props.customFooter({
|
|
46
|
-
nextPage: props.nextPage
|
|
47
|
-
}), !props.customFooter && showPagination && /*#__PURE__*/React.createElement(Pagination, {
|
|
48
|
-
width: props.width || width,
|
|
18
|
+
const currentBackgroundColor = (currentPage_ === null || currentPage_ === void 0 ? void 0 : currentPage_.backgroundColor) ?? 'white';
|
|
19
|
+
const isLight = getBrightness(currentBackgroundColor) > 180;
|
|
20
|
+
const footerBackgroundColor = isLight ? darken(currentBackgroundColor, 30) : lighten(currentBackgroundColor, 30);
|
|
21
|
+
const color = getBrightness(footerBackgroundColor) > 180 ? darken(footerBackgroundColor, 60) : lighten(footerBackgroundColor, 60);
|
|
22
|
+
const interpolatedBackgroundColor = useMemo(() => {
|
|
23
|
+
const pages = props.pages;
|
|
24
|
+
// interpolate() requires at least 2 stops; for 0 or 1 pages there is
|
|
25
|
+
// nothing to animate between, so use the solid current color.
|
|
26
|
+
if (pages.length < 2) return currentBackgroundColor;
|
|
27
|
+
const inputRange = pages.map((_, i) => i * pageWidth);
|
|
28
|
+
const outputRange = pages.map(p => p.backgroundColor ?? 'white');
|
|
29
|
+
return props.scrollX.interpolate({
|
|
30
|
+
inputRange,
|
|
31
|
+
outputRange,
|
|
32
|
+
extrapolate: 'clamp'
|
|
33
|
+
});
|
|
34
|
+
}, [props.pages, props.scrollX, pageWidth, currentBackgroundColor]);
|
|
35
|
+
const paginationProps = {
|
|
36
|
+
width: pageWidth,
|
|
49
37
|
onNext: props.nextPage,
|
|
50
38
|
onSkip: props.onSkip,
|
|
51
|
-
color
|
|
52
|
-
showNext
|
|
39
|
+
color,
|
|
40
|
+
showNext,
|
|
53
41
|
onDone: props.onDone,
|
|
54
42
|
showDone: props.showDone,
|
|
43
|
+
showPrevious: props.showPrevious,
|
|
55
44
|
backgroundColor: footerBackgroundColor,
|
|
56
|
-
animatedValue: props.
|
|
45
|
+
animatedValue: props.dotsAnimatedValue,
|
|
57
46
|
showSkip: props.showSkip,
|
|
58
47
|
numberOfScreens: props.pages.length,
|
|
59
48
|
skipLabel: props.skipLabel,
|
|
60
49
|
nextLabel: props.nextLabel,
|
|
50
|
+
previousLabel: props.previousLabel,
|
|
61
51
|
hasSkipPosition: !!props.skipButtonPosition,
|
|
62
52
|
doneLabel: props.doneLabel,
|
|
53
|
+
paginationStyle: props.paginationStyle,
|
|
54
|
+
progressBarStyle: props.progressBarStyle,
|
|
55
|
+
progressBarFillStyle: props.progressBarFillStyle,
|
|
56
|
+
dotsAreTappable: props.dotsAreTappable,
|
|
57
|
+
mirror: props.mirror,
|
|
63
58
|
paginationContainerStyle: props.paginationContainerStyle,
|
|
64
59
|
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
65
60
|
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
66
61
|
dotsContainerStyle: props.dotsContainerStyle,
|
|
67
62
|
doneLabelStyle: props.doneLabelStyle,
|
|
68
63
|
skipLabelStyle: props.skipLabelStyle,
|
|
64
|
+
previousLabelStyle: props.previousLabelStyle,
|
|
69
65
|
nextLabelStyle: props.nextLabelStyle,
|
|
70
66
|
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
71
67
|
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
72
|
-
doneButtonContainerStyle: props.doneButtonContainerStyle
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
69
|
+
previousButtonContainerStyle: props.previousButtonContainerStyle
|
|
70
|
+
};
|
|
71
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
72
|
+
style: [styles.container, {
|
|
73
|
+
backgroundColor: interpolatedBackgroundColor
|
|
74
|
+
}]
|
|
75
|
+
}, props.skipButtonPosition && props.showSkip && /*#__PURE__*/React.createElement(SkipButton, {
|
|
76
|
+
buttonTextStyle: props.skipLabelStyle,
|
|
77
|
+
buttonStyle: props.skipButtonContainerStyle,
|
|
78
|
+
position: props.skipButtonPosition,
|
|
79
|
+
label: props.skipLabel,
|
|
80
|
+
onPress: props.onSkip
|
|
81
|
+
}), props.paginationPosition === 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, showPagination && props.customFooter && props.customFooter({
|
|
82
|
+
nextPage: props.nextPage
|
|
83
|
+
}), !props.customFooter && showPagination && /*#__PURE__*/React.createElement(Pagination, paginationProps)), /*#__PURE__*/React.createElement(Animated.FlatList, {
|
|
84
|
+
ref: node => props.setFlatListRef(node),
|
|
75
85
|
data: props.pages,
|
|
76
86
|
horizontal: true,
|
|
77
87
|
pagingEnabled: true,
|
|
78
88
|
showsHorizontalScrollIndicator: false,
|
|
89
|
+
scrollEnabled: props.scrollEnabled,
|
|
90
|
+
style: props.mirror ? styles.mirror : undefined,
|
|
79
91
|
keyExtractor: (_, index) => index.toString(),
|
|
80
92
|
renderItem: ({
|
|
81
93
|
item,
|
|
82
94
|
index
|
|
83
95
|
}) => /*#__PURE__*/React.createElement(OnboardingPage, _extends({
|
|
84
96
|
color: color,
|
|
85
|
-
width:
|
|
97
|
+
width: pageWidth,
|
|
86
98
|
swap: props.swap,
|
|
99
|
+
mirror: props.mirror,
|
|
87
100
|
key: index
|
|
88
101
|
}, item)),
|
|
89
|
-
onScroll:
|
|
90
|
-
|
|
91
|
-
contentOffset: {
|
|
92
|
-
x: props.scrollX
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}], {
|
|
96
|
-
useNativeDriver: false
|
|
97
|
-
}),
|
|
102
|
+
onScroll: props.onScroll,
|
|
103
|
+
onScrollBeginDrag: props.onScrollBeginDrag,
|
|
98
104
|
scrollEventThrottle: 16,
|
|
99
105
|
onMomentumScrollEnd: event => {
|
|
100
|
-
const pageIndex = Math.round(event.nativeEvent.contentOffset.x /
|
|
101
|
-
|
|
106
|
+
const pageIndex = Math.round(event.nativeEvent.contentOffset.x / pageWidth);
|
|
107
|
+
props.setPage(pageIndex || 0);
|
|
102
108
|
}
|
|
103
109
|
}), props.paginationPosition !== 'top' && /*#__PURE__*/React.createElement(React.Fragment, null, showPagination && props.customFooter && props.customFooter({
|
|
104
110
|
nextPage: props.nextPage
|
|
105
|
-
}), !props.customFooter && showPagination && /*#__PURE__*/React.createElement(Pagination,
|
|
106
|
-
width: props.width || width,
|
|
107
|
-
onNext: props.nextPage,
|
|
108
|
-
onSkip: props.onSkip,
|
|
109
|
-
color: color,
|
|
110
|
-
hasSkipPosition: !!props.skipButtonPosition,
|
|
111
|
-
onDone: props.onDone,
|
|
112
|
-
showDone: props.showDone,
|
|
113
|
-
backgroundColor: footerBackgroundColor,
|
|
114
|
-
animatedValue: props.scrollX,
|
|
115
|
-
showSkip: props.showSkip,
|
|
116
|
-
numberOfScreens: props.pages.length,
|
|
117
|
-
skipLabel: props.skipLabel,
|
|
118
|
-
nextLabel: props.nextLabel,
|
|
119
|
-
doneLabel: props.doneLabel,
|
|
120
|
-
paginationContainerStyle: props.paginationContainerStyle,
|
|
121
|
-
buttonRightContainerStyle: props.buttonRightContainerStyle,
|
|
122
|
-
buttonLeftContainerStyle: props.buttonLeftContainerStyle,
|
|
123
|
-
dotsContainerStyle: props.dotsContainerStyle,
|
|
124
|
-
doneLabelStyle: props.doneLabelStyle,
|
|
125
|
-
skipLabelStyle: props.skipLabelStyle,
|
|
126
|
-
skipButtonContainerStyle: props.skipButtonContainerStyle,
|
|
127
|
-
nextButtonContainerStyle: props.nextButtonContainerStyle,
|
|
128
|
-
doneButtonContainerStyle: props.doneButtonContainerStyle,
|
|
129
|
-
showNext: showNext,
|
|
130
|
-
nextLabelStyle: props.nextLabelStyle
|
|
131
|
-
})));
|
|
111
|
+
}), !props.customFooter && showPagination && /*#__PURE__*/React.createElement(Pagination, paginationProps)));
|
|
132
112
|
};
|
|
133
113
|
const styles = StyleSheet.create({
|
|
134
114
|
container: {
|
|
@@ -160,6 +140,11 @@ const styles = StyleSheet.create({
|
|
|
160
140
|
flexDirection: 'row',
|
|
161
141
|
flex: 1,
|
|
162
142
|
justifyContent: 'center'
|
|
143
|
+
},
|
|
144
|
+
mirror: {
|
|
145
|
+
transform: [{
|
|
146
|
+
scaleX: -1
|
|
147
|
+
}]
|
|
163
148
|
}
|
|
164
149
|
});
|
|
165
150
|
//# sourceMappingURL=OnboardingPages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useMemo","getBrightness","lighten","darken","Animated","StyleSheet","Dimensions","Pagination","OnboardingPage","SkipButton","width","get","OnboardingPages","showPagination","showNext","props","pageWidth","currentPage_","pages","currentPage","currentBackgroundColor","backgroundColor","isLight","footerBackgroundColor","color","interpolatedBackgroundColor","length","inputRange","map","_","i","outputRange","p","scrollX","interpolate","extrapolate","paginationProps","onNext","nextPage","onSkip","onDone","showDone","showPrevious","animatedValue","dotsAnimatedValue","showSkip","numberOfScreens","skipLabel","nextLabel","previousLabel","hasSkipPosition","skipButtonPosition","doneLabel","paginationStyle","progressBarStyle","progressBarFillStyle","dotsAreTappable","mirror","paginationContainerStyle","buttonRightContainerStyle","buttonLeftContainerStyle","dotsContainerStyle","doneLabelStyle","skipLabelStyle","previousLabelStyle","nextLabelStyle","skipButtonContainerStyle","nextButtonContainerStyle","doneButtonContainerStyle","previousButtonContainerStyle","createElement","View","style","styles","container","buttonTextStyle","buttonStyle","position","label","onPress","paginationPosition","Fragment","customFooter","FlatList","ref","node","setFlatListRef","data","horizontal","pagingEnabled","showsHorizontalScrollIndicator","scrollEnabled","undefined","keyExtractor","index","toString","renderItem","item","_extends","swap","key","onScroll","onScrollBeginDrag","scrollEventThrottle","onMomentumScrollEnd","event","pageIndex","Math","round","nativeEvent","contentOffset","x","setPage","create","flex","justifyContent","alignItems","screen","pagination","flexDirection","paddingVertical","paddingHorizontal","dot","height","borderRadius","margin","dotsContainer","transform","scaleX"],"sourceRoot":"../../../src","sources":["components/OnboardingPages.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,aAAa,EAAEC,OAAO,EAAEC,MAAM,QAAQ,gBAAgB;AAC/D,SACEC,QAAQ,EACRC,UAAU,EACVC,UAAU,QA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KAAA,CAAAkF,QAAA,QACGpE,cAAc,IACbE,KAAK,CAACmE,YAAY,IAClBnE,KAAK,CAACmE,YAAY,CAAC;IAAE5C,QAAQ,EAAEvB,KAAK,CAACuB;EAAS,CAAC,CAAC,EACjD,CAACvB,KAAK,CAACmE,YAAY,IAAIrE,cAAc,iBACpCd,KAAA,CAAAuE,aAAA,CAAC/D,UAAU,EAAK6B,eAAkB,CAEpC,CAES,CAAC;AAEpB,CAAC;AAED,MAAMqC,MAAM,GAAGpE,UAAU,CAAC4G,MAAM,CAAC;EAC/BvC,SAAS,EAAE;IACTwC,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd,CAAC;EACDC,MAAM,EAAE;IACN3G,KAAK;IACLyG,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpB/F,eAAe,EAAE;EACnB,CAAC;EACDiG,UAAU,EAAE;IACVC,aAAa,EAAE,KAAK;IACpBH,UAAU,EAAE,QAAQ;IACpBI,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrB/G;EACF,CAAC;EACDgH,GAAG,EAAE;IACHC,MAAM,EAAE,EAAE;IACVjH,KAAK,EAAE,EAAE;IACTkH,YAAY,EAAE,CAAC;IACfvG,eAAe,EAAE,MAAM;IACvBwG,MAAM,EAAE;EACV,CAAC;EACDC,aAAa,EAAE;IACbP,aAAa,EAAE,KAAK;IACpBL,IAAI,EAAE,CAAC;IACPC,cAAc,EAAE;EAClB,CAAC;EACD1D,MAAM,EAAE;IACNsE,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAC5B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,12 +4,12 @@ const {
|
|
|
4
4
|
width,
|
|
5
5
|
height
|
|
6
6
|
} = Dimensions.get('window');
|
|
7
|
-
const
|
|
7
|
+
const portrait = height > width;
|
|
8
8
|
export function OnboardingPage(props) {
|
|
9
9
|
return /*#__PURE__*/React.createElement(View, {
|
|
10
10
|
style: [styles.container, {
|
|
11
11
|
width: props.width
|
|
12
|
-
}, props.containerStyle, props.swap && styles.swapStyle]
|
|
12
|
+
}, props.containerStyle, props.swap && styles.swapStyle, props.mirror && styles.mirror]
|
|
13
13
|
}, /*#__PURE__*/React.createElement(View, {
|
|
14
14
|
style: [styles.imageContainer, props.imageContainerStyle]
|
|
15
15
|
}, props.image), /*#__PURE__*/React.createElement(View, {
|
|
@@ -43,7 +43,7 @@ const styles = StyleSheet.create({
|
|
|
43
43
|
},
|
|
44
44
|
imageContainer: {
|
|
45
45
|
flex: 0,
|
|
46
|
-
paddingBottom:
|
|
46
|
+
paddingBottom: portrait ? 60 : 10,
|
|
47
47
|
alignItems: 'center',
|
|
48
48
|
width: '100%'
|
|
49
49
|
},
|
|
@@ -52,6 +52,11 @@ const styles = StyleSheet.create({
|
|
|
52
52
|
},
|
|
53
53
|
swapStyle: {
|
|
54
54
|
flexDirection: 'column-reverse'
|
|
55
|
+
},
|
|
56
|
+
mirror: {
|
|
57
|
+
transform: [{
|
|
58
|
+
scaleX: -1
|
|
59
|
+
}]
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
//# sourceMappingURL=Page.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Text","StyleSheet","Dimensions","React","width","height","get","
|
|
1
|
+
{"version":3,"names":["View","Text","StyleSheet","Dimensions","React","width","height","get","portrait","OnboardingPage","props","createElement","style","styles","container","containerStyle","swap","swapStyle","mirror","imageContainer","imageContainerStyle","image","titleContainer","titleContainerStyle","title","color","titleStyle","subtitle","subtitleStyle","create","flex","justifyContent","alignItems","flexDirection","fontSize","fontWeight","paddingBottom","textAlign","marginHorizontal","transform","scaleX"],"sourceRoot":"../../../src","sources":["components/Page.tsx"],"mappings":"AAAA,SACEA,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,UAAU,QAIL,cAAc;AACrB,OAAOC,KAAK,MAAM,O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AAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,aAAa,EAAE;EACjB,CAAC;EACDT,KAAK,EAAE;IACLU,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,aAAa,EAAE,EAAE;IACjBC,SAAS,EAAE;EACb,CAAC;EACDV,QAAQ,EAAE;IACRO,QAAQ,EAAE,EAAE;IACZG,SAAS,EAAE;EACb,CAAC;EACDlB,cAAc,EAAE;IACdW,IAAI,EAAE,CAAC;IACPM,aAAa,EAAE5B,QAAQ,GAAG,EAAE,GAAG,EAAE;IACjCwB,UAAU,EAAE,QAAQ;IACpB3B,KAAK,EAAE;EACT,CAAC;EACDiB,cAAc,EAAE;IACdgB,gBAAgB,EAAE;EACpB,CAAC;EACDrB,SAAS,EAAE;IACTgB,aAAa,EAAE;EACjB,CAAC;EACDf,MAAM,EAAE;IACNqB,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAC5B;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,28 +1,61 @@
|
|
|
1
|
-
|
|
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); }
|
|
2
|
+
import { View, Pressable, Animated, StyleSheet } from 'react-native';
|
|
2
3
|
import React from 'react';
|
|
4
|
+
import { setAlpha } from '../utils/color';
|
|
3
5
|
import { useOnboarding } from '../hooks/useOnboarding';
|
|
4
6
|
import { Button } from './button';
|
|
5
7
|
export function Pagination(props) {
|
|
6
8
|
const {
|
|
7
|
-
isDone
|
|
9
|
+
isDone,
|
|
10
|
+
currentPage,
|
|
11
|
+
progress,
|
|
12
|
+
scrollTo,
|
|
13
|
+
previousPage
|
|
8
14
|
} = useOnboarding();
|
|
9
15
|
const dots = Array.from({
|
|
10
16
|
length: props.numberOfScreens
|
|
11
17
|
}, (_, i) => i);
|
|
12
18
|
const width = props.width;
|
|
19
|
+
const showPrevious = props.showPrevious && currentPage > 0;
|
|
13
20
|
return /*#__PURE__*/React.createElement(View, {
|
|
14
21
|
style: [styles.pagination, {
|
|
15
22
|
backgroundColor: props.backgroundColor
|
|
16
23
|
}, props.paginationContainerStyle]
|
|
17
24
|
}, /*#__PURE__*/React.createElement(View, {
|
|
18
25
|
style: [styles.buttons, styles.leftButton, props.buttonLeftContainerStyle]
|
|
19
|
-
},
|
|
26
|
+
}, showPrevious && /*#__PURE__*/React.createElement(Button, {
|
|
27
|
+
onPress: () => previousPage(),
|
|
28
|
+
buttonTextStyle: props.previousLabelStyle,
|
|
29
|
+
buttonStyle: props.previousButtonContainerStyle,
|
|
30
|
+
label: props.previousLabel || 'Back'
|
|
31
|
+
}), !showPrevious && props.showSkip && !props.hasSkipPosition && /*#__PURE__*/React.createElement(Button, {
|
|
20
32
|
onPress: props.onSkip,
|
|
21
33
|
buttonTextStyle: props.skipLabelStyle,
|
|
22
34
|
buttonStyle: props.skipButtonContainerStyle,
|
|
23
35
|
label: props.skipLabel || 'Skip'
|
|
24
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
25
|
-
|
|
36
|
+
})), props.paginationStyle === 'progress' ? /*#__PURE__*/React.createElement(View, {
|
|
37
|
+
accessible: true,
|
|
38
|
+
accessibilityRole: "progressbar",
|
|
39
|
+
accessibilityValue: {
|
|
40
|
+
min: 0,
|
|
41
|
+
max: 100,
|
|
42
|
+
now: progress
|
|
43
|
+
},
|
|
44
|
+
style: [styles.progressTrack,
|
|
45
|
+
// Derive a faint track from the (background-aware) fill color so it
|
|
46
|
+
// stays visible on both light and dark pages.
|
|
47
|
+
{
|
|
48
|
+
backgroundColor: setAlpha(props.color, 0.25)
|
|
49
|
+
},
|
|
50
|
+
// Mirror the fill direction so it grows from the trailing edge.
|
|
51
|
+
props.mirror && styles.mirror, props.progressBarStyle]
|
|
52
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
53
|
+
style: [styles.progressFill, {
|
|
54
|
+
backgroundColor: props.color,
|
|
55
|
+
width: `${progress}%`
|
|
56
|
+
}, props.progressBarFillStyle]
|
|
57
|
+
})) : /*#__PURE__*/React.createElement(View, {
|
|
58
|
+
style: [styles.dotsContainer, props.mirror && styles.mirror, props.dotsContainerStyle]
|
|
26
59
|
}, dots.map((_, i) => {
|
|
27
60
|
const inputRange = [(i - 1) * width, i * width, (i + 1) * width];
|
|
28
61
|
const dotOpacity = props.animatedValue.interpolate({
|
|
@@ -30,13 +63,27 @@ export function Pagination(props) {
|
|
|
30
63
|
outputRange: [0.3, 1, 0.3],
|
|
31
64
|
extrapolate: 'clamp'
|
|
32
65
|
});
|
|
33
|
-
|
|
66
|
+
const dotProps = {
|
|
67
|
+
accessibilityRole: props.dotsAreTappable ? 'button' : 'image',
|
|
68
|
+
accessibilityLabel: `Page ${i + 1} of ${props.numberOfScreens}`,
|
|
69
|
+
accessibilityState: {
|
|
70
|
+
selected: i === currentPage
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const dot = /*#__PURE__*/React.createElement(Animated.View, {
|
|
34
74
|
key: i,
|
|
35
75
|
style: [styles.dot, {
|
|
36
76
|
backgroundColor: props.color,
|
|
37
77
|
opacity: dotOpacity
|
|
38
|
-
}
|
|
78
|
+
}]
|
|
39
79
|
});
|
|
80
|
+
return props.dotsAreTappable ? /*#__PURE__*/React.createElement(Pressable, _extends({
|
|
81
|
+
key: i,
|
|
82
|
+
onPress: () => scrollTo(i),
|
|
83
|
+
hitSlop: 8
|
|
84
|
+
}, dotProps), dot) : /*#__PURE__*/React.createElement(View, _extends({
|
|
85
|
+
key: i
|
|
86
|
+
}, dotProps), dot);
|
|
40
87
|
})), /*#__PURE__*/React.createElement(View, {
|
|
41
88
|
style: [styles.buttons, styles.rightButton, props.buttonRightContainerStyle]
|
|
42
89
|
}, !isDone && props.showNext && /*#__PURE__*/React.createElement(Button, {
|
|
@@ -69,22 +116,37 @@ const styles = StyleSheet.create({
|
|
|
69
116
|
},
|
|
70
117
|
dotsContainer: {
|
|
71
118
|
flexDirection: 'row',
|
|
72
|
-
flex:
|
|
73
|
-
justifyContent: 'center'
|
|
119
|
+
flex: 2,
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
alignItems: 'center'
|
|
122
|
+
},
|
|
123
|
+
progressTrack: {
|
|
124
|
+
flex: 2,
|
|
125
|
+
height: 6,
|
|
126
|
+
borderRadius: 3,
|
|
127
|
+
marginHorizontal: 16,
|
|
128
|
+
overflow: 'hidden'
|
|
129
|
+
},
|
|
130
|
+
progressFill: {
|
|
131
|
+
height: '100%',
|
|
132
|
+
borderRadius: 3
|
|
74
133
|
},
|
|
75
134
|
text: {
|
|
76
135
|
fontSize: 16
|
|
77
136
|
},
|
|
78
137
|
buttons: {
|
|
79
|
-
|
|
138
|
+
flex: 1
|
|
80
139
|
},
|
|
81
140
|
rightButton: {
|
|
82
|
-
alignItems: 'flex-end'
|
|
83
|
-
paddingRight: 30
|
|
141
|
+
alignItems: 'flex-end'
|
|
84
142
|
},
|
|
85
143
|
leftButton: {
|
|
86
|
-
alignItems: 'flex-start'
|
|
87
|
-
|
|
144
|
+
alignItems: 'flex-start'
|
|
145
|
+
},
|
|
146
|
+
mirror: {
|
|
147
|
+
transform: [{
|
|
148
|
+
scaleX: -1
|
|
149
|
+
}]
|
|
88
150
|
}
|
|
89
151
|
});
|
|
90
152
|
//# sourceMappingURL=Pagination.js.map
|