Mitgliederladen/Frontend-user/lib/finance.dart

135 lines
4.8 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:
2023-06-19 11:21:54 +02:00
- Design, Darkmode
2023-06-16 15:36:13 +02:00
- Einkauf und Settings
- Details zum Warenkorb und Beschreibung (https://stackoverflow.com/questions/49029841/how-to-animate-collapse-elements-in-flutter)
2023-06-12 23:06:20 +02:00
- 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);
}
2023-06-19 12:12:18 +02:00
//sample data
2023-06-19 16:25:10 +02:00
class Finance extends StatelessWidget {
2023-06-12 23:06:20 +02:00
final List<Transaction> transactions = [
Transaction(Art.monatlBeitrag, 0, now, ''),
Transaction(Art.aufladung, 2042, now, ''),
Transaction(Art.einkauf, -2442, now.subtract(const Duration(days: 2)), ''),
2023-06-16 15:36:13 +02:00
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)), ''),
2023-06-19 12:12:18 +02:00
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)), ''),
2023-06-12 23:06:20 +02:00
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
'Korrektur des Warenkorbs')
];
2023-06-19 16:25:10 +02:00
Finance({super.key});
2023-06-12 23:06:20 +02:00
@override
Widget build(BuildContext context) {
initializeDateFormatting('de_DE');
2023-06-16 15:36:13 +02:00
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),
)
],
)
],
),
2023-06-12 23:06:20 +02:00
),
2023-06-16 15:36:13 +02:00
)),
body: ListView.builder(
itemCount: null,
itemBuilder: (context, index) {
if (index < transactions.length) {
return Card(
clipBehavior: Clip.hardEdge,
child: InkWell(
2023-06-19 16:27:07 +02:00
splashColor: const Color(0xff5f7c61).withAlpha(50),
2023-06-16 15:36:13 +02:00
onTap: () {
2023-06-19 16:25:10 +02:00
showBottomSheet(
context: context,
builder: (BuildContext context) {
return SizedBox.expand(
child: Text(transactions[index].beschreibung));
});
2023-06-16 15:36:13 +02:00
},
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: [
2023-06-19 16:25:10 +02:00
Text(
DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
2023-06-16 15:36:13 +02:00
.format(now)),
2023-06-19 16:25:10 +02:00
Text(
'${transactions[index].art}: ${transactions[index].betrag / 100}')
2023-06-16 15:36:13 +02:00
],
),
],
),
2023-06-12 23:06:20 +02:00
),
2023-06-16 15:36:13 +02:00
),
);
} else {
return null;
}
},
));
2023-06-12 23:06:20 +02:00
}
}