|
|
@@ -1,17 +1,19 @@
|
|
|
-import { View } from "@tarojs/components"
|
|
|
+import { View, Textarea } from "@tarojs/components"
|
|
|
import IconMic from "@/components/icon/IconMic"
|
|
|
import IconStop from "@/components/icon/IconStop"
|
|
|
import IconSend from "@/components/icon/IconSend"
|
|
|
import { useState } from "react";
|
|
|
-// import WemetaInput from '@/components/wemeta-input'
|
|
|
+import TextareaInputAutoHeight from './TextareaInputAutoHeight'
|
|
|
import WemetaTextarea from '@/components/wemeta-textarea'
|
|
|
import { useTextChat } from "@/store/textChatStore";
|
|
|
+import { useAppStore } from "@/store/appStore";
|
|
|
interface Props {
|
|
|
disabled: boolean,
|
|
|
onIconClick: () => void
|
|
|
onSend: (msg: string)=> void
|
|
|
}
|
|
|
export default ({disabled, onIconClick, onSend}:Props) => {
|
|
|
+ const isIos = useAppStore( state => state.isIos)
|
|
|
const [value, setValue] = useState('')
|
|
|
const {messageStopHandle} = useTextChat()
|
|
|
|
|
|
@@ -31,29 +33,53 @@ export default ({disabled, onIconClick, onSend}:Props) => {
|
|
|
}
|
|
|
|
|
|
const renderExtra = () => {
|
|
|
- // IOS Textarea 高度最小只能是 34px, 高度无法再缩小,所以添加一个高度 34 在同一行中高度居中显示
|
|
|
- return <View className="flex items-center gap-12 leading-34 h-34">
|
|
|
- {!value.length && <View className="flex-center" onClick={onIconClick}><IconMic /></View>}
|
|
|
- {!messageStopHandle && <View className={`flex-center ${!!value.length ? '':'opacity-50'}`} onClick={handleConfirm}><IconSend /></View>}
|
|
|
- {!!messageStopHandle && <View className="flex-center" onClick={handleStopClick}><IconStop /></View>}
|
|
|
+ return <View className="flex items-center gap-12 leading-24 h-24">
|
|
|
+ {!value.length && <View className="flex-center" onClick={onIconClick}><IconMic /></View>}
|
|
|
+ {!messageStopHandle && <View className={`flex-center ${!!value.length ? '':'opacity-50'}`} onClick={handleConfirm}><IconSend /></View>}
|
|
|
+ {!!messageStopHandle && <View className="flex-center" onClick={handleStopClick}><IconStop /></View>}
|
|
|
</View>
|
|
|
}
|
|
|
return <View className="flex flex-col gap-12">
|
|
|
- <WemetaTextarea
|
|
|
- adjustPosition={false}
|
|
|
- disabled={disabled}
|
|
|
- className="px-16 py-6"
|
|
|
- // 必须添加 height 与 maxHeight 否则在初始化时高度会先 maxheight 再跳回到 lineHeight,导致闪烁和 高度计算错误
|
|
|
- style={{'borderRadius': '10px', maxHeight: '120px', 'lineHeight': '1', 'height': '24px'}}
|
|
|
- autoHeight
|
|
|
- placeholder="有问题尽管问我..."
|
|
|
- value={value}
|
|
|
- cursorSpacing={400}
|
|
|
- onConfirm={handleConfirm}
|
|
|
- confirmType="send"
|
|
|
- suffix={renderExtra}
|
|
|
- onInput={(value: any) => handleInput(value)}
|
|
|
- >
|
|
|
- </WemetaTextarea>
|
|
|
+ {/* 无法复用 wemeta-textarea 需要特殊处理 */}
|
|
|
+ <TextareaInputAutoHeight
|
|
|
+ adjustPosition={false}
|
|
|
+ disabled={disabled}
|
|
|
+ extraClass="flex-1 w-auto"
|
|
|
+ autoHeight
|
|
|
+ placeholder="有问题尽管问我..."
|
|
|
+ value={value}
|
|
|
+ cursorSpacing={400}
|
|
|
+ onConfirm={handleConfirm}
|
|
|
+ confirmType="send"
|
|
|
+ disable-default-padding
|
|
|
+ onInput={(value) => handleInput(value)}
|
|
|
+ suffix={renderExtra}
|
|
|
+ />
|
|
|
</View>
|
|
|
+ // return <View className="flex flex-col gap-12">
|
|
|
+ // <View className="flex items-end px-16 py-14 rounded-10 bg-white">
|
|
|
+ // <View className="min-h-24 flex items-center flex-1">
|
|
|
+ // <Textarea
|
|
|
+ // adjustPosition={false}
|
|
|
+ // disabled={disabled}
|
|
|
+ // className="flex-1 w-auto"
|
|
|
+ // // 必须添加 height 与 maxHeight 否则在初始化时高度会先 maxheight 再跳回到 lineHeight,导致闪烁和 高度计算错误
|
|
|
+ // style={{'borderRadius': '0px', maxHeight: '120px', 'lineHeight': '24px', 'height': '24px'}}
|
|
|
+ // autoHeight
|
|
|
+ // placeholder="有问题尽管问我..."
|
|
|
+ // value={value}
|
|
|
+ // cursorSpacing={400}
|
|
|
+ // onConfirm={handleConfirm}
|
|
|
+ // confirmType="send"
|
|
|
+ // disable-default-padding
|
|
|
+ // onInput={(e: any) => handleInput(e.target.value)}
|
|
|
+ // />
|
|
|
+ // </View>
|
|
|
+ // <View className="flex items-center gap-12 leading-24 h-24">
|
|
|
+ // {!value.length && <View className="flex-center" onClick={onIconClick}><IconMic /></View>}
|
|
|
+ // {!messageStopHandle && <View className={`flex-center ${!!value.length ? '':'opacity-50'}`} onClick={handleConfirm}><IconSend /></View>}
|
|
|
+ // {!!messageStopHandle && <View className="flex-center" onClick={handleStopClick}><IconStop /></View>}
|
|
|
+ // </View>
|
|
|
+ // </View>
|
|
|
+ // </View>
|
|
|
}
|