mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
exchange form desktop routing and dialogs
This commit is contained in:
parent
5f1a485ed5
commit
a8faa7b8e7
2 changed files with 229 additions and 59 deletions
|
@ -30,7 +30,11 @@ 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_loading_overlay.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/desktop/simple_desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
@ -139,14 +143,27 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
.read(exchangeFormStateProvider)
|
||||
.updateMarket(market, true);
|
||||
} catch (e) {
|
||||
unawaited(showDialog<dynamic>(
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
builder: (_) => const StackDialog(
|
||||
builder: (_) {
|
||||
if (isDesktop) {
|
||||
return const SimpleDesktopDialog(
|
||||
title: "Fixed rate market error",
|
||||
message:
|
||||
"Could not find the specified fixed rate trade pair",
|
||||
);
|
||||
} else {
|
||||
return const StackDialog(
|
||||
title: "Fixed rate market error",
|
||||
message:
|
||||
"Could not find the specified fixed rate trade pair",
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
@ -229,14 +246,26 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
.read(exchangeFormStateProvider)
|
||||
.updateMarket(market, true);
|
||||
} catch (e) {
|
||||
unawaited(showDialog<dynamic>(
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
builder: (_) => const StackDialog(
|
||||
builder: (_) {
|
||||
if (isDesktop) {
|
||||
return const SimpleDesktopDialog(
|
||||
title: "Fixed rate market error",
|
||||
message:
|
||||
"Could not find the specified fixed rate trade pair",
|
||||
);
|
||||
} else {
|
||||
return const StackDialog(
|
||||
title: "Fixed rate market error",
|
||||
message:
|
||||
"Could not find the specified fixed rate trade pair",
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
));
|
||||
);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
@ -324,7 +353,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
await ref.read(exchangeFormStateProvider).swap();
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
_swapLock = false;
|
||||
}
|
||||
|
@ -567,14 +596,14 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
? "-"
|
||||
: ref.read(exchangeFormStateProvider).toAmountString;
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
if (!(fromTicker == "-" || toTicker == "-")) {
|
||||
unawaited(
|
||||
|
@ -620,7 +649,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
true,
|
||||
);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
return;
|
||||
case SimpleSwapExchange.exchangeName:
|
||||
|
@ -657,7 +686,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
? "-"
|
||||
: ref.read(exchangeFormStateProvider).toAmountString;
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -669,7 +698,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
}
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||
}
|
||||
unawaited(
|
||||
showFloatingFlushBar(
|
||||
|
@ -722,15 +751,27 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
}
|
||||
|
||||
if (!isAvailable) {
|
||||
unawaited(showDialog<dynamic>(
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (_) => StackDialog(
|
||||
builder: (_) {
|
||||
if (isDesktop) {
|
||||
return SimpleDesktopDialog(
|
||||
title: "Selected trade pair unavailable",
|
||||
message:
|
||||
"The $fromTicker - $toTicker market is currently disabled for estimated/floating rate trades",
|
||||
);
|
||||
} else {
|
||||
return StackDialog(
|
||||
title: "Selected trade pair unavailable",
|
||||
message:
|
||||
"The $fromTicker - $toTicker market is currently disabled for estimated/floating rate trades",
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
));
|
||||
);
|
||||
return;
|
||||
}
|
||||
rate =
|
||||
|
@ -744,7 +785,69 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
shouldCancel = await showDialog<bool?>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (_) => StackDialog(
|
||||
builder: (_) {
|
||||
if (isDesktop) {
|
||||
return DesktopDialog(
|
||||
maxWidth: 500,
|
||||
maxHeight: 300,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Failed to update trade estimate",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
estimate.warningMessage!,
|
||||
style: STextStyles.desktopTextSmall(context),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
"Do you want to attempt trade anyways?",
|
||||
style: STextStyles.desktopTextSmall(context),
|
||||
),
|
||||
const Spacer(
|
||||
flex: 2,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
label: "Cancel",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
onPressed: () => Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pop(true),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
label: "Attempt",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
onPressed: () => Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pop(false),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return StackDialog(
|
||||
title: "Failed to update trade estimate",
|
||||
message:
|
||||
"${estimate.warningMessage!}\n\nDo you want to attempt trade anyways?",
|
||||
|
@ -774,7 +877,9 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
Navigator.of(context).pop(false);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
65
lib/widgets/desktop/simple_desktop_dialog.dart
Normal file
65
lib/widgets/desktop/simple_desktop_dialog.dart
Normal file
|
@ -0,0 +1,65 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.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';
|
||||
|
||||
class SimpleDesktopDialog extends StatelessWidget {
|
||||
const SimpleDesktopDialog({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.message,
|
||||
}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
final String message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DesktopDialog(
|
||||
maxWidth: 500,
|
||||
maxHeight: 300,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
message,
|
||||
style: STextStyles.desktopTextSmall(context),
|
||||
),
|
||||
const Spacer(
|
||||
flex: 2,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
label: "Ok",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
onPressed: Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pop,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue