2024-05-06 17:28:10 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2024-05-24 14:04:26 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-14 15:54:55 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2024-05-06 17:28:10 +02:00
|
|
|
import 'package:flutter_application_1/enums.dart';
|
2024-06-12 12:48:30 +02:00
|
|
|
import 'package:flutter_application_1/pages/chart_page.dart';
|
|
|
|
import 'package:flutter_application_1/pages/milestone_page.dart';
|
2024-05-24 14:04:26 +02:00
|
|
|
import 'package:flutter_application_1/widgets/custom_image_button_widget.dart';
|
2024-05-06 17:28:10 +02:00
|
|
|
|
2024-06-12 12:48:30 +02:00
|
|
|
// 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) {
|
2024-06-14 15:54:55 +02:00
|
|
|
final localizations = AppLocalizations.of(context)!;
|
|
|
|
|
2024-06-12 12:48:30 +02:00
|
|
|
List<Map<String, dynamic>> milestoneList = [
|
2024-06-14 15:54:55 +02:00
|
|
|
{'value': 700.0, 'emoji': '📱', 'text': localizations.milestone_text1 + localizations.amount(700)},
|
|
|
|
{'value': 3250.0, 'emoji': '🚲', 'text': localizations.milestone_text2 + localizations.amount(3250)},
|
|
|
|
{'value': 20000.0, 'emoji': '🌎', 'text': localizations.milestone_text3 + localizations.amount(20000)},
|
|
|
|
{'value': 100000.0, 'emoji': '🏎️', 'text': localizations.milestone_text4 + localizations.amount(100000)},
|
|
|
|
{'value': 350000.0, 'emoji': '🏡', 'text': localizations.milestone_text5 + localizations.amount(350000)},
|
2024-06-12 12:48:30 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
2024-06-14 15:54:55 +02:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
Expanded(child: _buildResultBox(localizations.final_capital, localizations.amount(compoundInterest))),
|
|
|
|
Expanded(child: _buildResultBox(localizations.deposits, localizations.amount(investedMoney))),
|
2024-06-15 13:35:59 +02:00
|
|
|
Expanded(child: _buildResultBox(localizations.interest_received, localizations.amount((double.parse(compoundInterest) - double.parse(investedMoney)).round()))),
|
2024-06-14 15:54:55 +02:00
|
|
|
],
|
|
|
|
),
|
2024-06-12 12:48:30 +02:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
Text(
|
2024-06-15 13:35:59 +02:00
|
|
|
localizations.result_text((double.parse(compoundInterest) - double.parse(investedMoney)).round(), compoundInterest, interestRate, investedMoney, time, monthlySavingsRate)
|
2024-05-24 14:04:26 +02:00
|
|
|
),
|
2024-06-12 12:48:30 +02:00
|
|
|
const SizedBox(height: 20),
|
|
|
|
CustomImageButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => ChartPage(
|
|
|
|
investedMoneyList: investedMoneyList,
|
|
|
|
compoundInterestList: compoundInterestList,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2024-06-15 14:14:20 +02:00
|
|
|
backgroundImage: 'assets/Button_Background_1.jpg',
|
2024-06-14 15:54:55 +02:00
|
|
|
child: Text(
|
|
|
|
localizations.graphic,
|
|
|
|
style: const TextStyle(color: CupertinoColors.white, fontSize: 20),
|
2024-06-12 12:48:30 +02:00
|
|
|
),
|
2024-05-24 14:04:26 +02:00
|
|
|
),
|
2024-06-12 12:48:30 +02:00
|
|
|
const SizedBox(height: 20),
|
|
|
|
CustomImageButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => MilestonePage(
|
|
|
|
compoundInterest: compoundInterest,
|
|
|
|
investedMoney: investedMoney,
|
|
|
|
milestoneList: milestoneList
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2024-06-15 14:14:20 +02:00
|
|
|
backgroundImage: 'assets/Button_Background_2.jpg',
|
2024-06-14 15:54:55 +02:00
|
|
|
child: Text(
|
|
|
|
localizations.milestones,
|
|
|
|
style: const TextStyle(color: CupertinoColors.white, fontSize: 20),
|
2024-06-12 12:48:30 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2024-05-06 17:28:10 +02:00
|
|
|
|
2024-06-14 15:54:55 +02:00
|
|
|
// Widget zum Aufbau einer Ergebnisbox
|
|
|
|
Widget _buildResultBox(String label, String value) {
|
|
|
|
return Container(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: CupertinoColors.extraLightBackgroundGray,
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
2024-06-12 12:48:30 +02:00
|
|
|
children: [
|
2024-06-14 15:54:55 +02:00
|
|
|
Text(
|
|
|
|
label,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 10,
|
2024-05-20 16:34:31 +02:00
|
|
|
),
|
2024-05-06 17:28:10 +02:00
|
|
|
),
|
2024-06-14 15:54:55 +02:00
|
|
|
const SizedBox(height: 5),
|
|
|
|
Text(
|
|
|
|
value,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
2024-05-20 16:34:31 +02:00
|
|
|
),
|
2024-05-06 17:28:10 +02:00
|
|
|
),
|
2024-06-12 12:48:30 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2024-06-14 15:54:55 +02:00
|
|
|
}
|