diff --git a/lib/new-ui/widgets/coins_page/assets_history/history_filters_page.dart b/lib/new-ui/widgets/coins_page/assets_history/history_filters_page.dart index 072f11015..a42edeb68 100644 --- a/lib/new-ui/widgets/coins_page/assets_history/history_filters_page.dart +++ b/lib/new-ui/widgets/coins_page/assets_history/history_filters_page.dart @@ -55,7 +55,7 @@ class HistoryFiltersPage extends StatelessWidget { if (dashboardViewModel.tradeFilterStore.displayAllTrades) { subtitle = S.of(context).manage_providers; subtitleColor = Theme.of(context).colorScheme.onSurfaceVariant; - } else if (dashboardViewModel.tradeFilterStore.enabledProviders == 0) { + } else if (dashboardViewModel.tradeFilterStore.enabledProvidersCount == 0) { subtitle = S.of(context).no_providers_selected; subtitleColor = Color(0xFFFFB84E); } else { @@ -74,10 +74,10 @@ class HistoryFiltersPage extends StatelessWidget { value: item.value(), onChanged: (val) { if ((val && - dashboardViewModel.tradeFilterStore.enabledProviders == + dashboardViewModel.tradeFilterStore.enabledProvidersCount == 0) || (!val && - dashboardViewModel.tradeFilterStore.enabledProviders > + dashboardViewModel.tradeFilterStore.enabledProvidersCount > 0)) { dashboardViewModel.tradeFilterStore .toggleDisplayExchange(ExchangeProviderDescription.all); 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 2bdd715ac..f6bab4488 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 @@ -56,153 +56,156 @@ class HistorySection extends StatelessWidget { ), ), ) - : SliverList( - delegate: SliverChildBuilderDelegate( - childCount: items.length, - (context, index) => Observer(builder: (_) { - final prevItem = index == 0 ? null : items[index - 1]; - final topPadding = index == 0 ? 0.0 : 18.0; - final item = items[index]; - final nextItem = index == items.length - 1 - ? null - : items[index + 1]; + : SliverPadding( + padding: EdgeInsets.only(bottom: short ? 0 : 144), + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + childCount: items.length, + (context, index) => Observer(builder: (_) { + final prevItem = index == 0 ? null : items[index - 1]; + final topPadding = index == 0 ? 0.0 : 18.0; + final item = items[index]; + final nextItem = index == items.length - 1 + ? null + : items[index + 1]; - final roundedBottom = (nextItem == null || nextItem is DateSectionItem); - final roundedTop = roundedTopSection && (prevItem == null || prevItem is DateSectionItem); + final roundedBottom = (nextItem == null || nextItem is DateSectionItem); + final roundedTop = roundedTopSection && (prevItem == null || prevItem is DateSectionItem); - if (item is TransactionListItem) { - final transaction = item.transaction; - final transactionType = dashboardViewModel.getTransactionType(transaction); + if (item is TransactionListItem) { + final transaction = item.transaction; + final transactionType = dashboardViewModel.getTransactionType(transaction); - if (item.hasTokens && item.assetOfTransaction == null) { - return Container(); - } + if (item.hasTokens && item.assetOfTransaction == null) { + return Container(); + } - CryptoCurrency? asset; - if (transaction.additionalInfo["isLightning"] == true) - asset = CryptoCurrency.btcln; - else - asset = item.assetOfTransaction; + CryptoCurrency? asset; + if (transaction.additionalInfo["isLightning"] == true) + asset = CryptoCurrency.btcln; + else + asset = item.assetOfTransaction; - return GestureDetector( - onTap: () { - final page = getIt.get(param1: transaction); - if (detailsAsPage) { - Navigator.of(context).push( - CupertinoPageRoute(builder: (context) => Material(child: page))); - } else { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (context) => - FractionallySizedBox(heightFactor: 0.9, child: page)); - } - }, - child: HistoryTile( - title: item.formattedTitle + transactionType, - date: _formatTransactionDate(item.date, localeName), - amount: item.formattedCryptoAmount, - amountFiat: item.formattedFiatAmount, - hasTokens: item.hasTokens, - chainIconPath: _getChainIconPath(), - roundedBottom: roundedBottom, - roundedTop: roundedTop, - bottomSeparator: !roundedBottom, - direction: item.transaction.direction, - pending: item.transaction.isPending, - asset: asset, - ), - ); - } else if (item is TradeListItem) { - final trade = item.trade; - final tradeFrom = trade.from; - final tradeTo = trade.to; - - return GestureDetector( - onTap: () => Navigator.of(context) - .pushNamed(Routes.tradeDetails, arguments: trade), - child: HistoryTradeTile( - from: tradeFrom, - to: tradeTo, - provider: trade.provider, - date: _formatTransactionDate(item.trade.createdAt ?? DateTime.now(), localeName), - amount: dashboardViewModel.balanceDisplayMode == BalanceDisplayMode.hiddenBalance ? "---" : trade.amountFormatted(), - receiveAmount: dashboardViewModel.balanceDisplayMode == BalanceDisplayMode.hiddenBalance ? "---" : trade.receiveAmountFormatted(), - roundedBottom: roundedBottom, - roundedTop: roundedTop, - bottomSeparator: !roundedBottom, - swapState: trade.state, - ), - ); - } else if (item is SpecificDateSectionItem) { - return Padding( - padding: EdgeInsets.only(left: 8.0, bottom: 8.0, top: topPadding), - child: Text(item.text, - style: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant))); - } else if (item is DateSectionItem) { - return Padding( - padding: EdgeInsets.only(left: 8.0, bottom: 8.0, top: topPadding), - child: Text(DateFormat("MMMM yyyy", localeName).format(item.date), - style: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant))); - } else if (item is OrderListItem) { - return GestureDetector( - onTap: () => Navigator.of(context) - .pushNamed(Routes.orderDetails, arguments: item.order), - child: HistoryOrderTile( - date: _formatTransactionDate(item.order.createdAt, localeName), - amount: item.orderFormattedAmount, - amountFiat: "", - roundedBottom: roundedBottom, - roundedTop: roundedTop, - bottomSeparator: !roundedBottom, - ), - ); - } else if (item is PayjoinTransactionListItem) { - final session = item.session; - - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - Routes.payjoinDetails, - arguments: [item.sessionId, item.transaction], - ), - child: PayjoinHistoryTile( - createdAt: _formatTransactionDate(session.inProgressSince!, localeName), - amount: dashboardViewModel.appStore.amountParsingProxy - .asDisplayString(Money( - session.amount, CryptoCurrency.btc)), - currency: item.transaction?.from ?? "BTC", - state: item.status, - isSending: session.isSenderSession, - roundedTop: roundedTop, + return GestureDetector( + onTap: () { + final page = getIt.get(param1: transaction); + if (detailsAsPage) { + Navigator.of(context).push( + CupertinoPageRoute(builder: (context) => Material(child: page))); + } else { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (context) => + FractionallySizedBox(heightFactor: 0.9, child: page)); + } + }, + child: HistoryTile( + title: item.formattedTitle + transactionType, + date: _formatTransactionDate(item.date, localeName), + amount: item.formattedCryptoAmount, + amountFiat: item.formattedFiatAmount, + hasTokens: item.hasTokens, + chainIconPath: _getChainIconPath(), roundedBottom: roundedBottom, - bottomSeparator: !roundedBottom), - ); - } else if (item is AnonpayTransactionListItem) { - final transactionInfo = item.transaction; + roundedTop: roundedTop, + bottomSeparator: !roundedBottom, + direction: item.transaction.direction, + pending: item.transaction.isPending, + asset: asset, + ), + ); + } else if (item is TradeListItem) { + final trade = item.trade; + final tradeFrom = trade.from; + final tradeTo = trade.to; - return GestureDetector( + return GestureDetector( onTap: () => Navigator.of(context) - .pushNamed(Routes.anonPayDetailsPage, arguments: transactionInfo), - child: AnonpayHistoryTile( - provider: transactionInfo.provider, - createdAt: _formatTransactionDate(transactionInfo.createdAt, localeName), - amount: transactionInfo.fiatAmount?.toString() ?? - (transactionInfo.amountTo?.toString() ?? ''), - currency: transactionInfo.fiatAmount != null - ? transactionInfo.fiatEquiv ?? '' - : CryptoCurrency.fromFullName(transactionInfo.coinTo) - .name - .toUpperCase(), + .pushNamed(Routes.tradeDetails, arguments: trade), + child: HistoryTradeTile( + from: tradeFrom, + to: tradeTo, + provider: trade.provider, + date: _formatTransactionDate(item.trade.createdAt ?? DateTime.now(), localeName), + amount: dashboardViewModel.balanceDisplayMode == BalanceDisplayMode.hiddenBalance ? "---" : trade.amountFormatted(), + receiveAmount: dashboardViewModel.balanceDisplayMode == BalanceDisplayMode.hiddenBalance ? "---" : trade.receiveAmountFormatted(), + roundedBottom: roundedBottom, + roundedTop: roundedTop, + bottomSeparator: !roundedBottom, + swapState: trade.state, + ), + ); + } else if (item is SpecificDateSectionItem) { + return Padding( + padding: EdgeInsets.only(left: 8.0, bottom: 8.0, top: topPadding), + child: Text(item.text, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant))); + } else if (item is DateSectionItem) { + return Padding( + padding: EdgeInsets.only(left: 8.0, bottom: 8.0, top: topPadding), + child: Text(DateFormat("MMMM yyyy", localeName).format(item.date), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant))); + } else if (item is OrderListItem) { + return GestureDetector( + onTap: () => Navigator.of(context) + .pushNamed(Routes.orderDetails, arguments: item.order), + child: HistoryOrderTile( + date: _formatTransactionDate(item.order.createdAt, localeName), + amount: item.orderFormattedAmount, + amountFiat: "", + roundedBottom: roundedBottom, + roundedTop: roundedTop, + bottomSeparator: !roundedBottom, + ), + ); + } else if (item is PayjoinTransactionListItem) { + final session = item.session; + + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.payjoinDetails, + arguments: [item.sessionId, item.transaction], + ), + child: PayjoinHistoryTile( + createdAt: _formatTransactionDate(session.inProgressSince!, localeName), + amount: dashboardViewModel.appStore.amountParsingProxy + .asDisplayString(Money( + session.amount, CryptoCurrency.btc)), + currency: item.transaction?.from ?? "BTC", + state: item.status, + isSending: session.isSenderSession, roundedTop: roundedTop, roundedBottom: roundedBottom, - bottomSeparator: !roundedBottom)); - } else - return Text(item.runtimeType.toString()); - }), + bottomSeparator: !roundedBottom), + ); + } else if (item is AnonpayTransactionListItem) { + final transactionInfo = item.transaction; + + return GestureDetector( + onTap: () => Navigator.of(context) + .pushNamed(Routes.anonPayDetailsPage, arguments: transactionInfo), + child: AnonpayHistoryTile( + provider: transactionInfo.provider, + createdAt: _formatTransactionDate(transactionInfo.createdAt, localeName), + amount: transactionInfo.fiatAmount?.toString() ?? + (transactionInfo.amountTo?.toString() ?? ''), + currency: transactionInfo.fiatAmount != null + ? transactionInfo.fiatEquiv ?? '' + : CryptoCurrency.fromFullName(transactionInfo.coinTo) + .name + .toUpperCase(), + roundedTop: roundedTop, + roundedBottom: roundedBottom, + bottomSeparator: !roundedBottom)); + } else + return Text(item.runtimeType.toString()); + }), + ), ), - ); + ); }, )); } diff --git a/lib/new-ui/widgets/coins_page/assets_history/history_swap_providers_page.dart b/lib/new-ui/widgets/coins_page/assets_history/history_swap_providers_page.dart index 1010e4c4a..46de3fb36 100644 --- a/lib/new-ui/widgets/coins_page/assets_history/history_swap_providers_page.dart +++ b/lib/new-ui/widgets/coins_page/assets_history/history_swap_providers_page.dart @@ -42,9 +42,9 @@ class HistorySwapProvidersPage extends StatelessWidget { title: S.of(context).swap_providers, onSelected: (val) { if ((val && - dashboardViewModel.tradeFilterStore.enabledProviders == 0) || + dashboardViewModel.tradeFilterStore.enabledProvidersCount == 0) || (!val && - dashboardViewModel.tradeFilterStore.enabledProviders > 0)) { + dashboardViewModel.tradeFilterStore.enabledProvidersCount > 0)) { dashboardViewModel.tradeFilterStore .toggleDisplayExchange(ExchangeProviderDescription.all); } diff --git a/lib/store/dashboard/trade_filter_store.dart b/lib/store/dashboard/trade_filter_store.dart index 2fee9cc70..57e3149ee 100644 --- a/lib/store/dashboard/trade_filter_store.dart +++ b/lib/store/dashboard/trade_filter_store.dart @@ -70,7 +70,7 @@ abstract class TradeFilterStoreBase with Store { bool displayNearIntents; @computed - int get enabledProviders => [ + int get enabledProvidersCount => [ displayChangeNow, displaySideShift, displaySimpleSwap, diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 8bdb6d4e9..77c59b762 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -274,9 +274,9 @@ abstract class DashboardViewModelBase with Store { onChanged: transactionFilterStore.toggleSilentPayments, ), SwapFilterItem( - enabledProviders: () => tradeFilterStore.enabledProviders, + enabledProviders: () => tradeFilterStore.enabledProvidersCount, allEnabled: () => tradeFilterStore.displayAllTrades, - value: () => tradeFilterStore.enabledProviders>0, + value: () => tradeFilterStore.enabledProvidersCount>0, onChanged: () => tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.all)), FilterItem(