ui: toon voorlaatste meting en gewichtsverschil in dashboard card

This commit is contained in:
eddy 2026-07-20 18:16:56 +02:00
commit 73d327f914
2 changed files with 31 additions and 11 deletions

View file

@ -2,7 +2,7 @@ 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 { initDatabase, getAllMeasurements } from '../database/db'
import { Measurement } from '../types'
import LatestMeasurementCard from '../components/LatestMeasurementCard'
import WeightChart from '../components/WeightChart'
@ -11,7 +11,6 @@ type Props = { navigation: any }
export default function DashboardScreen({ navigation }: Props) {
const insets = useSafeAreaInsets()
const [latest, setLatest] = useState<Measurement | null>(null)
const [all, setAll] = useState<Measurement[]>([])
const [loading, setLoading] = useState(true)
@ -23,7 +22,6 @@ export default function DashboardScreen({ navigation }: Props) {
const allM = await getAllMeasurements()
const visible = allM.filter(m => !m.deletedAt)
setAll(visible)
setLatest(visible.length > 0 ? visible[0] : null)
setLoading(false)
}
load()
@ -45,7 +43,7 @@ export default function DashboardScreen({ navigation }: Props) {
<Text style={styles.loading}>Laden...</Text>
) : (
<>
<LatestMeasurementCard measurement={latest} />
<LatestMeasurementCard measurements={all} />
<WeightChart measurements={all} />
</>
)}