fix component drawer

This commit is contained in:
2025-07-02 11:56:04 +08:00
parent 8fb37db0db
commit 23ae416f42
3 changed files with 34 additions and 8 deletions

View File

@@ -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
});
});
};

View File

@@ -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();
});
}}
/>

19
components/index.ts Normal file
View File

@@ -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,
};