forked from mgl_crew/Mitgliederladen
141 lines
4.9 KiB
Dart
141 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'expand.dart';
|
|
|
|
/*
|
|
todo:
|
|
- Design, Farbschema, 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;
|
|
bool elevated = true;
|
|
Transaction(this.art, this.betrag, this.datum, this.beschreibung);
|
|
}
|
|
|
|
class Finance extends StatefulWidget {
|
|
const Finance({super.key});
|
|
|
|
@override
|
|
State<Finance> createState() => _Finance();
|
|
}
|
|
|
|
class _Finance extends State<Finance> {
|
|
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')
|
|
];
|
|
|
|
@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,
|
|
//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),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
body: ListView.builder(
|
|
itemCount: null,
|
|
itemBuilder: (context, index) {
|
|
if (index < transactions.length) {
|
|
return Card(
|
|
clipBehavior: Clip.hardEdge,
|
|
child: InkWell(
|
|
splashColor: Colors.blue.withAlpha(30),
|
|
onTap: () {
|
|
transactions[index].elevated =
|
|
!transactions[index].elevated;
|
|
setState(() {});
|
|
debugPrint('Card tapped');
|
|
},
|
|
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: [
|
|
Row(
|
|
children: [
|
|
Text(DateFormat(
|
|
"EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
|
|
.format(now)),
|
|
Text(
|
|
'${transactions[index].art}: ${transactions[index].betrag / 100}€'),
|
|
],
|
|
),
|
|
Expand(
|
|
expand: transactions[index].elevated,
|
|
child: Text(transactions[index].beschreibung))
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
));
|
|
}
|
|
}
|