2024-05-24 14:04:26 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2024-06-15 13:35:59 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2024-05-24 14:04:26 +02:00
|
|
|
|
2024-06-12 12:48:30 +02:00
|
|
|
class MilestoneTimeline extends StatelessWidget {
|
2024-06-15 13:35:59 +02:00
|
|
|
final List<Map<String, dynamic>> milestones;
|
|
|
|
final int totalInterest;
|
2024-06-12 12:48:30 +02:00
|
|
|
|
|
|
|
const MilestoneTimeline({
|
2024-06-15 13:35:59 +02:00
|
|
|
super.key,
|
2024-06-12 12:48:30 +02:00
|
|
|
required this.milestones,
|
|
|
|
required this.totalInterest,
|
|
|
|
});
|
2024-06-03 12:46:40 +02:00
|
|
|
|
2024-06-12 12:48:30 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-06-15 13:35:59 +02:00
|
|
|
final localizations = AppLocalizations.of(context)!;
|
2024-06-12 12:48:30 +02:00
|
|
|
|
2024-06-15 13:35:59 +02:00
|
|
|
return Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Center(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: List.generate(milestones.length, (index) {
|
|
|
|
double milestoneValue = milestones[index]['value'];
|
|
|
|
String milestoneEmoji = milestones[index]['emoji'];
|
|
|
|
String milestoneText = milestones[index]['text'];
|
|
|
|
bool milestoneReached = totalInterest >= milestoneValue;
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
if (index > 0)
|
|
|
|
Container(
|
|
|
|
height: 25,
|
|
|
|
width: 2,
|
|
|
|
color: milestoneReached ? CupertinoColors.systemGreen : CupertinoColors.black,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
milestoneEmoji,
|
|
|
|
style: const TextStyle(fontSize: 30),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 5),
|
|
|
|
Text(
|
|
|
|
milestoneText,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
|
|
|
child: Icon(
|
|
|
|
milestoneReached ? CupertinoIcons.check_mark_circled_solid : CupertinoIcons.circle_fill,
|
|
|
|
size: 20,
|
|
|
|
color: milestoneReached ? CupertinoColors.systemGreen : CupertinoColors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2024-06-03 12:46:40 +02:00
|
|
|
children: [
|
2024-06-15 13:35:59 +02:00
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(8.0),
|
2024-06-12 12:48:30 +02:00
|
|
|
),
|
|
|
|
child: Column(
|
2024-06-15 13:35:59 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2024-06-12 12:48:30 +02:00
|
|
|
children: [
|
|
|
|
Text(
|
2024-06-15 13:35:59 +02:00
|
|
|
totalInterest < milestones[0]['value'] ? localizations.what_you_cant_afford(localizations.amount(totalInterest)) : localizations.what_you_can_afford(localizations.amount(totalInterest)),
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
2024-06-12 12:48:30 +02:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2024-06-15 13:35:59 +02:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
if (totalInterest >= milestones[0]['value']) ...[
|
|
|
|
_buildListItem(context, localizations.smartphone),
|
|
|
|
],
|
|
|
|
if (totalInterest >= milestones[1]['value']) ...[
|
|
|
|
_buildListItem(context, localizations.ebike),
|
|
|
|
],
|
|
|
|
if (totalInterest >= milestones[2]['value']) ...[
|
|
|
|
_buildListItem(context, localizations.world_tour),
|
|
|
|
],
|
|
|
|
if (totalInterest >= milestones[3]['value']) ...[
|
|
|
|
_buildListItem(context, localizations.sports_car),
|
|
|
|
],
|
|
|
|
if (totalInterest >= milestones[4]['value']) ...[
|
|
|
|
_buildListItem(context, localizations.single_family_house),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
2024-06-12 12:48:30 +02:00
|
|
|
],
|
|
|
|
),
|
2024-06-03 12:46:40 +02:00
|
|
|
),
|
|
|
|
],
|
2024-06-15 13:35:59 +02:00
|
|
|
),
|
|
|
|
),
|
2024-06-03 12:46:40 +02:00
|
|
|
),
|
2024-06-15 13:35:59 +02:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildListItem(BuildContext context, String text) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
const Icon(
|
|
|
|
CupertinoIcons.circle_fill,
|
|
|
|
size: 12,
|
|
|
|
color: CupertinoColors.black,
|
|
|
|
),
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
text,
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2024-06-12 12:48:30 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2024-06-03 12:46:40 +02:00
|
|
|
}
|