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 fallback icons for account/category #66

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions lib/entity/account.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flow/data/flow_icon.dart';
import 'package:flow/entity/_base.dart';
import 'package:flow/entity/transaction.dart';
import 'package:flutter/widgets.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:objectbox/objectbox.dart';
Expand Down Expand Up @@ -38,16 +37,13 @@ class Account implements EntityBase {

bool excludeFromTotalBalance;

/// Returns [IconData] from [iconCode]
///
/// Falls back to [Symbols.error_rounded]
@Transient()
@JsonKey(includeFromJson: false, includeToJson: false)
FlowIconData get icon {
try {
return FlowIconData.parse(iconCode);
} catch (e) {
return FlowIconData.emoji("🤷");
return FlowIconData.icon(Symbols.wallet_rounded);
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/entity/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flow/data/flow_icon.dart';
import 'package:flow/entity/_base.dart';
import 'package:flow/entity/transaction.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:objectbox/objectbox.dart';
import 'package:uuid/uuid.dart';

Expand Down Expand Up @@ -34,7 +35,7 @@ class Category implements EntityBase {
try {
return FlowIconData.parse(iconCode);
} catch (e) {
return FlowIconData.emoji("🤷");
return FlowIconData.icon(Symbols.category_rounded);
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/routes/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class _AccountPageState extends State<AccountPage> {
late final Account? _currentlyEditing;

String get iconCodeOrError =>
_iconData?.toString() ?? FlowIconData.emoji("❌").toString();
_iconData?.toString() ??
FlowIconData.icon(Symbols.wallet_rounded).toString();

dynamic error;

Expand Down
3 changes: 2 additions & 1 deletion lib/routes/category_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class _CategoryPageState extends State<CategoryPage> {
late final Category? _currentlyEditing;

String get iconCodeOrError =>
_iconData?.toString() ?? FlowIconData.emoji("❌").toString();
_iconData?.toString() ??
FlowIconData.icon(Symbols.category_rounded).toString();

dynamic error;

Expand Down