Bläddra i källkod

[RN] WelcomeScreen post-merge changes

master
Bettenbuk Zoltan 7 år sedan
förälder
incheckning
5579464951

+ 1
- 2
react/features/base/known-domains/reducer.js Visa fil

@@ -61,8 +61,7 @@ function _addKnownDomains(state, knownDomains) {
61 61
         nextState = Array.from(state);
62 62
         for (let knownDomain of knownDomains) {
63 63
             knownDomain = knownDomain.toLowerCase();
64
-            nextState.indexOf(knownDomain) === -1
65
-                && nextState.push(knownDomain);
64
+            !nextState.includes(knownDomain) && nextState.push(knownDomain);
66 65
         }
67 66
     }
68 67
 

+ 2
- 2
react/features/settings/components/native/FormRow.js Visa fil

@@ -25,7 +25,7 @@ type Props = {
25 25
     /**
26 26
      * The i18n key of the text label of the form field.
27 27
      */
28
-    i18nLabel: string,
28
+    label: string,
29 29
 
30 30
     /**
31 31
      * Invoked to obtain translated strings.
@@ -78,7 +78,7 @@ class FormRow extends Component<Props> {
78 78
                             styles.text,
79 79
                             styles.fieldLabelText
80 80
                         ] } >
81
-                        { t(this.props.i18nLabel) }
81
+                        { t(this.props.label) }
82 82
                     </Text>
83 83
                 </View>
84 84
                 <View style = { styles.fieldValueContainer } >

+ 3
- 3
react/features/settings/components/native/FormSectionHeader.js Visa fil

@@ -15,7 +15,7 @@ type Props = {
15 15
     /**
16 16
      * The i18n key of the text label of the section.
17 17
      */
18
-    i18nLabel: string,
18
+    label: string,
19 19
 
20 20
     /**
21 21
      * An external style object passed to the component.
@@ -41,7 +41,7 @@ class FormSectionHeader extends Component<Props> {
41 41
      * @returns {ReactElement}
42 42
      */
43 43
     render() {
44
-        const { i18nLabel, style, t } = this.props;
44
+        const { label, style, t } = this.props;
45 45
 
46 46
         return (
47 47
             <View
@@ -50,7 +50,7 @@ class FormSectionHeader extends Component<Props> {
50 50
                     style
51 51
                 ] } >
52 52
                 <Text>
53
-                    { t(i18nLabel) }
53
+                    { t(label) }
54 54
                 </Text>
55 55
             </View>
56 56
         );

+ 7
- 7
react/features/settings/components/native/SettingsView.js Visa fil

@@ -146,17 +146,17 @@ class SettingsView extends AbstractSettingsView {
146 146
             <SafeAreaView style = { styles.settingsForm }>
147 147
                 <ScrollView>
148 148
                     <FormSectionHeader
149
-                        i18nLabel = 'settingsView.profileSection' />
149
+                        label = 'settingsView.profileSection' />
150 150
                     <FormRow
151 151
                         fieldSeparator = { true }
152
-                        i18nLabel = 'settingsView.displayName'>
152
+                        label = 'settingsView.displayName'>
153 153
                         <TextInput
154 154
                             autoCorrect = { false }
155 155
                             onChangeText = { this._onChangeDisplayName }
156 156
                             placeholder = 'John Doe'
157 157
                             value = { _settings.displayName } />
158 158
                     </FormRow>
159
-                    <FormRow i18nLabel = 'settingsView.email'>
159
+                    <FormRow label = 'settingsView.email'>
160 160
                         <TextInput
161 161
                             autoCapitalize = 'none'
162 162
                             autoCorrect = { false }
@@ -166,10 +166,10 @@ class SettingsView extends AbstractSettingsView {
166 166
                             value = { _settings.email } />
167 167
                     </FormRow>
168 168
                     <FormSectionHeader
169
-                        i18nLabel = 'settingsView.conferenceSection' />
169
+                        label = 'settingsView.conferenceSection' />
170 170
                     <FormRow
171 171
                         fieldSeparator = { true }
172
-                        i18nLabel = 'settingsView.serverURL'>
172
+                        label = 'settingsView.serverURL'>
173 173
                         <TextInput
174 174
                             autoCapitalize = 'none'
175 175
                             autoCorrect = { false }
@@ -180,12 +180,12 @@ class SettingsView extends AbstractSettingsView {
180 180
                     </FormRow>
181 181
                     <FormRow
182 182
                         fieldSeparator = { true }
183
-                        i18nLabel = 'settingsView.startWithAudioMuted'>
183
+                        label = 'settingsView.startWithAudioMuted'>
184 184
                         <Switch
185 185
                             onValueChange = { this._onStartAudioMutedChange }
186 186
                             value = { _settings.startWithAudioMuted } />
187 187
                     </FormRow>
188
-                    <FormRow i18nLabel = 'settingsView.startWithVideoMuted'>
188
+                    <FormRow label = 'settingsView.startWithVideoMuted'>
189 189
                         <Switch
190 190
                             onValueChange = { this._onStartVideoMutedChange }
191 191
                             value = { _settings.startWithVideoMuted } />

+ 6
- 6
react/features/welcome/components/SideBarItem.js Visa fil

@@ -11,14 +11,14 @@ import styles from './styles';
11 11
 type Props = {
12 12
 
13 13
     /**
14
-     * The i18n label of the item.
14
+     * The icon of the item.
15 15
      */
16
-    i18Label: string,
16
+    icon: string,
17 17
 
18 18
     /**
19
-     * The icon of the item.
19
+     * The i18n label of the item.
20 20
      */
21
-    icon: string,
21
+    label: string,
22 22
 
23 23
     /**
24 24
      * The function to be invoked when the item is pressed
@@ -61,7 +61,7 @@ class SideBarItem extends Component<Props> {
61 61
      * @returns {ReactElement}
62 62
      */
63 63
     render() {
64
-        const { onPress, t } = this.props;
64
+        const { label, onPress, t } = this.props;
65 65
         const onPressCalculated
66 66
             = typeof onPress === 'function' ? onPress : this._onOpenURL;
67 67
 
@@ -74,7 +74,7 @@ class SideBarItem extends Component<Props> {
74 74
                         name = { this.props.icon }
75 75
                         style = { styles.sideBarItemIcon } />
76 76
                     <Text style = { styles.sideBarItemText }>
77
-                        { t(this.props.i18Label) }
77
+                        { t(label) }
78 78
                     </Text>
79 79
                 </View>
80 80
             </TouchableOpacity>

+ 23
- 22
react/features/welcome/components/WelcomePage.native.js Visa fil

@@ -47,10 +47,13 @@ class WelcomePage extends AbstractWelcomePage {
47 47
         this.state.hintBoxAnimation = new Animated.Value(0);
48 48
 
49 49
         // Bind event handlers so they are only bound once per instance.
50
-        this._getHintBoxStyle = this._getHintBoxStyle.bind(this);
51 50
         this._onFieldFocusChange = this._onFieldFocusChange.bind(this);
52 51
         this._onShowSideBar = this._onShowSideBar.bind(this);
53 52
         this._renderHintBox = this._renderHintBox.bind(this);
53
+
54
+        // Specially bind functions to avoid function definition on render.
55
+        this._onFieldBlur = this._onFieldFocusChange.bind(this, false);
56
+        this._onFieldFocus = this._onFieldFocusChange.bind(this, true);
54 57
     }
55 58
 
56 59
     /**
@@ -103,9 +106,9 @@ class WelcomePage extends AbstractWelcomePage {
103 106
                                 autoComplete = { false }
104 107
                                 autoCorrect = { false }
105 108
                                 autoFocus = { false }
106
-                                onBlur = { this._onFieldFocusChange(false) }
109
+                                onBlur = { this._onFieldBlur }
107 110
                                 onChangeText = { this._onRoomChange }
108
-                                onFocus = { this._onFieldFocusChange(true) }
111
+                                onFocus = { this._onFieldFocus }
109 112
                                 onSubmitEditing = { this._onJoin }
110 113
                                 placeholder = { t('welcomepage.roomname') }
111 114
                                 placeholderTextColor = {
@@ -149,28 +152,26 @@ class WelcomePage extends AbstractWelcomePage {
149 152
      *
150 153
      * @private
151 154
      * @param {boolean} focused - The focused state of the field.
152
-     * @returns {Function}
155
+     * @returns {void}
153 156
      */
154 157
     _onFieldFocusChange(focused) {
155
-        return () => {
156
-            focused
157
-                && this.setState({
158
-                    _fieldFocused: true
159
-                });
158
+        focused
159
+            && this.setState({
160
+                _fieldFocused: true
161
+            });
160 162
 
161
-            Animated.timing(
162
-                this.state.hintBoxAnimation,
163
-                {
164
-                    duration: 300,
165
-                    toValue: focused ? 1 : 0
166
-                })
167
-                .start(animationState =>
168
-                    animationState.finished
169
-                        && !focused
170
-                        && this.setState({
171
-                            _fieldFocused: false
172
-                        }));
173
-        };
163
+        Animated.timing(
164
+            this.state.hintBoxAnimation,
165
+            {
166
+                duration: 300,
167
+                toValue: focused ? 1 : 0
168
+            })
169
+            .start(animationState =>
170
+                animationState.finished
171
+                    && !focused
172
+                    && this.setState({
173
+                        _fieldFocused: false
174
+                    }));
174 175
     }
175 176
 
176 177
     /**

+ 12
- 8
react/features/welcome/components/WelcomePageSideBar.native.js Visa fil

@@ -45,7 +45,7 @@ type Props = {
45 45
     /**
46 46
      * The avatar URL to be rendered.
47 47
      */
48
-    _avatar: string,
48
+    _avatarURL: string,
49 49
 
50 50
     /**
51 51
      * Display name of the local participant.
@@ -90,7 +90,7 @@ class WelcomePageSideBar extends Component<Props> {
90 90
                     <Avatar
91 91
                         size = { SIDEBAR_AVATAR_SIZE }
92 92
                         style = { styles.avatar }
93
-                        uri = { this.props._avatar } />
93
+                        uri = { this.props._avatarURL } />
94 94
                     <Text style = { styles.displayName }>
95 95
                         { this.props._displayName }
96 96
                     </Text>
@@ -99,20 +99,20 @@ class WelcomePageSideBar extends Component<Props> {
99 99
                     <ScrollView
100 100
                         style = { styles.itemContainer }>
101 101
                         <SideBarItem
102
-                            i18Label = 'settings.title'
103 102
                             icon = 'settings'
103
+                            label = 'settings.title'
104 104
                             onPress = { this._onOpenSettings } />
105 105
                         <SideBarItem
106
-                            i18Label = 'welcomepage.terms'
107 106
                             icon = 'info'
107
+                            label = 'welcomepage.terms'
108 108
                             url = { TERMS_URL } />
109 109
                         <SideBarItem
110
-                            i18Label = 'welcomepage.privacy'
111 110
                             icon = 'info'
111
+                            label = 'welcomepage.privacy'
112 112
                             url = { PRIVACY_URL } />
113 113
                         <SideBarItem
114
-                            i18Label = 'welcomepage.sendFeedback'
115 114
                             icon = 'info'
115
+                            label = 'welcomepage.sendFeedback'
116 116
                             url = { SEND_FEEDBACK_URL } />
117 117
                     </ScrollView>
118 118
                 </SafeAreaView>
@@ -153,13 +153,17 @@ class WelcomePageSideBar extends Component<Props> {
153 153
  *
154 154
  * @param {Object} state - The redux state.
155 155
  * @protected
156
- * @returns {Object}
156
+ * @returns {{
157
+ *     _avatarURL: string,
158
+ *     _displayName: string,
159
+ *     _visible: boolean
160
+ * }}
157 161
  */
158 162
 function _mapStateToProps(state: Object) {
159 163
     const localParticipant = getLocalParticipant(state);
160 164
 
161 165
     return {
162
-        _avatar: getAvatarURL(localParticipant),
166
+        _avatarURL: getAvatarURL(localParticipant),
163 167
         _displayName: getParticipantDisplayName(state, localParticipant.id),
164 168
         _visible: state['features/welcome'].sideBarVisible
165 169
     };

Laddar…
Avbryt
Spara