1.1.1 • Published 3 years ago

@mohamadkh75/react-native-jalali-datepicker v1.1.1

Weekly downloads
10
License
MIT
Repository
github
Last release
3 years ago

react-native-jalali-datepicker

PRs Welcome   code style: prettier   npm version   DUB


Preview

Install

Package ManagerCommand
yarnyarn add @mohamadkh75/react-native-jalali-datepicker
npmnpm i --save @mohamadkh75/react-native-jalali-datepicker

Usage

import DatePicker from '@mohamadkh75/react-native-jalali-datepicker';

<DatePicker
  style={{
    width: '95%',
    height: '80%',
    alignSelf: 'center',
    backgroundColor: '#1e272e',
    borderWidth: 1,
    borderColor: '#4bcffa',
    borderRadius: 10,
    elevation: 4
  }}
  selected='1399/1/18'
  dateSeparator='/'
  minDate='1398/1/18'
  maxDate='1400/1/18'
  headerContainerStyle={{ height: '15%' }}
  yearMonthBoxStyle={{
    width: '30%',
    height: '75%',
    justifyContent: 'center',
    alignItems: 'center',
    borderWidth: 1,
    borderRadius: 10
  }}
  yearMonthTextStyle={{ fontSize: 22, color: '#4bcffa' }}
  iconContainerStyle={{ width: `${100 / 7}%` }}
  backIconStyle={{
    width: 20,
    height: 20,
    resizeMode: 'center',
    tintColor: '#808e9b'
  }}
  nextIconStyle={{
    width: 20,
    height: 20,
    resizeMode: 'center',
    tintColor: '#4bcffa'
  }}
  eachYearStyle={{
    width: 110,
    height: 82,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#4bcffa',
    marginTop: '1.5%',
    marginBottom: 5,
    marginHorizontal: '1.5%',
    borderRadius: 10,
    elevation: 3
  }}
  eachYearTextStyle={{
    fontSize: 16,
    color: 'white'
  }}
  eachMonthStyle={{
    width: `${88 / 3}%`,
    height: `${88 / 4}%`,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#4bcffa',
    marginBottom: '3%',
    borderRadius: 10,
    elevation: 3
  }}
  eachMonthTextStyle={{ fontSize: 16, color: 'white' }}
  weekdaysContainerStyle={{ height: '10%' }}
  weekdayStyle={{
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  }}
  weekdayTextStyle={{
    fontSize: 16,
    color: '#808e9b',
    marginBottom: 5
  }}
  borderColor='#4bcffa'
  dayStyle={{
    width: `${100 / 7}%`,
    justifyContent: 'center',
    alignItems: 'center',
    aspectRatio: 1 / 1
  }}
  selectedDayStyle={{
    width: '70%',
    aspectRatio: 1 / 1,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 100
  }}
  selectedDayColor='#4bcffa'
  dayTextStyle={{ fontSize: 18 }}
  selectedDayTextColor='white'
  dayTextColor='#4bcffa'
  disabledTextColor='#4bcffa66'
  onDateChange={date => console.warn(date)}
/>;

Properties

PropDefaultType
stylesee Props.jsViewStyle
selectedtodaystring
dateSeparator/string
minDatelast yearstring
maxDatenext yearstring
onDateChangedate => console.warn(date)Function
headerContainerStylesee Props.jsViewStyle
yearMonthBoxStylesee Props.jsViewStyle
yearMonthTextStyle{ fontSize: 22, color: 'black' }TextStyle
iconContainerStylesee Props.jsViewStyle
backIconStylesee Props.jsImageStyle
nextIconStylesee Props.jsImageStyle
eachYearStylesee Props.jsViewStyle
eachYearTextStyle{ fontSize: 16, color: 'white' }TextStyle
eachMonthStylesee Props.jsViewStyle
eachMonthTextStyle{ fontSize: 16, color: 'white' }TextStyle
weekdaysContainerStylesee Props.jsViewStyle
weekdayStylesee Props.jsViewStyle
weekdayTextStyle{ fontSize: 16, color: 'black', marginBottom: 5 }TextStyle
borderColorcoralstring
dayStylesee Props.jsViewStyle
selectedDayStylesee Props.jsViewStyle
selectedDayColorcoralstring
dayTextStyle{ fontSize: 18 }TextStyle
selectedDayTextColor#FFFFFFstring
dayTextColor#111111string
disabledTextColor#999999string

Example

Take a look at example:

git clone https://github.com/MohamadKh75/react-native-jalali-datepicker.git

cd example

yarn

react-native run-android

# OR

react-native run-ios

Acknowledgements

I used Vazir font by Saber Rastikerdar in example app!

License

MIT