diff --git a/.idea/react-native-simple-onboarding.iml b/.idea/react-native-simple-onboarding.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/react-native-simple-onboarding.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/a/7/a77b15c0d64cf6111e025645e562faf8ccabb9d7 b/.idea/sonarlint/issuestore/a/7/a77b15c0d64cf6111e025645e562faf8ccabb9d7 new file mode 100644 index 0000000..5fefbc5 --- /dev/null +++ b/.idea/sonarlint/issuestore/a/7/a77b15c0d64cf6111e025645e562faf8ccabb9d7 @@ -0,0 +1,2 @@ + +Qjavascript:S1128"0Remove this unused import of 'TouchableOpacity'.(ä彇üÿÿÿÿ \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/a/9/a90c3748aa79c6a0a3509686e634cae5084991d0 b/.idea/sonarlint/issuestore/a/9/a90c3748aa79c6a0a3509686e634cae5084991d0 new file mode 100644 index 0000000..c718be8 --- /dev/null +++ b/.idea/sonarlint/issuestore/a/9/a90c3748aa79c6a0a3509686e634cae5084991d0 @@ -0,0 +1,2 @@ + +Ljavascript:S1128"0Remove this unused import of 'TouchableOpacity'.(“ \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/c/a/ca67a0c9dcc2af5abc7c609231f2db528d528d14 b/.idea/sonarlint/issuestore/c/a/ca67a0c9dcc2af5abc7c609231f2db528d528d14 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000..8a3d80f --- /dev/null +++ b/.idea/sonarlint/issuestore/index.pb @@ -0,0 +1,7 @@ + +8 +index.js,a/7/a77b15c0d64cf6111e025645e562faf8ccabb9d7 +G +components/Paginator.js,a/9/a90c3748aa79c6a0a3509686e634cae5084991d0 +F +components/PageData.js,c/a/ca67a0c9dcc2af5abc7c609231f2db528d528d14 \ No newline at end of file diff --git a/components/PageData.js b/components/PageData.js index 2e6d13c..819a5a0 100644 --- a/components/PageData.js +++ b/components/PageData.js @@ -15,7 +15,7 @@ const PageContent = ({ children }) => ( ); -const PageData = ({ isLight, image, title, subtitle, titleStyles, subtitleStyles, ...rest }) => ( +const PageData = ({ isLight, image, title, subtitle, titleStyles, subtitleStyles, renderFooter, ...rest }) => ( @@ -27,6 +27,9 @@ const PageData = ({ isLight, image, title, subtitle, titleStyles, subtitleStyles {subtitle} + { + renderFooter || null + } ); @@ -55,6 +58,7 @@ const styles = { subtitle: { textAlign: 'center', fontSize: 16, + marginHorizontal: 16, color: 'rgba(255, 255, 255, 0.7)', }, subtitleLight: { diff --git a/components/Paginator.js b/components/Paginator.js index f4c2971..d5dc07a 100644 --- a/components/Paginator.js +++ b/components/Paginator.js @@ -8,9 +8,9 @@ const getDefaultStyle = (isLight) => ({ color: isLight ? 'rgba(0, 0, 0, 0.8)' : '#fff', }); -const SkipButton = ({ isLight, ...props }) => ( +const SkipButton = ({ isLight, skipText, ...props }) => ( - Skip + {skipText || 'Skip'} ); @@ -26,11 +26,11 @@ const DoneButton = ({ isLight, size, ...props }) => ( ); const BUTTON_SIZE = 40; -const Paginator = ({ isLight, overlay, showSkip, showNext, showDone, pages, currentPage, onEnd, onNext }) => ( +const Paginator = ({ isLight, overlay, showSkip, showNext, showDone, pages, currentPage, onEnd, onNext, skipText }) => ( {showSkip && currentPage + 1 !== pages ? - : + : null } diff --git a/index.js b/index.js index 43cfab4..b850ccb 100644 --- a/index.js +++ b/index.js @@ -21,8 +21,14 @@ export default class Onboarding extends Component { const page = Math.round(pageFraction); const isLastPage = this.props.pages.length === page + 1; if (isLastPage && pageFraction - page > 0.3) { + if (this.props.onScroll) { + this.props.onScroll(); + } this.props.onEnd(); } else { + if (this.props.onScroll) { + this.props.onScroll(); + } this.setState({ currentPage: page }); } }; @@ -42,7 +48,7 @@ export default class Onboarding extends Component { render() { const { width, height } = Dimensions.get('window'); - const { pages, bottomOverlay, showSkip, showNext, showDone } = this.props; + const { pages, bottomOverlay, showSkip, showNext, showDone, skipText } = this.props; const currentPage = pages[this.state.currentPage] || pages[0]; const { backgroundColor } = currentPage; const isLight = tinycolor(backgroundColor).getBrightness() > 180; @@ -57,7 +63,7 @@ export default class Onboarding extends Component { onScroll={this.updatePosition} scrollEventThrottle={100} > - {pages.map(({ image, title, subtitle, titleStyles, subtitleStyles }, idx) => ( + {pages.map(({ image, title, subtitle, titleStyles, subtitleStyles, renderFooter }, idx) => ( ))}