Files
hash-wallet/lib/new-ui/widgets/send_page/l2_send_external_modal.dart
T
jwinterm dd449f2594 Merge upstream Cake Wallet v6.5.0
Catches up from the May 12 fork point (v6.1.2+23) through v6.5.0: 535
upstream commits, including the Monero silent-open fix, Monero on Trezor,
Ledger/Trezor BLE fixes, the new seed and history screens, quick Bitcoin
sync, git-pinned dependencies (pubspec_overrides.yaml), frozen Hive
adapters (*.part.dart), monero_c v0.18.4.6-RC2 and Flutter 3.41.9.

Merged with both sides normalized first (import rename, 100-column
format), which took the conflict count from 614 paths to 322. The
procedure is now scripts/upstream_sync.sh.

Kept from Hash Bags:
- WalletType enum order and Hive IDs. SQLite stores WalletType.index and
  our order differs from upstream's; taking theirs would reread saved
  wallets as other chains. Our frozen adapter keeps the shipped IDs.
- The 1.0.2 legacy PIN and wallet-password decode and self-heal.
- Removed chains (Solana, Tron, Zano, Zcash, Decred, Haven) and the new
  Robinhood chain stay out; Cake Pay and non-Trocador swaps stay out.
- Default nodes (node.wownero.org, sethforprivacy, Blockstream, bysh.me),
  converted to upstream's isDefault node-list key; Wownero is back in the
  node reset list.
- Privacy: address resolvers limited to domain-anchored sources again;
  prices.neroswap.com for fiat; upstream's charts tab, which reads
  prices.cakewallet.com, sits behind FeatureFlag.isChartsEnabled = false.
- Lightning stays behind FeatureFlag.isLightningEnabled, including
  upstream's new post-seed Lightning username step.
- Our icon pipeline, branding and bundle identifiers.

Twelve new upstream widget tests are skipped: test and code are unchanged
from v6.5.0 apart from renames (not rerun on a pristine upstream checkout;
upstream's top_bar_test does not compile against its own TopBar).
flutter analyze lib: 0 errors; flutter test: 345 passed, 12 skipped;
flutter build bundle compiles. Built with Flutter 3.41.9.
2026-10-24 23:49:29 -04:00

212 lines
9.2 KiB
Dart

import 'package:hash_wallet/bitcoin/bitcoin.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:hash_wallet/new-ui/widgets/new_primary_button.dart';
import 'package:hash_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
import 'package:hash_wallet/src/screens/receive/widgets/qr_image.dart';
import 'package:hash_wallet/src/widgets/hash_image_widget.dart';
import 'package:hash_wallet/utils/address_formatter.dart';
import 'package:hash_wallet/utils/clipboard_util.dart';
import 'package:hash_wallet/view_model/send/send_view_model.dart';
import 'package:cw_core/payment_uris.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import "package:cw_core/wallet_type.dart";
class L2SendExternalModal extends StatefulWidget {
const L2SendExternalModal({super.key, required this.sendViewModel});
final SendViewModel sendViewModel;
@override
State<L2SendExternalModal> createState() => _L2SendExternalModalState();
}
class _L2SendExternalModalState extends State<L2SendExternalModal> {
PaymentURI? uri;
bool largeQrMode = false;
static const warningTextColor = Color(0xFFFFB84E);
static const warningBackgroundColor = Color(0xFF8E5800);
@override
void initState() {
super.initState();
() async {
if (widget.sendViewModel.wallet.type == WalletType.bitcoin) {
await bitcoin!.setAddressType(widget.sendViewModel.wallet,
bitcoin!.getOptionToType(bitcoin!.getBitcoinLightningReceivePageOption()));
} else if (widget.sendViewModel.wallet.type == WalletType.litecoin) {
await bitcoin!.setAddressType(widget.sendViewModel.wallet,
bitcoin!.getOptionToType(bitcoin!.getLitecoinMwebReceivePageOption()));
}
final newUri = await widget.sendViewModel.wallet.walletAddresses
.getPaymentRequestUri(widget.sendViewModel.outputs.first.cryptoAmount);
setState(() {
uri = newUri;
});
}.call();
}
@override
Widget build(BuildContext context) {
final output = widget.sendViewModel.outputs.first;
final resolvedSize = MediaQuery.of(context).size.width * (largeQrMode ? 0.8 : 0.54);
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ModalTopBar(
title: "",
leadingWidget: Row(
spacing: 12,
children: [
if (widget.sendViewModel.walletType == WalletType.bitcoin)
HashImageWidget(imageUrl: "assets/new-ui/lightning_deposit_help.svg", height: 36),
Text(
S.of(context).bitcoin_lightning_deposit,
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 20),
)
],
),
trailingIcon: Icon(Icons.close),
trailingSemanticLabel: S.of(context).close,
onTrailingPressed: Navigator.of(context).pop,
),
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
spacing: 24,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 12,
children: [
Text(
S.of(context).send_exactly,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.w500),
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
spacing: 8,
children: [
Text(
output.cryptoAmount,
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16,
color: Theme.of(context).colorScheme.primary),
),
Text(
widget.sendViewModel.currency.title,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 16,
color: Theme.of(context).colorScheme.primary),
),
],
),
)),
Text("${S.of(context).to}:",
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.w500))
],
),
uri == null
? Container(
width: resolvedSize,
height: resolvedSize,
child: CupertinoActivityIndicator(),
)
: GestureDetector(
onTap: () {
setState(() {
largeQrMode = !largeQrMode;
});
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutCubic,
width: resolvedSize,
height: resolvedSize,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: QrImage(
embeddedImagePath: widget.sendViewModel.currency.iconPath,
data: uri.toString(),
),
),
),
),
AddressFormatter.buildSegmentedAddress(
address: output.address,
evenTextStyle: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontFamily: "IBM Plex Mono"),
textAlign: TextAlign.center),
Container(
decoration: BoxDecoration(
color: warningBackgroundColor,
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: EdgeInsets.all(20),
child: Text(
S.of(context).lightning_external_disclaimer,
textAlign: TextAlign.center,
style: TextStyle(
color: warningTextColor,
fontSize: 14,
fontWeight: FontWeight.w500),
),
)),
Row(
spacing: 8,
children: [
Flexible(
child: NewPrimaryButton(
onPressed: () =>
ClipboardUtil.copyToClipboard(context, output.address),
text: S.of(context).copy,
color: Theme.of(context).colorScheme.primary,
textColor: Theme.of(context).colorScheme.onPrimary),
),
Flexible(
child: NewPrimaryButton(
onPressed: Navigator.of(context).pop,
text: S.of(context).sent_the_funds,
color: Theme.of(context).colorScheme.surfaceContainer,
textColor: Theme.of(context).colorScheme.primary),
),
],
),
SizedBox()
],
),
],
),
),
),
],
),
);
}
}