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-wheel-time-picker

v0.4.3

Published

simple pure js time picker for react-native

Downloads

1,327

Readme

npm version

react-native-wheel-time-picker

Simple and pure js time picker for react-native. It provides the same UI for Android and IOS. You can use the Wheel component independantly.

| Android | IOS | | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | | Jun-18-2021 14-16-57 | Jun-18-2021 14-16-45 |

Installation

npm install react-native-wheel-time-picker

Props

TimePicker Props

| | necessary | types | default | info | | -------------- | :-------: | ------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------ | | label | | string | undefined | | | value | | number | undefined | millisecond value after 0 0 | | onChange | | (newValue: number) => void | undefined | changing value function | | containerStyle | | ViewStyle | undefined | container style | | onScroll | | (scrollState: boolean) => void | undefined | a callback function. it may be used when the TimePicker is inside of a scroll view to preventing the outer scroll. | | textStyle | | TextStyle | undefined | text style | | timeFormat | | ( TimeType | string )[] | ['ampm', 'hours12', ':', 'min'] | | wheelProps | | StyleProps type of Wheel | undefined | see next |

Wheel StyleProps

| | necessary | types | default | info | | -------------- | :-------: | --------- | --------- | ---------------------------------------------- | | wheelHeight | | number | 70 | Wheel height | | displayCount | | number | 5 | Number of items to show in front of the wheel. | | containerStyle | | ViewStyle | undefined | Wheel container style | | itemHeight | | number | 15 | Wheel item height | | selectedColor | | string | 'black' | Selected item color | | disabledColor | | string | 'gray' | Other items color | | textStyle | | TextStyle | undefined | Text style of each item |

Other Wheel Props

Below props are provided by the TimePicker component.

| | necessary | types | default | info | | -------- | :-------: | ------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------ | | value | v | string | | item value | | setValue | v | (newValue: string) => void | | Changing value function | | values | v | string[] | | List of values to choose from | | onScroll | | (scrollState: boolean) => void | undefined | a callback function. it may be used when the TimePicker is inside of a scroll view to preventing the outer scroll. |

Usage

import React, { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import TimePicker from 'react-native-wheel-time-picker';
import { useMemo } from 'react';

const MILLISECONDS_PER_MINUTE = 60 * 1000;
const MILLISECONDS_PER_HOUR = 60 * 60 * 1000;
const MILLISECONDS_PER_DAY = 24 * MILLISECONDS_PER_HOUR;

export default function App() {
  const [timeValue, setTimeValue] = useState(Date.now() % MILLISECONDS_PER_DAY);
  const [hour, min] = useMemo(() => {
    return [
      Math.floor(timeValue / MILLISECONDS_PER_HOUR),
      Math.floor((timeValue % MILLISECONDS_PER_HOUR) / MILLISECONDS_PER_MINUTE),
      Math.floor((timeValue % MILLISECONDS_PER_MINUTE) / 1000),
    ];
  }, [timeValue]);
  return (
    <View style={styles.container}>
      <TimePicker
        value={timeValue}
        wheelProps={{
          wheelHeight: 70,
          itemHeight: 15,
        }}
        onChange={(newValue) => setTimeValue(newValue)}
      />
      <Text style={styles.timeValue}>{`${hour < 10 ? '0' : ''}${hour}:${
        min < 10 ? '0' : ''
      }${min}`}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  timeValue: {
    marginVertical: 20,
  },
});

Animated sine function

The sin function of the AnimatedMath.ts file is really inspired by 'react-native-animated-math' package. We tried to import the package and use it, but there was a performance issue, so we created a new function that omitted some terms. The function uses the Taylor series approximation as below.

 x - x^3 / 3! + x^5 / 5! - x^7 / 7!

The x value range is [-PI , PI] so it's maximum error will be

PI^9 / 9! = 0.08214 .....

If the x range is [-PI/2, PI/2] than the maximum error will be about 0.00016 ....

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT