-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
116 lines (102 loc) · 3.14 KB
/
main.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
import React, { useState, useEffect } from 'react';
import { SafeAreaView } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Dashboard from "./screens/Dashboard";
import FavoriteList from './screens/favoriteList';
import { randomQuote, randomPicture } from './ApiClientService';
export default function Main () {
// const [quote, setQuote] = useState({});
// const [nextQuote, setNextQuote] = useState({});
// const [picture, setPicture] = useState();
// const [nextPicture, setNextPicture] = useState();
// const [key, setKey] = useState('0');
// const [favorites, setFavorites] = useState([]);
// let isNext = false;
// const objToSave = {
// quote: quote.quote,
// author: quote.author,
// picture: picture,
// }
// const nextObjToSave = {
// quote: nextQuote.quote,
// author: nextQuote.author,
// picture: nextPicture,
// }
// const getSavedFavorites = async () => {
// try {
// const gottenKeys = await AsyncStorage.getAllKeys();
// const gottenFavorites = await AsyncStorage.multiGet(gottenKeys);
// const favsToGet = gottenFavorites.map(item => item)
// setFavorites(favsToGet);
// } catch (error) {
// console.error('Houston, we have a problem:', error);
// }
// }
// const storeData = async () => {
// try {
// const obj = isNext
// ? nextObjToSave
// : objToSave;
// const jsonObj = JSON.stringify(obj)
// await AsyncStorage.setItem(key, jsonObj)
// setKey((key) => (+key + 1).toString())
// setFavorites(getSavedFavorites())
// alert('saved it for you boo')
// } catch (error) {
// console.error('oh no something happened:', error);
// }
// }
// const removeFavorite = async (unlike) => {
// try {
// await AsyncStorage.removeItem(unlike)
// getSavedFavorites();
// alert("IT'S GONE MUTHAFUCKAAAAAAAAAAA");
// } catch (error) {
// console.error('no I dunnae think so', error);
// }
// }
// const getRandomQuote = () => {
// randomQuote()
// .then(res => {
// setQuote({
// quote: res.quote.quoteText,
// author: res.quote.quoteAuthor})
// });
// randomQuote()
// .then(res => {
// setNextQuote({
// quote: res.quote.quoteText,
// author: res.quote.quoteAuthor})
// });
// }
// const getRandomPicture = () => {
// randomPicture()
// .then(res => setPicture(res.url))
// randomPicture()
// .then(res => setNextPicture(res.url))
// }
// useEffect(() => {
// getRandomQuote();
// getRandomPicture();
// getSavedFavorites();
// }, [])
return (
<SafeAreaView>
{/* <Dashboard
getRandomPicture={getRandomPicture}
getRandomQuote={getRandomQuote}
nextQuote={nextQuote}
quote={quote}
picture={picture}
nextPicture={nextPicture}
isNext={isNext}
storeData={storeData}
navigation={navigation}
/> */}
{/* <FavoriteList
favorites={favorites}
removeFavorite={removeFavorite}
/> */}
</SafeAreaView>
)
}