fix: irregular cursor movement in settings

This commit is contained in:
Bettenbuk Zoltan 2020-03-25 11:10:13 +01:00 committed by Saúl Ibarra Corretgé
parent d13edd8f63
commit 25b4843327
1 changed files with 134 additions and 23 deletions

View File

@ -34,10 +34,45 @@ type Props = AbstractProps & {
type State = { type State = {
/**
* State variable for the disable call integration switch.
*/
disableCallIntegration: boolean,
/**
* State variable for the disable p2p switch.
*/
disableP2P: boolean,
/**
* State variable for the display name field.
*/
displayName: string,
/**
* State variable for the email field.
*/
email: string,
/**
* State variable for the server URL field.
*/
serverURL: string,
/** /**
* Whether to show advanced settings or not. * Whether to show advanced settings or not.
*/ */
showAdvanced: boolean showAdvanced: boolean,
/**
* State variable for the start with audio muted switch.
*/
startWithAudioMuted: boolean,
/**
* State variable for the start with video muted switch.
*/
startWithVideoMuted: boolean,
} }
/** /**
@ -55,9 +90,25 @@ class SettingsView extends AbstractSettingsView<Props, State> {
*/ */
constructor(props) { constructor(props) {
super(props); super(props);
const {
disableCallIntegration,
disableP2P,
displayName,
email,
serverURL,
startWithAudioMuted,
startWithVideoMuted
} = props._settings || {};
this.state = { this.state = {
showAdvanced: false disableCallIntegration,
disableP2P,
displayName,
email,
serverURL,
showAdvanced: false,
startWithAudioMuted,
startWithVideoMuted
}; };
// Bind event handlers so they are only bound once per instance. // Bind event handlers so they are only bound once per instance.
@ -103,25 +154,61 @@ class SettingsView extends AbstractSettingsView<Props, State> {
this._processServerURL(false /* hideOnSuccess */); this._processServerURL(false /* hideOnSuccess */);
} }
_onChangeDisplayName: (string) => void; /**
* Callback to update the display name.
*
* @param {string} displayName - The new value to set.
* @returns {void}
*/
_onChangeDisplayName(displayName) {
super._onChangeDisplayName(displayName);
this.setState({
displayName
});
}
_onChangeEmail: (string) => void; /**
* Callback to update the email.
*
* @param {string} email - The new value to set.
* @returns {void}
*/
_onChangeEmail(email) {
super._onChangeEmail(email);
this.setState({
email
});
}
_onChangeServerURL: (string) => void; /**
* Callback to update the server URL.
*
* @param {string} serverURL - The new value to set.
* @returns {void}
*/
_onChangeServerURL(serverURL) {
super._onChangeServerURL(serverURL);
this.setState({
serverURL
});
}
_onDisableCallIntegration: (boolean) => void; _onDisableCallIntegration: (boolean) => void;
/** /**
* Handles the disable call integration change event. * Handles the disable call integration change event.
* *
* @param {boolean} newValue - The new value * @param {boolean} disableCallIntegration - The new value
* option. * option.
* @private * @private
* @returns {void} * @returns {void}
*/ */
_onDisableCallIntegration(newValue) { _onDisableCallIntegration(disableCallIntegration) {
this._updateSettings({ this._updateSettings({
disableCallIntegration: newValue disableCallIntegration
});
this.setState({
disableCallIntegration
}); });
} }
@ -130,14 +217,17 @@ class SettingsView extends AbstractSettingsView<Props, State> {
/** /**
* Handles the disable P2P change event. * Handles the disable P2P change event.
* *
* @param {boolean} newValue - The new value * @param {boolean} disableP2P - The new value
* option. * option.
* @private * @private
* @returns {void} * @returns {void}
*/ */
_onDisableP2P(newValue) { _onDisableP2P(disableP2P) {
this._updateSettings({ this._updateSettings({
disableP2P: newValue disableP2P
});
this.setState({
disableP2P
}); });
} }
@ -165,9 +255,31 @@ class SettingsView extends AbstractSettingsView<Props, State> {
this.setState({ showAdvanced: !this.state.showAdvanced }); this.setState({ showAdvanced: !this.state.showAdvanced });
} }
_onStartAudioMutedChange: (boolean) => void; /**
* Callback to update the start with audio muted value.
*
* @param {boolean} startWithAudioMuted - The new value to set.
* @returns {void}
*/
_onStartAudioMutedChange(startWithAudioMuted) {
super._onStartAudioMutedChange(startWithAudioMuted);
this.setState({
startWithAudioMuted
});
}
_onStartVideoMutedChange: (boolean) => void; /**
* Callback to update the start with video muted value.
*
* @param {boolean} startWithVideoMuted - The new value to set.
* @returns {void}
*/
_onStartVideoMutedChange(startWithVideoMuted) {
super._onStartVideoMutedChange(startWithVideoMuted);
this.setState({
startWithVideoMuted
});
}
/** /**
* Processes the server URL. It normalizes it and an error alert is * Processes the server URL. It normalizes it and an error alert is
@ -199,8 +311,7 @@ class SettingsView extends AbstractSettingsView<Props, State> {
* @returns {React$Element} * @returns {React$Element}
*/ */
_renderAdvancedSettings() { _renderAdvancedSettings() {
const { _settings } = this.props; const { disableCallIntegration, disableP2P, showAdvanced } = this.state;
const { showAdvanced } = this.state;
if (!showAdvanced) { if (!showAdvanced) {
return ( return (
@ -221,14 +332,14 @@ class SettingsView extends AbstractSettingsView<Props, State> {
label = 'settingsView.disableCallIntegration'> label = 'settingsView.disableCallIntegration'>
<Switch <Switch
onValueChange = { this._onDisableCallIntegration } onValueChange = { this._onDisableCallIntegration }
value = { _settings.disableCallIntegration } /> value = { disableCallIntegration } />
</FormRow> </FormRow>
<FormRow <FormRow
fieldSeparator = { true } fieldSeparator = { true }
label = 'settingsView.disableP2P'> label = 'settingsView.disableP2P'>
<Switch <Switch
onValueChange = { this._onDisableP2P } onValueChange = { this._onDisableP2P }
value = { _settings.disableP2P } /> value = { disableP2P } />
</FormRow> </FormRow>
</> </>
); );
@ -241,7 +352,7 @@ class SettingsView extends AbstractSettingsView<Props, State> {
* @returns {React$Element} * @returns {React$Element}
*/ */
_renderBody() { _renderBody() {
const { _settings } = this.props; const { displayName, email, serverURL, startWithAudioMuted, startWithVideoMuted } = this.state;
return ( return (
<SafeAreaView style = { styles.settingsForm }> <SafeAreaView style = { styles.settingsForm }>
@ -255,7 +366,7 @@ class SettingsView extends AbstractSettingsView<Props, State> {
autoCorrect = { false } autoCorrect = { false }
onChangeText = { this._onChangeDisplayName } onChangeText = { this._onChangeDisplayName }
placeholder = 'John Doe' placeholder = 'John Doe'
value = { _settings.displayName } /> value = { displayName } />
</FormRow> </FormRow>
<FormRow label = 'settingsView.email'> <FormRow label = 'settingsView.email'>
<TextInput <TextInput
@ -264,7 +375,7 @@ class SettingsView extends AbstractSettingsView<Props, State> {
keyboardType = { 'email-address' } keyboardType = { 'email-address' }
onChangeText = { this._onChangeEmail } onChangeText = { this._onChangeEmail }
placeholder = 'email@example.com' placeholder = 'email@example.com'
value = { _settings.email } /> value = { email } />
</FormRow> </FormRow>
<FormSectionHeader <FormSectionHeader
label = 'settingsView.conferenceSection' /> label = 'settingsView.conferenceSection' />
@ -277,19 +388,19 @@ class SettingsView extends AbstractSettingsView<Props, State> {
onBlur = { this._onBlurServerURL } onBlur = { this._onBlurServerURL }
onChangeText = { this._onChangeServerURL } onChangeText = { this._onChangeServerURL }
placeholder = { this.props._serverURL } placeholder = { this.props._serverURL }
value = { _settings.serverURL } /> value = { serverURL } />
</FormRow> </FormRow>
<FormRow <FormRow
fieldSeparator = { true } fieldSeparator = { true }
label = 'settingsView.startWithAudioMuted'> label = 'settingsView.startWithAudioMuted'>
<Switch <Switch
onValueChange = { this._onStartAudioMutedChange } onValueChange = { this._onStartAudioMutedChange }
value = { _settings.startWithAudioMuted } /> value = { startWithAudioMuted } />
</FormRow> </FormRow>
<FormRow label = 'settingsView.startWithVideoMuted'> <FormRow label = 'settingsView.startWithVideoMuted'>
<Switch <Switch
onValueChange = { this._onStartVideoMutedChange } onValueChange = { this._onStartVideoMutedChange }
value = { _settings.startWithVideoMuted } /> value = { startWithVideoMuted } />
</FormRow> </FormRow>
<FormSectionHeader <FormSectionHeader
label = 'settingsView.buildInfoSection' /> label = 'settingsView.buildInfoSection' />