|
@@ -1,6 +1,6 @@
|
|
import React, { useCallback, useState } from 'react';
|
|
import React, { useCallback, useState } from 'react';
|
|
-import { StyleSheet, TouchableOpacity, View, Text } from 'react-native';
|
|
|
|
-import ActionSheet, { SheetManager } from 'react-native-actions-sheet';
|
|
|
|
|
|
+import { StyleSheet, TouchableOpacity, View, Text, Button } from 'react-native';
|
|
|
|
+import ActionSheet, { Route, SheetManager, useSheetRouter } from 'react-native-actions-sheet';
|
|
import { getFontSize } from 'src/utils';
|
|
import { getFontSize } from 'src/utils';
|
|
import { Colors } from 'src/theme';
|
|
import { Colors } from 'src/theme';
|
|
import { WarningProps } from '../types';
|
|
import { WarningProps } from '../types';
|
|
@@ -11,6 +11,7 @@ import * as DocumentPicker from 'react-native-document-picker';
|
|
|
|
|
|
import MegaphoneIcon from 'assets/icons/messages/megaphone.svg';
|
|
import MegaphoneIcon from 'assets/icons/messages/megaphone.svg';
|
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
|
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
|
|
|
+import RouteB from './RouteB';
|
|
|
|
|
|
const AttachmentsModal = () => {
|
|
const AttachmentsModal = () => {
|
|
const insets = useSafeAreaInsets();
|
|
const insets = useSafeAreaInsets();
|
|
@@ -18,6 +19,18 @@ const AttachmentsModal = () => {
|
|
const [shouldOpenWarningModal, setShouldOpenWarningModal] = useState<WarningProps | null>(null);
|
|
const [shouldOpenWarningModal, setShouldOpenWarningModal] = useState<WarningProps | null>(null);
|
|
const { mutateAsync: reportUser } = usePostReportConversationMutation();
|
|
const { mutateAsync: reportUser } = usePostReportConversationMutation();
|
|
|
|
|
|
|
|
+ const router = useSheetRouter('sheet-router');
|
|
|
|
+
|
|
|
|
+ const [currentLocation, setCurrentLocation] = useState<{
|
|
|
|
+ latitude: number;
|
|
|
|
+ longitude: number;
|
|
|
|
+ } | null>(null);
|
|
|
|
+ const [selectedLocation, setSelectedLocation] = useState<{
|
|
|
|
+ latitude: number;
|
|
|
|
+ longitude: number;
|
|
|
|
+ } | null>(null);
|
|
|
|
+ const [isLoading, setIsLoading] = useState(true);
|
|
|
|
+
|
|
const handleSheetOpen = (payload: any) => {
|
|
const handleSheetOpen = (payload: any) => {
|
|
setChatData(payload);
|
|
setChatData(payload);
|
|
};
|
|
};
|
|
@@ -99,24 +112,6 @@ const AttachmentsModal = () => {
|
|
}
|
|
}
|
|
}, [chatData?.onSendMedia, chatData?.closeOptions]);
|
|
}, [chatData?.onSendMedia, chatData?.closeOptions]);
|
|
|
|
|
|
- const handleShareLocation = useCallback(async () => {
|
|
|
|
- if (!chatData) return;
|
|
|
|
- try {
|
|
|
|
- // TODO:
|
|
|
|
- // const { status } = await Location.requestForegroundPermissionsAsync();
|
|
|
|
- // if (status !== 'granted') {}
|
|
|
|
-
|
|
|
|
- // const loc = await Location.getCurrentPositionAsync({});
|
|
|
|
- // const coords = { latitude: loc.coords.latitude, longitude: loc.coords.longitude };
|
|
|
|
-
|
|
|
|
- const coords = { latitude: 50.4501, longitude: 30.5234 };
|
|
|
|
- chatData.onSendLocation(coords);
|
|
|
|
- SheetManager.hide('chat-attachments');
|
|
|
|
- } catch (err) {
|
|
|
|
- console.warn('Location error: ', err);
|
|
|
|
- }
|
|
|
|
- }, [chatData?.onSendLocation, chatData?.closeOptions]);
|
|
|
|
-
|
|
|
|
const handleShareLiveLocation = useCallback(() => {
|
|
const handleShareLiveLocation = useCallback(() => {
|
|
if (!chatData) return;
|
|
if (!chatData) return;
|
|
chatData.onShareLiveLocation();
|
|
chatData.onShareLiveLocation();
|
|
@@ -152,62 +147,15 @@ const AttachmentsModal = () => {
|
|
SheetManager.hide('chat-attachments');
|
|
SheetManager.hide('chat-attachments');
|
|
}, [chatData?.onSendFile, chatData?.closeOptions]);
|
|
}, [chatData?.onSendFile, chatData?.closeOptions]);
|
|
|
|
|
|
- return (
|
|
|
|
- <ActionSheet
|
|
|
|
- id="chat-attachments"
|
|
|
|
- gestureEnabled={true}
|
|
|
|
- containerStyle={{
|
|
|
|
- borderTopLeftRadius: 15,
|
|
|
|
- borderTopRightRadius: 15
|
|
|
|
- }}
|
|
|
|
- defaultOverlayOpacity={0.3}
|
|
|
|
- onBeforeShow={(sheetRef) => {
|
|
|
|
- const payload = sheetRef || null;
|
|
|
|
- handleSheetOpen(payload);
|
|
|
|
- }}
|
|
|
|
- onClose={() => {
|
|
|
|
- if (shouldOpenWarningModal) {
|
|
|
|
- chatData?.setModalInfo({
|
|
|
|
- visible: true,
|
|
|
|
- type: 'delete',
|
|
|
|
- title: shouldOpenWarningModal.title,
|
|
|
|
- buttonTitle: shouldOpenWarningModal.buttonTitle,
|
|
|
|
- message: shouldOpenWarningModal.message,
|
|
|
|
- action: shouldOpenWarningModal.action
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- {/* <View
|
|
|
|
- style={{
|
|
|
|
- backgroundColor: 'white',
|
|
|
|
- paddingHorizontal: 16,
|
|
|
|
- gap: 16,
|
|
|
|
- paddingTop: 8,
|
|
|
|
- paddingBottom: 8 + insets.bottom
|
|
|
|
- }}
|
|
|
|
|
|
+ const RouteA = () => {
|
|
|
|
+ const router = useSheetRouter('sheet-router');
|
|
|
|
+ return (
|
|
|
|
+ <View
|
|
|
|
+ style={[
|
|
|
|
+ styles.container,
|
|
|
|
+ { paddingBottom: 8 + insets.bottom, backgroundColor: Colors.FILL_LIGHT }
|
|
|
|
+ ]}
|
|
>
|
|
>
|
|
- <TouchableOpacity style={[styles.option]} onPress={handleReport}>
|
|
|
|
- <Text style={[styles.optionText]}>Gallery</Text>
|
|
|
|
- <MegaphoneIcon fill={Colors.DARK_BLUE} />
|
|
|
|
- </TouchableOpacity>
|
|
|
|
-
|
|
|
|
- <TouchableOpacity style={[styles.option]} onPress={handleReport}>
|
|
|
|
- <Text style={[styles.optionText]}>Camera</Text>
|
|
|
|
- <MegaphoneIcon fill={Colors.DARK_BLUE} />
|
|
|
|
- </TouchableOpacity>
|
|
|
|
-
|
|
|
|
- <TouchableOpacity style={[styles.option]} onPress={handleReport}>
|
|
|
|
- <Text style={[styles.optionText]}>Location</Text>
|
|
|
|
- <MegaphoneIcon fill={Colors.DARK_BLUE} />
|
|
|
|
- </TouchableOpacity>
|
|
|
|
-
|
|
|
|
- <TouchableOpacity style={[styles.option, styles.dangerOption]} onPress={handleReport}>
|
|
|
|
- <Text style={[styles.optionText, styles.dangerText]}>Report {chatData?.name}</Text>
|
|
|
|
- <MegaphoneIcon fill={Colors.RED} />
|
|
|
|
- </TouchableOpacity>
|
|
|
|
- </View> */}
|
|
|
|
- <View style={[styles.container, { paddingBottom: 8 + insets.bottom }]}>
|
|
|
|
<View style={styles.optionRow}>
|
|
<View style={styles.optionRow}>
|
|
<TouchableOpacity style={styles.optionItem} onPress={handleOpenGallery}>
|
|
<TouchableOpacity style={styles.optionItem} onPress={handleOpenGallery}>
|
|
<MaterialCommunityIcons name="image" size={36} color={Colors.ORANGE} />
|
|
<MaterialCommunityIcons name="image" size={36} color={Colors.ORANGE} />
|
|
@@ -219,7 +167,12 @@ const AttachmentsModal = () => {
|
|
<Text style={styles.optionLabel}>Camera</Text>
|
|
<Text style={styles.optionLabel}>Camera</Text>
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
|
|
|
|
- <TouchableOpacity style={styles.optionItem} onPress={handleShareLocation}>
|
|
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={styles.optionItem}
|
|
|
|
+ onPress={() => {
|
|
|
|
+ router?.navigate('route-b');
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
<MaterialCommunityIcons name="map-marker" size={36} color={Colors.ORANGE} />
|
|
<MaterialCommunityIcons name="map-marker" size={36} color={Colors.ORANGE} />
|
|
<Text style={styles.optionLabel}>Location</Text>
|
|
<Text style={styles.optionLabel}>Location</Text>
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
@@ -241,7 +194,50 @@ const AttachmentsModal = () => {
|
|
<View style={styles.optionItem}></View>
|
|
<View style={styles.optionItem}></View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
- </ActionSheet>
|
|
|
|
|
|
+ );
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const routes: Route[] = [
|
|
|
|
+ {
|
|
|
|
+ name: 'route-a',
|
|
|
|
+ component: RouteA
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: 'route-b',
|
|
|
|
+ component: RouteB,
|
|
|
|
+ params: { onSendLocation: chatData?.onSendLocation, insetsBottom: insets.bottom }
|
|
|
|
+ }
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <ActionSheet
|
|
|
|
+ id="chat-attachments"
|
|
|
|
+ gestureEnabled={true}
|
|
|
|
+ containerStyle={{
|
|
|
|
+ backgroundColor: Colors.FILL_LIGHT
|
|
|
|
+ }}
|
|
|
|
+ enableRouterBackNavigation={true}
|
|
|
|
+ routes={routes}
|
|
|
|
+ initialRoute="route-a"
|
|
|
|
+ defaultOverlayOpacity={0}
|
|
|
|
+ indicatorStyle={{ backgroundColor: Colors.WHITE }}
|
|
|
|
+ onBeforeShow={(sheetRef) => {
|
|
|
|
+ const payload = sheetRef || null;
|
|
|
|
+ handleSheetOpen(payload);
|
|
|
|
+ }}
|
|
|
|
+ onClose={() => {
|
|
|
|
+ if (shouldOpenWarningModal) {
|
|
|
|
+ chatData?.setModalInfo({
|
|
|
|
+ visible: true,
|
|
|
|
+ type: 'delete',
|
|
|
|
+ title: shouldOpenWarningModal.title,
|
|
|
|
+ buttonTitle: shouldOpenWarningModal.buttonTitle,
|
|
|
|
+ message: shouldOpenWarningModal.message,
|
|
|
|
+ action: shouldOpenWarningModal.action
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|