forked from mgl_crew/Mitgliederladen
main #1
3 changed files with 62 additions and 10 deletions
|
@ -1,29 +1,51 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'sample_data.dart';
|
import 'sample_data.dart';
|
||||||
|
|
||||||
/* todo:
|
/* todo:
|
||||||
- Flag für Ansicht/Bearbeitung
|
|
||||||
- individuelle Icons je nach Kategorie
|
- individuelle Icons je nach Kategorie
|
||||||
- Gesamtpreis
|
- Gesamtpreis
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ShowBasket extends StatelessWidget {
|
class ShowBasket extends StatelessWidget {
|
||||||
final Transaction transaction;
|
final Transaction transaction;
|
||||||
|
final bool editable;
|
||||||
|
|
||||||
const ShowBasket({super.key, required this.transaction});
|
const ShowBasket(
|
||||||
|
{super.key, required this.transaction, this.editable = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
itemCount: null,
|
itemCount: null,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index < transaction.basket!.length) {
|
if (index < basket.length) {
|
||||||
return Card(
|
return Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.abc),
|
leading: getLeading(basket[index].products.category),
|
||||||
title: Text(
|
title: Text(basket[index].products.name),
|
||||||
transaction.basket![index].products.name), //better null check
|
subtitle: Text(
|
||||||
//trailing: Text(),
|
'${basket[index].amount} ${basket[index].products.unit}'),
|
||||||
|
trailing: editable == true ? getTrailing() : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} 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
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ todo:
|
||||||
- farbliche Hervorhebungen
|
- farbliche Hervorhebungen
|
||||||
- semanticLabels, Screenreader
|
- semanticLabels, Screenreader
|
||||||
- monatliche Aufladung: ausstehende Beträge
|
- monatliche Aufladung: ausstehende Beträge
|
||||||
|
- Icons: maybe flutter awesome
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Finance extends StatelessWidget {
|
class Finance extends StatelessWidget {
|
||||||
|
@ -95,6 +96,8 @@ class Finance extends StatelessWidget {
|
||||||
return 'Korrektur';
|
return 'Korrektur';
|
||||||
case TransaktionArt.monatlBeitrag:
|
case TransaktionArt.monatlBeitrag:
|
||||||
return 'monatlicher Beitrag';
|
return 'monatlicher Beitrag';
|
||||||
|
default:
|
||||||
|
return 'Ein Error ist aufgetreten';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +119,10 @@ class Finance extends StatelessWidget {
|
||||||
return const Icon(Icons.savings);
|
return const Icon(Icons.savings);
|
||||||
case TransaktionArt.einkauf:
|
case TransaktionArt.einkauf:
|
||||||
return const Icon(Icons.shopping_basket);
|
return const Icon(Icons.shopping_basket);
|
||||||
case TransaktionArt.korrektur:
|
|
||||||
return const Icon(Icons.priority_high);
|
|
||||||
case TransaktionArt.monatlBeitrag:
|
case TransaktionArt.monatlBeitrag:
|
||||||
return const Icon(Icons.payment);
|
return const Icon(Icons.payment);
|
||||||
|
default:
|
||||||
|
return const Icon(Icons.priority_high);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
seedColor: const Color(0xff5f7c61),
|
seedColor: const Color(0xff5f7c61),
|
||||||
)),
|
)),
|
||||||
themeMode: ThemeMode.dark,
|
themeMode: ThemeMode.system,
|
||||||
home: const MyHomePage(),
|
home: const MyHomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue