Selaa lähdekoodia

auth: fix rendering error and progress messages

Also removed some no longer used styles.
master
Saúl Ibarra Corretgé 5 vuotta sitten
vanhempi
commit
36455c24c8

+ 77
- 50
react/features/authentication/components/LoginDialog.native.js Näytä tiedosto

@@ -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
 

+ 16
- 25
react/features/authentication/components/styles.js Näytä tiedosto

@@ -1,50 +1,41 @@
1
-import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
2
-
3
-/**
4
- * The style common to {@code LoginDialog} and {@code WaitForOwnerDialog}.
5
- */
6
-const dialog = {
7
-    marginBottom: BoxModel.margin,
8
-    marginTop: BoxModel.margin
9
-};
10
-
11
-/**
12
- * The style common to {@code Text} rendered by {@code LoginDialog} and
13
- * {@code WaitForOwnerDialog}.
14
- */
15
-const text = {
16
-    color: ColorPalette.white
17
-};
1
+import { ColorSchemeRegistry, schemeColor } from '../../base/color-scheme';
2
+import { BoxModel } from '../../base/styles';
18 3
 
19 4
 /**
20 5
  * The styles of the authentication feature.
21 6
  */
22
-export default createStyleSheet({
7
+ColorSchemeRegistry.register('LoginDialog', {
23 8
 
24 9
     /**
25 10
      * The style of {@code Text} rendered by the {@code Dialog}s of the
26 11
      * feature authentication.
27 12
      */
28 13
     dialogText: {
29
-        ...text,
30 14
         margin: BoxModel.margin,
31 15
         marginTop: BoxModel.margin * 2
32 16
     },
33 17
 
18
+    /**
19
+     * The style used when an error message is rendered.
20
+     */
21
+    errorMessage: {
22
+        color: schemeColor('errorText')
23
+    },
24
+
34 25
     /**
35 26
      * The style of {@code LoginDialog}.
36 27
      */
37 28
     loginDialog: {
38
-        ...dialog,
39 29
         flex: 0,
40
-        flexDirection: 'column'
30
+        flexDirection: 'column',
31
+        marginBottom: BoxModel.margin,
32
+        marginTop: BoxModel.margin
41 33
     },
42 34
 
43 35
     /**
44
-     * The style of {@code WaitForOwnerDialog}.
36
+     * The style used then a progress message is rendered.
45 37
      */
46
-    waitForOwnerDialog: {
47
-        ...dialog,
48
-        ...text
38
+    progressMessage: {
39
+        color: schemeColor('text')
49 40
     }
50 41
 });

+ 1
- 0
react/features/base/color-scheme/defaultScheme.js Näytä tiedosto

@@ -10,6 +10,7 @@ export default {
10 10
         // Generic app theme colors that are used accross the entire app.
11 11
         // All scheme definitions below inherit these values.
12 12
         background: 'rgb(255, 255, 255)',
13
+        errorText: ColorPalette.red,
13 14
         icon: 'rgb(28, 32, 37)',
14 15
         text: 'rgb(28, 32, 37)'
15 16
     },

Loading…
Peruuta
Tallenna