REF: Use Switch for SSL Electrum port

This commit is contained in:
Marcos Rodriguez Vélez 2021-07-04 23:05:04 -04:00
parent 9e7980cd93
commit 79c9d9f91d
4 changed files with 67 additions and 45 deletions

View File

@ -349,7 +349,7 @@ PODS:
- React-Core (= 0.63.4)
- React-cxxreact (= 0.63.4)
- React-jsi (= 0.63.4)
- RealmJS (10.4.1):
- RealmJS (10.4.2):
- GCDWebServer
- React
- RemobileReactNativeQrcodeLocalImage (1.0.4):
@ -700,7 +700,7 @@ SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: cde416483dac037923206447da6e1454df403714
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Flipper: 1bd2db48dcc31e4b167b9a33ec1df01c2ded4893
@ -712,7 +712,7 @@ SPEC CHECKSUMS:
FlipperKit: 651f50a42eb95c01b3e89a60996dd6aded529eeb
Folly: b73c3869541e86821df3c387eb0af5f65addfab4
GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4
glog: 40a13f7840415b9a77023fbcae0f1e6f43192af3
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
lottie-ios: 3a3758ef5a008e762faec9c9d50a39842f26d124
lottie-react-native: 4dff8fe8d10ddef9e7880e770080f4a56121397e
@ -751,7 +751,7 @@ SPEC CHECKSUMS:
React-RCTText: 5c51df3f08cb9dedc6e790161195d12bac06101c
React-RCTVibration: ae4f914cfe8de7d4de95ae1ea6cc8f6315d73d9d
ReactCommon: 73d79c7039f473b76db6ff7c6b159c478acbbb3b
RealmJS: 8a51eff2b9eaabf78b53a6819da6da6edde27467
RealmJS: 90f2a558fdda19ebb9fcbc0a52c7b1d1b049fb88
RemobileReactNativeQrcodeLocalImage: 57aadc12896b148fb5e04bc7c6805f3565f5c3fa
RNCAsyncStorage: 8324611026e8dc3706f829953aa6e3899f581589
RNCClipboard: dac13db8b1ce9b998f1cbc7ca33440113602847f

View File

@ -259,8 +259,8 @@
"electrum_connected_not": "Not Connected",
"electrum_error_connect": "Cant connect to the provided Electrum server",
"electrum_host": "E.g. {example}",
"electrum_port": "TCP port, usually {example}",
"electrum_port_ssl": "SSL port, usually {example}",
"electrum_port": "Port, usually {example}",
"use_ssl": "Use SSL",
"electrum_saved": "Your changes have been saved successfully. Restarting BlueWallet may be required for the changes to take effect.",
"set_electrum_server_as_default": "Set {server} as the default Electrum server?",
"set_lndhub_as_default": "Set {url} as the default LNDHub server?",

View File

@ -12,6 +12,7 @@ import {
Keyboard,
KeyboardAvoidingView,
Platform,
Switch,
} from 'react-native';
import DefaultPreference from 'react-native-default-preference';
import RNWidgetCenter from 'react-native-widget-center';
@ -46,6 +47,8 @@ export default class ElectrumSettings extends Component {
serverHistory: [],
config: {},
server,
sslPort: '',
port: '',
};
}
@ -231,6 +234,21 @@ export default class ElectrumSettings extends Component {
});
};
useSSLPortToggled = value => {
switch (value) {
case true:
this.setState(prevState => {
return { port: '', sslPort: prevState.port };
});
break;
case false:
this.setState(prevState => {
return { port: prevState.sslPort, sslPort: '' };
});
break;
}
};
render() {
const serverHistoryItems = this.state.serverHistory.map((server, i) => {
return (
@ -287,45 +305,38 @@ export default class ElectrumSettings extends Component {
/>
</View>
<BlueSpacing20 />
<View style={styles.inputWrap}>
<TextInput
placeholder={loc.formatString(loc.settings.electrum_port, { example: '50001' })}
value={this.state.port}
onChangeText={text => this.setState({ port: text.trim() })}
numberOfLines={1}
style={styles.inputText}
editable={!this.state.isLoading}
placeholderTextColor="#81868e"
underlineColorAndroid="transparent"
autoCorrect={false}
autoCapitalize="none"
keyboardType="number-pad"
inputAccessoryViewID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}
testID="PortInput"
onFocus={() => this.setState({ isAndroidNumericKeyboardFocused: true })}
onBlur={() => this.setState({ isAndroidNumericKeyboardFocused: false })}
/>
<View style={styles.portWrap}>
<View style={styles.inputWrap}>
<TextInput
placeholder={loc.formatString(loc.settings.electrum_port, { example: '50001' })}
value={this.state.sslPort?.trim() === '' ? this.state.port : this.state.sslPort}
onChangeText={text =>
this.setState(prevState => {
if (prevState.sslPort?.trim() === '') {
return { port: text.trim(), sslPort: '' };
} else {
return { port: '', sslPort: text.trim() };
}
})
}
numberOfLines={1}
style={styles.inputText}
editable={!this.state.isLoading}
placeholderTextColor="#81868e"
underlineColorAndroid="transparent"
autoCorrect={false}
autoCapitalize="none"
keyboardType="number-pad"
inputAccessoryViewID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}
testID="PortInput"
onFocus={() => this.setState({ isAndroidNumericKeyboardFocused: true })}
onBlur={() => this.setState({ isAndroidNumericKeyboardFocused: false })}
/>
</View>
<BlueText style={styles.usePort}>{loc.settings.use_ssl}</BlueText>
<Switch testID="SSLPortInput" value={this.state.sslPort?.trim() > 0} onValueChange={this.useSSLPortToggled} />
</View>
<BlueSpacing20 />
<View style={styles.inputWrap}>
<TextInput
placeholder={loc.formatString(loc.settings.electrum_port_ssl, { example: '50002' })}
value={this.state.sslPort}
onChangeText={text => this.setState({ sslPort: text.trim() })}
numberOfLines={1}
style={styles.inputText}
editable={!this.state.isLoading}
autoCorrect={false}
placeholderTextColor="#81868e"
autoCapitalize="none"
keyboardType="number-pad"
underlineColorAndroid="transparent"
inputAccessoryViewID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}
testID="SSLPortInput"
onFocus={() => this.setState({ isAndroidNumericKeyboardFocused: true })}
onBlur={() => this.setState({ isAndroidNumericKeyboardFocused: false })}
/>
</View>
<View style={styles.serverAddTitle}>
<BlueText style={styles.explain}>{loc.settings.electrum_settings_explain}</BlueText>
@ -438,6 +449,11 @@ const styles = StyleSheet.create({
textAlign: 'center',
color: BlueCurrentTheme.colors.foregroundColor,
},
usePort: {
textAlign: 'center',
color: BlueCurrentTheme.colors.foregroundColor,
marginHorizontal: 8,
},
explain: {
color: BlueCurrentTheme.colors.feeText,
marginBottom: -24,
@ -449,6 +465,7 @@ const styles = StyleSheet.create({
alignItems: 'flex-start',
},
inputWrap: {
flex: 1,
flexDirection: 'row',
borderColor: BlueCurrentTheme.colors.formBorder,
borderBottomColor: BlueCurrentTheme.colors.formBorder,
@ -460,6 +477,12 @@ const styles = StyleSheet.create({
alignItems: 'center',
borderRadius: 4,
},
portWrap: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
inputText: {
flex: 1,
marginHorizontal: 8,

View File

@ -86,7 +86,6 @@ describe('BlueWallet UI Tests', () => {
await element(by.id('ElectrumSettings')).tap();
await element(by.id('HostInput')).replaceText('electrum.blockstream.info\n');
await element(by.id('PortInput')).replaceText('50001\n');
await element(by.id('SSLPortInput')).replaceText('50002\n');
await element(by.id('Save')).tap();
await sup('OK');
await element(by.text('OK')).tap();
@ -95,7 +94,7 @@ describe('BlueWallet UI Tests', () => {
await element(by.text('OK')).tap();
await expect(element(by.id('HostInput'))).toHaveText('');
await expect(element(by.id('PortInput'))).toHaveText('');
await expect(element(by.id('SSLPortInput'))).toHaveText('');
await expect(element(by.id('SSLPortInput'))).toHaveToggleValue(false);
await device.pressBack();
// network -> lightning