feat: toon positieve comments bij gelijk/gestegen gewicht (issue #17)
- 'Vetje naar beneden' als vetmassa gedaald is
- 💪 als spiermassa gestegen is
- Combineer beide op één regel indien van toepassing
- Alleen tonen bij diff >= 0 kg
This commit is contained in:
parent
aafa041840
commit
a1e8a7ed48
1 changed files with 14 additions and 0 deletions
|
|
@ -32,6 +32,16 @@ export default function LatestMeasurementCard({ measurements }: Props) {
|
||||||
const latest = measurements[0]
|
const latest = measurements[0]
|
||||||
const previous = measurements[1]
|
const previous = measurements[1]
|
||||||
const diff = previous ? (latest.weight - previous.weight) : null
|
const diff = previous ? (latest.weight - previous.weight) : null
|
||||||
|
const fatMassDiff = previous ? (latest.fatMass - previous.fatMass) : null
|
||||||
|
const muscleMassDiff = previous ? (latest.muscleMass - previous.muscleMass) : null
|
||||||
|
|
||||||
|
let positiveComment: string | null = null
|
||||||
|
if (previous && diff !== null && diff >= 0) {
|
||||||
|
const parts: string[] = []
|
||||||
|
if (fatMassDiff !== null && fatMassDiff < 0) parts.push('Vetje naar beneden')
|
||||||
|
if (muscleMassDiff !== null && muscleMassDiff > 0) parts.push('💪')
|
||||||
|
if (parts.length > 0) positiveComment = parts.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
const handleShare = async () => {
|
const handleShare = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -62,6 +72,9 @@ export default function LatestMeasurementCard({ measurements }: Props) {
|
||||||
<Text style={styles.diffLabel}>
|
<Text style={styles.diffLabel}>
|
||||||
Verschil {diff !== null && (diff > 0 ? '+' : '')}{diff?.toFixed(1)} kg
|
Verschil {diff !== null && (diff > 0 ? '+' : '')}{diff?.toFixed(1)} kg
|
||||||
</Text>
|
</Text>
|
||||||
|
{positiveComment && (
|
||||||
|
<Text style={styles.positiveComment}>{positiveComment}</Text>
|
||||||
|
)}
|
||||||
<View style={styles.divider} />
|
<View style={styles.divider} />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
@ -100,4 +113,5 @@ const styles = StyleSheet.create({
|
||||||
previousTitle: { fontSize: 18, fontWeight: '700', marginBottom: 4 },
|
previousTitle: { fontSize: 18, fontWeight: '700', marginBottom: 4 },
|
||||||
previousDate: { fontSize: 14, color: '#666', marginBottom: 4 },
|
previousDate: { fontSize: 14, color: '#666', marginBottom: 4 },
|
||||||
diffLabel: { fontSize: 16, fontWeight: '700', color: '#2196F3' },
|
diffLabel: { fontSize: 16, fontWeight: '700', color: '#2196F3' },
|
||||||
|
positiveComment: { fontSize: 14, color: '#4CAF50', marginTop: 4 },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue