Compare commits
6 commits
5ad2ae0867
...
3ab6cd5690
Author | SHA1 | Date | |
---|---|---|---|
3ab6cd5690 | |||
f083ab8cf0 | |||
893b421fe3 | |||
f343214df0 | |||
99282eb9da | |||
df0fabce0f |
3 changed files with 143 additions and 105 deletions
|
@ -1,5 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
//this was used in a earlier version of the app and will possibly be removed in future versions.
|
||||||
|
|
||||||
class Expand extends StatefulWidget {
|
class Expand extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final bool expand;
|
final bool expand;
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
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, Farbschema, Darkmode
|
|
||||||
- Einkauf und Settings
|
- Einkauf und Settings
|
||||||
- Details zum Warenkorb und Beschreibung (https://stackoverflow.com/questions/49029841/how-to-animate-collapse-elements-in-flutter)
|
- Warenkorb
|
||||||
|
- Aufladungen?
|
||||||
- farbliche Hervorhebungen
|
- farbliche Hervorhebungen
|
||||||
|
- semanticLabels, Screenreader
|
||||||
|
- monatliche Aufladung: ausstehende Beträge
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum Art { monatlBeitrag, aufladung, einkauf, korrektur }
|
enum Art { monatlBeitrag, aufladung, einkauf, korrektur }
|
||||||
|
@ -19,42 +20,42 @@ class Transaction {
|
||||||
int betrag;
|
int betrag;
|
||||||
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 StatefulWidget {
|
//sample data
|
||||||
const Finance({super.key});
|
class Finance extends StatelessWidget {
|
||||||
|
|
||||||
@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)),
|
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
|
||||||
'Korrektur des Warenkorbs'),
|
'Korrektur des Warenkorbs'),
|
||||||
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)),
|
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
|
||||||
'Korrektur des Warenkorbs'),
|
'Korrektur des Warenkorbs'),
|
||||||
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)),
|
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
|
||||||
'Korrektur des Warenkorbs'),
|
'Korrektur des Warenkorbs'),
|
||||||
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)),
|
Transaction(Art.korrektur, 2332, now.subtract(const Duration(hours: 5)),
|
||||||
'Korrektur des Warenkorbs')
|
'Korrektur des Warenkorbs')
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Finance({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
initializeDateFormatting('de_DE');
|
initializeDateFormatting('de_DE');
|
||||||
|
@ -63,79 +64,98 @@ class _Finance extends State<Finance> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
toolbarHeight: 75,
|
toolbarHeight: 75,
|
||||||
title: const Card(
|
title: const Card(
|
||||||
child: Padding(
|
child: ListTile(
|
||||||
padding: EdgeInsets.all(8.0),
|
leading: Icon(
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.euro,
|
Icons.euro,
|
||||||
//color: Colors.black,
|
|
||||||
//semanticLabel: 'Text for screenreader',
|
|
||||||
),
|
),
|
||||||
Column(
|
title: Text(
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Aktuelles Guthaben:',
|
'Aktuelles Guthaben:',
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
),
|
||||||
Text(
|
subtitle: Text(
|
||||||
'-00,34€',
|
'-00,34€',
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
body: ListView.builder(
|
body: ListView.builder(
|
||||||
itemCount: null,
|
itemCount: null,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index < transactions.length) {
|
if (index < transactions.length) {
|
||||||
return Card(
|
return Card(
|
||||||
clipBehavior: Clip.hardEdge,
|
child: ListTile(
|
||||||
child: InkWell(
|
leading: getIcon(transactions[index].art),
|
||||||
splashColor: Colors.blue.withAlpha(30),
|
title: Text(gettitle(transactions[index].art)),
|
||||||
|
subtitle: getSubtitle(index),
|
||||||
|
trailing: transactions[index].art == Art.einkauf
|
||||||
|
? PopupMenuButton(
|
||||||
|
onSelected: (value) {},
|
||||||
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<String>>[
|
||||||
|
const PopupMenuItem<String>(
|
||||||
|
value: 'Option',
|
||||||
|
child: ListTile(
|
||||||
|
leading: Icon(Icons.manage_history),
|
||||||
|
title: Text('Warenkorb bearbeiten')),
|
||||||
|
),
|
||||||
|
const PopupMenuItem<String>(
|
||||||
|
value: 'Option',
|
||||||
|
child: ListTile(
|
||||||
|
leading:
|
||||||
|
Icon(Icons.remove_shopping_cart),
|
||||||
|
title: Text('Einkauf stornieren')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: null,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
transactions[index].elevated =
|
if (transactions[index].art == Art.einkauf) {
|
||||||
!transactions[index].elevated;
|
showBottomSheet(
|
||||||
setState(() {});
|
context: context,
|
||||||
debugPrint('Card tapped');
|
builder: (BuildContext context) {
|
||||||
},
|
return const SizedBox.expand();
|
||||||
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 {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
}));
|
||||||
));
|
}
|
||||||
|
|
||||||
|
String gettitle(Art art) {
|
||||||
|
switch (art) {
|
||||||
|
case Art.aufladung:
|
||||||
|
return 'Aufladung';
|
||||||
|
case Art.einkauf:
|
||||||
|
return 'Einkauf';
|
||||||
|
case Art.korrektur:
|
||||||
|
return 'Korrektur';
|
||||||
|
case Art.monatlBeitrag:
|
||||||
|
return 'monatlicher Beitrag';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text getSubtitle(int index) {
|
||||||
|
String text = '${transactions[index].betrag / 100}';
|
||||||
|
text += '€ ';
|
||||||
|
text += DateFormat("EEEE, dd. MMMM yyyy HH:mm", 'de_DE')
|
||||||
|
.format(transactions[index].datum);
|
||||||
|
if (transactions[index].beschreibung != null) {
|
||||||
|
(text += '\n${transactions[index].beschreibung}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
Icon getIcon(Art art) {
|
||||||
|
switch (art) {
|
||||||
|
case Art.aufladung:
|
||||||
|
return const Icon(Icons.savings);
|
||||||
|
case Art.einkauf:
|
||||||
|
return const Icon(Icons.shopping_basket);
|
||||||
|
case Art.korrektur:
|
||||||
|
return const Icon(Icons.priority_high);
|
||||||
|
case Art.monatlBeitrag:
|
||||||
|
return const Icon(Icons.payment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,19 @@ class MyApp extends StatelessWidget {
|
||||||
title: 'SoNaKo Demo App',
|
title: 'SoNaKo Demo App',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
|
//darkgreen:5f7c61, mediumgreen: 66906a, lightgreen: 9cbe96, yellow: f5de64
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
|
brightness: Brightness.light,
|
||||||
colorScheme: ColorScheme.fromSeed(
|
colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: Colors.green)), //9bbee6 //79,128,104
|
brightness: Brightness.light,
|
||||||
darkTheme: ThemeData.dark(),
|
seedColor: const Color(0xff5f7c61))),
|
||||||
|
darkTheme: ThemeData(
|
||||||
|
useMaterial3: true,
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
colorScheme: ColorScheme.fromSeed(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
seedColor: const Color(0xff5f7c61),
|
||||||
|
)),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: const MyHomePage(),
|
home: const MyHomePage(),
|
||||||
);
|
);
|
||||||
|
@ -72,9 +81,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text('Page $test'),
|
child: Text('Page $test'),
|
||||||
),
|
),
|
||||||
const Finance(),
|
Finance(),
|
||||||
const Text(
|
ListView(children: const <Widget>[
|
||||||
'Hier könnten Einstellungen zu Darkmode mit shared_preferences und riverpod sein')
|
ListTile(
|
||||||
|
leading: Icon(Icons.dark_mode),
|
||||||
|
title: Text(
|
||||||
|
'Hier könnten Einstellungen zu Darkmode mit shared_preferences und riverpod sein',
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
])
|
||||||
][currentPageIndex],
|
][currentPageIndex],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue