From 4cb18aba415fdc3d3c21f06c3e060f672d5e3c2a Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Sat, 25 Oct 2025 00:15:13 +0200 Subject: [PATCH] Messwerte Scroller --- .../igel/presentation/igel_detail_screen.dart | 94 ++++++++++--------- 1 file changed, 50 insertions(+), 44 deletions(-) diff --git a/lib/features/igel/presentation/igel_detail_screen.dart b/lib/features/igel/presentation/igel_detail_screen.dart index 4e7b59d..4ae9e8a 100644 --- a/lib/features/igel/presentation/igel_detail_screen.dart +++ b/lib/features/igel/presentation/igel_detail_screen.dart @@ -914,12 +914,6 @@ class _IgelDetailState extends ConsumerState { ], icon: const Icon(Icons.ios_share), ), - if (canEdit) - IconButton( - onPressed: _pickAndUpload, - tooltip: 'Bilder hinzufügen', - icon: const Icon(Icons.add_a_photo), - ), ], ), body: Stack( @@ -1170,39 +1164,45 @@ class _IgelDetailState extends ConsumerState { child: Text('Keine Messwerte'), ) else - SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: DataTable( - columns: [ - const DataColumn( - label: Text('Datum/Uhrzeit')), - const DataColumn( - label: Text('Gewicht (g)')), - const DataColumn( - label: Text('Behandlung')), - const DataColumn( - label: Text('Bemerkung')), - if (canEdit) - const DataColumn( - label: Text('Aktionen')), - ], - rows: [ - for (final m in messwerte) - DataRow( - cells: [ - DataCell(Text( - _fmtDateTime(m.datum))), - DataCell( - Text('${m.gewicht}')), - DataCell(Text( - m.behandlung ?? '')), - DataCell(Text( - m.bemerkung ?? '')), - if (canEdit) - DataCell( - Row( - mainAxisSize: - MainAxisSize.min, + SizedBox( + // fixe Höhe für angenehmes Scrollen; gerne anpassen (z. B. 360–480) + height: 420, + child: Scrollbar( + thumbVisibility: true, + child: ListView.separated( + itemCount: messwerte.length, + separatorBuilder: (_, __) => + const Divider(height: 1), + itemBuilder: (_, i) { + final m = messwerte[i]; + return ListTile( + dense: true, + leading: const Icon( + Icons.timeline), + title: Text( + _fmtDateTime(m.datum)), + subtitle: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + 'Gewicht: ${m.gewicht} g'), + if ((m.behandlung ?? '') + .trim() + .isNotEmpty) + Text( + 'Behandlung: ${m.behandlung}'), + if ((m.bemerkung ?? '') + .trim() + .isNotEmpty) + Text( + 'Bemerkung: ${m.bemerkung}'), + ], + ), + trailing: canEdit + ? Wrap( + spacing: 4, children: [ IconButton( tooltip: @@ -1223,11 +1223,17 @@ class _IgelDetailState extends ConsumerState { m), ), ], - ), - ), - ], - ), - ], + ) + : null, + isThreeLine: true, + contentPadding: + const EdgeInsets + .symmetric( + horizontal: 12, + vertical: 6), + ); + }, + ), ), ), ],