Viktoriia 4 settimane fa
parent
commit
4208d88c13

+ 66 - 40
src/components/SelectSheet/index.tsx

@@ -9,10 +9,13 @@ import {
   FlatList,
   FlatList,
   TextInput,
   TextInput,
   Dimensions,
   Dimensions,
+  Platform
 } from 'react-native';
 } from 'react-native';
 import ActionSheet, { ActionSheetRef } from 'react-native-actions-sheet';
 import ActionSheet, { ActionSheetRef } from 'react-native-actions-sheet';
 import ChevronIcon from 'assets/icons/travels-screens/down-arrow.svg';
 import ChevronIcon from 'assets/icons/travels-screens/down-arrow.svg';
 import { Colors } from 'src/theme';
 import { Colors } from 'src/theme';
+import CloseSvg from 'assets/icons/close.svg';
+import CheckSvg from 'assets/icons/mark.svg';
 
 
 export interface SelectSheetProps<T extends Record<string, any>> {
 export interface SelectSheetProps<T extends Record<string, any>> {
   data: T[];
   data: T[];
@@ -50,14 +53,11 @@ export const SelectSheet = <T extends Record<string, any>>({
   const sheetRef = useRef<ActionSheetRef>(null);
   const sheetRef = useRef<ActionSheetRef>(null);
   const [query, setQuery] = useState('');
   const [query, setQuery] = useState('');
 
 
-  const selectedItem =
-    value != null ? data.find((item) => item[valueField] === value) : null;
+  const selectedItem = value != null ? data.find((item) => item[valueField] === value) : null;
 
 
   const filteredData =
   const filteredData =
     searchable && query.trim()
     searchable && query.trim()
-      ? data.filter((item) =>
-        String(item[labelField]).toLowerCase().includes(query.toLowerCase())
-      )
+      ? data.filter((item) => String(item[labelField]).toLowerCase().includes(query.toLowerCase()))
       : data;
       : data;
 
 
   const handleSelect = useCallback(
   const handleSelect = useCallback(
@@ -82,10 +82,7 @@ export const SelectSheet = <T extends Record<string, any>>({
         style={[styles.trigger, disabled && styles.triggerDisabled, style]}
         style={[styles.trigger, disabled && styles.triggerDisabled, style]}
       >
       >
         <Text
         <Text
-          style={[
-            styles.triggerText,
-            !selectedItem && styles.placeholderText,
-          ]}
+          style={[styles.triggerText, !selectedItem && styles.placeholderText]}
           numberOfLines={1}
           numberOfLines={1}
         >
         >
           {selectedItem ? String(selectedItem[labelField]) : placeholder}
           {selectedItem ? String(selectedItem[labelField]) : placeholder}
@@ -95,7 +92,7 @@ export const SelectSheet = <T extends Record<string, any>>({
 
 
       <ActionSheet
       <ActionSheet
         ref={sheetRef}
         ref={sheetRef}
-        gestureEnabled
+        gestureEnabled={Platform.OS !== 'android'}
         closeOnTouchBackdrop
         closeOnTouchBackdrop
         snapPoints={[initialSnapPoint, 100]}
         snapPoints={[initialSnapPoint, 100]}
         initialSnapIndex={0}
         initialSnapIndex={0}
@@ -104,7 +101,22 @@ export const SelectSheet = <T extends Record<string, any>>({
         onClose={() => setQuery('')}
         onClose={() => setQuery('')}
       >
       >
         <View style={styles.sheetContent}>
         <View style={styles.sheetContent}>
-          {!hideTitle && <Text style={styles.sheetTitle}>{placeholder}</Text>}
+          {Platform.OS === 'android' && (
+            <TouchableOpacity
+              onPress={() => sheetRef.current?.hide()}
+              style={styles.closeBtnAlone}
+              hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
+            >
+              <CloseSvg />
+            </TouchableOpacity>
+          )}
+          {!hideTitle && (
+            <View style={styles.titleRow}>
+              <Text style={[styles.sheetTitle, Platform.OS === 'android' ? { paddingTop: 0 } : {}]}>
+                {placeholder}
+              </Text>
+            </View>
+          )}
 
 
           {searchable && (
           {searchable && (
             <View style={styles.searchWrapper}>
             <View style={styles.searchWrapper}>
@@ -150,7 +162,7 @@ export const SelectSheet = <T extends Record<string, any>>({
                   </Text>
                   </Text>
                   {isSelected && (
                   {isSelected && (
                     <View style={styles.checkmark}>
                     <View style={styles.checkmark}>
-                      <Text style={styles.checkmarkText}>✓</Text>
+                      <CheckSvg fill={Colors.DARK_BLUE} height={12} width={15} />
                     </View>
                     </View>
                   )}
                   )}
                 </TouchableOpacity>
                 </TouchableOpacity>
@@ -161,7 +173,7 @@ export const SelectSheet = <T extends Record<string, any>>({
       </ActionSheet>
       </ActionSheet>
     </>
     </>
   );
   );
-}
+};
 
 
 const styles = StyleSheet.create({
 const styles = StyleSheet.create({
   trigger: {
   trigger: {
@@ -171,53 +183,43 @@ const styles = StyleSheet.create({
     paddingHorizontal: 12,
     paddingHorizontal: 12,
     flexDirection: 'row',
     flexDirection: 'row',
     alignItems: 'center',
     alignItems: 'center',
-    justifyContent: 'space-between',
+    justifyContent: 'space-between'
   },
   },
   triggerDisabled: {
   triggerDisabled: {
-    opacity: 0.5,
+    opacity: 0.5
   },
   },
   triggerText: {
   triggerText: {
     flex: 1,
     flex: 1,
     fontSize: 15,
     fontSize: 15,
     color: Colors.DARK_BLUE,
     color: Colors.DARK_BLUE,
-    marginRight: 6,
+    marginRight: 6
   },
   },
   placeholderText: {
   placeholderText: {
-    color: Colors.TEXT_GRAY,
+    color: Colors.TEXT_GRAY
   },
   },
   sheetContent: {
   sheetContent: {
     height: Dimensions.get('window').height * 0.9,
     height: Dimensions.get('window').height * 0.9,
     backgroundColor: Colors.WHITE,
     backgroundColor: Colors.WHITE,
     borderTopLeftRadius: 20,
     borderTopLeftRadius: 20,
     borderTopRightRadius: 20,
     borderTopRightRadius: 20,
-    overflow: 'hidden',
+    overflow: 'hidden'
   },
   },
   sheetContainer: {
   sheetContainer: {
     height: '90%',
     height: '90%',
     backgroundColor: Colors.WHITE,
     backgroundColor: Colors.WHITE,
     borderTopLeftRadius: 20,
     borderTopLeftRadius: 20,
-    borderTopRightRadius: 20,
+    borderTopRightRadius: 20
   },
   },
   indicator: {
   indicator: {
     width: 44,
     width: 44,
     height: 5,
     height: 5,
     borderRadius: 3,
     borderRadius: 3,
     backgroundColor: Colors.LIGHT_GRAY,
     backgroundColor: Colors.LIGHT_GRAY,
-    marginTop: 8,
-  },
-  sheetTitle: {
-    fontSize: 18,
-    fontWeight: '700',
-    color: Colors.DARK_BLUE,
-    paddingVertical: 12,
-    paddingHorizontal: 24,
-    textAlign: 'center',
-    borderBottomWidth: StyleSheet.hairlineWidth,
-    borderBottomColor: Colors.DARK_LIGHT,
+    marginTop: 8
   },
   },
   searchWrapper: {
   searchWrapper: {
     paddingHorizontal: 16,
     paddingHorizontal: 16,
-    paddingVertical: 12,
+    paddingVertical: 12
   },
   },
   searchInput: {
   searchInput: {
     height: 44,
     height: 44,
@@ -225,38 +227,62 @@ const styles = StyleSheet.create({
     borderRadius: 6,
     borderRadius: 6,
     paddingHorizontal: 16,
     paddingHorizontal: 16,
     fontSize: 16,
     fontSize: 16,
-    color: Colors.DARK_BLUE,
+    color: Colors.DARK_BLUE
   },
   },
   list: {
   list: {
-    flex: 1,
+    flex: 1
   },
   },
   listContent: {
   listContent: {
     paddingBottom: 40,
     paddingBottom: 40,
-    paddingTop: 8,
+    paddingTop: 8
   },
   },
   option: {
   option: {
     flexDirection: 'row',
     flexDirection: 'row',
     alignItems: 'center',
     alignItems: 'center',
     paddingHorizontal: 24,
     paddingHorizontal: 24,
-    paddingVertical: 16,
+    paddingVertical: 16
   },
   },
   optionText: {
   optionText: {
     flex: 1,
     flex: 1,
     fontSize: 16,
     fontSize: 16,
-    color: Colors.DARK_BLUE,
+    color: Colors.DARK_BLUE
   },
   },
   optionTextSelectedWeight: {
   optionTextSelectedWeight: {
-    fontWeight: '700',
+    fontWeight: '700'
   },
   },
   checkmark: {
   checkmark: {
-    marginLeft: 12,
+    marginLeft: 12
   },
   },
   checkmarkText: {
   checkmarkText: {
     fontSize: 18,
     fontSize: 18,
     color: Colors.DARK_BLUE,
     color: Colors.DARK_BLUE,
-    fontWeight: '700',
+    fontWeight: '700'
   },
   },
   chevron: {
   chevron: {
-    marginLeft: 2,
+    marginLeft: 2
   },
   },
+  titleRow: {
+    flexDirection: 'row',
+    alignItems: 'center',
+    borderBottomWidth: StyleSheet.hairlineWidth,
+    borderBottomColor: Colors.DARK_LIGHT
+  },
+  sheetTitle: {
+    flex: 1,
+    fontSize: 16,
+    fontWeight: '700',
+    color: Colors.DARK_BLUE,
+    paddingVertical: 12,
+    paddingHorizontal: 24,
+    textAlign: 'center'
+  },
+  closeBtn: {
+    paddingHorizontal: 16,
+    paddingVertical: 12
+  },
+  closeBtnAlone: {
+    alignSelf: 'flex-end',
+    paddingHorizontal: 16,
+    paddingTop: 16
+  }
 });
 });

+ 18 - 5
src/screens/InAppScreens/MapScreen/FilterModal/index.tsx

@@ -54,6 +54,7 @@ import { getFontSize } from 'src/utils';
 import InfoIcon from 'assets/icons/info-solid.svg';
 import InfoIcon from 'assets/icons/info-solid.svg';
 import Tooltip from 'react-native-walkthrough-tooltip';
 import Tooltip from 'react-native-walkthrough-tooltip';
 import FriendsIcon from 'assets/icons/friend.svg';
 import FriendsIcon from 'assets/icons/friend.svg';
+import CloseSvg from 'assets/icons/close.svg';
 
 
 export interface FilterModalRef {
 export interface FilterModalRef {
   openFilter: (type: string) => void;
   openFilter: (type: string) => void;
@@ -377,7 +378,7 @@ const FilterModal = forwardRef<
       }
       }
     };
     };
 
 
-    const handleCloseFilter = () => { };
+    const handleCloseFilter = () => {};
 
 
     const renderRegions = () => {
     const renderRegions = () => {
       return (
       return (
@@ -465,6 +466,15 @@ const FilterModal = forwardRef<
 
 
       return (
       return (
         <View style={[styles.seriesSheetContainer]}>
         <View style={[styles.seriesSheetContainer]}>
+          {Platform.OS === 'android' && (
+            <TouchableOpacity
+              onPress={() => bottomSheetRef.current?.hide()}
+              style={styles.seriesCloseBtn}
+              hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
+            >
+              <CloseSvg />
+            </TouchableOpacity>
+          )}
           <View style={[styles.optionsContainer, { paddingHorizontal: 16 }]}>
           <View style={[styles.optionsContainer, { paddingHorizontal: 16 }]}>
             <View style={[styles.row, { gap: 8 }]}>
             <View style={[styles.row, { gap: 8 }]}>
               <Switch
               <Switch
@@ -577,7 +587,10 @@ const FilterModal = forwardRef<
           </ScrollView>
           </ScrollView>
 
 
           <View
           <View
-            style={{ marginTop: 'auto', marginBottom: insets.bottom || 24, paddingHorizontal: 16 }}
+            style={[
+              { marginTop: 'auto', paddingHorizontal: 16 },
+              Platform.OS === 'android' ? {} : { marginBottom: insets.bottom || 24 }
+            ]}
           >
           >
             <Button
             <Button
               children="Reset"
               children="Reset"
@@ -961,7 +974,7 @@ const FilterModal = forwardRef<
             message={
             message={
               'This feature is available to Premium users. Premium account settings can be managed on our website.'
               'This feature is available to Premium users. Premium account settings can be managed on our website.'
             }
             }
-            action={() => { }}
+            action={() => {}}
             onClose={() => setPremiumModalVisible(false)}
             onClose={() => setPremiumModalVisible(false)}
             title={'Premium Feature'}
             title={'Premium Feature'}
           />
           />
@@ -1022,12 +1035,12 @@ const FilterModal = forwardRef<
         key={isSeriesFilter ? 'series-sheet' : 'default-sheet'}
         key={isSeriesFilter ? 'series-sheet' : 'default-sheet'}
         ref={bottomSheetRef}
         ref={bottomSheetRef}
         snapPoints={sheetSnapPoints}
         snapPoints={sheetSnapPoints}
-        gestureEnabled
+        gestureEnabled={isSeriesFilter && Platform.OS === 'android' ? false : true}
         closeOnTouchBackdrop
         closeOnTouchBackdrop
         defaultOverlayOpacity={0.2}
         defaultOverlayOpacity={0.2}
         onClose={handleCloseFilter}
         onClose={handleCloseFilter}
         containerStyle={[styles.sheetBackground, isSeriesFilter ? { height: '100%' } : {}]}
         containerStyle={[styles.sheetBackground, isSeriesFilter ? { height: '100%' } : {}]}
-        safeAreaInsets={{ bottom: insets.bottom, top: insets.top, left: 0, right: 0 }}
+        safeAreaInsets={{ bottom: insets.bottom || 24, top: insets.top, left: 0, right: 0 }}
       >
       >
         <View
         <View
           style={[
           style={[

+ 5 - 0
src/screens/InAppScreens/MapScreen/FilterModal/styles.tsx

@@ -214,5 +214,10 @@ export const styles = StyleSheet.create({
   sheetHandle: {
   sheetHandle: {
     backgroundColor: '#D1D1D6',
     backgroundColor: '#D1D1D6',
     width: 40
     width: 40
+  },
+  seriesCloseBtn: {
+    alignSelf: 'flex-end',
+    paddingHorizontal: 16,
+    paddingVertical: 4
   }
   }
 });
 });

+ 4 - 1
src/screens/InAppScreens/TravellersScreen/Components/FilterModal.tsx

@@ -1,5 +1,5 @@
 import React, { FC, useState, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
 import React, { FC, useState, useEffect, useRef, forwardRef, useImperativeHandle } from 'react';
-import { TouchableOpacity, View, Animated, Easing } from 'react-native';
+import { TouchableOpacity, View, Animated, Easing, Platform } from 'react-native';
 
 
 import { ModalStyles } from './styles';
 import { ModalStyles } from './styles';
 import { Colors } from '../../../../theme';
 import { Colors } from '../../../../theme';
@@ -119,6 +119,7 @@ export const FilterModal = forwardRef<FilterModalRef, ModalProps>(({
               onChange={(item) => setFilterCountry(item)}
               onChange={(item) => setFilterCountry(item)}
               searchable={true}
               searchable={true}
               searchPlaceholder="Search country..."
               searchPlaceholder="Search country..."
+              initialSnapPoint={Platform.OS === 'android' ? 100 : 70}
             />
             />
           )}
           )}
 
 
@@ -131,6 +132,7 @@ export const FilterModal = forwardRef<FilterModalRef, ModalProps>(({
               value={filterRanking?.value ?? null}
               value={filterRanking?.value ?? null}
               placeholder="Ranking"
               placeholder="Ranking"
               onChange={(item) => setFilterRanking(item)}
               onChange={(item) => setFilterRanking(item)}
+              initialSnapPoint={Platform.OS === 'android' ? 100 : 70}
             />
             />
             <SelectSheet
             <SelectSheet
               style={ModalStyles.dropdown}
               style={ModalStyles.dropdown}
@@ -141,6 +143,7 @@ export const FilterModal = forwardRef<FilterModalRef, ModalProps>(({
               value={filterAge?.value ?? null}
               value={filterAge?.value ?? null}
               placeholder="Age"
               placeholder="Age"
               onChange={(item) => setFilterAge(item)}
               onChange={(item) => setFilterAge(item)}
+              initialSnapPoint={Platform.OS === 'android' ? 100 : 70}
             />
             />
           </View>
           </View>
           <View style={ModalStyles.buttonsWrapper}>
           <View style={ModalStyles.buttonsWrapper}>