1+ import 'dart:async' ;
12import 'dart:io' ;
23
34import 'package:flutter/material.dart' ;
@@ -11,10 +12,13 @@ import '../../models/isar/models/blockchain_data/utxo.dart';
1112import '../../models/isar/ordinal.dart' ;
1213import '../../networking/http.dart' ;
1314import '../../notifications/show_flush_bar.dart' ;
15+ import '../../pages/ordinals/widgets/dialogs.dart' ;
16+ import '../../pages/send_view/confirm_transaction_view.dart' ;
1417import '../../pages/wallet_view/transaction_views/transaction_details_view.dart' ;
1518import '../../providers/db/main_db_provider.dart' ;
1619import '../../providers/global/wallets_provider.dart' ;
1720import '../../services/tor_service.dart' ;
21+ import '../desktop_home_view.dart' ;
1822import '../../themes/stack_colors.dart' ;
1923import '../../utilities/amount/amount.dart' ;
2024import '../../utilities/amount/amount_formatter.dart' ;
@@ -23,9 +27,12 @@ import '../../utilities/constants.dart';
2327import '../../utilities/prefs.dart' ;
2428import '../../utilities/show_loading.dart' ;
2529import '../../utilities/text_styles.dart' ;
30+ import '../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart' ;
2631import '../../widgets/custom_buttons/app_bar_icon_button.dart' ;
2732import '../../widgets/desktop/desktop_app_bar.dart' ;
33+ import '../../widgets/desktop/desktop_dialog.dart' ;
2834import '../../widgets/desktop/desktop_scaffold.dart' ;
35+ import '../../widgets/desktop/primary_button.dart' ;
2936import '../../widgets/desktop/secondary_button.dart' ;
3037import '../../widgets/ordinal_image.dart' ;
3138import '../../widgets/rounded_white_container.dart' ;
@@ -169,33 +176,143 @@ class _DesktopOrdinalDetailsViewState
169176 ),
170177 ),
171178 const SizedBox (width: 16 ),
172- // PrimaryButton(
173- // width: 150,
174- // label: "Send",
175- // icon: SvgPicture.asset(
176- // Assets.svg.send,
177- // width: 18,
178- // height: 18,
179- // color: Theme.of(context)
180- // .extension<StackColors>()!
181- // .buttonTextPrimary,
182- // ),
183- // buttonHeight: ButtonHeight.l,
184- // iconSpacing: 8,
185- // onPressed: () async {
186- // final response = await showDialog<String?>(
187- // context: context,
188- // builder: (_) =>
189- // const SendOrdinalUnfreezeDialog(),
190- // );
191- // if (response == "unfreeze") {
192- // // TODO: unfreeze and go to send ord screen
193- // }
194- // },
195- // ),
196- // const SizedBox(
197- // width: 16,
198- // ),
179+ PrimaryButton (
180+ width: 150 ,
181+ label: "Send" ,
182+ icon: SvgPicture .asset (
183+ Assets .svg.send,
184+ width: 18 ,
185+ height: 18 ,
186+ color: Theme .of (
187+ context,
188+ ).extension < StackColors > ()! .buttonTextPrimary,
189+ ),
190+ buttonHeight: ButtonHeight .l,
191+ iconSpacing: 8 ,
192+ onPressed: () async {
193+ final utxo = widget.ordinal.getUTXO (
194+ ref.read (mainDBProvider),
195+ );
196+ if (utxo == null ) {
197+ unawaited (
198+ showFloatingFlushBar (
199+ type: FlushBarType .warning,
200+ message: "Could not find ordinal UTXO" ,
201+ context: context,
202+ ),
203+ );
204+ return ;
205+ }
206+
207+ if (utxo.isBlocked) {
208+ final unfreezeResponse =
209+ await showDialog <String ?>(
210+ context: context,
211+ builder: (_) =>
212+ const SendOrdinalUnfreezeDialog (),
213+ );
214+ if (unfreezeResponse != "unfreeze" ) return ;
215+ }
216+
217+ if (! context.mounted) return ;
218+
219+ final address = await showDialog <String ?>(
220+ context: context,
221+ builder: (_) =>
222+ OrdinalRecipientAddressDialog (
223+ inscriptionNumber:
224+ widget.ordinal.inscriptionNumber,
225+ ),
226+ );
227+ if (address == null || address.isEmpty) return ;
228+
229+ final wallet = ref
230+ .read (pWallets)
231+ .getWallet (widget.walletId);
232+ if (! wallet.cryptoCurrency
233+ .validateAddress (address)) {
234+ if (context.mounted) {
235+ unawaited (
236+ showFloatingFlushBar (
237+ type: FlushBarType .warning,
238+ message: "Invalid address" ,
239+ context: context,
240+ ),
241+ );
242+ }
243+ return ;
244+ }
245+
246+ if (! context.mounted) return ;
247+
248+ final OrdinalsInterface ? ordinalsWallet =
249+ wallet is OrdinalsInterface
250+ ? wallet
251+ : null ;
252+ if (ordinalsWallet == null ) {
253+ unawaited (
254+ showFloatingFlushBar (
255+ type: FlushBarType .warning,
256+ message:
257+ "Wallet does not support ordinals" ,
258+ context: context,
259+ ),
260+ );
261+ return ;
262+ }
263+
264+ bool didError = false ;
265+ final txData = await showLoading (
266+ whileFuture:
267+ ordinalsWallet.prepareOrdinalSend (
268+ ordinalUtxo: utxo,
269+ recipientAddress: address,
270+ ),
271+ context: context,
272+ rootNavigator: true ,
273+ message: "Preparing transaction..." ,
274+ onException: (e) {
275+ didError = true ;
276+ String msg = e.toString ();
277+ while (msg.isNotEmpty &&
278+ msg.startsWith ("Exception:" )) {
279+ msg = msg.substring (10 ).trim ();
280+ }
281+ if (context.mounted) {
282+ showFloatingFlushBar (
283+ type: FlushBarType .warning,
284+ message: msg,
285+ context: context,
286+ );
287+ }
288+ },
289+ );
290+
291+ if (didError ||
292+ txData == null ||
293+ ! context.mounted) {
294+ return ;
295+ }
296+
297+ await showDialog <void >(
298+ context: context,
299+ builder: (context) => DesktopDialog (
300+ maxHeight:
301+ MediaQuery .of (context).size.height -
302+ 64 ,
303+ maxWidth: 580 ,
304+ child: ConfirmTransactionView (
305+ walletId: widget.walletId,
306+ txData: txData,
307+ routeOnSuccessName:
308+ DesktopHomeView .routeName,
309+ onSuccess: () {},
310+ ),
311+ ),
312+ );
313+ },
314+ ),
315+ const SizedBox (width: 16 ),
199316 SecondaryButton (
200317 width: 150 ,
201318 label: "Download" ,
0 commit comments