New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-neat-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-neat-date-picker

An easy-to-use date picker for React Native

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
496
decreased by-34.65%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Neat Date Picker

An easy-to-use date picker for react native.



Main Features

📲 Both Android and iOS devices are supported
👍 Providing range and single selection modes
🕒 Using mordern Date object to manipulate dates.
🌈 Color customization
✨ Clean UI
🈶 Chinese / English


Dependencies

react-native-modal

@expo-google-fonts/roboto


How to Start

First install

npm i react-native-neat-date-picker

Then check if you have already got the dependencies in your project.

If no, install them by

npm i react-native-modal
npm i @expo-google-fonts/roboto

Import


import DatePicker from 'react-native-neat-date-picker'

Basic Usage


import React, { useState } from 'react'
import { StyleSheet, View, Button } from 'react-native'
import DatePicker from 'react-native-neat-date-picker'

const App = () => {

  const [showDatePicker, setShowDatePicker] = useState(false)

  const openDatePicker = () => {
    setShowDatePicker(true)
  }

  const onCancel = () => {
    // You should close the modal in here
    setShowDatePicker(false)
  }

  const onConfirm = (date) => {
    // You should close the modal in here
    setShowDatePicker(false)

    // The parameter 'date' is a Date object so that you can use any Date prototype method.
    console.log(date.getDate())
  }

  return (
    <View style={styles.container}>
      <Button title={'open'} onPress={openDatePicker} />
      <DatePicker
        isVisible={showDatePicker}
        mode={'single'}
        onCancel={onCancel}
        onConfirm={onConfirm}
      />
    </View>
  )
}

export default App

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    justifyContent: 'center',
    alignItems: 'center'
  }
})

Properties

PropertyTypeDefaultDiscription
isVisibleBooleanREQUIREDShow the date picker modal
modeStringREQUIRED'single' for single date selection. 'range' for date range selection.
onCancelFunction( ) => nullThis function will execute when user presses cancel button.
onConfirmFunction( ) => nullThis function will execute when user presses confirm button. See OnConfirm section.
initialDateDatenew Date()When it is the first time that the user open this date picker, it will show the month which initialDate is in.
minDateDate-The earliest date which is allowed to be selected.
maxDateDate-The lateset date which is allowed to be selected.
startDateDate-Set this prop to a date if you need to set an initial starting date when opening the date picker the first time. Only works with 'range' mode.
endDateDate-Similar to startDate but for ending date.
onBackButtonPressFunctiononCancelCalled when the Android back button is pressed.
onBackdropPressFunctiononCancelCalled when the backdrop is pressed.
chineseBooleanfalseToggle Chinese mode.
colorOptionsObjectnullSee ColorOptions section.

OnConfirm

For 'single' mode, this prop passes an argument date.
As for 'range' mode, it passes two arguments start and end
All arguments are just javascript Date objects.

Example:

// single mode
onConfirm={(date)=>{
  console.log(date.getTime())
}

// range mode
onConfirm={(start,end)=>{
  console.log(start.getTime())
  console.log(end.getTime())
}

ColorOptions

The colorOptions prop contains several color settings. It helps you customize the date picker.

OptionTypediscription
backgroundColorStringThe background color of date picker and that of change year modal.
headerColorStringThe background color of header.
headerTextColorStringThe color of texts and icons in header.
changeYearModalColorstringThe color of texts and icons in change year modal.
weekDaysColorstringThe text color of week days (like Monday, Tuesday ...) which shown below header.
dateTextColor*stringThe text color of all the displayed date when not being selected.
selectedDateColor*stringThe text color of all the displayed date when being selected.
selectedDateBackgroundColor*stringThe background color of all the displayed date when being selected.
confirmButtonColorstringThe text color of the confirm Button.

* : Only six-digits HEX code colors (like #ffffff. #fff won't work) are allowed because I do something like this behind the scene.

style={{color:'{dateTextColor}22'}}  // '#rrggbbaa'

Example:

const colorOptions = {
  headerColor:'#9DD9D2',
  backgroundColor:'#FFF8F0'
}
...
<DatePicker
  ...
  colorOptions={colorOptions}
/>


TODOs

  • Add font customization.
  • Turn to typescript.

Inspiration

react-native-daterange-picker


Contact Me

This is my first open source.
Therefore, I expect there are lots of improvements that could be done.
Any Suggestions or contributions would be very appreciated.
Also, feel free to contact me at 2roto93Stark@gmail.com if you need.

Keywords

FAQs

Package last updated on 22 Sep 2021

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