Skip to content

Commit aefb30a

Browse files
committed
Plagiarism page done
1 parent 731f962 commit aefb30a

File tree

5 files changed

+208
-3
lines changed

5 files changed

+208
-3
lines changed

App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {ToastProvider} from 'react-native-toast-notifications';
1010
import {OnboardingScreen} from './Screens/OnboardingScreen';
1111
import {Initial} from './Screens/Initial';
1212
import {EsseyPage} from './Screens/EsseyPage';
13+
import {PlagiarismPage} from './Screens/Plagiarism';
1314

1415
function App(): JSX.Element {
1516
const Stack = createNativeStackNavigator();
@@ -60,6 +61,13 @@ function App(): JSX.Element {
6061
headerShown: false,
6162
}}
6263
/>
64+
<Stack.Screen
65+
name={'PlagiarismPage'}
66+
component={PlagiarismPage}
67+
options={{
68+
headerShown: false,
69+
}}
70+
/>
6371
<Stack.Screen
6472
name={'CodePage'}
6573
component={CodePage}

Assets/Essey.png

83.3 KB
Loading

Components/Global/ReaultDiaplay.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function ResultDisplay({text}) {
104104
alignItems: 'center',
105105
flexDirection: 'row',
106106
justifyContent: 'center',
107+
marginTop: 10,
107108
}}
108109
onPress={() => {
109110
Clipboard.setString(text);

Screens/HomePage.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ export function HomePage({navigation}) {
8686
title={'ESSEY'}
8787
discreption={'Generate essay on any topic.'}
8888
image={require('../Assets/Essey.png')}
89-
color={'rgba(136, 48, 85, 0.22)'}
89+
color={'rgba(136, 48, 48, 0.18)'}
9090
navigation={navigation}
9191
route={'EsseyPage'}
9292
/>
9393
<EachCard
94-
title={'AI'}
95-
discreption={'Chat with your pdf and get the best out of it'}
94+
title={'PLAGIARISM'}
95+
discreption={'Remove plagiarism of any text in one tap.'}
9696
image={require('../Assets/ai.png')}
9797
color={'#2c2250'}
98+
route={'PlagiarismPage'}
99+
navigation={navigation}
98100
/>
99101
</View>
100102
<View

Screens/Plagiarism.js

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/* eslint-disable react-native/no-inline-styles */
2+
/* eslint-disable react/react-in-jsx-scope */
3+
import {
4+
Image,
5+
ScrollView,
6+
Text,
7+
TextInput,
8+
TouchableOpacity,
9+
View,
10+
Clipboard,
11+
Dimensions,
12+
} from 'react-native';
13+
import {TopHeader} from '../Components/Global/TopHeader';
14+
import {useState} from 'react';
15+
import {useToast} from 'react-native-toast-notifications';
16+
import axios from 'axios';
17+
import ResultDiaplay from '../Components/Global/ReaultDiaplay';
18+
19+
export const PlagiarismPage = ({navigation}) => {
20+
const windowWidth = Dimensions.get('window').width;
21+
const [input, setInput] = useState('');
22+
const [loading, setloading] = useState(false);
23+
const [result, setResult] = useState('');
24+
const toast = useToast();
25+
async function GenerateCode() {
26+
if (input === '') {
27+
toast.show('Enter Paragraph', {
28+
type: 'danger',
29+
placement: 'center',
30+
duration: 4000,
31+
offset: 30,
32+
animationType: 'zoom-in',
33+
});
34+
} else {
35+
setloading(true);
36+
let config = {
37+
method: 'post',
38+
maxBodyLength: Infinity,
39+
url: 'https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage?key=AIzaSyD46fzT8jTrrC8mFSoZWtHFzoCh79MpkYk',
40+
headers: {
41+
'Content-Type': 'application/json',
42+
},
43+
data: JSON.stringify({
44+
prompt: {
45+
messages: [
46+
{
47+
content: `remove plagiarism from following text: \n
48+
${input}`,
49+
},
50+
],
51+
},
52+
}),
53+
};
54+
axios
55+
.request(config)
56+
.then(r => {
57+
setResult(r.data.candidates[0].content);
58+
setInput('');
59+
setloading(false);
60+
})
61+
.catch(e => {
62+
setloading(false);
63+
if (e.message === 'Network Error') {
64+
toast.show('No Internet 😟', {
65+
type: 'danger',
66+
placement: 'top',
67+
duration: 3000,
68+
offset: 30,
69+
animationType: 'zoom-in',
70+
});
71+
}
72+
console.log(e.message);
73+
});
74+
}
75+
}
76+
return (
77+
<View
78+
style={{
79+
flex: 1,
80+
backgroundColor: '#1e1b38',
81+
}}>
82+
<TopHeader text={'Plagiarism'} navigation={navigation} />
83+
<ScrollView>
84+
<View style={{paddingHorizontal: 20}}>
85+
<View
86+
style={{
87+
backgroundColor: '#292250',
88+
borderTopRightRadius: 10,
89+
borderTopLeftRadius: 10,
90+
overflow: 'hidden',
91+
}}>
92+
<TextInput
93+
clearButtonMode="while-editing"
94+
multiline={true}
95+
numberOfLines={6}
96+
placeholder={'Paragraph...'}
97+
value={input}
98+
onChangeText={text => {
99+
setInput(text);
100+
}}
101+
placeholderTextColor={'rgb(197, 195, 195)'}
102+
style={{
103+
backgroundColor: '#292250',
104+
alignItems: 'flex-start',
105+
textAlignVertical: 'top',
106+
padding: 15,
107+
color: 'white',
108+
borderBottomWidth: 1,
109+
borderBottomColor: '#100b2e',
110+
}}
111+
/>
112+
</View>
113+
</View>
114+
{!loading && (
115+
<View
116+
style={{
117+
flexDirection: 'row',
118+
gap: 2,
119+
}}>
120+
<TouchableOpacity
121+
onPress={() => {
122+
if (!loading) {
123+
setInput('');
124+
}
125+
}}
126+
style={{
127+
backgroundColor: '#4341c2',
128+
marginLeft: 20,
129+
alignItems: 'center',
130+
justifyContent: 'center',
131+
height: 50,
132+
flex: 1,
133+
borderBottomLeftRadius: 10,
134+
}}>
135+
<Text
136+
style={{
137+
textAlign: 'center',
138+
fontSize: windowWidth * 0.032,
139+
color: 'rgb(236, 236, 236)',
140+
}}>
141+
Clear text
142+
</Text>
143+
</TouchableOpacity>
144+
<TouchableOpacity
145+
onPress={() => {
146+
if (!loading) {
147+
GenerateCode();
148+
}
149+
}}
150+
style={{
151+
backgroundColor: '#4341c2',
152+
marginRight: 20,
153+
alignItems: 'center',
154+
justifyContent: 'center',
155+
height: 50,
156+
flex: 1,
157+
borderBottomRightRadius: 10,
158+
}}>
159+
<Text
160+
style={{
161+
textAlign: 'center',
162+
fontSize: windowWidth * 0.032,
163+
color: 'rgb(236, 236, 236)',
164+
}}>
165+
Remove plagiarism
166+
</Text>
167+
</TouchableOpacity>
168+
</View>
169+
)}
170+
{loading && (
171+
<View
172+
style={{
173+
backgroundColor: '#292250',
174+
marginHorizontal: 20,
175+
alignItems: 'center',
176+
justifyContent: 'center',
177+
height: 50,
178+
borderBottomRightRadius: 10,
179+
borderBottomLeftRadius: 10,
180+
}}>
181+
<Image
182+
source={require('../Assets/loading.gif')}
183+
style={{
184+
width: 100,
185+
height: 50,
186+
}}
187+
/>
188+
</View>
189+
)}
190+
{result.length !== 0 && <ResultDiaplay text={result} />}
191+
</ScrollView>
192+
</View>
193+
);
194+
};

0 commit comments

Comments
 (0)