main #1

Open
fdenzer wants to merge 46 commits from mgl_crew/Mitgliederladen:main into main
3 changed files with 62 additions and 10 deletions
Showing only changes of commit 0ee26fedb0 - Show all commits

View file

@ -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> 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: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
);
}
}

View file

@ -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);
}
}
}

View file

@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
brightness: Brightness.dark,
seedColor: const Color(0xff5f7c61),
)),
themeMode: ThemeMode.dark,
themeMode: ThemeMode.system,
home: const MyHomePage(),
);
}