-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
80 lines (67 loc) · 2.08 KB
/
Copy pathApp.js
File metadata and controls
80 lines (67 loc) · 2.08 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
68
69
70
71
72
73
74
75
76
77
78
79
80
import { StatusBar } from 'expo-status-bar';
import React, {useState, Component} from 'react';
import { StyleSheet, View, Text, Alert } from 'react-native';
import Blurbs from './components/Blurbs'
import Journaling from './screens/Journaling'
import Entries from './screens/Entries'
import promptsJSON from './prompts.json'
export default function App() {
/*mode is used to control which screen we see
mode 0 = blurbs
mode 1 = journal
mode 2 = entries
TODO: change to enum or so
*/
const [mode, setMode] = useState(0)
const [userText, setUserText] = useState('')
const [amountOfJournalEntries, setAmountOfJournalEntries] = useState(0)
const [currentJournal, setCurrentJournal] = useState(0)
let prompt = "prompts" + currentJournal.toString()
//When we hit the last blurb we throw this and increment mode to go to journal
const blurbViewHandler = (blurbViewOver) => {
if(blurbViewOver){
setMode(1)
}
}
//when the "all done" button is hit at the bottom of the journal move to entry
const journalEntryHandler = (journalEntered) => {
if(journalEntered){
setMode(2)
}
}
//wrap entry screen back to blurb[0]. Temporary
const goBackHomeHandler = (backHome) => {
if(backHome){
setMode(0)
setCurrentJournal(currentJournal + 1)
}
}
const addJournalText = (journalText) => {
setUserText(journalText)
promptsJSON.[prompt][1] = journalText
setAmountOfJournalEntries(amountOfJournalEntries + 1)
}
//switch content based on mode
let content
switch(mode){
case 0:
content = <Blurbs blurbViewOver = {blurbViewHandler}/>
break;
case 1:
content = <Journaling journalEntered = {journalEntryHandler} journalText = {addJournalText} currentJournal = {currentJournal} />
break;
case 2:
content = <Entries backHome = {goBackHomeHandler} text = {userText} numEntries = {amountOfJournalEntries}/>
break;
default:
Alert.alert("great, you broke it.")
}
return (
//print content
<View >
{content}
</View>
);
}
const styles = StyleSheet.create({
});