Skip to content

Commit 04dbc10

Browse files
authored
Fix Android paste (#469)
* fix android paste * snapshot * email-address * auto complete off * snapshots * mounted
1 parent 7bf0424 commit 04dbc10

File tree

8 files changed

+147
-71
lines changed

8 files changed

+147
-71
lines changed

app/components/UI/AddCustomCollectible/__snapshots__/index.test.js.snap

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ exports[`AddCustomCollectible should render correctly 1`] = `
4646
onSubmitEditing={[Function]}
4747
placeholder="0x..."
4848
style={
49-
Object {
50-
"borderColor": "#CCCCCC",
51-
"borderRadius": 4,
52-
"borderWidth": 1,
53-
"fontFamily": "Roboto",
54-
"fontWeight": "400",
55-
"padding": 16,
56-
}
49+
Array [
50+
Object {
51+
"borderColor": "#CCCCCC",
52+
"borderRadius": 4,
53+
"borderWidth": 1,
54+
"fontFamily": "Roboto",
55+
"fontWeight": "400",
56+
"padding": 16,
57+
},
58+
Object {},
59+
]
5760
}
5861
testID="input-collectible-address"
5962
underlineColorAndroid="transparent"
@@ -95,14 +98,17 @@ exports[`AddCustomCollectible should render correctly 1`] = `
9598
placeholder=""
9699
returnKeyType="done"
97100
style={
98-
Object {
99-
"borderColor": "#CCCCCC",
100-
"borderRadius": 4,
101-
"borderWidth": 1,
102-
"fontFamily": "Roboto",
103-
"fontWeight": "400",
104-
"padding": 16,
105-
}
101+
Array [
102+
Object {
103+
"borderColor": "#CCCCCC",
104+
"borderRadius": 4,
105+
"borderWidth": 1,
106+
"fontFamily": "Roboto",
107+
"fontWeight": "400",
108+
"padding": 16,
109+
},
110+
Object {},
111+
]
106112
}
107113
testID="input-token-decimals"
108114
underlineColorAndroid="transparent"

app/components/UI/AddCustomCollectible/index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import { Alert, Text, TextInput, View, StyleSheet } from 'react-native';
2+
import { Platform, Alert, Text, TextInput, View, StyleSheet } from 'react-native';
33
import { colors, fontStyles } from '../../../styles/common';
44
import Engine from '../../../core/Engine';
55
import PropTypes from 'prop-types';
@@ -36,7 +36,8 @@ const styles = StyleSheet.create({
3636
class AddCustomCollectible extends Component {
3737
state = {
3838
address: '',
39-
tokenId: ''
39+
tokenId: '',
40+
inputWidth: Platform.OS === 'android' ? '99%' : undefined
4041
};
4142

4243
static propTypes = {
@@ -50,6 +51,19 @@ class AddCustomCollectible extends Component {
5051
selectedAddress: PropTypes.string
5152
};
5253

54+
componentDidMount = () => {
55+
this.mounted = true;
56+
// Workaround https://github.com/facebook/react-native/issues/9958
57+
this.state.inputWidth &&
58+
setTimeout(() => {
59+
this.mounted && this.setState({ inputWidth: '100%' });
60+
}, 100);
61+
};
62+
63+
componentWillUnmount = () => {
64+
this.mounted = false;
65+
};
66+
5367
addCollectible = async () => {
5468
if (!(await this.validateCustomCollectible())) return;
5569
const isOwner = await this.validateCollectibleOwnership();
@@ -149,7 +163,7 @@ class AddCustomCollectible extends Component {
149163
<View style={styles.rowWrapper}>
150164
<Text style={fontStyles.normal}>{strings('collectible.collectible_address')}</Text>
151165
<TextInput
152-
style={styles.textInput}
166+
style={[styles.textInput, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
153167
placeholder={'0x...'}
154168
value={this.state.address}
155169
onChangeText={this.onAddressChange}
@@ -162,7 +176,7 @@ class AddCustomCollectible extends Component {
162176
<View style={styles.rowWrapper}>
163177
<Text style={fontStyles.normal}>{strings('collectible.collectible_token_id')}</Text>
164178
<TextInput
165-
style={styles.textInput}
179+
style={[styles.textInput, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
166180
value={this.state.tokenId}
167181
keyboardType="numeric"
168182
placeholder={''}

app/components/UI/HomePage/index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const styles = StyleSheet.create({
8686
marginHorizontal: 10,
8787
backgroundColor: colors.white,
8888
fontSize: 14,
89-
flex: 1,
9089
...fontStyles.normal
9190
},
9291
searchIcon: {
@@ -183,21 +182,29 @@ class HomePage extends Component {
183182

184183
state = {
185184
searchInputValue: '',
186-
inputValue: ''
185+
inputValue: '',
186+
inputWidth: Platform.OS === 'android' ? '99%' : undefined
187187
};
188188

189189
actionSheet = null;
190190

191191
bookmarkIndexToRemove = null;
192192

193-
componentDidMount() {
193+
componentDidMount = () => {
194194
if (Platform.OS === 'android') {
195195
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.keyboardDidHide);
196196
}
197-
}
197+
this.mounted = true;
198+
// Workaround https://github.com/facebook/react-native/issues/9958
199+
this.state.inputWidth &&
200+
setTimeout(() => {
201+
this.mounted && this.setState({ inputWidth: '100%' });
202+
}, 100);
203+
};
198204

199205
componentWillUnmount() {
200206
Platform.OS === 'android' && this.keyboardDidHideListener.remove();
207+
this.mounted = false;
201208
}
202209

203210
onInitialUrlChange = searchInputValue => {
@@ -260,7 +267,10 @@ class HomePage extends Component {
260267
<View style={styles.searchWrapper}>
261268
<Icon name="search" size={18} color={colors.asphalt} style={styles.searchIcon} />
262269
<TextInput
263-
style={styles.searchInput}
270+
style={[
271+
styles.searchInput,
272+
this.state.inputWidth ? { width: this.state.inputWidth } : {}
273+
]}
264274
autoCapitalize="none"
265275
autoCorrect={false}
266276
clearButtonMode="while-editing"

app/components/Views/AdvancedSettings/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,21 @@ class Settings extends Component {
121121
state = {
122122
resetModalVisible: false,
123123
rpcUrl: undefined,
124-
warningRpcUrl: ''
124+
warningRpcUrl: '',
125+
inputWidth: Platform.OS === 'android' ? '99%' : undefined
126+
};
127+
128+
componentDidMount = () => {
129+
this.mounted = true;
130+
// Workaround https://github.com/facebook/react-native/issues/9958
131+
this.state.inputWidth &&
132+
setTimeout(() => {
133+
this.mounted && this.setState({ inputWidth: '100%' });
134+
}, 100);
135+
};
136+
137+
componentWillUnmount = () => {
138+
this.mounted = false;
125139
};
126140

127141
displayResetAccountModal = () => {
@@ -221,9 +235,10 @@ class Settings extends Component {
221235
<Text style={styles.title}>{strings('app_settings.new_RPC_URL')}</Text>
222236
<Text style={styles.desc}>{strings('app_settings.rpc_desc')}</Text>
223237
<TextInput
238+
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
224239
autoCapitalize={'none'}
240+
autoComplete={'off'}
225241
autoCorrect={false}
226-
style={styles.input}
227242
value={this.state.rpcUrl}
228243
onBlur={this.addRpcUrl}
229244
onChangeText={this.onRpcUrlChange}

app/components/Views/ImportFromSeed/__snapshots__/index.test.js.snap

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ exports[`ImportFromSeed should render correctly 1`] = `
5252
<TextInput
5353
allowFontScaling={true}
5454
autoCapitalize="none"
55-
autoComplete="false"
55+
autoComplete="off"
5656
blurOnSubmit={true}
5757
keyboardType="default"
5858
multiline={true}
@@ -62,22 +62,26 @@ exports[`ImportFromSeed should render correctly 1`] = `
6262
placeholder="Enter your seed phrase here"
6363
returnKeyType="next"
6464
style={
65-
Object {
66-
"backgroundColor": "#FFFFFF",
67-
"borderColor": "#CCCCCC",
68-
"borderRadius": 10,
69-
"borderWidth": 0.5,
70-
"fontFamily": "Roboto",
71-
"fontSize": 20,
72-
"fontWeight": "400",
73-
"height": 110,
74-
"marginBottom": 10,
75-
"marginTop": 10,
76-
"paddingBottom": 20,
77-
"paddingLeft": 20,
78-
"paddingRight": 20,
79-
"paddingTop": 20,
80-
}
65+
Array [
66+
Object {
67+
"backgroundColor": "#FFFFFF",
68+
"borderColor": "#CCCCCC",
69+
"borderRadius": 10,
70+
"borderWidth": 0.5,
71+
"fontFamily": "Roboto",
72+
"fontSize": 20,
73+
"fontWeight": "400",
74+
"height": "auto",
75+
"marginBottom": 10,
76+
"marginTop": 10,
77+
"minHeight": 110,
78+
"paddingBottom": 20,
79+
"paddingLeft": 20,
80+
"paddingRight": 20,
81+
"paddingTop": 20,
82+
},
83+
Object {},
84+
]
8185
}
8286
testID="input-seed-phrase"
8387
underlineColorAndroid="transparent"

app/components/Views/ImportFromSeed/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ const styles = StyleSheet.create({
7575
paddingRight: 20,
7676
fontSize: 20,
7777
borderRadius: 10,
78-
height: 110,
78+
minHeight: 110,
79+
height: 'auto',
7980
borderWidth: StyleSheet.hairlineWidth,
8081
borderColor: colors.borderColor,
8182
...fontStyles.normal
@@ -130,11 +131,10 @@ class ImportFromSeed extends Component {
130131
rememberMe: false,
131132
biometryChoice: false,
132133
loading: false,
133-
error: null
134+
error: null,
135+
inputWidth: Platform.OS === 'android' ? '99%' : undefined
134136
};
135137

136-
mounted = true;
137-
138138
passwordInput = React.createRef();
139139
confirmPasswordInput = React.createRef();
140140

@@ -143,11 +143,17 @@ class ImportFromSeed extends Component {
143143
if (biometryType) {
144144
this.setState({ biometryType, biometryChoice: true });
145145
}
146+
this.mounted = true;
147+
// Workaround https://github.com/facebook/react-native/issues/9958
148+
this.state.inputWidth &&
149+
setTimeout(() => {
150+
this.mounted && this.setState({ inputWidth: '100%' });
151+
}, 100);
146152
}
147153

148-
componentWillUnmount() {
154+
componentWillUnmount = () => {
149155
this.mounted = false;
150-
}
156+
};
151157

152158
onPressImport = async () => {
153159
if (this.state.loading) return;
@@ -288,15 +294,15 @@ class ImportFromSeed extends Component {
288294
value={this.state.seedWords}
289295
numberOfLines={3}
290296
multiline
291-
style={styles.seedPhrase}
297+
style={[styles.seedPhrase, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
292298
placeholder={strings('import_from_seed.seed_phrase_placeholder')}
293299
onChangeText={this.onSeedWordsChange}
294300
testID={'input-seed-phrase'}
295301
blurOnSubmit
296302
onSubmitEditing={this.jumpToPassword}
297303
returnKeyType={'next'}
298-
autoComplete="false"
299-
keyboardType={Platform.OS === 'android' ? 'visible-password' : 'default'}
304+
autoComplete={'off'}
305+
keyboardType={Platform.OS === 'android' ? 'email-address' : 'default'}
300306
autoCapitalize="none"
301307
/>
302308
<View style={styles.field}>

app/components/Views/ImportPrivateKey/__snapshots__/index.test.js.snap

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ exports[`ImportPrivateKey should render correctly 1`] = `
181181
</View>
182182
<TextInput
183183
allowFontScaling={true}
184+
autoCapitalize="none"
185+
autoComplete="off"
184186
blurOnSubmit={true}
185187
multiline={true}
186188
numberOfLines={3}
@@ -189,22 +191,25 @@ exports[`ImportPrivateKey should render correctly 1`] = `
189191
placeholder="e.g. 3a1076bf45ab87712ad64ccb3b10217737f7faacbf2872e88fdd9a537d8fe266"
190192
returnKeyType="next"
191193
style={
192-
Object {
193-
"backgroundColor": "#FFFFFF",
194-
"borderColor": "#CCCCCC",
195-
"borderRadius": 4,
196-
"borderWidth": 0.5,
197-
"fontFamily": "Roboto",
198-
"fontSize": 15,
199-
"fontWeight": "400",
200-
"height": 120,
201-
"marginBottom": 10,
202-
"marginTop": 20,
203-
"paddingBottom": 20,
204-
"paddingLeft": 20,
205-
"paddingRight": 20,
206-
"paddingTop": 20,
207-
}
194+
Array [
195+
Object {
196+
"backgroundColor": "#FFFFFF",
197+
"borderColor": "#CCCCCC",
198+
"borderRadius": 4,
199+
"borderWidth": 0.5,
200+
"fontFamily": "Roboto",
201+
"fontSize": 15,
202+
"fontWeight": "400",
203+
"height": 120,
204+
"marginBottom": 10,
205+
"marginTop": 20,
206+
"paddingBottom": 20,
207+
"paddingLeft": 20,
208+
"paddingRight": 20,
209+
"paddingTop": 20,
210+
},
211+
Object {},
212+
]
208213
}
209214
testID="input-private-key"
210215
underlineColorAndroid="transparent"

0 commit comments

Comments
 (0)