Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
baf0a8e
Update README.md
henninghall Apr 16, 2020
e503e95
add zh_CN locale
TrustDec May 13, 2020
8829c12
Merge pull request #189 from TrustTheBoy/patch-1
henninghall May 13, 2020
8ba71ca
v2.7.10
henninghall May 13, 2020
481cf76
Fix return of wrong pattern piece
draperunner Jun 17, 2020
0ffe7ec
Merge pull request #195 from entur/fix-illegal-pattern-character
henninghall Jun 18, 2020
69bbb99
2.7.11
henninghall Jun 18, 2020
e4b5784
Fix zh_* locale parsing
mars-lan Jun 23, 2020
b181269
Merge pull request #198 from mars-lan/patch-1
henninghall Jun 27, 2020
ec530b2
2.7.12
henninghall Jun 27, 2020
32eabdf
first working version
henninghall Jul 5, 2020
9e49217
Change default date format for Finnish
Jul 7, 2020
a98b0d7
Change default weekdays format for Salmi
Jul 7, 2020
620eb57
Merge pull request #201 from hungneox/change-default-date-format-for-…
henninghall Jul 8, 2020
1bd41fd
2.7.13
henninghall Jul 8, 2020
37eb16d
progress
henninghall Jul 11, 2020
159a69e
update prop in example app
henninghall Jul 11, 2020
da67141
center
henninghall Jul 11, 2020
070d268
text size
henninghall Jul 11, 2020
6b3067f
divider color in example project
henninghall Jul 11, 2020
64168ce
scroll animation max min
henninghall Jul 11, 2020
66938fc
not editable
henninghall Jul 11, 2020
2a6564c
smaller font
henninghall Jul 11, 2020
1f8821a
event stability
henninghall Jul 11, 2020
f83b83d
text color
henninghall Jul 11, 2020
a8267f4
styles
henninghall Jul 11, 2020
3466f1f
ios clone as default
henninghall Jul 11, 2020
2d4d929
update docs
henninghall Jul 11, 2020
baa8758
add gif
henninghall Jul 11, 2020
9403a8e
Merge pull request #203 from henninghall/native-android-variant
henninghall Jul 11, 2020
5d05df8
Update README.md
henninghall Jul 11, 2020
868c6ca
Update README.md
henninghall Jul 11, 2020
631edc4
Update README.md
henninghall Jul 11, 2020
30df028
Update README.md
henninghall Jul 11, 2020
d04dfda
Update README.md
henninghall Jul 11, 2020
0d04dd9
3.0.0-beta.0
henninghall Jul 11, 2020
f511611
Update README.md
henninghall Jul 11, 2020
d5ae026
Update package.json
henninghall Jul 11, 2020
7fee84a
Bugfix: Prevent NullpointerException for some locales by using hard c…
henninghall Jul 12, 2020
e97c57d
Update README.md
henninghall Jul 12, 2020
6a4ab3d
fix native android wheel glitch
henninghall Jul 12, 2020
0eabc46
add badge
henninghall Jul 12, 2020
437b317
Fix android native wheel stop glitch
henninghall Jul 12, 2020
a5b6cae
Update package.json
henninghall Jul 12, 2020
ade5d8b
bugfix: scrolls beyond min/max date not always triggering onChange
henninghall Jul 12, 2020
4f6b483
Add missing androidVariant prop
mars-lan Jul 12, 2020
db7af03
Merge pull request #206 from mars-lan/patch-2
henninghall Jul 12, 2020
5980d4b
Specify the default value for androidVariant prop
mars-lan Jul 12, 2020
da7d410
Merge pull request #207 from mars-lan/patch-3
henninghall Jul 12, 2020
bd8c220
Merge pull request #208 from henninghall/scrolls-beyond-not-always-tr…
henninghall Jul 12, 2020
dedd03c
fixing failaing tests + prettier format tests
henninghall Jul 12, 2020
bdf3b2e
3.0.2
henninghall Jul 12, 2020
21b3472
Bump lodash from 4.17.15 to 4.17.19 in /examples/detox
dependabot[bot] Jul 17, 2020
ac3a313
custom am-pm width
henninghall Jul 26, 2020
8394a73
Merge pull request #211 from henninghall/dependabot/npm_and_yarn/exam…
henninghall Jul 26, 2020
cad62c8
Merge pull request #216 from henninghall/fix-am-pm-width
henninghall Jul 26, 2020
faaea93
set wheels as preferred date picker style
henninghall Jul 26, 2020
fac6702
Merge pull request #217 from henninghall/ios-14-fix
henninghall Jul 26, 2020
7f364fc
use same readme for npm and github
henninghall Jul 26, 2020
ba6da9a
3.0.3
henninghall Jul 26, 2020
4a0041c
add timezone offset tests
henninghall Jul 28, 2020
8a11f59
Merge pull request #218 from henninghall/timezone-offset-tests
henninghall Jul 28, 2020
24e228d
support different color formats (#219)
henninghall Jul 28, 2020
37c1338
larger touchable wheel area (#222)
henninghall Jul 31, 2020
fa0e40b
divider height prop (#220)
henninghall Jul 31, 2020
fcda7ea
remove duplicated meta method UIDatePickerMode (#225)
henninghall Aug 2, 2020
b84ccc5
bugfix: fast scroll flickering (#226)
henninghall Aug 2, 2020
ed846ff
3.1.0
henninghall Aug 2, 2020
fc67e05
fix datetime order pattern for vi-vn locale (#228)
kida7 Aug 20, 2020
91ca067
Update README.md
henninghall Aug 22, 2020
adb4d8e
add is24hourSource prop (#231)
henninghall Aug 22, 2020
db5939e
Npm readme (#232)
henninghall Aug 22, 2020
ab56007
3.2.0
henninghall Aug 22, 2020
69ca7de
fix picker width and wheel spacing (#234)
henninghall Aug 23, 2020
752edb1
3.2.1
henninghall Aug 23, 2020
21c054a
center 24h time mode wheels (#237)
henninghall Aug 29, 2020
28df5eb
3.2.2
henninghall Aug 29, 2020
310e84c
bugfix: onDateChange not called on tapped (#240)
henninghall Sep 10, 2020
ec84a5c
Update package.json
henninghall Sep 10, 2020
1151c20
Fix nynorsk (nn) locale by adding it to Formats (#250)
draperunner Oct 2, 2020
4a0d106
fix: Xcode 12 compatibility (#251)
vikrantnegi Oct 7, 2020
ba3705c
Removed dependency to moment.js (#242)
kentandersen Oct 12, 2020
c57fecf
3.2.4
henninghall Oct 12, 2020
f9d59c4
Update README.md
henninghall Oct 18, 2020
08a0e03
fix android compilation issues below sdk 26
henninghall Oct 18, 2020
95eca35
Merge pull request #255 from henninghall/fix-android-compilation-issues
henninghall Oct 18, 2020
3eaeac8
fix ios compilation issues
henninghall Oct 18, 2020
58e82d3
Merge pull request #256 from henninghall/ios-compilation-issues
henninghall Oct 18, 2020
aa30f8e
3.2.5
henninghall Oct 18, 2020
c09da74
bugfix: fadeToColor none
henninghall Dec 28, 2020
399bc45
v2
henninghall Dec 28, 2020
f2c1ce0
update detox
henninghall Dec 28, 2020
9f967bd
Merge pull request #279 from henninghall/fix-build
henninghall Dec 28, 2020
efe14d0
Merge remote-tracking branch 'origin/master' into fix-fadeToColor--none
henninghall Dec 28, 2020
257986e
Merge pull request #278 from henninghall/fix-fadeToColor--none
henninghall Dec 28, 2020
5547b72
3.2.6
henninghall Dec 28, 2020
26f7316
Bugfix: Scroll away from invalid dates (#280)
henninghall Dec 28, 2020
c3cae74
v3.2.7
henninghall Dec 28, 2020
0ed97fc
increase yarn timeout
henninghall Dec 28, 2020
7308bb1
Create codeql-analysis.yml
henninghall Dec 30, 2020
1612df6
codeql: change build working dir
henninghall Dec 30, 2020
51163cd
codeql attempt
henninghall Dec 30, 2020
7190661
remove codeql
henninghall Dec 30, 2020
b5f1de2
update dependencies (#282)
henninghall Dec 30, 2020
c428a2c
Update README.md
henninghall Jan 17, 2021
d8b89cd
Update README.md
henninghall Jan 17, 2021
3d54efe
Update README.md
henninghall Jan 17, 2021
2a9be30
fix: android native variant min/max scrolling issues (#286)
henninghall Jan 17, 2021
3c343ca
3.2.8
henninghall Jan 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
name: "Android: build & test"
name: 'Build & Test'

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build_and_test:
name: Build & test
javascript_unit_tests:
name: Unit tests - javascript
runs-on: macos-latest
timeout-minutes: 30
timeout-minutes: 5

steps:
- name: Checkout
Expand All @@ -17,29 +23,73 @@ jobs:
- name: Node
uses: actions/setup-node@v1

- name: Install npm dependencies
run: |
yarn install --frozen-lockfile

- name: Run unit tests
run: |
yarn test

java_unit_tests:
name: Unit tests - java
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Install npm dependencies
working-directory: ./examples/detox
run: |
yarn install --frozen-lockfile

- name: Run unit tests
working-directory: ./examples/detox/android
run: ./gradlew testDebugUnitTest

end_to_end_tests:
name: End to end tests
runs-on: macos-latest
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Node
uses: actions/setup-node@v2

- name: Use specific Java version for sdkmanager to work
uses: joschi/setup-jdk@v1
uses: joschi/setup-jdk@v2
with:
java-version: 'openjdk8'
architecture: 'x64'

- name: Install npm dependencies
working-directory: ./examples/detox
run: |
yarn install --frozen-lockfile --network-timeout 60000

- name: Download Android Emulator Image
timeout-minutes: 15
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-29;google_apis;x86"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd --force --name emu --device "Nexus 5X" -k 'system-images;android-29;google_apis;x86'
$ANDROID_HOME/emulator/emulator -list-avds

- name: Install npm dependencies
working-directory: ./examples/detox
run: |
yarn install --frozen-lockfile

- name: Build
working-directory: ./examples/detox
run: |
yarn build:android-ci

- name: Start android emulator
timeout-minutes: 5
working-directory: ./examples/detox
continue-on-error: true
run: |
Expand All @@ -48,13 +98,14 @@ jobs:
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
echo "Emulator started"

- name: Run tests

- name: Run e2e tests
timeout-minutes: 30
working-directory: ./examples/detox
run: yarn start & yarn test:android-ci

- name: Upload artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v2
if: failure()
with:
name: Failing tests
Expand Down
78 changes: 64 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# React Native Date Picker [![npm](https://img.shields.io/npm/v/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker) [![Build status](https://img.shields.io/github/workflow/status/henninghall/react-native-date-picker/Android:%20build%20&%20test?label=tests)](https://github.com/henninghall/react-native-date-picker/actions) [![npm](https://img.shields.io/npm/dm/react-native-date-picker.svg)](https://www.npmjs.com/package/react-native-date-picker)


This is a React Native Date Picker with following main features:

📱 Supporting iOS and Android <br>
Expand All @@ -11,27 +10,37 @@ This is a React Native Date Picker with following main features:
<table>
<tr>
<td align="center"><b>iOS</b></td>
<td align="center"><b>Android</b></td>
</tr>
<tr>
<td><img src="docs/react-native-date-picker.gif" alt="React Native Date Picker" title="React Native Date Picker" height="150px" />
</td>
</tr>

<tr>
<td align="center" colspan="2"><b>Android</b><br>Choose from 2 different variants</td>
</tr>
<tr>
<td><img src="docs/react-native-date-picker-android.gif" alt="React Native Date Picker Android" height="150px" style="margin-left:10px" />
</td>
</td>
<td><img src="docs/react-native-date-picker-android-native.gif" alt="React Native Datepicker" height="150px" style="margin-left:10px" />
</td>
</tr>
<tr>
<td align="center">A slightly improved DatePickerIOS.</td>
<td align="center">A custom made native component.</td>
<td align="center"><code>androidVariant="iosClone"</code></td><td align="center"><code>androidVariant="nativeAndroid"</code></td>
</tr>

</table>

## Installation

1. `npm install react-native-date-picker --save`
2. `react-native link react-native-date-picker` (Only needed for React Native <= 0.59)
1. ```npm install react-native-date-picker``` or ```yarn add react-native-date-picker```
1. `(cd ios && pod install)` (If you're using CocoaPods)
1. Rebuild the project (e.g. `react-native run-android` or `react-native run-ios`)

If you're having troubles after following these steps, there might be a <a href="https://github.com/henninghall/react-native-date-picker/#user-content-linking">linking issue</a> or you're <a href="https://github.com/henninghall/react-native-date-picker/#user-content-can-i-use-expo">using Expo</a>.

Xcode 11 is required to run the latest version of the date picker. Xcode 10 is supported up to version 2.7.2.
## Requirements

- Xcode >= 11.6

## Minimal Example

Expand Down Expand Up @@ -60,31 +69,42 @@ export default () => {
| date | The currently selected date. |
| onDateChange | Date change handler |
| fadeToColor | Android picker is fading towards this background color. {color, 'none'} |
| maximumDate | Maximum selectable date. |
| minimumDate | Minimum selectable date |
| maximumDate | Maximum selectable date. <br/> Example: `new Date("2021-12-31")` |
| minimumDate | Minimum selectable date. <br/> Example: `new Date("2021-01-01")` |
| androidVariant | Choose from 2 android style variants. {'iosClone', 'nativeAndroid'} (default: 'iosClone') | | <img src="docs/datetime-mode-android.png" alt="Datepicker ios clone variant" height="120px" /><img src="docs/react-native-date-picker-android.png" alt="Datepicker android native variant"/> |
| minuteInterval | The interval at which minutes can be selected. | <img src="docs/minute-interval-ios.png" alt="Date picker minute interval IOS" height="120px" /> | <img src="docs/minute-interval-android.png" alt="Date picker minute interval Android" height="120px" /> |
| mode | The date picker mode. {'datetime', 'date', 'time'} | <img src="docs/datetime-mode-ios.png" alt="React native date time picker" height="120px" /><img src="docs/date-mode-ios.png" alt="React native datepicker" height="120px" /><img src="docs/time-mode-ios.png" alt="React native time picker" height="120px" /> | <img src="docs/datetime-mode-android.png" alt="react native date time picker android" height="120px" /><img src="docs/date-mode-android.png" alt="react native datepicker android" height="120px" /><img src="docs/time-mode-android.png" alt="react native time picker android" height="120px" /> |
| locale | The locale for the date picker. Changes language, date order and am/pm preferences. Value needs to be a <a title="react native datepicker locale id" href="https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html">Locale ID.</a> | <img src="docs/locale-ios.png" alt="React Native Date picker locale language ios" height="120px" /> | <img src="docs/locale-android.png" alt="React Native Date picker locale language android" height="120px" /> |
| textColor | Changes the text color. ⚠ Colors other than black (#000000) or white (#ffffff) will replace the "Today" string with a date on iOS 13. | <img src="docs/colors-ios.png" alt="react native datepicker text color background color ios" height="120px" /> | <img src="docs/colors-android.png" alt="Text color background color android" height="120px" /> |
| textColor | Changes the text color. ⚠ Colors other than black (#000000) or white (#ffffff) will replace the "Today" string with a date on iOS 13 or higher. | <img src="docs/colors-ios.png" alt="react native datepicker text color background color ios" height="120px" /> | <img src="docs/colors-android.png" alt="Text color background color android" height="120px" /> |
| timeZoneOffsetInMinutes | Timezone offset in minutes (default: device's timezone) |
| dividerHeight | Change the divider height (only supported for iosClone) |
| is24hourSource | Change how the 24h mode (am/pm) should be determined, by device settings or by locale. {'locale', 'device'} (android only, default: 'device') |
## Linking
This package supports automatic linking. Usually, the only thing you need to do is to install the package, the cocoapods dependencies (as descripted above). Then rebuild the project by running `react-native run-ios`, `react-native run-android` or start the build from within Xcode/Android Studio. If you'running a React Native version below 0.60 or your setup is having issues with automatic linking, you can run `npx react-native link react-native-date-picker` and rebuild. In some occations you'll have to manually link the package. Instructions in <a href="https://github.com/henninghall/react-native-date-picker/issues/40">this issue</a>.

## About

📅 &nbsp; React Native Date Picker is a cross platform component working on both iOS and Android. It uses the slightly improved DatePickerIOS on iOS and a custom picker on Android which has similar look and feel. The datetime mode might be particulary interesting if you looking for a way to avoid two different popup pickers on android.

## FAQ

### How do I change the divider color?
The color of the divider, separator (or whatever you choose to call it) can only be changed on android for the androidNative variant. To change it, add the following to your android AppTheme. The theme is often found in styles.xml.
```xml
<item name="colorControlNormal">#ff0000</item>
```

### Can I use expo?

Unfortunately, expo does not support this date picker at the moment. Upvote <a href="https://expo.canny.io/feature-requests/p/support-react-native-date-picker">this feature request</a> if you would like to have it included.

### How do i change the date order? (To YYYY-MM-DD etc)

The order is determined by the `locale` prop. Set for instance `locale='fr'`to get the France preference.
The order is determined by the `locale` prop. Set for instance `locale='fr'`to get the french preference.

### How do i change the 12/24h or AM/PM format?

On iOS the 12/24h preference is determined by the `locale` prop. Set for instance `locale='fr'`to get the France preference. On Android the 12/24h format is determined by the device setting. When using 12h mode the AM/PM part of the picker will be displayed.
On iOS the 12/24h preference is determined by the `locale` prop. Set for instance `locale='fr'`to get the french preference. On Android the 12/24h format is determined by the device setting by default. Add `is24hourSource="locale"` to let the locale determine the device setting on android as well. When using 12h mode the AM/PM part of the picker will be displayed. It is NOT recommended to force any specific 12/24h format, but this can be achieved by, choosing a locale which has the desired 24h preference and add `is24hourSource="locale"`.

### Is it possible to show only month and year?

Expand All @@ -99,6 +119,36 @@ If you have enabled <a href="https://facebook.github.io/react-native/docs/signed
-keep public class net.time4j.PrettyTime
```

## Two different Android variants
On Android there are two design variants to choose from:

<table>
<tr><td align="center"><b>iOS clone</b></td><td align="center"><b>Native Android</b></td>
</tr><tr><td align="center">
<img src="docs/react-native-date-picker-android.gif" alt="date time picker" height="120px" />
</td><td align="center">
<img src="docs/react-native-date-picker-android-native.gif" alt="date time picker" height="120px" />
</td></tr>

<tr><td>The so called "iOS clone" looks and works similar to the ios version. It shows normaly 5 lines of dates. It is enabled by default.</td><td>
The "Android Native" version looks more like a standard native implementation on Android. The divider color can be changed by adding the following to you Android theme:
<br><code>&lt;item name=&quot;colorControlNormal&quot;&gt;#03b6fc&lt;/item&gt;</code>
</td></tr>
<tr><td>

```js
androidVariant="iosClone"
```
</td><td>

```js
androidVariant="nativeAndroid"
```
</td></tr>
</table>



## Three different modes
Here are some more info about the three different picker modes that are available.

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.facebook.react:react-native:+'
implementation 'com.henninghall.android:NumberPickerView:1.1.2'
implementation 'com.henninghall.android:NumberPickerView:1.1.5'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation group: 'net.time4j', name: 'time4j-android', version: '4.2-2018i'
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.henninghall.date_picker.props.DividerHeightProp;
import com.henninghall.date_picker.props.Is24hourSourceProp;
import com.henninghall.date_picker.props.VariantProp;
import com.henninghall.date_picker.props.DateProp;
import com.henninghall.date_picker.props.FadeToColorProp;
import com.henninghall.date_picker.props.LocaleProp;
Expand Down Expand Up @@ -41,7 +44,9 @@ public PickerView createViewInstance(ThemedReactContext reactContext) {
}

@ReactPropGroup(names = { DateProp.name, ModeProp.name, LocaleProp.name, MaximumDateProp.name,
MinimumDateProp.name, FadeToColorProp.name, TextColorProp.name, UtcProp.name, MinuteIntervalProp.name})
MinimumDateProp.name, FadeToColorProp.name, TextColorProp.name, UtcProp.name, MinuteIntervalProp.name,
VariantProp.name, DividerHeightProp.name, Is24hourSourceProp.name
})
public void setProps(PickerView view, int index, Dynamic value) {
updateProp("setProps", view, index, value);
}
Expand Down
Loading