fix: differentiate expense/income with color

This commit is contained in:
Matyáš Caras 2024-01-08 21:53:51 +01:00
parent 17a3a1ce20
commit b72e811339
Signed by untrusted user who does not match committer: hernik
GPG key ID: 2A3175F98820C5C6
2 changed files with 39 additions and 5 deletions

View file

@ -6,6 +6,7 @@
- Added pie chart for expense/income data per category
- Added recurring entries
- Fixed wrong default sorting
- Differentiate expense and income on home view
# 1.0.0-alpha+2
- Fixed localization issues
- Added graphs for expenses and income per month/year

View file

@ -3,6 +3,7 @@
import 'dart:async';
import 'dart:math';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -146,7 +147,8 @@ class _HomeViewState extends State<HomeView> {
}
logger.d(
"Created ${selectedWallet!.recurringEntries.length} recurring entries");
"Created ${selectedWallet!.recurringEntries.length} recurring entries",
);
// save and reload
WalletManager.saveWallet(selectedWallet!).then((value) {
@ -408,10 +410,41 @@ class _HomeViewState extends State<HomeView> {
),
),
title: Text(element.data.name),
subtitle: Text(
NumberFormat.currency(
symbol: selectedWallet!.currency.symbol,
).format(element.data.amount),
subtitle: RichText(
text: TextSpan(
children: [
TextSpan(
text: NumberFormat.currency(
symbol: selectedWallet!.currency.symbol,
).format(element.data.amount),
style: TextStyle(
color: (element.type == EntryType.income)
? (MediaQuery.of(context)
.platformBrightness ==
Brightness.dark)
? Colors.green.shade300
: Colors.green.harmonizeWith(
Theme.of(context)
.colorScheme
.primary,
)
: (MediaQuery.of(context)
.platformBrightness ==
Brightness.dark)
? Colors.red.shade300
: Colors.red.harmonizeWith(
Theme.of(context)
.colorScheme
.primary,
),
),
),
TextSpan(
text:
" | ${DateFormat.MMMd(locale).format(element.date)}",
),
],
),
),
),
),