-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
177 lines (154 loc) · 4.55 KB
/
App.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import { StatusBar } from 'expo-status-bar';
import { useState, useEffect } from "react";
import { StyleSheet, Text, ScrollView, View, TouchableHighlight, ActivityIndicator } from 'react-native';
import AddButton from './components/AddButton';
import MovieModal from './components/MovieModal';
import Fire from './Fire';
import { Card, Title, Paragraph } from 'react-native-paper';
import moment from 'moment';
import 'moment/locale/fr';
import CommentsModal from './components/CommentsModal';
export default function App() {
const myDate = moment().format('llll');
const [isModalVisible, setIsModalVisible] = useState(false);
const [movies, setMovies] = useState([]);
const [loading, setLoading] = useState(true);
const [updateMovie, setUpdateMovie] = useState(null);
const [comment, setComment] = useState(null);
useEffect(() => {
const firebase = new Fire();
firebase.getMovies(movies => {
setMovies(movies);
setLoading(false);
})
}, [])
function removeMovie(movie) {
const firebase = new Fire();
firebase.deleteMovie(movie)
}
return (
<View style={styles.container}>
<Text style={[styles.red]}> Bienvenue sur my <Text style={{ color: "#1E90FF" }}>Movies</Text>
</Text>
{loading && (<ActivityIndicator size={"large"} />)}
<StatusBar style="auto" />
{/* Affichage des films à l'écran principal */}
<Text style={[styles.Time]}>
Nous sommes le {myDate}
</Text>
<ScrollView>
{movies.map(movie => (
<View style={[styles.card]} key={movie.id}>
<Card style={[styles.card]}>
<Card.Content>
<Title style={[styles.MovieTitle]}>{movie.title}</Title>
<Paragraph style={[styles.filmDesc]}>{movie.synopsis}</Paragraph>
</Card.Content>
<Card.Cover resizeMode="contain" source={{ uri: movie.url }} style={[styles.Photo]} />
<Card.Actions style={[styles.condition]}>
<View style={[styles.Btn]}>
<TouchableHighlight onPress={() => removeMovie(movie)} styles={styles.btn1}>
<Text style={[styles.textTouch]}> Supprimer</Text>
</TouchableHighlight>
</View>
<View style={[styles.Btn]}>
<TouchableHighlight onPress={() => { setUpdateMovie(movie); setIsModalVisible(true) }} styles={styles.Btn}>
<Text style={[styles.textTouch]}> Modifier</Text>
</TouchableHighlight>
</View>
<View style={styles.Btn}>
<TouchableHighlight >
<Text style={[styles.textTouch]}> Commenter</Text>
</TouchableHighlight>
</View>
</Card.Actions>
</Card>
</View>
))}
{isModalVisible && (<MovieModal isVisible={isModalVisible} handleClose={() => { setIsModalVisible(false) }} movie={updateMovie}> </MovieModal>
)}
</ScrollView>
<View style={styles.fixed}>
<AddButton content="+" handlePress={() => { setIsModalVisible(true); setUpdateMovie(null) }}></AddButton>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
marginVertical: 55,
marginHorizontal: 5,
flex: 1,
backgroundColor: '#fff',
},
fixed: {
position: "absolute",
bottom: 20,
right: 12,
},
Time: {
fontSize: 10,
marginHorizontal: 10,
},
red: {
color: 'black',
fontWeight: 'bold',
fontSize: 28,
textAlign: 'center',
},
filmDesc: {
textAlign: 'justify',
color: 'black',
},
MovieTitle: {
fontWeight: 'bold',
textAlign: 'justify',
color: 'black',
},
Btn: {
padding: 0.5,
backgroundColor: "dodgerblue",
borderRadius: 8,
borderWidth: 0.5,
borderColor: '#fff',
},
comma: {
alignItems: 'center',
paddingVertical: 10,
},
comment: {
padding: 0.5,
backgroundColor: "dodgerblue",
borderRadius: 8,
borderWidth: 0.5,
borderColor: '#fff',
},
textTouch: {
textAlign: 'center',
color: "white",
fontSize: 20,
padding: 5,
},
com:{
flex: 1,
backgroundColor: "dodgerblue",
color: "white",
textAlign: "center",
alignItems: "center",
height: 20,
width: 600,
},
card: {
borderRadius: 1,
borderWidth: 0.5,
margin: 5,
borderWidth: 1,
borderColor: '#071e22n',
},
condition: {
margin: 5,
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center',
},
});