fix: restore direct MoonPay purchases in Hash Bags 1.0.6

This commit is contained in:
jwinterm
2026-11-23 17:12:50 -05:00
committed by John Winter Murphy
parent 4c1426f8ab
commit 13a2908e8a
11 changed files with 116 additions and 168 deletions
-1
View File
@@ -15,7 +15,6 @@ import "package:hash_wallet/new-ui/pages/seed/seed_backup_reminder_page.dart";
import "package:hash_wallet/new-ui/pages/send_page.dart";
import "package:hash_wallet/new-ui/pages/settings_page.dart";
import "package:hash_wallet/new-ui/pages/wallet_accounts_page.dart";
import "package:hash_wallet/new-ui/widgets/buy_sell/buy_sell_selector_modal.dart";
import "package:hash_wallet/new-ui/widgets/coins_page/action_row/coin_action_row.dart";
import "package:hash_wallet/new-ui/widgets/coins_page/assets_history/assets_history_section.dart";
import "package:hash_wallet/new-ui/widgets/coins_page/cards/balance_card.dart";
@@ -1,154 +0,0 @@
import "package:hash_wallet/di.dart";
import "package:hash_wallet/generated/i18n.dart";
import "package:hash_wallet/main.dart";
import "package:hash_wallet/new-ui/modal_navigator.dart";
import "package:hash_wallet/new-ui/pages/buy_sell/buy_sell_amount_page.dart";
import "package:hash_wallet/new-ui/viewmodels/charts/charts_bloc.dart";
import "package:hash_wallet/src/widgets/hash_image_widget.dart";
import "package:hash_wallet/themes/core/theme_extension.dart";
import "package:hash_wallet/view_model/buy/buy_sell_view_model.dart";
import "package:flutter/material.dart";
class BuySellSelectorModal extends StatelessWidget {
const BuySellSelectorModal({super.key});
@override
Widget build(BuildContext context) => Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.vertical(top: Radius.circular(18)),
gradient: LinearGradient(
colors: [
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surfaceDim,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: SafeArea(
top: false,
child: Column(
spacing: 24,
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox.shrink(),
Text(
S.of(context).buy_or_sell,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
Text(
S.of(context).buy_or_sell_desc,
style:
TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.onSurfaceVariant),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 18),
child: Column(
spacing: 12,
children: [
BuySellSelectorModalButton(
title: S.of(context).buy_crypto,
description: S.of(context).buy_crypto_desc,
iconPath: "assets/new-ui/plus.svg",
onTap: () => openBuySellPage(context, BuySellPageMode.buy),
),
BuySellSelectorModalButton(
title: S.of(context).sell_crypto,
description: S.of(context).sell_crypto_desc,
iconPath: "assets/new-ui/sell.svg",
onTap: () => openBuySellPage(context, BuySellPageMode.sell),
),
],
),
),
const SizedBox.shrink(),
],
),
),
);
void openBuySellPage(BuildContext context, BuySellPageMode mode) {
Navigator.of(context).pop();
final page = getIt.get<NewBuySellAmountPage>(param1: NewBuySellParams(mode: mode));
showModalBottomSheet(
useSafeArea: true,
isScrollControlled: true,
context: navigatorKey.currentContext!,
builder: (modalContext) => ModalNavigator(
rootPage: page,
parentContext: modalContext,
),
);
}
}
class BuySellSelectorModalButton extends StatelessWidget {
const BuySellSelectorModalButton({
required this.title,
required this.description,
required this.iconPath,
required this.onTap,
super.key,
});
final String title;
final String description;
final String iconPath;
final VoidCallback onTap;
@override
Widget build(BuildContext context) => GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(
width: 1,
color: Theme.of(context).colorScheme.surfaceContainerHigh,
),
gradient: LinearGradient(
colors: [
context.customColors.cardGradientColorPrimary,
context.customColors.cardGradientColorSecondary,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: Padding(
padding: const EdgeInsets.all(24),
child: Row(
spacing: 20,
children: [
HashImageWidget(
imageUrl: iconPath,
width: 55,
height: 55,
colorFilter: ColorFilter.mode(
Theme.of(context).colorScheme.onSurfaceVariant,
BlendMode.srcIn,
),
),
Column(
spacing: 8,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 16),
),
Text(
description,
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
],
),
),
),
);
}
@@ -1,4 +1,5 @@
import "package:hash_wallet/di.dart";
import "package:hash_wallet/entities/provider_types.dart";
import "package:hash_wallet/generated/i18n.dart";
import "package:hash_wallet/main.dart";
import "package:hash_wallet/new-ui/modal_navigator.dart";
@@ -57,7 +58,7 @@ class ChartModal extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
spacing: MediaQuery.of(context).size.width * 0.05,
children: [
if (canOpenBuySell) ...[
if (canOpenBuySell && ProvidersHelper.getAvailableBuyProviderTypes().isNotEmpty)
CoinActionButton(
icon: HashImageWidget(
width: 36,
@@ -71,6 +72,7 @@ class ChartModal extends StatelessWidget {
label: S.of(context).buy,
action: () => openBuySellPage(context, BuySellPageMode.buy),
),
if (canOpenBuySell && ProvidersHelper.getAvailableSellProviderTypes().isNotEmpty)
CoinActionButton(
icon: HashImageWidget(
width: 36,
@@ -84,7 +86,6 @@ class ChartModal extends StatelessWidget {
label: S.of(context).sell,
action: () => openBuySellPage(context, BuySellPageMode.sell),
),
],
CoinActionButton(
icon: HashImageWidget(
imageUrl: "assets/new-ui/exchange.svg",
@@ -10,7 +10,6 @@ import 'package:hash_wallet/entities/provider_types.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/new-ui/modal_navigator.dart';
import 'package:hash_wallet/new-ui/pages/send_page.dart';
import 'package:hash_wallet/new-ui/widgets/buy_sell/buy_sell_selector_modal.dart';
import 'package:hash_wallet/routes.dart';
import 'package:hash_wallet/utils/payment_request.dart';
import 'package:hash_wallet/utils/responsive_layout_util.dart';
@@ -214,10 +213,7 @@ class _CardsViewState extends State<CardsView> {
label: S.current.buy,
icon: Icons.arrow_forward_ios_rounded,
iconSize: 12,
onTap: () {
showModalBottomSheet(
context: context, builder: (context) => BuySellSelectorModal());
},
onTap: () => Navigator.of(context).pushNamed(Routes.buySellPage),
)
]
: [];