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
Blazebrain committed
Apr 17, 2025 at 08:09 UTC
fe435d4e3bd40ac2fd51e83b9db15f5b807e6fae
2 files changed
+30
-4
lib/src/screens/buy/buy_sell_page.dart
+8
@@ -490,11 +490,19 @@ class BuySellPage extends BasePage {
490
return DesktopExchangeCardsSection(
491
firstExchangeCard: fiatExchangeCard,
492
secondExchangeCard: cryptoExchangeCard,
493
+ onBuyTap: () => null,
494
+ onSellTap: () =>
495
+ buySellViewModel.isBuyAction ? buySellViewModel.changeBuySellAction() : null,
496
+ isBuySellOption: true,
497
);
498
} else {
499
return DesktopExchangeCardsSection(
500
firstExchangeCard: cryptoExchangeCard,
501
secondExchangeCard: fiatExchangeCard,
502
+ onBuyTap: () =>
503
+ !buySellViewModel.isBuyAction ? buySellViewModel.changeBuySellAction() : null,
504
+ onSellTap: () => null,
505
+ isBuySellOption: true,
506
);
507
}
508
},
lib/src/screens/exchange/widgets/desktop_exchange_cards_section.dart
+22
-4
@@ -1,15 +1,22 @@
1
+import 'package:cake_wallet/src/screens/exchange/widgets/mobile_exchange_cards_section.dart';
2
import 'package:flutter/material.dart';
3
4
class DesktopExchangeCardsSection extends StatelessWidget {
4
- final Widget firstExchangeCard;
5
- final Widget secondExchangeCard;
6
-
5
const DesktopExchangeCardsSection({
6
Key? key,
7
required this.firstExchangeCard,
8
required this.secondExchangeCard,
9
+ this.isBuySellOption = false,
10
+ this.onBuyTap,
11
+ this.onSellTap,
12
}) : super(key: key);
13
14
+ final Widget firstExchangeCard;
15
+ final Widget secondExchangeCard;
16
+ final bool isBuySellOption;
17
+ final VoidCallback? onBuyTap;
18
+ final VoidCallback? onSellTap;
19
+
20
@override
21
Widget build(BuildContext context) {
22
return FocusTraversalGroup(
@@ -18,7 +25,18 @@ class DesktopExchangeCardsSection extends StatelessWidget {
25
children: <Widget>[
26
Padding(
27
padding: EdgeInsets.only(top: 55, left: 24, right: 24),
21
- child: firstExchangeCard,
28
+ child: Column(
29
+ children: [
30
+ if (isBuySellOption)
31
+ Column(
32
+ children: [
33
+ const SizedBox(height: 16),
34
+ BuySellOptionButtons(onBuyTap: onBuyTap, onSellTap: onSellTap),
35
+ ],
36
+ ),
37
+ firstExchangeCard,
38
+ ],
39
+ ),
40
),
41
Padding(
42
padding: EdgeInsets.only(top: 29, left: 24, right: 24),