Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-super-timepicker

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-super-timepicker

React Native 24-hour super TimePicker for iOS

  • 1.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by145.45%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-super-timepicker

npm version npm downloads

Summary

A 24-hour format time picker which improves on react-native-24h-timepicker by:

  • supporting minHour and maxHour (contribution by mindmind)
  • removing deprecated stuff like componentWillReceiveProps
  • updated dependencies to the latest stuff

Screenshot

screenshot

Installation

npm i react-native-super-timepicker --save

or

yarn add react-native-super-timepicker

Example

import React, { Component } from "react";
import { StyleSheet, View, TouchableOpacity, Text } from "react-native";
import TimePicker from "react-native-super-timepicker";

class Example extends Component {
  constructor() {
    super();
    this.state = {
      time: "",
    };
  }

  onCancel() {
    this.TimePicker.close();
  }

  onConfirm(hour, minute) {
    this.setState({ time: `${hour}:${minute}` });
    this.TimePicker.close();
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.text}>REACT NATIVE</Text>
        <Text style={styles.text}>24 HOURS FORMAT TIMEPICKER</Text>
        <TouchableOpacity
          onPress={() => this.TimePicker.open()}
          style={styles.button}
        >
          <Text style={styles.buttonText}>TIMEPICKER</Text>
        </TouchableOpacity>
        <Text style={styles.text}>{this.state.time}</Text>
        <TimePicker
          ref={(ref) => {
            this.TimePicker = ref;
          }}
          onCancel={() => this.onCancel()}
          onConfirm={(hour, minute) => this.onConfirm(hour, minute)}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    backgroundColor: "#fff",
    paddingTop: 100,
  },
  text: {
    fontSize: 20,
    marginTop: 10,
  },
  button: {
    backgroundColor: "#4EB151",
    paddingVertical: 11,
    paddingHorizontal: 17,
    borderRadius: 3,
    marginVertical: 50,
  },
  buttonText: {
    color: "#FFFFFF",
    fontSize: 16,
    fontWeight: "600",
  },
});

export default Example;

Props

PropTypeDescriptionDefault
minHournumberMinimum of hour0
maxHournumberMaximum of hour23
minMinutenumberMinimum of minute0
maxMinutenumberMaximum of minute59
hourIntervalnumberThe interval at which hours can be selected.1
minuteIntervalnumberThe interval at which minutes can be selected.1
hourUnitstringAdd extra text to hour (e.g. "hrs"). Include a space if you want a gap between the number and the text (e.g. " hrs" for "18 hrs")""
hourUnitSingularstringThe first hour's extra text, if not hourUnit (e.g. "1 hr" vs "2 hrs")""
minuteUnitstringAdd extra text to minute (e.g. "mins"). Include a space if you want a gap between the number and the text (e.g. " mins" for "4 mins")""
minuteUnitSingularstringThe first minute's extra text, if not minuteUnit (e.g. "1 min" vs "2 mins")""
selectedHourstringDefault hour"0"
selectedMinutestringDefault minute"00"
itemStyleobjectItem text style{}
textCancelstringCancel button textCancel
textConfirmstringConfirm button textConfirm
onCancelfunctionEvent on Cancel button
onConfirmfunctionEvent on Confirm button

Methods

Method NameDescription
openOpen TimePicker
closeClose TimePicker

Note

Always set ref to TimePicker and call each method by using this.TimePicker.methodName() like example above.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Author

Made by Philip Su, with thanks to original author NYSamnang. Repo was forked to provide more active maintenance and to accept others' pull requests.

Keywords

FAQs

Package last updated on 04 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc