Skip to content

Commit eb26362

Browse files
committed
clear chat
1 parent b2bac2f commit eb26362

File tree

2 files changed

+91
-2
lines changed

2 files changed

+91
-2
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { Text, TouchableOpacity, View} from "react-native";
2+
import {useContext, useState} from "react";
3+
import Context from "../../Context/Context";
4+
5+
export const HeadingHistory = ({title}) => {
6+
const {Style1,History,setHistory,SaveData} = useContext(Context)
7+
const [show,setShow]=useState(false)
8+
return (
9+
<View style={{
10+
flexDirection:"row",
11+
justifyContent:"space-between",
12+
alignItems:"center",
13+
paddingTop:20,
14+
paddingHorizontal:20,
15+
marginBottom:10
16+
}}>
17+
<Text style={{
18+
color:Style1.color4,
19+
fontSize:25,
20+
fontWeight:"600",
21+
}}>{title}</Text>
22+
<TouchableOpacity onPress={()=>{
23+
setShow(true)
24+
}} style={{
25+
borderColor:Style1.color2,
26+
borderWidth:1,
27+
padding:5,
28+
borderRadius:10,
29+
}}>
30+
<Text style={{
31+
color:Style1.color2,
32+
fontWeight:"500"
33+
}}>Clear</Text>
34+
</TouchableOpacity>
35+
{show&&<View style={{
36+
height:100,
37+
position:"absolute",
38+
width:200,
39+
backgroundColor:Style1.color5,
40+
zIndex:100,
41+
right:25,
42+
top:-84,
43+
borderRadius:10,
44+
elevation:5,
45+
padding:10,
46+
justifyContent:"space-between",
47+
}}>
48+
<Text style={{
49+
fontSize:17,
50+
fontWeight:"500",
51+
color:Style1.color4
52+
}}>Are you sure you want to clear chat history?</Text>
53+
<View style={{
54+
flexDirection:"row",
55+
alignItems:"center",
56+
justifyContent:"space-between"
57+
}}>
58+
<TouchableOpacity onPress={()=>{
59+
setShow(false)
60+
}} style={{
61+
borderRadius:10,
62+
borderWidth:1,
63+
borderColor:Style1.color2,
64+
padding:5
65+
}}>
66+
<Text style={{
67+
color:Style1.color2
68+
}}>Cancel</Text>
69+
</TouchableOpacity>
70+
<TouchableOpacity onPress={()=>{
71+
setShow(false)
72+
setHistory([])
73+
SaveData()
74+
}} style={{
75+
borderRadius:10,
76+
backgroundColor:"rgb(234,114,114)",
77+
paddingHorizontal:15,
78+
paddingVertical:5,
79+
}}>
80+
<Text style={{
81+
color:Style1.color3
82+
}}>Yes</Text>
83+
</TouchableOpacity>
84+
</View>
85+
</View>}
86+
</View>
87+
)
88+
}

Screens/HomePage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Heading} from "../Components/Global/Heading";
66
import {TopPart} from "../Components/Homepage/TopPart";
77
import {EachHistory} from "../Components/Homepage/EachHistory";
88
import ToggleSwitch from "toggle-switch-react-native";
9+
import {HeadingHistory} from "../Components/Global/HeadingHistory";
910

1011
export const HomePage = ({navigation}) => {
1112
const {Style1,setDarkmode,darkMode,History,SaveDarkMode}=useContext(Context)
@@ -54,8 +55,8 @@ export const HomePage = ({navigation}) => {
5455
<EachFeaturesCard navigation={navigation} image={require("../Assets/kate-macate-xmddEHyCisc-unsplash.jpg")} name={"Generate Mail"} navigate={"MailPage"}/>
5556
<EachFeaturesCard navigation={navigation} image={require("../Assets/christopher-gower-m_HRfLhgABo-unsplash.jpg")} name={"Generate Code"} navigate={"CodePage"}/>
5657
</ScrollView>
57-
<Heading title={"Chat history"}/>
58-
{History!=undefined&&History?.map((e,i)=>{
58+
<HeadingHistory title={"Chat history"}/>
59+
{History!==undefined&&History?.map((e,i)=>{
5960
return <EachHistory text={e[1].message} key={i} data={e} navigation={navigation} index={i}/>
6061
})}
6162
</ScrollView>

0 commit comments

Comments
 (0)