import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; 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 investedMoneyList; // Liste der investierten Geldbeträge final List 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)!; return Scaffold( body: CustomScrollView( slivers: [ 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), ), 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, ), children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.year, style: const TextStyle( color: CupertinoColors.white, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.deposits, style: const TextStyle( color: CupertinoColors.white, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.interest_received, style: const TextStyle( color: CupertinoColors.white, fontWeight: FontWeight.bold, ), textAlign: TextAlign.center, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.final_capital, style: const TextStyle( 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]), style: const TextStyle(color: CupertinoColors.white), textAlign: TextAlign.center, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.amount(compoundInterestList[i]), style: const TextStyle(color: CupertinoColors.white), textAlign: TextAlign.center, ), ), Padding( padding: const EdgeInsets.all(8.0), child: Text( localizations.amount(compoundInterestList[i] + investedMoneyList[i]), style: const TextStyle(color: CupertinoColors.white), textAlign: TextAlign.center, ), ), ], ), ], ), ), ), ), ], ), ); } }