0.0.12 ā€¢ Published 3 years ago

react-native-calendarview-datepicker v0.0.12

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

React-native-calendarview-datepicker

GitHub top language GitHub code size in bytes npm GitHub tag (latest by date) Hits banner-image

šŸ“¦ Installation

npm i react-native-calendarview-datepicker

or

yarn add react-native-calendarview-datepicker

šŸ“ŗ Preview

banner-image banner-image

šŸš€ Basic Usage

Default

You can simply add date-picker as follows. It shows minimal default calendar. But you can customize as you wish.

import DatePickerCalendar from 'react-native-calendarview-datepicker';
import Moment from 'moment';

...

const App = () => {
  const [date, setDate] = useState(moment());

  return (
        <DatePickerCalendar date={date} onChange={(selectedDate) => setDate(selectedDate)}/>
  );
};

Customized

You can have full control of calendar picker. Pass your own calendar header and condition styles for darkmode.

import DatePickerCalendar from 'react-native-calendarview-datepicker';
import Moment from 'moment';

...

const App = () => {
  const [date, setDate] = useState(moment());
  
  //Custom datepicker header
const customHeader = (date, month, year, setMonth, setYear) => {
    return (
        <View style={{flexDirection: "row", justifyContent: 'space-between'}}>
            <View>
                <View>
                    <Text style={{color: "#fff", fontSize: 18, opacity: 0.5, marginBottom: 4}}>{year}</Text>
                </View>
                <View>
                    <Text style={{
                        color: "#fff",
                        fontSize: 25,
                        fontWeight: 'bold'
                    }}>{moment(date).format("MMMM Do YYYY")}</Text>
                </View>
            </View>
            <View style={{flexDirection: "row", alignItems: 'center'}}>
                <TouchableOpacity style={{
                    alignItems: 'center',
                    justifyContent: 'center',
                    marginRight: 10,
                    height: 40,
                    width: 40,
                    backgroundColor: "#155B3C",
                    borderRadius: 100
                }} onPress={() => setMonth(month - 1)}>
                    <Text style={{color: "#18D183", fontSize: 30, marginBottom: 5}}>{'ā€¹'}</Text>
                </TouchableOpacity>
                <TouchableOpacity style={{
                    alignItems: 'center',
                    justifyContent: 'center',
                    height: 40,
                    width: 40,
                    backgroundColor: "#155B3C",
                    borderRadius: 100
                }} onPress={() => setMonth(month + 1)}>
                    <Text style={{color: "#18D183", fontSize: 30, marginBottom: 5}}>{'ā€ŗ'}</Text>
                </TouchableOpacity>
            </View>
        </View>
    )
}

  return (
        <DatePickerCalendar
            date={date}
            onChange={(selectedDate) => setDate(selectedDate)}
            placeholder="Select date"
            placeholderStyles={{color: "#04e37d"}}
            fieldButtonStylesDateFormat="MMM Do YY"
            fieldButtonStyles={{width: '95%', backgroundColor: "#1D323E", borderRadius: 12, borderWidth: 2, borderColor: "#18D183", paddingLeft: 20}}
            fieldButtonTextStyles={{color: "#18D183"}}
            modalBackgroundColor={"#1D323E"}
            weekHeaderTextColor={"#18D183"}
            datesColor={"#fff"}
            selectedDateColor={"#1D323E"}
            selectedDateHighlightColor={"#18D183"}
            selectedDateHighlightRadius={5}
            customHeader={(date, month, year, setMonth, setYear) => customHeader(date, month, year, setMonth, setYear)}
            headerStyles={{padding: 0}}
        />
  );
};

šŸ“‘ API Reference

PropsTypeDescription
dateMomentIf your need to show placeholder on initial load just pass undefined, else for default value pass moment() object
onChangeFunctionCallback triggered on date select (Required)
placeholderStringCustom placeholder text
placeholderStylesObjectPlaceholder text styles
modalBackgroundColorStringCalendar modal background color
headerStylesObjectHeader wrapper styles
customHeaderFunctionFunction should return a component. Args: (date, month, year, setMonth, setYear)
weekHeaderTextColorStringWeek days names text color
selectedDateHighlightColorStringSelected date highlight marker color
selectedDateHighlightRadiusNumberSelected date highlight marker radius
datesColorStringCalendar date color
selectedDateColorStringSelected calendar date color
fieldButtonStylesDateFormatStringSelected date showing format. Available formats
fieldButtonStylesObjectField button styles
fieldButtonTextStylesObjectField button text styles

šŸ—ž License

React-native-calendarview-datepicker is licensed under the MIT License

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago