|
@@ -0,0 +1,143 @@
|
|
1
|
+// @flow
|
|
2
|
+
|
|
3
|
+import React, { PureComponent } from 'react';
|
|
4
|
+import { Text, TouchableOpacity, View } from 'react-native';
|
|
5
|
+
|
|
6
|
+import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
|
7
|
+import { getFeatureFlag, INVITE_ENABLED } from '../../../base/flags';
|
|
8
|
+import { connect } from '../../../base/redux';
|
|
9
|
+import { StyleType } from '../../../base/styles';
|
|
10
|
+import { translate } from '../../../base/i18n';
|
|
11
|
+import { getParticipantCount } from '../../../base/participants';
|
|
12
|
+import { isAddPeopleEnabled, isDialOutEnabled, setAddPeopleDialogVisible } from '../../../invite';
|
|
13
|
+import { beginShareRoom } from '../../../share-room';
|
|
14
|
+
|
|
15
|
+import styles from './styles';
|
|
16
|
+import { Icon, IconAddPeople } from '../../../base/icons';
|
|
17
|
+
|
|
18
|
+/**
|
|
19
|
+ * Props type of the component.
|
|
20
|
+ */
|
|
21
|
+type Props = {
|
|
22
|
+
|
|
23
|
+ /**
|
|
24
|
+ * True if any of the invite functions are enabled.
|
|
25
|
+ */
|
|
26
|
+ _inviteEnabled: boolean,
|
|
27
|
+
|
|
28
|
+ /**
|
|
29
|
+ * True if it's a lonely meeting (participant count excluding fakes is 1).
|
|
30
|
+ */
|
|
31
|
+ _isLonelyMeeting: boolean,
|
|
32
|
+
|
|
33
|
+ /**
|
|
34
|
+ * Color schemed styles of the component.
|
|
35
|
+ */
|
|
36
|
+ _styles: StyleType,
|
|
37
|
+
|
|
38
|
+ /**
|
|
39
|
+ * The Redux Dispatch function.
|
|
40
|
+ */
|
|
41
|
+ dispatch: Function,
|
|
42
|
+
|
|
43
|
+ /**
|
|
44
|
+ * Function to be used to translate i18n labels.
|
|
45
|
+ */
|
|
46
|
+ t: Function
|
|
47
|
+};
|
|
48
|
+
|
|
49
|
+/**
|
|
50
|
+ * Implements the UI elements to be displayed in the lonely meeting experience.
|
|
51
|
+ */
|
|
52
|
+class LonelyMeetingExperience extends PureComponent<Props> {
|
|
53
|
+ /**
|
|
54
|
+ * Instantiates a new component.
|
|
55
|
+ *
|
|
56
|
+ * @inheritdoc
|
|
57
|
+ */
|
|
58
|
+ constructor(props: Props) {
|
|
59
|
+ super(props);
|
|
60
|
+
|
|
61
|
+ this._onPress = this._onPress.bind(this);
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ /**
|
|
65
|
+ * Implements {@code PureComponent#render}.
|
|
66
|
+ *
|
|
67
|
+ * @inheritdoc
|
|
68
|
+ */
|
|
69
|
+ render() {
|
|
70
|
+ const { _isLonelyMeeting, _styles, t } = this.props;
|
|
71
|
+
|
|
72
|
+ if (!_isLonelyMeeting) {
|
|
73
|
+ return null;
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ return (
|
|
77
|
+ <View style = { styles.lonelyMeetingContainer }>
|
|
78
|
+ <Text
|
|
79
|
+ style = { [
|
|
80
|
+ styles.lonelyMessage,
|
|
81
|
+ _styles.lonelyMessage
|
|
82
|
+ ] }>
|
|
83
|
+ { t('lonelyMeetingExperience.youAreAlone') }
|
|
84
|
+ </Text>
|
|
85
|
+ <TouchableOpacity
|
|
86
|
+ onPress = { this._onPress }
|
|
87
|
+ style = { [
|
|
88
|
+ styles.lonelyButton,
|
|
89
|
+ _styles.lonelyButton
|
|
90
|
+ ] }>
|
|
91
|
+ <Icon
|
|
92
|
+ size = { 24 }
|
|
93
|
+ src = { IconAddPeople }
|
|
94
|
+ style = { styles.lonelyButtonComponents } />
|
|
95
|
+ <Text
|
|
96
|
+ style = { [
|
|
97
|
+ styles.lonelyButtonComponents,
|
|
98
|
+ _styles.lonelyMessage
|
|
99
|
+ ] }>
|
|
100
|
+ { t('lonelyMeetingExperience.button') }
|
|
101
|
+ </Text>
|
|
102
|
+ </TouchableOpacity>
|
|
103
|
+ </View>
|
|
104
|
+ );
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ _onPress: () => void;
|
|
108
|
+
|
|
109
|
+ /**
|
|
110
|
+ * Callback for the onPress function of the button.
|
|
111
|
+ *
|
|
112
|
+ * @returns {void}
|
|
113
|
+ */
|
|
114
|
+ _onPress() {
|
|
115
|
+ const { _inviteEnabled, dispatch } = this.props;
|
|
116
|
+
|
|
117
|
+ if (_inviteEnabled) {
|
|
118
|
+ dispatch(setAddPeopleDialogVisible(true));
|
|
119
|
+ } else {
|
|
120
|
+ dispatch(beginShareRoom());
|
|
121
|
+ }
|
|
122
|
+ }
|
|
123
|
+}
|
|
124
|
+
|
|
125
|
+/**
|
|
126
|
+ * Maps parts of the Redux state to the props of this Component.
|
|
127
|
+ *
|
|
128
|
+ * @param {Object} state - The redux state.
|
|
129
|
+ * @private
|
|
130
|
+ * @returns {Props}
|
|
131
|
+ */
|
|
132
|
+function _mapStateToProps(state): $Shape<Props> {
|
|
133
|
+ const _inviteEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
|
|
134
|
+ && (isAddPeopleEnabled(state) || isDialOutEnabled(state));
|
|
135
|
+
|
|
136
|
+ return {
|
|
137
|
+ _inviteEnabled,
|
|
138
|
+ _isLonelyMeeting: getParticipantCount(state) === 1,
|
|
139
|
+ _styles: ColorSchemeRegistry.get(state, 'Conference')
|
|
140
|
+ };
|
|
141
|
+}
|
|
142
|
+
|
|
143
|
+export default connect(_mapStateToProps)(translate(LonelyMeetingExperience));
|