From 9fa35660dfbf5688e50fa61b443aaa35bf071492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 25 Dec 2023 19:54:30 +0100 Subject: [PATCH] feat(graphs): change style --- lib/pw/platformbutton.dart | 10 +++++++--- lib/util/graphs.dart | 13 +++++++++---- lib/views/graph_view.dart | 9 ++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/pw/platformbutton.dart b/lib/pw/platformbutton.dart index 901101d..aa49d08 100644 --- a/lib/pw/platformbutton.dart +++ b/lib/pw/platformbutton.dart @@ -5,12 +5,16 @@ import 'package:prasule/pw/platformwidget.dart'; class PlatformButton extends PlatformWidget { final String text; final void Function()? onPressed; + final ButtonStyle? style; const PlatformButton( - {super.key, required this.text, required this.onPressed}); + {super.key, required this.text, required this.onPressed, this.style}); @override - TextButton createAndroidWidget(BuildContext context) => - TextButton(onPressed: onPressed, child: Text(text)); + TextButton createAndroidWidget(BuildContext context) => TextButton( + onPressed: onPressed, + style: style, + child: Text(text), + ); @override CupertinoButton createIosWidget(BuildContext context) => diff --git a/lib/util/graphs.dart b/lib/util/graphs.dart index b4a2bef..5a21330 100644 --- a/lib/util/graphs.dart +++ b/lib/util/graphs.dart @@ -1,4 +1,5 @@ import 'package:currency_picker/currency_picker.dart'; +import 'package:dynamic_color/dynamic_color.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -102,7 +103,8 @@ class ExpensesLineChart extends StatelessWidget { isStrokeCapRound: true, dotData: const FlDotData(show: false), belowBarData: BarAreaData(show: false), - color: Theme.of(context).colorScheme.primary, + color: Colors.green + .harmonizeWith(Theme.of(context).colorScheme.secondary), spots: List.generate( (yearly) ? 12 : DateTime(date.year, date.month, 0).day, (index) => FlSpot(index.toDouble(), incomeData[index]), @@ -115,7 +117,8 @@ class ExpensesLineChart extends StatelessWidget { isStrokeCapRound: true, dotData: const FlDotData(show: false), belowBarData: BarAreaData(show: false), - color: Theme.of(context).colorScheme.error, + color: Colors.red + .harmonizeWith(Theme.of(context).colorScheme.secondary), spots: List.generate( (yearly) ? 12 : DateTime(date.year, date.month, 0).day, (index) => FlSpot(index.toDouble() + 1, expenseData[index]), @@ -277,12 +280,14 @@ class ExpensesBarChart extends StatelessWidget { if (incomeData.isNotEmpty) BarChartRodData( toY: incomeData[index], - color: Theme.of(context).colorScheme.primary, + color: Colors.green + .harmonizeWith(Theme.of(context).colorScheme.secondary), ), if (expenseData.isNotEmpty) BarChartRodData( toY: expenseData[index], - color: Theme.of(context).colorScheme.error, + color: Colors.red + .harmonizeWith(Theme.of(context).colorScheme.secondary), ), ], ), diff --git a/lib/views/graph_view.dart b/lib/views/graph_view.dart index 80ed028..188e231 100644 --- a/lib/views/graph_view.dart +++ b/lib/views/graph_view.dart @@ -153,7 +153,7 @@ class _GraphViewState extends State { strokeWidth: 5, ) : SizedBox( - width: MediaQuery.of(context).size.width * 0.9, + width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height, child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -212,6 +212,13 @@ class _GraphViewState extends State { child: Column( children: [ 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)