|
@@ -5,6 +5,7 @@ import { Text, TextInput, View } from 'react-native';
|
5
|
5
|
import { connect as reduxConnect } from 'react-redux';
|
6
|
6
|
import type { Dispatch } from 'redux';
|
7
|
7
|
|
|
8
|
+import { ColorSchemeRegistry } from '../../base/color-scheme';
|
8
|
9
|
import { toJid } from '../../base/connection';
|
9
|
10
|
import { connect } from '../../base/connection/actions.native';
|
10
|
11
|
import {
|
|
@@ -19,7 +20,9 @@ import { JitsiConnectionErrors } from '../../base/lib-jitsi-meet';
|
19
|
20
|
import type { StyleType } from '../../base/styles';
|
20
|
21
|
|
21
|
22
|
import { authenticateAndUpgradeRole, cancelLogin } from '../actions';
|
22
|
|
-import styles from './styles';
|
|
23
|
+
|
|
24
|
+// Register styles.
|
|
25
|
+import './styles';
|
23
|
26
|
|
24
|
27
|
/**
|
25
|
28
|
* The type of the React {@link Component} props of {@link LoginDialog}.
|
|
@@ -58,6 +61,11 @@ type Props = {
|
58
|
61
|
*/
|
59
|
62
|
_progress: number,
|
60
|
63
|
|
|
64
|
+ /**
|
|
65
|
+ * The color-schemed stylesheet of this feature.
|
|
66
|
+ */
|
|
67
|
+ _styles: StyleType,
|
|
68
|
+
|
61
|
69
|
/**
|
62
|
70
|
* Redux store dispatch method.
|
63
|
71
|
*/
|
|
@@ -144,12 +152,59 @@ class LoginDialog extends Component<Props, State> {
|
144
|
152
|
const {
|
145
|
153
|
_connecting: connecting,
|
146
|
154
|
_dialogStyles,
|
|
155
|
+ _styles: styles,
|
|
156
|
+ t
|
|
157
|
+ } = this.props;
|
|
158
|
+
|
|
159
|
+ return (
|
|
160
|
+ <CustomSubmitDialog
|
|
161
|
+ okDisabled = { connecting }
|
|
162
|
+ onCancel = { this._onCancel }
|
|
163
|
+ onSubmit = { this._onLogin }>
|
|
164
|
+ <View style = { styles.loginDialog }>
|
|
165
|
+ <TextInput
|
|
166
|
+ autoCapitalize = { 'none' }
|
|
167
|
+ autoCorrect = { false }
|
|
168
|
+ onChangeText = { this._onUsernameChange }
|
|
169
|
+ placeholder = { 'user@domain.com' }
|
|
170
|
+ placeholderTextColor = { PLACEHOLDER_COLOR }
|
|
171
|
+ style = { _dialogStyles.field }
|
|
172
|
+ underlineColorAndroid = { FIELD_UNDERLINE }
|
|
173
|
+ value = { this.state.username } />
|
|
174
|
+ <TextInput
|
|
175
|
+ onChangeText = { this._onPasswordChange }
|
|
176
|
+ placeholder = { t('dialog.userPassword') }
|
|
177
|
+ placeholderTextColor = { PLACEHOLDER_COLOR }
|
|
178
|
+ secureTextEntry = { true }
|
|
179
|
+ style = { [
|
|
180
|
+ _dialogStyles.field,
|
|
181
|
+ inputDialogStyle.bottomField
|
|
182
|
+ ] }
|
|
183
|
+ underlineColorAndroid = { FIELD_UNDERLINE }
|
|
184
|
+ value = { this.state.password } />
|
|
185
|
+ { this._renderMessage() }
|
|
186
|
+ </View>
|
|
187
|
+ </CustomSubmitDialog>
|
|
188
|
+ );
|
|
189
|
+ }
|
|
190
|
+
|
|
191
|
+ /**
|
|
192
|
+ * Renders an optional message, if applicable.
|
|
193
|
+ *
|
|
194
|
+ * @returns {ReactElement}
|
|
195
|
+ * @private
|
|
196
|
+ */
|
|
197
|
+ _renderMessage() {
|
|
198
|
+ const {
|
|
199
|
+ _connecting: connecting,
|
147
|
200
|
_error: error,
|
148
|
201
|
_progress: progress,
|
|
202
|
+ _styles: styles,
|
149
|
203
|
t
|
150
|
204
|
} = this.props;
|
151
|
205
|
|
152
|
206
|
let messageKey;
|
|
207
|
+ let messageIsError = false;
|
153
|
208
|
const messageOptions = {};
|
154
|
209
|
|
155
|
210
|
if (progress && progress < 1) {
|
|
@@ -170,54 +225,32 @@ class LoginDialog extends Component<Props, State> {
|
170
|
225
|
this.props._configHosts)
|
171
|
226
|
&& credentials.password === this.state.password) {
|
172
|
227
|
messageKey = 'dialog.incorrectPassword';
|
|
228
|
+ messageIsError = true;
|
173
|
229
|
}
|
174
|
230
|
} else if (name) {
|
175
|
231
|
messageKey = 'dialog.connectErrorWithMsg';
|
176
|
232
|
messageOptions.msg = `${name} ${error.message}`;
|
|
233
|
+ messageIsError = true;
|
177
|
234
|
}
|
|
235
|
+ } else if (connecting) {
|
|
236
|
+ messageKey = 'connection.CONNECTING';
|
178
|
237
|
}
|
179
|
238
|
|
180
|
|
- const showMessage = messageKey || connecting;
|
181
|
|
- const message = messageKey
|
182
|
|
- ? t(messageKey, messageOptions)
|
183
|
|
- : connecting
|
184
|
|
- ? t('connection.CONNECTING')
|
185
|
|
- : '';
|
|
239
|
+ if (messageKey) {
|
|
240
|
+ const message = t(messageKey, messageOptions);
|
|
241
|
+ const messageStyles = [
|
|
242
|
+ styles.dialogText,
|
|
243
|
+ messageIsError ? styles.errorMessage : styles.progressMessage
|
|
244
|
+ ];
|
|
245
|
+
|
|
246
|
+ return (
|
|
247
|
+ <Text style = { messageStyles }>
|
|
248
|
+ { message }
|
|
249
|
+ </Text>
|
|
250
|
+ );
|
|
251
|
+ }
|
186
|
252
|
|
187
|
|
- return (
|
188
|
|
- <CustomSubmitDialog
|
189
|
|
- okDisabled = { connecting }
|
190
|
|
- onCancel = { this._onCancel }
|
191
|
|
- onSubmit = { this._onLogin }>
|
192
|
|
- <View style = { styles.loginDialog }>
|
193
|
|
- <TextInput
|
194
|
|
- autoCapitalize = { 'none' }
|
195
|
|
- autoCorrect = { false }
|
196
|
|
- onChangeText = { this._onUsernameChange }
|
197
|
|
- placeholder = { 'user@domain.com' }
|
198
|
|
- placeholderTextColor = { PLACEHOLDER_COLOR }
|
199
|
|
- style = { _dialogStyles.field }
|
200
|
|
- underlineColorAndroid = { FIELD_UNDERLINE }
|
201
|
|
- value = { this.state.username } />
|
202
|
|
- <TextInput
|
203
|
|
- onChangeText = { this._onPasswordChange }
|
204
|
|
- placeholder = { t('dialog.userPassword') }
|
205
|
|
- placeholderTextColor = { PLACEHOLDER_COLOR }
|
206
|
|
- secureTextEntry = { true }
|
207
|
|
- style = { [
|
208
|
|
- _dialogStyles.field,
|
209
|
|
- inputDialogStyle.bottomField
|
210
|
|
- ] }
|
211
|
|
- underlineColorAndroid = { FIELD_UNDERLINE }
|
212
|
|
- value = { this.state.password } />
|
213
|
|
- { showMessage && (
|
214
|
|
- <Text style = { styles.dialogText }>
|
215
|
|
- { message }
|
216
|
|
- </Text>
|
217
|
|
- ) }
|
218
|
|
- </View>
|
219
|
|
- </CustomSubmitDialog>
|
220
|
|
- );
|
|
253
|
+ return null;
|
221
|
254
|
}
|
222
|
255
|
|
223
|
256
|
_onUsernameChange: (string) => void;
|
|
@@ -295,14 +328,7 @@ class LoginDialog extends Component<Props, State> {
|
295
|
328
|
*
|
296
|
329
|
* @param {Object} state - The Redux state.
|
297
|
330
|
* @private
|
298
|
|
- * @returns {{
|
299
|
|
- * _conference: JitsiConference,
|
300
|
|
- * _configHosts: Object,
|
301
|
|
- * _connecting: boolean,
|
302
|
|
- * _dialogStyles: StyleType,
|
303
|
|
- * _error: Object,
|
304
|
|
- * _progress: number
|
305
|
|
- * }}
|
|
331
|
+ * @returns {Props}
|
306
|
332
|
*/
|
307
|
333
|
function _mapStateToProps(state) {
|
308
|
334
|
const {
|
|
@@ -323,7 +349,8 @@ function _mapStateToProps(state) {
|
323
|
349
|
_configHosts: configHosts,
|
324
|
350
|
_connecting: Boolean(connecting) || Boolean(thenableWithCancel),
|
325
|
351
|
_error: connectionError || authenticateAndUpgradeRoleError,
|
326
|
|
- _progress: progress
|
|
352
|
+ _progress: progress,
|
|
353
|
+ _styles: ColorSchemeRegistry.get(state, 'LoginDialog')
|
327
|
354
|
};
|
328
|
355
|
}
|
329
|
356
|
|