main #1

Open
fdenzer wants to merge 46 commits from mgl_crew/Mitgliederladen:main into main
5 changed files with 166 additions and 69 deletions
Showing only changes of commit 5ad2ae0867 - Show all commits

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 KiB

View 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);
}
}

View file

@ -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,11 +59,10 @@ 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(
@ -66,38 +88,54 @@ class Finance extends StatelessWidget {
], ],
), ),
), ),
); )),
} else if (index <= transactions.length) { body: ListView.builder(
itemCount: null,
itemBuilder: (context, index) {
if (index < transactions.length) {
return Card( 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( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Icon(transactions[index - 1].art == Art.korrektur Icon(transactions[index].art == Art.korrektur
? Icons.error ? Icons.error
: Icons.money), : Icons.money),
Column( Column(
children: [ children: [
Row( Row(
children: [ children: [
Text(DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE') Text(DateFormat(
"EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
.format(now)), .format(now)),
Text( Text(
'${transactions[index - 1].art}: ${transactions[index - 1].betrag / 100}'), '${transactions[index].art}: ${transactions[index].betrag / 100}'),
], ],
), ),
Text(transactions[index - 1].beschreibung) Expand(
expand: transactions[index].elevated,
child: Text(transactions[index].beschreibung))
], ],
), ),
], ],
), ),
), ),
),
); );
} else { } else {
return null; return null;
} }
}, },
); ));
} }
} }

View file

@ -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],

View file

@ -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