WIP send from stack desktop trade transaction navigation

This commit is contained in:
julian 2022-11-22 11:21:43 -06:00
parent 6552fc913d
commit 0bdf337ffb
5 changed files with 700 additions and 473 deletions

View file

@ -7,15 +7,23 @@ import 'package:stackwallet/models/trade_wallet_lookup.dart';
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart'; import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart'; import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_container.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
@ -52,14 +60,16 @@ class _ConfirmChangeNowSendViewState
late final Trade trade; late final Trade trade;
Future<void> _attemptSend(BuildContext context) async { Future<void> _attemptSend(BuildContext context) async {
unawaited(showDialog<void>( unawaited(
context: context, showDialog<void>(
useSafeArea: false, context: context,
barrierDismissible: false, useSafeArea: false,
builder: (context) { barrierDismissible: false,
return const SendingTransactionDialog(); builder: (context) {
}, return const SendingTransactionDialog();
)); },
),
);
final String note = transactionInfo["note"] as String? ?? ""; final String note = transactionInfo["note"] as String? ?? "";
final manager = final manager =
@ -93,6 +103,9 @@ class _ConfirmChangeNowSendViewState
// pop back to wallet // pop back to wallet
if (mounted) { if (mounted) {
if (Util.isDesktop) {
Navigator.of(context, rootNavigator: true).pop();
}
Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName)); Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName));
} }
} catch (e) { } catch (e) {
@ -129,6 +142,60 @@ class _ConfirmChangeNowSendViewState
} }
} }
Future<void> _confirmSend() async {
final dynamic unlocked;
if (Util.isDesktop) {
unlocked = await showDialog<bool?>(
context: context,
builder: (context) => DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
DesktopDialogCloseButton(),
],
),
const Padding(
padding: EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: DesktopAuthSend(),
),
],
),
),
);
} else {
unlocked = await Navigator.push(
context,
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder: (_) => const LockscreenView(
showBackButton: true,
popOnSuccess: true,
routeOnSuccessArguments: true,
routeOnSuccess: "",
biometricsCancelButtonString: "CANCEL",
biometricsLocalizedReason: "Authenticate to send transaction",
biometricsAuthenticationTitle: "Confirm Transaction",
),
settings: const RouteSettings(name: "/confirmsendlockscreen"),
),
);
}
if (unlocked is bool && unlocked && mounted) {
await _attemptSend(context);
}
}
@override @override
void initState() { void initState() {
transactionInfo = widget.transactionInfo; transactionInfo = widget.transactionInfo;
@ -142,280 +209,503 @@ class _ConfirmChangeNowSendViewState
Widget build(BuildContext context) { Widget build(BuildContext context) {
final managerProvider = ref.watch(walletsChangeNotifierProvider final managerProvider = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManagerProvider(walletId))); .select((value) => value.getManagerProvider(walletId)));
return Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
leading: AppBarBackButton(
onPressed: () async {
// if (FocusScope.of(context).hasFocus) {
// FocusScope.of(context).unfocus();
// await Future<void>.delayed(Duration(milliseconds: 50));
// }
Navigator.of(context).pop();
},
),
title: Text(
"Confirm transaction",
style: STextStyles.navBarTitle(context),
),
),
body: LayoutBuilder(
builder: (builderContext, constraints) {
return Padding(
padding: const EdgeInsets.only(
left: 12,
top: 12,
right: 12,
),
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight - 24,
),
child: IntrinsicHeight(
child: Padding(
padding: const EdgeInsets.all(4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
style: STextStyles.pageTitleH1(context),
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Send from",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
ref
.watch(walletsChangeNotifierProvider)
.getManager(walletId)
.walletName,
style: STextStyles.itemSubtitle12(context),
),
],
),
),
const SizedBox(
height: 12,
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"${trade.exchangeName} address",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
"${transactionInfo["address"] ?? "ERROR"}",
style: STextStyles.itemSubtitle12(context),
),
],
),
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Amount",
style: STextStyles.smallMed12(context),
),
Text(
"${Format.satoshiAmountToPrettyString(
transactionInfo["recipientAmt"] as int,
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider
.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
],
),
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Transaction fee",
style: STextStyles.smallMed12(context),
),
Text(
"${Format.satoshiAmountToPrettyString(
transactionInfo["fee"] as int,
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider
.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
],
),
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Note",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
transactionInfo["note"] as String? ?? "",
style: STextStyles.itemSubtitle12(context),
),
],
),
),
const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Trade ID",
style: STextStyles.smallMed12(context),
),
Text(
trade.tradeId,
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
],
),
),
const SizedBox(
height: 12,
),
RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.snackBarBackSuccess,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Total amount",
style:
STextStyles.titleBold12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
),
Text(
"${Format.satoshiAmountToPrettyString(
(transactionInfo["fee"] as int) +
(transactionInfo["recipientAmt"] as int),
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider
.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
textAlign: TextAlign.right,
),
],
),
),
const SizedBox(
height: 16,
),
const Spacer(),
TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context),
onPressed: () async {
final unlocked = await Navigator.push(
context,
RouteGenerator.getRoute(
shouldUseMaterialRoute:
RouteGenerator.useMaterialPageRoute,
builder: (_) => const LockscreenView(
showBackButton: true,
popOnSuccess: true,
routeOnSuccessArguments: true,
routeOnSuccess: "",
biometricsCancelButtonString: "CANCEL",
biometricsLocalizedReason:
"Authenticate to send transaction",
biometricsAuthenticationTitle:
"Confirm Transaction",
),
settings: const RouteSettings(
name: "/confirmsendlockscreen"),
),
);
if (unlocked is bool && unlocked && mounted) { final isDesktop = Util.isDesktop;
await _attemptSend(context);
} return ConditionalParent(
}, condition: !isDesktop,
child: Text( builder: (child) {
"Send", return Scaffold(
style: STextStyles.button(context), backgroundColor:
), Theme.of(context).extension<StackColors>()!.background,
), appBar: AppBar(
], backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
leading: AppBarBackButton(
onPressed: () async {
// if (FocusScope.of(context).hasFocus) {
// FocusScope.of(context).unfocus();
// await Future<void>.delayed(Duration(milliseconds: 50));
// }
Navigator.of(context).pop();
},
),
title: Text(
"Confirm transaction",
style: STextStyles.navBarTitle(context),
),
),
body: LayoutBuilder(
builder: (builderContext, constraints) {
return Padding(
padding: const EdgeInsets.only(
left: 12,
top: 12,
right: 12,
),
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight - 24,
),
child: IntrinsicHeight(
child: Padding(
padding: const EdgeInsets.all(4),
child: child,
),
), ),
), ),
), ),
);
},
),
);
},
child: ConditionalParent(
condition: isDesktop,
builder: (child) => DesktopDialog(
maxHeight: double.infinity,
maxWidth: 580,
child: Column(
children: [
Row(
children: [
const SizedBox(
width: 6,
),
const AppBarBackButton(
isCompact: true,
iconSize: 23,
),
const SizedBox(
width: 12,
),
Text(
"Confirm ${ref.watch(managerProvider.select((value) => value.coin)).ticker} transaction",
style: STextStyles.desktopH3(context),
)
],
),
Padding(
padding: const EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: Column(
children: [
RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
borderColor: Theme.of(context)
.extension<StackColors>()!
.background,
child: child,
),
const SizedBox(
height: 16,
),
Row(
children: [
Text(
"Transaction fee",
style:
STextStyles.desktopTextExtraExtraSmall(context),
),
],
),
const SizedBox(
height: 10,
),
RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"${Format.satoshiAmountToPrettyString(
(transactionInfo["fee"] as int),
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style:
STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
),
),
],
),
),
const SizedBox(
height: 16,
),
RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.snackBarBackSuccess,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Total amount",
style: STextStyles.titleBold12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
),
Text(
"${Format.satoshiAmountToPrettyString(
(transactionInfo["fee"] as int) +
(transactionInfo["recipientAmt"] as int),
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
textAlign: TextAlign.right,
),
],
),
),
const SizedBox(
height: 16,
),
Row(
children: [
Expanded(
child: SecondaryButton(
label: "Cancel",
buttonHeight: ButtonHeight.l,
onPressed: Navigator.of(context).pop,
),
),
const SizedBox(
width: 16,
),
Expanded(
child: PrimaryButton(
label: "Send",
buttonHeight: isDesktop ? ButtonHeight.l : null,
onPressed: _confirmSend,
),
),
],
)
],
),
),
],
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ConditionalParent(
condition: isDesktop,
builder: (child) => Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.background,
borderRadius: BorderRadius.vertical(
top: Radius.circular(
Constants.size.circularBorderRadius,
),
),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
child,
],
),
),
),
child: Text(
"Send ${ref.watch(managerProvider.select((value) => value.coin)).ticker}",
style: isDesktop
? STextStyles.desktopTextMedium(context)
: STextStyles.pageTitleH1(context),
), ),
), ),
); isDesktop
}, ? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Send from",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
ref
.watch(walletsChangeNotifierProvider)
.getManager(walletId)
.walletName,
style: STextStyles.itemSubtitle12(context),
),
],
),
),
isDesktop
? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"${trade.exchangeName} address",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
"${transactionInfo["address"] ?? "ERROR"}",
style: STextStyles.itemSubtitle12(context),
),
],
),
),
isDesktop
? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Amount",
style: STextStyles.smallMed12(context),
),
ConditionalParent(
condition: isDesktop,
builder: (child) => Row(
children: [
child,
Builder(builder: (context) {
final coin = ref.watch(
walletsChangeNotifierProvider.select(
(value) => value.getManager(walletId).coin));
final price = ref.watch(
priceAnd24hChangeNotifierProvider
.select((value) => value.getPrice(coin)));
final amount = Format.satoshisToAmount(
transactionInfo["recipientAmt"] as int,
coin: coin,
);
final value = price.item1 * amount;
final currency = ref.watch(prefsChangeNotifierProvider
.select((value) => value.currency));
return Text(
" | ${value.toStringAsFixed(Constants.decimalPlacesForCoin(coin))} $currency",
style:
STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle2,
),
);
})
],
),
child: Text(
"${Format.satoshiAmountToPrettyString(
transactionInfo["recipientAmt"] as int,
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
),
],
),
),
isDesktop
? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Transaction fee",
style: STextStyles.smallMed12(context),
),
Text(
"${Format.satoshiAmountToPrettyString(
transactionInfo["fee"] as int,
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
],
),
),
isDesktop
? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Note",
style: STextStyles.smallMed12(context),
),
const SizedBox(
height: 4,
),
Text(
transactionInfo["note"] as String? ?? "",
style: STextStyles.itemSubtitle12(context),
),
],
),
),
isDesktop
? Container(
color:
Theme.of(context).extension<StackColors>()!.background,
height: 1,
)
: const SizedBox(
height: 12,
),
RoundedWhiteContainer(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Trade ID",
style: STextStyles.smallMed12(context),
),
Text(
trade.tradeId,
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
),
],
),
),
if (!isDesktop)
const SizedBox(
height: 12,
),
if (!isDesktop)
RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.snackBarBackSuccess,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Total amount",
style: STextStyles.titleBold12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
),
Text(
"${Format.satoshiAmountToPrettyString(
(transactionInfo["fee"] as int) +
(transactionInfo["recipientAmt"] as int),
ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textConfirmTotalAmount,
),
textAlign: TextAlign.right,
),
],
),
),
if (!isDesktop)
const SizedBox(
height: 16,
),
if (!isDesktop) const Spacer(),
if (!isDesktop)
PrimaryButton(
label: "Send",
buttonHeight: isDesktop ? ButtonHeight.l : null,
onPressed: _confirmSend,
),
],
),
), ),
); );
} }

View file

@ -7,8 +7,8 @@ import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart';
import 'package:stackwallet/pages/exchange_view/confirm_change_now_send.dart'; import 'package:stackwallet/pages/exchange_view/confirm_change_now_send.dart';
import 'package:stackwallet/pages/home_view/home_view.dart'; import 'package:stackwallet/pages/home_view/home_view.dart';
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
@ -30,8 +30,6 @@ import 'package:stackwallet/widgets/expandable.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
import '../../pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
class SendFromView extends ConsumerStatefulWidget { class SendFromView extends ConsumerStatefulWidget {
const SendFromView({ const SendFromView({
Key? key, Key? key,
@ -39,6 +37,7 @@ class SendFromView extends ConsumerStatefulWidget {
required this.trade, required this.trade,
required this.amount, required this.amount,
required this.address, required this.address,
this.shouldPopRoot = false,
}) : super(key: key); }) : super(key: key);
static const String routeName = "/sendFrom"; static const String routeName = "/sendFrom";
@ -47,6 +46,7 @@ class SendFromView extends ConsumerStatefulWidget {
final Decimal amount; final Decimal amount;
final String address; final String address;
final Trade trade; final Trade trade;
final bool shouldPopRoot;
@override @override
ConsumerState<SendFromView> createState() => _SendFromViewState(); ConsumerState<SendFromView> createState() => _SendFromViewState();
@ -142,7 +142,7 @@ class _SendFromViewState extends ConsumerState<SendFromView> {
DesktopDialogCloseButton( DesktopDialogCloseButton(
onPressedOverride: Navigator.of( onPressedOverride: Navigator.of(
context, context,
rootNavigator: false, rootNavigator: widget.shouldPopRoot,
).pop, ).pop,
), ),
], ],
@ -239,12 +239,23 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
useSafeArea: false, useSafeArea: false,
barrierDismissible: false, barrierDismissible: false,
builder: (context) { builder: (context) {
return BuildingTransactionDialog( return ConditionalParent(
onCancel: () { condition: Util.isDesktop,
wasCancelled = true; builder: (child) => DesktopDialog(
maxWidth: 400,
maxHeight: double.infinity,
child: Padding(
padding: const EdgeInsets.all(32),
child: child,
),
),
child: BuildingTransactionDialog(
onCancel: () {
wasCancelled = true;
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
),
); );
}, },
), ),
@ -290,7 +301,10 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
// pop building dialog // pop building dialog
if (mounted) { if (mounted) {
Navigator.of(context).pop(); Navigator.of(
context,
rootNavigator: Util.isDesktop,
).pop();
} }
txData["note"] = txData["note"] =
@ -304,7 +318,9 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
builder: (_) => ConfirmChangeNowSendView( builder: (_) => ConfirmChangeNowSendView(
transactionInfo: txData, transactionInfo: txData,
walletId: walletId, walletId: walletId,
routeOnSuccessName: HomeView.routeName, routeOnSuccessName: Util.isDesktop
? DesktopExchangeView.routeName
: HomeView.routeName,
trade: trade, trade: trade,
shouldSendPublicFiroFunds: shouldSendPublicFiroFunds, shouldSendPublicFiroFunds: shouldSendPublicFiroFunds,
), ),
@ -401,58 +417,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
), ),
), ),
onPressed: () async { onPressed: () async {
final dynamic unlocked; if (mounted) {
if (Util.isDesktop) {
unlocked = await showDialog<bool?>(
context: context,
builder: (context) => DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
DesktopDialogCloseButton(),
],
),
const Padding(
padding: EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: DesktopAuthSend(),
),
],
),
),
);
} else {
unlocked = await Navigator.push(
context,
RouteGenerator.getRoute(
shouldUseMaterialRoute:
RouteGenerator.useMaterialPageRoute,
builder: (_) => const LockscreenView(
showBackButton: true,
popOnSuccess: true,
routeOnSuccessArguments: true,
routeOnSuccess: "",
biometricsCancelButtonString: "CANCEL",
biometricsLocalizedReason:
"Authenticate to send transaction",
biometricsAuthenticationTitle: "Confirm Transaction",
),
settings:
const RouteSettings(name: "/confirmsendlockscreen"),
),
);
}
if (unlocked is bool && unlocked && mounted) {
unawaited( unawaited(
_send( _send(
manager, manager,
@ -537,58 +502,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
), ),
), ),
onPressed: () async { onPressed: () async {
final dynamic unlocked; if (mounted) {
if (Util.isDesktop) {
unlocked = await showDialog<bool?>(
context: context,
builder: (context) => DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
DesktopDialogCloseButton(),
],
),
const Padding(
padding: EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: DesktopAuthSend(),
),
],
),
),
);
} else {
unlocked = await Navigator.push(
context,
RouteGenerator.getRoute(
shouldUseMaterialRoute:
RouteGenerator.useMaterialPageRoute,
builder: (_) => const LockscreenView(
showBackButton: true,
popOnSuccess: true,
routeOnSuccessArguments: true,
routeOnSuccess: "",
biometricsCancelButtonString: "CANCEL",
biometricsLocalizedReason:
"Authenticate to send transaction",
biometricsAuthenticationTitle: "Confirm Transaction",
),
settings:
const RouteSettings(name: "/confirmsendlockscreen"),
),
);
}
if (unlocked is bool && unlocked && mounted) {
unawaited( unawaited(
_send( _send(
manager, manager,
@ -680,57 +594,7 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
), ),
), ),
onPressed: () async { onPressed: () async {
final dynamic unlocked; if (mounted) {
if (Util.isDesktop) {
unlocked = await showDialog<bool?>(
context: context,
builder: (context) => DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: const [
DesktopDialogCloseButton(),
],
),
const Padding(
padding: EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: DesktopAuthSend(),
),
],
),
),
);
} else {
unlocked = await Navigator.push(
context,
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
builder: (_) => const LockscreenView(
showBackButton: true,
popOnSuccess: true,
routeOnSuccessArguments: true,
routeOnSuccess: "",
biometricsCancelButtonString: "CANCEL",
biometricsLocalizedReason:
"Authenticate to send transaction",
biometricsAuthenticationTitle: "Confirm Transaction",
),
settings:
const RouteSettings(name: "/confirmsendlockscreen"),
),
);
}
if (unlocked is bool && unlocked && mounted) {
unawaited( unawaited(
_send(manager), _send(manager),
); );

View file

@ -219,7 +219,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
children: children, children: children,
), ),
), ),
if (isStackCoin(trade.payInCurrency) && if (!hasTx &&
isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||
trade.status == "waiting" || trade.status == "waiting" ||
@ -227,7 +228,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
const SizedBox( const SizedBox(
height: 32, height: 32,
), ),
if (isStackCoin(trade.payInCurrency) && if (!hasTx &&
isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||
trade.status == "waiting" || trade.status == "waiting" ||
@ -1142,6 +1144,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
height: 12, height: 12,
), ),
if (!isDesktop && if (!isDesktop &&
!hasTx &&
isStackCoin(trade.payInCurrency) && isStackCoin(trade.payInCurrency) &&
(trade.status == "New" || (trade.status == "New" ||
trade.status == "new" || trade.status == "new" ||

View file

@ -51,6 +51,8 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
late final FocusNode _toFocusNode; late final FocusNode _toFocusNode;
late final FocusNode _refundFocusNode; late final FocusNode _refundFocusNode;
bool enableNext = false;
bool isStackCoin(String ticker) { bool isStackCoin(String ticker) {
try { try {
coinFromTickerCaseInsensitive(ticker); coinFromTickerCaseInsensitive(ticker);
@ -60,13 +62,13 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
} }
} }
void selectRecipientAddressFromStack() { void selectRecipientAddressFromStack() async {
try { try {
final coin = coinFromTickerCaseInsensitive( final coin = coinFromTickerCaseInsensitive(
model.receiveTicker, model.receiveTicker,
); );
showDialog<String?>( final address = await showDialog<String?>(
context: context, context: context,
barrierColor: Colors.transparent, barrierColor: Colors.transparent,
builder: (context) => DesktopDialog( builder: (context) => DesktopDialog(
@ -79,27 +81,31 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
), ),
), ),
), ),
).then((value) async { );
if (value is String) {
final manager =
ref.read(walletsChangeNotifierProvider).getManager(value);
_toController.text = manager.walletName; if (address is String) {
model.recipientAddress = await manager.currentReceivingAddress; final manager =
} ref.read(walletsChangeNotifierProvider).getManager(address);
});
_toController.text = manager.walletName;
model.recipientAddress = await manager.currentReceivingAddress;
}
} catch (e, s) { } catch (e, s) {
Logging.instance.log("$e\n$s", level: LogLevel.Info); Logging.instance.log("$e\n$s", level: LogLevel.Info);
} }
setState(() {
enableNext =
_toController.text.isNotEmpty && _refundController.text.isNotEmpty;
});
} }
void selectRefundAddressFromStack() { void selectRefundAddressFromStack() async {
try { try {
final coin = coinFromTickerCaseInsensitive( final coin = coinFromTickerCaseInsensitive(
model.sendTicker, model.sendTicker,
); );
showDialog<String?>( final address = await showDialog<String?>(
context: context, context: context,
barrierColor: Colors.transparent, barrierColor: Colors.transparent,
builder: (context) => DesktopDialog( builder: (context) => DesktopDialog(
@ -112,18 +118,21 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
), ),
), ),
), ),
).then((value) async { );
if (value is String) { if (address is String) {
final manager = final manager =
ref.read(walletsChangeNotifierProvider).getManager(value); ref.read(walletsChangeNotifierProvider).getManager(address);
_refundController.text = manager.walletName; _refundController.text = manager.walletName;
model.refundAddress = await manager.currentReceivingAddress; model.refundAddress = await manager.currentReceivingAddress;
} }
});
} catch (e, s) { } catch (e, s) {
Logging.instance.log("$e\n$s", level: LogLevel.Info); Logging.instance.log("$e\n$s", level: LogLevel.Info);
} }
setState(() {
enableNext =
_toController.text.isNotEmpty && _refundController.text.isNotEmpty;
});
} }
void selectRecipientFromAddressBook() async { void selectRecipientFromAddressBook() async {
@ -168,7 +177,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
if (entry != null) { if (entry != null) {
_toController.text = entry.address; _toController.text = entry.address;
model.recipientAddress = entry.address; model.recipientAddress = entry.address;
setState(() {}); setState(() {
enableNext =
_toController.text.isNotEmpty && _refundController.text.isNotEmpty;
});
} }
} }
@ -214,7 +226,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
if (entry != null) { if (entry != null) {
_refundController.text = entry.address; _refundController.text = entry.address;
model.refundAddress = entry.address; model.refundAddress = entry.address;
setState(() {}); setState(() {
enableNext =
_toController.text.isNotEmpty && _refundController.text.isNotEmpty;
});
} }
} }
@ -334,7 +349,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
focusNode: _toFocusNode, focusNode: _toFocusNode,
style: STextStyles.field(context), style: STextStyles.field(context),
onChanged: (value) { onChanged: (value) {
setState(() {}); setState(() {
enableNext = _toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
}, },
decoration: standardInputDecoration( decoration: standardInputDecoration(
"Enter the ${model.receiveTicker.toUpperCase()} payout address", "Enter the ${model.receiveTicker.toUpperCase()} payout address",
@ -363,7 +381,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
onTap: () { onTap: () {
_toController.text = ""; _toController.text = "";
model.recipientAddress = _toController.text; model.recipientAddress = _toController.text;
setState(() {}); setState(() {
enableNext = _toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
}, },
child: const XIcon(), child: const XIcon(),
) )
@ -378,7 +399,11 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
final content = data.text!.trim(); final content = data.text!.trim();
_toController.text = content; _toController.text = content;
model.recipientAddress = _toController.text; model.recipientAddress = _toController.text;
setState(() {}); setState(() {
enableNext =
_toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
} }
}, },
child: _toController.text.isEmpty child: _toController.text.isEmpty
@ -454,7 +479,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
focusNode: _refundFocusNode, focusNode: _refundFocusNode,
style: STextStyles.field(context), style: STextStyles.field(context),
onChanged: (value) { onChanged: (value) {
setState(() {}); setState(() {
enableNext = _toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
}, },
decoration: standardInputDecoration( decoration: standardInputDecoration(
"Enter ${model.sendTicker.toUpperCase()} refund address", "Enter ${model.sendTicker.toUpperCase()} refund address",
@ -484,7 +512,10 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
_refundController.text = ""; _refundController.text = "";
model.refundAddress = _refundController.text; model.refundAddress = _refundController.text;
setState(() {}); setState(() {
enableNext = _toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
}, },
child: const XIcon(), child: const XIcon(),
) )
@ -501,7 +532,11 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
_refundController.text = content; _refundController.text = content;
model.refundAddress = _refundController.text; model.refundAddress = _refundController.text;
setState(() {}); setState(() {
enableNext =
_toController.text.isNotEmpty &&
_refundController.text.isNotEmpty;
});
} }
}, },
child: _refundController.text.isEmpty child: _refundController.text.isEmpty
@ -552,6 +587,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
Expanded( Expanded(
child: PrimaryButton( child: PrimaryButton(
label: "Next", label: "Next",
enabled: enableNext,
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: () async { onPressed: () async {
await showDialog<void>( await showDialog<void>(

View file

@ -1,11 +1,14 @@
import 'dart:async'; import 'dart:async';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
import 'package:stackwallet/pages/exchange_view/send_from_view.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart'; import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
@ -199,7 +202,38 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
child: SecondaryButton( child: SecondaryButton(
label: "Send from Stack Wallet", label: "Send from Stack Wallet",
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: Navigator.of(context).pop, onPressed: () {
final trade = model.trade!;
final amount = Decimal.parse(trade.payInAmount);
final address = trade.payInAddress;
final coin =
coinFromTickerCaseInsensitive(trade.payInCurrency);
showDialog<void>(
context: context,
builder: (context) => Navigator(
initialRoute: SendFromView.routeName,
onGenerateRoute: RouteGenerator.generateRoute,
onGenerateInitialRoutes: (_, __) {
return [
FadePageRoute(
SendFromView(
coin: coin,
trade: trade,
amount: amount,
address: address,
shouldPopRoot: true,
),
const RouteSettings(
name: SendFromView.routeName,
),
),
];
},
),
);
},
), ),
), ),
const SizedBox( const SizedBox(