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 @@
<option name="ignoredIdentifiers">
<list>
<option value="tensorflow.keras" />
<option value="backend.IT18256888.app.flask_marshmallow" />
<option value="backend.IT18256888.app.*" />
</list>
</option>
</inspection_tool>
......
......@@ -210,4 +210,4 @@ def reading():
return make_response(body)
if __name__ == "__main__":
app.run(host='192.168.8.101')
app.run(host='192.168.8.100')
......@@ -124,4 +124,5 @@ def add_result():
#run the flask file
if __name__ == "__main__":
# 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() {
.then(res => {
console.log(res.data);
if (res.status == 200) {
console.log(res.data);
const token = res.data.token;
// console.log(res.data);
const colorToken = res.data.token;
try {
AsyncStorage.setItem('token', token);
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
AsyncStorage.setItem('colorToken', colorToken);
console.log(colorToken)
} catch (error) {
console.log(error);
}
navigation.navigate(path);
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
}
})
.catch(error => {
......
......@@ -13,9 +13,11 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
export default function Red() {
const colorToken = AsyncStorage.getItem('colorSession');
const [colorToken, setColorToken] = useState();
const [modalVisible, setModalVisible] = useState(false);
const [colorData, setColorData] = useState({activity: ''});
const [modalVisible2, setModalVisible2] = useState(false);
const [colorData, setColorData] = useState({ activity: '' });
const navigation = useNavigation();
......@@ -38,8 +40,7 @@ export default function Red() {
Voice.onSpeechEnd = onSpeechEndHandler;
Voice.onSpeechResults = onSpeechResultsHandler;
Voice.onSpeechPartialResults = onSpeechPartialResults;
// console.log(backColor);
// Voice.onSpeechError = onSpeechError;
return () => {
Voice.destroy().then(Voice.removeAllListeners);
......@@ -48,15 +49,9 @@ export default function Red() {
useEffect(() => {
console.log(colorToken);
// AsyncStorage.getItem('token')
// .then(value => {
// console.log(value);
// })
// .catch(error => {
// console.log(error);
// });
}, []);
// console.log(colorToken);
}, []);
const onSpeechStartHandler = e => {
// console.log('start handler =>> ', e);
......@@ -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) {
var date = new Date().getDate();
var month = new Date().getMonth() + 1;
var year = new Date().getFullYear();
AsyncStorage.getItem('colorToken')
.then(res => {
var todayData = date + '-' + month + '-' + year;
var date = new Date().getDate();
var month = new Date().getMonth() + 1;
var year = new Date().getFullYear();
var data = {
value: value,
date: todayData,
token: colorToken,
}
var todayData = date + '-' + month + '-' + year;
var data = {
value: value,
date: todayData,
token: res,
}
data = JSON.stringify(data);
setColorData(data);
data = JSON.stringify(data);
console.log(data);
setColorData(data);
// console.log(localStorage.getItem('colorSession'));
client.post('store', data, {
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: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}).then((response) => {
console.log(response.data);
}).catch(err => {
console.log(err);
})
})
.catch(error => {
console.log(error);
});
}
......@@ -139,17 +171,9 @@ export default function Red() {
// setPartialResults(e.value);
};
const onFinishCD = () => {
Alert.alert('Countdown Finished...');
}
const onPressCD = () => {
Alert.alert('Countdown Component Pressed...');
}
const startRecording = async () => {
setModalVisible(true);
// setModalVisible(true);
try {
await Voice.start('en-US');
......@@ -201,6 +225,32 @@ export default function Red() {
</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" }}>
<ImageBackground style={styles.image} source={require("../../assets/game/gameback.png")}>
......@@ -237,7 +287,7 @@ export default function Red() {
</View>
<View style={{ marginLeft: -100 }}>
<TouchableOpacity onPress={() => { }}
<TouchableOpacity onPress={() => { navigation.navigate("Green")}}
style={{ width: "60%", height: "40%", borderRadius: 50 }}>
<Image source={require('../../assets/game/next.png')} resizeMode='contain' style={{ flex: .9, marginLeft: -90 }} />
</TouchableOpacity>
......@@ -314,4 +364,46 @@ const styles = StyleSheet.create({
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';
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
export default axios.create({
baseURL: 'http://192.168.8.101:5000/',
baseURL: 'http://192.168.8.100:5000/',
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