diff --git a/lib/new-ui/widgets/coins_page/assets_history/assets_history_section.dart b/lib/new-ui/widgets/coins_page/assets_history/assets_history_section.dart index 998ebc137..e57f46c79 100644 --- a/lib/new-ui/widgets/coins_page/assets_history/assets_history_section.dart +++ b/lib/new-ui/widgets/coins_page/assets_history/assets_history_section.dart @@ -43,6 +43,7 @@ class _AssetsHistorySectionState extends State { S.current.history, HistorySection( dashboardViewModel: widget.dashboardViewModel, + short: true, )), if (isNFTACtivatedChain(widget.dashboardViewModel.wallet.type, chainId: widget.dashboardViewModel.wallet.chainId)) diff --git a/lib/new-ui/widgets/coins_page/assets_history/history_section.dart b/lib/new-ui/widgets/coins_page/assets_history/history_section.dart index 32d99020b..e4ecd6230 100644 --- a/lib/new-ui/widgets/coins_page/assets_history/history_section.dart +++ b/lib/new-ui/widgets/coins_page/assets_history/history_section.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/new-ui/widgets/coins_page/assets_history/anonpay_history_tile.dart'; @@ -22,16 +24,19 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:intl/intl.dart'; class HistorySection extends StatelessWidget { - const HistorySection({super.key, required this.dashboardViewModel}); + const HistorySection({super.key, required this.dashboardViewModel, required this.short}); final DashboardViewModel dashboardViewModel; + final bool short; @override Widget build(BuildContext context) { + final items = short ? dashboardViewModel.itemsShort : dashboardViewModel.items; + return SliverPadding( padding: const EdgeInsets.symmetric(horizontal: 16.0), sliver: Observer( - builder: (_) => (dashboardViewModel.items.isEmpty) + builder: (_) => (items.isEmpty) ? SliverPadding( padding: EdgeInsets.only(top: 24), sliver: SliverToBoxAdapter( @@ -48,14 +53,14 @@ class HistorySection extends StatelessWidget { ) : SliverList( delegate: SliverChildBuilderDelegate( - childCount: dashboardViewModel.items.length, + childCount: items.length, (context, index) => Observer(builder: (_) { - final prevItem = index == 0 ? null : dashboardViewModel.items[index - 1]; + final prevItem = index == 0 ? null : items[index - 1]; final topPadding = index == 0 ? 0.0 : 18.0; - final item = dashboardViewModel.items[index]; - final nextItem = index == dashboardViewModel.items.length - 1 + final item = items[index]; + final nextItem = index == items.length - 1 ? null - : dashboardViewModel.items[index + 1]; + : items[index + 1]; final roundedBottom = (nextItem == null || nextItem is DateSectionItem); final roundedTop = (prevItem == null || prevItem is DateSectionItem); diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index d97d119a4..1a2e476e0 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -5,6 +5,7 @@ import 'dart:io' show Platform; import 'package:cake_wallet/.secrets.g.dart' as secrets; import 'package:cake_wallet/bitcoin/bitcoin.dart'; import 'package:cake_wallet/core/key_service.dart'; +import 'package:cake_wallet/view_model/dashboard/date_section_item.dart'; import "package:cw_core/balance_card_style_settings.dart"; import 'package:cake_wallet/core/trade_monitor.dart'; import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart'; @@ -715,6 +716,11 @@ abstract class DashboardViewModelBase with Store { return formattedItemsList(_items); } + static const shortHistoryLength = 3; + + @computed + List get itemsShort => items.where((item)=>item is! DateSectionItem).take(3).toList(); + @observable WalletBase, TransactionInfo> wallet;