Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the finance health tiles #238

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 64 additions & 48 deletions lib/app/stats/widgets/finance_health_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,6 @@ class FinanceHealthDetails extends StatefulWidget {
}

class _FinanceHealthDetailsState extends State<FinanceHealthDetails> {
Widget buildExpansionPanel({
required FinanceHealthAttrScore attrScore,
required int index,
required String title,
required String subtitle,
required String text,
}) {
return ExpansionTile(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title),
const SizedBox(height: 2),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.circle,
size: 16,
color: FinanceHealthData.getHealthyValueColor(attrScore.score),
),
const SizedBox(width: 4),
Text(
attrScore.getScoreReviewTitle(context),
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: FinanceHealthData.getHealthyValueColor(
attrScore.score),
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 6),
],
),
subtitle: Text(subtitle),
childrenPadding: const EdgeInsets.all(16),
children: [
HTMLText(
tags: const {'b': TextStyle(fontWeight: FontWeight.bold)},
htmlString: text,
)
],
);
}

@override
Widget build(BuildContext context) {
final t = Translations.of(context);
Expand Down Expand Up @@ -108,15 +62,15 @@ class _FinanceHealthDetailsState extends State<FinanceHealthDetails> {
title: t.stats.finance_health_breakdown,
body: Column(
children: [
buildExpansionPanel(
_FinanceHealthDetailTile(
attrScore: financeHealthData.monthsWithoutIncomeScore,
title: t.financial_health.months_without_income.title,
subtitle:
t.financial_health.months_without_income.subtitle,
text:
'${financeHealthData.getMonthsWithoutIncomeResume(context)}\n\n${t.financial_health.months_without_income.suggestion}',
index: 0),
buildExpansionPanel(
_FinanceHealthDetailTile(
attrScore: financeHealthData.savingPercentageScore,
title: t.financial_health.savings_percentage.title,
subtitle:
Expand All @@ -134,3 +88,65 @@ class _FinanceHealthDetailsState extends State<FinanceHealthDetails> {
});
}
}

class _FinanceHealthDetailTile extends StatelessWidget {
const _FinanceHealthDetailTile({
required this.attrScore,
required this.index,
required this.title,
required this.subtitle,
required this.text,
});

final FinanceHealthAttrScore attrScore;
final int index;
final String title;
final String subtitle;
final String text;

@override
Widget build(BuildContext context) {
return ExpansionTile(
expandedCrossAxisAlignment: CrossAxisAlignment.start,
expandedAlignment: Alignment.topLeft,

title: ListTile(
title: Text(title),
leading: SizedBox(
width: 30,
child: Column(
children: [
Text(
attrScore.weightedValue?.toStringAsFixed(0) ?? '--',
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: FinanceHealthData.getHealthyValueColor(
attrScore.score),
fontWeight: FontWeight.bold,
),
),
Text(
'pts',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: FinanceHealthData.getHealthyValueColor(
attrScore.score),
fontWeight: FontWeight.bold,
),
)
],
),
),
minTileHeight: 20,
minVerticalPadding: 0,
contentPadding: const EdgeInsets.all(0),
subtitle: Text(subtitle)),
// subtitle: Text(subtitle),
childrenPadding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
children: [
HTMLText(
tags: const {'b': TextStyle(fontWeight: FontWeight.bold)},
htmlString: text,
),
],
);
}
}