适用于React Native 旋转木马应用程序介绍

 更新时间:2022年10月25日 16:32:05   作者:Jovie  
这篇文章主要介绍了适用于React Native 旋转木马应用程序介绍,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪

正文

一个带有分页功能的介绍页面旋转木马(onboarding)动画。

如何使用它

1.安装并导入 react-native-intro-carousel

# Yarn
$ yarn add react-native-intro-carousel
# NPM
$ npm i react-native-intro-carousel
import * as React from 'react';
import { Image, StyleSheet, View } from 'react-native';
import Carousel from 'react-native-intro-carousel';

2.示例应用程序

export default function App() {
  return (
    <View style={styles.container}>
      <Carousel
        data={[
          {
            key: '1',
            title: 'Cool package',
            description: 'This is a cool package',
            backgroundColor: '#e879f2',
            image,
            titleStyle: {
              color: 'white',
            },
            descriptionStyle: {
              color: 'white',
            },
          },
          {
            key: '2',
            title: 'Good information here',
            description: 'This is a good information\nOther text here',
            backgroundColor: '#f0ae35',
            image,
            imagePosition: 'center',
            // contentStyle: {
            //   justifyContent: 'space-evenly',
            // },
            titleStyle: {
              color: 'white',
            },
            descriptionStyle: {
              color: 'white',
            },
          },
          {
            key: '3',
            title: 'I am tired',
            description: 'I am tired',
            backgroundColor: '#79adf2',
            image,
            imagePosition: 'bottom',
            titleStyle: {
              color: 'white',
            },
            descriptionStyle: {
              color: 'white',
            },
          },
        ]}
        // renderItem={({ item }) => <Text>{item.title}</Text>}
        paginationConfig={{
          // dotSize: 10,
          // animated: false,
          // disabled: true,
          dotIncreaseSize: 1,
          dotSpacing: 30,
          // color: '#00000050',
          // activeColor: 'black',
          // activeDotStyle: {
          //   width: 30,
          //   left: -7.5,
          // }
        }}
        buttonsConfig={{
          next: {
            renderButton: (index, onChangeSlider) => (
              <View
                onTouchStart={() => onChangeSlider(index + 1)}
                style={styles.iconButton}
              >
                <Image source={arrowIcon} style={styles.arrow} />
              </View>
            ),
          },
          prev: {
            disabled: true,
          },
          done: {
            renderButton: (index, onChangeSlider) => (
              <View
                onTouchStart={() => onChangeSlider(index + 1)}
                style={styles.iconButton}
              >
                <Image source={checkIcon} style={styles.arrow} />
              </View>
            ),
          },
        }}
        // onFinish={() => console.log('finish')}
        // onPressSkip={() => console.log('test')}
        // renderItem={({ item, index }, goToSlide) => (
        //   <View style={styles.content}>
        //     <Image source={item.image} style={styles.image} />
        //     <Text>{item.title}</Text>
        //     <Text>{item.description}</Text>
        //     <View style={styles.buttonsContainer}>
        //       <Pressable
        //         style={styles.button}
        //         onPress={() => goToSlide(index - 1)}
        //       >
        //         <Text>Previous</Text>
        //       </Pressable>
        //       <Pressable
        //         style={[styles.button, { marginLeft: 10 }]}
        //         onPress={() => goToSlide(index + 1)}
        //       >
        //         <Text>Next</Text>
        //       </Pressable>
        //     </View>
        //   </View>
        // )}
      />
    </View>
  );
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
  },
  content: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  button: {
    padding: 10,
    backgroundColor: '#47d16c',
    marginTop: 20,
    borderRadius: 5,
  },
  buttonsContainer: {
    flexDirection: 'row',
  },
  image: {
    width: 200,
    height: 200,
  },
  arrow: {
    width: 30,
    height: 30,
  },
  iconButton: {
    padding: 10,
    borderRadius: 50,
    backgroundColor: '#00000050',
  },
});

预览

The postApp Introduction Carousel For React Nativeappeared first onReactScript.

以上就是适用于React Native 旋转木马应用程序介绍的详细内容,更多关于React Native 旋转木马的资料请关注脚本之家其它相关文章!

相关文章

  • React中的for循环解读

    React中的for循环解读

    这篇文章主要介绍了React中的for循环解读,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2023-01-01
  • 深入了解React中的合成事件

    深入了解React中的合成事件

    React 中的事件,是对原生事件的封装,叫做合成事件。这篇文章主要通过几个简单的示例为大家详细介绍一下React中的合成事件,感兴趣的可以了解一下
    2023-02-02
  • React diff算法超详细讲解

    React diff算法超详细讲解

    渲染真实DOM的开销很大,有时候我们修改了某个数据,直接渲染到真实dom上会引起整个dom树的重绘和重排。我们希望只更新我们修改的那一小块dom,而不是整个dom,diff算法就帮我们实现了这点。diff算法的本质就是:找出两个对象之间的差异,目的是尽可能做到节点复用
    2022-11-11
  • React事件处理超详细介绍

    React事件处理超详细介绍

    这篇文章主要介绍了React事件处理,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-09-09
  • react 跳转后路由变了页面没刷新的解决方案

    react 跳转后路由变了页面没刷新的解决方案

    最近在学习React的过程中遇到了路由跳转后页面不刷新的问题,本文就详细的介绍一下解决方法,需要的朋友们下面随着小编来一起学习学习吧
    2021-06-06
  • 利用React高阶组件实现一个面包屑导航的示例

    利用React高阶组件实现一个面包屑导航的示例

    这篇文章主要介绍了利用React高阶组件实现一个面包屑导航的示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-08-08
  • 你知道怎么在 HTML 页面中使用 React吗

    你知道怎么在 HTML 页面中使用 React吗

    这篇文章主要为大家详细介绍了如何在HTML页面中使用 React,使用使用js模块化的方式开发,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-01-01
  • React 高阶组件入门介绍

    React 高阶组件入门介绍

    本篇文章主要介绍了React高阶组件入门介绍,这篇文章中我们详细的介绍了什么是高阶组件,如何使用高阶组件,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-01-01
  • ReactJS中不同类型的状态详解

    ReactJS中不同类型的状态详解

    这篇文章主要为大家介绍了ReactJS中不同类型的状态详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2022-12-12
  • React组件二次包装的具体实现

    React组件二次包装的具体实现

    本文主要介绍了React组件二次包装的具体实现,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-02-02

最新评论