-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathAttachmentPickerSelectionBar.tsx
More file actions
64 lines (58 loc) · 1.78 KB
/
AttachmentPickerSelectionBar.tsx
File metadata and controls
64 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, { useMemo, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import {
AttachmentTypePickerButton,
useAttachmentPickerState,
CameraPickerButton,
CommandsPickerButton,
FilePickerButton,
MediaPickerButton,
PollPickerButton,
useAttachmentPickerContext,
useStableCallback,
useTheme,
} from 'stream-chat-react-native';
import { ShareLocationIcon } from '../icons/ShareLocationIcon';
import { LiveLocationCreateModal } from './LocationSharing/CreateLocationModal';
export const CustomAttachmentPickerSelectionBar = () => {
const [modalVisible, setModalVisible] = useState(false);
const { attachmentPickerStore } = useAttachmentPickerContext();
const { selectedPicker } = useAttachmentPickerState();
const styles = useStyles();
const onRequestClose = () => {
setModalVisible(false);
};
const onOpenModal = useStableCallback(() => {
attachmentPickerStore.setSelectedPicker('location');
setModalVisible(true);
});
return (
<View style={styles.selectionBar}>
<MediaPickerButton />
<CameraPickerButton />
<FilePickerButton />
<PollPickerButton />
<CommandsPickerButton />
<AttachmentTypePickerButton
Icon={ShareLocationIcon}
onPress={onOpenModal}
selected={selectedPicker === 'location'}
/>
{modalVisible ? (
<LiveLocationCreateModal visible={modalVisible} onRequestClose={onRequestClose} />
) : null}
</View>
);
};
const useStyles = () => {
const { theme: { semantics }} = useTheme();
return useMemo(() => StyleSheet.create({
selectionBar: {
backgroundColor: semantics.backgroundCoreElevation1,
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 16,
paddingBottom: 12,
},
}), [semantics])
}