11"use client" ;
22
3- import React , { useCallback , useEffect , useRef } from "react" ;
3+ import React , { useCallback } from "react" ;
44import {
55 TextInput ,
66 type NativeSyntheticEvent ,
77 type TextInputContentSizeChangeEventData ,
8+ View ,
89 type TextInputProps ,
910} from "react-native" ;
1011import { cn } from "~/utils/cn" ;
@@ -24,20 +25,22 @@ export type AutoResizeTextareaProps = Omit<
2425 "onChange" | "multiline"
2526> & {
2627 onChange ?: ( value : string , e ?: unknown ) => void ;
27- // minRows?: number;
28- // maxRows?: number;
29- // rowHeight?: number;
30- // onHeightChange?: (height: number) => void;
31- // cacheMeasurements?: boolean;
32- // height?: number;
28+ headerContent ?: React . ReactNode ;
3329} ;
3430
3531export const AutoResizeTextarea = React . forwardRef <
3632 TextInput ,
3733 AutoResizeTextareaProps
3834> (
3935 (
40- { onChange, onChangeText, onContentSizeChange, className, ...restProps } ,
36+ {
37+ onChange,
38+ onChangeText,
39+ onContentSizeChange,
40+ headerContent,
41+ className,
42+ ...restProps
43+ } ,
4144 ref ,
4245 ) => {
4346 const [ displayExpand , setDisplayExpand ] = React . useState < boolean > ( false ) ;
@@ -59,24 +62,6 @@ export const AutoResizeTextarea = React.forwardRef<
5962 [ onChange , onChangeText ] ,
6063 ) ;
6164
62- // const fadeAnim = useRef(new Animated.Value(0)).current;
63-
64- // useEffect(() => {
65- // if(displayExpand) {
66- // Animated.timing(fadeAnim, {
67- // toValue: 1,
68- // duration: 300,
69- // useNativeDriver: true,
70- // }).start();
71- // } else {
72- // Animated.timing(fadeAnim, {
73- // toValue: 0,
74- // duration: 300,
75- // useNativeDriver: true,
76- // }).start();
77- // }
78- // }, [displayExpand]);
79-
8065 return (
8166 < ActionSheet >
8267 < TextInput
@@ -91,10 +76,10 @@ export const AutoResizeTextarea = React.forwardRef<
9176 < Animated . View
9277 entering = { FadeIn . duration ( 200 ) }
9378 exiting = { FadeOut . duration ( 200 ) }
94- className = "absolute top-2 right-2"
79+ className = "absolute top-2 right-2 z-20 "
9580 >
9681 < ActionSheetTrigger asChild >
97- < Button size = "sm-icon" variant = "ghost" >
82+ < Button size = "sm-icon" variant = "ghost" className = "bg-secondary" >
9883 < Icon name = "Expand" size = { 20 } color = { textMutedForeground } />
9984 </ Button >
10085 </ ActionSheetTrigger >
@@ -112,19 +97,21 @@ export const AutoResizeTextarea = React.forwardRef<
11297 < Button
11398 size = "sm-icon"
11499 variant = "ghost"
115- className = "absolute top-4 right-4 z-10 "
100+ className = "absolute top-4 right-4 z-20 "
116101 >
117102 < Icon name = "Shrink" size = { 20 } />
118103 </ Button >
119104 </ ActionSheetClose >
120105
106+ { headerContent }
107+
121108 < TextInput
122109 { ...restProps }
123110 ref = { ref }
124111 multiline
125112 className = { cn ( "h-full p-4 pt-12 text-base text-foreground" ) }
126113 onChangeText = { handleChangeText }
127- > </ TextInput >
114+ / >
128115 </ ActionSheetContent >
129116 </ ActionSheet >
130117 ) ;
0 commit comments