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

@ilz5753/react-native-swipe-picker

v0.1.4

Published

React Native Swipe Picker

Downloads

69

Readme

react-native-swipe-picker

@ilz5753/react-native-swipe-picker is a React Native library that provides an inline picker component with a swipe-to-select-an-item interaction. It is similar to the input mechanism used in apps like SHealth, where users can swipe left or right to select a value from a list of options. This library allows you to create a user-friendly and intuitive picker component for your React Native applications, making it easier for users to input data or make selections without the need for traditional dropdown menus or modal pickers.

Demo

https://github.com/ilz5753/react-native-swipe-picker/assets/87062381/0d18bfa0-62ff-4a68-9d3a-f22dfb2aa228

Note

The @ilz5753/react-native-swipe-picker package relies on react-native-reanimated and react-native-gesture-handler to provide smooth animations and gestures. These dependencies must be installed and properly configured in your React Native project for the swipe picker component to function correctly.

Installation

npm install @ilz5753/react-native-swipe-picker
# yarn
yarn add @ilz5753/react-native-swipe-picker
# bun
bun add @ilz5753/react-native-swipe-picker

Usage

import SwipePicker, {
  type ISwipePickerId,
  type ISwipePickerItem,
} from "@ilz5753/react-native-swipe-picker";

//

const itemHeight = 90;

interface Account extends ISwipePickerId {
  fullName: string;
  address: string;
  uri: string;
}

const JennieNichols: Account = {
  id: "0",
  fullName: "Jennie Nichols",
  address: "Valwood Pkwy",
  uri: "https://randomuser.me/api/portraits/women/1.jpg",
};

const accounts: Account[] = [JennieNichols];

function RenderAccount({ item, itemHeight }: ISwipePickerItem<Account>) {
  let imgSize = useMemo(() => itemHeight * 0.75, [itemHeight]);
  return (
    <View
      style={[
        styles.fdr,
        styles.aic,
        styles.jcsb,
        styles.ph8,
        { height: itemHeight },
      ]}
    >
      <View style={[styles.fdr, styles.aic, styles.gap8]}>
        <Image
          style={[
            { width: imgSize, height: imgSize, borderRadius: imgSize / 2 },
          ]}
          source={{ uri: item.uri }}
        />
        <View style={[styles.gap8]}>
          <Text>{item.fullName}</Text>
          <Text>{item.address}</Text>
        </View>
      </View>
    </View>
  );
}

export default function Example() {
  const [activeAccount, setActiveAccount] = useState(JennieNichols);
  let onSelectItem = useCallback((acc: Account) => setActiveAccount(acc), []);
  return (
    <View style={[styles.f1, styles.aic, styles.jcc, styles.gap8]}>
      <SwipePicker
        {...{
          items: accounts,
          renderItem: RenderAccount,
          itemHeight,
          onSelectItem,
        }}
      />
      {activeAccount && (
        <Animated.View
          entering={FadeInUp}
          exiting={FadeOutUp}
          layout={LinearTransition}
        >
          <RenderAccount
            {...{
              item: activeAccount,
              itemHeight,
              index: 0,
            }}
          />
        </Animated.View>
      )}
    </View>
  );
}

Features

The @ilz5753/react-native-swipe-picker library offers several features to help you create a customizable and accessible inline picker component for your React Native applications:

  1. Swipe-to-select interaction: Users can easily swipe left or right to select a value from a list of options, providing a more intuitive and engaging experience compared to traditional dropdown menus or modal pickers.
  2. Customizable appearance: You can customize various aspects of the picker component, such as the text color, background color, font size, and item padding. This allows you to match the component's appearance to your app's theme and branding.
  3. Lightweight and performant: The component is lightweight and designed to have minimal impact on the performance of your React Native applications, ensuring a smooth and responsive user experience.
  4. Cross-platform support: The library works well on both iOS and Android platforms, enabling you to create consistent user experiences across different devices and operating systems.

License

This project Licensed under the MIT License.


Made with create-react-native-library