Commit eff51a52 authored by norhalimah's avatar norhalimah

...

parent bd4f4110
...@@ -27,31 +27,31 @@ import Sound from 'react-native-sound'; ...@@ -27,31 +27,31 @@ import Sound from 'react-native-sound';
const path = RNFS.DocumentDirectoryPath + '/settings.txt'; const path = RNFS.DocumentDirectoryPath + '/settings.txt';
const path1 = RNFS.DocumentDirectoryPath + '/counter.txt'; const path1 = RNFS.DocumentDirectoryPath + '/counter.txt';
const NOTESWHITE = [ const NOTESWHITE = [
{name: 'C1', url: require('../sound/c1.mp3')}, {name: 'C1', url: require('../sound/c.mp3')},
{name: 'D1', url: require('../sound/d1.mp3')}, {name: 'D1', url: require('../sound/d.mp3')},
{name: 'E1', url: require('../sound/e1.mp3')}, {name: 'E1', url: require('../sound/e.mp3')},
{name: 'F1', url: require('../sound/f1.mp3')}, {name: 'F1', url: require('../sound/f.mp3')},
{name: 'G1', url: require('../sound/g1.mp3')}, {name: 'G1', url: require('../sound/g.mp3')},
{name: 'A1', url: require('../sound/a1.mp3')}, {name: 'A1', url: require('../sound/a.mp3')},
{name: 'B1', url: require('../sound/b1.mp3')}, {name: 'B1', url: require('../sound/b.mp3')},
{name: 'C2', url: require('../sound/c2.mp3')}, {name: 'C2', url: require('../sound/cc.mp3')},
{name: 'D2', url: require('../sound/d2.mp3')}, {name: 'D2', url: require('../sound/dd.mp3')},
{name: 'E2', url: require('../sound/e2.mp3')}, {name: 'E2', url: require('../sound/ee.mp3')},
{name: 'F2', url: require('../sound/f2.mp3')}, {name: 'F2', url: require('../sound/ff.mp3')},
{name: 'G2', url: require('../sound/g2.mp3')}, {name: 'G2', url: require('../sound/gg.mp3')},
{name: 'A2', url: require('../sound/a2.mp3')}, {name: 'A2', url: require('../sound/aa.mp3')},
{name: 'B2', url: require('../sound/b2.mp3')}, {name: 'B2', url: require('../sound/bb.mp3')},
]; ];
const NOTESCC = [{name: 'C#1', url: require('../sound/c_1.mp3')}]; const NOTESCC = [{name: 'C#1', url: require('../sound/c_c.mp3')}];
const NOTESDD = [{name: 'D#1', url: require('../sound/d_1.mp3')}]; const NOTESDD = [{name: 'D#1', url: require('../sound/d_d.mp3')}];
const NOTESFF = [{name: 'F#1', url: require('../sound/f_1.mp3')}]; const NOTESFF = [{name: 'F#1', url: require('../sound/f_f.mp3')}];
const NOTESGG = [{name: 'G#1', url: require('../sound/g_1.mp3')}]; const NOTESGG = [{name: 'G#1', url: require('../sound/g_g.mp3')}];
const NOTESAA = [{name: 'A#1', url: require('../sound/a_1.mp3')}]; const NOTESAA = [{name: 'A#1', url: require('../sound/a_a.mp3')}];
const NOTESCC1 = [{name: 'C#2', url: require('../sound/c_2.mp3')}]; const NOTESCC1 = [{name: 'C#2', url: require('../sound/c_cc.mp3')}];
const NOTESDD1 = [{name: 'D#2', url: require('../sound/d_2.mp3')}]; const NOTESDD1 = [{name: 'D#2', url: require('../sound/d_dd.mp3')}];
const NOTESFF1 = [{name: 'F#2', url: require('../sound/f_2.mp3')}]; const NOTESFF1 = [{name: 'F#2', url: require('../sound/f_ff.mp3')}];
const NOTESGG1 = [{name: 'G#2', url: require('../sound/g_2.mp3')}]; const NOTESGG1 = [{name: 'G#2', url: require('../sound/g_gg.mp3')}];
const NOTESAA1 = [{name: 'A#2', url: require('../sound/a_2.mp3')}]; const NOTESAA1 = [{name: 'A#2', url: require('../sound/a_aa.mp3')}];
const keywordsList = []; const keywordsList = [];
var maxCount = 5; var maxCount = 5;
...@@ -63,6 +63,7 @@ var stime = 0; ...@@ -63,6 +63,7 @@ var stime = 0;
class Quiz extends React.Component { class Quiz extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
Sound.setCategory('Playback'); // true = mixWithOthers
this.state = { this.state = {
logbook: [], logbook: [],
index:0, index:0,
......
...@@ -26,8 +26,37 @@ const config = { ...@@ -26,8 +26,37 @@ const config = {
deviceWidth: Dimensions.get('window').width, deviceWidth: Dimensions.get('window').width,
deviceHeight: Dimensions.get('window').height, deviceHeight: Dimensions.get('window').height,
}; };
const note = [];
var counter = 0; var counter = 0;
/* eslint-disable prettier/prettier */
const notes = [
'C Major',
'D Major','E Major',
'F Sharp Major',
'F Major',
'E Flat Major',
'D Flat Major',
'G Major',
'A Major',
'B Major',
'C Sharp Major',
'B Flat Major',
'A Flat Major',
'G Flat Major',
'Bass Clef C Major',
'Bass Clef D Major',
'Bass Clef E Major',
'Bass Clef F Sharp Major',
'Bass Clef F Major',
'Bass Clef E Flat Major',
'Bass Clef D Flat Major',
'Bass Clef G Major',
'Bass Clef A Major',
'Bass Clef B Major',
'Bass Clef C Sharp Major',
'Bass Clef B Flat Major',
'Bass Clef A Flat Major',
'Bass Clef G Flat Major',
];
export default class Settings extends React.Component { export default class Settings extends React.Component {
constructor(props) { constructor(props) {
...@@ -37,23 +66,24 @@ export default class Settings extends React.Component { ...@@ -37,23 +66,24 @@ export default class Settings extends React.Component {
}; };
} }
toggleKeyword = (keyword) => { toggleKeyword = (keyword) => {
let list = note; // console.log(notes.indexOf(keyword));
let list = notes;
let index = -1; let index = -1;
if ((index = note.indexOf(keyword)) !== -1) { if ((index = notes.indexOf(keyword)) !== -1) {
list.splice(index, 1); list.splice(index, 1);
} else { } else {
list.push(keyword); list.push(keyword);
} }
this.setState({note: list}); this.setState({notes: list});
this.saveData(note); this.saveData(notes);
this.displayData(); this.displayData();
console.log(counter); // console.log(notes);
}; };
saveData = async () => { saveData = async () => {
RNFS.writeFile(path,JSON.stringify(note),'utf8',) RNFS.writeFile(path,JSON.stringify(notes),'utf8',)
.then((success) => { .then((success) => {
console.log(JSON.stringify(note)); console.log(JSON.stringify(notes));
}) })
.catch((err) => { .catch((err) => {
console.log(err.message); console.log(err.message);
...@@ -73,7 +103,7 @@ export default class Settings extends React.Component { ...@@ -73,7 +103,7 @@ export default class Settings extends React.Component {
saveData1 = async () => { saveData1 = async () => {
RNFS.writeFile(path1,JSON.stringify(counter),'utf8',) RNFS.writeFile(path1,JSON.stringify(counter),'utf8',)
.then((success) => { .then((success) => {
//console.log(JSON.stringify(note)); //console.log(JSON.stringify(counter));
}) })
.catch((err) => { .catch((err) => {
console.log(err.message); console.log(err.message);
...@@ -91,10 +121,10 @@ export default class Settings extends React.Component { ...@@ -91,10 +121,10 @@ export default class Settings extends React.Component {
}; };
componentDidMount() { componentDidMount() {
note.splice(0, note.length); // notes.splice(0, notes.length);
console.log(note); // console.log(notes);
Orientation.lockToPortrait(); Orientation.lockToPortrait();
console.log(note.length); // console.log(notes.length);
counter = 0; counter = 0;
RNFS.unlink(path).then(res => { RNFS.unlink(path).then(res => {
console.log('delete'); console.log('delete');
...@@ -125,9 +155,6 @@ export default class Settings extends React.Component { ...@@ -125,9 +155,6 @@ export default class Settings extends React.Component {
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ImageBackground
source={require('../img/background.jpg')}
style={{width: config.deviceWidth, height: config.deviceHeight}}>
<SafeAreaView> <SafeAreaView>
<View style={{alignItems:'center',marginTop: '15%', marginLeft: config.deviceWidth * 0.08, <View style={{alignItems:'center',marginTop: '15%', marginLeft: config.deviceWidth * 0.08,
marginRight: config.deviceWidth * 0.1, flexDirection: 'row', marginRight: config.deviceWidth * 0.1, flexDirection: 'row',
...@@ -150,7 +177,7 @@ export default class Settings extends React.Component { ...@@ -150,7 +177,7 @@ export default class Settings extends React.Component {
rightButtonBackgroundColor="black" rightButtonBackgroundColor="black"
leftButtonBackgroundColor="black"/> leftButtonBackgroundColor="black"/>
</View> </View>
<ScrollView style={{marginTop: '5%', marginBottom : '20%'}}> <ScrollView style={{marginTop: '5%'}}>
<View <View
style={{ style={{
flexDirection: 'row', flexDirection: 'row',
...@@ -163,7 +190,7 @@ export default class Settings extends React.Component { ...@@ -163,7 +190,7 @@ export default class Settings extends React.Component {
<View key={id}> <View key={id}>
<TouchableOpacity <TouchableOpacity
style={ style={
note.find((element) => element === item.name) notes.find((element) => element === item.name)
? styles.selectedKeywordStyle ? styles.selectedKeywordStyle
: styles.buttonStyle : styles.buttonStyle
} }
...@@ -185,7 +212,6 @@ export default class Settings extends React.Component { ...@@ -185,7 +212,6 @@ export default class Settings extends React.Component {
</View> </View>
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
</ImageBackground>
</View> </View>
); );
} }
...@@ -205,7 +231,8 @@ const styles = StyleSheet.create({ ...@@ -205,7 +231,8 @@ const styles = StyleSheet.create({
borderWidth: 1, borderWidth: 1,
borderColor: 'black', borderColor: 'black',
borderRadius: 10, borderRadius: 10,
backgroundColor: 'white', backgroundColor: 'rgba(0,0,0,0)',
//opacity: 0.5,
padding: 10, padding: 10,
marginRight: config.deviceWidth * 0.03, marginRight: config.deviceWidth * 0.03,
marginBottom: config.deviceHeight * 0.03, marginBottom: config.deviceHeight * 0.03,
...@@ -216,7 +243,9 @@ const styles = StyleSheet.create({ ...@@ -216,7 +243,9 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
borderWidth: 1, borderWidth: 1,
borderColor: 'black', borderColor: 'black',
backgroundColor: 'lightpink', backgroundColor: 'white',
// backgroundColor: 'rgba(0,0,0,0)',
// opacity: 0.5,
borderRadius: 10, borderRadius: 10,
marginRight: config.deviceWidth * 0.03, marginRight: config.deviceWidth * 0.03,
marginBottom: config.deviceHeight * 0.03, marginBottom: config.deviceHeight * 0.03,
......
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
...@@ -318,7 +318,7 @@ export default StyleSheet.create({ ...@@ -318,7 +318,7 @@ export default StyleSheet.create({
}, },
selectedKeywordStyleSettings: { selectedKeywordStyleSettings: {
flex: 1, flex: 1,
backgroundColor: 'lightpink', backgroundColor: 'rgba(0,0,0,0)',
width: config.deviceHeight * 0.4, width: config.deviceHeight * 0.4,
alignItems: 'center', alignItems: 'center',
borderWidth: 1, borderWidth: 1,
......
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