forked from mgl_crew/Mitgliederladen
remake finance, included assets
This commit is contained in:
parent
5edef0200d
commit
5ad2ae0867
5 changed files with 166 additions and 69 deletions
BIN
Frontend-user/assets/logo_sonako_4c_optimal.png
Normal file
BIN
Frontend-user/assets/logo_sonako_4c_optimal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 713 KiB |
58
Frontend-user/lib/expand.dart
Normal file
58
Frontend-user/lib/expand.dart
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Expand extends StatefulWidget {
|
||||||
|
final Widget child;
|
||||||
|
final bool expand;
|
||||||
|
const Expand({super.key, this.expand = true, required this.child});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Expand> createState() => _ExpandState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExpandState extends State<Expand> with SingleTickerProviderStateMixin {
|
||||||
|
late AnimationController expandController;
|
||||||
|
late Animation<double> animation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
prepareAnimations();
|
||||||
|
_runExpandCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
///Setting up the animation
|
||||||
|
void prepareAnimations() {
|
||||||
|
expandController = AnimationController(
|
||||||
|
vsync: this, duration: const Duration(milliseconds: 500));
|
||||||
|
animation = CurvedAnimation(
|
||||||
|
parent: expandController,
|
||||||
|
curve: Curves.fastOutSlowIn,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _runExpandCheck() {
|
||||||
|
if (widget.expand) {
|
||||||
|
expandController.forward();
|
||||||
|
} else {
|
||||||
|
expandController.reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(Expand oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
_runExpandCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
expandController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizeTransition(
|
||||||
|
axisAlignment: 1.0, sizeFactor: animation, child: widget.child);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:intl/date_symbol_data_local.dart';
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
|
import 'expand.dart';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
todo:
|
todo:
|
||||||
- Design
|
- Design, Farbschema, Darkmode
|
||||||
- Details zum Warenkorb und Beschreibung (Popup?)
|
- Einkauf und Settings
|
||||||
|
- Details zum Warenkorb und Beschreibung (https://stackoverflow.com/questions/49029841/how-to-animate-collapse-elements-in-flutter)
|
||||||
- farbliche Hervorhebungen
|
- farbliche Hervorhebungen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -18,16 +20,37 @@ class Transaction {
|
||||||
Art art;
|
Art art;
|
||||||
DateTime datum;
|
DateTime datum;
|
||||||
String beschreibung;
|
String beschreibung;
|
||||||
|
bool elevated = true;
|
||||||
Transaction(this.art, this.betrag, this.datum, this.beschreibung);
|
Transaction(this.art, this.betrag, this.datum, this.beschreibung);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Finance extends StatelessWidget {
|
class Finance extends StatefulWidget {
|
||||||
Finance({super.key});
|
const Finance({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Finance> createState() => _Finance();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Finance extends State<Finance> {
|
||||||
final List<Transaction> transactions = [
|
final List<Transaction> transactions = [
|
||||||
Transaction(Art.monatlBeitrag, 0, now, ''),
|
Transaction(Art.monatlBeitrag, 0, now, ''),
|
||||||
Transaction(Art.aufladung, 2042, now, ''),
|
Transaction(Art.aufladung, 2042, now, ''),
|
||||||
Transaction(Art.einkauf, -2442, now.subtract(const Duration(days: 2)), ''),
|
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)),
|
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
|
||||||
'Korrektur des Warenkorbs')
|
'Korrektur des Warenkorbs')
|
||||||
];
|
];
|
||||||
|
@ -36,68 +59,83 @@ class Finance extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
initializeDateFormatting('de_DE');
|
initializeDateFormatting('de_DE');
|
||||||
|
|
||||||
return ListView.builder(
|
return Scaffold(
|
||||||
itemCount: null,
|
appBar: AppBar(
|
||||||
itemBuilder: (context, index) {
|
toolbarHeight: 75,
|
||||||
if (index == 0) {
|
title: const Card(
|
||||||
return const Card(
|
child: Padding(
|
||||||
child: Padding(
|
padding: EdgeInsets.all(8.0),
|
||||||
padding: EdgeInsets.all(8.0),
|
child: Row(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
Icon(
|
||||||
Icon(
|
Icons.euro,
|
||||||
Icons.euro,
|
//color: Colors.black,
|
||||||
//color: Colors.black,
|
//semanticLabel: 'Text for screenreader',
|
||||||
//semanticLabel: 'Text for screenreader',
|
),
|
||||||
),
|
Column(
|
||||||
Column(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
'Aktuelles Guthaben:',
|
||||||
'Aktuelles Guthaben:',
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
'-00,34€',
|
||||||
'-00,34€',
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
)
|
||||||
)
|
],
|
||||||
],
|
)
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
)),
|
||||||
);
|
body: ListView.builder(
|
||||||
} else if (index <= transactions.length) {
|
itemCount: null,
|
||||||
return Card(
|
itemBuilder: (context, index) {
|
||||||
child: Padding(
|
if (index < transactions.length) {
|
||||||
padding: const EdgeInsets.all(8.0),
|
return Card(
|
||||||
child: Row(
|
clipBehavior: Clip.hardEdge,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
child: InkWell(
|
||||||
children: [
|
splashColor: Colors.blue.withAlpha(30),
|
||||||
Icon(transactions[index - 1].art == Art.korrektur
|
onTap: () {
|
||||||
? Icons.error
|
transactions[index].elevated =
|
||||||
: Icons.money),
|
!transactions[index].elevated;
|
||||||
Column(
|
setState(() {});
|
||||||
children: [
|
debugPrint('Card tapped');
|
||||||
Row(
|
},
|
||||||
children: [
|
child: Padding(
|
||||||
Text(DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
|
padding: const EdgeInsets.all(8.0),
|
||||||
.format(now)),
|
child: Row(
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
'${transactions[index - 1].art}: ${transactions[index - 1].betrag / 100}€'),
|
children: [
|
||||||
],
|
Icon(transactions[index].art == Art.korrektur
|
||||||
),
|
? Icons.error
|
||||||
Text(transactions[index - 1].beschreibung)
|
: 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;
|
||||||
} else {
|
}
|
||||||
return null;
|
},
|
||||||
}
|
));
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
leading:
|
||||||
|
const Image(image: AssetImage('assets/logo_sonako_4c_optimal.png')),
|
||||||
title: const Text('SoNaKo Demo App'),
|
title: const Text('SoNaKo Demo App'),
|
||||||
),
|
),
|
||||||
bottomNavigationBar: NavigationBar(
|
bottomNavigationBar: NavigationBar(
|
||||||
|
@ -70,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text('Page $test'),
|
child: Text('Page $test'),
|
||||||
),
|
),
|
||||||
Finance(),
|
const Finance(),
|
||||||
const Text(
|
const Text(
|
||||||
'Hier könnten Einstellungen zu Darkmode mit shared_preferences und riverpod sein')
|
'Hier könnten Einstellungen zu Darkmode mit shared_preferences und riverpod sein')
|
||||||
][currentPageIndex],
|
][currentPageIndex],
|
||||||
|
|
|
@ -60,9 +60,8 @@ flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
# assets:
|
assets:
|
||||||
# - images/a_dot_burr.jpeg
|
- assets/
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||||
|
|
Loading…
Reference in a new issue