npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boxmodel-native-carousel

v2.0.4

Published

React Native Carousel

Downloads

4

Readme

Carousel created for adding JSX components within a swipeable container for react native.

Including form support with authenticated steps.

Example

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Carousel from 'boxmodel-native-carousel';

export default function App() {

    const carouselItems = [
        {
            id: '0',
            items: [
                <Text style={[styles.header]}>Step 1</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        },
        {
            id: '1',
            items: [
                <Text style={[styles.header]}>Step 2</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        },
        {
            id: '2',
            items: [
                <Text style={[styles.header]}>Step 3</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        }
    ]

    return (
        <View style={styles.container}>
            <Carousel
                carouselItems={carouselItems}
                paginationColor={'#17e592'}
                buttonColor={'#17e592'}
                progressBarColor={
                    {
                        innerColor: '#d6d6d6',
                        outerColor: '#17e592'
                    }
                }
            />
        </View>
    )
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
    },
    header: {
        fontSize: 24,
        fontWeight: 'bold',
        marginBottom: 20,
        color: '#000000'
    },
    text: {
        color: '#3b3b3b'
    }
});

Adding carouselItems

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Carousel from 'boxmodel-native-carousel';

export default function App() {

    const carouselItems = [
        {
            id: '0',
            items: [
                <Text style={[styles.header]}>Step 1</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        },
        {
            id: '1',
            items: [
                <Text style={[styles.header]}>Step 2</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        },
        {
            id: '2',
            items: [
                <Text style={[styles.header]}>Step 3</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        }
    ]

    return (
        <View style={styles.container}>
            <Carousel
                carouselItems={carouselItems}
            />
        </View>
    )
}

Authenticating Steps

import React, { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Carousel from 'boxmodel-native-carousel';
import Form from './myComponents/form';

export default function App() {

    const [nextButtonEnabled, setNextButtonEnabled] = useState(false)
    const [completed, setCompleted] = useState(false)

    const carouselItems = [
        {
            id: '0',
            allowNextStep: false,
            items: [
                <Text style={[styles.header]}>Step 1</Text>,
                <Text style={[styles.text]}>Example text</Text>,
                <Form setValidateNextStep={setNextButtonEnabled} /> //Return true when form is complete
            ]
        },
        {
            id: '1',
            allowNextStep: true,
            items: [
                <Text style={[styles.header]}>Step 2</Text>,
                <Text style={[styles.text]}>Example text</Text>
            ]
        }
    ]

    return (
        <View style={styles.container}>
            <Carousel
                carouselItems={carouselItems}
                nextButtonEnabled={nextButtonEnabled}
                setNextButtonEnabled={setNextButtonEnabled}
                setCompleted={setCompleted}
            />
        </View>
    )
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
    },
    header: {
        fontSize: 24,
        fontWeight: 'bold',
        marginBottom: 20,
        color: '#000000'
    },
    text: {
        color: '#3b3b3b'
    }
});

Here we use state to set the value of the nextButtonEnabled property, if set to false the move-to-next button will be deactivated and swiping will be disabled.

You can also pass setNextButtonEnabled as a property so the component can toggle the state back to false when the next slide appears.

To tell the component which slide to respond to the nextButtonEnabled property you will need to add it into the object inside of the carouselItems array as allowNextStep: true || false ( example shown above ), this will default to true if not defined.

Create a CustomButton

const CustomButton = (props: any) => {
    return (
        <TouchableOpacity {...props} style={[styles.button, props.style]}>
            <AntDesign name={'right'} size={32} color={'#FFF'} />
        </TouchableOpacity>
    )
}

<Carousel
    CustomButton={CustomButton}
/>

Properties

| Properties | Type | | ------------------- | ------------------------------------------------------------------- | | carouselItems | Array<{ id: string, allowNextStep?: boolean, items: Array<any> }> | | nextButtonEnabled | Boolean | | setValidateNextStep | Function | | setCompleted | Function | | CustomButton | JSX.Element | | paginationColor | string | | buttonColor | string | | progressBarColor | { innerColor: string, outerColor: string } |