|
1 | 1 | import { useEffect, useRef, useState } from 'react';
|
2 | 2 | import {
|
3 | 3 | Keyboard,
|
4 |
| - KeyboardAvoidingView, |
5 |
| - Platform, |
6 | 4 | StyleSheet,
|
7 | 5 | Text,
|
8 | 6 | TextInput,
|
@@ -57,73 +55,66 @@ export default function LLMScreen() {
|
57 | 55 | textContent={`Loading the model ${(llm.downloadProgress * 100).toFixed(0)} %`}
|
58 | 56 | />
|
59 | 57 | ) : (
|
60 |
| - <SafeAreaView style={styles.container}> |
61 |
| - <TouchableWithoutFeedback onPress={Keyboard.dismiss}> |
62 |
| - <KeyboardAvoidingView |
63 |
| - style={styles.keyboardAvoidingView} |
64 |
| - behavior={Platform.OS === 'ios' ? 'padding' : 'height'} |
65 |
| - keyboardVerticalOffset={Platform.OS === 'android' ? 30 : 0} |
66 |
| - > |
67 |
| - {llm.messageHistory.length ? ( |
68 |
| - <View style={styles.chatContainer}> |
69 |
| - <Messages |
70 |
| - chatHistory={llm.messageHistory} |
71 |
| - llmResponse={llm.response} |
72 |
| - isGenerating={llm.isGenerating} |
73 |
| - deleteMessage={llm.deleteMessage} |
74 |
| - /> |
75 |
| - </View> |
76 |
| - ) : ( |
77 |
| - <View style={styles.helloMessageContainer}> |
78 |
| - <Text style={styles.helloText}>Hello! 👋</Text> |
79 |
| - <Text style={styles.bottomHelloText}> |
80 |
| - What can I help you with? |
81 |
| - </Text> |
82 |
| - </View> |
83 |
| - )} |
84 |
| - |
85 |
| - <View style={styles.bottomContainer}> |
86 |
| - <TextInput |
87 |
| - onFocus={() => setIsTextInputFocused(true)} |
88 |
| - onBlur={() => setIsTextInputFocused(false)} |
89 |
| - style={{ |
90 |
| - ...styles.textInput, |
91 |
| - borderColor: isTextInputFocused |
92 |
| - ? ColorPalette.blueDark |
93 |
| - : ColorPalette.blueLight, |
94 |
| - }} |
95 |
| - placeholder="Your message" |
96 |
| - placeholderTextColor={'#C1C6E5'} |
97 |
| - multiline={true} |
98 |
| - ref={textInputRef} |
99 |
| - onChangeText={(text: string) => setUserInput(text)} |
| 58 | + <TouchableWithoutFeedback onPress={Keyboard.dismiss}> |
| 59 | + <SafeAreaView style={styles.container}> |
| 60 | + {llm.messageHistory.length ? ( |
| 61 | + <View style={styles.chatContainer}> |
| 62 | + <Messages |
| 63 | + chatHistory={llm.messageHistory} |
| 64 | + llmResponse={llm.response} |
| 65 | + isGenerating={llm.isGenerating} |
| 66 | + deleteMessage={llm.deleteMessage} |
100 | 67 | />
|
101 |
| - {userInput && ( |
102 |
| - <TouchableOpacity |
103 |
| - style={styles.sendChatTouchable} |
104 |
| - onPress={async () => !llm.isGenerating && (await sendMessage())} |
105 |
| - > |
106 |
| - <SendIcon height={24} width={24} padding={4} margin={8} /> |
107 |
| - </TouchableOpacity> |
108 |
| - )} |
109 |
| - {llm.isGenerating && ( |
110 |
| - <TouchableOpacity |
111 |
| - style={styles.sendChatTouchable} |
112 |
| - onPress={llm.interrupt} |
113 |
| - > |
114 |
| - <PauseIcon height={24} width={24} padding={4} margin={8} /> |
115 |
| - </TouchableOpacity> |
116 |
| - )} |
117 | 68 | </View>
|
118 |
| - </KeyboardAvoidingView> |
119 |
| - </TouchableWithoutFeedback> |
120 |
| - </SafeAreaView> |
| 69 | + ) : ( |
| 70 | + <View style={styles.helloMessageContainer}> |
| 71 | + <Text style={styles.helloText}>Hello! 👋</Text> |
| 72 | + <Text style={styles.bottomHelloText}> |
| 73 | + What can I help you with? |
| 74 | + </Text> |
| 75 | + </View> |
| 76 | + )} |
| 77 | + |
| 78 | + <View style={styles.bottomContainer}> |
| 79 | + <TextInput |
| 80 | + onFocus={() => setIsTextInputFocused(true)} |
| 81 | + onBlur={() => setIsTextInputFocused(false)} |
| 82 | + style={{ |
| 83 | + ...styles.textInput, |
| 84 | + borderColor: isTextInputFocused |
| 85 | + ? ColorPalette.blueDark |
| 86 | + : ColorPalette.blueLight, |
| 87 | + }} |
| 88 | + placeholder="Your message" |
| 89 | + placeholderTextColor={'#C1C6E5'} |
| 90 | + multiline={true} |
| 91 | + ref={textInputRef} |
| 92 | + onChangeText={(text: string) => setUserInput(text)} |
| 93 | + /> |
| 94 | + {userInput && ( |
| 95 | + <TouchableOpacity |
| 96 | + style={styles.sendChatTouchable} |
| 97 | + onPress={async () => !llm.isGenerating && (await sendMessage())} |
| 98 | + > |
| 99 | + <SendIcon height={24} width={24} padding={4} margin={8} /> |
| 100 | + </TouchableOpacity> |
| 101 | + )} |
| 102 | + {llm.isGenerating && ( |
| 103 | + <TouchableOpacity |
| 104 | + style={styles.sendChatTouchable} |
| 105 | + onPress={llm.interrupt} |
| 106 | + > |
| 107 | + <PauseIcon height={24} width={24} padding={4} margin={8} /> |
| 108 | + </TouchableOpacity> |
| 109 | + )} |
| 110 | + </View> |
| 111 | + </SafeAreaView> |
| 112 | + </TouchableWithoutFeedback> |
121 | 113 | );
|
122 | 114 | }
|
123 | 115 |
|
124 | 116 | const styles = StyleSheet.create({
|
125 | 117 | container: { flex: 1 },
|
126 |
| - keyboardAvoidingView: { flex: 1 }, |
127 | 118 | chatContainer: { flex: 10, width: '100%' },
|
128 | 119 | helloMessageContainer: {
|
129 | 120 | flex: 10,
|
|
0 commit comments