Skip to content

Commit 70d057b

Browse files
committed
Simplifying the footer code
1 parent 9efca8c commit 70d057b

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

src/views/card/audiocard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import Sound from "react-native-sound";
99

1010
const playAudio = async (key) => {
1111

12-
console.log('Attempting to play', key);
12+
// console.log('Attempting to play', key);
1313

1414
const signedUrl = await Storage.get(key);
15-
console.log(signedUrl);
15+
// console.log(signedUrl);
1616

1717
const track = new Sound(signedUrl, null, (e) => {
1818
if (e) {
@@ -26,7 +26,7 @@ const playAudio = async (key) => {
2626
const removeTrack = async (englishKey, chineseKey) => {
2727
const result1 = await Storage.remove(englishKey);
2828
const result2 = await Storage.remove(chineseKey);
29-
console.log(result1, result2);
29+
// console.log(result1, result2);
3030
}
3131

3232
const AudioCard = (param) => {

src/views/footer.js

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const fontSize = 16;
1111

1212
const audioPlayer = new AudioPlayer();
1313

14+
const FooterButton = (param) => {
15+
return <TouchableOpacity onPress={param.onPress}>
16+
<Text style={{ fontSize }}>{param.children}</Text>
17+
</TouchableOpacity>
18+
}
19+
1420
/**
1521
* @param {Object} param
1622
* @property {[string,string][]} param.pathPairs
@@ -19,32 +25,20 @@ const audioPlayer = new AudioPlayer();
1925
*/
2026
const AudioFooter = (param) => {
2127

22-
// audioPlayer.load(param.audioPathPairs)
23-
2428
useEffect(() => {
2529
console.log('Reloading audioplayer')
26-
// console.log('attempting loading', param.pathPairs)
2730
audioPlayer.load(param.pathPairs)
28-
// audioPlayer.load([["210822144607_I am eating apple", "210822144607_我在吃苹果"]])
2931
}, [param.pathPairs])
3032

3133
return (
3234
<View style={[
3335
styles.footerCard,
3436
{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }
3537
]}>
36-
<TouchableOpacity onPress={() => {
37-
// playTestSound();
38-
// console.log('Play')
39-
40-
audioPlayer.playRandom()
41-
}}>
42-
<Text style={{ fontSize }}>Play</Text>
43-
</TouchableOpacity>
44-
<Text style={{ fontSize }}>Stop</Text>
45-
<TouchableOpacity onPress={param.backToMenu}>
46-
<Text style={{ fontSize }}>Back</Text>
47-
</TouchableOpacity>
38+
<FooterButton onPress={() => { audioPlayer.play() }}>Play</FooterButton>
39+
<FooterButton onPress={() => { audioPlayer.playRandom() }}>Random</FooterButton>
40+
<FooterButton onPress={audioPlayer.stop}>Stop</FooterButton>
41+
<FooterButton onPress={param.backToMenu}>Back</FooterButton>
4842
</View>
4943
)
5044
}
@@ -55,12 +49,8 @@ const CategoryFooter = (param) => {
5549
styles.footerCard,
5650
{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }
5751
]}>
58-
<TouchableOpacity onPress={param.openAddEntryMenu}>
59-
<Text style={{ fontSize }}>Add new entry</Text>
60-
</TouchableOpacity>
61-
<TouchableOpacity onPress={param.refreshCategories}>
62-
<Text style={{ fontSize }}>Refresh</Text>
63-
</TouchableOpacity>
52+
<FooterButton onPress={param.openAddEntryMenu}>Add new entry</FooterButton>
53+
<FooterButton onPress={param.refreshCategories}>Refresh</FooterButton>
6454
</View>
6555
)
6656
}
@@ -71,12 +61,8 @@ const OpenAddEntryFooter = (param) => {
7161
styles.footerCard,
7262
{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }
7363
]}>
74-
<TouchableOpacity onPress={param.closeAddEntryMenu}>
75-
<Text style={{ fontSize }}>Close</Text>
76-
</TouchableOpacity>
77-
<TouchableOpacity onPress={param.addNew}>
78-
<Text style={{ fontSize }}>Submit entry to AWS</Text>
79-
</TouchableOpacity>
64+
<FooterButton onPress={param.closeAddEntryMenu}>Close</FooterButton>
65+
<FooterButton onPress={param.addNew}>Submit entry to AWS</FooterButton>
8066
</View>
8167
)
8268
}
@@ -93,9 +79,6 @@ const OpenAddEntryFooter = (param) => {
9379
* @returns {React.ReactElement}
9480
*/
9581
const Footer = (param) => {
96-
// console.log('isSelectedView', param.isSelectedView, 'addEntryMenuOpen', param.entryMenuOpen)
97-
98-
// console.log('current param', param)
9982

10083
return (
10184
<View>

0 commit comments

Comments
 (0)