Skip to content

Commit 50fae0e

Browse files
committed
KeyboardAvoidingView
1 parent 9da7f2a commit 50fae0e

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"android.permission.SYSTEM_ALERT_WINDOW",
2929
"android.permission.WAKE_LOCK",
3030
"android.permission.BLUETOOTH"
31-
]
31+
],
32+
"softwareKeyboardLayoutMode": "pan"
3233
},
3334
"web": {
3435
"bundler": "metro",

app/assistant/ui/ChatBar.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Image, StyleProp, StyleSheet, TextInput, TouchableOpacity, View, ViewStyle } from "react-native";
1+
import { Image, KeyboardAvoidingView, Platform, StyleProp, StyleSheet, TextInput, TouchableOpacity, View, ViewStyle } from "react-native";
22

33
type ChatBarProps = {
44
style: StyleProp<ViewStyle>,
@@ -15,30 +15,37 @@ export default function ChatBar({
1515
}: ChatBarProps) {
1616

1717
return (
18-
<View style={[style, styles.container]} >
19-
<TextInput
20-
style={[styles.input]}
21-
value={value}
22-
placeholder={ "Message" }
23-
placeholderTextColor={'#666666'}
24-
onChangeText={onChangeText}
25-
multiline={true}
26-
/>
27-
<TouchableOpacity
28-
style={styles.button}
29-
activeOpacity={0.7}
30-
onPress={() => onChatSend(value)}
31-
>
32-
<View>
33-
<Image source={require('@/assets/images/arrow_upward_24dp.png')} />
34-
</View>
35-
</TouchableOpacity>
36-
</View>
18+
<KeyboardAvoidingView
19+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
20+
style={[style]}
21+
keyboardVerticalOffset={24}
22+
>
23+
<View style={styles.container}>
24+
<TextInput
25+
style={[styles.input]}
26+
value={value}
27+
placeholder={ "Message" }
28+
placeholderTextColor={'#666666'}
29+
onChangeText={onChangeText}
30+
multiline={true}
31+
/>
32+
<TouchableOpacity
33+
style={styles.button}
34+
activeOpacity={0.7}
35+
onPress={() => onChatSend(value)}
36+
>
37+
<View>
38+
<Image source={require('@/assets/images/arrow_upward_24dp.png')} />
39+
</View>
40+
</TouchableOpacity>
41+
</View>
42+
</KeyboardAvoidingView>
3743
)
3844
}
3945

4046
const styles = StyleSheet.create({
4147
container: {
48+
width: '100%',
4249
flexDirection: 'row',
4350
backgroundColor: '#131313',
4451
borderRadius: 24,

0 commit comments

Comments
 (0)