From 23ae416f428e70c18f84e7011543c468dcb9b072 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Wed, 2 Jul 2025 11:56:04 +0800 Subject: [PATCH] fix component drawer --- app/(application)/profile/[id]/index.tsx | 6 ++++-- components/Drawer/DrawerCustom.tsx | 17 +++++++++++------ components/index.ts | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 components/index.ts diff --git a/app/(application)/profile/[id]/index.tsx b/app/(application)/profile/[id]/index.tsx index 6d0f18e..e68051b 100644 --- a/app/(application)/profile/[id]/index.tsx +++ b/app/(application)/profile/[id]/index.tsx @@ -10,7 +10,7 @@ import { Styles } from "@/styles/global-styles"; import { Ionicons } from "@expo/vector-icons"; import { router, Stack, useLocalSearchParams } from "expo-router"; import React, { useRef, useState } from "react"; -import { Animated, Text, TouchableHighlight, TouchableOpacity, View } from "react-native"; +import { Animated, InteractionManager, Text, TouchableHighlight, TouchableOpacity, View } from "react-native"; export default function Profile() { const { id } = useLocalSearchParams(); @@ -64,7 +64,9 @@ export default function Profile() { duration: 300, useNativeDriver: true, }).start(() => { - setIsDrawerOpen(false); // baru ganti state setelah animasi selesai + InteractionManager.runAfterInteractions(() => { + setIsDrawerOpen(false); // baru ganti state setelah animasi selesai + }); }); }; diff --git a/components/Drawer/DrawerCustom.tsx b/components/Drawer/DrawerCustom.tsx index af4524d..937bc4a 100644 --- a/components/Drawer/DrawerCustom.tsx +++ b/components/Drawer/DrawerCustom.tsx @@ -1,9 +1,10 @@ import React, { useRef } from "react"; import { - Animated, - PanResponder, - StyleSheet, - View + Animated, + PanResponder, + StyleSheet, + View, + InteractionManager, } from "react-native"; import { AccentColor, MainColor } from "@/constants/color-palet"; @@ -39,7 +40,9 @@ DrawerCustomProps) { }, onPanResponderRelease: (_, gestureState) => { if (gestureState.dy > 200) { - closeDrawer(); + InteractionManager.runAfterInteractions(() => { + closeDrawer(); + }); } else { Animated.spring(drawerAnim, { toValue: 0, @@ -59,7 +62,9 @@ DrawerCustomProps) { style={styles.overlay} pointerEvents="auto" onTouchStart={() => { - setTimeout(closeDrawer, 0); + InteractionManager.runAfterInteractions(() => { + closeDrawer(); + }); }} /> diff --git a/components/index.ts b/components/index.ts new file mode 100644 index 0000000..55331a9 --- /dev/null +++ b/components/index.ts @@ -0,0 +1,19 @@ +import { TextInputCustom } from "./TextInput/TextInputCustom"; +import ButtonCustom from "./Button/ButtonCustom"; +import AlertCustom from "./Alert/AlertCustom"; +import DrawerCustom from "./Drawer/DrawerCustom"; +import ViewWrapper from "./_ShareComponent/ViewWrapper"; +import BackButton from "./_ShareComponent/BackButton"; +import Spacing from "./_ShareComponent/Spacing"; +import TruncatedText from "./_ShareComponent/TruncatedText"; + +export { + TextInputCustom, + ButtonCustom, + AlertCustom, + DrawerCustom, + ViewWrapper, + BackButton, + Spacing, + TruncatedText, +};