Commit a658579b authored by norhalimah's avatar norhalimah

updating.....

parent b736426d
......@@ -18,27 +18,27 @@ import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example:
// packages.add(new MyReactNativePackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
......@@ -53,24 +53,23 @@ public class MainApplication extends Application implements ReactApplication {
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
* Loads Flipper in React Native templates. Call this in the onCreate method
* with something like initializeFlipper(this,
* getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
* We use reflection here to pick up the class that initializes Flipper, since
* Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.pianoapp.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
aClass.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class).invoke(null, context,
reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
......
......@@ -9,13 +9,14 @@ import {
TouchableOpacity,
StyleSheet,
ScrollView,
Image,
} from 'react-native';
import {Icon} from 'react-native-elements';
import Orientation from 'react-native-orientation';
class Home extends React.PureComponent {
componentDidMount() {
async componentDidMount() {
Orientation.lockToPortrait();
}
......@@ -34,26 +35,26 @@ class Home extends React.PureComponent {
}}>
<SafeAreaView>
<ScrollView>
<View style={{marginTop: '10%'}}>
<View style={{marginTop: '5%', marginBottom: '5%'}}>
<TouchableOpacity
style={styles.menu}
onPress={() => {
this.props.navigation.navigate('2',{c: 0, w: 0, t: 0, cc : 1});
}}>
<Icon raised name="trophy" type="font-awesome" />
<Text>Piano</Text>
<Image style={{height:150, width:250}} source={require('../img/1piano.png')} />
<Text style={{fontSize:20}}>{'\n'}Piano</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.menu}
onPress={() => this.props.navigation.navigate('3')}>
<Icon raised name="clipboard" type="font-awesome" />
<Text>Records</Text>
<Icon size={150} name="clipboard" type="font-awesome" />
<Text style={{fontSize:20}}>{'\n'}Records</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.menu}
onPress={() => this.props.navigation.navigate('4')}>
<Icon raised name="cogs" type="font-awesome" />
<Text>Settings</Text>
<Image style={{height:150, width:150}} source={require('../img/settings.png')} />
<Text style={{fontSize:20}}>{'\n'}Settings</Text>
</TouchableOpacity>
</View>
</ScrollView>
......@@ -73,13 +74,12 @@ const styles = StyleSheet.create({
justifyContent: 'center',
},
menu: {
marginTop: '3%',
marginBottom: '2%',
alignItems: 'center',
justifyContent: 'center',
padding: '15%',
marginLeft: '5%',
marginRight: '5%',
padding: '10%',
marginLeft: '3%',
marginRight: '3%',
borderRadius: 10,
borderWidth: 2,
borderColor: 'white',
......
......@@ -18,7 +18,7 @@ import Orientation from 'react-native-orientation';
//import AsyncStorage from '@react-native-async-storage/async-storage';
import * as RNFS from 'react-native-fs';
var path = RNFS.DocumentDirectoryPath + '/test.txt';
var array = [];
//var array = [];
class LogBook extends React.PureComponent {
constructor(props) {
......@@ -35,20 +35,7 @@ class LogBook extends React.PureComponent {
this.setState({
logbook: res.split('\n'),
});
// var l = this.state.logbook.length;
//console.log(res);
// console.log(this.state.logbook);
let index = -1;
array = this.state.logbook;
// console.log(array);
if ((index = array.indexOf('')) !== -1) {
array.splice(index, 1);
this.setState({
logbook: array,
});
console.log(this.state.logbook);
}
// console.log(this.state.logbook.length);
console.log(this.state.logbook);
})
.catch((err) => {
console.log(err.message, err.code);
......@@ -73,22 +60,18 @@ class LogBook extends React.PureComponent {
<ScrollView
style={{
marginTop: 50,
marginLeft: 5,
marginRight: 5,
}}>
{this.state.logbook.map((item, id) => (
<View
key={id}
style={{
flexDirection: 'row',
marginBottom: 10,
padding: 15,
borderWidth: 2,
borderColor: 'black',
backgroundColor: 'white',
borderRadius: 10,
borderBottomWidth:1,
}}>
<Text style={{fontSize:15}}>{item.split(',').join('\n')}</Text>
<Text style={{fontSize:17}}>{item.split(',').join('\n')}</Text>
</View>
)).reverse()}
</ScrollView>
......
/* eslint-disable prettier/prettier */
/* eslint-disable react/no-did-mount-set-state */
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable prettier/prettier */
/* eslint-disable prettier/prettier */
import React from 'react';
import {
......@@ -10,19 +11,20 @@ import {
TouchableHighlight,
Button,
Image,
Alert,
///Alert,
Modal,
TouchableOpacity,
Dimensions,
} from 'react-native';
import {Stopwatch} from 'react-native-stopwatch-timer';
import Orientation from 'react-native-orientation';
import * as RNFS from 'react-native-fs';
var path = RNFS.DocumentDirectoryPath + '/settings.txt';
var path1 = RNFS.DocumentDirectoryPath + '/counter.txt';
import Notes from './data';
import styles from '../style/style';
import moment from 'moment';
var date = moment().utcOffset('+08:00').format('D MMM YYYY');
var time = moment().utcOffset('+08:00').format('h:mm a');
var record = RNFS.DocumentDirectoryPath + '/test.txt';
import OtherClass from './saveRecords';
const path = RNFS.DocumentDirectoryPath + '/settings.txt';
const path1 = RNFS.DocumentDirectoryPath + '/counter.txt';
const NOTESWHITE = [
'C1',
'D1',
......@@ -50,9 +52,11 @@ const NOTESFF1 = ['F#2'];
const NOTESGG1 = ['G#2'];
const NOTESAA1 = ['A#2'];
const keywordsList = [];
var maxCount = 0;
var maxCount = 5;
var imageN = '';
var indexN = 0;
var stime = 0;
class Quiz extends React.Component {
......@@ -61,12 +65,15 @@ class Quiz extends React.Component {
this.state = {
logbook: [],
index:0,
timer: 0,
correct: 0,
wrong: 0,
keywordsList: '',
count: 1,
name : '',
start : true,
showC : false,
showW : false,
showDone : false,
};
}
......@@ -83,22 +90,11 @@ class Quiz extends React.Component {
this.setState({keywordsList: list});
};
//reset
removeArray = () => {
keywordsList.splice(0, keywordsList.length);
console.log(keywordsList);
/* this.setState({
timer: 0,
});
clearInterval(this._interval); */
Orientation.lockToLandscape();
};
onSubmit = () => {
if (this.state.name.includes('C Major') || this.state.name.includes('Bass Clef C Major')) {
this.ansCMajor();
}
else if (this.state.name.includes('D Major') || this.state.name.includes('Bass Clef D Major')) {
else if (this.state.name.includes('D Major') || this.state.name.includes('Bass Clef D Major')) {
this.ansDMajor();
}
else if (this.state.name.includes('E Major') || this.state.name.includes('Bass Clef E Major')) {
......@@ -144,800 +140,481 @@ class Quiz extends React.Component {
};
ansCMajor = ()=> {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'C1,D1,E1,F1,G1,A1,B1,C2'){
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansDMajor = () => {
console.log(maxCount);
console.log(this.state.count);
ansDMajor = () => {
if (keywordsList.toString() === 'D1,E1,F#1,G1,A1,B1,C#2,D2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansEMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'E1,F#1,G#1,A1,B1,C#2,D#2,E2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansFsMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'F#1,G#1,A#1,B1,C#2,D#2,F2,F#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansFMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'F1,G1,A1,A#1,C2,D2,E2,F2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansEbMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'D#1,F1,G1,G#1,A#1,C2,D2,D#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansDbMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'C#1,D#1,F1,F#1,G#1,A#1,C2,C#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansGMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'G1,A1,B1,C2,D2,E2,F#2,G2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansAMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'A1,B1,C#2,D2,E2,F#2,G#2,A2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansBMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'B1,C#2,D#2,E2,F#2,G#2,A#2,B2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansCsMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'C#1,D#1,F1,F#1,G#1,A#1,C2,C#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansBbMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'A#1,C2,D2,D#2,F2,G2,A2,A#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansAbMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'G#1,A#1,C2,C#2,D#2,F2,G2,G#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
if ( (this.state.count + 1) > maxCount) {
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
ansGbMajor = () => {
console.log(maxCount);
console.log(this.state.count);
if (keywordsList.toString() === 'F#1,G#1,A#1,B1,C#2,D#2,F2,F#2') {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
(this.state.correct + 2) +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord((this.state.correct + 2), this.state.wrong, this.state.timer);
console.log('finish');}
this.setState({correct : this.state.correct + 1});
this.setState({showDone: true});
this.handlerArgCall((this.state.correct + 1), this.state.wrong, stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Correct!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct + 2,
w: this.state.wrong,
t: this.state.timer,
cc : this.state.count + 1,
});
keywordsList.splice(0, keywordsList.length);
this.setState({correct : this.state.correct + 1, count:this.state.count + 1, showC: true});
this.displayData();
}
} else {
if ( (this.state.count + 1) > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
(this.state.wrong + 1) +
'\n',
);
this.saveRecord(this.state.correct, (this.state.wrong + 1), this.state.timer);
console.log('finish');}
this.setState({wrong : this.state.wrong + 1});
this.setState({showDone: true});
this.handlerArgCall(this.state.correct, (this.state.wrong + 1), stime);
console.log('finish');
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
}
else {
Alert.alert('Wrong!');
keywordsList.splice(0, keywordsList.length);
this.props.navigation.push('2', {
c: this.state.correct,
w: this.state.wrong + 1,
t: this.state.timer,
cc : this.state.count + 1,
});
this.setState({showW: true});
keywordsList.splice(0, keywordsList.length);
this.setState({wrong : this.state.wrong + 1, count:this.state.count + 1});
this.displayData();
}
}
};
/* countMax(){
if (this.state.count > this.state.logbook.length || this.state.count > countQ || this.state.count > maxCount) {
this.props.navigation.navigate('1');
Orientation.lockToPortrait();
Alert.alert(
'Well Done',
'Correct: ' +
this.state.correct +
'\nWrong: ' +
this.state.wrong +
'\n',
);
this.saveRecord(this.state.correct, this.state.wrong, this.state.timer);
console.log('finish');}
}*/
componentDidMount() {
this.setState({
correct: this.props.route.params.c,
wrong: this.props.route.params.w,
timer: this.props.route.params.t,
count: this.props.route.params.cc,
});
// console.log(this.props.route.params.cc);
async componentDidMount() {
this.removeArray();
Orientation.lockToLandscape();
this.interval = setInterval(
() => this.setState((prevState) => ({timer: prevState.timer + 1})),
1000,
);
this.displayData();
}
componentWillUnmount() {
clearInterval(this.interval);
// Orientation.lockToLandscape();
this.removeArray();
//clearInterval(this.interval);
// Orientation.lockToLandscape();
}
';';
displayData = async () => {
displayData = async () => {
RNFS.readFile(path, 'ascii')
.then((res) => {
this.setState({
......@@ -954,7 +631,6 @@ class Quiz extends React.Component {
indexN = Notes.findIndex(item=> '"' + item.name + '"' === this.state.name || '["' + item.name + '"]' === this.state.name || '["' + item.name + '"' === this.state.name || '"' + item.name + '"]' === this.state.name);
console.log(this.state.name);
maxCount = ccc;
console.log(maxCount);
})
.catch((err) => {
console.log(err.message, err.code);
......@@ -964,10 +640,8 @@ class Quiz extends React.Component {
name : this.state.logbook[imageN],
});
indexN = Notes.findIndex(item=> '"' + item.name + '"' === this.state.name || '["' + item.name + '"]' === this.state.name || '["' + item.name + '"' === this.state.name || '"' + item.name + '"]' === this.state.name);
//console.log(this.state.name);
});
maxCount = this.state.logbook.length;
console.log(maxCount);
})
.catch((err) => {
console.log(err.message, err.code);
......@@ -979,10 +653,8 @@ class Quiz extends React.Component {
this.setState({
name : Notes[indexN].name,
});
// console.log(this.state.name);
// console.log(imageN);
maxCount = res;
console.log(maxCount);
//console.log(res);
})
.catch(() => {
// console.log(err.message, err.code);
......@@ -992,78 +664,20 @@ class Quiz extends React.Component {
this.setState({
name : Notes[indexN].name,
});
// console.log(this.state.name);
// console.log(imageN);
maxCount = 2;
console.log(maxCount);
maxCount = 5;
});
});
};
saveRecord = async (correct, wrong, timer) => {
let obj = {
correct: correct,
wrong: wrong,
timer: timer,
date: date,
time: time,
};
if (await RNFS.exists(record)) {
console.log('BLAH EXISTS');
// write the file
RNFS.appendFile(
record,
'Correct : ' +
JSON.stringify(obj.correct) +
',' +
'Wrong : ' +
JSON.stringify(obj.wrong) +
',' +
'Timer : ' +
JSON.stringify(obj.timer) +
',' +
'Date : ' +
date +
',' +
'Time : ' +
time +
'\n',
'utf8',
)
.then((success) => {
console.log(JSON.stringify(obj));
})
.catch((err) => {
console.log(err.message);
});
} else {
console.log('BLAH DOES NOT EXIST');
RNFS.writeFile(
record,
'Correct : ' +
JSON.stringify(obj.correct) +
',' +
'Wrong : ' +
JSON.stringify(obj.wrong) +
',' +
'Timer : ' +
JSON.stringify(obj.timer) +
',' +
'Date : ' +
date +
',' +
'Time : ' +
time +
'\n',
'utf8',
)
.then((success) => {
console.log(JSON.stringify(obj));
})
.catch((err) => {
console.log(err.message);
});
}
handlerArgCall = (correct, wrong, timer) => {
new OtherClass().saveRecord(correct, wrong, timer);
};
//reset
removeArray = () => {
keywordsList.splice(0, keywordsList.length);
console.log(keywordsList);
clearInterval(this._interval);
};
render() {
......@@ -1094,18 +708,123 @@ class Quiz extends React.Component {
} = styles;
return (
<View style={styles.container}>
<Modal transparent={true} visible={this.state.showC}>
<View style={{backgroundColor: '#000000aa', flex: 1}}>
<View
style={{
marginTop: Dimensions.get('window').height * 0.3,
marginLeft: Dimensions.get('window').width * 0.3,
backgroundColor: 'white',
width : Dimensions.get('window').width * 0.4,
borderRadius: 5,
}}>
<Text style={{fontSize: 20, margin:10}}>Correct</Text>
<View
style={{
alignItems: 'flex-end',
}}>
<TouchableOpacity style={{
backgroundColor: 'black',
padding: 15,
borderRadius: 5,
margin:10,
}}
onPress={() => this.setState({showC: false})}>
<Text style={{color: 'white'}}>Ok</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<Modal transparent={true} visible={this.state.showW}>
<View style={{backgroundColor: '#000000aa', flex: 1}}>
<View
style={{
marginTop: Dimensions.get('window').height * 0.3,
marginLeft: Dimensions.get('window').width * 0.3,
backgroundColor: 'white',
width : Dimensions.get('window').width * 0.4,
borderRadius: 5,
}}>
<Text style={{fontSize: 20, margin:10}}>Wrong</Text>
<View
style={{
alignItems: 'flex-end',
}}>
<TouchableOpacity style={{
backgroundColor: 'black',
padding: 15,
borderRadius: 5,
margin:10,
}}
onPress={() => this.setState({showW: false})}>
<Text style={{color: 'white'}}>Ok</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<Modal transparent={true} visible={this.state.showDone}>
<View style={{backgroundColor: '#000000aa', flex: 1}}>
<View
style={{
marginTop: Dimensions.get('window').height * 0.6,
marginLeft: Dimensions.get('window').width * 0.05,
backgroundColor: 'white',
width : Dimensions.get('window').width * 0.4,
borderRadius: 5,
}}>
<Text style={{fontSize: 20, margin:10}}>Well Done</Text>
<Text style={{fontSize: 15, marginLeft:10}}>Correct : {this.state.correct}</Text>
<Text style={{fontSize: 15, marginLeft:10}}>Wrong: {this.state.wrong}</Text>
<View
style={{
alignItems: 'flex-end',
}}>
<TouchableOpacity style={{
backgroundColor: 'black',
padding: 15,
borderRadius: 5,
margin : 10,
}}
onPress={() => this.setState({showDone: false})}>
<Text style={{color: 'white'}}>Ok</Text>
</TouchableOpacity>
</View>
</View>
</View>
</Modal>
<StatusBar hidden />
<View style={styles.c1}>
<View style={styles.cc1}>
<Text style={styles.correct}>Correct : {this.state.correct}</Text>
<Text style={styles.wrong}>
Wrong :{'\n'}
{this.state.wrong}
</Text>
<Text style={styles.timer}>
Timer :{'\n'}
{this.state.timer}
</Text>
<Text style={styles.wrong}>{this.state.wrong}</Text>
<Text style={styles.correct}>{this.state.correct} / {maxCount}</Text>
<Stopwatch
secs
start={this.state.start}
getTime={(tt) => {
//console.log(tt);
stime = tt;
}}
options={{ container: {
backgroundColor: 'black',
padding: 5,
borderRadius: 10,
width: 200,
alignItems: 'center',
},
text: {
fontSize: 25,
color: '#FFF',
textAlign: 'center',
paddingTop: 10,
alignItems: 'center',
},
}}
// Options for the styling
/>
</View>
<View style={styles.buttonView}>
<View style={styles.submit}>
......
/* eslint-disable prettier/prettier */
/*This is an Example of Calling Other Class Function in React Native*/
import { Component } from 'react';
import {Alert} from 'react-native';
import moment from 'moment';
import * as RNFS from 'react-native-fs';
const date = moment().utcOffset('+08:00').format('D MMM YYYY');
const time = moment().utcOffset('+08:00').format('h:mm a');
const record = RNFS.DocumentDirectoryPath + '/test.txt';
class OtherClass extends Component {
functionWithoutArg = () => {
//function to be called from default class (without args)
Alert.alert('Function Called Without Argument ');
};
functionWithArg = (Value) => {
//function to called from default class (with args)
Alert.alert(Value);
};
saveRecord = async (correct, wrong, stime) => {
let obj = {
correct: correct,
wrong: wrong,
timer: stime,
date: date,
time: time,
};
if (await RNFS.exists(record)) {
console.log('BLAH EXISTS');
// write the file
RNFS.appendFile(
record,
'Correct : ' +
JSON.stringify(obj.correct) +
',' +
'Wrong : ' +
JSON.stringify(obj.wrong) +
',' +
'Timer : ' +
stime +
',' +
'Date : ' +
date +
',' +
'Time : ' +
time +
'\n',
'utf8',
)
.then((success) => {
console.log(JSON.stringify(obj));
})
.catch((err) => {
console.log(err.message);
});
} else {
console.log('BLAH DOES NOT EXIST');
RNFS.writeFile(
record,
'Correct : ' +
JSON.stringify(obj.correct) +
',' +
'Wrong : ' +
JSON.stringify(obj.wrong) +
',' +
'Timer : ' +
stime +
',' +
'Date : ' +
date +
',' +
'Time : ' +
time +
'\n',
'utf8',
)
.then((success) => {
console.log(JSON.stringify(obj));
})
.catch((err) => {
console.log(err.message);
});
}
};
}
export default OtherClass;
......@@ -11,23 +11,16 @@ import {
Image,
ScrollView,
Dimensions,
// TextInput,
} from 'react-native';
import Orientation from 'react-native-orientation';
import Notes from './data';
import * as RNFS from 'react-native-fs';
import Counter from 'react-native-counters';
import Feather from 'react-native-vector-icons/Feather';
import NumericInput from 'react-native-numeric-input';
var path = RNFS.DocumentDirectoryPath + '/settings.txt';
var path1 = RNFS.DocumentDirectoryPath + '/counter.txt';
const minusIcon = (isDisabled) => {
return <Feather name="minus" size={20} color={'black'} />;
};
const plusIcon = (isPlusDisabled) => {
return <Feather name="plus" size={20} color={'black'} />;
};
const config = {
deviceWidth: Dimensions.get('window').width,
......@@ -37,6 +30,12 @@ const note = [];
var counter = 0;
export default class Settings extends React.Component {
constructor(props) {
super(props);
this.state = {
value: 0,
};
}
toggleKeyword = (keyword) => {
let list = note;
let index = -1;
......@@ -134,19 +133,23 @@ export default class Settings extends React.Component {
marginRight: config.deviceWidth * 0.1, flexDirection: 'row',
flexWrap: 'wrap'}}>
<Text style={{fontSize: 15,marginRight:5}}>No. of Questions : </Text>
<Counter start={0}
buttonStyle={{
borderColor: '#333',
borderWidth: 2,
}}
countTextStyle={{
color: '#333',
}}
minusIcon={minusIcon}
plusIcon={plusIcon}
onChange={this.onChange.bind(this)}
/>
</View>
<NumericInput
value={this.state.value}
minValue={0}
maxValue={100}
onChange={this.onChange.bind(this)}
onLimitReached={(isMax,msg) => console.log(isMax,msg)}
totalWidth={150}
totalHeight={40}
iconSize={25}
step={1}
valueType="real"
rounded
textColor="black"
iconStyle={{ color: 'white' }}
rightButtonBackgroundColor="black"
leftButtonBackgroundColor="black"/>
</View>
<ScrollView style={{marginTop: '5%', marginBottom : '20%'}}>
<View
style={{
......@@ -165,7 +168,7 @@ export default class Settings extends React.Component {
: styles.buttonStyle
}
onPress={() => this.toggleKeyword(item.name)}
key={id}>
key={id} activeOpacity={1.0}>
<Image
source={item.image}
style={{
......@@ -211,7 +214,6 @@ const styles = StyleSheet.create({
flex: 1,
width: config.deviceWidth * 0.4,
alignItems: 'center',
backgroundColor: '#EEA1E1',
borderWidth: 1,
borderColor: 'black',
borderRadius: 10,
......
......@@ -6,6 +6,7 @@ export default StyleSheet.create({
height: '70%',
alignItems: 'center',
borderColor: 'black',
marginTop:5,
},
cc1: {
flexDirection: 'row',
......@@ -55,36 +56,39 @@ export default StyleSheet.create({
marginTop: config.deviceWidth * 0.1,
},
correct: {
width: 65,
width: 100,
textAlign: 'center',
paddingTop: 15,
color: 'black',
height: 70,
height: 60,
borderRadius: 10,
alignItems: 'center',
fontSize: 15,
fontSize: 25,
marginRight: 10,
backgroundColor:'green',
},
wrong: {
width: 65,
height: 70,
width: 100,
height: 60,
borderRadius: 10,
alignItems: 'center',
textAlign: 'center',
paddingTop: 15,
color: 'black',
fontSize: 15,
fontSize: 25,
marginRight: 10,
backgroundColor:'red',
},
timer: {
width: 65,
height: 70,
height: 60,
borderRadius: 10,
alignItems: 'center',
textAlign: 'center',
paddingTop: 16,
color: 'black',
fontSize: 15,
color: 'white',
fontSize: 25,
backgroundColor:'black',
},
submit: {
width: '40%',
......
......@@ -2426,11 +2426,6 @@ dayjs@^1.8.15:
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.9.6.tgz#6f0c77d76ac1ff63720dd1197e5cb87b67943d70"
integrity sha512-HngNLtPEBWRo8EFVmHFmSXAjtCX8rGNqeXQI0Gh7wCTSqwaKgPIDqu9m07wABVopNwzvOeCb+2711vQhDlcIXw==
debounce@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.0.tgz#44a540abc0ea9943018dc0eaa95cce87f65cd131"
integrity sha512-mYtLl1xfZLi1m4RtQYlZgJUNQjl4ZxVnHzIR8nLLgi4q1YT8o/WM+MK/f8yfcc9s5Ir5zRaPZyZU6xs1Syoocg==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
......@@ -5847,7 +5842,7 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"
prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
......@@ -5949,13 +5944,6 @@ react-native-fs@^2.16.6:
base-64 "^0.1.0"
utf8 "^3.0.0"
react-native-full-screen@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/react-native-full-screen/-/react-native-full-screen-0.0.3.tgz#00c954f44577527afededfa2a42f6817b5d12891"
integrity sha512-t30Es2jgRR/FPZuXirWRnyhkRYuaZ+WC6SQNj57DYhEJ1tIwLfVRiqdoPxJcpVLFicOmeXHius86CJ2uuDJT8w==
dependencies:
debounce "^1.0.0"
react-native-gesture-handler@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.9.0.tgz#e441b1c0277c3fd4ca3e5c58fdd681e2f0ceddf0"
......@@ -5979,11 +5967,24 @@ react-native-iphone-x-helper@^1.3.0:
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010"
integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg==
react-native-numeric-input@^1.8.3:
version "1.8.3"
resolved "https://registry.yarnpkg.com/react-native-numeric-input/-/react-native-numeric-input-1.8.3.tgz#e869aa1b60d0c38b92e84e44bb28944f48b4ccd3"
integrity sha512-8MeAgbM4+doAkwjPg7iEA604z4d7krJz9r0755YThldCdIvwWZh5VbtRDHxbkMVQ2Ix5xRujFSn7uQWMtln8RA==
dependencies:
prop-types "^15.6.1"
react-native-pixel-perfect "^1.0.1"
react-native-orientation@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/react-native-orientation/-/react-native-orientation-3.1.3.tgz#d45803841fe94b6cce9acbe904fd5ca191a3711e"
integrity sha512-A0h0E+2f95X4avmhaBG1ZT8WDxBACA/q//JN2eF1E7kq8AJVxt5XDiavv+aSBkBlqFsfF3bIS+T/DB5mXmnxuA==
react-native-pixel-perfect@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-native-pixel-perfect/-/react-native-pixel-perfect-1.0.2.tgz#8e6dc97e377caa4bd07f9e584ba438d53c0e25e8"
integrity sha512-0IvYCNkxuQbQC9q4tI+C3i6o38nbx916p7gBRBWuPxDhKBCuTkVV3VukcfW6vtjRlwQm6kwQcF9OtI+yUBt+YA==
react-native-ratings@^7.3.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/react-native-ratings/-/react-native-ratings-7.3.0.tgz#32e11e4ed944ba8adbbc995d601df3f131619b6f"
......@@ -6019,6 +6020,13 @@ react-native-status-bar-height@^2.5.0:
resolved "https://registry.yarnpkg.com/react-native-status-bar-height/-/react-native-status-bar-height-2.6.0.tgz#b6afd25b6e3d533c43d0fcdcfd5cafd775592cea"
integrity sha512-z3SGLF0mHT+OlJDq7B7h/jXPjWcdBT3V14Le5L2PjntjjWM3+EJzq2BcXDwV+v67KFNJic5pgA26cCmseYek6w==
react-native-stopwatch-timer@^0.0.21:
version "0.0.21"
resolved "https://registry.yarnpkg.com/react-native-stopwatch-timer/-/react-native-stopwatch-timer-0.0.21.tgz#52c39f603e36c538bed3466212b1bfb350ed452f"
integrity sha512-qFFsD85NkBT1nxo32HMGq3XAtQyMC09p9ZDIEuOED2BOxgs0UpWg/FSTA0MmEoIKMyXUwSE5VxEzBaGP3z1HFw==
dependencies:
prop-types "^15.7.2"
react-native-super-grid@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/react-native-super-grid/-/react-native-super-grid-4.0.3.tgz#67ce71c241eb572a4ca92c4b667a053f3ec6a874"
......
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