hide or show Buy features based on configuration

This commit is contained in:
sneurlax 2024-06-05 17:48:38 -05:00
parent 42b728eb08
commit 2b28e6b121
5 changed files with 68 additions and 61 deletions

View file

@ -139,48 +139,50 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
),
),
),
const SizedBox(
width: 8,
),
Expanded(
child: TextButton(
style: selectedIndex == 2
? 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 != 2) {
ref.read(homeViewPageIndexStateProvider.state).state = 2;
}
// await BuyDataLoadingService().loadAll(ref);
},
child: Text(
"Buy",
style: STextStyles.button(context).copyWith(
fontSize: 14,
color: selectedIndex == 2
? Theme.of(context)
.extension<StackColors>()!
.buttonTextPrimary
: Theme.of(context)
.extension<StackColors>()!
.buttonTextSecondary,
if (AppConfig.hasFeature(AppFeature.buy))
const SizedBox(
width: 8,
),
if (AppConfig.hasFeature(AppFeature.buy))
Expanded(
child: TextButton(
style: selectedIndex == 2
? 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 != 2) {
ref.read(homeViewPageIndexStateProvider.state).state = 2;
}
// await BuyDataLoadingService().loadAll(ref);
},
child: Text(
"Buy",
style: STextStyles.button(context).copyWith(
fontSize: 14,
color: selectedIndex == 2
? Theme.of(context)
.extension<StackColors>()!
.buttonTextPrimary
: Theme.of(context)
.extension<StackColors>()!
.buttonTextSecondary,
),
),
),
),
),
],
);
}

View file

@ -265,14 +265,16 @@ class TokenWalletOptions extends ConsumerWidget {
),
),
),
const SizedBox(
width: 16,
),
TokenOptionsButton(
onPressed: () => _onBuyPressed(context),
subLabel: "Buy",
iconAssetPathSVG: Assets.svg.creditCard,
),
if (AppConfig.hasFeature(AppFeature.buy))
const SizedBox(
width: 16,
),
if (AppConfig.hasFeature(AppFeature.buy))
TokenOptionsButton(
onPressed: () => _onBuyPressed(context),
subLabel: "Buy",
iconAssetPathSVG: Assets.svg.creditCard,
),
],
);
}

View file

@ -1069,7 +1069,8 @@ class _WalletViewState extends ConsumerState<WalletView> {
onTap: () => _onExchangePressed(context),
),
if (Constants.enableExchange &&
ref.watch(pWalletCoin(walletId)) is! FrostCurrency)
ref.watch(pWalletCoin(walletId)) is! FrostCurrency &&
AppConfig.hasFeature(AppFeature.buy))
WalletNavigationBarItemData(
label: "Buy",
icon: const BuyNavIcon(),

View file

@ -200,17 +200,19 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
onChanged: updateSelectedMenuItem,
controller: controllers[1],
),
const SizedBox(
height: 2,
),
DesktopMenuItem(
duration: duration,
icon: const DesktopBuyIcon(),
label: "Buy crypto",
value: DesktopMenuItemId.buy,
onChanged: updateSelectedMenuItem,
controller: controllers[2],
),
if (AppConfig.hasFeature(AppFeature.buy))
const SizedBox(
height: 2,
),
if (AppConfig.hasFeature(AppFeature.buy))
DesktopMenuItem(
duration: duration,
icon: const DesktopBuyIcon(),
label: "Buy crypto",
value: DesktopMenuItemId.buy,
onChanged: updateSelectedMenuItem,
controller: controllers[2],
),
const SizedBox(
height: 2,
),

View file

@ -383,11 +383,11 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
),
onPressed: () => _onSwapPressed(),
),
if (Constants.enableExchange)
if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.buy))
const SizedBox(
width: 16,
),
if (Constants.enableExchange)
if (Constants.enableExchange && AppConfig.hasFeature(AppFeature.buy))
SecondaryButton(
label: "Buy",
width: buttonWidth,