125 lines
4.4 KiB
Dart
125 lines
4.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_application_1/enums.dart';
|
|
import 'package:flutter_application_1/pages/chart_page.dart';
|
|
import 'package:flutter_application_1/pages/milestone_page.dart';
|
|
import 'package:flutter_application_1/utils.dart';
|
|
import 'package:flutter_application_1/widgets/custom_image_button_widget.dart';
|
|
|
|
// Widget zur Anzeige der Ergebnisse der Berechnungen und zur Navigation zu anderen Seiten
|
|
class ResultWidget extends StatelessWidget {
|
|
final String compoundInterest;
|
|
final String investedMoney;
|
|
final String time;
|
|
final String monthlySavingsRate;
|
|
final String interestRate;
|
|
final PayoutInterval payoutInterval;
|
|
final List<double> investedMoneyList;
|
|
final List<double> compoundInterestList;
|
|
|
|
const ResultWidget({
|
|
super.key,
|
|
required this.compoundInterest,
|
|
required this.investedMoney,
|
|
required this.time,
|
|
required this.monthlySavingsRate,
|
|
required this.interestRate,
|
|
required this.payoutInterval,
|
|
required this.investedMoneyList,
|
|
required this.compoundInterestList,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<Map<String, dynamic>> milestoneList = [
|
|
{'value': 700.0, 'emoji': '📱', 'text': 'Smartphone\nPreis: 700€'},
|
|
{'value': 3250.0, 'emoji': '🚲', 'text': 'eBike\nPreis: 3250€'},
|
|
{'value': 20000.0, 'emoji': '🌎', 'text': 'Weltreise\nPreis: 20000€'},
|
|
{'value': 100000.0, 'emoji': '🏎️', 'text': 'Sportwagen\nPreis: 100000€'},
|
|
{'value': 350000.0, 'emoji': '🏡', 'text': '150qm Einfamilienhaus\nPreis: 350000€'},
|
|
];
|
|
|
|
return Column(
|
|
children: <Widget>[
|
|
_buildResultRow('Endkapital:', '$compoundInterest€'),
|
|
_buildResultRow('Einzahlungen:', '$investedMoney€'),
|
|
_buildResultRow('Erhaltene Zinsen:', '${double.parse(compoundInterest) + double.parse(investedMoney)}€'),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
'Wenn du über einen Zeitraum von $time Jahren ${translateInterval(payoutInterval)} $monthlySavingsRate€ mit einem Zinssatz von $interestRate% investierst, erreichst du am Ende ein Endkapital von $compoundInterest€. Dieses setzt sich aus Einzahlungen von $investedMoney€ und Zinsen bzw. Kapitalerträgen in Höhe von ${double.parse(compoundInterest) - double.parse(investedMoney)}€ zusammen.'
|
|
),
|
|
const SizedBox(height: 20),
|
|
CustomImageButton(
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => ChartPage(
|
|
investedMoneyList: investedMoneyList,
|
|
compoundInterestList: compoundInterestList,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
backgroundImage: 'assets/images/button_bg1.jpg',
|
|
child: const Text(
|
|
'Grafik',
|
|
style: TextStyle(color: CupertinoColors.white, fontSize: 20),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
CustomImageButton(
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => MilestonePage(
|
|
compoundInterest: compoundInterest,
|
|
investedMoney: investedMoney,
|
|
milestoneList: milestoneList
|
|
),
|
|
),
|
|
);
|
|
},
|
|
backgroundImage: 'assets/images/button_bg2.jpg',
|
|
child: const Text(
|
|
'Meilensteine',
|
|
style: TextStyle(color: CupertinoColors.white, fontSize: 20),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
// Widget zum Aufbau einer Ergebniszeile
|
|
Widget _buildResultRow(String label, String value) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Flexible(
|
|
child: Text(
|
|
label,
|
|
textAlign: TextAlign.start,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 20),
|
|
Flexible(
|
|
child: Text(
|
|
value,
|
|
textAlign: TextAlign.end,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|