Skip to content

Commit f9f1478

Browse files
Merge branch 'development' of github.com:web-ridge/react-native-paper-dates
2 parents 3069650 + ea461a2 commit f9f1478

File tree

108 files changed

+15594
-2262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+15594
-2262
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ android.iml
3838

3939
# Cocoapods
4040
#
41-
example/ios/Pods
41+
old-example/ios/Pods
4242

4343
# node.js
4444
#

CONTRIBUTING.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To get started with the project, run `yarn bootstrap` in the root directory to i
1010
yarn bootstrap
1111
```
1212

13-
While developing, you can run the [example app](/example/) to test your changes.
13+
While developing, you can run the [example app](/old-example/) to test your changes.
1414

1515
To start the packager:
1616

@@ -53,19 +53,6 @@ To edit the Objective-C files, open `example/ios/PaperDatesExample.xcworkspace`
5353

5454
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativepaperdates` under `Android`.
5555

56-
### Commit message convention
57-
58-
We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
59-
60-
- `fix`: bug fixes, e.g. fix crash due to deprecated method.
61-
- `feat`: new features, e.g. add new method to the module.
62-
- `refactor`: code refactor, e.g. migrate from class components to hooks.
63-
- `docs`: changes into documentation, e.g. add usage example for the module..
64-
- `test`: adding or updating tests, eg add integration tests using detox.
65-
- `chore`: tooling changes, e.g. change CI config.
66-
67-
Our pre-commit hooks verify that your commit message matches this format when committing.
68-
6956
### Linting and tests
7057

7158
[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)

README.md

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## react-native-paper-dates
22

3-
- Smooth and fast cross platform Material Design date picker for React Native Paper
3+
- Smooth and fast cross platform Material Design **date** picker and **time** picker for React Native Paper
44
- Tested on Android, iOS and the web platform!
55
- Uses the native Date.Intl API's which work out of the box on the web / iOS
66
- Simple API
77
- Typesafe
88
- Endless scrolling
99
- Performant
10+
- Great react-native-web support
1011

1112
Older demo of this library.
1213
<img src="https://user-images.githubusercontent.com/6492229/90681177-4970f280-e263-11ea-8257-6810c5166f92.gif"/>
@@ -66,8 +67,9 @@ function SingleDatePage() {
6667
onDismiss={onDismiss}
6768
date={date}
6869
onConfirm={onChange}
69-
saveLabel={'Save'} // optional
70-
label={'Select period'} // optional
70+
saveLabel="Save" // optional
71+
label="Select date" // optional
72+
animationType="slide" // optional, default is 'slide' on ios/android and 'none' on web
7173
/>
7274
<Button onPress={()=> setVisible(true)}>
7375
Pick date
@@ -98,16 +100,17 @@ export default function RangeDatePage() {
98100
return (
99101
<>
100102
<DatePickerModal
101-
mode="range"
102-
visible={visible}
103-
onDismiss={onDismiss}
104-
startDate={undefined}
105-
endDate={undefined}
106-
onConfirm={onChange}
107-
saveLabel={'Save'} // optional
108-
label={'Select period'} // optional
109-
startLabel={'From'} // optional
110-
endLabel={'To'} // optional
103+
mode="range"
104+
visible={visible}
105+
onDismiss={onDismiss}
106+
startDate={undefined}
107+
endDate={undefined}
108+
onConfirm={onChange}
109+
saveLabel="Save" // optional
110+
label="Select period" // optional
111+
startLabel="From" // optional
112+
endLabel="To" // optional
113+
animationType="slide" // optional, default is slide on ios/android and none on web
111114
/>
112115
<Button onPress={()=> setVisible(true)}>
113116
Pick range
@@ -118,11 +121,70 @@ export default function RangeDatePage() {
118121
```
119122

120123

124+
### Time picker
125+
```tsx
126+
import * as React from 'react'
127+
import { Button } from 'react-native-paper'
128+
import { TimePickerModal } from 'react-native-paper-dates'
129+
130+
export default function TimePickerPage() {
131+
const [visible, setVisible] = React.useState(false)
132+
const onDismiss = React.useCallback(() => {
133+
setVisible(false)
134+
}, [setVisible])
135+
136+
const onConfirm = React.useCallback(
137+
({ hours, minutes }) => {
138+
setVisible(false);
139+
console.log({ hours, minutes });
140+
},
141+
[setVisible]
142+
);
143+
144+
145+
return (
146+
<>
147+
<TimePickerModal
148+
visible={visible}
149+
onDismiss={onDismiss}
150+
onConfirm={onConfirm}
151+
hours={12} // default: current hours
152+
minutes={14} // default: current minutes
153+
label="Select time" // optional, default 'Select time'
154+
cancelLabel="Cancel" // optional, default: 'Cancel'
155+
confirmLabel="Ok" // optional, default: 'Ok'
156+
animationType="fade" // optional, default is 'none'
157+
/>
158+
<Button onPress={()=> setVisible(true)}>
159+
Pick time
160+
</Button>
161+
</>
162+
)
163+
}
164+
```
165+
166+
167+
168+
169+
121170

122171
## Roadmap
123-
Things on our roadmap are labeled with enhancement.
172+
Things on our roadmap have labels with `enhancement`.
124173
https://github.com/web-ridge/react-native-paper-dates/issues
125174

175+
## Tips & Tricks
176+
- Use 0.14+ version of React-Native-Web (Modal and better number input)
177+
- Try to avoid putting the pickers inside of a scrollView
178+
If that is **not possible** use the following props on the surrounding ScrollViews/Flatlists
179+
180+
```javascript
181+
keyboardDismissMode="on-drag"
182+
keyboardShouldPersistTaps="handled"
183+
contentInsetAdjustmentBehavior="always"
184+
```
185+
This is to prevent the need to press 2 times before save works (1 press for closing keyboard, 1 press for confirm/close)
186+
(https://github.com/facebook/react-native/issues/10138)
187+
126188
## Android Caveats
127189

128190
You will need to add a polyfill for the Intl API on Android if:

example/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

example/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

example/.flowconfig

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
14+
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
20+
21+
[include]
22+
23+
[libs]
24+
node_modules/react-native/interface.js
25+
node_modules/react-native/flow/
26+
27+
[options]
28+
emoji=true
29+
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
32+
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
36+
37+
munge_underscores=true
38+
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
41+
42+
suppress_type=$FlowIssue
43+
suppress_type=$FlowFixMe
44+
suppress_type=$FlowFixMeProps
45+
suppress_type=$FlowFixMeState
46+
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50+
51+
[lints]
52+
sketchy-null-number=warn
53+
sketchy-null-mixed=warn
54+
sketchy-number=warn
55+
untyped-type-import=warn
56+
nonstrict-import=warn
57+
deprecated-type=warn
58+
unsafe-getters-setters=warn
59+
unnecessary-invariant=warn
60+
signature-verification-failure=warn
61+
deprecated-utility=error
62+
63+
[strict]
64+
deprecated-type
65+
nonstrict-import
66+
sketchy-null
67+
unclear-type
68+
unsafe-getters-setters
69+
untyped-import
70+
untyped-type-import
71+
72+
[version]
73+
^0.122.0

example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# Android/IntelliJ
25+
#
26+
build/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
yarn-error.log
37+
38+
# BUCK
39+
buck-out/
40+
\.buckd/
41+
*.keystore
42+
!debug.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/

example/.prettierrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
trailingComma: 'es5',
3+
tabWidth: 2,
4+
semi: true,
5+
singleQuote: true,
6+
useTabs: false,
7+
printWidth: 80,
8+
jsxBracketSameLine: false,
9+
};

0 commit comments

Comments
 (0)