-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.js
85 lines (81 loc) · 2.18 KB
/
Home.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
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
import React from "react";
import { StyleSheet, Text, View, FlatList } from "react-native";
import { DATA } from "./Data";
import { Ionicons } from "@expo/vector-icons";
import { createStackNavigator } from "@react-navigation/stack";
import { TouchableOpacity } from "react-native-gesture-handler";
export default function Home({ navigation }) {
//icon
//render function :
//icon :
const renderIcon = (isCompleted) => {
if (isCompleted) {
return (
<TouchableOpacity>
<Ionicons name="md-checkbox" size={30} color="green" />
</TouchableOpacity>
);
} else {
return (
<TouchableOpacity>
<Ionicons name="md-checkbox" size={30} color="#1E1E1E" />
</TouchableOpacity>
);
}
};
//items
const Item = ({ title, repetetion, backgroundColor, isCompleted }) => (
<TouchableOpacity
style={{
height: 85,
backgroundColor: "#fff",
marginTop: 20,
justifyContent: "center",
marginHorizontal: 20,
padding: 20,
borderRadius: 5,
backgroundColor: backgroundColor,
}}
onPress={() => navigation.push("Paragraph")}
>
<View style={{ flexDirection: "row", alignItems: "center" }}>
{renderIcon(isCompleted)}
<View style={{ flex: 1 }}>
<Text style={{ color: "#1E1E1E", fontSize: 18, fontWeight: "bold" }}>
{title}
</Text>
<Text style={{ color: "#1E1E1E", fontSize: 16, marginTop: 10 }}>
عدد التكرار {repetetion}
</Text>
</View>
</View>
</TouchableOpacity>
);
//
const renderItem = ({ item }) => (
<Item
title={item.title}
repetetion={item.repetetion}
backgroundColor={item.backgroundColor}
isCompleted={item.isCompleted}
/>
);
return (
<View style={styles.container}>
<FlatList
style={{ flex: 1, width: "100%" }}
data={DATA}
renderItem={renderItem}
keyExtractor={(item) => item.id}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#1F2328",
alignItems: "center",
justifyContent: "center",
},
});