Skip to content

Commit f7577af

Browse files
committed
refactor: message input components
1 parent d2a6e50 commit f7577af

File tree

15 files changed

+313
-329
lines changed

15 files changed

+313
-329
lines changed

docs/migrateComponents.md

Lines changed: 0 additions & 204 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@aws-sdk/client-bedrock": "^3.840.0",
6363
"@aws-sdk/client-bedrock-runtime": "^3.840.0",
6464
"@aws-sdk/client-s3": "^3.840.0",
65+
"@callstack/liquid-glass": "^0.6.1",
6566
"@cherrystudio/ai-core": "^1.0.9",
6667
"@cherrystudio/ai-sdk-provider": "^0.1.3",
6768
"@cherrystudio/openai": "^6.9.0",

src/componentsV2/base/LiquidGlassButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const LiquidGlassButton = ({
5353
return (
5454
<Button
5555
onPress={onPress}
56-
className={cn('h-10 w-10 items-center justify-center rounded-full', className)}
56+
className={cn('bg-secondary h-10 w-10 items-center justify-center rounded-full', className)}
5757
variant={variant}
5858
style={style}>
5959
{children}

src/componentsV2/base/SearchInput/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ interface SearchInputProps {
1212

1313
export const SearchInput = ({ placeholder, onChangeText, value }: SearchInputProps) => {
1414
return (
15-
<TextField>
15+
<TextField className="bg-secondary rounded-3xl">
1616
<TextField.Input
1717
placeholder={placeholder}
1818
onChangeText={onChangeText}
1919
value={value}
20-
className="h-10 w-full rounded-xl bg-transparent px-2 py-0 text-base">
20+
className="h-10 w-full"
21+
selectionColor="#2563eb"
22+
colors={{
23+
blurBackground: 'transparent',
24+
focusBackground: 'transparent',
25+
blurBorder: 'transparent',
26+
focusBorder: 'transparent'
27+
}}
28+
style={{
29+
fontSize: 18
30+
}}>
2131
<TextField.InputStartContent>
2232
<Search size={20} className="text-foreground-secondary" />
2333
</TextField.InputStartContent>

src/componentsV2/features/ChatScreen/MessageInput/MessageTextField.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ExpandButton } from './ExpandButton'
99

1010
const LINE_HEIGHT = 20
1111
const MAX_VISIBLE_LINES = 4
12+
const MAX_INPUT_HEIGHT = 96
1213

1314
interface MessageTextFieldProps {
1415
text: string
@@ -19,20 +20,24 @@ interface MessageTextFieldProps {
1920
export const MessageTextField: React.FC<MessageTextFieldProps> = ({ text, setText, onExpand }) => {
2021
const { t } = useTranslation()
2122
const [showExpandButton, setShowExpandButton] = useState(false)
23+
const [inputHeight, setInputHeight] = useState<number | undefined>(undefined)
2224

2325
const handleContentSizeChange = (e: TextInputContentSizeChangeEvent) => {
2426
const { height } = e.nativeEvent.contentSize
2527
const lineCount = Math.ceil(height / LINE_HEIGHT)
2628
setShowExpandButton(lineCount > MAX_VISIBLE_LINES)
29+
setInputHeight(height)
2730
}
2831

32+
const computedInputHeight = inputHeight === undefined ? undefined : Math.min(inputHeight, MAX_INPUT_HEIGHT)
33+
2934
return (
3035
<>
3136
{/* hidden measurement input */}
3237
<View style={{ position: 'absolute', opacity: 0, pointerEvents: 'none' }} className="w-full">
33-
<TextField className="w-full p-0">
38+
<TextField className="w-full rounded-2xl p-0">
3439
<TextField.Input
35-
className="text-foreground h-auto border-none p-0 text-base"
40+
className="text-foreground h-auto"
3641
value={text}
3742
multiline
3843
onContentSizeChange={handleContentSizeChange}
@@ -42,21 +47,35 @@ export const MessageTextField: React.FC<MessageTextFieldProps> = ({ text, setTex
4247
blurBorder: 'transparent',
4348
focusBorder: 'transparent'
4449
}}
50+
style={{
51+
minHeight: 36,
52+
fontSize: 20,
53+
lineHeight: 26,
54+
paddingVertical: 6
55+
}}
4556
/>
4657
</TextField>
4758
</View>
4859
{/* visible input */}
49-
<View className="relative top-[5px]">
50-
{showExpandButton && <ExpandButton onPress={onExpand} />}
51-
<TextField className="w-full p-0">
60+
<View className="relative">
61+
<View className="right-2 top-2">{showExpandButton && <ExpandButton onPress={onExpand} />}</View>
62+
<TextField className="w-full rounded-3xl p-0">
5263
<TextField.Input
53-
className="text-foreground h-24 border-none p-0 text-base"
64+
className="text-foreground h-auto"
5465
placeholder={t('inputs.placeholder')}
5566
value={text}
5667
onChangeText={setText}
5768
multiline
5869
numberOfLines={10}
5970
selectionColor="#2563eb"
71+
style={{
72+
height: computedInputHeight,
73+
maxHeight: MAX_INPUT_HEIGHT,
74+
minHeight: 36,
75+
fontSize: 20,
76+
lineHeight: 26,
77+
paddingVertical: 6
78+
}}
6079
colors={{
6180
blurBackground: 'transparent',
6281
focusBackground: 'transparent',

src/componentsV2/features/ChatScreen/MessageInput/PauseButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@ interface PauseButtonProps {
88
}
99

1010
export const PauseButton: React.FC<PauseButtonProps> = ({ onPause }) => {
11-
return <IconButton icon={<CirclePause size={24} className="text-error-base" />} onPress={onPause} />
11+
return (
12+
<IconButton
13+
style={{ height: 36, width: 36, alignItems: 'center', justifyContent: 'center' }}
14+
icon={<CirclePause size={32} className="text-red-600" />}
15+
onPress={onPause}
16+
/>
17+
)
1218
}

src/componentsV2/features/ChatScreen/MessageInput/ToolButton.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react'
22
import { Keyboard } from 'react-native'
33

4-
import { IconButton } from '@/componentsV2/base/IconButton'
5-
import { AssetsIcon } from '@/componentsV2/icons'
4+
import { LiquidGlassButton } from '@/componentsV2/base/LiquidGlassButton'
5+
import { Plus } from '@/componentsV2/icons/LucideIcon'
66
import type { Assistant, Model } from '@/types/assistant'
77
import type { FileMetadata } from '@/types/file'
88

@@ -34,5 +34,9 @@ export const ToolButton: React.FC<AddAssetsButtonProps> = ({
3434
})
3535
}
3636

37-
return <IconButton icon={<AssetsIcon size={20} />} onPress={handlePress} />
37+
return (
38+
<LiquidGlassButton size={38} onPress={handlePress}>
39+
<Plus size={24} />
40+
</LiquidGlassButton>
41+
)
3842
}

0 commit comments

Comments
 (0)