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

@appandflow/react-native-magic-scroll

v0.1.24

Published

Library to help managing keyboard interaction in form

Downloads

213

Readme

magic-scroll

About

App & Flow is a Montreal-based, close-knit team that specializes in React Native and Expo development. We work with multiple YC-backed startups and are recommended by Expo. Need a hand? Let’s build together. [email protected]

npm (scoped)

Why react-native-magic-scroll?

The goal of the library is to seamlessly and precisely handle your keyboard, scrollview and inputs when interacting with forms. While other solutions offer plug-and-play functionalities, we wanted to have something more precise and with more flexibility so that it can be used in any situation.

Examples

We recreated two flows from popular apps to showcase our library in action. The demo app code is available here.

| Twitch's sign up | Shop's check out | | ------------- | ------------- | | | |

Installation

react-native-magic-scroll

yarn install @appandflow/react-native-magic-scroll
npm i @appandflow/react-native-magic-scroll

Dependencies

To use our library, you will need to install these two dependencies into your project.

1) React Native Reanimated

npx expo install react-native-reanimated

Learn more about this dependency here.

2) SafeAreaContext

npx expo install react-native-safe-area-context

Learn more about this dependency here.

Android

On Android, make sure to set android:windowSoftInputMode in your AndroidManifest.xml to pan

Expo

// app.json
"android": {
  ...rest,
  "softwareKeyboardLayoutMode": "pan"
}

Basic Usage

Wrap your screen within our ScrollView.

import { MagicScroll } from '@appandflow/react-native-magic-scroll';
// rest of your imports

const YourScreen = () => {
  return (
    <MagicScroll.ScrollView>
      // Your form
    </MagicScroll.ScrollView>
  );
};

export default YourScreen;

You then use our TextInputs for the form itself, that you place inside the MagicScroll.ScrollView. Easily "chain" your inputs (so that the return keyboard button hops to the next desired input) by using the MagicScroll.TextInput name and chainTo props, like so:

import { MagicScroll } from '@appandflow/react-native-magic-scroll';
// rest of your imports

const textInputStyle = {
  height: 50,
  backgroundColor: '#ddd',
  borderRadius: 10,
  marginTop: 8,
};


const YourScreen = () => {
  return (
    <MagicScroll.ScrollView>
      <MagicScroll.TextInput
        // This is the name of this text input, used by the `chainTo` prop
        name="email"
        // This is where you can design your a custom label above the input
        renderTop={() => <Text>Email</Text>}
        // This is where you can design your custom label below the input
        renderBottom={() => <Text>Must be unique</Text>}
        // This is the function that will make the text input named "password" focused when pressing the Enter or Return key on the device's keyboard
        chainTo="password"
        textInputProps={{
          style: textInputStyle,
        }}
      />
      <MagicScroll.TextInput
        name="password"
        renderTop={() => <Text>Password</Text>}
        textInputProps={{
          secureTextEntry: true,
          style: textInputStyle,
        }}
      />
    </MagicScroll.ScrollView>
  );
};

Advanced

As mentioned in the introduction, the drawbacks of a plug-and-play library are its limitations when deviating from standard functionality. That's precisely why our library allows for customization, enabling you to tailor its usage to suit your specific needs and use cases.

Tips

It's a great idea to wrap our MagicScroll.TextInput within your own for re-usability!

Here's an example

import { MagicScroll } from '@appandflow/react-native-magic-scroll';

// rest of your imports

interface Props {
  label?: string;
  isPassword?: boolean;
  name?: string;
  description?: string;
  chainTo?: string;
}

const YourCustomInput = (props: Props) => {
  return (
    <MagicScroll.TextInput
      name={props.name}
      chainTo={props.chainTo}
      renderTop={() => <Text>{props.label}</Text>}
      renderBottom={() => <Text>{props.description}</Text>}
      textInputProps={{
        secureTextEntry: props.isPassword,
        style: {
          height: 50,
          backgroundColor: '#ddd',
          borderRadius: 10,
          marginTop: 8,
        },
      }}
    />
  );
};

Props (Optional)

All of these props are optional. It is, however, recommended to use them to get the most out of the library.

MagicScroll.ScrollView:

| Name | Description | Values | | ---- | ----------- | ------ | | additionalPadding | adds extra padding between your text input and the keyboard | number | | scrollViewProps | contains all props of the scrollview from React's Reanimated library | props |

MagicScroll.TextInput:

| Name | Description | Values | | ---- | ----------- | ------ | | chainTo | a string containing the name of the next text input that will be focused when pressing the "Enter Key" | string | | containerStyle | contains all Style props of the View from React Native | props | | name | a string to name the current text input, used in the "chainTo" props mentionned above | string | | renderBottom() | a function that renders components to display custom text under the text input | renderBottom={() => <Text>bottomText</Text>} | | renderTop() | a function that renders components to display custom text above the text input | renderTop={() => <Text>topText</Text>} | | textInputProps | contains all props of the TextInput component from React Native | props |