flutter_application_1/lib/pages/chart_page.dart

183 lines
7.1 KiB
Dart
Raw Normal View History

2024-06-12 12:48:30 +02:00
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2024-06-12 12:48:30 +02:00
import 'package:flutter_application_1/widgets/chart_widget.dart';
// Widget für die Seite, die das gestapelte Säulendiagramm anzeigt
class ChartPage extends StatelessWidget {
final List<double> investedMoneyList; // Liste der investierten Geldbeträge
final List<double> compoundInterestList; // Liste der zusammengesetzten Zinsen
const ChartPage({
super.key,
required this.investedMoneyList,
required this.compoundInterestList,
});
@override
Widget build(BuildContext context) {
final localizations = AppLocalizations.of(context)!;
2024-06-12 12:48:30 +02:00
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
padding: EdgeInsets.only(
left: 10,
right: 10,
top: MediaQuery.of(context).padding.top + 10,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: const Icon(CupertinoIcons.chevron_left, size: 15),
onPressed: () {
Navigator.pop(context); // Zurück zur vorherigen Seite
},
),
Text(
localizations.graphic,
style: const TextStyle(fontWeight: FontWeight.bold),
2024-06-12 12:48:30 +02:00
),
const SizedBox(width: 40),
],
),
),
),
// Anzeige des gestapelten Säulendiagramms
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: StackedColumnChart(
lowerValues: investedMoneyList,
upperValues: compoundInterestList,
),
),
),
// Tabelle mit Einzahlungen, Zinsen und Endkapital
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
decoration: BoxDecoration(
color: CupertinoColors.black,
borderRadius: BorderRadius.circular(5),
),
clipBehavior: Clip.antiAlias,
child: Table(
columnWidths: const {
0: FixedColumnWidth(60),
1: FlexColumnWidth(),
2: FlexColumnWidth(),
3: FlexColumnWidth(),
},
border: TableBorder.symmetric(
inside: const BorderSide(
color: CupertinoColors.white,
width: 1,
),
),
children: [
// Tabellenkopf
TableRow(
decoration: const BoxDecoration(
color: CupertinoColors.black,
2024-06-12 12:48:30 +02:00
),
children: [
Padding(
padding: const EdgeInsets.all(8.0),
2024-06-12 12:48:30 +02:00
child: Text(
localizations.year,
style: const TextStyle(
2024-06-12 12:48:30 +02:00
color: CupertinoColors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
2024-06-12 12:48:30 +02:00
child: Text(
localizations.deposits,
style: const TextStyle(
2024-06-12 12:48:30 +02:00
color: CupertinoColors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
2024-06-12 12:48:30 +02:00
child: Text(
localizations.interest_received,
style: const TextStyle(
2024-06-12 12:48:30 +02:00
color: CupertinoColors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
2024-06-12 12:48:30 +02:00
child: Text(
localizations.final_capital,
style: const TextStyle(
2024-06-12 12:48:30 +02:00
color: CupertinoColors.white,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
],
),
// Datenzeilen
for (int i = 0; i < investedMoneyList.length; i++)
TableRow(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'${i + 1}',
style: const TextStyle(color: CupertinoColors.white),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
localizations.amount(investedMoneyList[i]),
2024-06-12 12:48:30 +02:00
style: const TextStyle(color: CupertinoColors.white),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
localizations.amount(compoundInterestList[i]),
2024-06-12 12:48:30 +02:00
style: const TextStyle(color: CupertinoColors.white),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
localizations.amount(compoundInterestList[i] + investedMoneyList[i]),
2024-06-12 12:48:30 +02:00
style: const TextStyle(color: CupertinoColors.white),
textAlign: TextAlign.center,
),
),
],
),
],
),
),
),
),
],
),
);
}
}