This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
109 lines (88 loc) · 2.43 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
import React, { useState } from 'react';
import { StyleSheet, Text, View, Image, Button, SafeAreaView, ScrollView } from 'react-native';
import MyHeader from './components/Header'
import Journal from './pages/Journal'
import BankAccount from './pages/BankAccount'
import AddForm from './pages/AddForm'
import Login from './pages/Login'
import ListeCourses from './pages/ListeCourses'
import TutorialImage from './pages/TutorialImage';
export default function App() {
const [dataJournal, setDataJournal] = useState([])
const [page, setPage] = useState('Journal');
const [loggedIn, setLoggedIn] = useState(true);
function navigate(page){
setPage(page)
}
function login(){
setLoggedIn(true);
}
function logout(){
setLoggedIn(false);
}
/*
Add to state ([dataJournal])
*/
function addToJournal(title, desc){
setDataJournal([
...dataJournal, {
title: title,
description: desc,
done: false
}
])
navigate('Journal');
}
if(!loggedIn){
return (
<Login login={login}/>
)
}
return (
<SafeAreaView style={styles.container}>
<MyHeader title={page}/>
{ page === 'Journal' &&
<Journal data={dataJournal} navigate={navigate}/> }
{ page === 'BankAccount' && <BankAccount />}
{ page === 'AddForm' && <AddForm handleAdd={addToJournal}/>}
{ page === 'Tutorial' && <TutorialImage/>}
{ page === 'Courses' && <ListeCourses/>}
<View style={styles.topMenu}>
<Button
title="Bank"
color={page === "BankAccount" ? "green" : 'grey'}
onPress={() => navigate('BankAccount')}
/>
<Button
title="Bank"
color={page === "Courses" ? "green" : 'grey'}
onPress={() => navigate('Courses')}
/>
<Button
title="Journal"
color={page === "Journal" ? 'green' : 'grey'}
onPress={() => navigate('Journal')}
/>
<Button
title="Image"
color={page === "Tutorial" ? 'green' : 'grey'}
onPress={() => navigate('Tutorial')}
/>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
topMenu: {
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-around'
},
container: {
width: '100%',
flex: 1,
alignItems: 'flex-start',
justifyContent: 'flex-start',
},
});