Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pianoApp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
norhalimah
pianoApp
Commits
f4f3a657
Commit
f4f3a657
authored
Mar 11, 2021
by
norhalimah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating
parent
57822ae6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
25 deletions
+31
-25
round.png
media/img/round.png
+0
-0
metronome.js
screens/metronome.js
+31
-25
No files found.
media/img/round.png
deleted
100644 → 0
View file @
57822ae6
57.3 KB
screens/metronome.js
View file @
f4f3a657
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable react-native/no-inline-styles */
/* eslint-disable prettier/prettier */
/* eslint-disable prettier/prettier */
/* eslint-disable prettier/prettier */
/* eslint-disable prettier/prettier */
import
React
,
{
useState
}
from
'react'
;
import
React
from
'react'
;
import
{
import
{
ImageBackground
,
ImageBackground
,
Text
,
Text
,
...
@@ -165,6 +165,7 @@ class MetronomeSkill extends React.Component {
...
@@ -165,6 +165,7 @@ class MetronomeSkill extends React.Component {
isEnabled
:
true
,
isEnabled
:
true
,
showPendulum
:
true
,
showPendulum
:
true
,
barTempoH
:
config
.
deviceHeight
*
0.09
,
barTempoH
:
config
.
deviceHeight
*
0.09
,
// num : 0,
};
};
}
}
...
@@ -448,12 +449,14 @@ class MetronomeSkill extends React.Component {
...
@@ -448,12 +449,14 @@ class MetronomeSkill extends React.Component {
clearInterval
(
this
.
timer
);
clearInterval
(
this
.
timer
);
this
.
setState
({
this
.
setState
({
playing
:
false
,
playing
:
false
,
// num:0,
});
});
barTempo
.
map
((
item
,
id
)
=>
{
barTempo
.
map
((
item
,
id
)
=>
{
item
.
active
=
true
;
item
.
active
=
true
;
});
});
}
else
{
}
else
{
this
.
animate
();
this
.
animate
();
// console.log('count stop:', this.state.count);
this
.
timer
=
setInterval
(
this
.
timer
=
setInterval
(
this
.
playClick
,
this
.
playClick
,
(
60
/
this
.
state
.
tempo
)
*
1000
(
60
/
this
.
state
.
tempo
)
*
1000
...
@@ -462,6 +465,7 @@ class MetronomeSkill extends React.Component {
...
@@ -462,6 +465,7 @@ class MetronomeSkill extends React.Component {
{
{
count
:
0
,
count
:
0
,
playing
:
true
,
playing
:
true
,
// num:0,
},
},
this
.
playClick
this
.
playClick
);
);
...
@@ -469,8 +473,6 @@ class MetronomeSkill extends React.Component {
...
@@ -469,8 +473,6 @@ class MetronomeSkill extends React.Component {
}
}
playClick
=
async
()
=>
{
playClick
=
async
()
=>
{
let
i
=
0
;
let
index
=
-
1
;
// const { count} = this.state;
// const { count} = this.state;
var
play1
=
new
Sound
(
this
.
state
.
soundName
,
(
error
)
=>
{
var
play1
=
new
Sound
(
this
.
state
.
soundName
,
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -488,17 +490,24 @@ class MetronomeSkill extends React.Component {
...
@@ -488,17 +490,24 @@ class MetronomeSkill extends React.Component {
});
});
});
});
this
.
setState
(
state
=>
({
this
.
setState
({
count
:
(
state
.
count
+
1
)
%
this
.
state
.
beat
,
count
:
(
this
.
state
.
count
)
%
this
.
state
.
beat
,
}));
});
// console.log('count before:', this.state.count);
barTempo
.
map
((
item
,
id
)
=>
{
barTempo
.
map
((
item
,
id
)
=>
{
if
(
id
===
i
)
{
item
.
active
=
false
;
console
.
log
(
id
);}
if
(
id
===
this
.
state
.
count
)
{
item
.
active
=
false
;
// console.log('count:', this.state.count);
// console.log(id);
}
else
{
item
.
active
=
true
;}
else
{
item
.
active
=
true
;}
});
});
// this.setState({num : this.state.num + 1});
//console.log('count after:', this.state.count);
this
.
setState
({
count
:
this
.
state
.
count
+
1
,
});
}
}
keepTap
=
async
()
=>
{
keepTap
=
async
()
=>
{
...
@@ -631,7 +640,7 @@ getRotationAnimation = () => {
...
@@ -631,7 +640,7 @@ getRotationAnimation = () => {
this
.
setState
({
tempoName
:
'Allegro'
});
this
.
setState
({
tempoName
:
'Allegro'
});
if
(
barTempo
.
length
<
7
)
{
if
(
barTempo
.
length
<
7
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
7
;
j
++
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
7
;
j
++
)
{
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]});
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]
,
active
:
true
});
}
}
this
.
setState
({
beat
:
barTempo
.
length
});
this
.
setState
({
beat
:
barTempo
.
length
});
}
}
...
@@ -653,7 +662,7 @@ getRotationAnimation = () => {
...
@@ -653,7 +662,7 @@ getRotationAnimation = () => {
let
index
=
-
1
;
let
index
=
-
1
;
if
(
barTempo
.
length
<
4
)
{
if
(
barTempo
.
length
<
4
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
4
;
j
++
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
4
;
j
++
)
{
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]});
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]
,
active
:
true
});
}
}
this
.
setState
({
beat
:
barTempo
.
length
});
this
.
setState
({
beat
:
barTempo
.
length
});
}
}
...
@@ -676,7 +685,7 @@ getRotationAnimation = () => {
...
@@ -676,7 +685,7 @@ getRotationAnimation = () => {
let
index
=
-
1
;
let
index
=
-
1
;
if
(
barTempo
.
length
<
8
)
{
if
(
barTempo
.
length
<
8
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
8
;
j
++
)
{
for
(
var
j
=
barTempo
.
length
;
j
<
8
;
j
++
)
{
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]});
barTempo
.
push
({
name
:
this
.
state
.
beat
+
1
,
note
:[{
id
:
1
},
{
id
:
2
},{
id
:
3
}]
,
active
:
true
});
}
}
this
.
setState
({
beat
:
barTempo
.
length
});
this
.
setState
({
beat
:
barTempo
.
length
});
}
}
...
@@ -709,15 +718,12 @@ getRotationAnimation = () => {
...
@@ -709,15 +718,12 @@ getRotationAnimation = () => {
return
(
return
(
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
5
,
marginLeft
:
13
,
marginRight
:
15
,
justifyContent
:
'space-between'
}}
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
5
,
marginLeft
:
13
,
marginRight
:
15
,
justifyContent
:
'space-between'
}}
>
<
TouchableOpacity
style
=
{{
backgroundColor
:
'grey'
,
width
:
'100%'
,
height
:
'180%'
}}
><
Text
/><
/TouchableOpacity
>
<
TouchableOpacity
style
=
{{
backgroundColor
:
'grey'
,
width
:
'100%'
,
height
:
'180%'
}}
><
Text
/><
/TouchableOpacity
>
<
TouchableOpacity
style
=
{{
height
:
'180%'
,
width
:
10
,
position
:
'absolute'
}}
>
<
Animated
.
Image
<
Animated
.
View
style
=
{{
style
=
{{
marginLeft
:
this
.
state
.
showImg
?
0
:
movingMargin
,
marginLeft
:
this
.
state
.
showImg
?
0
:
movingMargin
,
height
:
'100%'
,
height
:
'180%'
,
width
:
'250%'
,
width
:
'8%'
,
backgroundColor
:
'black'
}}
/
>
backgroundColor
:
'black'
,
position
:
'absolute'
}}
/
>
<
/TouchableOpacity
>
<
/View
>
<
/View
>
);
);
}
}
...
@@ -728,10 +734,10 @@ getRotationAnimation = () => {
...
@@ -728,10 +734,10 @@ getRotationAnimation = () => {
render
()
{
render
()
{
var
imgSource
=
this
.
state
.
showImg
?
playIcon
:
stopIcon
;
var
imgSource
=
this
.
state
.
showImg
?
playIcon
:
stopIcon
;
const
movingMargin
=
this
.
animatedValue
.
interpolate
({
/*
const movingMargin = this.animatedValue.interpolate({
inputRange: [0, 0.5, 1],
inputRange: [0, 0.5, 1],
outputRange: [0, 300, 1],
outputRange: [0, 300, 1],
});
});
*/
return
(
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
View
style
=
{{
flex
:
1
}}
>
...
@@ -954,9 +960,9 @@ getRotationAnimation = () => {
...
@@ -954,9 +960,9 @@ getRotationAnimation = () => {
}}
}}
{...
this
.
_panResponder
.
panHandlers
}
{...
this
.
_panResponder
.
panHandlers
}
/
>
/
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
30
,
right
:
config
.
deviceWidth
*
0.5
}}
onPress
=
{
this
.
leftDown
}
><
Image
style
=
{{
height
:
252
,
width
:
115
}}
source
=
{
leftIcon
}
/></
TouchableOpacity
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
40
,
right
:
config
.
deviceWidth
*
0.5
}}
onPress
=
{
this
.
leftDown
}
><
Image
style
=
{{
height
:
242
,
width
:
110
}}
source
=
{
leftIcon
}
/></
TouchableOpacity
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
30
,
left
:
config
.
deviceWidth
*
0.5
}}
onPress
=
{
this
.
rightUp
}
><
Image
style
=
{{
height
:
250
,
width
:
115
}}
source
=
{
rightIcon
}
/></
TouchableOpacity
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
40
,
left
:
config
.
deviceWidth
*
0.5
}}
onPress
=
{
this
.
rightUp
}
><
Image
style
=
{{
height
:
240
,
width
:
110
}}
source
=
{
rightIcon
}
/></
TouchableOpacity
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
7
5
}}
onPress
=
{()
=>
this
.
stopPlay
()}
><
Image
style
=
{{
height
:
150
,
width
:
150
}}
source
=
{
imgSource
}
/></
TouchableOpacity
>
<
TouchableOpacity
style
=
{{
position
:
'absolute'
,
top
:
8
5
}}
onPress
=
{()
=>
this
.
stopPlay
()}
><
Image
style
=
{{
height
:
150
,
width
:
150
}}
source
=
{
imgSource
}
/></
TouchableOpacity
>
<
/View
>
<
/View
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
config
.
deviceHeight
*
0.4
}}
>
<
View
style
=
{{
flexDirection
:
'row'
,
marginTop
:
config
.
deviceHeight
*
0.4
}}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment