125 lines
4.3 KiB
Dart
125 lines
4.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'basket.dart';
|
|
import 'sample_data.dart';
|
|
|
|
/*
|
|
todo:
|
|
- Einkauf und Settings
|
|
- Warenkorb
|
|
- Aufladungen?
|
|
- farbliche Hervorhebungen
|
|
- semanticLabels, Screenreader
|
|
- monatliche Aufladung: ausstehende Beträge
|
|
*/
|
|
|
|
class Finance extends StatelessWidget {
|
|
const Finance({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
initializeDateFormatting('de_DE');
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
toolbarHeight: 75,
|
|
title: const Card(
|
|
child: ListTile(
|
|
leading: Icon(
|
|
Icons.euro,
|
|
),
|
|
title: Text(
|
|
'Aktuelles Guthaben:',
|
|
),
|
|
subtitle: Text(
|
|
'-00,34€',
|
|
)),
|
|
),
|
|
),
|
|
body: ListView.builder(
|
|
itemCount: null,
|
|
itemBuilder: (context, index) {
|
|
if (index < SampleData().transactions.length) {
|
|
return Card(
|
|
child: ListTile(
|
|
leading: getIcon(SampleData().transactions[index].type),
|
|
title: Text(
|
|
gettitle(SampleData().transactions[index].type)),
|
|
subtitle: getSubtitle(index),
|
|
trailing: SampleData().transactions[index].type ==
|
|
TransaktionArt.einkauf
|
|
? PopupMenuButton(
|
|
onSelected: (value) {},
|
|
itemBuilder: (BuildContext context) =>
|
|
<PopupMenuEntry<String>>[
|
|
const PopupMenuItem<String>(
|
|
value: 'Option',
|
|
child: ListTile(
|
|
leading: Icon(Icons.manage_history),
|
|
title: Text('Warenkorb bearbeiten')),
|
|
),
|
|
const PopupMenuItem<String>(
|
|
value: 'Option',
|
|
child: ListTile(
|
|
leading:
|
|
Icon(Icons.remove_shopping_cart),
|
|
title: Text('Einkauf stornieren')),
|
|
),
|
|
],
|
|
)
|
|
: null,
|
|
onTap: () {
|
|
if (SampleData().transactions[index].type ==
|
|
TransaktionArt.einkauf) {
|
|
showBottomSheet(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return ShowBasket();
|
|
});
|
|
}
|
|
}));
|
|
} else {
|
|
return null;
|
|
}
|
|
}));
|
|
}
|
|
|
|
String gettitle(TransaktionArt art) {
|
|
switch (art) {
|
|
case TransaktionArt.aufladung:
|
|
return 'Aufladung';
|
|
case TransaktionArt.einkauf:
|
|
return 'Einkauf';
|
|
case TransaktionArt.korrektur:
|
|
return 'Korrektur';
|
|
case TransaktionArt.monatlBeitrag:
|
|
return 'monatlicher Beitrag';
|
|
}
|
|
}
|
|
|
|
Text getSubtitle(int index) {
|
|
String text = '${SampleData().transactions[index].amount / 100}';
|
|
text += '€ ';
|
|
text += DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
|
|
.format(SampleData().transactions[index].date);
|
|
if (SampleData().transactions[index].description != null) {
|
|
(text += '\n${SampleData().transactions[index].description}');
|
|
}
|
|
|
|
return Text(text);
|
|
}
|
|
|
|
Icon getIcon(TransaktionArt art) {
|
|
switch (art) {
|
|
case TransaktionArt.aufladung:
|
|
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);
|
|
}
|
|
}
|
|
}
|