Commit e9e4bfe5 authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

Merge branch 'it18218640' into 'master'

It18218640

See merge request !167
parents 73d032b1 d6c8e846
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
<option name="ignoredIdentifiers"> <option name="ignoredIdentifiers">
<list> <list>
<option value="tensorflow.keras" /> <option value="tensorflow.keras" />
<option value="backend.IT18256888.app.flask_marshmallow" />
<option value="backend.IT18256888.app.*" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
......
...@@ -210,4 +210,4 @@ def reading(): ...@@ -210,4 +210,4 @@ def reading():
return make_response(body) return make_response(body)
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='192.168.8.101') app.run(host='192.168.8.100')
...@@ -124,4 +124,5 @@ def add_result(): ...@@ -124,4 +124,5 @@ def add_result():
#run the flask file #run the flask file
if __name__ == "__main__": if __name__ == "__main__":
# app.run(debug=True) # app.run(debug=True)
app.run(host='0.0.0.0', port=5000, debug=True) app.run(host='192.168.8.101')
# app.run(host='0.0.0.0', port=5000, debug=True)
...@@ -34,16 +34,16 @@ export default function Color() { ...@@ -34,16 +34,16 @@ export default function Color() {
.then(res => { .then(res => {
console.log(res.data); console.log(res.data);
if (res.status == 200) { if (res.status == 200) {
console.log(res.data); // console.log(res.data);
const token = res.data.token; const colorToken = res.data.token;
try { try {
AsyncStorage.setItem('token', token); AsyncStorage.setItem('colorToken', colorToken);
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 }) console.log(colorToken)
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
navigation.navigate(path); navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
} }
}) })
.catch(error => { .catch(error => {
......
...@@ -13,9 +13,11 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; ...@@ -13,9 +13,11 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
export default function Red() { export default function Red() {
const colorToken = AsyncStorage.getItem('colorSession'); const [colorToken, setColorToken] = useState();
const [modalVisible, setModalVisible] = useState(false); const [modalVisible, setModalVisible] = useState(false);
const [colorData, setColorData] = useState({activity: ''}); const [modalVisible2, setModalVisible2] = useState(false);
const [colorData, setColorData] = useState({ activity: '' });
const navigation = useNavigation(); const navigation = useNavigation();
...@@ -38,8 +40,7 @@ export default function Red() { ...@@ -38,8 +40,7 @@ export default function Red() {
Voice.onSpeechEnd = onSpeechEndHandler; Voice.onSpeechEnd = onSpeechEndHandler;
Voice.onSpeechResults = onSpeechResultsHandler; Voice.onSpeechResults = onSpeechResultsHandler;
Voice.onSpeechPartialResults = onSpeechPartialResults; Voice.onSpeechPartialResults = onSpeechPartialResults;
// Voice.onSpeechError = onSpeechError;
// console.log(backColor);
return () => { return () => {
Voice.destroy().then(Voice.removeAllListeners); Voice.destroy().then(Voice.removeAllListeners);
...@@ -48,15 +49,9 @@ export default function Red() { ...@@ -48,15 +49,9 @@ export default function Red() {
useEffect(() => { useEffect(() => {
console.log(colorToken); // console.log(colorToken);
// AsyncStorage.getItem('token')
// .then(value => { }, []);
// console.log(value);
// })
// .catch(error => {
// console.log(error);
// });
}, []);
const onSpeechStartHandler = e => { const onSpeechStartHandler = e => {
// console.log('start handler =>> ', e); // console.log('start handler =>> ', e);
...@@ -98,35 +93,72 @@ export default function Red() { ...@@ -98,35 +93,72 @@ export default function Red() {
}; };
// const onSpeechError = e => {
// console.log('onSpeechError: ', e);
// const value = e.value;
// if (value.includes(secondColor[0]) == true) {
// console.log('Your Answer is Correct');
// sendData(mainColor[0])
// // showAlert = () => {
// // this.setState({
// // showAlert: true
// // });
// // };
// } else {
// console.log('Your Answer is Incorrect', value);
// }
// };
function sendData(value) { function sendData(value) {
var date = new Date().getDate(); AsyncStorage.getItem('colorToken')
var month = new Date().getMonth() + 1; .then(res => {
var year = new Date().getFullYear();
var todayData = date + '-' + month + '-' + year; var date = new Date().getDate();
var month = new Date().getMonth() + 1;
var year = new Date().getFullYear();
var data = { var todayData = date + '-' + month + '-' + year;
value: value,
date: todayData, var data = {
token: colorToken, value: value,
} date: todayData,
token: res,
}
data = JSON.stringify(data);
setColorData(data);
data = JSON.stringify(data); console.log(data);
setColorData(data); client.post('store', data, {
// console.log(localStorage.getItem('colorSession')); headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}).then((response) => {
console.log(response.data);
// setModalVisible2(true);
// navigation.navigate("Green");
}).catch(err => {
console.log(err);
})
client.post('store', data, { })
headers: { .catch(error => {
Accept: 'application/json', console.log(error);
'Content-Type': 'application/json', });
},
}).then((response) => {
console.log(response.data);
}).catch(err => {
console.log(err);
})
} }
...@@ -139,17 +171,9 @@ export default function Red() { ...@@ -139,17 +171,9 @@ export default function Red() {
// setPartialResults(e.value); // setPartialResults(e.value);
}; };
const onFinishCD = () => {
Alert.alert('Countdown Finished...');
}
const onPressCD = () => {
Alert.alert('Countdown Component Pressed...');
}
const startRecording = async () => { const startRecording = async () => {
setModalVisible(true); // setModalVisible(true);
try { try {
await Voice.start('en-US'); await Voice.start('en-US');
...@@ -201,6 +225,32 @@ export default function Red() { ...@@ -201,6 +225,32 @@ export default function Red() {
</View> </View>
<View>
<Modal
animationType="slide"
transparent={true}
hidden={true}
visible={modalVisible2}
onRequestClose={() => {
setModalVisible2(!modalVisible2);
}}
>
<View style={styles.centeredView2}>
<View style={styles.modalView2}>
<Text>Your answer is Corect</Text>
<Pressable
style={[styles.button, styles.buttonClose2]}
onPress={() => navigation.navigate("Green")}
>
<Text style={styles.textStyle2}>Next Game</Text>
</Pressable>
</View>
</View>
</Modal>
</View>
<View style={{ flexDirection: "column" }}> <View style={{ flexDirection: "column" }}>
<ImageBackground style={styles.image} source={require("../../assets/game/gameback.png")}> <ImageBackground style={styles.image} source={require("../../assets/game/gameback.png")}>
...@@ -237,7 +287,7 @@ export default function Red() { ...@@ -237,7 +287,7 @@ export default function Red() {
</View> </View>
<View style={{ marginLeft: -100 }}> <View style={{ marginLeft: -100 }}>
<TouchableOpacity onPress={() => { }} <TouchableOpacity onPress={() => { navigation.navigate("Green")}}
style={{ width: "60%", height: "40%", borderRadius: 50 }}> style={{ width: "60%", height: "40%", borderRadius: 50 }}>
<Image source={require('../../assets/game/next.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -90 }} /> <Image source={require('../../assets/game/next.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -90 }} />
</TouchableOpacity> </TouchableOpacity>
...@@ -314,4 +364,46 @@ const styles = StyleSheet.create({ ...@@ -314,4 +364,46 @@ const styles = StyleSheet.create({
elevation: 2 elevation: 2
}, },
centeredView2: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22
},
modalView2: {
margin: 20,
backgroundColor: "white",
borderRadius: 20,
padding: 35,
alignItems: "center",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5
},
button2: {
borderRadius: 20,
padding: 10,
elevation: 2
},
buttonOpen2: {
backgroundColor: "#F194FF",
},
buttonClose2: {
backgroundColor: "#2196F3",
},
textStyle2: {
color: "white",
fontWeight: "bold",
textAlign: "center"
},
modalText2: {
marginBottom: 15,
textAlign: "center"
}
}) })
\ No newline at end of file
...@@ -2,6 +2,6 @@ import axios from 'axios'; ...@@ -2,6 +2,6 @@ import axios from 'axios';
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, }); // export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
export default axios.create({ export default axios.create({
baseURL: 'http://192.168.8.101:5000/', baseURL: 'http://192.168.8.100:5000/',
timeout: 15000, timeout: 15000,
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment