Mitgliederladen/Frontend-user/lib/finance.dart

104 lines
3 KiB
Dart
Raw Normal View History

2023-06-12 23:06:20 +02:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
/*
todo:
- Design
- Details zum Warenkorb und Beschreibung (Popup?)
- farbliche Hervorhebungen
*/
enum Art { monatlBeitrag, aufladung, einkauf, korrektur }
final now = DateTime.now();
class Transaction {
int betrag;
Art art;
DateTime datum;
String beschreibung;
Transaction(this.art, this.betrag, this.datum, this.beschreibung);
}
class Finance extends StatelessWidget {
Finance({super.key});
final List<Transaction> transactions = [
Transaction(Art.monatlBeitrag, 0, now, ''),
Transaction(Art.aufladung, 2042, now, ''),
Transaction(Art.einkauf, -2442, now.subtract(const Duration(days: 2)), ''),
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
'Korrektur des Warenkorbs')
];
@override
Widget build(BuildContext context) {
initializeDateFormatting('de_DE');
return ListView.builder(
itemCount: null,
itemBuilder: (context, index) {
if (index == 0) {
return const Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
Icons.euro,
//color: Colors.black,
//semanticLabel: 'Text for screenreader',
),
Column(
children: [
Text(
'Aktuelles Guthaben:',
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
'-00,34€',
style: TextStyle(fontWeight: FontWeight.bold),
)
],
)
],
),
),
);
} else if (index <= transactions.length) {
return Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(transactions[index - 1].art == Art.korrektur
? Icons.error
: Icons.money),
Column(
children: [
Row(
children: [
Text(DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
.format(now)),
Text(
'${transactions[index - 1].art}: ${transactions[index - 1].betrag / 100}'),
],
),
Text(transactions[index - 1].beschreibung)
],
),
],
),
),
);
} else {
return null;
}
},
);
}
}