Skip to content

Commit

Permalink
added fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
lfkwtz committed Sep 20, 2019
1 parent aceea45 commit 2014e0b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
41 changes: 31 additions & 10 deletions demoApp/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {Component} from 'react';
import React, {Component, Fragment} from 'react';
import {
Button,
View,
Expand Down Expand Up @@ -32,6 +32,10 @@ export default class App extends Component {
type: 'day',
value: '',
},
birthday_year: {
type: 'year',
value: '',
},
state: {
type: 'state',
value: '',
Expand Down Expand Up @@ -116,15 +120,16 @@ export default class App extends Component {
{this.renderError('last_name')}
</View>

<View
onLayout={({nativeEvent}) => {
this.setInputPosition({
ids: ['birthday_month', 'birthday_day'],
value: nativeEvent.layout.y,
});
}}>
<Fragment>
<Text>Birthday?</Text>
<View style={styles.split}>
<View
onLayout={({nativeEvent}) => {
this.setInputPosition({
ids: ['birthday_month', 'birthday_day'],
value: nativeEvent.layout.y,
});
}}
style={styles.split}>
<View style={{flex: 1, marginRight: 5}}>
<TextInput
style={styles.input}
Expand All @@ -146,7 +151,23 @@ export default class App extends Component {
{this.renderError('birthday_day')}
</View>
</View>
</View>
<View
onLayout={({nativeEvent}) => {
this.setInputPosition({
ids: ['birthday_year'],
value: nativeEvent.layout.y,
});
}}>
<TextInput
style={styles.input}
placeholder="Year"
onChangeText={value => {
this.onInputChange({id: 'birthday_year', value});
}}
/>
{this.renderError('birthday_year')}
</View>
</Fragment>

<View
onLayout={({nativeEvent}) => {
Expand Down
12 changes: 12 additions & 0 deletions demoApp/validation/dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ export const validationDictionary = {
},
},

year: {
presence: {
allowEmpty: false,
message: '^This is required',
},
numericality: {
greaterThan: 1900,
lessThanOrEqualTo: new Date().getFullYear(),
message: '^Must be valid',
},
},

zip: {
presence: {
allowEmpty: false,
Expand Down

0 comments on commit 2014e0b

Please sign in to comment.