Skip to content

Commit f19d538

Browse files
committed
Merge branch 'master' into infra/typescript-page-control
* master: Fix missed issue with migrating Picker API - PickerItem needs to retrieve the correct value format Add Slider testID (#999) Remove declaration of ref type on TouchableOpacity convert three digit hex to six (#976) Fix/text field right icon alignment (#997) migrate Switch to TS (#991) Move from KeyboardAwareListView to KeyboardAwareFlatList (#960) Update constants typings migrate ActionBar to TS (#987) Do not notify the user onPageChange for the fake page (fix autoscroll on Android bug) (#994) Add progress type for ProgressBarProps (#996) Fix generated JS files to include propTypes (#995) # Conflicts: # generatedTypes/components/touchableOpacity/index.d.ts
2 parents 050ddab + 2265d81 commit f19d538

File tree

32 files changed

+518
-362
lines changed

32 files changed

+518
-362
lines changed

demo/src/screens/componentScreens/ActionBarScreen.js renamed to demo/src/screens/componentScreens/ActionBarScreen.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import tags from '../../assets/icons/tags.png';
88
import collections from '../../assets/icons/collections.png';
99
import richText from '../../assets/icons/richText.png';
1010

11-
1211
export default class ActionBarScreen extends Component {
1312

1413
constructor(props) {

demo/src/screens/componentScreens/KeyboardAwareScrollViewScreen.js

Lines changed: 119 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,204 +1,164 @@
1+
import _ from 'lodash';
12
import React, {Component} from 'react';
2-
import {StyleSheet, TouchableHighlight, RecyclerViewBackedScrollView} from 'react-native';
3+
import {StyleSheet} from 'react-native';
34
import {
4-
Button,
55
Colors,
66
KeyboardAwareScrollView,
7-
KeyboardAwareListView,
7+
KeyboardAwareFlatList,
88
TextField,
99
Text,
1010
Typography,
1111
View
1212
} from 'react-native-ui-lib';
13+
import {renderBooleanOption} from '../ExampleScreenPresenter';
1314

14-
const LOREM_IPSUM =
15-
'Lorem ipsum dolor sit amet, ius ad pertinax oportere accommodare, an vix civibus corrumpit referrentur. Te nam case ludus inciderint, te mea facilisi adipiscing. Sea id integre luptatum. In tota sale consequuntur nec. Erat ocurreret mei ei. Eu paulo sapientem vulputate est, vel an accusam intellegam interesset. Nam eu stet pericula reprimique, ea vim illud modus, putant invidunt reprehendunt ne qui.';
16-
const hashCode = function (str) {
17-
let hash = 15;
18-
for (let ii = str.length - 1; ii >= 0; ii--) {
19-
// eslint-disable-next-line no-bitwise
20-
hash = (hash << 5) - hash + str.charCodeAt(ii);
15+
const data = [
16+
{
17+
placeholder: 'First Name',
18+
ref: '_firstNameTI',
19+
nextRef: '_lastNameTI'
20+
},
21+
{
22+
placeholder: 'Last Name',
23+
ref: '_lastNameTI',
24+
nextRef: '_countryTI'
25+
},
26+
{
27+
placeholder: 'Country',
28+
ref: '_countryTI',
29+
nextRef: '_stateTI'
30+
},
31+
{
32+
placeholder: 'State',
33+
ref: '_stateTI',
34+
nextRef: '_addrTI'
35+
},
36+
{
37+
placeholder: 'Address',
38+
ref: '_addrTI',
39+
nextRef: '_emailTI'
40+
},
41+
{
42+
placeholder: 'Email',
43+
keyboardType: 'email-address',
44+
ref: '_emailTI',
45+
nextRef: '_msgTI'
46+
},
47+
{
48+
placeholder: 'Message',
49+
ref: '_msgTI',
50+
nextRef: '_notesTI'
51+
},
52+
{
53+
placeholder: 'Notes',
54+
ref: '_notesTI'
2155
}
22-
return hash;
23-
};
56+
];
2457

2558
export default class KeyboardAwareScrollViewScreen extends Component {
2659
constructor(props) {
2760
super(props);
2861
this.state = {
29-
listToggle: false,
30-
data: {}
62+
isFlatList: false
3163
};
3264
}
3365

34-
_genRows(pressData) {
35-
const dataBlob = [];
36-
for (let ii = 0; ii < 10; ii++) {
37-
const pressedText = pressData[ii] ? ' (pressed)' : '';
38-
dataBlob.push('Row ' + ii + pressedText);
39-
}
40-
return dataBlob;
41-
}
42-
43-
_renderRow(rowData, sectionID, rowID) {
44-
const rowHash = Math.abs(hashCode(rowData));
66+
renderItem = (data) => {
67+
const {isFlatList} = this.state;
68+
const item = isFlatList ? data.item : data;
69+
const {placeholder, ref, nextRef, keyboardType} = item;
70+
const returnKeyType = nextRef ? 'next' : 'go';
71+
const onSubmitEditing = nextRef ? () => this[nextRef].focus() : undefined;
4572
return (
46-
<TouchableHighlight>
47-
<View>
48-
<View style={styles.row}>
49-
<Text style={styles.text}>{rowData + ' - ' + LOREM_IPSUM.substr(0, (rowHash % 301) + 10)}</Text>
50-
</View>
51-
<View style={{backgroundColor: Colors.white}}>
52-
<TextField style={[styles.text, {borderWidth: 0.5}]} placeholder={'Text goes here'}/>
53-
</View>
54-
</View>
55-
</TouchableHighlight>
73+
<TextField
74+
key={placeholder}
75+
text70R
76+
placeholder={placeholder}
77+
ref={(r) => {
78+
this[ref] = r;
79+
}}
80+
returnKeyType={returnKeyType}
81+
keyboardType={keyboardType}
82+
onSubmitEditing={onSubmitEditing}
83+
/>
5684
);
57-
}
85+
};
86+
87+
keyExtractor = (item) => item.placeholder;
5888

59-
_renderBodyButton(bodyHeaderTitle) {
89+
renderKeyboardAwareFlatList() {
6090
return (
61-
<Button
62-
text80
63-
link
64-
label={bodyHeaderTitle}
65-
labelStyle={{color: Colors.black}}
66-
onPress={() => this.setState({listToggle: !this.state.listToggle})}
67-
style={styles.topButton}
91+
<KeyboardAwareFlatList
92+
showsVerticalScrollIndicator={false}
93+
keyboardDismissMode="interactive"
94+
keyboardShouldPersistTaps="always"
95+
data={data}
96+
contentContainerStyle={{paddingTop: 20}}
97+
keyExtractor={this.keyExtractor}
98+
renderItem={this.renderItem}
99+
getTextInputRefs={() => {
100+
return [
101+
this._firstNameTI,
102+
this._lastNameTI,
103+
this._countryTI,
104+
this._stateTI,
105+
this._addrTI,
106+
this._emailTI,
107+
this._msgTI,
108+
this._notesTI
109+
];
110+
}}
68111
/>
69112
);
70113
}
71114

72-
_renderKeyboardAwareListView() {
115+
renderKeyboardAwareScrollView() {
73116
return (
74-
<View style={styles.container}>
75-
{this._renderBodyButton('Switch to ScrollView')}
76-
<KeyboardAwareListView
77-
keyboardDismissMode="interactive"
78-
keyboardShouldPersistTaps="always"
79-
dataSource={this.state.data}
80-
renderRow={this._renderRow}
81-
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props}/>}
82-
renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator}/>}
83-
/>
84-
</View>
117+
<KeyboardAwareScrollView
118+
showsVerticalScrollIndicator={false}
119+
keyboardDismissMode="interactive"
120+
keyboardShouldPersistTaps="always"
121+
getTextInputRefs={() => {
122+
return [
123+
this._firstNameTI,
124+
this._lastNameTI,
125+
this._countryTI,
126+
this._stateTI,
127+
this._addrTI,
128+
this._emailTI,
129+
this._msgTI,
130+
this._notesTI
131+
];
132+
}}
133+
>
134+
{_.map(data, (item) => this.renderItem(item))}
135+
</KeyboardAwareScrollView>
85136
);
86137
}
87138

88-
_renderKeyboardAwareScrollView() {
139+
render() {
140+
const {isFlatList} = this.state;
141+
const switchText = `${
142+
isFlatList ? 'KeyboardAwareFlatList' : 'KeyboardAwareScrollView'
143+
}`;
89144
return (
90145
<View style={styles.container}>
91146
<Text text65 marginB-20>
92-
KeyboardAwareScrollView
147+
KeyboardAware example form
93148
</Text>
94-
<Text text65R style={{marginBottom: 10}}>Example Form</Text>
95-
96-
{this.state.listToggle && this._renderBodyButton('Switch to ListView')}
97-
<KeyboardAwareScrollView
98-
showsVerticalScrollIndicator={false}
99-
keyboardDismissMode="interactive"
100-
keyboardShouldPersistTaps="always"
101-
getTextInputRefs={() => {
102-
return [
103-
this._firstNameTI,
104-
this._lastNameTI,
105-
this._countryTI,
106-
this._stateTI,
107-
this._addrTI,
108-
this._emailTI,
109-
this._msgTI,
110-
this._notesTI
111-
];
112-
}}
113-
>
114-
<TextField
115-
style={styles.TextField}
116-
placeholder={'First Name'}
117-
ref={r => {
118-
this._firstNameTI = r;
119-
}}
120-
returnKeyType={'next'}
121-
onSubmitEditing={event => this._lastNameTI.focus()}
122-
/>
123-
<TextField
124-
style={styles.TextField}
125-
placeholder={'Last Name'}
126-
ref={r => {
127-
this._lastNameTI = r;
128-
}}
129-
returnKeyType={'next'}
130-
onSubmitEditing={event => this._countryTI.focus()}
131-
/>
132-
<TextField
133-
style={styles.TextField}
134-
placeholder={'Country'}
135-
ref={r => {
136-
this._countryTI = r;
137-
}}
138-
returnKeyType={'next'}
139-
onSubmitEditing={event => this._stateTI.focus()}
140-
/>
141-
<TextField
142-
style={styles.TextField}
143-
placeholder={'State'}
144-
ref={r => {
145-
this._stateTI = r;
146-
}}
147-
returnKeyType={'next'}
148-
onSubmitEditing={event => this._addrTI.focus()}
149-
/>
150-
<TextField
151-
style={styles.TextField}
152-
placeholder={'Address'}
153-
ref={r => {
154-
this._addrTI = r;
155-
}}
156-
returnKeyType={'next'}
157-
onSubmitEditing={event => this._emailTI.focus()}
158-
/>
159-
<TextField
160-
style={styles.TextField}
161-
keyboardType="email-address"
162-
placeholder={'Email'}
163-
ref={r => {
164-
this._emailTI = r;
165-
}}
166-
returnKeyType={'next'}
167-
onSubmitEditing={event => this._msgTI.focus()}
168-
/>
169-
<TextField
170-
style={styles.TextField}
171-
placeholder={'Message'}
172-
ref={r => {
173-
this._msgTI = r;
174-
}}
175-
returnKeyType={'next'}
176-
onSubmitEditing={event => this._notesTI.focus()}
177-
/>
178-
<TextField
179-
style={styles.TextField}
180-
placeholder={'Notes'}
181-
ref={r => {
182-
this._notesTI = r;
183-
}}
184-
returnKeyType={'go'}
185-
/>
186-
</KeyboardAwareScrollView>
149+
{renderBooleanOption.call(this, switchText, 'isFlatList')}
150+
<View height={40}/>
151+
{isFlatList
152+
? this.renderKeyboardAwareFlatList()
153+
: this.renderKeyboardAwareScrollView()}
187154
</View>
188155
);
189156
}
190-
191-
render() {
192-
if (this.state.listToggle) {
193-
return this._renderKeyboardAwareListView();
194-
} else {
195-
return this._renderKeyboardAwareScrollView();
196-
}
197-
}
198157
}
199158

200159
const styles = StyleSheet.create({
201160
container: {
161+
flex: 1,
202162
padding: 20
203163
},
204164
TextField: {

demo/src/screens/componentScreens/SwitchScreen.js renamed to demo/src/screens/componentScreens/SwitchScreen.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ class SwitchScreen extends Component {
1515
return (
1616
<View flex bottom padding-20>
1717
<View flex center>
18-
<Switch testID="switch" value={this.state.value1} onValueChange={value1 => this.setState({value1})} style={{marginBottom: 20}}/>
18+
<Switch testID="switch" value={this.state.value1} onValueChange={(value1: boolean) => this.setState({value1})} style={{marginBottom: 20}}/>
1919
<Switch
2020
onColor={Colors.purple30}
2121
offColor={Colors.purple60}
2222
value={this.state.value2}
23-
onValueChange={value2 => this.setState({value2})}
23+
onValueChange={(value2: boolean) => this.setState({value2})}
2424
style={{marginBottom: 20}}
2525
/>
2626
<Switch
2727
width={80}
2828
height={38}
2929
thumbSize={34}
3030
value={this.state.value3}
31-
onValueChange={value3 => this.setState({value3})}
31+
onValueChange={(value3: boolean) => this.setState({value3})}
3232
style={{marginBottom: 20}}
3333
/>
3434
<Switch
@@ -39,21 +39,21 @@ class SwitchScreen extends Component {
3939
offColor={Colors.dark60}
4040
thumbColor={Colors.dark10}
4141
value={this.state.value4}
42-
onValueChange={value4 => this.setState({value4})}
42+
onValueChange={(value4: boolean) => this.setState({value4})}
4343
style={{marginBottom: 20}}
4444
/>
4545
<View row marginB-20>
4646
<Text text70 centerV>Disabled: </Text>
4747
<Switch
4848
disabled
4949
value={this.state.value5}
50-
onValueChange={value5 => this.setState({value5})}
50+
onValueChange={(value5: boolean) => this.setState({value5})}
5151
style={{marginRight: 10}}
5252
/>
5353
<Switch
5454
disabled
5555
value={!this.state.value5}
56-
onValueChange={value5 => this.setState({value5})}
56+
onValueChange={(value5: boolean) => this.setState({value5})}
5757
/>
5858
</View>
5959
</View>

0 commit comments

Comments
 (0)