A beautiful swipeable calendar component for React Native app. Based on reanimated and react-native-gesture-handler.
How to use it:
1. Install and import the swipeable calendar component.
# Yarn $ yarn add react-native-swipe-calendar # NPM $ npm i react-native-swipe-calendar
2. Basic usage.
import React, { useState, useRef, } from "react"; import { Text, View, StyleSheet, LayoutAnimation, TouchableOpacity, Platform, UIManager, } from "react-native"; import Calendar from "react-native-swipe-calendar"; if (Platform.OS === "android") { UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true); } export default function App() { const [currentDate, setCurrentDate] = useState(new Date()); const [selectedDate, setSelectedDate] = useState<Date | null>(null); const calendarRef = useRef(null); return ( <View style={styles.container}> <Calendar theme={{ todayIndicatorDotColor: "blue" }} ref={calendarRef} currentDate={currentDate} onDateSelect={(date, { isSelected }) => setSelectedDate(isSelected ? null : date )} selectedDate={selectedDate} onMonthChange={(date) => { setCurrentDate(date); LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); }} /> <View style={styles.controlBar}> <TouchableOpacity style={styles.incDec} onPress={() => calendarRef.current?.decrementMonth()} > <Text>{"<"}</Text> </TouchableOpacity> <TouchableOpacity style={styles.incDec} onPress={() => calendarRef.current?.incrementMonth()} > <Text>{">"}</Text> </TouchableOpacity> </View> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "white", paddingTop: 100 }, incDec: { paddingHorizontal: 20, padding: 10, backgroundColor: "lightgrey", alignItems: "center", justifyContent: "center", borderRadius: 5, }, controlBar: { position: "absolute", top: 100, left: 0, right: 0, flexDirection: "row", justifyContent: "space-between", }, });
Preview:
Download Details:
Author:
Live Demo: View The Demo
Download Link: Download The Source Code
License: