Skip to content

Commit

Permalink
add some custom styles and types
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandima committed Jun 24, 2021
1 parent 80d6a93 commit 00c2867
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 149 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ tmp
example


rnv-date-range-picker-*.tgz
rnv-date-range-picker-*.tgz
screen.png
screen2.png
67 changes: 52 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A simple React Native date range picker component

---

### Installing:
## Installing

```
npm install rn-select-date-range
Expand All @@ -16,21 +16,32 @@ or
yarn add rn-select-date-range
```

### Screenshot
---

## Screenshot

![screen gif](https://media.giphy.com/media/qvl9TQCBdaMh116zk1/giphy.gif)
<p align="center">
<img src="https://media.giphy.com/media/qvl9TQCBdaMh116zk1/giphy.gif">
</p>

![screen shot](https://raw.githubusercontent.com/dilipchandima/rnv-date-range-picker/master/screen.png)
<p align="center">
<img src="https://raw.githubusercontent.com/dilipchandima/rnv-date-range-picker/master/screen.png">
<img src="https://raw.githubusercontent.com/dilipchandima/rnv-date-range-picker/master/screen2.png">
</p>

---

# Prerequisites
## Prerequisites

CalendarPicker requires Moment JS.

```
npm install --save moment
```

# Example
---

## Example React Native App

```js
import moment from "moment";
Expand All @@ -47,9 +58,12 @@ const App = () => {
onSelectDateRange={(range) => {
setRange(range);
}}
blockSingleDateSelection={true}
responseFormat="YYYY-MM-DD"
maxDate={moment()}
minDate={moment().subtract(100, "days")}
selectedDateContainerStyle={styles.selectedDateContainerStyle}
selectedDateStyle={styles.selectedDateStyle}
/>
<View style={styles.container}>
<Text>first date: {selectedRange.firstDate}</Text>
Expand All @@ -64,21 +78,40 @@ const styles = StyleSheet.create({
container: {
margin: 50,
},
selectedDateContainerStyle: {
height: 35,
width: "100%",
alignItems: "center",
justifyContent: "center",
backgroundColor: "blue",
},
selectedDateStyle: {
fontWeight: "bold",
color: "white",
},
});

export default App;
```

---

## CalendarPicker Props

| Prop | Type | Description |
| :---------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------- |
| **`maxDate`** | `Moment()` | Optional. If you need to pass Max Date user can select, set this prop as a moment date |
| **`minDate`** | `Moment()` | Optional. If you need to pass Min Date user can select, set this prop as a moment date |
| **`responseFormat`** | `String` | Optional. Please refere the date formats here [Moment Date Formats](https://momentjs.com/docs/#/parsing/string-format/) |
| **`onSelectDateRange`** | `Method` | This will return a object with firstDate and lastDate |
| Prop | Type | Description |
| :------------------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------- |
| **`maxDate`** | `Moment()` | Optional. If you need to pass Max Date user can select, set this prop as a moment date |
| **`minDate`** | `Moment()` | Optional. If you need to pass Min Date user can select, set this prop as a moment date |
| **`responseFormat`** | `String` | Optional. Please refere the date formats here [Moment Date Formats](https://momentjs.com/docs/#/parsing/string-format/) |
| **`onSelectDateRange`** | `Method` | This will return a object with firstDate and lastDate |
| **`blockSingleDateSelection`** | `boolean` | This will block the user to click single date without date range |
| **`font`** | `String` | Name of the font you are using in your theme |
| **`selectedDateContainerStyle`** | `Style` | Style of the selected date container |
| **`selectedDateStyle`** | `Style` | Style of the selected date |

---

### onSelectDateRange response
## onSelectDateRange response

```
{
Expand All @@ -87,14 +120,18 @@ export default App;
}
```

### Run the sample app
---

## Run the sample app

```
cd example
npm install
npx react-native run-ios
```

# Suggestions?
---

## Suggestions?

Open Issues. Submit PRs.
16 changes: 15 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';
import React, {useState} from 'react';
import {SafeAreaView, StyleSheet, View, Text} from 'react-native';
import DateRangePicker from 'rnv-date-range-picker';
import DateRangePicker from 'rn-select-date-range';

const App = () => {
const [selectedRange, setRange] = useState({});
Expand All @@ -12,9 +12,12 @@ const App = () => {
onSelectDateRange={range => {
setRange(range);
}}
blockSingleDateSelection={true}
responseFormat="YYYY-MM-DD"
maxDate={moment()}
minDate={moment().subtract(100, 'days')}
selectedDateContainerStyle={styles.selectedDateContainerStyle}
selectedDateStyle={styles.selectedDateStyle}
/>
<View style={styles.container}>
<Text>first date: {selectedRange.firstDate}</Text>
Expand All @@ -29,6 +32,17 @@ const styles = StyleSheet.create({
container: {
margin: 50,
},
selectedDateContainerStyle: {
height: 35,
width: '100%',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'blue',
},
selectedDateStyle: {
fontWeight: 'bold',
color: 'white',
},
});

export default App;
82 changes: 5 additions & 77 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
},
"dependencies": {
"moment": "^2.29.1",
"moment-range": "^4.0.2",
"react": "17.0.1",
"react-native": "0.64.2",
"rnv-date-range-picker": "^1.1.0"
"rn-select-date-range": "^1.1.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-select-date-range",
"version": "1.0.0",
"version": "1.3.0",
"description": "A simple and fully customizable React Native date range picker component",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -43,7 +43,6 @@
"metro-react-native-babel-preset": "^0.66.0"
},
"dependencies": {
"moment": "^2.29.1",
"moment-range": "^4.0.2"
"moment": "^2.29.1"
}
}
Binary file modified screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from "react";
import { TouchableOpacity, Text, StyleSheet } from "react-native";

export default ({ lable, onPress = () => {}, align, disabled = false }) => {
const textStyle = { textAlign: align, opacity: disabled ? 0.2 : 1 };

return (
<TouchableOpacity
disabled={disabled}
style={styles.buttonContainer}
onPress={() => onPress()}
>
<Text style={{ textAlign: align, opacity: disabled ? 0.2 : 1 }}>
{lable}
</Text>
<Text style={textStyle}>{lable}</Text>
</TouchableOpacity>
);
};
Expand Down
Loading

0 comments on commit 00c2867

Please sign in to comment.