@ -1,4 +1,4 @@ | |||
module.exports = { | |||
root: true, | |||
extends: '@react-native-community', | |||
}; | |||
} |
@ -1 +1 @@ | |||
{} | |||
{} |
@ -1,4 +1,4 @@ | |||
{ | |||
"name": "rn602", | |||
"displayName": "DatePicker" | |||
"name": "rn602", | |||
"displayName": "DatePicker" | |||
} |
@ -1,3 +1,3 @@ | |||
module.exports = { | |||
presets: ['module:metro-react-native-babel-preset'], | |||
}; | |||
} |
@ -1,9 +1,5 @@ | |||
/** | |||
* @format | |||
*/ | |||
import { AppRegistry } from 'react-native' | |||
import App from './src/App' | |||
import { name as appName } from './app.json' | |||
import {AppRegistry} from 'react-native'; | |||
import App from './src/App'; | |||
import {name as appName} from './app.json'; | |||
AppRegistry.registerComponent(appName, () => App); | |||
AppRegistry.registerComponent(appName, () => App) |
@ -1,28 +1,28 @@ | |||
{ | |||
"name": "rn602", | |||
"version": "0.0.1", | |||
"private": true, | |||
"scripts": { | |||
"start": "react-native start", | |||
"test": "jest", | |||
"lint": "eslint ." | |||
}, | |||
"dependencies": { | |||
"react": "16.8.6", | |||
"react-native": "0.60.3", | |||
"react-native-date-picker": "^2.5.0" | |||
}, | |||
"devDependencies": { | |||
"@babel/core": "^7.5.4", | |||
"@babel/runtime": "^7.5.4", | |||
"@react-native-community/eslint-config": "^0.0.5", | |||
"babel-jest": "^24.8.0", | |||
"eslint": "^6.0.1", | |||
"jest": "^24.8.0", | |||
"metro-react-native-babel-preset": "^0.55.0", | |||
"react-test-renderer": "16.8.6" | |||
}, | |||
"jest": { | |||
"preset": "react-native" | |||
} | |||
"name": "rn602", | |||
"version": "0.0.1", | |||
"private": true, | |||
"scripts": { | |||
"start": "react-native start", | |||
"test": "jest", | |||
"lint": "eslint ." | |||
}, | |||
"dependencies": { | |||
"react": "16.8.6", | |||
"react-native": "0.60.3", | |||
"react-native-date-picker": "^2.6.1" | |||
}, | |||
"devDependencies": { | |||
"@babel/core": "^7.5.4", | |||
"@babel/runtime": "^7.5.4", | |||
"@react-native-community/eslint-config": "^0.0.5", | |||
"babel-jest": "^24.8.0", | |||
"eslint": "^6.0.1", | |||
"jest": "^24.8.0", | |||
"metro-react-native-babel-preset": "^0.55.0", | |||
"react-test-renderer": "16.8.6" | |||
}, | |||
"jest": { | |||
"preset": "react-native" | |||
} | |||
} |
@ -1,4 +1,6 @@ | |||
import React, { Component } from 'react'; | |||
import { Button } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { Button } from 'react-native' | |||
export const PropButton = ({ title, value, onChange }) => <Button title={title} onPress={() => onChange(value)} /> | |||
export const PropButton = ({ title, value, onChange }) => ( | |||
<Button title={title} onPress={() => onChange(value)} /> | |||
) |
@ -1,56 +1,63 @@ | |||
import React, { Component } from 'react'; | |||
import { Dimensions, FlatList, StyleSheet, Text, TouchableOpacity } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { | |||
Dimensions, | |||
FlatList, | |||
StyleSheet, | |||
Text, | |||
TouchableOpacity, | |||
} from 'react-native' | |||
const { width, height } = Dimensions.get('screen') | |||
export default class PropSlider extends Component { | |||
render() { | |||
return ( | |||
<FlatList | |||
horizontal | |||
style={styles.list} | |||
data={this.data()} | |||
renderItem={this.renderItem} | |||
contentContainerStyle={styles.content} | |||
keyExtractor={item => item.name} | |||
/> | |||
) | |||
} | |||
data = () => this.props.data.map(prop => (prop.selected = this.props.selectedProp === prop.name, prop)) | |||
onPress = index => () => this.props.onSelect(this.props.data[index].name) | |||
renderItem = ({ item, index }) => ( | |||
<TouchableOpacity | |||
key={item.name} | |||
style={[styles.item, this.getStyle(item)]} | |||
onPress={this.onPress(index)} | |||
> | |||
<Text key={item.name}>{item.name}</Text> | |||
</TouchableOpacity> | |||
render() { | |||
return ( | |||
<FlatList | |||
horizontal | |||
style={styles.list} | |||
data={this.data()} | |||
renderItem={this.renderItem} | |||
contentContainerStyle={styles.content} | |||
keyExtractor={item => item.name} | |||
/> | |||
) | |||
} | |||
getStyle = (item) => ({ | |||
backgroundColor: item.selected ? '#82e584' : '#abcdef', | |||
width: this.props.width ? this.props.width : 100, | |||
height: 30, | |||
}) | |||
data = () => | |||
this.props.data.map( | |||
prop => ((prop.selected = this.props.selectedProp === prop.name), prop) | |||
) | |||
onPress = index => () => this.props.onSelect(this.props.data[index].name) | |||
renderItem = ({ item, index }) => ( | |||
<TouchableOpacity | |||
key={item.name} | |||
style={[styles.item, this.getStyle(item)]} | |||
onPress={this.onPress(index)} | |||
> | |||
<Text key={item.name}>{item.name}</Text> | |||
</TouchableOpacity> | |||
) | |||
getStyle = item => ({ | |||
backgroundColor: item.selected ? '#82e584' : '#abcdef', | |||
width: this.props.width ? this.props.width : 100, | |||
height: 30, | |||
}) | |||
} | |||
const styles = StyleSheet.create({ | |||
list: { | |||
width, | |||
}, | |||
content: { | |||
padding: 20, | |||
}, | |||
item: { | |||
justifyContent: 'center', | |||
alignItems: 'center', | |||
marginHorizontal: 5, | |||
borderRadius: 10, | |||
}, | |||
}) | |||
list: { | |||
width, | |||
}, | |||
content: { | |||
padding: 20, | |||
}, | |||
item: { | |||
justifyContent: 'center', | |||
alignItems: 'center', | |||
marginHorizontal: 5, | |||
borderRadius: 10, | |||
}, | |||
}) |
@ -1,6 +1,6 @@ | |||
export const EXAMPLE_KEYS = { | |||
MINIMAL : 'MINIMAL', | |||
ADVANCED : 'ADVANCED', | |||
TIME_MODE : 'TIME_MODE', | |||
DATE_MODE : 'DATE_MODE', | |||
} | |||
MINIMAL: 'MINIMAL', | |||
ADVANCED: 'ADVANCED', | |||
TIME_MODE: 'TIME_MODE', | |||
DATE_MODE: 'DATE_MODE', | |||
} |
@ -1,15 +1,14 @@ | |||
import React, { Component } from 'react'; | |||
import DatePicker from 'react-native-date-picker'; | |||
import React, { Component } from 'react' | |||
import DatePicker from 'react-native-date-picker' | |||
export default class DateMode extends Component { | |||
state = { date: new Date() } | |||
render = () => | |||
render = () => ( | |||
<DatePicker | |||
date={this.state.date} | |||
onDateChange={date => this.setState({ date })} | |||
mode={'date'} | |||
/> | |||
) | |||
} |
@ -1,14 +1,13 @@ | |||
import React, { Component } from 'react'; | |||
import DatePicker from 'react-native-date-picker'; | |||
import React, { Component } from 'react' | |||
import DatePicker from 'react-native-date-picker' | |||
export default class MinimalExample extends Component { | |||
state = { date: new Date() } | |||
render = () => | |||
render = () => ( | |||
<DatePicker | |||
date={this.state.date} | |||
onDateChange={date => this.setState({ date })} | |||
onDateChange={date => this.setState({ date })} | |||
/> | |||
) | |||
} |
@ -1,15 +1,14 @@ | |||
import React, { Component } from 'react'; | |||
import DatePicker from 'react-native-date-picker'; | |||
import React, { Component } from 'react' | |||
import DatePicker from 'react-native-date-picker' | |||
export default class TimeMode extends Component { | |||
state = { date: new Date() } | |||
render = () => | |||
render = () => ( | |||
<DatePicker | |||
date={this.state.date} | |||
onDateChange={date => this.setState({ date })} | |||
mode={'time'} | |||
/> | |||
) | |||
} |
@ -1,212 +1,212 @@ | |||
export default [ | |||
'af-ZA', | |||
'am-ET', | |||
'ar-AE', | |||
'ar-BH', | |||
'ar-DZ', | |||
'ar-EG', | |||
'ar-IQ', | |||
'ar-JO', | |||
'ar-KW', | |||
'ar-LB', | |||
'ar-LY', | |||
'ar-MA', | |||
'arn-CL', | |||
'ar-OM', | |||
'ar-QA', | |||
'ar-SA', | |||
'ar-SY', | |||
'ar-TN', | |||
'ar-YE', | |||
'as-IN', | |||
'az-Cyrl-AZ', | |||
'az-Latn-AZ', | |||
'ba-RU', | |||
'be-BY', | |||
'bg-BG', | |||
'bn-BD', | |||
'bn-IN', | |||
'bo-CN', | |||
'br-FR', | |||
'bs-Cyrl-BA', | |||
'bs-Latn-BA', | |||
'ca-ES', | |||
'co-FR', | |||
'cs-CZ', | |||
'cy-GB', | |||
'da-DK', | |||
'de-AT', | |||
'de-CH', | |||
'de-DE', | |||
'de-LI', | |||
'de-LU', | |||
'dsb-DE', | |||
'dv-MV', | |||
'el-GR', | |||
'en-029', | |||
'en-AU', | |||
'en-BZ', | |||
'en-CA', | |||
'en-GB', | |||
'en-IE', | |||
'en-IN', | |||
'en-JM', | |||
'en-MY', | |||
'en-NZ', | |||
'en-PH', | |||
'en-SG', | |||
'en-TT', | |||
'en-US', | |||
'en-ZA', | |||
'en-ZW', | |||
'es-AR', | |||
'es-BO', | |||
'es-CL', | |||
'es-CO', | |||
'es-CR', | |||
'es-DO', | |||
'es-EC', | |||
'es-ES', | |||
'es-GT', | |||
'es-HN', | |||
'es-MX', | |||
'es-NI', | |||
'es-PA', | |||
'es-PE', | |||
'es-PR', | |||
'es-PY', | |||
'es-SV', | |||
'es-US', | |||
'es-UY', | |||
'es-VE', | |||
'et-EE', | |||
'eu-ES', | |||
'fa-IR', | |||
'fi-FI', | |||
'fil-PH', | |||
'fo-FO', | |||
'fr-BE', | |||
'fr-CA', | |||
'fr-CH', | |||
'fr-FR', | |||
'fr-LU', | |||
'fr-MC', | |||
'fy-NL', | |||
'ga-IE', | |||
'gd-GB', | |||
'gl-ES', | |||
'gsw-FR', | |||
'gu-IN', | |||
'ha-Latn-NG', | |||
'he-IL', | |||
'hi-IN', | |||
'hr-BA', | |||
'hr-HR', | |||
'hsb-DE', | |||
'hu-HU', | |||
'hy-AM', | |||
'id-ID', | |||
'ig-NG', | |||
'ii-CN', | |||
'is-IS', | |||
'it-CH', | |||
'it-IT', | |||
'iu-Cans-CA', | |||
'iu-Latn-CA', | |||
'ja-JP', | |||
'ka-GE', | |||
'kk-KZ', | |||
'kl-GL', | |||
'km-KH', | |||
'kn-IN', | |||
'kok-IN', | |||
'ko-KR', | |||
'ky-KG', | |||
'lb-LU', | |||
'lo-LA', | |||
'lt-LT', | |||
'lv-LV', | |||
'mi-NZ', | |||
'mk-MK', | |||
'ml-IN', | |||
'mn-MN', | |||
'mn-Mong-CN', | |||
'moh-CA', | |||
'mr-IN', | |||
'ms-BN', | |||
'ms-MY', | |||
'mt-MT', | |||
'nb-NO', | |||
'ne-NP', | |||
'nl-BE', | |||
'nl-NL', | |||
'nn-NO', | |||
'nso-ZA', | |||
'oc-FR', | |||
'or-IN', | |||
'pa-IN', | |||
'pl-PL', | |||
'prs-AF', | |||
'ps-AF', | |||
'pt-BR', | |||
'pt-PT', | |||
'qut-GT', | |||
'quz-BO', | |||
'quz-EC', | |||
'quz-PE', | |||
'rm-CH', | |||
'ro-RO', | |||
'ru-RU', | |||
'rw-RW', | |||
'sah-RU', | |||
'sa-IN', | |||
'se-FI', | |||
'se-NO', | |||
'se-SE', | |||
'si-LK', | |||
'sk-SK', | |||
'sl-SI', | |||
'sma-NO', | |||
'sma-SE', | |||
'smj-NO', | |||
'smj-SE', | |||
'smn-FI', | |||
'sms-FI', | |||
'sq-AL', | |||
'sr-Cyrl-BA', | |||
'sr-Cyrl-CS', | |||
'sr-Cyrl-ME', | |||
'sr-Cyrl-RS', | |||
'sr-Latn-BA', | |||
'sr-Latn-CS', | |||
'sr-Latn-ME', | |||
'sr-Latn-RS', | |||
'sv-FI', | |||
'sv-SE', | |||
'sw-KE', | |||
'syr-SY', | |||
'ta-IN', | |||
'te-IN', | |||
'tg-Cyrl-TJ', | |||
'th-TH', | |||
'tk-TM', | |||
'tn-ZA', | |||
'tr-TR', | |||
'tt-RU', | |||
'tzm-Latn-DZ', | |||
'ug-CN', | |||
'uk-UA', | |||
'ur-PK', | |||
'uz-Cyrl-UZ', | |||
'uz-Latn-UZ', | |||
'vi-VN', | |||
'wo-SN', | |||
'xh-ZA', | |||
'yo-NG', | |||
'zh-CN', | |||
'zh-HK', | |||
'zh-MO', | |||
'zh-SG', | |||
'zh-TW', | |||
'zu-ZA', | |||
] | |||
'af-ZA', | |||
'am-ET', | |||
'ar-AE', | |||
'ar-BH', | |||
'ar-DZ', | |||
'ar-EG', | |||
'ar-IQ', | |||
'ar-JO', | |||
'ar-KW', | |||
'ar-LB', | |||
'ar-LY', | |||
'ar-MA', | |||
'arn-CL', | |||
'ar-OM', | |||
'ar-QA', | |||
'ar-SA', | |||
'ar-SY', | |||
'ar-TN', | |||
'ar-YE', | |||
'as-IN', | |||
'az-Cyrl-AZ', | |||
'az-Latn-AZ', | |||
'ba-RU', | |||
'be-BY', | |||
'bg-BG', | |||
'bn-BD', | |||
'bn-IN', | |||
'bo-CN', | |||
'br-FR', | |||
'bs-Cyrl-BA', | |||
'bs-Latn-BA', | |||
'ca-ES', | |||
'co-FR', | |||
'cs-CZ', | |||
'cy-GB', | |||
'da-DK', | |||
'de-AT', | |||
'de-CH', | |||
'de-DE', | |||
'de-LI', | |||
'de-LU', | |||
'dsb-DE', | |||
'dv-MV', | |||
'el-GR', | |||
'en-029', | |||
'en-AU', | |||
'en-BZ', | |||
'en-CA', | |||
'en-GB', | |||
'en-IE', | |||
'en-IN', | |||
'en-JM', | |||
'en-MY', | |||
'en-NZ', | |||
'en-PH', | |||
'en-SG', | |||
'en-TT', | |||
'en-US', | |||
'en-ZA', | |||
'en-ZW', | |||
'es-AR', | |||
'es-BO', | |||
'es-CL', | |||
'es-CO', | |||
'es-CR', | |||
'es-DO', | |||
'es-EC', | |||
'es-ES', | |||
'es-GT', | |||
'es-HN', | |||
'es-MX', | |||
'es-NI', | |||
'es-PA', | |||
'es-PE', | |||
'es-PR', | |||
'es-PY', | |||
'es-SV', | |||
'es-US', | |||
'es-UY', | |||
'es-VE', | |||
'et-EE', | |||
'eu-ES', | |||
'fa-IR', | |||
'fi-FI', | |||
'fil-PH', | |||
'fo-FO', | |||
'fr-BE', | |||
'fr-CA', | |||
'fr-CH', | |||
'fr-FR', | |||
'fr-LU', | |||
'fr-MC', | |||
'fy-NL', | |||
'ga-IE', | |||
'gd-GB', | |||
'gl-ES', | |||
'gsw-FR', | |||
'gu-IN', | |||
'ha-Latn-NG', | |||
'he-IL', | |||
'hi-IN', | |||
'hr-BA', | |||
'hr-HR', | |||
'hsb-DE', | |||
'hu-HU', | |||
'hy-AM', | |||
'id-ID', | |||
'ig-NG', | |||
'ii-CN', | |||
'is-IS', | |||
'it-CH', | |||
'it-IT', | |||
'iu-Cans-CA', | |||
'iu-Latn-CA', | |||
'ja-JP', | |||
'ka-GE', | |||
'kk-KZ', | |||
'kl-GL', | |||
'km-KH', | |||
'kn-IN', | |||
'kok-IN', | |||
'ko-KR', | |||
'ky-KG', | |||
'lb-LU', | |||
'lo-LA', | |||
'lt-LT', | |||
'lv-LV', | |||
'mi-NZ', | |||
'mk-MK', | |||
'ml-IN', | |||
'mn-MN', | |||
'mn-Mong-CN', | |||
'moh-CA', | |||
'mr-IN', | |||
'ms-BN', | |||
'ms-MY', | |||
'mt-MT', | |||
'nb-NO', | |||
'ne-NP', | |||
'nl-BE', | |||
'nl-NL', | |||
'nn-NO', | |||
'nso-ZA', | |||
'oc-FR', | |||
'or-IN', | |||
'pa-IN', | |||
'pl-PL', | |||
'prs-AF', | |||
'ps-AF', | |||
'pt-BR', | |||
'pt-PT', | |||
'qut-GT', | |||
'quz-BO', | |||
'quz-EC', | |||
'quz-PE', | |||
'rm-CH', | |||
'ro-RO', | |||
'ru-RU', | |||
'rw-RW', | |||
'sah-RU', | |||
'sa-IN', | |||
'se-FI', | |||
'se-NO', | |||
'se-SE', | |||
'si-LK', | |||
'sk-SK', | |||
'sl-SI', | |||
'sma-NO', | |||
'sma-SE', | |||
'smj-NO', | |||
'smj-SE', | |||
'smn-FI', | |||
'sms-FI', | |||
'sq-AL', | |||
'sr-Cyrl-BA', | |||
'sr-Cyrl-CS', | |||
'sr-Cyrl-ME', | |||
'sr-Cyrl-RS', | |||
'sr-Latn-BA', | |||
'sr-Latn-CS', | |||
'sr-Latn-ME', | |||
'sr-Latn-RS', | |||
'sv-FI', | |||
'sv-SE', | |||
'sw-KE', | |||
'syr-SY', | |||
'ta-IN', | |||
'te-IN', | |||
'tg-Cyrl-TJ', | |||
'th-TH', | |||
'tk-TM', | |||
'tn-ZA', | |||
'tr-TR', | |||
'tt-RU', | |||
'tzm-Latn-DZ', | |||
'ug-CN', | |||
'uk-UA', | |||
'ur-PK', | |||
'uz-Cyrl-UZ', | |||
'uz-Latn-UZ', | |||
'vi-VN', | |||
'wo-SN', | |||
'xh-ZA', | |||
'yo-NG', | |||
'zh-CN', | |||
'zh-HK', | |||
'zh-MO', | |||
'zh-SG', | |||
'zh-TW', | |||
'zu-ZA', | |||
] |
@ -1,26 +1,45 @@ | |||
import React, { Component } from 'react'; | |||
import { Dimensions, Button, View, StyleSheet, ScrollView, Text, TouchableOpacity } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { | |||
Dimensions, | |||
Button, | |||
View, | |||
StyleSheet, | |||
ScrollView, | |||
Text, | |||
TouchableOpacity, | |||
} from 'react-native' | |||
export default class extends Component { | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
<Button title='Add 1 min' | |||
onPress={() => this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 1000) | |||
)} /> | |||
<Text /> | |||
<Button title='Add 1 hour' | |||
onPress={() => this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 60 * 1000) | |||
)} /> | |||
<Text /> | |||
<Button title='Add 24 hours' | |||
onPress={() => this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 60 * 24 * 1000) | |||
)} /> | |||
</React.Fragment> | |||
); | |||
} | |||
} | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
<Button | |||
title="Add 1 min" | |||
onPress={() => | |||
this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 1000) | |||
) | |||
} | |||
/> | |||
<Text /> | |||
<Button | |||
title="Add 1 hour" | |||
onPress={() => | |||
this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 60 * 1000) | |||
) | |||
} | |||
/> | |||
<Text /> | |||
<Button | |||
title="Add 24 hours" | |||
onPress={() => | |||
this.props.onChange( | |||
new Date(this.props.value.getTime() + 60 * 60 * 24 * 1000) | |||
) | |||
} | |||
/> | |||
</React.Fragment> | |||
) | |||
} | |||
} |
@ -1,12 +1,8 @@ | |||
import React, { Component } from 'react'; | |||
import { Button } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { Button } from 'react-native' | |||
export default class extends Component { | |||
render() { | |||
return ( | |||
<Button title={'Change color'} onPress={this.props.onChange} /> | |||
); | |||
} | |||
} | |||
render() { | |||
return <Button title={'Change color'} onPress={this.props.onChange} /> | |||
} | |||
} |
@ -1,40 +1,39 @@ | |||
import React, { Component } from 'react'; | |||
import locales from '../locales'; | |||
import PropSlider from '../PropSlider'; | |||
import React, { Component } from 'react' | |||
import locales from '../locales' | |||
import PropSlider from '../PropSlider' | |||
const data = locales.map(key => ({ name: key })); | |||
const data = locales.map(key => ({ name: key })) | |||
const split1 = Math.floor(data.length / 3); | |||
const split2 = Math.floor(2 * data.length / 3); | |||
const split1 = Math.floor(data.length / 3) | |||
const split2 = Math.floor((2 * data.length) / 3) | |||
const data1 = data.slice(0, split1); | |||
const data2 = data.slice(split1, split2); | |||
const data3 = data.slice(split2); | |||
const data1 = data.slice(0, split1) | |||
const data2 = data.slice(split1, split2) | |||
const data3 = data.slice(split2) | |||
export default class LocalPicker extends Component { | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data1} | |||
width={50} | |||
/> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data2} | |||
width={50} | |||
/> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data3} | |||
width={50} | |||
/> | |||
</React.Fragment> | |||
); | |||
} | |||
} | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data1} | |||
width={50} | |||
/> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data2} | |||
width={50} | |||
/> | |||
<PropSlider | |||
selectedProp={this.props.locale} | |||
onSelect={this.props.onChange} | |||
data={data3} | |||
width={50} | |||
/> | |||
</React.Fragment> | |||
) | |||
} | |||
} |
@ -1,41 +1,55 @@ | |||
import React, { Component } from 'react'; | |||
import { Text, Button, View, StyleSheet } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { Text, Button, View, StyleSheet } from 'react-native' | |||
import { readableDate } from '../examples/Advanced' | |||
import { PropButton } from '../PropButton'; | |||
import { PropButton } from '../PropButton' | |||
export default class extends Component { | |||
render() { | |||
const { onChange, defaultDate } = this.props | |||
return ( | |||
<React.Fragment> | |||
<Text>{readableDate(this.props.value)}</Text> | |||
<View style={styles.row}> | |||
{this.renderButton('-1 hour', -1)} | |||
{this.renderButton('+1 hour', 1)} | |||
</View> | |||
<View style={styles.row}> | |||
{this.renderButton('-1 day', -24)} | |||
{this.renderButton('+1 day', 24)} | |||
</View> | |||
<View style={styles.row}> | |||
<PropButton | |||
title="Set undefined" | |||
value={undefined} | |||
onChange={onChange} | |||
/> | |||
<PropButton | |||
title="Set default" | |||
value={defaultDate} | |||
onChange={onChange} | |||
/> | |||
</View> | |||
</React.Fragment> | |||
) | |||
} | |||
render() { | |||
const { onChange, defaultDate } = this.props; | |||
return ( | |||
<React.Fragment> | |||
<Text>{readableDate(this.props.value)}</Text> | |||
<View style={styles.row} > | |||
{this.renderButton('-1 hour', -1)} | |||
{this.renderButton('+1 hour', 1)} | |||
</View> | |||
<View style={styles.row} > | |||
{this.renderButton('-1 day', -24)} | |||
{this.renderButton('+1 day', 24)} | |||
</View> | |||
<View style={styles.row} > | |||
<PropButton title='Set undefined' value={undefined} onChange={onChange} /> | |||
<PropButton title='Set default' value={defaultDate} onChange={onChange} /> | |||
</View> | |||
</React.Fragment > | |||
) | |||
} | |||
renderButton = (title, hourDiff) => <PropButton title={title} onChange={this.props.onChange} | |||
value={this.props.value && new Date(this.props.value.getTime()).addHours(hourDiff)} /> | |||
renderButton = (title, hourDiff) => ( | |||
<PropButton | |||
title={title} | |||
onChange={this.props.onChange} | |||
value={ | |||
this.props.value && | |||
new Date(this.props.value.getTime()).addHours(hourDiff) | |||
} | |||
/> | |||
) | |||
} | |||
const styles = StyleSheet.create({ | |||
row: { | |||
flexDirection: 'row', | |||
width: 300, | |||
justifyContent: 'space-between', | |||
margin: 5, | |||
} | |||
}) | |||
row: { | |||
flexDirection: 'row', | |||
width: 300, | |||
justifyContent: 'space-between', | |||
margin: 5, | |||
}, | |||
}) |
@ -1,18 +1,18 @@ | |||
import React, { Component } from 'react'; | |||
import {Button } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { Button } from 'react-native' | |||
export default class extends Component { | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
{[1, 5, 10, 15].map(minutes => | |||
<Button | |||
key={minutes} | |||
title={minutes + ' min'} | |||
onPress={() => this.props.onChange(minutes)} | |||
/>)} | |||
</React.Fragment> | |||
); | |||
} | |||
} | |||
render() { | |||
return ( | |||
<React.Fragment> | |||
{[1, 5, 10, 15].map(minutes => ( | |||
<Button | |||
key={minutes} | |||
title={minutes + ' min'} | |||
onPress={() => this.props.onChange(minutes)} | |||
/> | |||
))} | |||
</React.Fragment> | |||
) | |||
} | |||
} |
@ -1,22 +1,17 @@ | |||
import React, { Component } from 'react'; | |||
import PropSlider from '../PropSlider'; | |||
import React, { Component } from 'react' | |||
import PropSlider from '../PropSlider' | |||
const data = [ | |||
{ name: 'datetime' }, | |||
{ name: 'date' }, | |||
{ name: 'time' }, | |||
] | |||
const data = [{ name: 'datetime' }, { name: 'date' }, { name: 'time' }] | |||
export default class extends Component { | |||
render() { | |||
return ( | |||
<PropSlider | |||
selectedProp={this.props.selected} | |||
onSelect={this.props.onChange} | |||
data={data} | |||
width={100} | |||
/> | |||
); | |||
} | |||
} | |||
render() { | |||
return ( | |||
<PropSlider | |||
selectedProp={this.props.selected} | |||
onSelect={this.props.onChange} | |||
data={data} | |||
width={100} | |||
/> | |||
) | |||
} | |||
} |
@ -1,12 +1,8 @@ | |||
import React, { Component } from 'react'; | |||
import { Button } from 'react-native'; | |||
import React, { Component } from 'react' | |||
import { Button } from 'react-native' | |||
export default class extends Component { | |||
render() { | |||
return ( | |||
<Button title={'Change color'} onPress={this.props.onChange} /> | |||
); | |||
} | |||
} | |||
render() { | |||
return <Button title={'Change color'} onPress={this.props.onChange} /> | |||
} | |||
} |
@ -1,17 +1,20 @@ | |||
import React, { Component } from 'react'; | |||
import { PropButton } from '../PropButton'; | |||
import React, { Component } from 'react' | |||
import { PropButton } from '../PropButton' | |||
export default class extends Component { | |||
render() { | |||
const {onChange} = this.props | |||
return ( | |||
<React.Fragment> | |||
<PropButton title='Set undefined' value={undefined} onChange={onChange} /> | |||
<PropButton title='Set 0' value={0} onChange={onChange} /> | |||
<PropButton title='Set 180' value={180} onChange={onChange} /> | |||
<PropButton title='Set -180' value={-180} onChange={onChange} /> | |||
</React.Fragment> | |||
); | |||
} | |||
} | |||
render() { | |||
const { onChange } = this.props | |||
return ( | |||
<React.Fragment> | |||
<PropButton | |||
title="Set undefined" | |||
value={undefined} | |||
onChange={onChange} | |||
/> | |||
<PropButton title="Set 0" value={0} onChange={onChange} /> | |||
<PropButton title="Set 180" value={180} onChange={onChange} /> | |||
<PropButton title="Set -180" value={-180} onChange={onChange} /> | |||
</React.Fragment> | |||
) | |||
} | |||
} |
@ -1,7 +1,7 @@ | |||
/** @format */ | |||
import {AppRegistry} from 'react-native'; | |||
import App from './App'; | |||
import {name as appName} from './app.json'; | |||
import { AppRegistry } from 'react-native' | |||
import App from './App' | |||
import { name as appName } from './app.json' | |||
AppRegistry.registerComponent(appName, () => App); | |||
AppRegistry.registerComponent(appName, () => App) |
@ -1,19 +1,19 @@ | |||
describe('Example', () => { | |||
beforeEach(async () => { | |||
await device.reloadReactNative(); | |||
}); | |||
await device.reloadReactNative() | |||
}) | |||
it('should have welcome screen', async () => { | |||
await expect(element(by.id('welcome'))).toBeVisible(); | |||
}); | |||
await expect(element(by.id('welcome'))).toBeVisible() | |||
}) | |||
it('should show hello screen after tap', async () => { | |||
await element(by.id('hello_button')).tap(); | |||
await expect(element(by.text('Hello!!!'))).toBeVisible(); | |||
}); | |||
await element(by.id('hello_button')).tap() | |||
await expect(element(by.text('Hello!!!'))).toBeVisible() | |||
}) | |||
it('should show world screen after tap', async () => { | |||
await element(by.id('world_button')).tap(); | |||
await expect(element(by.text('World!!!'))).toBeVisible(); | |||
}); | |||
}); | |||
await element(by.id('world_button')).tap() | |||
await expect(element(by.text('World!!!'))).toBeVisible() | |||
}) | |||
}) |
@ -1,19 +1,19 @@ | |||
const detox = require('detox'); | |||
const config = require('../package.json').detox; | |||
const adapter = require('detox/runners/mocha/adapter'); | |||
const detox = require('detox') | |||
const config = require('../package.json').detox | |||
const adapter = require('detox/runners/mocha/adapter') | |||
before(async () => { | |||
await detox.init(config); | |||
}); | |||
await detox.init(config) | |||
}) | |||
beforeEach(async function () { | |||
await adapter.beforeEach(this); | |||
}); | |||
beforeEach(async function() { | |||
await adapter.beforeEach(this) | |||
}) | |||
afterEach(async function () { | |||
await adapter.afterEach(this); | |||
}); | |||
afterEach(async function() { | |||
await adapter.afterEach(this) | |||
}) | |||
after(async () => { | |||
await detox.cleanup(); | |||
}); | |||
await detox.cleanup() | |||
}) |
@ -1,26 +1,28 @@ | |||
const {device, expect, element, by, waitFor} = require('detox'); | |||
const { device, expect, element, by, waitFor } = require('detox') | |||
describe('Example', () => { | |||
beforeEach(async () => { | |||
await device.reloadReactNative(); | |||
}); | |||
await device.reloadReactNative() | |||
}) | |||
it('should have welcome screen', async () => { | |||
await expect(element(by.id('welcome'))).toBeVisible(); | |||
}); | |||
await expect(element(by.id('welcome'))).toBeVisible() | |||
}) | |||
it('should show hello screen after tap', async () => { | |||
await element(by.id('hello_button')).tap(); | |||
await expect(element(by.text('Hello!!!'))).toBeVisible(); | |||
}); | |||
await element(by.id('hello_button')).tap() | |||
await expect(element(by.text('Hello!!!'))).toBeVisible() | |||
}) | |||
it('should show world screen after tap', async () => { | |||
await element(by.id('world_button')).tap(); | |||
await expect(element(by.text('World!!!'))).toBeVisible(); | |||
}); | |||
await element(by.id('world_button')).tap() | |||
await expect(element(by.text('World!!!'))).toBeVisible() | |||
}) | |||
it('waitFor should be exported', async () => { | |||
await waitFor(element(by.id('welcome'))).toExist().withTimeout(2000); | |||
await expect(element(by.id('welcome'))).toExist(); | |||
}); | |||
}); | |||
await waitFor(element(by.id('welcome'))) | |||
.toExist() | |||
.withTimeout(2000) | |||
await expect(element(by.id('welcome'))).toExist() | |||
}) | |||
}) |
@ -1,14 +1,14 @@ | |||
const detox = require('detox'); | |||
const config = require('../package.json').detox; | |||
const detox = require('detox') | |||
const config = require('../package.json').detox | |||
/* | |||
Example showing how to use Detox with required objects rather than globally exported. | |||
e.g `const {device, expect, element, by, waitFor} = require('detox');` | |||
*/ | |||
before(async () => { | |||
await detox.init(config, {initGlobals: false}); | |||
}); | |||
await detox.init(config, { initGlobals: false }) | |||
}) | |||
after(async () => { | |||
await detox.cleanup(); | |||
}); | |||
await detox.cleanup() | |||
}) |
@ -1 +1 @@ | |||
require('./app'); | |||
require('./app') |
@ -1 +1 @@ | |||
require('./app'); | |||
require('./app') |
@ -1,12 +1,12 @@ | |||
let metroBundler; | |||
let metroBundler | |||
try { | |||
metroBundler = require('metro'); | |||
metroBundler = require('metro') | |||
} catch (ex) { | |||
metroBundler = require('metro-bundler'); | |||
metroBundler = require('metro-bundler') | |||
} | |||
module.exports = { | |||
getBlacklistRE: function() { | |||
return metroBundler.createBlacklist([/test\/.*/, /detox\/node_modules\/.*/]); | |||
} | |||
}; | |||
return metroBundler.createBlacklist([/test\/.*/, /detox\/node_modules\/.*/]) | |||
}, | |||
} |
@ -1,3 +1,3 @@ | |||
module.exports = { | |||
presets: ['module:metro-react-native-babel-preset'], | |||
}; | |||
} |
@ -1,3 +1,3 @@ | |||
module.exports = { | |||
presets: ['module:metro-react-native-babel-preset'], | |||
}; | |||
} |
@ -1,4 +1,4 @@ | |||
module.exports = { | |||
root: true, | |||
extends: '@react-native-community', | |||
}; | |||
} |
@ -1,3 +1,3 @@ | |||
module.exports = { | |||
presets: ['module:metro-react-native-babel-preset'], | |||
}; | |||
} |
@ -1,6 +1,5 @@ | |||
import { Platform } from 'react-native'; | |||
import DatePickerIOS from './DatePickerIOS'; | |||
import DatePickerAndroid from './DatePickerAndroid'; | |||
import { Platform } from 'react-native' | |||
import DatePickerIOS from './DatePickerIOS' | |||
import DatePickerAndroid from './DatePickerAndroid' | |||
export default Platform.OS === 'ios' ? DatePickerIOS : DatePickerAndroid |
@ -0,0 +1,5 @@ | |||
module.exports = { | |||
trailingComma: 'es5', | |||
semi: false, | |||
singleQuote: true, | |||
} |
@ -1,36 +1,43 @@ | |||
export function throwIfInvalidProps(props) { | |||
checks.forEach(check => check.validate(props)) | |||
checks.forEach(check => check.validate(props)) | |||
} | |||
class PropCheck { | |||
constructor(isInvalid, errorText) { | |||
this.isInvalid = isInvalid | |||
this.errorText = errorText | |||
} | |||
validate = (props) => { | |||
if (this.isInvalid(props)) { | |||
throw new Error(`${this.errorText} Check usage of react-native-date-picker.`) | |||
} | |||
constructor(isInvalid, errorText) { | |||
this.isInvalid = isInvalid | |||
this.errorText = errorText | |||
} | |||
validate = props => { | |||
if (this.isInvalid(props)) { | |||
throw new Error( | |||
`${this.errorText} Check usage of react-native-date-picker.` | |||
) | |||
} | |||
} | |||
} | |||
const widthCheck = new PropCheck( | |||
(props) => props && props.style && props.style.width && typeof props.style.width !== "number", | |||
"Invalid style: width. Width needs to be a number. Percentages or other values are not supported." | |||
props => | |||
props && | |||
props.style && | |||
props.style.width && | |||
typeof props.style.width !== 'number', | |||
'Invalid style: width. Width needs to be a number. Percentages or other values are not supported.' | |||
) | |||
const heightCheck = new PropCheck( | |||
(props) => props && props.style && props.style.height && typeof props.style.height !== "number", | |||
"Invalid style: height. Height needs to be a number. Percentages or other values are not supported." | |||
props => | |||
props && | |||
props.style && | |||
props.style.height && | |||
typeof props.style.height !== 'number', | |||
'Invalid style: height. Height needs to be a number. Percentages or other values are not supported.' | |||
) | |||
const modeCheck = new PropCheck( | |||
(props) => props && props.mode && !["datetime", "date", "time"].includes(props.mode), | |||
"Invalid mode. Valid modes: 'datetime', 'date', 'time'" | |||
props => | |||
props && props.mode && !['datetime', 'date', 'time'].includes(props.mode), | |||
"Invalid mode. Valid modes: 'datetime', 'date', 'time'" | |||
) | |||
const checks = [ | |||
widthCheck, | |||
heightCheck, | |||
modeCheck, | |||
] | |||
const checks = [widthCheck, heightCheck, modeCheck] |
@ -0,0 +1,13 @@ | |||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |||
# yarn lockfile v1 | |||
moment@^2.22.1: | |||
version "2.24.0" | |||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" | |||
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== | |||
prettier@^1.18.2: | |||
version "1.18.2" | |||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" | |||
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== |