hide swap and buy buttons around the ui

and const keys
This commit is contained in:
sneurlax 2024-07-02 22:41:00 -05:00
parent 1e9775eded
commit 2b2127aeb5
5 changed files with 43 additions and 24 deletions

View file

@ -44,8 +44,10 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
@override
Widget build(BuildContext context) {
//todo: check if print needed
// debugPrint("BUILD: HomeViewButtonBar");
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final selectedIndex = ref.watch(homeViewPageIndexStateProvider.state).state;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -88,11 +90,11 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
),
),
),
if (AppConfig.hasFeature(AppFeature.swap))
if (AppConfig.hasFeature(AppFeature.swap) && showExchange)
const SizedBox(
width: 8,
),
if (AppConfig.hasFeature(AppFeature.swap))
if (AppConfig.hasFeature(AppFeature.swap) && showExchange)
Expanded(
child: TextButton(
style: selectedIndex == 1
@ -139,11 +141,11 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
),
),
),
if (AppConfig.hasFeature(AppFeature.buy))
if (AppConfig.hasFeature(AppFeature.buy) && showExchange)
const SizedBox(
width: 8,
),
if (AppConfig.hasFeature(AppFeature.buy))
if (AppConfig.hasFeature(AppFeature.buy) && showExchange)
Expanded(
child: TextButton(
style: selectedIndex == 2

View file

@ -218,6 +218,9 @@ class TokenWalletOptions extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -251,11 +254,11 @@ class TokenWalletOptions extends ConsumerWidget {
subLabel: "Send",
iconAssetPathSVG: Assets.svg.arrowUpRight,
),
if (AppConfig.hasFeature(AppFeature.swap))
if (AppConfig.hasFeature(AppFeature.swap) && showExchange)
const SizedBox(
width: 16,
),
if (AppConfig.hasFeature(AppFeature.swap))
if (AppConfig.hasFeature(AppFeature.swap) && showExchange)
TokenOptionsButton(
onPressed: () => _onExchangePressed(context),
subLabel: "Swap",
@ -265,11 +268,11 @@ class TokenWalletOptions extends ConsumerWidget {
),
),
),
if (AppConfig.hasFeature(AppFeature.buy))
if (AppConfig.hasFeature(AppFeature.buy) && showExchange)
const SizedBox(
width: 16,
),
if (AppConfig.hasFeature(AppFeature.buy))
if (AppConfig.hasFeature(AppFeature.buy) && showExchange)
TokenOptionsButton(
onPressed: () => _onBuyPressed(context),
subLabel: "Buy",

View file

@ -518,6 +518,9 @@ class _WalletViewState extends ConsumerState<WalletView> {
final coin = ref.watch(pWalletCoin(walletId));
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
return ConditionalParent(
condition: _rescanningOnOpen,
builder: (child) {
@ -1053,7 +1056,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
),
if (Constants.enableExchange &&
ref.watch(pWalletCoin(walletId)) is! FrostCurrency &&
AppConfig.hasFeature(AppFeature.swap))
AppConfig.hasFeature(AppFeature.swap) &&
showExchange)
WalletNavigationBarItemData(
label: "Swap",
icon: const ExchangeNavIcon(),
@ -1061,7 +1065,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
),
if (Constants.enableExchange &&
ref.watch(pWalletCoin(walletId)) is! FrostCurrency &&
AppConfig.hasFeature(AppFeature.buy))
AppConfig.hasFeature(AppFeature.buy) &&
showExchange)
WalletNavigationBarItemData(
label: "Buy",
icon: const BuyNavIcon(),

View file

@ -186,7 +186,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
DesktopMenuItem(
key: ValueKey('myStack'),
key: const ValueKey('myStack'),
duration: duration,
icon: const DesktopMyStackIcon(),
label: "My ${AppConfig.prefix}",
@ -200,7 +200,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('swap'),
key: const ValueKey('swap'),
duration: duration,
icon: const DesktopExchangeIcon(),
label: "Swap",
@ -215,7 +215,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('buy'),
key: const ValueKey('buy'),
duration: duration,
icon: const DesktopBuyIcon(),
label: "Buy crypto",
@ -228,7 +228,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('notifications'),
key: const ValueKey('notifications'),
duration: duration,
icon: const DesktopNotificationsIcon(),
label: "Notifications",
@ -240,7 +240,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('addressBook'),
key: const ValueKey('addressBook'),
duration: duration,
icon: const DesktopAddressBookIcon(),
label: "Address Book",
@ -252,7 +252,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('settings'),
key: const ValueKey('settings'),
duration: duration,
icon: const DesktopSettingsIcon(),
label: "Settings",
@ -264,7 +264,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('support'),
key: const ValueKey('support'),
duration: duration,
icon: const DesktopSupportIcon(),
label: "Support",
@ -276,7 +276,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
height: 2,
),
DesktopMenuItem(
key: ValueKey('about'),
key: const ValueKey('about'),
duration: duration,
icon: const DesktopAboutIcon(),
label: "About",
@ -287,7 +287,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
const Spacer(),
if (!Platform.isIOS)
DesktopMenuItem(
key: ValueKey('exit'),
key: const ValueKey('exit'),
duration: duration,
labelLength: 123,
icon: const DesktopExitIcon(),

View file

@ -353,6 +353,9 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
final wallet = ref.watch(pWallets).getWallet(widget.walletId);
final coin = wallet.info.coin;
final prefs = ref.watch(prefsChangeNotifierProvider);
final showExchange = prefs.showExchange;
final showMore = wallet is PaynymInterface ||
(wallet is CoinControlInterface &&
ref.watch(
@ -368,7 +371,9 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
return Row(
children: [
if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.swap))
if (Constants.enableExchange &&
AppConfig.hasFeature(AppFeature.swap) &&
showExchange)
SecondaryButton(
label: "Swap",
width: buttonWidth,
@ -383,11 +388,15 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
),
onPressed: () => _onSwapPressed(),
),
if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.buy))
if (Constants.enableExchange &&
AppConfig.hasFeature(AppFeature.buy) &&
showExchange)
const SizedBox(
width: 16,
),
if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.buy))
if (Constants.enableExchange &&
AppConfig.hasFeature(AppFeature.buy) &&
showExchange)
SecondaryButton(
label: "Buy",
width: buttonWidth,