From b5a81f379bc282b5d2bc2a1ca7dc1aea720d4d23 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Thu, 26 Jun 2025 03:29:31 +0800 Subject: [PATCH] feat: replace Modal with BottomModal in SelectableTextSheet component --- apps/mobile/src/modules/ai/summary.tsx | 88 ++------------------------ 1 file changed, 7 insertions(+), 81 deletions(-) diff --git a/apps/mobile/src/modules/ai/summary.tsx b/apps/mobile/src/modules/ai/summary.tsx index 2b6888c93..baedec092 100644 --- a/apps/mobile/src/modules/ai/summary.tsx +++ b/apps/mobile/src/modules/ai/summary.tsx @@ -7,7 +7,6 @@ import * as React from "react" import type { LayoutChangeEvent } from "react-native" import { Clipboard, - Modal, Pressable, ScrollView, StyleSheet, @@ -27,6 +26,7 @@ import Animated, { import { useSafeAreaInsets } from "react-native-safe-area-context" import { useColor } from "react-native-uikit-colors" +import { BottomModal } from "@/src/components/ui/modal/BottomModal" import { AiCuteReIcon } from "@/src/icons/ai_cute_re" import { CloseCuteReIcon } from "@/src/icons/close_cute_re" import { CopyCuteReIcon } from "@/src/icons/copy_cute_re" @@ -192,65 +192,19 @@ const SelectableTextSheet: FC<{ text: string }> = ({ visible, onClose, text }) => { const insets = useSafeAreaInsets() - const translateY = useSharedValue(500) - const [isRendered, setIsRendered] = React.useState(visible) - const textColor = useColor("label") - const sheetAnimatedStyle = useAnimatedStyle(() => ({ - transform: [{ translateY: translateY.value }], - })) - - React.useEffect(() => { - if (visible) { - setIsRendered(true) - translateY.value = withSpring(0, { - damping: 20, - stiffness: 150, - overshootClamping: true, - }) - } else { - if (isRendered) { - translateY.value = withTiming(800, { duration: 250 }) - setTimeout(() => { - setIsRendered(false) - }, 250) - } - } - }, [visible, isRendered, translateY]) - - if (!isRendered) { - return null - } - - const handleClose = () => { - onClose() - } - const handleCopyAll = () => { Clipboard.setString(text) Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success) - handleClose() + onClose() } return ( // Wrap in a View to avoid rendering issues with Modal on Android - - - - - + + AI Summary @@ -269,8 +223,8 @@ const SelectableTextSheet: FC<{ {text} - - + + ) } @@ -301,32 +255,4 @@ const styles = StyleSheet.create({ borderWidth: 0.5, elevation: 2, }, - sheetContainer: { - position: "absolute", - bottom: 0, - left: 0, - right: 0, - maxHeight: "70%", - borderTopLeftRadius: 20, - borderTopRightRadius: 20, - paddingHorizontal: 16, - paddingTop: 16, - overflow: "hidden", - }, - sheetHeader: { - alignItems: "center", - paddingBottom: 10, - borderBottomWidth: StyleSheet.hairlineWidth, - }, - sheetTitle: { - fontSize: 18, - fontWeight: "600", - }, - textScrollView: { - marginVertical: 15, - }, - selectableText: { - fontSize: 16, - lineHeight: 24, - }, })