1.2.0 • Published 5 months ago

react-native-limit-timepicker v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

react-native-limit-timepicker

npm version license

React Native Limit Timepicker is a library that provides a LIMITABLE and CUSTOMIZABLE timepicker component for React Native applications.

Features

  • Smooth Animated Timepicker
  • Can limit the minimum time and maximum time in scroll picker
  • Easy to use
  • Consistent look and feel on iOS and Android
  • Customizable font size, colors and animation duration
  • Implemented with typescript
If you love this library, and want to support it, let's give us a star, you will be a ray of sunshine in our lives 🥰

Getting started

npm install react-native-limit-timepicker --save

or

yarn add react-native-limit-timepicker

Timepicker Props

PropsParamsisRequireDescription
disabledbooleanNoDisable the scrollable of Timepicker
customHourDataArray<ItemT = string | number>NoString or number array of the hour (Ex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
customMinutesDataArrayNoString or number array of the minute (Ex: 0, 30)
customPeriodDataArrayNoString or number array of the minute (Ex: 'am, 'pm')
renderTextHour(data: ItemT) => stringNoCustomize the text of the hour item
renderTextMinute(data: ItemT) => stringNoCustomize the text of the minute item
renderTextPeriod(data: ItemT) => stringNoCustomize the text of the period item
onChangeHour(value: ItemTundefined, index: number) => voidNoCalled when the hour's momentum scroll ends (scroll which occurs as the ScrollView glides to a stop)
onChangeMinute(value: ItemTundefined, index: number) => voidNoCalled when the minute's momentum scroll ends (scroll which occurs as the ScrollView glides to a stop)
onChangePeriod(value: ItemTundefined, index: number) => voidNoCalled when the period's momentum scroll ends (scroll which occurs as the ScrollView glides to a stop)
timeDateNoSet default time
minDateDateNothe minimum date can selected
maxDateDateNothe maximum date can selected
containerStyleViewStyleNoStyling for view container
scrollHourStyleViewStyleNoStyling for hour scroll View
scrollMinuteStyleViewStyleNoStyling for minute scroll View
scrollPeriodStyleViewStyleNoStyling for period scroll View
highlightColorStringNoBorder color for top and bottom centered item in scroll timepicker container
highlightBorderWidthNumberNoBorder width for top and bottom line selected in scroll timepicker container
hourTextStyleTextStyleNoStyling for hour text
minuteTextStyleTextStyleNoStyling for minute text
periodTextStyleTextStyleNoStyling for period text
activeItemTextStyleTextStyleNoStyling for selected text
itemHeightNumberNoCustomize item height in each scroll container
wrapperHeightNumberNoCustomize wrapper height of scroll container
wrapperBackgroundStringNoCustomize background color of scroll container

Timepicker example

  import React, { useState } from 'react';
  import { View } from 'react-native';
  import TimePicker from 'react-native-limit-timepicker';

  const TimePickerComponent = () => {
    return (
      <View style={styles.container}>
        <TimePicker
          customMinutesData={[0, 15, 30, 45]}
          onChangeHour={value => console.log('hour: ', value)}
          onChangeMinute={value => console.log('minute: ', value)}
          onChangePeriod={value => console.log('period: ', value)}
          minDate={new Date()}
          time={new Date()}
        />
      </View>
    );
  };

  export default TimePickerComponent;

  const styles = StyleSheet.create({
    container: {
      backgroundColor: 'white',
      padding: 16,
    },
  });

Support react-native-limit-timepicker <3