diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 894127e..ff85f5e 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,21 +1,47 @@ -import {StyleSheet, ScrollView, SafeAreaView, View, StatusBar} from 'react-native'; -// @ts-ignore +import React, {useEffect, useState} from 'react'; +import {StyleSheet, ScrollView, SafeAreaView, View, StatusBar, TouchableOpacity, Image} from 'react-native'; import CalendarPicker from 'react-native-calendar-picker'; +import Ionicons from '@expo/vector-icons/Ionicons'; import {ThemedText} from '@/components/ThemedText'; import {ThemedView} from '@/components/ThemedView'; import {Colors} from '@/constants/Colors'; import {useColorScheme} from '@/hooks/useColorScheme'; -import React, {useEffect} from 'react'; -import Ionicons from '@expo/vector-icons/Ionicons'; import {useToken} from '@/context/AppProvider'; +import {Request} from '@/services/request'; +import List from '@/components/List'; export default function HomeScreen() { const colorScheme = useColorScheme() ?? 'light'; const {token, isLoading} = useToken(); + const [name, setName] = useState(' '); // Default empty space to prevent layout shifting + const [dates, setDates] = useState([]); + const [types, setTypes] = useState([]); useEffect(() => { - console.log('token found', token); + if (token) { + Request.post('calendar', {token: token}).then((response) => { + if (response.success) { + // Set name + setName(response.name); + + // Set dates + let calendarDates: any[] = []; + response.dates.forEach((date: any) => { + calendarDates.push({ + date: new Date(date.date), + style: {backgroundColor: date.color}, + textStyle: {color: Colors.white}, + allowDisabled: true, + }) + }) + setDates(calendarDates); + + // Set types + setTypes(response.types); + } + }) + } }, [token]); return ( @@ -23,22 +49,24 @@ export default function HomeScreen() { - { getGreeting() }, + {getGreeting()}, - Maarten + {name} + } nextComponent={ - + } weekdays={["Zo", "Ma", "Di", "Woe", "Do", "Vrij", "Zat"]} months={[ @@ -59,22 +87,17 @@ export default function HomeScreen() { - - - GFT+e - - - - Papier - - - - PMD - - - - Restafval - + Legenda: + ( + + + { type.name } + + )} + /> @@ -112,11 +135,14 @@ const styles = StyleSheet.create({ marginTop: 15, }, legendaContainer: { - marginTop: 25, + marginTop: 40, + }, + legendaList: { + marginTop: 15, flex: 1, - flexDirection: 'row', + flexDirection: 'column', alignContent: 'center', - gap: 10, + gap: 15, }, legendaItem: { flex: 1, @@ -130,4 +156,13 @@ const styles = StyleSheet.create({ height: 25, borderRadius: 50, }, + today: { + borderWidth: 3, + borderColor: Colors.dark.grey, + borderRadius: 25, + textAlign: 'center', + paddingTop: 8, + width: 40, + height: 40, + }, }); diff --git a/components/List.tsx b/components/List.tsx index 3d9845c..7d37ec2 100644 --- a/components/List.tsx +++ b/components/List.tsx @@ -1,12 +1,14 @@ -import {StyleSheet, View} from 'react-native'; import React from 'react'; +import {ViewStyle} from 'react-native'; +import {ThemedView} from '@/components/ThemedView'; interface ListProps { data: any; renderItem: Function; + viewStyle?: ViewStyle; } -const CustomList: React.FC = ({ data, renderItem }) => { +const CustomList: React.FC = ({ data, renderItem, viewStyle }) => { const renderList = () => { let list: any[] = []; @@ -20,9 +22,9 @@ const CustomList: React.FC = ({ data, renderItem }) => { }; return ( - + {renderList()} - + ); }; diff --git a/constants/Colors.ts b/constants/Colors.ts index 7fdfab1..c0c10f6 100644 --- a/constants/Colors.ts +++ b/constants/Colors.ts @@ -7,6 +7,10 @@ const tintColorLight = '#76af2a'; const tintColorDark = '#76af2a'; export const Colors = { + // Base + black: '#000', + white: '#fff', + light: { // Main text: '#11181C', diff --git a/expo-env.d.ts b/expo-env.d.ts index 5411fdd..0920e9f 100644 --- a/expo-env.d.ts +++ b/expo-env.d.ts @@ -1,3 +1,3 @@ -/// +declare module 'react-native-calendar-picker'; // NOTE: This file should not be edited and should be in your git ignore \ No newline at end of file