Code Monkey home page Code Monkey logo

react-native-app-intro's Introduction

react-native-app-intro

react-native-app-intro is a react native component implementing a parallax effect welcome page using base on react-native-swiper , similar to the one found in Google's app like Sheet, Drive, Docs...

react-native-app-intro Screen Capture

Example code

Support ios、android

Designed by Freepik

Installation

$ npm i react-native-app-intro --save

Basic Usage

You can use pageArray quick generation your app intro with parallax effect. With the basic usage, the Android status bar will be updated to match your slide background color.

import React, { Component } from 'react';
import { AppRegistry, Alert } from 'react-native';
import AppIntro from 'react-native-app-intro';

class Example extends Component {
  onSkipBtnHandle = (index) => {
    Alert.alert('Skip');
    console.log(index);
  }
  doneBtnHandle = () => {
    Alert.alert('Done');
  }
  nextBtnHandle = (index) => {
    Alert.alert('Next');
    console.log(index);
  }
  onSlideChangeHandle = (index, total) => {
    console.log(index, total);
  }
  render() {
    const pageArray = [{
      title: 'Page 1',
      description: 'Description 1',
      img: 'https://goo.gl/Bnc3XP',
      imgStyle: {
        height: 80 * 2.5,
        width: 109 * 2.5,
      },
      backgroundColor: '#fa931d',
      fontColor: '#fff',
      level: 10,
    }, {
      title: 'Page 2',
      description: 'Description 2',
      img: require('../assets/some_image.png'),
      imgStyle: {
        height: 93 * 2.5,
        width: 103 * 2.5,
      },
      backgroundColor: '#a4b602',
      fontColor: '#fff',
      level: 10,
    }];
    return (
      <AppIntro
        onNextBtnClick={this.nextBtnHandle}
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
        pageArray={pageArray}
      />
    );
  }
}

AppRegistry.registerComponent('Example', () => Example);

Advanced Usage

If you need customized page like my Example, you can pass in View component into AppIntro component and set level. Remember any need use parallax effect component, Need to be <View level={10}></View> inside.

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';
import AppIntro from 'react-native-app-intro';

const styles = StyleSheet.create({
  slide: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#9DD6EB',
    padding: 15,
  },
  text: {
    color: '#fff',
    fontSize: 30,
    fontWeight: 'bold',
  },
});

class Example extends Component {

  render() {
    return (
      <AppIntro>
        <View style={[styles.slide,{ backgroundColor: '#fa931d' }]}>
          <View level={10}><Text style={styles.text}>Page 1</Text></View>
          <View level={15}><Text style={styles.text}>Page 1</Text></View>
          <View level={8}><Text style={styles.text}>Page 1</Text></View>
        </View>
        <View style={[styles.slide, { backgroundColor: '#a4b602' }]}>
          <View level={-10}><Text style={styles.text}>Page 2</Text></View>
          <View level={5}><Text style={styles.text}>Page 2</Text></View>
          <View level={20}><Text style={styles.text}>Page 2</Text></View>
        </View>
        <View style={[styles.slide,{ backgroundColor: '#fa931d' }]}>
          <View level={8}><Text style={styles.text}>Page 3</Text></View>
          <View level={0}><Text style={styles.text}>Page 3</Text></View>
          <View level={-10}><Text style={styles.text}>Page 3</Text></View>
        </View>
        <View style={[styles.slide, { backgroundColor: '#a4b602' }]}>
          <View level={5}><Text style={styles.text}>Page 4</Text></View>
          <View level={10}><Text style={styles.text}>Page 4</Text></View>
          <View level={15}><Text style={styles.text}>Page 4</Text></View>
        </View>
      </AppIntro>
    );
  }
}
AppRegistry.registerComponent('Example', () => Example);

And in Android, image inside view component, view need width、height.

<View style={{
  position: 'absolute',
  top: 80,
  left: 30,
  width: windows.width,
  height: windows.height,
}} level={20}
>
  <Image style={{ width: 115, height: 70 }} source={require('./img/1/c2.png')} />
</View>

Properties

Prop PropType Default Value Description
dotColor string 'rgba(255,255,255,0.3)' Bottom of the page dot color
activeDotColor string '#fff' Active page index dot color
rightTextColor string '#fff' The bottom right Text Done、> color
leftTextColor string '#fff' The bottom left Text Skip color
onSlideChange (index, total) => {} function to call when the pages change
onSkipBtnClick (index) => {} function to call when the Skip button click
onDoneBtnClick func function to call when the Done button click
onNextBtnClick (index) => {} function to call when the Next '>' button click
doneBtnLabel string、Text element Done The bottom right custom Text label
skipBtnLabel string、Text element Skip The bottom left custom Text label
nextBtnLabel string、Text element The bottom left custom Text label
pageArray array In the basic usage, you can input object array to render basic view example: [[{title: 'Page 1', description: 'Description 1', img: 'https://goo.gl/uwzs0C', imgStyle: {height: 80 * 2.5, width: 109 * 2.5 }, backgroundColor: '#fa931d', fontColor: '#fff', level: 10 }] , level is parallax effect level ,if you use pageArray you can't use custom view
defaultIndex number 0 number of the index of the initial index
showSkipButton bool true a boolean defining if we should render the skip button
showDoneButton bool true a boolean that defines if we should render the done button
showDots bool true a boolean that defines if we should render the bottom dots
Children View Properties
Prop PropType Default Value Description
level number parallax effect level

react-native-app-intro's People

Contributors

auser avatar bilalbudhani avatar doomsower avatar el-lsan avatar fuyaode avatar jonoirwinrsa avatar joshuapinter avatar lucasfeliciano avatar paulohenriquesg avatar phoenixbox avatar sandromachado 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  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

react-native-app-intro's Issues

Warnings

I've keep receiving those warnings:
Warning? Failed prop type: Invalid props.style key "font-family":"montserrat_light" ....
That style is only applied to an <Text /> inside Appintro's slide.

Stagger when using custom view

Hi, when using custom view injected in AppIntro component I get a serious stagger on slide change but only on real Android devices. It works normally in the Android emulator.

To be precise, if I touch screen and move left or right slightly there is no stagger, only if I quick swipe and it goes to next slide.
Strangely, the problem does not happen in transition if tapping 'next' button

Go to the next page when touching Skip

Hello,

Thanks for this great library!
I was wondering if it is possible, by any ways, to slide on the next page when touching the button "Skip"

Thanks for your help !

Slides get stuck when ">" arrow is pressed too quickly

The slides appear to get stuck when the right arrow (">") is pressed too quickly in succession. At normal clicking speed the "Done" button will appear which will then trigger the end of the slide, however when pressing very quickly it will never show the Done button and simply try to keep advancing through the slides even though there are none. This then causes a strange behavior where the scrollview might get stuck past the last slide and the Done button never appears.

Suggested solution:
When the right arrow (">") button is pressed but the internal state shows that the current index is greater than the current visible slide, then trigger the Done button onPress instead.

Labels could be more than Strings

It would be nice if we could pass actual components as params to skipBtnLabel and doneBtnLabel. Currently these take only strings which means we cannot customise them properly. For example if i wanted the font weight to be different, I should be apple to say

skipBtnLabel={<Text style={{fontWeight: 'normal'}}>Test</Text>}>

This does in fact work already. As shown in the bellow example:

simulator screen shot 22 jun 2016 10 42 04

As you can see the font weight has been modified... However a warning message is shown which i would rather not Force Disable.

simulator screen shot 22 jun 2016 10 42 00

Currently many values of the string are hardcoded, yes we can change the colour using another prop. Yet i feel it would be nice if we had more control.

Crash on Swiper onMomentumScrollEnd()

TypeError: undefined is not an object (evaluating 'this.props.pageArray[state.index].backgroundColor')

React native 0.38
react-native-app-intro 1.1.5
Platform android 7.0 Huawei

I found this error in my Sentry Error list.
The problem is on this line:

StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3), false);

I think for some reasons the state in swiper is null. I have also noticed that the swiper fork is behind master by many commits, so I am not sure if this is actually a small bug that has been fixed already in the swiper master branch.
For example, just reading the commit I can see possible problems with the scroller and state: leecade/react-native-swiper@d4065d7

onSlideChange triggers when swipe animation starts

onSlideChange callback is called when the swipe animation start.

So it is called even when the page doesn't change.

With that, when the user start to swiping it will be called and when he release the swipe without changing the screen it will be triggered again in the same page.

I'm trying to fix it but I dont see where do you keep trace of the actual index in your component

Update

I fixed it wrapping in a component like this:

import React, { Component } from 'react';
import AppIntro from 'react-native-app-intro';

export class TourScreen extends Component {
  constructor(props) {
    super(props);
    this.onSkipBtnHandle = this.onSkipBtnHandle.bind(this);
    this.doneBtnHandle = this.doneBtnHandle.bind(this);
    this.nextBtnHendle = this.nextBtnHendle.bind(this);
    this.onSlideChangeHandle = this.onSlideChangeHandle.bind(this);
    this.index = 0;
  }
  onSkipBtnHandle() {
    console.log('Skip');
  }
  doneBtnHandle() {
    console.log('Done');
  }
  nextBtnHendle() {
    console.log('Next');
  }
  onSlideChangeHandle(i) {
    if (i !== this.index) {
      console.log('change:', i);
      this.index = i;
    }
  }

  render() {
    const pageArray = [{
      title: 'Page 1',
      description: 'Description 1',
      img: 'https://goo.gl/Bnc3XP',
      imgStyle: {
        height: 80 * 2.5,
        width: 109 * 2.5,
      },
      backgroundColor: '#fa931d',
      fontColor: '#fff',
      level: 10,
    }, {
      title: 'Page 2',
      description: 'Description 2',
      img: 'https://goo.gl/GPO6JB',
      imgStyle: {
        height: 93 * 2.5,
        width: 103 * 2.5,
      },
      backgroundColor: '#a4b602',
      fontColor: '#fff',
      level: 10,
    }];
    return (
      <AppIntro
        onNextBtnClick={this.nextBtnHendle}
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
        pageArray={pageArray}
      />
    );
  }
}

No dots, skip or done buttons in both examples

Hi.
I tried both the Basic and Advanced examples but the skip, next and done buttons don't show, as well as the dots. I can only swipe (both Android and iOS).
Am I missing something?
I'm on RN 0.33.

onPress doesn't work

i added a button from native-base and the onPress callback doesn't seem to work.

<AppIntro> <View style={[styles.slide, { backgroundColor: '#fa931d' }]}> <View style={{ position: 'absolute', top: 50, left: 30, width, height }} level={10} > <Image style={{ width: 250, height: 160 }} source={camera} /> </View> <View level={-50}><Text style={styles.text}>some text</Text></View> <View style={{ top: 5 }} level={10}> <Button success onPress={() => Alert.alert('clicked')}>button</Button> </View> </View> </AppIntro> ); }

EDIT: richard-sim managed to fix the issue.

Good work!

Android : Page dont change but dots change

I have tried using pageArray for views and it works fine but the other way dont work work in android. Both works fine with ios. Am i the only one getting this issue?

dots position

i want set the position of dots by myself,but i couldn't find the prop,how can i do it?thank you.

Change Component State reset index

Changing state this.setState reset index to 0

class Screen extends Component {
    constructor() {
        super();

        this.state = {
            showButt : false
        };
    }

    _onSlideChange(slide) {
        this.setState((prevState, props) => ({
            showButt: slide === 2
        }));
    }

    _SkipWT() {

    }

    render() {
        return (
            <View style={styles.mainContainer}>
                <StatusBar/>
                <Header fixedHeader wtSkip={this._SkipWT.bind(this)}/>
                <View style={styles.wtContainer}>
                    <AppIntro showSkipButton={false} showDoneButton={false} showDots={true}
                              activeDotColor={Colors.primary} dotColor={"#58595B"}
                              onSlideChange={this._onSlideChange.bind(this)}>
                        <View style={styles.slide}>
                            <View style={styles.slideImage} level={1}>
                                <Image source={require("../Resources/wt-1.png")}/>
                            </View>
                            <View style={styles.slideText} level={15}>
                                <Text style={styles.text}>Browse and place your order</Text>
                            </View>
                        </View>

                        <View style={styles.slide}>
                            <View style={styles.slideImage} level={1}>
                                <Image source={require("../Resources/wt-2.png")}/>
                            </View>
                            <View style={styles.slideText} level={15}>
                                <Text style={styles.text}>We will send it to the restaurant</Text>
                            </View>
                        </View>

                        <View style={styles.slide}>
                            <View style={styles.slideImage} level={1}>
                                <Image source={require("../Resources/wt-3.png")}/>
                            </View>
                            <View style={styles.slideText} level={15}>
                                <Text style={styles.text}>Your food arrives...</Text>
                            </View>
                        </View>
                    </AppIntro>

                    <Button style={[styles.startButt, {bottom : this.state.showButt ? 80 : -Config.buttonHeight}]}>
                        <View style={styles.startButtContainer}>
                            <Text style={styles.startButtText}>Let’s get started!</Text>
                        </View>
                    </Button>
                </View>
            </View>
        );
    }
}

screen recording 2017-04-13 at 09 37 pm

Done button is not working on iOS

Done button doesn't register any TouchableOpacity event like the Skip button on iOS.
On Android it works fine.
While looking deeper inside the library code it looks like TouchableOpacity is missing when the next button turns into Done button.

return (
    <View style={styles.btnContainer}>
      <Animated.View style={[styles.full, { height: 0 }, {
        opacity: doneFadeOpacity,
        transform: [{
          translateX: skipFadeOpacity.interpolate({
            inputRange: [0, 1],
            outputRange: [0, 20],
          }),
        }],
      }]}
      >
        <View style={styles.full}>
          <Text style={[styles.controllText, {
            color: rightTextColor, paddingRight: 30,
          }]}>
            {doneBtnLabel}
          </Text>
        </View>
      </Animated.View>
      <Animated.View style={[styles.full, { height: 0 }, { opacity: nextOpacity }]}>
        <TouchableOpacity style={styles.full}
          onPress={ isDoneBtnShow ? onDoneBtnClick : onNextBtnClick}>
         <Text style={[styles.nextButtonText, { color: rightTextColor }]}>
          {nextBtnLabel}
        </Text>
        </TouchableOpacity>
      </Animated.View>
    </View>
  )

view cannot response touchableopacity onpress

hello,i have a problem here:
<View style={styles.info}> <View level={-5}><Text style={styles.title}>title</Text></View> <View level={-15}><Text style={styles.description}>description</Text></View> <View level={-10} style={{marginTop:10,height: 50,}} > <TouchableOpacity activeOpacity={0.9} onPress={() => {Alert.alert('Next');}}> <Image style={{ width: 45 * 2.5, height: 13 * 2.5 }} source={require('../ui-module/img/[email protected]')} /> </TouchableOpacity> </View> </View>

when i add a TouchableOpacity in a view of a page in the appintro, the onPress() didnot fire, is it a bug
or something ? any advice?

Remove or Style Dots

Hi There,

I am trying to remove the dots at the bottom of the screen or even style it. is that doable ?

app-into-dots

Thanks

Level Swipe doesn´t work if Dev mode: off

As far as my Dev mode is set to on the different level at a swipe work perfect. As far as I set Dev mode: off its complete static at the swipe. (Using: Samsung Galaxy Note Edge 2 - Android: 6.0.1) (React-Native: 0.23.1)

Does Not Seem to Be Compatible with Navigator

I use navigator for the rest of my app. Does not integrate well with navigator. Perhaps if I kept your intro separate from my app? But not sure how to do that because it was unclear whether I need to create the AppIntro.js file manually, or import it from node_modules. More installation instructions would be very helpful.

Also, you instantiate or import AppIntro twice, once as an exported extends class, and then again as a node module. This has to be why it's breaking for and why I can't integrate it. Please help. They should not be using the same name space. Please clarify.

TypeError: Cannot assign to read only property 'onScroll' of object '#<Object>'(…)

TypeError: Cannot assign to read only property 'onScroll' of object '#'(…)

for(let prop in props) {
// if(~scrollResponders.indexOf(prop)
if(typeof props[prop] === 'function'
&& prop !== 'onMomentumScrollEnd'
&& prop !== 'renderPagination'
&& prop !== 'onScrollBeginDrag'
&& prop !== 'onScroll'
) {
let originResponder = props[prop]
props[prop] = (e) => originResponder(e, this.state, this)
}
}

btn and dot style

skip btn and dot are on the bottom , cant make them to the top , need alter the code by hand

Ignore /build from npm

Hi,

Currently /Example/ios/build/ & /Example/android/app/build/ took quite a lot of space whenever we run npm install this package.
Possible to ignore this from the npm?

Error with Android pagination

There is an error when rendering pagination on Android only. I've tracked it down to the DoneButton <Text> rendering:

This causes the dots to rerender (props changed) which causes the pagination to return to the previous page:

    <View style={[styles.btnContainer, { height: 0, paddingBottom: 5 }]}>
      <TouchableOpacity style={styles.full}
        onPress={ isDoneBtnShow ? onDoneBtnClick : onNextBtnClick}
      >
       <Text style={[styles.nextButtonText, { color: rightTextColor }]}>
         {isDoneBtnShow ? doneBtnLabel : nextBtnLabel}
       </Text>
      </TouchableOpacity>
    </View>

This, on the other hand does not cause a rerender or the bug:

    <View style={[styles.btnContainer, { height: 0, paddingBottom: 5 }]}>
      <TouchableOpacity style={styles.full}
        onPress={ isDoneBtnShow ? onDoneBtnClick : onNextBtnClick}
      >
       <Text style={[styles.nextButtonText, { color: rightTextColor }]}>
         {doneBtnLabel}
       </Text>
      </TouchableOpacity>
    </View>

The difference is the ternary operator in the <Text /> element. Could use some thoughts on how to approach this bug. Am I the only one seeing this?

styling bugs

Currently I'm facing following bugs:

  • on IOS customizing leftTextColor does not work and it follows rightTextColor
  • padding \ margin is behaving weird

here's my component's code:

'use strict';

import React, { Component } from 'react';
import AppIntro from 'react-native-app-intro'

import {
    StyleSheet,
    TextInput,
    View,
    Image,
    Text,
    Dimensions,
} from 'react-native';

class AppPreview extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <AppIntro dotColor='#eeeef0' activeDotColor='#c7c7cd' rightTextColor='red' leftTextColor='blue'>
                <View style={[styles.slide]}>
                    <View level={10} style={[styles.header]}>
                        <View style={[styles.imageContainer]}>
                            <Image
                                resizeMode="stretch"
                                style={[styles.image]}
                                source={{uri:'https://dummyimage.com/200x300/000/fff.png'}}/>
                        </View>
                    </View>
                    <View  level={10} style={[styles.footer]}>
                        <Text style={styles.headline}>Title 1</Text>
                        <Text style={styles.description}>Description 1</Text>
                    </View>
                </View>
                <View style={[styles.slide]}>
                    <View level={10} style={[styles.header]}>
                        <View style={[styles.imageContainer]}>
                            <Image
                                resizeMode="stretch"
                                style={[styles.image]}
                                source={{uri:'https://dummyimage.com/200x300/000/fff.png'}}/>
                        </View>
                    </View>
                    <View  level={10} style={[styles.footer]}>
                        <Text style={styles.headline}>Title 2</Text>
                        <Text style={styles.description}>Description 1</Text>
                    </View>
                </View>
            </AppIntro>
        );
    }
}

const deviceWidth = Dimensions.get('window').width;
const deviceHeight = Dimensions.get('window').height;

const styles = StyleSheet.create({
    slide: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    header: {
        flex: 2,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#f5f5f5',
        alignSelf: 'stretch',
    },
    footer: {
        flex: 1,
        backgroundColor: 'white',
        alignSelf: 'stretch',
    },
    imageContainer: {
        flex: 1,
        marginTop: 45,
        marginRight: 42,
        marginLeft: 42,
    },
    image: {
        flex: 1,
        width: deviceWidth - 82,
        height: deviceHeight / 2,

    },
    headline: {
        textAlign: 'center',
        fontSize: 30,
        paddingTop:30,
        borderWidth: 2,
        borderColor: 'black',

    },
    description: {
        textAlign: 'center',
        fontSize: 18,
        paddingTop:20,
        borderWidth: 2,
        borderColor: 'green',
    },
});

export default AppPreview;

Here's the screenshot of what I get:

image

Plus following warning as well:

image

But here's what I'm expecting to get (of course with the dots and skip button, ect. ) :

image

in the above screen shot basically I just used one of the view wrapper which I have inside my AppIntro which means:

<View style={[styles.slide]}>
    <View level={10} style={[styles.header]}>
        <View style={[styles.imageContainer]}>
            <Image
                resizeMode="stretch"
                style={[styles.image]}
                source={{uri:'https://dummyimage.com/200x300/000/fff.png'}}/>
        </View>
    </View>
    <View  level={10} style={[styles.footer]}>
        <Text style={styles.headline}>Title 1</Text>
        <Text style={styles.description}>Description 1</Text>
    </View>
</View>

Recommend how modify example to work in landscape?

You made a _beautiful_ example! Very nice work!

Can you recommend a way to make it resize to fill landscape orientation?

It currently displays whitespace on right-side. Sorry I cannot figure out where or what to change the style to?

sep-15-2016 08-50-01

onSkipBtnClick receiving arguments

Since we don't have the need to track the index into the component state would be nice to pass the same arguments to the other callbacks.

The motivation behind it is that I need to send an analytics event when the user skip the tour with the page that he is. To know how far the user goes.

Updating the statusbar color resets the pagination indicator

Hi @FuYaoDe,

I am trying to update the status bar color (in Android) to match background of each page of the onboard.

My render function looks like this:

  render() {
    return (
      <View>
      <StatusBar
        backgroundColor={shadeStatusBarColor(this.state.statusBarColor, -0.3)}
      />
      <AppIntro
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
        pageArray={this.state.pageArray}
      />
      </View>
    );
  }

On the slide change callback I have this:

onSlideChangeHandle = (index, total) => {
    this.setState({ statusBarColor: this.state.pageArray[index].backgroundColor, currentPage: index });
  }

Doing this, the color of the statusbar changes, but the pagination is reset to the first position.

baconmhc19qsandromachado09262016140353

I also tried to do this change directly in the library (I want to make a PR to add this feature to the library also), but the behaviour is the same, the page position is not persisted.

Do you have any tips to fix this?

Thanks for the great work.

Ask - Route to other pages when Done button is clicked

So I made a sample code with this component. At the end of page ( Done Button when it's clicked ), I want to routes to my other pages ( main.js ). How can I do that?

I tried this but it doesn't work.
Here's my index.ios.js:

import React, { Component } from 'react';
import {
  AppRegistry,
  Alert,
  View,
  Text, 
} from 'react-native';
import AppIntro from 'react-native-app-intro';
import Main from './src/main';

const routes = {
  Main
}

class introApp extends Component {
  onSkipBtnHandle = (index) => {
    Alert.alert('Skip');
    console.log(index);
  }

  doneBtnHandle = () => {
    return (
      <Main />
    )
  }

  nextBtnHandle = (index) => {
    Alert.alert('Next');
    console.log(index);
  }
  onSlideChangeHandle = (index, total) => {
    console.log(index, total);
  }
  render() {
    const pageArray = [{
      title: 'Page 1',
      description: 'Description 1',
      img: 'https://goo.gl/Bnc3XP',
      imgStyle: {
        height: 80 * 2.5,
        width: 109 * 2.5,
      },
      backgroundColor: '#fa931d',
      fontColor: '#fff',
      level: 10,
    }, {
      title: 'Page 2',
      description: 'Description 2',
      img: 'https://goo.gl/GPO6JB',
      imgStyle: {
        height: 93 * 2.5,
        width: 103 * 2.5,
      },
      backgroundColor: '#a4b602',
      fontColor: '#fff',
      level: 10,
    }];
    return (
      <AppIntro
        onNextBtnClick={this.nextBtnHandle}
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
        pageArray={pageArray}
      />
    );
  }
}

AppRegistry.registerComponent('introApp', () => introApp);

And here's my main.js:

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

class Main extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});



module.exports = Main;

Swiper next action does not trigger if you scroll back from first page [iOS]

You're react-native-app-intro component is suffering from an issue that was reported and fixed in the original react-native-swiper repo. You can see the issue here.
The bug only manifested on iOS for us as on Android the event chain is different and less events are fired.

What happens is that if you have an app intro that does not loop and you happen to swipe left on the initial page, this sets the isScrolling prop of the Swiper's state to true when the onScrollBeginDrag event fires. Afterwards, there is no logic to reset the isScrolling to false. This means that when the onNextBtnClick is called, it will return immediately due to this condition:
if (context.state.isScrolling || context.state.total < 2) return;

This could be solved by either adding this prop to your react-native-swiper fork's ScrollView component declaration:
onScrollEndDrag={()=>this.setState({isScrolling:false})}
Or, ideally, dropping your react-native-swiper fork from the package.json for the original as, by now, it already has many other fixes and it's not really worth it to have a branch just to add scrollEventThrottle={16} to it. You can do that in your own project.

The only change that you need to make to use the original react-native-swiper is changing the object on the onScroll Animated.event's array, to this:
[{ nativeEvent: { contentOffset: { x: this.state.parallax } } }].

EDIT: There is an issue on Android if you decide to user the react-native-swiper master branch. On Android, for some reason I was unable to identify in spite of a lot of debugging, only the first page is actually rendered. If you switch pages, the pagination component and the buttons update but the images are not rendered. =/
In case you are unable to fix that then at least add the onScrollEndDrag to fix the issue I reported. This can be done by merging Swiper-PR#6

full page, hide status bar

I am using the

<StatusBar hidden />

for removing the status bar on the page, it looks like this:

           <View>
                <StatusBar hidden />
                <AppIntro {props} />
            </View> 

but I still see the space of the status bar in the top, even when its not there

image

Publish new release to NPM

Hello there :D

So, I saw that you fixed that issue about the triggering the callback when the animation start but I think you forgot to publish it into NPM, it still the old version :)

Android Buttons doesn't response

when using react native button inside a view it does not works.
my code is:

<AppIntro
        onNextBtnClick={this.nextBtnHendle}
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
      >
        <View style={[styles.container,{ backgroundColor: '#fa931d' }]}>
          <View level={-10}><Text style={styles.text}>Page 1</Text></View>
          <View level={-15}><Text style={styles.text}>Page 1</Text></View>
          <View level={-20}><Text style={styles.text}>Page 1</Text></View>
        </View>
        <View style={[styles.container, { backgroundColor: '#a4b602' }]}>
          <View level={-10}><Text style={styles.text}>Page 2</Text></View>
          <View level={-15}><Text style={styles.text}>Page 2</Text></View>
          <View level={-20}><Text style={styles.text}>Page 2</Text></View>
        </View>
        <View style={[styles.container,{ backgroundColor: 'grey' }]}>
          <Button  onPress={()=>this.login}>Login</Button>
        </View>
      </AppIntro>

right padding

Hi. I have very weird padding in right site. It is not possible to deleted it. Any advice, how can I fix this?

simulator screen shot 16 jun 2017 11 23 59

First Page doesn't show

I just installed this component and when I run it, I see this:

screen shot 2017-04-05 at 6 46 29 pm

If I start to swipe (even a slight bit) then the screens show correctly.

Android: Error while updating property 'src' of a view managed by RCTImageView

Hello,

I tried running the advanced usage example as seen in README.md, just like this:

  render() {
    return (<AppIntro
        onNextBtnClick={this.nextBtnHandle}
        onDoneBtnClick={this.doneBtnHandle}
        onSkipBtnClick={this.onSkipBtnHandle}
        onSlideChange={this.onSlideChangeHandle}
      >
      <View style={[styles.slide,{ backgroundColor: '#fa931d' }]}>
      <View level={10}><Text style={styles.text}>Page 1</Text></View>
      <View level={15}><Text style={styles.text}>Page 1</Text></View>
      <View level={8}><Text style={styles.text}>Page 1</Text></View>
      </View>
      <View style={[styles.slide, { backgroundColor: '#a4b602' }]}>
      <View level={-10}><Text style={styles.text}>Page 2</Text></View>
      <View level={5}><Text style={styles.text}>Page 2</Text></View>
      <View level={20}><Text style={styles.text}>Page 2</Text></View>
      </View>
      <View style={[styles.slide,{ backgroundColor: '#fa931d' }]}>
      <View level={8}><Text style={styles.text}>Page 3</Text></View>
      <View level={0}><Text style={styles.text}>Page 3</Text></View>
      <View level={-10}><Text style={styles.text}>Page 3</Text></View>
      </View>
      <View style={[styles.slide, { backgroundColor: '#a4b602' }]}>
      <View level={5}><Text style={styles.text}>Page 4</Text></View>
      <View level={10}><Text style={styles.text}>Page 4</Text></View>
      <View level={15}><Text style={styles.text}>Page 4</Text></View>
      </View>

      </AppIntro>
    );
  }

This runs just fine in an iOS emulator. In Android, as soon as I reach a component that has a reference to react-native-app-intro (i.e. a component that imports this module) it gives me the error message from the title, even though I'm not using any images inside the AppIntro component and its children.

Any ideas on what may be causing this?

Btw, great job, your module seems very promising, I intend to use it as a first-time tutorial for my app.

Text Styles for Done and Skip Buttons

If I give long text to these buttons, it does not fit the screen.

So being able to setting styles of these buttons could be useful.

ex:

doneBtnStyle

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.