Skip to content

Commit

Permalink
Fix last two paste context issues on Android (#1577)
Browse files Browse the repository at this point in the history
* Add setTimeouts to get paste context working on Android, fixes #1567
  • Loading branch information
rickycodes authored May 27, 2020
1 parent 04f6f34 commit e2aa8ae
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
17 changes: 12 additions & 5 deletions app/components/UI/PaymentRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ const styles = StyleSheet.create({
marginVertical: 8
},
searchInput: {
flex: 1,
marginHorizontal: 0,
paddingTop: Device.isAndroid() ? 12 : 2,
borderRadius: 8,
paddingHorizontal: 38,
fontSize: 16,
backgroundColor: colors.white,
height: 40,
width: '100%',
color: colors.grey400,
borderColor: colors.grey100,
borderWidth: 1,
Expand Down Expand Up @@ -266,7 +266,8 @@ class PaymentRequest extends PureComponent {
secondaryAmount: undefined,
symbol: undefined,
showError: false,
chainId: ''
chainId: '',
inputWidth: { width: '99%' }
};

/**
Expand All @@ -276,7 +277,13 @@ class PaymentRequest extends PureComponent {
const { primaryCurrency, navigation, networkType } = this.props;
const receiveAsset = navigation && navigation.getParam('receiveAsset', undefined);
const chainId = Object.keys(NetworkList).indexOf(networkType) > -1 && NetworkList[networkType].networkId;
this.setState({ internalPrimaryCurrency: primaryCurrency, chainId });
setTimeout(() => {
this.setState({
internalPrimaryCurrency: primaryCurrency,
chainId,
inputWidth: { width: '100%' }
});
}, 100);
if (receiveAsset) {
this.goToAmountInput(receiveAsset);
}
Expand Down Expand Up @@ -339,7 +346,7 @@ class PaymentRequest extends PureComponent {
*/
renderSelectAssets = () => {
const { tokens } = this.props;
const { chainId } = this.state;
const { chainId, inputWidth } = this.state;
let results;
if (chainId === 1) {
results = this.state.searchInputValue ? this.state.results : defaultAssets;
Expand All @@ -359,7 +366,7 @@ class PaymentRequest extends PureComponent {
{chainId === 1 && (
<View style={styles.searchWrapper}>
<TextInput
style={[styles.searchInput, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.searchInput, inputWidth]}
autoCapitalize="none"
autoCorrect={false}
clearButtonMode="while-editing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ exports[`NetworkSettings should render correctly 1`] = `
"fontWeight": "400",
"padding": 10,
},
Object {},
Object {
"width": "99%",
},
]
}
testID="input-network-name"
Expand Down Expand Up @@ -126,7 +128,9 @@ exports[`NetworkSettings should render correctly 1`] = `
"fontWeight": "400",
"padding": 10,
},
Object {},
Object {
"width": "99%",
},
]
}
testID="input-rpc-url"
Expand Down Expand Up @@ -163,7 +167,9 @@ exports[`NetworkSettings should render correctly 1`] = `
"fontWeight": "400",
"padding": 10,
},
Object {},
Object {
"width": "99%",
},
]
}
/>
Expand Down Expand Up @@ -197,7 +203,9 @@ exports[`NetworkSettings should render correctly 1`] = `
"fontWeight": "400",
"padding": 10,
},
Object {},
Object {
"width": "99%",
},
]
}
testID="input-network-symbol"
Expand Down Expand Up @@ -232,7 +240,9 @@ exports[`NetworkSettings should render correctly 1`] = `
"fontWeight": "400",
"padding": 10,
},
Object {},
Object {
"width": "99%",
},
]
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class NetworkSettings extends PureComponent {
validatedRpcURL: true,
validatedChainId: true,
initialState: undefined,
enableAction: false
enableAction: false,
inputWidth: { width: '99%' }
};

inputRpcURL = React.createRef();
Expand Down Expand Up @@ -146,6 +147,11 @@ class NetworkSettings extends PureComponent {
} else {
this.setState({ addMode: true });
}
setTimeout(() => {
this.setState({
inputWidth: { width: '100%' }
});
}, 100);
};

/**
Expand Down Expand Up @@ -293,7 +299,8 @@ class NetworkSettings extends PureComponent {
addMode,
warningRpcUrl,
warningChainId,
enableAction
enableAction,
inputWidth
} = this.state;
return (
<SafeAreaView style={styles.wrapper} testID={'new-rpc-screen'}>
Expand All @@ -308,7 +315,7 @@ class NetworkSettings extends PureComponent {

<Text style={styles.label}>{strings('app_settings.network_name_label')}</Text>
<TextInput
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.input, inputWidth]}
autoCapitalize={'none'}
autoCorrect={false}
value={nickname}
Expand All @@ -323,7 +330,7 @@ class NetworkSettings extends PureComponent {
<Text style={styles.label}>{strings('app_settings.network_rpc_url_label')}</Text>
<TextInput
ref={this.inputRpcURL}
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.input, inputWidth]}
autoCapitalize={'none'}
autoCorrect={false}
value={rpcUrl}
Expand All @@ -344,7 +351,7 @@ class NetworkSettings extends PureComponent {
<Text style={styles.label}>{strings('app_settings.network_chain_id_label')}</Text>
<TextInput
ref={this.inputChainId}
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.input, inputWidth]}
autoCapitalize={'none'}
autoCorrect={false}
value={chainId}
Expand All @@ -365,7 +372,7 @@ class NetworkSettings extends PureComponent {
<Text style={styles.label}>{strings('app_settings.network_symbol_label')}</Text>
<TextInput
ref={this.inputSymbol}
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.input, inputWidth]}
autoCapitalize={'none'}
autoCorrect={false}
value={ticker}
Expand All @@ -380,7 +387,7 @@ class NetworkSettings extends PureComponent {
<Text style={styles.label}>{strings('app_settings.network_block_explorer_label')}</Text>
<TextInput
ref={this.inputBlockExplorerURL}
style={[styles.input, this.state.inputWidth ? { width: this.state.inputWidth } : {}]}
style={[styles.input, inputWidth]}
autoCapitalize={'none'}
autoCorrect={false}
value={blockExplorerUrl}
Expand Down

0 comments on commit e2aa8ae

Please sign in to comment.