|
@@ -3,7 +3,7 @@
|
3
|
3
|
import React, { useCallback } from 'react';
|
4
|
4
|
import { useTranslation } from 'react-i18next';
|
5
|
5
|
import { Text, View } from 'react-native';
|
6
|
|
-import { Button } from 'react-native-paper';
|
|
6
|
+import { Button, withTheme } from 'react-native-paper';
|
7
|
7
|
import { useDispatch, useSelector } from 'react-redux';
|
8
|
8
|
|
9
|
9
|
import { admitMultiple } from '../../../lobby/actions.native';
|
|
@@ -12,17 +12,25 @@ import { getLobbyState } from '../../../lobby/functions';
|
12
|
12
|
import { LobbyParticipantItem } from './LobbyParticipantItem';
|
13
|
13
|
import styles from './styles';
|
14
|
14
|
|
15
|
|
-export const LobbyParticipantList = () => {
|
|
15
|
+type Props = {
|
|
16
|
+
|
|
17
|
+ /**
|
|
18
|
+ * Theme used for styles.
|
|
19
|
+ */
|
|
20
|
+ theme: Object
|
|
21
|
+};
|
|
22
|
+
|
|
23
|
+const LobbyParticipantList = ({ theme }: Props) => {
|
16
|
24
|
const {
|
17
|
25
|
lobbyEnabled,
|
18
|
26
|
knockingParticipants: participants
|
19
|
27
|
} = useSelector(getLobbyState);
|
20
|
|
-
|
21
|
28
|
const dispatch = useDispatch();
|
22
|
29
|
const admitAll = useCallback(() =>
|
23
|
30
|
dispatch(admitMultiple(participants)),
|
24
|
|
- [ dispatch ]);
|
|
31
|
+ [ dispatch, participants ]);
|
25
|
32
|
const { t } = useTranslation();
|
|
33
|
+ const { palette } = theme;
|
26
|
34
|
|
27
|
35
|
if (!lobbyEnabled || !participants.length) {
|
28
|
36
|
return null;
|
|
@@ -35,14 +43,17 @@ export const LobbyParticipantList = () => {
|
35
|
43
|
{t('participantsPane.headings.waitingLobby',
|
36
|
44
|
{ count: participants.length })}
|
37
|
45
|
</Text>
|
38
|
|
- <Button
|
39
|
|
- color = '#3D3D3D'
|
40
|
|
- labelStyle = { styles.admitAllParticipantsActionButtonLabel }
|
41
|
|
- mode = 'text'
|
42
|
|
- onPress = { admitAll }
|
43
|
|
- style = { styles.admitAllParticipantsActionButton }>
|
44
|
|
- {t('lobby.admitAll')}
|
45
|
|
- </Button>
|
|
46
|
+ {
|
|
47
|
+ participants.length > 1 && (
|
|
48
|
+ <Button
|
|
49
|
+ color = { palette.action02 }
|
|
50
|
+ labelStyle = { styles.admitAllParticipantsActionButtonLabel }
|
|
51
|
+ mode = 'text'
|
|
52
|
+ onPress = { admitAll }>
|
|
53
|
+ {t('lobby.admitAll')}
|
|
54
|
+ </Button>
|
|
55
|
+ )
|
|
56
|
+ }
|
46
|
57
|
</View>
|
47
|
58
|
{
|
48
|
59
|
participants.map(p => (
|
|
@@ -54,3 +65,5 @@ export const LobbyParticipantList = () => {
|
54
|
65
|
</View>
|
55
|
66
|
);
|
56
|
67
|
};
|
|
68
|
+
|
|
69
|
+export default withTheme(LobbyParticipantList);
|