|
|
@@ -1,5 +1,6 @@
|
|
1
|
1
|
import React from 'react';
|
|
2
|
2
|
import {
|
|
|
3
|
+ Animated,
|
|
3
|
4
|
Keyboard,
|
|
4
|
5
|
SafeAreaView,
|
|
5
|
6
|
Switch,
|
|
|
@@ -59,8 +60,13 @@ class WelcomePage extends AbstractWelcomePage {
|
|
59
|
60
|
constructor(props) {
|
|
60
|
61
|
super(props);
|
|
61
|
62
|
|
|
|
63
|
+ this.state.hintBoxAnimation = new Animated.Value(0);
|
|
|
64
|
+
|
|
|
65
|
+ this._getHintBoxStyle = this._getHintBoxStyle.bind(this);
|
|
|
66
|
+ this._onFieldFocusChange = this._onFieldFocusChange.bind(this);
|
|
62
|
67
|
this._onShowSideBar = this._onShowSideBar.bind(this);
|
|
63
|
68
|
this._onStartAudioOnlyChange = this._onStartAudioOnlyChange.bind(this);
|
|
|
69
|
+ this._renderHintBox = this._renderHintBox.bind(this);
|
|
64
|
70
|
}
|
|
65
|
71
|
|
|
66
|
72
|
/**
|
|
|
@@ -124,7 +130,9 @@ class WelcomePage extends AbstractWelcomePage {
|
|
124
|
130
|
autoComplete = { false }
|
|
125
|
131
|
autoCorrect = { false }
|
|
126
|
132
|
autoFocus = { false }
|
|
|
133
|
+ onBlur = { this._onFieldFocusChange(false) }
|
|
127
|
134
|
onChangeText = { this._onRoomChange }
|
|
|
135
|
+ onFocus = { this._onFieldFocusChange(true) }
|
|
128
|
136
|
onSubmitEditing = { this._onJoin }
|
|
129
|
137
|
placeholder = { t('welcomepage.roomname') }
|
|
130
|
138
|
placeholderTextColor = { PLACEHOLDER_TEXT_COLOR }
|
|
|
@@ -133,9 +141,9 @@ class WelcomePage extends AbstractWelcomePage {
|
|
133
|
141
|
underlineColorAndroid = 'transparent'
|
|
134
|
142
|
value = { this.state.room } />
|
|
135
|
143
|
{
|
|
136
|
|
- this._renderJoinButton()
|
|
|
144
|
+ this._renderHintBox()
|
|
137
|
145
|
}
|
|
138
|
|
- <RecentList />
|
|
|
146
|
+ <RecentList disabled = { this.state._fieldFocused } />
|
|
139
|
147
|
</SafeAreaView>
|
|
140
|
148
|
<AppSettings />
|
|
141
|
149
|
</View>
|
|
|
@@ -144,6 +152,50 @@ class WelcomePage extends AbstractWelcomePage {
|
|
144
|
152
|
);
|
|
145
|
153
|
}
|
|
146
|
154
|
|
|
|
155
|
+ /**
|
|
|
156
|
+ * Constructs a style array to handle the hint box animation.
|
|
|
157
|
+ *
|
|
|
158
|
+ * @private
|
|
|
159
|
+ * @returns {Array<Object>}
|
|
|
160
|
+ */
|
|
|
161
|
+ _getHintBoxStyle() {
|
|
|
162
|
+ return [
|
|
|
163
|
+ styles.hintContainer,
|
|
|
164
|
+ {
|
|
|
165
|
+ opacity: this.state.hintBoxAnimation
|
|
|
166
|
+ }
|
|
|
167
|
+ ];
|
|
|
168
|
+ }
|
|
|
169
|
+
|
|
|
170
|
+ /**
|
|
|
171
|
+ * Callback for when the room field's focus changes so the hint box
|
|
|
172
|
+ * must be rendered or removed.
|
|
|
173
|
+ *
|
|
|
174
|
+ * @private
|
|
|
175
|
+ * @param {boolean} focused - The focused state of the field.
|
|
|
176
|
+ * @returns {Function}
|
|
|
177
|
+ */
|
|
|
178
|
+ _onFieldFocusChange(focused) {
|
|
|
179
|
+ return () => {
|
|
|
180
|
+ if (focused) {
|
|
|
181
|
+ this.setState({
|
|
|
182
|
+ _fieldFocused: true
|
|
|
183
|
+ });
|
|
|
184
|
+ }
|
|
|
185
|
+
|
|
|
186
|
+ Animated.timing(this.state.hintBoxAnimation, {
|
|
|
187
|
+ duration: 300,
|
|
|
188
|
+ toValue: focused ? 1 : 0
|
|
|
189
|
+ }).start(animationState => {
|
|
|
190
|
+ if (animationState.finished && !focused) {
|
|
|
191
|
+ this.setState({
|
|
|
192
|
+ _fieldFocused: false
|
|
|
193
|
+ });
|
|
|
194
|
+ }
|
|
|
195
|
+ });
|
|
|
196
|
+ };
|
|
|
197
|
+ }
|
|
|
198
|
+
|
|
147
|
199
|
/**
|
|
148
|
200
|
* Toggles the side bar.
|
|
149
|
201
|
*
|
|
|
@@ -171,6 +223,36 @@ class WelcomePage extends AbstractWelcomePage {
|
|
171
|
223
|
}));
|
|
172
|
224
|
}
|
|
173
|
225
|
|
|
|
226
|
+ /**
|
|
|
227
|
+ * Renders the hint box if necessary.
|
|
|
228
|
+ *
|
|
|
229
|
+ * @private
|
|
|
230
|
+ * @returns {React$Node}
|
|
|
231
|
+ */
|
|
|
232
|
+ _renderHintBox() {
|
|
|
233
|
+ if (this.state._fieldFocused) {
|
|
|
234
|
+ const { t } = this.props;
|
|
|
235
|
+
|
|
|
236
|
+ return (
|
|
|
237
|
+ <Animated.View
|
|
|
238
|
+ style = { this._getHintBoxStyle() }>
|
|
|
239
|
+ <View style = { styles.hintTextContainer } >
|
|
|
240
|
+ <Text>
|
|
|
241
|
+ { t('welcomepage.hintText') }
|
|
|
242
|
+ </Text>
|
|
|
243
|
+ </View>
|
|
|
244
|
+ <View style = { styles.hintButtonContainer } >
|
|
|
245
|
+ {
|
|
|
246
|
+ this._renderJoinButton()
|
|
|
247
|
+ }
|
|
|
248
|
+ </View>
|
|
|
249
|
+ </Animated.View>
|
|
|
250
|
+ );
|
|
|
251
|
+ }
|
|
|
252
|
+
|
|
|
253
|
+ return null;
|
|
|
254
|
+ }
|
|
|
255
|
+
|
|
174
|
256
|
/**
|
|
175
|
257
|
* Renders the join button.
|
|
176
|
258
|
*
|
|
|
@@ -188,7 +270,9 @@ class WelcomePage extends AbstractWelcomePage {
|
|
188
|
270
|
// modify non-native children.
|
|
189
|
271
|
children = (
|
|
190
|
272
|
<View>
|
|
191
|
|
- <LoadingIndicator color = { styles.buttonText.color } />
|
|
|
273
|
+ <LoadingIndicator
|
|
|
274
|
+ color = { styles.buttonText.color }
|
|
|
275
|
+ size = 'small' />
|
|
192
|
276
|
</View>
|
|
193
|
277
|
);
|
|
194
|
278
|
} else {
|
|
|
@@ -201,12 +285,17 @@ class WelcomePage extends AbstractWelcomePage {
|
|
201
|
285
|
|
|
202
|
286
|
/* eslint-enable no-extra-parens */
|
|
203
|
287
|
|
|
|
288
|
+ const buttonDisabled = this._isJoinDisabled();
|
|
|
289
|
+
|
|
204
|
290
|
return (
|
|
205
|
291
|
<TouchableHighlight
|
|
206
|
292
|
accessibilityLabel = { 'Tap to Join.' }
|
|
207
|
|
- disabled = { this._isJoinDisabled() }
|
|
|
293
|
+ disabled = { buttonDisabled }
|
|
208
|
294
|
onPress = { this._onJoin }
|
|
209
|
|
- style = { styles.button }
|
|
|
295
|
+ style = { [
|
|
|
296
|
+ styles.button,
|
|
|
297
|
+ buttonDisabled ? styles.buttonDisabled : null
|
|
|
298
|
+ ] }
|
|
210
|
299
|
underlayColor = { ColorPalette.white }>
|
|
211
|
300
|
{
|
|
212
|
301
|
children
|