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,140 @@ 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: (_) => OrdinalRecipientAddressDialog (
222+ inscriptionNumber:
223+ widget.ordinal.inscriptionNumber,
224+ ),
225+ );
226+ if (address == null || address.isEmpty) return ;
227+
228+ final wallet = ref
229+ .read (pWallets)
230+ .getWallet (widget.walletId);
231+ if (! wallet.cryptoCurrency.validateAddress (
232+ address,
233+ )) {
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 ? wallet : null ;
250+ if (ordinalsWallet == null ) {
251+ unawaited (
252+ showFloatingFlushBar (
253+ type: FlushBarType .warning,
254+ message:
255+ "Wallet does not support ordinals" ,
256+ context: context,
257+ ),
258+ );
259+ return ;
260+ }
261+
262+ bool didError = false ;
263+ final txData = await showLoading (
264+ whileFuture: ordinalsWallet
265+ .prepareOrdinalSend (
266+ ordinalUtxo: utxo,
267+ recipientAddress: address,
268+ ),
269+ context: context,
270+ rootNavigator: true ,
271+ message: "Preparing transaction..." ,
272+ onException: (e) {
273+ didError = true ;
274+ String msg = e.toString ();
275+ while (msg.isNotEmpty &&
276+ msg.startsWith ("Exception:" )) {
277+ msg = msg.substring (10 ).trim ();
278+ }
279+ if (context.mounted) {
280+ showFloatingFlushBar (
281+ type: FlushBarType .warning,
282+ message: msg,
283+ context: context,
284+ );
285+ }
286+ },
287+ );
288+
289+ if (didError ||
290+ txData == null ||
291+ ! context.mounted) {
292+ return ;
293+ }
294+
295+ await showDialog <void >(
296+ context: context,
297+ builder: (context) => DesktopDialog (
298+ maxHeight:
299+ MediaQuery .of (context).size.height - 64 ,
300+ maxWidth: 580 ,
301+ child: ConfirmTransactionView (
302+ walletId: widget.walletId,
303+ txData: txData,
304+ routeOnSuccessName:
305+ DesktopHomeView .routeName,
306+ onSuccess: () {},
307+ ),
308+ ),
309+ );
310+ },
311+ ),
312+ const SizedBox (width: 16 ),
199313 SecondaryButton (
200314 width: 150 ,
201315 label: "Download" ,
0 commit comments