-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp_full.js
More file actions
67 lines (63 loc) · 1.61 KB
/
App_full.js
File metadata and controls
67 lines (63 loc) · 1.61 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
import React, { useState } from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button, SafeAreaView, TextInput } from 'react-native';
import SongList from './components/SongList';
import AddSongForm from './components/AddSongForm';
import { sync } from './model/sync';
export default function App() {
const [searchQuery, setSearchQuery] = useState('');
const handleSync = async () => {
try {
await sync();
alert('Sync finished!');
} catch (error) {
alert('Sync failed: ' + error.message);
}
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.header}>
<Text style={styles.title}>Magic Mic</Text>
<Button title="Sync" onPress={handleSync} />
</View>
<View style={styles.searchContainer}>
<TextInput
style={styles.searchInput}
placeholder="Search songs..."
value={searchQuery}
onChangeText={setSearchQuery}
/>
</View>
<AddSongForm />
<SongList searchQuery={searchQuery} />
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
header: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
padding: 20,
borderBottomWidth: 1,
borderBottomColor: '#eee',
},
title: {
fontSize: 24,
fontWeight: 'bold',
},
searchContainer: {
padding: 10,
backgroundColor: '#eee',
},
searchInput: {
backgroundColor: '#fff',
padding: 10,
borderRadius: 5,
},
});