Skip to content

Commit e8be5a3

Browse files
committed
fix: picker btn behaviour
1 parent 6e5a2fd commit e8be5a3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

examples/SampleApp/src/components/AttachmentPickerContent.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import React, { useState } from 'react';
1+
import React, { useCallback, useState } from 'react';
22
import {
33
useAttachmentPickerState,
44
AttachmentPickerContentProps,
55
AttachmentPickerContent,
66
AttachmentPickerGenericContent,
77
useStableCallback,
8+
useTheme,
89
useTranslationContext,
910
} from 'stream-chat-react-native';
1011
import { ShareLocationIcon } from '../icons/ShareLocationIcon.tsx';
@@ -14,6 +15,14 @@ export const CustomAttachmentPickerContent = (props: AttachmentPickerContentProp
1415
const [modalVisible, setModalVisible] = useState(false);
1516
const { selectedPicker } = useAttachmentPickerState();
1617
const { t } = useTranslationContext();
18+
const {
19+
theme: { semantics },
20+
} = useTheme();
21+
22+
const Icon = useCallback(
23+
() => <ShareLocationIcon stroke={semantics.textTertiary} />,
24+
[semantics.textTertiary],
25+
);
1726

1827
const onRequestClose = () => {
1928
setModalVisible(false);
@@ -27,7 +36,7 @@ export const CustomAttachmentPickerContent = (props: AttachmentPickerContentProp
2736
return (
2837
<>
2938
<AttachmentPickerGenericContent
30-
Icon={ShareLocationIcon}
39+
Icon={Icon}
3140
onPress={onOpenModal}
3241
height={props.height}
3342
buttonText={t('Share Location')}

examples/SampleApp/src/components/AttachmentPickerSelectionBar.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo } from 'react';
1+
import React, { useMemo, useState } from 'react';
22
import { StyleSheet, View } from 'react-native';
33
import {
44
AttachmentTypePickerButton,
@@ -13,15 +13,22 @@ import {
1313
useTheme,
1414
} from 'stream-chat-react-native';
1515
import { ShareLocationIcon } from '../icons/ShareLocationIcon';
16+
import { LiveLocationCreateModal } from './LocationSharing/CreateLocationModal';
1617

1718
export const CustomAttachmentPickerSelectionBar = () => {
19+
const [modalVisible, setModalVisible] = useState(false);
1820
const { attachmentPickerStore } = useAttachmentPickerContext();
1921
const { selectedPicker } = useAttachmentPickerState();
2022

2123
const styles = useStyles();
2224

25+
const onRequestClose = () => {
26+
setModalVisible(false);
27+
};
28+
2329
const onOpenModal = useStableCallback(() => {
2430
attachmentPickerStore.setSelectedPicker('location');
31+
setModalVisible(true);
2532
});
2633

2734
return (
@@ -36,6 +43,9 @@ export const CustomAttachmentPickerSelectionBar = () => {
3643
onPress={onOpenModal}
3744
selected={selectedPicker === 'location'}
3845
/>
46+
{modalVisible ? (
47+
<LiveLocationCreateModal visible={modalVisible} onRequestClose={onRequestClose} />
48+
) : null}
3949
</View>
4050
);
4151
};

0 commit comments

Comments
 (0)