import React, { useCallback, useState } from 'react' import { View, ScrollView, TouchableOpacity, Text, StyleSheet } from 'react-native' import { useFocusEffect } from '@react-navigation/native' import { useSafeAreaInsets } from 'react-native-safe-area-context' import { initDatabase, getAllMeasurements, getLatestMeasurement } from '../database/db' import { Measurement } from '../types' import LatestMeasurementCard from '../components/LatestMeasurementCard' import WeightChart from '../components/WeightChart' type Props = { navigation: any } export default function DashboardScreen({ navigation }: Props) { const insets = useSafeAreaInsets() const [latest, setLatest] = useState(null) const [all, setAll] = useState([]) useFocusEffect( useCallback(() => { const load = async () => { await initDatabase() const allM = await getAllMeasurements() setAll(allM) const latestM = await getLatestMeasurement() setLatest(latestM) } load() }, []) ) return ( navigation.navigate('History')}> Historie navigation.navigate('Settings')}> Instellingen navigation.navigate('NewMeasurement')} > + Nieuwe meting ) } const styles = StyleSheet.create({ outer: { flex: 1, backgroundColor: '#f5f5f5' }, container: { flex: 1 }, navBar: { flexDirection: 'row', justifyContent: 'space-around', padding: 12, backgroundColor: '#fff', borderBottomWidth: 1, borderBottomColor: '#eee' }, navLink: { fontSize: 16, color: '#2196F3', fontWeight: '600' }, fab: { backgroundColor: '#4CAF50', padding: 16, borderRadius: 8, margin: 16, alignItems: 'center' }, fabText: { color: '#fff', fontSize: 16, fontWeight: '700' }, })