Skip to content

Commit

Permalink
Merge pull request #66 from flow-mn/improve-default-icons
Browse files Browse the repository at this point in the history
Improve fallback icons for account/category
  • Loading branch information
sadespresso authored Feb 18, 2024
2 parents 0b92557 + 59e90d3 commit e397cb4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
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

0 comments on commit e397cb4

Please sign in to comment.