feat: add graphs #16
3 changed files with 24 additions and 8 deletions
|
@ -5,12 +5,16 @@ import 'package:prasule/pw/platformwidget.dart';
|
|||
class PlatformButton extends PlatformWidget<TextButton, CupertinoButton> {
|
||||
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) =>
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -153,7 +153,7 @@ class _GraphViewState extends State<GraphView> {
|
|||
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<GraphView> {
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue