Mitgliederladen/Frontend-user/lib/finance.dart
2023-06-19 16:27:07 +02:00

134 lines
4.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
/*
todo:
- Design, Darkmode
- Einkauf und Settings
- Details zum Warenkorb und Beschreibung (https://stackoverflow.com/questions/49029841/how-to-animate-collapse-elements-in-flutter)
- 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);
}
//sample data
class Finance extends StatelessWidget {
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'),
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'),
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'),
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'),
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')
];
Finance({super.key});
@override
Widget build(BuildContext context) {
initializeDateFormatting('de_DE');
return Scaffold(
appBar: AppBar(
toolbarHeight: 75,
title: const Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
Icons.euro,
//semanticLabel: 'Text for screenreader',
),
Column(
children: [
Text(
'Aktuelles Guthaben:',
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(
'-00,34€',
style: TextStyle(fontWeight: FontWeight.bold),
)
],
)
],
),
),
)),
body: ListView.builder(
itemCount: null,
itemBuilder: (context, index) {
if (index < transactions.length) {
return Card(
clipBehavior: Clip.hardEdge,
child: InkWell(
splashColor: const Color(0xff5f7c61).withAlpha(50),
onTap: () {
showBottomSheet(
context: context,
builder: (BuildContext context) {
return SizedBox.expand(
child: Text(transactions[index].beschreibung));
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(transactions[index].art == Art.korrektur
? Icons.error
: Icons.money),
Column(
children: [
Text(
DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
.format(now)),
Text(
'${transactions[index].art}: ${transactions[index].betrag / 100}')
],
),
],
),
),
),
);
} else {
return null;
}
},
));
}
}