fix(buy/sell-flow): add buy/sell toggle to DesktopExchangeCardsSection

The desktop exchange screen was only showing the buy flow with no way
to switch to sell. This change adds the missing toggle to the DesktopExchangeCardsSection and links it up in the buy/sell page
This commit is contained in:
Blazebrain 2025-04-17 08:09:53 +01:00
parent d9c01a5d07
commit fe435d4e3b
2 changed files with 30 additions and 4 deletions

View file

@ -490,11 +490,19 @@ class BuySellPage extends BasePage {
return DesktopExchangeCardsSection(
firstExchangeCard: fiatExchangeCard,
secondExchangeCard: cryptoExchangeCard,
onBuyTap: () => null,
onSellTap: () =>
buySellViewModel.isBuyAction ? buySellViewModel.changeBuySellAction() : null,
isBuySellOption: true,
);
} else {
return DesktopExchangeCardsSection(
firstExchangeCard: cryptoExchangeCard,
secondExchangeCard: fiatExchangeCard,
onBuyTap: () =>
!buySellViewModel.isBuyAction ? buySellViewModel.changeBuySellAction() : null,
onSellTap: () => null,
isBuySellOption: true,
);
}
},

View file

@ -1,15 +1,22 @@
import 'package:cake_wallet/src/screens/exchange/widgets/mobile_exchange_cards_section.dart';
import 'package:flutter/material.dart';
class DesktopExchangeCardsSection extends StatelessWidget {
final Widget firstExchangeCard;
final Widget secondExchangeCard;
const DesktopExchangeCardsSection({
Key? key,
required this.firstExchangeCard,
required this.secondExchangeCard,
this.isBuySellOption = false,
this.onBuyTap,
this.onSellTap,
}) : super(key: key);
final Widget firstExchangeCard;
final Widget secondExchangeCard;
final bool isBuySellOption;
final VoidCallback? onBuyTap;
final VoidCallback? onSellTap;
@override
Widget build(BuildContext context) {
return FocusTraversalGroup(
@ -18,7 +25,18 @@ class DesktopExchangeCardsSection extends StatelessWidget {
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 55, left: 24, right: 24),
child: firstExchangeCard,
child: Column(
children: [
if (isBuySellOption)
Column(
children: [
const SizedBox(height: 16),
BuySellOptionButtons(onBuyTap: onBuyTap, onSellTap: onSellTap),
],
),
firstExchangeCard,
],
),
),
Padding(
padding: EdgeInsets.only(top: 29, left: 24, right: 24),