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

react-native-tip

v0.0.25

Published

React Native tip utility

Downloads

1,350

Readme

React Native Tip is a simple package inspired in MaterialUI-Tooltip that helps you to show a quick tip to the user and highlight some important item in your app. It is useful to explain the user some funcionality.

Installation

To install the latest version of react-native-tip you only need to run:

npm install --save react-native-tip

or

yarn add react-native-tip

Try it out

You can find the examples above on src/example.

Basic Usage

Import TipProvider and place it at the very bottom of your App.js as below:

import React from "react";
import { SafeAreaView } from "react-native";
import TipProvider from "react-native-tip";

export default class App extends React.Component {
    render() {
        return (
            <SafeAreaView style={{ flex: 1 }}>
                ... all your stuff

                <TipProvider
                    ...global options, see below
                />
            </SafeAreaView>
        );
    }
}

Show a tip

To show a tip you need to import the Tip component and wrap the component you want to highlight inside it as shown below:

import React from "react";
import { Text } from "react-native";
import { Tip } from "react-native-tip";

class App extends React.Component {
  render() {
    return (
        <Tip
            title="Title"
            body="body"
        >
            <Text
                style={{
                    padding: 10,
                    fontWeight: 'bold',
                    fontSize: 20
                }}
            >
                Show tip
            </Text>
        </Tip>
    );
  }
}

When you wrap a component inside <Tip> it becomes a touchable. When you press it, it shows the tip automatically by default but you can change that by setting the props active = false.

OBS: if the item is already a pressable component, you have to show or close the tip manually by importing showTip(), closeTip() help functions.

import React from 'react'
import { View, StyleSheet, TouchableOpacity, Button } from 'react-native'
import { showTip, closeTip, Tip } from './Tip'
import Icon from 'react-native-vector-icons/Ionicons'

const Screen = ({ navigation }) => {
    const [_showTip, setShowTip] = React.useState(true)

    return (
        <View style={styles.container}>
            <Tip
                id='heart'
                title="Do you liked it?"
                body="Remember to hit the heart if you enjoyed the content"
                showItemPulseAnimation
                pulseColor='#ff8080'
                active={false}
            >
                <TouchableOpacity
                    onPress={() => {
                        _showTip && showTip('heart')
                        setShowTip(false)
                    }}
                    style={{ padding: 10, borderRadius: 50 }}
                >
                    <Icon name='heart' color='red' size={35}/>
                </TouchableOpacity>
            </Tip>

            <View style={{ width: 200 }}>
                <Button
                    title="Show heart tip"
                    onPress={() => showTip('heart')}
                />
            </View>
        </View>
    )
}

Show a tip tour

You can create a tour with the tips you choose by setting a list of steps and pass it as a param of showTipTour(steps) helper function. Each step receives a series of params specified in TipStep Props below. You can find a complete example in src/example/components/TourButton

Tip Props

| Property | Type | Description | | ----------------- | -------------------- | ----------------------------------------- | | id | string or number | The tip's id, useful to control it.| | title | string | The title text of your tip.| | titleStyle | TextStyle | Style for the title of your tip.| | body | string | The body text of your tip.| | bodyStyle | TextStyle | Style for the body of your tip.| | style | ViewStyle | Style of the item wrapper component: <Tip style={style}>.| | activeItemStyle | ViewStyle | Style for the item when the tip is open.>.| | tipContainerStyle | ViewStyle | Style for the tip. Use carefully, this can mess up the tip's position.| | overlayOpacity |number | Set opacity intensity of overlay. default0.6.| | renderTip | ({ titleStyle:TextStyle, bodyStyle:TextStyle }) => React.Component;| Set a custom component to be rendered inside your tip. You can inject your current tip's global titleStyle and bodyStyle (if you defined one in yourTipProvider) props direct in your custom tip component with titleStyleandbodyStyleparams.| | showItemPulseAnimation |boolean | Show item pulse animation when tip is open.| | pulseColor |string | Set pulse animation color.| | pulseStyle |ViewStyle | Style for the pulse animation.| | pulseIntensity |number | Style for the pulse animation intensity size.| | dismissable |boolean | Allow auto dismiss on touch overlay.| | active |boolean Default = true | If true the item becomes pressable and shows the tip automatically when pressed. OBS: if the item is already a pressable component, you should show or close it manually by usingshowTip(), closeTip()help functions.| | onPressItem |() => void | Trigger your custom action on item press.| | onTipPress |() => void | Trigger your custom action on tip press.| | onDismiss |() => void` | Override dismiss natural action.|

TipProvider Props

You can set a default style for all your tips with the following:

| Property | Type | Description | | ---------------------- | ----------- | --------------------------- | | tipContainerStyle | ViewStyle | Set global style for the tip wrapper.| | titleStyle | TextStyle | Set global style for the title of your tip.| | bodyStyle | TextStyle | Set global style for the body of your tip.| | overlayOpacity | number | Set global opacity intensity of overlay. default 0.6.| | showItemPulseAnimation | boolean | Set global pulse animation on item when tip is open.| | pulseColor | string | Set global pulse animation color.| | pulseStyle | ViewStyle | Set global style for the pulse animation.| | pulseIntensity | number | Set global pulse animation intensity size.| | darkMode | boolean | When true set a dark custom color scheme for your tip. It can be overwritten by titleStyle and bodyStyle props.| | prevButtonLabel | string | Label for Prev action button on tip tour mode.| | nextButtonLabel | string | Label for Next action button on tip tour mode.| | closeButtonLabel | string | Label for Close action button on tip tour mode.| | prevNextButtonStyle | ViewStyle | Style for Next, Prev, Close action buttons on tip tour mode.| | prevNextTextStyle | TextStyle | Style for Next, Prev, Close action buttons text on tip tour mode.|

Helper functions

| Property | Type | Description | | -------- | ---- | ----------- | | showTip | (tipId?: string, delay?: number, props?: Partial<ITip>) => void | Show your tip, can be called anywhere in your code. * You can show a specific tip by passing its id. * You can delay your tip's appearing by passing a delay number in milliseconds, useful to await async tasks live navigate to another screen, default=0 | | closeTip | ()=>void | Close the current opened tip, can be called anywhere in your code.| | showTipTour | (steps: ITipStep[])=>void | Set a tip tour sequence.|

TipStep Props

| Property | Type | Description | | ---------- | ------------ | ------------------------------------------------------------------------------------------------------ | | id | string | Current tip id, required | | prevId | string | Previous tip id, optional | | nextId | string | Next tip id, optional | | delay | number | Timeout before triggering the tip change to next or previous one. | | prevAction | () => void | Action to be executed right before Prev button is pressed. Use it with delay prop for async tasks. | | nextAction | () => void | Action to be executed right before Next button is pressed. Use it with delay prop for async tasks. |

License

MIT