-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
151 lines (140 loc) Β· 5.16 KB
/
App.tsx
File metadata and controls
151 lines (140 loc) Β· 5.16 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React, { useState, useEffect } from 'react';
import { Modal, Platform, StyleSheet } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { MainScreen } from './src/screens/MainScreen';
import { SampleEditScreen } from './src/screens/SampleEditScreen';
import { ChopScreen } from './src/screens/ChopScreen';
import { ExportScreen } from './src/screens/ExportScreen';
import { SynthModal } from './src/components/synth/SynthModal';
import { GrainSynthScreen } from './src/screens/GrainSynthScreen';
import { KeyboardScreen } from './src/screens/KeyboardScreen';
import { SampleBankModal } from './src/components/SampleBankModal';
import { colors } from './src/theme/colors';
import { useAppStore } from './src/state/useAppStore';
// Inject global CSS on web to eliminate Safari tap delay and improve touch responsiveness
if (Platform.OS === 'web' && typeof document !== 'undefined') {
const style = document.createElement('style');
style.textContent = `
* { touch-action: manipulation; }
input, textarea { touch-action: auto; }
`;
document.head.appendChild(style);
}
export default function App() {
const [editingChannel, setEditingChannel] = useState<number | null>(null);
const [synthChannel, setSynthChannel] = useState<number | null>(null);
const [showChop, setShowChop] = useState(false);
const [showExport, setShowExport] = useState(false);
const [grainSynthChannel, setGrainSynthChannel] = useState<number | null>(null);
const [keyboardChannel, setKeyboardChannel] = useState<number | null>(null);
const [bankChannel, setBankChannel] = useState<number | null>(null);
const loadSample = useAppStore((s) => s.loadSample);
return (
<GestureHandlerRootView style={styles.root}>
<SafeAreaProvider>
<MainScreen
onEditSample={(channelId) => setEditingChannel(channelId)}
onOpenSynth={(channelId) => setSynthChannel(channelId)}
onChopSong={() => setShowChop(true)}
onOpenGrainSynth={(channelId) => setGrainSynthChannel(channelId)}
onOpenKeyboard={(channelId) => setKeyboardChannel(channelId)}
onOpenBank={(channelId) => setBankChannel(channelId)}
onExport={() => setShowExport(true)}
/>
<Modal
visible={editingChannel !== null}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setEditingChannel(null)}
>
{editingChannel !== null && (
<SampleEditScreen
channelId={editingChannel}
onClose={() => setEditingChannel(null)}
/>
)}
</Modal>
<Modal
visible={synthChannel !== null}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setSynthChannel(null)}
>
{synthChannel !== null && (
<SynthModal
channelId={synthChannel}
onClose={() => setSynthChannel(null)}
/>
)}
</Modal>
<Modal
visible={grainSynthChannel !== null}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setGrainSynthChannel(null)}
>
{grainSynthChannel !== null && (
<GrainSynthScreen
channelId={grainSynthChannel}
onClose={() => setGrainSynthChannel(null)}
/>
)}
</Modal>
<Modal
visible={keyboardChannel !== null}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setKeyboardChannel(null)}
>
{keyboardChannel !== null && (
<KeyboardScreen
channelId={keyboardChannel}
onClose={() => setKeyboardChannel(null)}
/>
)}
</Modal>
<SampleBankModal
visible={bankChannel !== null}
onClose={() => setBankChannel(null)}
onSelect={(sample) => {
if (bankChannel !== null) {
// Give a fresh ID so the channel player re-loads the audio buffer
loadSample(bankChannel, {
...sample,
id: `bank_${Date.now()}`,
});
}
}}
/>
<Modal
visible={showChop}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setShowChop(false)}
>
<ChopScreen onClose={() => setShowChop(false)} />
</Modal>
<Modal
visible={showExport}
animationType="slide"
presentationStyle="pageSheet"
onRequestClose={() => setShowExport(false)}
>
<ExportScreen onClose={() => setShowExport(false)} />
</Modal>
</SafeAreaProvider>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
root: {
flex: 1,
backgroundColor: colors.forest,
...(Platform.OS === 'web' ? {
userSelect: 'none' as any,
// Eliminate Safari's 300ms tap delay on all touch targets
touchAction: 'manipulation' as any,
} : {}),
},
});