diff --git a/Frontend-user/lib/basket.dart b/Frontend-user/lib/basket.dart index 1924d3c..0b48d0a 100644 --- a/Frontend-user/lib/basket.dart +++ b/Frontend-user/lib/basket.dart @@ -1,29 +1,51 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'sample_data.dart'; /* todo: - - Flag für Ansicht/Bearbeitung - individuelle Icons je nach Kategorie - Gesamtpreis */ class ShowBasket extends StatelessWidget { final Transaction transaction; + final bool editable; - const ShowBasket({super.key, required this.transaction}); + const ShowBasket( + {super.key, required this.transaction, this.editable = false}); @override Widget build(BuildContext context) { + return Column(children: [ + Card( + child: ListTile( + leading: const Icon( + Icons.euro, + ), + title: const Text( + 'Kosten:', + ), + subtitle: Text( + '${transaction.amount / 100}', + )), + ), + getBasket(transaction.basket!) + ]); + } + + ListView getBasket(List basket) { return ListView.builder( + shrinkWrap: true, itemCount: null, itemBuilder: (context, index) { - if (index < transaction.basket!.length) { + if (index < basket.length) { return Card( child: ListTile( - leading: const Icon(Icons.abc), - title: Text( - transaction.basket![index].products.name), //better null check - //trailing: Text(), + leading: getLeading(basket[index].products.category), + title: Text(basket[index].products.name), + subtitle: Text( + '${basket[index].amount} ${basket[index].products.unit}'), + trailing: editable == true ? getTrailing() : null, ), ); } else { @@ -32,4 +54,31 @@ class ShowBasket extends StatelessWidget { }, ); } + + Widget getLeading(Category category) { + switch (category) { + case Category.obstUndGemuese: + return const Text("🍅"); + case Category.brotCerealienUndAufstriche: + return const Text('🍞'); + case Category.drogerieUndHaushalt: + case Category.getraenke: + case Category.kochenUndBacken: + case Category.pfand: + case Category.suessesUndKnabbereien: + case Category.oeleSossenUndGewuerze: + default: + return const Icon(Icons.error); + } + } + + Widget getTrailing() { + return TextField( + decoration: const InputDecoration(labelText: "Enter your number"), + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], + ); + } } diff --git a/Frontend-user/lib/finance.dart b/Frontend-user/lib/finance.dart index 16e9d1f..d32f7a8 100644 --- a/Frontend-user/lib/finance.dart +++ b/Frontend-user/lib/finance.dart @@ -11,6 +11,7 @@ todo: - farbliche Hervorhebungen - semanticLabels, Screenreader - monatliche Aufladung: ausstehende Beträge + - Icons: maybe flutter awesome */ class Finance extends StatelessWidget { @@ -95,6 +96,8 @@ class Finance extends StatelessWidget { return 'Korrektur'; case TransaktionArt.monatlBeitrag: return 'monatlicher Beitrag'; + default: + return 'Ein Error ist aufgetreten'; } } @@ -116,10 +119,10 @@ class Finance extends StatelessWidget { return const Icon(Icons.savings); case TransaktionArt.einkauf: return const Icon(Icons.shopping_basket); - case TransaktionArt.korrektur: - return const Icon(Icons.priority_high); case TransaktionArt.monatlBeitrag: return const Icon(Icons.payment); + default: + return const Icon(Icons.priority_high); } } } diff --git a/Frontend-user/lib/main.dart b/Frontend-user/lib/main.dart index 80807a3..5c7fee8 100644 --- a/Frontend-user/lib/main.dart +++ b/Frontend-user/lib/main.dart @@ -27,7 +27,7 @@ class MyApp extends StatelessWidget { brightness: Brightness.dark, seedColor: const Color(0xff5f7c61), )), - themeMode: ThemeMode.dark, + themeMode: ThemeMode.system, home: const MyHomePage(), ); }