-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
87 lines (81 loc) · 2.12 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React, { useState } from "react";
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View, Image, FlatList, TextInput, TouchableOpacity } from "react-native";
import Response from "./components/response";
import Message from "./components/message";
export default function App() {
const [inputText, setInputText] = useState("");
const [listData, setListData] = useState([]);
const SearchInput = () => {
setListData((prevList) => [...prevList, inputText]);
setInputText("");
};
return (
<View style={styles.container}>
<StatusBar style="auto" />
{/* Header */}
<View style={styles.header}>
<Image source={require("./assets/icons/robot.png")} style={styles.icon} />
<Text style={{ fontSize: 24, fontWeight: "800", color: "#323232" }}>Gemini AI</Text>
</View>
{/* Content */}
<FlatList
style={{ paddingHorizontal: 16, marginBottom: 80 }}
data={listData}
renderItem={({ item }) => (
<View>
<Message message={item} />
<Response prompt={item} />
</View>
)}
keyExtractor={(item, index) => index.toString()}
/>
{/* Search-Bar */}
<View style={styles.searchBar}>
<TextInput placeholder="Ask to Gemini AI" style={styles.input} value={inputText} onChangeText={(text) => setInputText(text)} selectionColor={"#323232"}></TextInput>
<TouchableOpacity onPress={SearchInput}>
<Image source={require("./assets/icons/right-arrow.png")} style={styles.icon} />
</TouchableOpacity>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
gap: 16,
paddingTop: 36,
},
header: {
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 16,
margin: 8,
gap: 8,
},
icon: {
width: 32,
height: 32,
},
searchBar: {
backgroundColor: "#ffffff",
width: "100%",
position: "absolute",
bottom: 0,
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
paddingHorizontal: 32,
paddingVertical: 16,
gap: 8,
},
input: {
backgroundColor: "#fff",
width: "100%",
fontSize: 16,
paddingVertical: 16,
paddingHorizontal: 24,
borderRadius: 32,
borderWidth: 0.1,
},
});