diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index 8744e1980..059e943ba 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -10,6 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../../app_config.dart'; import '../../../providers/providers.dart'; import '../../../themes/stack_colors.dart'; import '../../../utilities/text_styles.dart'; @@ -86,55 +88,57 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> { ), ), ), - const SizedBox( - width: 8, - ), - Expanded( - child: TextButton( - style: selectedIndex == 1 - ? Theme.of(context) - .extension<StackColors>()! - .getPrimaryEnabledButtonStyle(context)! - .copyWith( - minimumSize: - MaterialStateProperty.all<Size>(const Size(46, 36)), - ) - : Theme.of(context) - .extension<StackColors>()! - .getSecondaryEnabledButtonStyle(context)! - .copyWith( - minimumSize: - MaterialStateProperty.all<Size>(const Size(46, 36)), - ), - onPressed: () async { - FocusScope.of(context).unfocus(); - if (selectedIndex != 1) { - ref.read(homeViewPageIndexStateProvider.state).state = 1; - } - // DateTime now = DateTime.now(); - // if (ref.read(prefsChangeNotifierProvider).externalCalls) { - // print("loading?"); - // await ExchangeDataLoadingService().loadAll(ref); - // } - // if (now.difference(_lastRefreshed) > _refreshInterval) { - // await ExchangeDataLoadingService().loadAll(ref); - // } - }, - child: Text( - "Swap", - style: STextStyles.button(context).copyWith( - fontSize: 14, - color: selectedIndex == 1 - ? Theme.of(context) - .extension<StackColors>()! - .buttonTextPrimary - : Theme.of(context) - .extension<StackColors>()! - .buttonTextSecondary, + if (AppConfig.hasFeature(AppFeature.swap)) + const SizedBox( + width: 8, + ), + if (AppConfig.hasFeature(AppFeature.swap)) + Expanded( + child: TextButton( + style: selectedIndex == 1 + ? Theme.of(context) + .extension<StackColors>()! + .getPrimaryEnabledButtonStyle(context)! + .copyWith( + minimumSize: + MaterialStateProperty.all<Size>(const Size(46, 36)), + ) + : Theme.of(context) + .extension<StackColors>()! + .getSecondaryEnabledButtonStyle(context)! + .copyWith( + minimumSize: + MaterialStateProperty.all<Size>(const Size(46, 36)), + ), + onPressed: () async { + FocusScope.of(context).unfocus(); + if (selectedIndex != 1) { + ref.read(homeViewPageIndexStateProvider.state).state = 1; + } + // DateTime now = DateTime.now(); + // if (ref.read(prefsChangeNotifierProvider).externalCalls) { + // print("loading?"); + // await ExchangeDataLoadingService().loadAll(ref); + // } + // if (now.difference(_lastRefreshed) > _refreshInterval) { + // await ExchangeDataLoadingService().loadAll(ref); + // } + }, + child: Text( + "Swap", + style: STextStyles.button(context).copyWith( + fontSize: 14, + color: selectedIndex == 1 + ? Theme.of(context) + .extension<StackColors>()! + .buttonTextPrimary + : Theme.of(context) + .extension<StackColors>()! + .buttonTextSecondary, + ), ), ), ), - ), const SizedBox( width: 8, ), diff --git a/lib/pages/token_view/sub_widgets/token_summary.dart b/lib/pages/token_view/sub_widgets/token_summary.dart index d20662eb4..c14c6d90f 100644 --- a/lib/pages/token_view/sub_widgets/token_summary.dart +++ b/lib/pages/token_view/sub_widgets/token_summary.dart @@ -14,12 +14,10 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:tuple/tuple.dart'; + +import '../../../app_config.dart'; import '../../../models/isar/models/ethereum/eth_contract.dart'; -import '../../buy_view/buy_in_wallet_view.dart'; -import '../../exchange_view/wallet_initiated_exchange_view.dart'; -import '../../receive_view/receive_view.dart'; -import '../../send_view/token_send_view.dart'; -import '../../wallet_view/sub_widgets/wallet_refresh_button.dart'; import '../../../providers/global/locale_provider.dart'; import '../../../providers/global/prefs_provider.dart'; import '../../../providers/global/price_provider.dart'; @@ -37,7 +35,11 @@ import '../../../wallets/isar/providers/eth/token_balance_provider.dart'; import '../../../wallets/isar/providers/wallet_info_provider.dart'; import '../../../widgets/conditional_parent.dart'; import '../../../widgets/rounded_container.dart'; -import 'package:tuple/tuple.dart'; +import '../../buy_view/buy_in_wallet_view.dart'; +import '../../exchange_view/wallet_initiated_exchange_view.dart'; +import '../../receive_view/receive_view.dart'; +import '../../send_view/token_send_view.dart'; +import '../../wallet_view/sub_widgets/wallet_refresh_button.dart'; class TokenSummary extends ConsumerWidget { const TokenSummary({ @@ -249,18 +251,20 @@ class TokenWalletOptions extends ConsumerWidget { subLabel: "Send", iconAssetPathSVG: Assets.svg.arrowUpRight, ), - const SizedBox( - width: 16, - ), - TokenOptionsButton( - onPressed: () => _onExchangePressed(context), - subLabel: "Swap", - iconAssetPathSVG: ref.watch( - themeProvider.select( - (value) => value.assets.exchange, + if (AppConfig.hasFeature(AppFeature.swap)) + const SizedBox( + width: 16, + ), + if (AppConfig.hasFeature(AppFeature.swap)) + TokenOptionsButton( + onPressed: () => _onExchangePressed(context), + subLabel: "Swap", + iconAssetPathSVG: ref.watch( + themeProvider.select( + (value) => value.assets.exchange, + ), ), ), - ), const SizedBox( width: 16, ), diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 7147ca299..e131c49aa 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -16,31 +16,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; +import 'package:tuple/tuple.dart'; + +import '../../app_config.dart'; import '../../frost_route_generator.dart'; import '../../models/isar/exchange_cache/currency.dart'; import '../../notifications/show_flush_bar.dart'; -import '../buy_view/buy_in_wallet_view.dart'; -import '../cashfusion/cashfusion_view.dart'; -import '../coin_control/coin_control_view.dart'; -import '../exchange_view/wallet_initiated_exchange_view.dart'; -import '../home_view/home_view.dart'; -import '../monkey/monkey_view.dart'; -import '../notification_views/notifications_view.dart'; -import '../ordinals/ordinals_view.dart'; -import '../paynym/paynym_claim_view.dart'; -import '../paynym/paynym_home_view.dart'; -import '../receive_view/receive_view.dart'; -import '../send_view/frost_ms/frost_send_view.dart'; -import '../send_view/send_view.dart'; -import '../settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; -import '../settings_views/wallet_settings_view/wallet_settings_view.dart'; -import '../special/firo_rescan_recovery_error_dialog.dart'; -import '../token_view/my_tokens_view.dart'; -import 'sub_widgets/transactions_list.dart'; -import 'sub_widgets/wallet_summary.dart'; -import 'transaction_views/all_transactions_view.dart'; -import 'transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'transaction_views/tx_v2/transaction_v2_list.dart'; import '../../providers/global/active_wallet_provider.dart'; import '../../providers/global/auto_swb_service_provider.dart'; import '../../providers/global/paynym_api_provider.dart'; @@ -95,7 +76,28 @@ import '../../widgets/wallet_navigation_bar/components/icons/receive_nav_icon.da import '../../widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart'; import '../../widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart'; import '../../widgets/wallet_navigation_bar/wallet_navigation_bar.dart'; -import 'package:tuple/tuple.dart'; +import '../buy_view/buy_in_wallet_view.dart'; +import '../cashfusion/cashfusion_view.dart'; +import '../coin_control/coin_control_view.dart'; +import '../exchange_view/wallet_initiated_exchange_view.dart'; +import '../home_view/home_view.dart'; +import '../monkey/monkey_view.dart'; +import '../notification_views/notifications_view.dart'; +import '../ordinals/ordinals_view.dart'; +import '../paynym/paynym_claim_view.dart'; +import '../paynym/paynym_home_view.dart'; +import '../receive_view/receive_view.dart'; +import '../send_view/frost_ms/frost_send_view.dart'; +import '../send_view/send_view.dart'; +import '../settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; +import '../settings_views/wallet_settings_view/wallet_settings_view.dart'; +import '../special/firo_rescan_recovery_error_dialog.dart'; +import '../token_view/my_tokens_view.dart'; +import 'sub_widgets/transactions_list.dart'; +import 'sub_widgets/wallet_summary.dart'; +import 'transaction_views/all_transactions_view.dart'; +import 'transaction_views/tx_v2/all_transactions_v2_view.dart'; +import 'transaction_views/tx_v2/transaction_v2_list.dart'; /// [eventBus] should only be set during testing class WalletView extends ConsumerStatefulWidget { @@ -1059,7 +1061,8 @@ class _WalletViewState extends ConsumerState<WalletView> { }, ), if (Constants.enableExchange && - ref.watch(pWalletCoin(walletId)) is! FrostCurrency) + ref.watch(pWalletCoin(walletId)) is! FrostCurrency && + AppConfig.hasFeature(AppFeature.swap)) WalletNavigationBarItemData( label: "Swap", icon: const ExchangeNavIcon(), diff --git a/lib/pages_desktop_specific/desktop_menu.dart b/lib/pages_desktop_specific/desktop_menu.dart index 868454541..9d7df1ad2 100644 --- a/lib/pages_desktop_specific/desktop_menu.dart +++ b/lib/pages_desktop_specific/desktop_menu.dart @@ -14,15 +14,16 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; + import '../app_config.dart'; -import 'desktop_menu_item.dart'; -import 'settings/settings_menu.dart'; import '../providers/desktop/current_desktop_menu_item.dart'; import '../themes/stack_colors.dart'; import '../utilities/assets.dart'; import '../utilities/text_styles.dart'; import '../widgets/desktop/desktop_tor_status_button.dart'; import '../widgets/desktop/living_stack_icon.dart'; +import 'desktop_menu_item.dart'; +import 'settings/settings_menu.dart'; enum DesktopMenuItemId { myStack, @@ -186,17 +187,19 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> { onChanged: updateSelectedMenuItem, controller: controllers[0], ), - const SizedBox( - height: 2, - ), - DesktopMenuItem( - duration: duration, - icon: const DesktopExchangeIcon(), - label: "Swap", - value: DesktopMenuItemId.exchange, - onChanged: updateSelectedMenuItem, - controller: controllers[1], - ), + if (AppConfig.hasFeature(AppFeature.swap)) + const SizedBox( + height: 2, + ), + if (AppConfig.hasFeature(AppFeature.swap)) + DesktopMenuItem( + duration: duration, + icon: const DesktopExchangeIcon(), + label: "Swap", + value: DesktopMenuItemId.exchange, + onChanged: updateSelectedMenuItem, + controller: controllers[1], + ), const SizedBox( height: 2, ), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index 2fa0ee1eb..ce47d8b1e 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -15,16 +15,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; + +import '../../../../app_config.dart'; import '../../../../notifications/show_flush_bar.dart'; import '../../../../pages/monkey/monkey_view.dart'; import '../../../../pages/paynym/paynym_claim_view.dart'; import '../../../../pages/paynym/paynym_home_view.dart'; -import '../../../cashfusion/desktop_cashfusion_view.dart'; -import '../../../coin_control/desktop_coin_control_view.dart'; -import '../../../desktop_menu.dart'; -import '../desktop_wallet_view.dart'; -import 'more_features/more_features_dialog.dart'; -import '../../../ordinals/desktop_ordinals_view.dart'; import '../../../../providers/desktop/current_desktop_menu_item.dart'; import '../../../../providers/global/paynym_api_provider.dart'; import '../../../../providers/providers.dart'; @@ -48,6 +44,12 @@ import '../../../../widgets/desktop/desktop_dialog.dart'; import '../../../../widgets/desktop/primary_button.dart'; import '../../../../widgets/desktop/secondary_button.dart'; import '../../../../widgets/loading_indicator.dart'; +import '../../../cashfusion/desktop_cashfusion_view.dart'; +import '../../../coin_control/desktop_coin_control_view.dart'; +import '../../../desktop_menu.dart'; +import '../../../ordinals/desktop_ordinals_view.dart'; +import '../desktop_wallet_view.dart'; +import 'more_features/more_features_dialog.dart'; class DesktopWalletFeatures extends ConsumerStatefulWidget { const DesktopWalletFeatures({ @@ -366,7 +368,7 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> { return Row( children: [ - if (Constants.enableExchange) + if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.swap)) SecondaryButton( label: "Swap", width: buttonWidth,