1.0.30 • Published 7 months ago

react-native-amazing-date-picker v1.0.30

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

React Native Amazing Date Picker

A customizable date picker modal for React Native applications.

Installation

You can install react-native-amazing-date-picker via npm or Yarn:

npm install react-native-amazing-date-picker

or

yarn add react-native-amazing-date-picker

Example Preview

Here’s a preview of how the DatePickerModal looks when rendered:

showYear prop to true it unable the year column.  Default view of the date picker modal.

Dependencies

This package requires the following dependencies:

Usage

Here is a simple example of how to use the DatePickerModal component in your React Native application:

<DatePickerModal
  isVisible={isModalVisible}
  onClose={() => setModalVisible(false)}
  date={isStartDate ? startDate : endDate}
  onChange={onChange}
  isStartDate={isStartDate}
  showYear={false} // To show only date and month
  modalContentStyle={{ height: 350 }} // Example custom style
  modalTitleStyle={{ color: "blue" }} // Example custom style
  selectionOverlayStyle={{ backgroundColor: "rgba(0,0,0,0.2)" }} // Example custom style
  buttonContainerStyle={{ justifyContent: "flex-end" }} // Example custom style
  cancelButtonStyle={{ backgroundColor: "red" }} // Example custom style
  confirmButtonStyle={{ backgroundColor: "green" }} // Example custom style
/>

Below is the complete example of how to use this component within a simple app:

import React, { useState } from "react";
import { View } from "react-native";
import { DatePickerModal } from "react-native-amazing-date-picker";

const App = () => {
  const [isModalVisible, setModalVisible] = useState(false);
  const [selectedDate, setSelectedDate] = useState(new Date());

  const handleDateChange = (date) => {
    setSelectedDate(date);
    setModalVisible(false);
  };

  const formattedDate = selectedDate.toLocaleDateString("en-US", {
    weekday: "long",
    year: "numeric",
    month: "long",
    day: "numeric",
  });

  return (
    <View style={styles.container}>
      <Text style={styles.text}>{formattedDate}</Text>
      {/* Your component code */}
      <TouchableOpacity
        style={styles.button}
        onPress={() => setModalVisible(!isModalVisible)}
      >
        <Text style={styles.buttonText}>Open Picker</Text>
      </TouchableOpacity>
      <DatePickerModal
        isVisible={isModalVisible}
        onClose={() => setModalVisible(false)}
        date={selectedDate}
        onChange={handleDateChange}
        isStartDate={true} // if you want to have two modal for different date then can handle with this prop
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    padding: 20,
    backgroundColor: "#fff",
  },
  buttonText: {
    color: "#fff",
    fontSize: 16,
    fontWeight: "bold",
  },
  button: {
    backgroundColor: "skyblue",
    padding: 15,
    borderRadius: 5,
    marginBottom: 15,
    alignItems: "center",
  },
  text: {
    fontSize: 18,
    color: "#333",
    marginBottom: 20,
  },
});
export default App;

Prop Usage

License

This project is licensed under the MIT License. See the LICENSE file for details.

1.0.22

7 months ago

1.0.26

7 months ago

1.0.25

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.29

7 months ago

1.0.28

7 months ago

1.0.27

7 months ago

1.0.30

7 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago