GithubHelp home page GithubHelp logo

jfilter / react-native-onboarding-swiper Goto Github PK

View Code? Open in Web Editor NEW
965.0 14.0 179.0 3.27 MB

πŸ›³ Delightful onboarding for your React-Native app

Home Page: https://www.npmjs.com/package/react-native-onboarding-swiper

License: Other

JavaScript 100.00%
react-native react-native-component onboarding tutorial introduction intro welcome instructions slider

react-native-onboarding-swiper's Introduction

<Onboarding /> npm npm

There are many ways to onboard people to your mobile app. But for React-Native, there is solely one component that is a) easy to setup and b) highly customizable: react-native-onboarding-swiper.

Your new users shouldn't jump in at the deep end. First give them a pleasurable, delightful introduction and only then let them explore your awesome app.

Getting everything running merely takes a minute. Try out the example running in your browser. Or check out this tutorial on YouTube.

Install

npm i react-native-onboarding-swiper
yarn add react-native-onboarding-swiper

Usage

import Onboarding from 'react-native-onboarding-swiper';

<Onboarding
  pages={[
    {
      backgroundColor: '#fff',
      image: <Image source={require('./images/circle.png')} />,
      title: 'Onboarding',
      subtitle: 'Done with React Native Onboarding Swiper',
    },
    ...
  ]}
/>

Examples

Check out the three examples files: the simple example, the example with a Call-to-Action button or the example with custom button components.

Required Properties

  • pages (required): an array of pages in the following shape:
    • backgroundColor (required): a background color. The color of the font and dots adapts to the background color.
    • image (required): a component (e.g. <Image />) to display at the top of the page.
    • title (required): a string OR a React-Native component.
    • subtitle (required): a string OR a React-Native component.

Optional Properties

Buttons

  • nextLabel (optional): a string OR a React-Native component for the Next label. Defaults to Next.
  • showNext (optional): a bool flag indicating whether the Next button is visible. Defaults to true.
  • skipLabel (optional): a string OR a React-Native component for the Skip label. Defaults to Skip.
  • showSkip (optional): a bool flag indicating whether the Skip button is visible. Defaults to true.
  • onSkip (optional): a callback that is fired if the Onboarding is skipped.
  • skipToPage (optional): when pressing skip, go to that page (e.g. skipToPage={2}). If this prop is provided, ignores onSkip.
  • onDone (optional): a callback that is fired after the Onboarding is completed.
  • showDone (optional): a bool flag indicating whether the Done checkmark button is visible. Defaults to true.

General

  • bottomBarHeight (optional): a number for the height of the bottom bar. Defaults to 60.
  • bottomBarColor (optional): backgroundColor of the bottom bar. Defaults to transparent.
  • bottomBarHighlight (optional): a bool flag indicating whether the bottom bar should be highlighted. Defaults to true.
  • controlStatusBar (optional): a bool flag indicating whether the status bar should change with the background color. Defaults to true.
  • showPagination (optional): whether to show the bottom pagination bar. Defaults to true.
  • flatlistProps (optional): additional props for the FlatList which holds all the pages.
  • transitionAnimationDuration (optional): The duration in milliseconds for the animation of the background color for the page transition. Defaults to 500.
  • allowFontScalingText (optional): Font scaling can cause troubles with high-resolution screens. You may want to disable it. Defaults to true.
  • allowFontScalingButtons (optional): Font scaling can cause troubles with high-resolution screens. You may want to disable it. Defaults to true.
  • pageIndexCallback (optional): a function that receives the page index as a parameter on page change. Example Usage

Default Page Styles

For the pages in the pages array, you can set the default styles (and override the styles set by this component).

  • containerStyles (optional): override the default container styles.
  • imageContainerStyles (optional): override the default image container styles e.g. the paddingBottom of 60.
  • titleStyles (optional): override the default title styles.
  • subTitleStyles (optional): override the default subtitle styles.

Adjust Individual Page Styles

For each page in the pages array, you can override the default page styles. An example.

  • titleStyles (optional): modify styles of a specific page's title.
  • subTitleStyles (optional): modify styles of a specific page's subtitle.

Custom Components Properties

You can also provide your own custom components for the buttons and the dots. All of them have access to a isLight prop but it's up to you what you do with it. Also checkout this example.

  • SkipButtonComponent (optional): Skip Button, gets skipLabel as prop.
  • NextButtonComponent (optional): Next Button, gets nextLabel as prop.
  • DoneButtonComponent (optional): Done Button.
  • DotComponent (optional): Dot for the pagination, gets selected as prop to indicate the active page.

Controlling the pages imperatively

You can control the Onboarding component imperatively with useRef.

const onboardingRef = useRef<Onboarding>(null);

<Onboarding
    ref={onboardingRef}
    pages={pages}
/>

onboardingRef.current.goNext()
onboardingRef.current.goToPage(2, true)
onboardingRef.current.goToPage(2, false)

Methods:

  • goNext() : Go to the next page.
  • goToPage(pageIndex, animated) : Go to the selected page.

Contributing

If you have a question, found a bug or want to propose a new feature, have a look at the issues page.

Pull requests are especially welcomed when they fix bugs or improve the code quality.

Related Work

Acknowledgements

Built upon the work by Gosha Arinich which was originally inspired by AndroidOnboarder.

License

MIT.

react-native-onboarding-swiper's People

Contributors

azizhk avatar bebax avatar dalwadani avatar darrylyoung avatar deadcoder0904 avatar dependabot[bot] avatar goshacmd avatar jfilter avatar julekgwa avatar lowewenzel avatar marcelkalveram avatar micahalcorn avatar morenoh149 avatar nattatorn-dev avatar nbolender avatar pjay79 avatar rwoverdijk avatar yawanseh avatar yek-plus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-onboarding-swiper's Issues

Allow any React component as a label

Hi again πŸ‘‹

I would like to use react-intl and it's FormattedMessage as a nextLabel but at the moment it only accepts a string as a label (well things work but there is a warning).

I see you are setting the label simply as {nextLabel} inside the NextButton so basically it can be any React component, right?

Thanks in advance!

Proposal of channel discussion

Hi, I took the liberty of creating a public chat in the discord facing React-Native. With the intention of uniting the React-native community and improving communication.

I'm creating a channel for public discussions about your project. To avoid flooding "chat" on your github. If you can support the initiative, great! Just share the link below xD

I'm adding RN only projects to this public chat service. And I commit myself to manage rooms.

here's the link
https://discord.gg/RvFM97v

Cheers.

Hide next on one screen until a user has performed an action

Hi,

We love the onboarding swiper! Halfway through our onboarding process, we prompt the user for their name. We would like to hide the skip button whilst this takes place until a user has entered the appropriate information.

Is it possible to hide the next button on a single page? We tried toggling the showNext prop but it doesn't seem to affect the layout once the onboarding sequence has been loaded.

Thanks in advance!

KR

Dynamic title and subtitle color based on background color

First of all, thank you for creating the swiper component. It works like a charm. I've been trying to adjust the color of the title and subtitle of the pages according to the isLight function, but couldn't work it out.

Current behavior

The text of the pages dynamically changes color, between black and white, based on the background color. I try to make the text custom colored, but it only worked at the Skip button component taken from the CustomButtons.js example.

const getBackgroundColor = (isLight: boolean) =>
  isLight ? customColors.cyanDark : customColors.white;

const Skip = ({ isLight, ...props }) => {
  return (
    <View style={style.skipButton}>
      <Button
        title={"Skip"}
        color={getBackgroundColor(isLight)}
        onPress={() => navigate("Main")}
      />
    </View>
  );
};

Nice to have

An option where you can enter a custom 'dark' and 'light' color for the title and subtitle.

For now

What would be best practise to change the colors dynamicly?

pagination position

Can We Change the pagination position?
Like now it's in the center I want it in the left corner.

Doesn't auto resize on orientation change

Hi,

I'm using react-native-onboarding-swiper v ^0.3.1 in my Expo CRNA app and when I test on my iPad on landscape the pages are stitched together with the width of the device in portrait mode. This means it works well in portrait mode, but on landscape it's unaligned.

img_0070
img_0071

Any advice how I can adjust/fix this?

Integrate next button into a page?

Hi, a main part of my app experience is entering info into a couple of Inputs and hitting a submit button. I am showing the UI in one of the pages, but I cannot figure out if I can use the submit button to go to the next screen.

Is that possible? Thanks!

Go to next slide programmatically

Hello,
I'm developing a wizard form using this awesome lib.
I'm using the image component to put a TextInput and works well. When someone press the next button in the keyboard, needs to be transported to the next slide, so, here is my question:

ΒΏHow can I go to the next slide programmatically?
What function I have to call to be transported to the next slide of this onboarding

Thanks!

Custom Done Button breaks it

I used this

DoneButtonComponent={<Animated.View><Button text={'Get Started'}/></Animated.View>}

Upon swiping to the page that contains the DoneButton, I get red error screen:
`Invariant Violation: element type is invalid: expected a string.

Add Eula example

Hello, was wondering if it was possible to power a Eula step with this library. It would be nice to show how to display a typical Eula and require the user to scroll to the bottom before the accept button is tappable.

Possible to add new component to replace bottom bar?

I am looking to have an exact layout like in the attached picture:
example

Is this library sufficient to achieve that exact design?

So there is a bold Header, a picture in the middle, then a paragraph and the normal skip + dots + next buttons.
In the last screen, the bottom bar is replaced completely with a Login and Signup button.

I was wondering if its possible to achieve this with this library? I'm not sure if the current props allow for this to happen.

Thanks!

View.propTypes.style is crashing in release

undefined is not an object (evaluating 's.View.propTypes.style')

com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError ExceptionsManagerModule.java:56
com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException ExceptionsManagerModule.java:40
java.lang.reflect.Method.invoke Method.java
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:363
com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:162
com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java
android.os.Handler.handleCallback Handler.java:815
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage MessageQueueThreadHandler.java:31
android.os.Looper.loop Looper.java:194
com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run MessageQueueThreadImpl.java:194

    java.lang.Thread.run Thread.java:818

The issue is from the SymbolButton file where you still use the deprecated View.propTypes stuff.

ie. https://github.com/zbtang/React-Native-ViewPager/pull/90/files

calls 'onDone' right away

I am testing the 'onDone' property by logging to console: console.log('Finished Onboarding'). I realized when the Onboard component renders, it logs to the console right away and does not wait for me to click the Done button. How do I fix this so that it will log to console after I've clicked done?

Elements Order

Is there a way to show the title first, then the image, then the subtitle? Thank you!

Gradient background applicable?

Hi, first of all, Amazing component, great job!

I want to know if is possible to set the backgroundColor with gradient as LinearGradient?

Persistance

Hey there, thank you for your wonderful work.
Is there any mechanism currently in place that let's the user skip on-boarding after the first use? Or will on-boarding render every time the app is opened?

Thanks!

Bottom bar text colour ?

Hi,

First of all great component, I'm using it in my shopping list app and it looks incredible. However, I have one small issue, the text colour.

How can I change the text colour?

Transition to the next screen super slow

I tried implementing this in both a current project and a fresh react-native one, but the transition to the next screen is still slow.

I am using version 1.1.0.

It is like the gif examples in your README, but 5-10x slower. What might be the issue?

EDIT: I'm using iPhone X for this. I have noticed that on iPhone 7 or models before iPhone X , the library works perfectly.

Programmatically control paging

Hey, cool module. I've been playing with it a bit and it does work well, when used the way it was intended to.

But I don't want to use it the way it was intended to, because I'm a rebel. :D

I want to not show the pagination component, and handle that myself. Is there any way to accomplish that? I checked out the code but it doesn't look like it.

Runnable example

It would be nice to be able to run the example straight away, without creating a new project, copying code, manually installing dependencies. Could you do that please?

[FEATURE] Background animation timing

Hi,

Thanks for this library ! it is great !
I'd like to suggest a new feature : Allow developer to decide which timingAnimation is used for the screen Transition.

Cant call setState, forceUpdate on an unmounted Component

Using with create-react-native-app

What I'm doing is onDone and onSkip navigating to another screen:

import React from 'react';
import { Image } from 'react-native'
import Onboarding from 'react-native-onboarding-swiper';

const OnboardingView = ({ navigation, ...props }) =>
  <Onboarding
    pages={[
      {
        backgroundColor: '#fff',
        image: <Image source={require('./circle.png')} />,
        title: 'Onboarding',
        subtitle: 'Done with React Native Onboarding Swiper',
      },
      {
        backgroundColor: '#fe6e58',
        image: <Image source={require('./square.png')} />,
        title: 'The Title',
        subtitle: 'This is the subtitle that sumplements the title.',
      },
      {
        backgroundColor: '#999',
        image: <Image source={require('./triangle.png')} />,
        title: 'Triangle',
        subtitle: "Beautiful, isn't it?",
      },
    ]}
    onDone={() => navigation.navigate('Terms')}
    onSkip={() => navigation.navigate('Terms')}
  />

export default OnboardingView

screen shot 2018-04-30 at 3 18 54 pm

Move bottom bar to the top of page

Just wondering if there is a way to move the bottom navigation including the skip and next to the top of the page? I can't seem to find any container for it. Also a way to swap around the skip and next button?

DotComponent Prop Not Working

When I try to pass a custom dot component to the onboarding component nothing changes. The default dots stay the same. All the other props (SkipButton, NextButton, etc) work but not the DotComponent. I've tried using the square const from the example but still no change.

StatusBar being changed even when controlStatusBar is set to null

Hello,

Nice library (firstly).

A bug when I set the controlStatusBar bool to false, it still makes the statusbar revert to default when the Onboarding screen is closed. This should not happen.

Can be easily fixed by updating the code in the Pagination component.

Cheers

Get current page number

Hi,

I would like to ask permissions like location,camera, etc... on the different onboarding steps. Is it possible to retrieve the current page number as a callback when going to the next screen?

Add Current Page Property

For tracking purposes, I would like to know on which page the user is on when they click the skip button. Can you make the currentPage property available somehow?

I've tried achieving this information by overriding the onViewableItemsChanged FlatList property but that causes my app to run out of memory.

Do you have any better way of achieving this?

Export TextButton & SymbolButton

I don't like the way the done button works (would rather use the word "Done" without any fade animation). I simply want to mimic the behavior of the "Skip" button for when the user's done.

The DoneButtonComponent prop is perfect for allowing this behavior, but it feels like I'm reinventing the wheel to mimic the existing text button behavior. I'm pretty much just copying out the TextButton and NextButton code, which also means that I'll need to be aware of changes to those internal components whenever I upgrade the dependency in my app.

I'd like to propose exporting those components such that users can easily create buttons matching the style embedded in this package. Thanks!

Display horizontal scrolling

I want to disable horizontal scrolling until a certain action has been completed. Maybe a prop to disable horizontal scrolling that also hides the next button will be helpful.

Headers style

How to change title and subtitle styles?(ex: fontSizes, colors) Couldn't find any prop for that in the doc.

RTL issue on iOS

This lib is awesome and well works with android when I18nManager.ForceRTL(true) is called, bot not with iOS!

On iOS it starts on the last page and also swipe gesture is reversed!
Actually if you see carefully you can see its coming up by the first page and immediately goes to the last one.

Page flex properties

Currently the page children (image, title, subtitle) seem to be justified to center on the screen. Is there any way to align them to the top of the page?

imageContainerStyles Issues.

(imageContainerStyles) property is not overrides. How do i change the margin or padding Bottom to different value?

Weird page rendering

There's some weird rendering between pages. This happens when i swipe to the next page. The last page does have subtitle which is a bit longer, but i assumed it would just word wrap. See images below. Any help would be appreciated.

rendering

rendering1

Onboarding in Android Device is skipped to the end when KeyPress

Hello

I'm using this library to implement an onboarding mixed with a wizard form.
The first page is for presentation, and the others are to ask things about the user: the name, phone, email.

I'm using the parameter image to insert a <TextInput and works fine in iOS

The problem is in Android, when I change the value of the TextInput the onboarding go directly to the last page.

ezgif-4-eb19e37a8c7f

Note: I know the image param is for <Image :( but works with other component

Adding events with each page view

Is it possible to call a function with each page view in order to view traffic through the flow of the onboarding?

I'm using Amplitude with Expo, if that helps, and just need to log events with when the user navigates between pages. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.