-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
75 lines (70 loc) · 1.85 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View, Linking } from "react-native";
import PianoKeyboard from "./PianoKeyboard";
import { MidiProvider } from "./MidiProvider";
import { useState } from "react";
export default function App() {
const [keyPressed, setKeyPressed] = useState<string[]>([]);
const onPressKey = (note: string) => {
console.log("Key pressed:", note);
setKeyPressed((prev) => [...prev, note]);
};
const onLink1 = () => {
Linking.openURL("https://www.onlinepianist.com/virtual-piano");
};
const onLink2 = () => {
Linking.openURL("https://tonejs.github.io/");
};
return (
<MidiProvider>
<View style={styles.container}>
<Text style={styles.title}>React Native Piano KeyBoard</Text>
<Text style={styles.piano}>🎹</Text>
<Text style={styles.description}>
Get inspired from{" "}
<Text style={styles.link} onPress={onLink1}>
ONLINE PIANIST
</Text>
</Text>
<Text style={styles.description}>
Sounds by{" "}
<Text style={styles.link} onPress={onLink2}>
Tone.js
</Text>
</Text>
<View style={{ flex: 1 }} />
<Text style={styles.keylog}>Key pressed: {keyPressed.join(", ")}</Text>
<PianoKeyboard onPressKey={onPressKey} />
<StatusBar style="auto" />
</View>
</MidiProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
title: {
fontSize: 40,
textAlign: "center",
marginTop: 80,
},
piano: {
fontSize: 80,
textAlign: "center",
},
description: {
fontSize: 18,
textAlign: "center",
marginTop: 10,
},
link: {
color: "blue",
textDecorationLine: "underline",
},
keylog: {
paddingHorizontal: 20,
marginBottom: 4,
},
});