|
@@ -1,10 +1,13 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import React, { Component } from 'react';
|
4
|
|
-import { Platform } from 'react-native';
|
|
3
|
+import React, { PureComponent } from 'react';
|
|
4
|
+import { Platform, TouchableOpacity } from 'react-native';
|
|
5
|
+import Collapsible from 'react-native-collapsible';
|
|
6
|
+import GestureRecognizer, { swipeDirections } from 'react-native-swipe-gestures';
|
5
|
7
|
|
6
|
8
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
7
|
9
|
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
|
|
10
|
+import { IconDragHandle } from '../../../base/icons';
|
8
|
11
|
import { CHAT_ENABLED, IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
|
9
|
12
|
import { connect } from '../../../base/redux';
|
10
|
13
|
import { StyleType } from '../../../base/styles';
|
|
@@ -16,10 +19,12 @@ import { RoomLockButton } from '../../../room-lock';
|
16
|
19
|
import { ClosedCaptionButton } from '../../../subtitles';
|
17
|
20
|
import { TileViewButton } from '../../../video-layout';
|
18
|
21
|
|
19
|
|
-import AudioOnlyButton from './AudioOnlyButton';
|
20
|
22
|
import HelpButton from '../HelpButton';
|
|
23
|
+
|
|
24
|
+import AudioOnlyButton from './AudioOnlyButton';
|
21
|
25
|
import RaiseHandButton from './RaiseHandButton';
|
22
|
26
|
import ToggleCameraButton from './ToggleCameraButton';
|
|
27
|
+import styles from './styles';
|
23
|
28
|
|
24
|
29
|
/**
|
25
|
30
|
* The type of the React {@code Component} props of {@link OverflowMenu}.
|
|
@@ -52,6 +57,14 @@ type Props = {
|
52
|
57
|
dispatch: Function
|
53
|
58
|
};
|
54
|
59
|
|
|
60
|
+type State = {
|
|
61
|
+
|
|
62
|
+ /**
|
|
63
|
+ * True if the 'more' button set needas to be rendered.
|
|
64
|
+ */
|
|
65
|
+ showMore: boolean
|
|
66
|
+}
|
|
67
|
+
|
55
|
68
|
/**
|
56
|
69
|
* The exported React {@code Component}. We need it to execute
|
57
|
70
|
* {@link hideDialog}.
|
|
@@ -65,7 +78,7 @@ let OverflowMenu_; // eslint-disable-line prefer-const
|
65
|
78
|
* Implements a React {@code Component} with some extra actions in addition to
|
66
|
79
|
* those in the toolbar.
|
67
|
80
|
*/
|
68
|
|
-class OverflowMenu extends Component<Props> {
|
|
81
|
+class OverflowMenu extends PureComponent<Props, State> {
|
69
|
82
|
/**
|
70
|
83
|
* Initializes a new {@code OverflowMenu} instance.
|
71
|
84
|
*
|
|
@@ -74,8 +87,15 @@ class OverflowMenu extends Component<Props> {
|
74
|
87
|
constructor(props: Props) {
|
75
|
88
|
super(props);
|
76
|
89
|
|
|
90
|
+ this.state = {
|
|
91
|
+ showMore: false
|
|
92
|
+ };
|
|
93
|
+
|
77
|
94
|
// Bind event handlers so they are only bound once per instance.
|
78
|
95
|
this._onCancel = this._onCancel.bind(this);
|
|
96
|
+ this._onSwipe = this._onSwipe.bind(this);
|
|
97
|
+ this._onToggleMenu = this._onToggleMenu.bind(this);
|
|
98
|
+ this._renderMenuExpandToggle = this._renderMenuExpandToggle.bind(this);
|
79
|
99
|
}
|
80
|
100
|
|
81
|
101
|
/**
|
|
@@ -85,37 +105,71 @@ class OverflowMenu extends Component<Props> {
|
85
|
105
|
* @returns {ReactElement}
|
86
|
106
|
*/
|
87
|
107
|
render() {
|
|
108
|
+ const { _bottomSheetStyles } = this.props;
|
|
109
|
+ const { showMore } = this.state;
|
|
110
|
+
|
88
|
111
|
const buttonProps = {
|
89
|
112
|
afterClick: this._onCancel,
|
90
|
113
|
showLabel: true,
|
91
|
|
- styles: this.props._bottomSheetStyles
|
|
114
|
+ styles: _bottomSheetStyles.buttons
|
92
|
115
|
};
|
93
|
116
|
|
94
|
117
|
return (
|
95
|
|
- <BottomSheet onCancel = { this._onCancel }>
|
|
118
|
+ <BottomSheet
|
|
119
|
+ onCancel = { this._onCancel }
|
|
120
|
+ renderHeader = { this._renderMenuExpandToggle }>
|
96
|
121
|
<AudioRouteButton { ...buttonProps } />
|
97
|
122
|
<ToggleCameraButton { ...buttonProps } />
|
98
|
123
|
<AudioOnlyButton { ...buttonProps } />
|
99
|
|
- <RoomLockButton { ...buttonProps } />
|
100
|
|
- <ClosedCaptionButton { ...buttonProps } />
|
101
|
|
- {
|
102
|
|
- this.props._recordingEnabled
|
103
|
|
- && <RecordButton { ...buttonProps } />
|
104
|
|
- }
|
105
|
|
- <LiveStreamButton { ...buttonProps } />
|
106
|
|
- <TileViewButton { ...buttonProps } />
|
107
|
|
- <InviteButton { ...buttonProps } />
|
108
|
|
- {
|
109
|
|
- this.props._chatEnabled
|
110
|
|
- && <InfoDialogButton { ...buttonProps } />
|
111
|
|
- }
|
112
|
|
- <RaiseHandButton { ...buttonProps } />
|
113
|
|
- <SharedDocumentButton { ...buttonProps } />
|
114
|
|
- <HelpButton { ...buttonProps } />
|
|
124
|
+ <Collapsible collapsed = { !showMore }>
|
|
125
|
+ <RoomLockButton { ...buttonProps } />
|
|
126
|
+ <ClosedCaptionButton { ...buttonProps } />
|
|
127
|
+ {
|
|
128
|
+ this.props._recordingEnabled
|
|
129
|
+ && <RecordButton { ...buttonProps } />
|
|
130
|
+ }
|
|
131
|
+ <LiveStreamButton { ...buttonProps } />
|
|
132
|
+ <TileViewButton { ...buttonProps } />
|
|
133
|
+ <InviteButton { ...buttonProps } />
|
|
134
|
+ {
|
|
135
|
+ this.props._chatEnabled
|
|
136
|
+ && <InfoDialogButton { ...buttonProps } />
|
|
137
|
+ }
|
|
138
|
+ <RaiseHandButton { ...buttonProps } />
|
|
139
|
+ <SharedDocumentButton { ...buttonProps } />
|
|
140
|
+ <HelpButton { ...buttonProps } />
|
|
141
|
+ </Collapsible>
|
115
|
142
|
</BottomSheet>
|
116
|
143
|
);
|
117
|
144
|
}
|
118
|
145
|
|
|
146
|
+ _renderMenuExpandToggle: () => React$Element<any>;
|
|
147
|
+
|
|
148
|
+ /**
|
|
149
|
+ * Function to render the menu toggle in the bottom sheet header area.
|
|
150
|
+ *
|
|
151
|
+ * @returns {React$Element}
|
|
152
|
+ */
|
|
153
|
+ _renderMenuExpandToggle() {
|
|
154
|
+ return (
|
|
155
|
+ <GestureRecognizer
|
|
156
|
+ config = {{
|
|
157
|
+ velocityThreshold: 0.1,
|
|
158
|
+ directionalOffsetThreshold: 30
|
|
159
|
+ }}
|
|
160
|
+ onSwipe = { this._onSwipe }
|
|
161
|
+ style = { [
|
|
162
|
+ this.props._bottomSheetStyles.sheet,
|
|
163
|
+ styles.expandMenuContainer
|
|
164
|
+ ] }>
|
|
165
|
+ <TouchableOpacity onPress = { this._onToggleMenu }>
|
|
166
|
+ { /* $FlowFixMeProps */ }
|
|
167
|
+ <IconDragHandle style = { this.props._bottomSheetStyles.expandIcon } />
|
|
168
|
+ </TouchableOpacity>
|
|
169
|
+ </GestureRecognizer>
|
|
170
|
+ );
|
|
171
|
+ }
|
|
172
|
+
|
119
|
173
|
_onCancel: () => boolean;
|
120
|
174
|
|
121
|
175
|
/**
|
|
@@ -133,6 +187,50 @@ class OverflowMenu extends Component<Props> {
|
133
|
187
|
|
134
|
188
|
return false;
|
135
|
189
|
}
|
|
190
|
+
|
|
191
|
+ _onSwipe: (string) => void;
|
|
192
|
+
|
|
193
|
+ /**
|
|
194
|
+ * Callback to be invoked when a swipe gesture is detected on the menu.
|
|
195
|
+ *
|
|
196
|
+ * @param {string} gestureName - The name of the swipe gesture.
|
|
197
|
+ * @returns {void}
|
|
198
|
+ */
|
|
199
|
+ _onSwipe(gestureName) {
|
|
200
|
+ const { showMore } = this.state;
|
|
201
|
+
|
|
202
|
+ switch (gestureName) {
|
|
203
|
+ case swipeDirections.SWIPE_UP:
|
|
204
|
+ !showMore && this.setState({
|
|
205
|
+ showMore: true
|
|
206
|
+ });
|
|
207
|
+ break;
|
|
208
|
+ case swipeDirections.SWIPE_DOWN:
|
|
209
|
+ if (showMore) {
|
|
210
|
+ // If the menu is expanded, we collapse it.
|
|
211
|
+ this.setState({
|
|
212
|
+ showMore: false
|
|
213
|
+ });
|
|
214
|
+ } else {
|
|
215
|
+ // If the menu is not expanded, we close the menu
|
|
216
|
+ this._onCancel();
|
|
217
|
+ }
|
|
218
|
+ break;
|
|
219
|
+ }
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ _onToggleMenu: () => void;
|
|
223
|
+
|
|
224
|
+ /**
|
|
225
|
+ * Callback to be invoked when the expand menu button is pressed.
|
|
226
|
+ *
|
|
227
|
+ * @returns {void}
|
|
228
|
+ */
|
|
229
|
+ _onToggleMenu() {
|
|
230
|
+ this.setState({
|
|
231
|
+ showMore: !this.state.showMore
|
|
232
|
+ });
|
|
233
|
+ }
|
136
|
234
|
}
|
137
|
235
|
|
138
|
236
|
/**
|