From 94b387db43adfb36796c6205c184afd5ca726d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 29 Jan 2024 23:29:15 +0100 Subject: [PATCH] fix: add titles to graphs --- CHANGELOG.md | 2 ++ lib/l10n/app_cs.arb | 5 +++- lib/l10n/app_en.arb | 23 ++++++++++++++- lib/main.dart | 12 ++++++-- lib/util/graphs.dart | 5 +++- lib/views/graph_view.dart | 61 ++++++++++++++++++++++++++------------- 6 files changed, 83 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acf2aaf..c04250d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - Added sorting by oldest - Moved search into three-dot menu - Make search case-insensitive +- Added titles above graphs +- Some extra optimization for iOS # 1.0.0-alpha+5 - Add tests - Add searching through entries to homepage diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index f7074e0..51525c0 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -110,5 +110,8 @@ "sortNewest":"Nejnovější první", "sortOldest":"Nejstarší první", "sort":"Seřadit", - "search":"Prohledat" + "search":"Prohledat", + "expensesPerYear":"Měsíční výdaje v roce {year}", + "expensesPerMonth":"Denní výdaje během měsíce {monthYear}", + "expensesPerCategory":"Total expenses per category" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 89e1ddb..0105718 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -226,5 +226,26 @@ "sortNewest":"Newest first", "sortOldest":"Oldest first", "sort":"Sort", - "search":"Search" + "search":"Search", + "expensesPerYear":"Expenses per month in {year}", + "@expensesPerYear":{ + "placeholders": { + "year":{ + "description": "The year of the monthly expense sum", + "example": "2024", + "type": "int" + } + } + }, + "expensesPerMonth":"Expenses per day during {monthYear}", + "@expensesPerMonth":{ + "placeholders": { + "monthYear":{ + "description": "Month and year formatted through DateFormat class", + "example": "June, 2024", + "type": "String" + } + } + }, + "expensesPerCategory":"Total expenses per category" } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index d6791ea..bdf37d7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -78,8 +78,16 @@ class MyApp extends StatelessWidget { ? darkColorScheme : lightColorScheme, ), - child: const CupertinoApp( - localizationsDelegates: [ + child: CupertinoApp( + theme: CupertinoThemeData( + textTheme: CupertinoTextThemeData( + primaryColor: + ((MediaQuery.of(context).platformBrightness == + Brightness.dark) + ? darkColorScheme + : lightColorScheme) + .onPrimary)), + localizationsDelegates: const [ AppLocalizations.delegate, ...GlobalMaterialLocalizations.delegates, ...GlobalCupertinoLocalizations.delegates, diff --git a/lib/util/graphs.dart b/lib/util/graphs.dart index 1fba13e..89696e7 100644 --- a/lib/util/graphs.dart +++ b/lib/util/graphs.dart @@ -71,6 +71,7 @@ class ExpensesLineChart extends StatelessWidget { LineChartData( lineTouchData: LineTouchData( touchTooltipData: LineTouchTooltipData( + tooltipBgColor: Theme.of(context).colorScheme.secondaryContainer, getTooltipItems: (spots) => List.generate( spots.length, (index) => LineTooltipItem( @@ -439,7 +440,9 @@ class _CategoriesPieChartState extends State { const SizedBox( height: 5, ), - Expanded( + LimitedBox( + maxHeight: MediaQuery.of(context).size.height * 0.23, + maxWidth: MediaQuery.of(context).size.width * 0.9, child: PieChart( PieChartData( centerSpaceRadius: double.infinity, diff --git a/lib/views/graph_view.dart b/lib/views/graph_view.dart index c5b8108..da86f5b 100644 --- a/lib/views/graph_view.dart +++ b/lib/views/graph_view.dart @@ -96,18 +96,8 @@ class _GraphViewState extends State { return Scaffold( floatingActionButton: Tooltip( message: AppLocalizations.of(context).changeDate, - child: PlatformButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.primary, - ), - foregroundColor: MaterialStateProperty.all( - Theme.of(context).colorScheme.onPrimary, - ), - ), - text: yearly - ? DateFormat.y(locale).format(_selectedDate) - : DateFormat.yMMMM(locale).format(_selectedDate), + child: FloatingActionButton( + child: const Icon(Icons.calendar_month), onPressed: () async { final firstDate = (selectedWallet!.entries ..sort( @@ -266,6 +256,23 @@ class _GraphViewState extends State { padding: const EdgeInsets.all(8), child: Column( children: [ + Text( + yearly + ? AppLocalizations.of(context) + .expensesPerYear(_selectedDate.year) + : AppLocalizations.of(context) + .expensesPerMonth( + DateFormat.yMMMM() + .format(_selectedDate), + ), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox( + height: 15, + ), SizedBox( width: MediaQuery.of(context).size.width * 0.9, height: @@ -328,14 +335,28 @@ class _GraphViewState extends State { Theme.of(context).colorScheme.secondaryContainer, ), width: MediaQuery.of(context).size.width * 0.95, - height: MediaQuery.of(context).size.height * 0.35, - child: Padding( - padding: const EdgeInsets.all(8), - child: CategoriesPieChart( - symbol: selectedWallet!.currency.symbol, - entries: selectedWallet!.entries, - categories: selectedWallet!.categories, - ), + height: MediaQuery.of(context).size.height * 0.4, + child: Column( + children: [ + const SizedBox( + height: 10, + ), + Text( + AppLocalizations.of(context).expensesPerCategory, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + Padding( + padding: const EdgeInsets.all(8), + child: CategoriesPieChart( + symbol: selectedWallet!.currency.symbol, + entries: selectedWallet!.entries, + categories: selectedWallet!.categories, + ), + ), + ], ), ), ],