Commit bd4f4110 authored by norhalimah's avatar norhalimah

updating....

parent a658579b
...@@ -13,10 +13,14 @@ import Orientation from 'react-native-orientation'; ...@@ -13,10 +13,14 @@ import Orientation from 'react-native-orientation';
const Stack = createStackNavigator(); const Stack = createStackNavigator();
class App extends React.Component { class App extends React.PureComponent {
componentDidMount() { componentDidMount() {
Orientation.lockToPortrait(); Orientation.lockToPortrait();
} }
componentDidUpdate(){
Orientation.lockToPortrait();
}
render() { render() {
return ( return (
<NavigationContainer> <NavigationContainer>
......
...@@ -4,6 +4,8 @@ import android.app.Application; ...@@ -4,6 +4,8 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import com.facebook.react.PackageList; import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.zmxv.RNSound.RNSoundPackage;
import com.zmxv.RNSound.RNSoundPackage;
import com.github.yamill.orientation.OrientationPackage; import com.github.yamill.orientation.OrientationPackage;
import com.github.yamill.orientation.OrientationPackage; import com.github.yamill.orientation.OrientationPackage;
import com.rnfs.RNFSPackage; import com.rnfs.RNFSPackage;
......
rootProject.name = 'PianoApp' rootProject.name = 'PianoApp'
include ':react-native-sound'
project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
include ':react-native-sound'
project(':react-native-sound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
include ':react-native-orientation' include ':react-native-orientation'
project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation/android') project(':react-native-orientation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation/android')
include ':react-native-fs' include ':react-native-fs'
......
...@@ -14,6 +14,8 @@ target 'PianoApp' do ...@@ -14,6 +14,8 @@ target 'PianoApp' do
pod 'react-native-orientation', :path => '../node_modules/react-native-orientation' pod 'react-native-orientation', :path => '../node_modules/react-native-orientation'
pod 'RNSound', :path => '../node_modules/react-native-sound'
target 'PianoAppTests' do target 'PianoAppTests' do
inherit! :complete inherit! :complete
# Pods for testing # Pods for testing
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
"react-native-reanimated": "^1.13.2", "react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.9", "react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.15.0", "react-native-screens": "^2.15.0",
"react-native-sound": "^0.11.0",
"react-native-stopwatch-timer": "^0.0.21", "react-native-stopwatch-timer": "^0.0.21",
"react-native-super-grid": "^4.0.3", "react-native-super-grid": "^4.0.3",
"react-native-vector-icons": "^7.1.0" "react-native-vector-icons": "^7.1.0"
......
...@@ -22,35 +22,36 @@ import * as RNFS from 'react-native-fs'; ...@@ -22,35 +22,36 @@ import * as RNFS from 'react-native-fs';
import Notes from './data'; import Notes from './data';
import styles from '../style/style'; import styles from '../style/style';
import OtherClass from './saveRecords'; import OtherClass from './saveRecords';
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 = [
'C1', {name: 'C1', url: require('../sound/c1.mp3')},
'D1', {name: 'D1', url: require('../sound/d1.mp3')},
'E1', {name: 'E1', url: require('../sound/e1.mp3')},
'F1', {name: 'F1', url: require('../sound/f1.mp3')},
'G1', {name: 'G1', url: require('../sound/g1.mp3')},
'A1', {name: 'A1', url: require('../sound/a1.mp3')},
'B1', {name: 'B1', url: require('../sound/b1.mp3')},
'C2', {name: 'C2', url: require('../sound/c2.mp3')},
'D2', {name: 'D2', url: require('../sound/d2.mp3')},
'E2', {name: 'E2', url: require('../sound/e2.mp3')},
'F2', {name: 'F2', url: require('../sound/f2.mp3')},
'G2', {name: 'G2', url: require('../sound/g2.mp3')},
'A2', {name: 'A2', url: require('../sound/a2.mp3')},
'B2', {name: 'B2', url: require('../sound/b2.mp3')},
]; ];
const NOTESCC = ['C#1']; const NOTESCC = [{name: 'C#1', url: require('../sound/c_1.mp3')}];
const NOTESDD = ['D#1']; const NOTESDD = [{name: 'D#1', url: require('../sound/d_1.mp3')}];
const NOTESFF = ['F#1']; const NOTESFF = [{name: 'F#1', url: require('../sound/f_1.mp3')}];
const NOTESGG = ['G#1']; const NOTESGG = [{name: 'G#1', url: require('../sound/g_1.mp3')}];
const NOTESAA = ['A#1']; const NOTESAA = [{name: 'A#1', url: require('../sound/a_1.mp3')}];
const NOTESCC1 = ['C#2']; const NOTESCC1 = [{name: 'C#2', url: require('../sound/c_2.mp3')}];
const NOTESDD1 = ['D#2']; const NOTESDD1 = [{name: 'D#2', url: require('../sound/d_2.mp3')}];
const NOTESFF1 = ['F#2']; const NOTESFF1 = [{name: 'F#2', url: require('../sound/f_2.mp3')}];
const NOTESGG1 = ['G#2']; const NOTESGG1 = [{name: 'G#2', url: require('../sound/g_2.mp3')}];
const NOTESAA1 = ['A#2']; const NOTESAA1 = [{name: 'A#2', url: require('../sound/a_2.mp3')}];
const keywordsList = []; const keywordsList = [];
var maxCount = 5; var maxCount = 5;
...@@ -78,13 +79,29 @@ class Quiz extends React.Component { ...@@ -78,13 +79,29 @@ class Quiz extends React.Component {
} }
toggleKeyword = (keyword) => { toggleKeyword = (keyword) => {
var sound = new Sound(keyword.url, (error) => {
if (error) {
console.log('failed to load the sound', error);
return;
}
// loaded successfully
sound.play((success) => {
if (success) {
console.log('successfully finished playing');
} else {
console.log('playback failed due to audio decoding errors');
sound.release();
}
});
});
let list = keywordsList; let list = keywordsList;
let index = -1; let index = -1;
if ((index = keywordsList.indexOf(keyword)) !== -1) { if ((index = keywordsList.indexOf(keyword.name)) !== -1) {
list.splice(index, 1); list.splice(index, 1);
console.log(list); console.log(list);
} else { } else {
list.push(keyword); list.push(keyword.name);
console.log(list); console.log(list);
} }
this.setState({keywordsList: list}); this.setState({keywordsList: list});
...@@ -602,7 +619,7 @@ class Quiz extends React.Component { ...@@ -602,7 +619,7 @@ class Quiz extends React.Component {
}; };
async componentDidMount() { async componentDidMount() {
this.removeArray(); //this.removeArray();
Orientation.lockToLandscape(); Orientation.lockToLandscape();
this.displayData(); this.displayData();
} }
...@@ -674,10 +691,13 @@ class Quiz extends React.Component { ...@@ -674,10 +691,13 @@ class Quiz extends React.Component {
}; };
//reset //reset
removeArray = () => { removeArray = () => {
keywordsList.splice(0, keywordsList.length); keywordsList.splice(0, keywordsList.length);
console.log(keywordsList); console.log(keywordsList);
clearInterval(this._interval); this.setState({
correct: this.state.correct,
wrong: this.state.wrong,
});
}; };
render() { render() {
...@@ -844,7 +864,7 @@ class Quiz extends React.Component { ...@@ -844,7 +864,7 @@ class Quiz extends React.Component {
{NOTESWHITE.map((item, id) => ( {NOTESWHITE.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? selectedKeywordStyle ? selectedKeywordStyle
: buttonStyle : buttonStyle
} }
...@@ -856,7 +876,7 @@ class Quiz extends React.Component { ...@@ -856,7 +876,7 @@ class Quiz extends React.Component {
{NOTESCC.map((item, id) => ( {NOTESCC.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB1 ? SbuttonB1
: buttonB1 : buttonB1
} }
...@@ -868,7 +888,7 @@ class Quiz extends React.Component { ...@@ -868,7 +888,7 @@ class Quiz extends React.Component {
{NOTESDD.map((item, id) => ( {NOTESDD.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB2 ? SbuttonB2
: buttonB2 : buttonB2
} }
...@@ -880,7 +900,7 @@ class Quiz extends React.Component { ...@@ -880,7 +900,7 @@ class Quiz extends React.Component {
{NOTESFF.map((item, id) => ( {NOTESFF.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB3 ? SbuttonB3
: buttonB3 : buttonB3
} }
...@@ -892,7 +912,7 @@ class Quiz extends React.Component { ...@@ -892,7 +912,7 @@ class Quiz extends React.Component {
{NOTESGG.map((item, id) => ( {NOTESGG.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB4 ? SbuttonB4
: buttonB4 : buttonB4
} }
...@@ -904,7 +924,7 @@ class Quiz extends React.Component { ...@@ -904,7 +924,7 @@ class Quiz extends React.Component {
{NOTESAA.map((item, id) => ( {NOTESAA.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB5 ? SbuttonB5
: buttonB5 : buttonB5
} }
...@@ -916,7 +936,7 @@ class Quiz extends React.Component { ...@@ -916,7 +936,7 @@ class Quiz extends React.Component {
{NOTESCC1.map((item, id) => ( {NOTESCC1.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB11 ? SbuttonB11
: buttonB11 : buttonB11
} }
...@@ -928,7 +948,7 @@ class Quiz extends React.Component { ...@@ -928,7 +948,7 @@ class Quiz extends React.Component {
{NOTESDD1.map((item, id) => ( {NOTESDD1.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB21 ? SbuttonB21
: buttonB21 : buttonB21
} }
...@@ -940,7 +960,7 @@ class Quiz extends React.Component { ...@@ -940,7 +960,7 @@ class Quiz extends React.Component {
{NOTESFF1.map((item, id) => ( {NOTESFF1.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB31 ? SbuttonB31
: buttonB31 : buttonB31
} }
...@@ -952,7 +972,7 @@ class Quiz extends React.Component { ...@@ -952,7 +972,7 @@ class Quiz extends React.Component {
{NOTESGG1.map((item, id) => ( {NOTESGG1.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB41 ? SbuttonB41
: buttonB41 : buttonB41
} }
...@@ -964,7 +984,7 @@ class Quiz extends React.Component { ...@@ -964,7 +984,7 @@ class Quiz extends React.Component {
{NOTESAA1.map((item, id) => ( {NOTESAA1.map((item, id) => (
<TouchableHighlight <TouchableHighlight
style={ style={
keywordsList.find((element) => element === item) keywordsList.find((element) => element === item.name)
? SbuttonB51 ? SbuttonB51
: buttonB51 : buttonB51
} }
......
...@@ -117,7 +117,7 @@ export default class Settings extends React.Component { ...@@ -117,7 +117,7 @@ export default class Settings extends React.Component {
counter = number; counter = number;
if (counter > 0) { if (counter > 0) {
this.saveData1(counter); this.saveData1(counter);
//console.log(counter); console.log(number);
this.displayData1(); this.displayData1();
} }
} }
...@@ -216,9 +216,10 @@ const styles = StyleSheet.create({ ...@@ -216,9 +216,10 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
borderWidth: 1, borderWidth: 1,
borderColor: 'black', borderColor: 'black',
backgroundColor: 'lightpink',
borderRadius: 10, borderRadius: 10,
marginRight: config.deviceWidth * 0.03, marginRight: config.deviceWidth * 0.03,
marginBottom: config.deviceHeight * 0.03, marginBottom: config.deviceHeight * 0.03,
padding: 10, padding: 10,
}, },
}); });
\ No newline at end of file
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
...@@ -304,4 +304,48 @@ export default StyleSheet.create({ ...@@ -304,4 +304,48 @@ export default StyleSheet.create({
marginBottom: '5%', marginBottom: '5%',
borderRadius: 30, borderRadius: 30,
}, },
buttonStyleSettings: {
flex: 1,
width: config.deviceHeight * 0.4,
alignItems: 'center',
borderWidth: 1,
borderColor: 'black',
borderRadius: 10,
backgroundColor: 'white',
padding: 10,
marginRight: config.deviceHeight * 0.03,
marginBottom: config.deviceWidth * 0.03,
},
selectedKeywordStyleSettings: {
flex: 1,
backgroundColor: 'lightpink',
width: config.deviceHeight * 0.4,
alignItems: 'center',
borderWidth: 1,
borderColor: 'black',
borderRadius: 10,
marginRight: config.deviceHeight * 0.03,
marginBottom: config.deviceWidth * 0.03,
padding: 10,
},
containerSettings: {
alignItems: 'center',
justifyContent: 'center',
width: '100%',
height: '100%',
},
viewSettings: {
flexDirection: 'row',
flexWrap: 'wrap',
width: config.deviceHeight,
marginLeft: config.deviceWidth * 0.05,
marginRight: config.deviceWidth * 0.08,
},
viewInputSettings: {
alignItems:'center',
marginTop: '15%',
marginLeft: config.deviceHeight * 0.08,
marginRight: config.deviceHeight * 0.1,
flexDirection: 'row',
flexWrap: 'wrap'},
}); });
...@@ -6015,6 +6015,11 @@ react-native-size-matters@^0.3.1: ...@@ -6015,6 +6015,11 @@ react-native-size-matters@^0.3.1:
resolved "https://registry.yarnpkg.com/react-native-size-matters/-/react-native-size-matters-0.3.1.tgz#24d0cfc335a2c730f6d58bd7b43ea5a41be4b49f" resolved "https://registry.yarnpkg.com/react-native-size-matters/-/react-native-size-matters-0.3.1.tgz#24d0cfc335a2c730f6d58bd7b43ea5a41be4b49f"
integrity sha512-mKOfBLIBFBcs9br1rlZDvxD5+mAl8Gfr5CounwJtxI6Z82rGrMO+Kgl9EIg3RMVf3G855a85YVqHJL2f5EDRlw== integrity sha512-mKOfBLIBFBcs9br1rlZDvxD5+mAl8Gfr5CounwJtxI6Z82rGrMO+Kgl9EIg3RMVf3G855a85YVqHJL2f5EDRlw==
react-native-sound@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/react-native-sound/-/react-native-sound-0.11.0.tgz#ad60b55ba8c6dc89917f381ad3713f2738de530f"
integrity sha512-4bGAZfni6E2L695NQjOZwNLBQGXgBGYC4Sy+h99K5h0HqNZjCqR0+aLel+ezASxEJDpaH83gylNObXpiqJgdwg==
react-native-status-bar-height@^2.5.0: react-native-status-bar-height@^2.5.0:
version "2.6.0" version "2.6.0"
resolved "https://registry.yarnpkg.com/react-native-status-bar-height/-/react-native-status-bar-height-2.6.0.tgz#b6afd25b6e3d533c43d0fcdcfd5cafd775592cea" resolved "https://registry.yarnpkg.com/react-native-status-bar-height/-/react-native-status-bar-height-2.6.0.tgz#b6afd25b6e3d533c43d0fcdcfd5cafd775592cea"
......
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