-
Notifications
You must be signed in to change notification settings - Fork 0
/
Router.js
59 lines (54 loc) · 1.45 KB
/
Router.js
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
import { StatusBar } from "expo-status-bar";
import { useEffect, useState } from "react";
import songData from "./music-data.json";
import { NavigationContainer } from "@react-navigation/native";
import {
StyleSheet,
Switch,
Text,
View,
FlatList,
SafeAreaView,
} from "react-native";
import SongCart from "./src/components/SongCart";
import SearchBar from "./src/components/SearchBar";
export default function App() {
const [text, setText] = useState("");
const [list, setList] = useState(songData);
const seperatorItem = () => <Text style={styles.seperator} />;
const handleSearch = (text) => {
const filtered = songData.filter((song) => {
return song.title.toLowerCase().indexOf(text.toLowerCase()) > -1;
});
setList(filtered);
};
return (
<NavigationContainer>
<SafeAreaView style={styles.container}>
<SearchBar handleSearch={handleSearch} />
{list.length > 0 ? (
<FlatList
data={list}
renderItem={({ item }) => <SongCart item={item} />}
ItemSeparatorComponent={seperatorItem}
style={{ marginTop: 49 }}
/>
) : (
<Text>Albüm bulunamadı...</Text>
)}
</SafeAreaView>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
padding: 5,
},
seperator: {
borderWidth: 0.01,
backgroundColor: "#000",
opacity: 0.4,
},
});