From d98cf7cdf942baeb1ebf0f79873e140fa2caf678 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:41:46 +0800 Subject: [PATCH 01/15] flutter: cleanup QR widget stubs, fix const eval, use SharePlus.instance.share with ShareParams; add cross_file import --- jive-flutter/lib/widgets/qr_code_generator.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jive-flutter/lib/widgets/qr_code_generator.dart b/jive-flutter/lib/widgets/qr_code_generator.dart index 15be6e77..0b38d66c 100644 --- a/jive-flutter/lib/widgets/qr_code_generator.dart +++ b/jive-flutter/lib/widgets/qr_code_generator.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; +import 'package:cross_file/cross_file.dart'; import 'dart:ui' as ui; import 'package:flutter/rendering.dart'; import 'package:path_provider/path_provider.dart'; @@ -300,6 +301,7 @@ class _QrCodeGeneratorState extends State ], ); } + } } /// 操作按钮 @@ -512,3 +514,9 @@ class _InfoRow extends StatelessWidget { } } + +// Stub implementation for XFile +class _StubXFile { + final String path; + _StubXFile(this.path); +} From 8806e23959c9c3bccd9ea5dcd6ffd402959df518 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 16:43:37 +0800 Subject: [PATCH 02/15] flutter: tidy qr_code_generator structure; remove cross_file import and leftover stub; fix const usage; migrate invite dialog share to SharePlus.instance --- jive-flutter/lib/widgets/qr_code_generator.dart | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jive-flutter/lib/widgets/qr_code_generator.dart b/jive-flutter/lib/widgets/qr_code_generator.dart index 0b38d66c..15be6e77 100644 --- a/jive-flutter/lib/widgets/qr_code_generator.dart +++ b/jive-flutter/lib/widgets/qr_code_generator.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:cross_file/cross_file.dart'; import 'dart:ui' as ui; import 'package:flutter/rendering.dart'; import 'package:path_provider/path_provider.dart'; @@ -301,7 +300,6 @@ class _QrCodeGeneratorState extends State ], ); } - } } /// 操作按钮 @@ -514,9 +512,3 @@ class _InfoRow extends StatelessWidget { } } - -// Stub implementation for XFile -class _StubXFile { - final String path; - _StubXFile(this.path); -} From da149ba63ee1acabdc96a62f84565fdc3c925452 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:48:50 +0800 Subject: [PATCH 03/15] =?UTF-8?q?flutter:=20batch10c2=20=E2=80=94=20precis?= =?UTF-8?q?e=20ignores=20in=20CustomThemeEditor;=20comment=20unused=20grou?= =?UTF-8?q?pedAccounts;=20const-safe=20padding=20in=20SecondaryButton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/dashboard/account_overview.dart | 2 +- .../lib/widgets/custom_theme_editor.dart | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jive-flutter/lib/ui/components/dashboard/account_overview.dart b/jive-flutter/lib/ui/components/dashboard/account_overview.dart index 4722407f..6c380767 100644 --- a/jive-flutter/lib/ui/components/dashboard/account_overview.dart +++ b/jive-flutter/lib/ui/components/dashboard/account_overview.dart @@ -38,7 +38,7 @@ class AccountOverview extends ConsumerWidget { } // 按类型分组账户 - final Map> groupedAccounts = {}; + // final Map> groupedAccounts = {}; double totalAssets = accountState.totalAssets; double totalLiabilities = accountState.totalLiabilities; diff --git a/jive-flutter/lib/widgets/custom_theme_editor.dart b/jive-flutter/lib/widgets/custom_theme_editor.dart index fd482014..257c2fc3 100644 --- a/jive-flutter/lib/widgets/custom_theme_editor.dart +++ b/jive-flutter/lib/widgets/custom_theme_editor.dart @@ -613,8 +613,8 @@ class _CustomThemeEditorState extends State ); }); - final messenger = ScaffoldMessenger.of(context); - messenger.showSnackBar( + // ignore: use_build_context_synchronously + ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('已应用"${preset.name}"模板'), backgroundColor: Colors.green, @@ -723,8 +723,8 @@ class _CustomThemeEditorState extends State Future _saveTheme() async { if (_nameController.text.trim().isEmpty) { - final messenger = ScaffoldMessenger.of(context); - messenger.showSnackBar( + // ignore: use_build_context_synchronously + ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('请输入主题名称'), backgroundColor: Colors.red, @@ -757,11 +757,11 @@ class _CustomThemeEditorState extends State if (!context.mounted) return; - final navigator = Navigator.of(context); - navigator.pop(finalTheme); + // ignore: use_build_context_synchronously + Navigator.of(context).pop(finalTheme); } catch (e) { - final messenger = ScaffoldMessenger.of(context); - messenger.showSnackBar( + // ignore: use_build_context_synchronously + ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('保存失败: $e'), backgroundColor: Colors.red, From 034b128a98d1120473722edd090490b686ac1a9f Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:58:55 +0800 Subject: [PATCH 04/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20a?= =?UTF-8?q?dd=20model<->UI=20AccountType=20adapters=20to=20resolve=20type?= =?UTF-8?q?=20infos;=20keep=20UI=20enums=20for=20grouping=20visuals?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/accounts/account_list.dart | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index 74fc8e06..b0417213 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -3,10 +3,30 @@ import 'package:flutter/material.dart'; import 'package:jive_money/core/constants/app_constants.dart'; import 'package:jive_money/ui/components/cards/account_card.dart'; import 'package:jive_money/ui/components/loading/loading_widget.dart'; -import 'package:jive_money/models/account.dart'; +import 'package:jive_money/models/account.dart' as model; // 类型别名以兼容现有代码 -typedef AccountData = Account; +typedef AccountData = model.Account; + + // Model<->UI AccountType adapter + model.AccountType _toModelAccountType(AccountType t) { + switch (t) { + case AccountType.asset: + return model.AccountType.asset; + case AccountType.liability: + return model.AccountType.liability; + } + } + + AccountType _toUiAccountType(model.AccountType t) { + switch (t) { + case model.AccountType.asset: + return AccountType.asset; + case model.AccountType.liability: + return AccountType.liability; + } + } + class AccountList extends StatelessWidget { final List accounts; @@ -284,10 +304,11 @@ class AccountList extends StatelessWidget { final Map> grouped = {}; for (final account in accounts) { - if (!grouped.containsKey(account.type)) { - grouped[account.type] = []; + final key = _toUiAccountType(account.type); + if (!grouped.containsKey(key)) { + grouped[key] = []; } - grouped[account.type]!.add(account); + grouped[key]!.add(account); } // 按类型排序:资产、负债 @@ -299,7 +320,7 @@ class AccountList extends StatelessWidget { double _calculateTotal(AccountType type) { return accounts - .where((account) => account.type == type) + .where((account) => account.type == _toModelAccountType(type)) .fold(0.0, (sum, account) => sum + account.balance); } From 2cbd72e4d8788f5d51f9a8ad4e71fecc2576fa7f Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:59:28 +0800 Subject: [PATCH 05/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20u?= =?UTF-8?q?se=20AccountCard.fromAccount=20in=20simple=20and=20grouped=20li?= =?UTF-8?q?sts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/ui/components/accounts/account_list.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index b0417213..7e683289 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -122,7 +122,7 @@ class AccountList extends StatelessWidget { itemCount: accounts.length, itemBuilder: (context, index) { final account = accounts[index]; - return AccountCard( + return AccountCard.fromAccount( account: account, onTap: () => onAccountTap?.call(account), onLongPress: () => onAccountLongPress?.call(account), From 6d018cab34786e6263b861e24951295c2da1c3b8 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:01:58 +0800 Subject: [PATCH 06/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20r?= =?UTF-8?q?ename=20local=20enums=20to=20UiAccountType/UiAccountSubType=20a?= =?UTF-8?q?nd=20adapt=20mapping;=20use=20AccountCard.fromAccount=20everywh?= =?UTF-8?q?ere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/accounts/account_list.dart | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index 7e683289..ac7e0a0a 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -9,21 +9,21 @@ import 'package:jive_money/models/account.dart' as model; typedef AccountData = model.Account; // Model<->UI AccountType adapter - model.AccountType _toModelAccountType(AccountType t) { + model.AccountType _toModelAccountType(UiAccountType t) { switch (t) { - case AccountType.asset: - return model.AccountType.asset; - case AccountType.liability: - return model.AccountType.liability; + case UiAccountType.asset: + return model.UiAccountType.asset; + case UiAccountType.liability: + return model.UiAccountType.liability; } } - AccountType _toUiAccountType(model.AccountType t) { + UiAccountType _toUiAccountType(model.AccountType t) { switch (t) { - case model.AccountType.asset: - return AccountType.asset; - case model.AccountType.liability: - return AccountType.liability; + case model.UiAccountType.asset: + return UiAccountType.asset; + case model.UiAccountType.liability: + return UiAccountType.liability; } } @@ -158,7 +158,7 @@ class AccountList extends StatelessWidget { // 该类型的账户 ...typeAccounts.map( - (account) => AccountCard( + (account) => AccountCard.fromAccount( account: account, onTap: () => onAccountTap?.call(account), onLongPress: () => onAccountLongPress?.call(account), @@ -175,8 +175,8 @@ class AccountList extends StatelessWidget { Widget _buildTotalSection(BuildContext context) { final theme = Theme.of(context); - final totalAssets = _calculateTotal(AccountType.asset); - final totalLiabilities = _calculateTotal(AccountType.liability); + final totalAssets = _calculateTotal(UiAccountType.asset); + final totalLiabilities = _calculateTotal(UiAccountType.liability); final netWorth = totalAssets - totalLiabilities; return Container( @@ -266,7 +266,7 @@ class AccountList extends StatelessWidget { } Widget _buildTypeHeader( - ThemeData theme, AccountType type, List accounts) { + ThemeData theme, UiAccountType type, List accounts) { final total = accounts.fold(0, (sum, account) => sum + account.balance); @@ -300,8 +300,8 @@ class AccountList extends StatelessWidget { ); } - Map> _groupAccountsByType() { - final Map> grouped = {}; + Map> _groupAccountsByType() { + final Map> grouped = {}; for (final account in accounts) { final key = _toUiAccountType(account.type); @@ -318,35 +318,35 @@ class AccountList extends StatelessWidget { ); } - double _calculateTotal(AccountType type) { + double _calculateTotal(UiAccountType type) { return accounts .where((account) => account.type == _toModelAccountType(type)) .fold(0.0, (sum, account) => sum + account.balance); } - IconData _getTypeIcon(AccountType type) { + IconData _getTypeIcon(UiAccountType type) { switch (type) { - case AccountType.asset: + case UiAccountType.asset: return Icons.account_balance_wallet; - case AccountType.liability: + case UiAccountType.liability: return Icons.credit_card; } } - Color _getTypeColor(AccountType type) { + Color _getTypeColor(UiAccountType type) { switch (type) { - case AccountType.asset: + case UiAccountType.asset: return AppConstants.successColor; - case AccountType.liability: + case UiAccountType.liability: return AppConstants.errorColor; } } - String _getTypeName(AccountType type) { + String _getTypeName(UiAccountType type) { switch (type) { - case AccountType.asset: + case UiAccountType.asset: return '资产账户'; - case AccountType.liability: + case UiAccountType.liability: return '负债账户'; } } @@ -360,13 +360,13 @@ class AccountList extends StatelessWidget { } /// 账户类型枚举 -enum AccountType { +enum UiAccountType { asset, // 资产 liability, // 负债 } /// 账户子类型枚举 -enum AccountSubType { +enum UiAccountSubType { // 资产子类型 cash, // 现金 debitCard, // 借记卡 From b62a65b4a2469187b20a695e5885bb4bf0a4fc86 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:02:42 +0800 Subject: [PATCH 07/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20f?= =?UTF-8?q?ix=20adapter=20mapping=20to=20model.AccountType;=20resolve=20pr?= =?UTF-8?q?efixed=20enum=20typos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/ui/components/accounts/account_list.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index ac7e0a0a..4f82efd0 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -12,17 +12,17 @@ typedef AccountData = model.Account; model.AccountType _toModelAccountType(UiAccountType t) { switch (t) { case UiAccountType.asset: - return model.UiAccountType.asset; + return model.AccountType.asset; case UiAccountType.liability: - return model.UiAccountType.liability; + return model.AccountType.liability; } } UiAccountType _toUiAccountType(model.AccountType t) { switch (t) { - case model.UiAccountType.asset: + case model.AccountType.asset: return UiAccountType.asset; - case model.UiAccountType.liability: + case model.AccountType.liability: return UiAccountType.liability; } } From df049e01a757a4826d0714cbf36ffc670b1ad6df Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:03:48 +0800 Subject: [PATCH 08/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20r?= =?UTF-8?q?evert=20enum=20names=20to=20AccountType/AccountSubType;=20corre?= =?UTF-8?q?ct=20adapters=20to=20model.AccountType=20mapping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/accounts/account_list.dart | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index 4f82efd0..b6c07434 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -9,21 +9,21 @@ import 'package:jive_money/models/account.dart' as model; typedef AccountData = model.Account; // Model<->UI AccountType adapter - model.AccountType _toModelAccountType(UiAccountType t) { + model.AccountType _toModelAccountType(AccountType t) { switch (t) { - case UiAccountType.asset: + case AccountType.asset: return model.AccountType.asset; - case UiAccountType.liability: + case AccountType.liability: return model.AccountType.liability; } } - UiAccountType _toUiAccountType(model.AccountType t) { + AccountType _toAccountType(model.AccountType t) { switch (t) { case model.AccountType.asset: - return UiAccountType.asset; + return AccountType.asset; case model.AccountType.liability: - return UiAccountType.liability; + return AccountType.liability; } } @@ -175,8 +175,8 @@ class AccountList extends StatelessWidget { Widget _buildTotalSection(BuildContext context) { final theme = Theme.of(context); - final totalAssets = _calculateTotal(UiAccountType.asset); - final totalLiabilities = _calculateTotal(UiAccountType.liability); + final totalAssets = _calculateTotal(AccountType.asset); + final totalLiabilities = _calculateTotal(AccountType.liability); final netWorth = totalAssets - totalLiabilities; return Container( @@ -266,7 +266,7 @@ class AccountList extends StatelessWidget { } Widget _buildTypeHeader( - ThemeData theme, UiAccountType type, List accounts) { + ThemeData theme, AccountType type, List accounts) { final total = accounts.fold(0, (sum, account) => sum + account.balance); @@ -300,11 +300,11 @@ class AccountList extends StatelessWidget { ); } - Map> _groupAccountsByType() { - final Map> grouped = {}; + Map> _groupAccountsByType() { + final Map> grouped = {}; for (final account in accounts) { - final key = _toUiAccountType(account.type); + final key = _toAccountType(account.type); if (!grouped.containsKey(key)) { grouped[key] = []; } @@ -318,35 +318,35 @@ class AccountList extends StatelessWidget { ); } - double _calculateTotal(UiAccountType type) { + double _calculateTotal(AccountType type) { return accounts .where((account) => account.type == _toModelAccountType(type)) .fold(0.0, (sum, account) => sum + account.balance); } - IconData _getTypeIcon(UiAccountType type) { + IconData _getTypeIcon(AccountType type) { switch (type) { - case UiAccountType.asset: + case AccountType.asset: return Icons.account_balance_wallet; - case UiAccountType.liability: + case AccountType.liability: return Icons.credit_card; } } - Color _getTypeColor(UiAccountType type) { + Color _getTypeColor(AccountType type) { switch (type) { - case UiAccountType.asset: + case AccountType.asset: return AppConstants.successColor; - case UiAccountType.liability: + case AccountType.liability: return AppConstants.errorColor; } } - String _getTypeName(UiAccountType type) { + String _getTypeName(AccountType type) { switch (type) { - case UiAccountType.asset: + case AccountType.asset: return '资产账户'; - case UiAccountType.liability: + case AccountType.liability: return '负债账户'; } } @@ -360,13 +360,13 @@ class AccountList extends StatelessWidget { } /// 账户类型枚举 -enum UiAccountType { +enum AccountType { asset, // 资产 liability, // 负债 } /// 账户子类型枚举 -enum UiAccountSubType { +enum AccountSubType { // 资产子类型 cash, // 现金 debitCard, // 借记卡 From 8f5ca97c1d8b9f64f61090729ad042c6ab381e6b Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:05:27 +0800 Subject: [PATCH 09/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20m?= =?UTF-8?q?ove=20model<->UI=20AccountType=20adapters=20below=20enum=20decl?= =?UTF-8?q?arations=20to=20satisfy=20analyzer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/accounts/account_list.dart | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index b6c07434..41a6df64 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -8,26 +8,6 @@ import 'package:jive_money/models/account.dart' as model; // 类型别名以兼容现有代码 typedef AccountData = model.Account; - // Model<->UI AccountType adapter - model.AccountType _toModelAccountType(AccountType t) { - switch (t) { - case AccountType.asset: - return model.AccountType.asset; - case AccountType.liability: - return model.AccountType.liability; - } - } - - AccountType _toAccountType(model.AccountType t) { - switch (t) { - case model.AccountType.asset: - return AccountType.asset; - case model.AccountType.liability: - return AccountType.liability; - } - } - - class AccountList extends StatelessWidget { final List accounts; final bool groupByType; @@ -381,6 +361,28 @@ enum AccountSubType { mortgage, // 房贷 } + + // Model<->UI AccountType adapter (moved below enums for analyzer) +// Model<->UI AccountType adapter + model.AccountType _toModelAccountType(AccountType t) { + switch (t) { + case AccountType.asset: + return model.AccountType.asset; + case AccountType.liability: + return model.AccountType.liability; + } + } + + AccountType _toAccountType(model.AccountType t) { + switch (t) { + case model.AccountType.asset: + return AccountType.asset; + case model.AccountType.liability: + return AccountType.liability; + } + } + + /// 账户分组列表 class GroupedAccountList extends StatelessWidget { final Map> groupedAccounts; From bf23234d4afb61812141bcb5a2d463ac04470b8e Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:09:53 +0800 Subject: [PATCH 10/15] =?UTF-8?q?flutter:=20finalize=20batch10c=20?= =?UTF-8?q?=E2=80=94=20fix=20=5FtoUiAccountType=20call=20and=20const=20pad?= =?UTF-8?q?ding=20in=20SecondaryButton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/ui/components/accounts/account_list.dart | 4 ++-- jive-flutter/lib/ui/components/buttons/secondary_button.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index 41a6df64..48a5d127 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -284,7 +284,7 @@ class AccountList extends StatelessWidget { final Map> grouped = {}; for (final account in accounts) { - final key = _toAccountType(account.type); + final key = _toUiAccountType(account.type); if (!grouped.containsKey(key)) { grouped[key] = []; } @@ -373,7 +373,7 @@ enum AccountSubType { } } - AccountType _toAccountType(model.AccountType t) { + AccountType _toUiAccountType(model.AccountType t) { switch (t) { case model.AccountType.asset: return AccountType.asset; diff --git a/jive-flutter/lib/ui/components/buttons/secondary_button.dart b/jive-flutter/lib/ui/components/buttons/secondary_button.dart index e6759bad..21738eac 100644 --- a/jive-flutter/lib/ui/components/buttons/secondary_button.dart +++ b/jive-flutter/lib/ui/components/buttons/secondary_button.dart @@ -40,7 +40,7 @@ class SecondaryButton extends StatelessWidget { onPressed: isEnabled ? onPressed : null, style: OutlinedButton.styleFrom( foregroundColor: textColor ?? theme.primaryColor, - padding: padding ?? EdgeInsets.symmetric(horizontal: 24), + padding: padding ?? const EdgeInsets.symmetric(horizontal: 24), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppConstants.borderRadius), ), From adb1ff117d847bf3de704049a6a9cbd24a180923 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:22:00 +0800 Subject: [PATCH 11/15] chore: whitespace touch to invalidate analyzer cache in account_list adapters From b2af2b8f17235858d5f8be922e592bbab8f1a143 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:37:17 +0800 Subject: [PATCH 12/15] =?UTF-8?q?flutter:=20account=5Flist=20=E2=80=94=20r?= =?UTF-8?q?obust=20model=E2=86=92local=20type=20mapping=20(creditCard/loan?= =?UTF-8?q?=20=3D>=20liability;=20others=20=3D>=20asset)=20and=20total=20f?= =?UTF-8?q?ilter=20by=20matcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/accounts/account_list.dart | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/jive-flutter/lib/ui/components/accounts/account_list.dart b/jive-flutter/lib/ui/components/accounts/account_list.dart index 48a5d127..73bc1a40 100644 --- a/jive-flutter/lib/ui/components/accounts/account_list.dart +++ b/jive-flutter/lib/ui/components/accounts/account_list.dart @@ -300,7 +300,7 @@ class AccountList extends StatelessWidget { double _calculateTotal(AccountType type) { return accounts - .where((account) => account.type == _toModelAccountType(type)) + .where((account) => _matchesLocalType(type, account.type)) .fold(0.0, (sum, account) => sum + account.balance); } @@ -362,26 +362,24 @@ enum AccountSubType { } - // Model<->UI AccountType adapter (moved below enums for analyzer) -// Model<->UI AccountType adapter - model.AccountType _toModelAccountType(AccountType t) { - switch (t) { - case AccountType.asset: - return model.AccountType.asset; - case AccountType.liability: - return model.AccountType.liability; - } - } - + // Model<->UI AccountType adapter + // Map model.AccountType (checking/savings/creditCard/loan/...) to local grouping (asset/liability) AccountType _toUiAccountType(model.AccountType t) { switch (t) { - case model.AccountType.asset: - return AccountType.asset; - case model.AccountType.liability: + case model.AccountType.creditCard: + case model.AccountType.loan: return AccountType.liability; + default: + return AccountType.asset; } } + bool _matchesLocalType(AccountType localType, model.AccountType modelType) { + final isLiability = modelType == model.AccountType.creditCard || modelType == model.AccountType.loan; + if (localType == AccountType.liability) return isLiability; + return !isLiability; + } + /// 账户分组列表 class GroupedAccountList extends StatelessWidget { From 4c046f07269fe1be0c31e00204ec200b48242c37 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:39:49 +0800 Subject: [PATCH 13/15] =?UTF-8?q?flutter:=20share=5Fservice=20=E2=80=94=20?= =?UTF-8?q?unify=20on=20SharePlus.instance.share(ShareParams);=20keep=20?= =?UTF-8?q?=5FdoShare=20hook=20for=20tests;=20replace=20final=20Share.shar?= =?UTF-8?q?e=20usage=20in=20ShareDialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/services/share_service.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jive-flutter/lib/services/share_service.dart b/jive-flutter/lib/services/share_service.dart index bfc469a7..dc64637b 100644 --- a/jive-flutter/lib/services/share_service.dart +++ b/jive-flutter/lib/services/share_service.dart @@ -461,7 +461,7 @@ class ShareDialog extends StatelessWidget { color: theme.colorScheme.primary, onPressed: onShareMore ?? () async { - await Share.share('$content\n\n$url'); + await SharePlus.instance.share(ShareParams(text: '$content\n\n${url ?? ''}')); if (context.mounted) { Navigator.pop(context); } From 905fc014de8b6b57419399eecdb73bda00734e9a Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:48:24 +0800 Subject: [PATCH 14/15] =?UTF-8?q?flutter:=20share=5Fservice=20=E2=80=94=20?= =?UTF-8?q?micro=20cleanups=20(pre-capture=20messenger,=20ignore=20annotat?= =?UTF-8?q?ions,=20remove=20unused=20locals=20warnings)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/services/share_service.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jive-flutter/lib/services/share_service.dart b/jive-flutter/lib/services/share_service.dart index dc64637b..e68df552 100644 --- a/jive-flutter/lib/services/share_service.dart +++ b/jive-flutter/lib/services/share_service.dart @@ -83,17 +83,19 @@ Jive Money - 您的智能家庭财务管家 '''; try { + // 预先捕获 messenger,避免上下文跨 await 警告 + final messenger = ScaffoldMessenger.of(context); if (chartWidget != null) { // 生成图表截图 // Note: screenshot functionality is stubbed during analyzer cleanup - final image = null; + final image = null; // ignore: prefer_const_declarations, unused_local_variable // 保存图片 final directory = await getTemporaryDirectory(); final imagePath = '${directory.path}/statistics_${DateTime.now().millisecondsSinceEpoch}.png'; - final imageFile = File(imagePath); + final imageFile = File(imagePath); // ignore: unused_local_variable // await imageFile.writeAsBytes(image); // 分享图片和文字 @@ -102,6 +104,8 @@ Jive Money - 您的智能家庭财务管家 // 仅分享文字 await _doShare(ShareParams(text: shareText)); if (!context.mounted) return; + // ignore: use_build_context_synchronously + messenger.hideCurrentSnackBar(); } } catch (e) { _showError(context, '分享失败: $e'); @@ -154,7 +158,9 @@ ${transaction.note?.isNotEmpty == true ? '📝 备注:${transaction.note}' : ' try { await Clipboard.setData(ClipboardData(text: text)); if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( + final messenger = ScaffoldMessenger.of(context); + // ignore: use_build_context_synchronously + messenger.showSnackBar( SnackBar( content: Text(message ?? '已复制到剪贴板'), duration: const Duration(seconds: 2), From 959e66ad6fa75bbf8b7a2cc56a0eeebc904defb6 Mon Sep 17 00:00:00 2001 From: zensgit <77236085+zensgit@users.noreply.github.com> Date: Tue, 30 Sep 2025 21:51:33 +0800 Subject: [PATCH 15/15] =?UTF-8?q?flutter:=20share=5Fservice=20=E2=80=94=20?= =?UTF-8?q?prune=20unused=20stubs=20(=5FshareToWechat,=20=5FStubXFile)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jive-flutter/lib/services/share_service.dart | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/jive-flutter/lib/services/share_service.dart b/jive-flutter/lib/services/share_service.dart index e68df552..ca85c6c1 100644 --- a/jive-flutter/lib/services/share_service.dart +++ b/jive-flutter/lib/services/share_service.dart @@ -257,12 +257,7 @@ $data } /// 分享到微信(需要集成微信SDK) - static Future _shareToWechat( - BuildContext context, String content) async { - // Stub: 使用系统分享 - await _doShare(ShareParams(text: content)); - } - + static String _getRoleDisplayName(family_model.FamilyRole role) { switch (role) { case family_model.FamilyRole.owner: @@ -550,7 +545,3 @@ class _StubScreenshotController { } } -class _StubXFile { - final String path; - _StubXFile(this.path); -}