mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
close exchange step 4 back to wallet or exchange home view
This commit is contained in:
parent
e78fc3ef9e
commit
86ca402401
3 changed files with 561 additions and 515 deletions
|
@ -15,6 +15,7 @@ class IncompleteExchangeModel extends ChangeNotifier {
|
|||
final ExchangeRateType rateType;
|
||||
|
||||
final bool reversed;
|
||||
final bool walletInitiated;
|
||||
|
||||
String? _recipientAddress;
|
||||
|
||||
|
@ -68,6 +69,7 @@ class IncompleteExchangeModel extends ChangeNotifier {
|
|||
required this.receiveAmount,
|
||||
required this.rateType,
|
||||
required this.reversed,
|
||||
required this.walletInitiated,
|
||||
String? rateId,
|
||||
}) : _rateId = rateId;
|
||||
}
|
||||
|
|
|
@ -558,6 +558,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
rateType: rateType,
|
||||
rateId: estimate.rateId,
|
||||
reversed: estimate.reversed,
|
||||
walletInitiated: walletInitiated,
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import 'package:stackwallet/pages/exchange_view/send_from_view.dart';
|
|||
import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart';
|
||||
import 'package:stackwallet/pages/home_view/home_view.dart';
|
||||
import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -105,24 +106,50 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isWalletCoin =
|
||||
_isWalletCoinAndHasWallet(model.trade!.payInCurrency, ref);
|
||||
return Background(
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: AppBar(
|
||||
leading: AppBarBackButton(
|
||||
onPressed: () async {
|
||||
Future<void> _close() async {
|
||||
if (FocusScope.of(context).hasFocus) {
|
||||
FocusScope.of(context).unfocus();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 75));
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).popUntil(
|
||||
ModalRoute.withName(
|
||||
model.walletInitiated ? WalletView.routeName : HomeView.routeName,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isWalletCoin =
|
||||
_isWalletCoinAndHasWallet(model.trade!.payInCurrency, ref);
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
await _close();
|
||||
return false;
|
||||
},
|
||||
child: Background(
|
||||
child: Scaffold(
|
||||
backgroundColor:
|
||||
Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: AppBar(
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: AppBarIconButton(
|
||||
size: 32,
|
||||
color: Theme.of(context).extension<StackColors>()!.background,
|
||||
shadows: const [],
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.x,
|
||||
width: 24,
|
||||
height: 24,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.topNavIconPrimary,
|
||||
),
|
||||
onPressed: _close,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
"Exchange",
|
||||
|
@ -184,7 +211,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
TextSpan(
|
||||
text:
|
||||
"If you send less than ${model.sendAmount.toString()} ${model.sendTicker}, your transaction may not be converted and it may not be refunded.",
|
||||
style: STextStyles.label(context).copyWith(
|
||||
style:
|
||||
STextStyles.label(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.warningForeground,
|
||||
|
@ -207,12 +235,14 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
children: [
|
||||
Text(
|
||||
"Amount",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
style:
|
||||
STextStyles.itemSubtitle(context),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final data = ClipboardData(
|
||||
text: model.sendAmount.toString());
|
||||
text:
|
||||
model.sendAmount.toString());
|
||||
await clipboard.setData(data);
|
||||
unawaited(showFloatingFlushBar(
|
||||
type: FlushBarType.info,
|
||||
|
@ -264,7 +294,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
children: [
|
||||
Text(
|
||||
"Send ${model.sendTicker.toUpperCase()} to this address",
|
||||
style: STextStyles.itemSubtitle(context),
|
||||
style:
|
||||
STextStyles.itemSubtitle(context),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
|
@ -358,7 +389,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
),
|
||||
RoundedWhiteContainer(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Status",
|
||||
|
@ -425,7 +457,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).pop(),
|
||||
Navigator.of(context)
|
||||
.pop(),
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(
|
||||
|
@ -469,7 +502,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
String buttonTitle = "Send from Stack Wallet";
|
||||
|
||||
final tuple = ref
|
||||
.read(exchangeSendFromWalletIdStateProvider
|
||||
.read(
|
||||
exchangeSendFromWalletIdStateProvider
|
||||
.state)
|
||||
.state;
|
||||
if (tuple != null &&
|
||||
|
@ -511,7 +545,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
onCancel: () {
|
||||
wasCancelled = true;
|
||||
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
|
@ -522,7 +557,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
address: address,
|
||||
satoshiAmount: amount,
|
||||
args: {
|
||||
"feeRate": FeeRateType.average,
|
||||
"feeRate":
|
||||
FeeRateType.average,
|
||||
// ref.read(feeRateTypeStateProvider)
|
||||
},
|
||||
);
|
||||
|
@ -540,7 +576,8 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
|
||||
if (mounted) {
|
||||
unawaited(
|
||||
Navigator.of(context).push(
|
||||
Navigator.of(context)
|
||||
.push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute:
|
||||
RouteGenerator
|
||||
|
@ -584,10 +621,12 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(
|
||||
style:
|
||||
STextStyles.button(
|
||||
context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
color: Theme.of(
|
||||
context)
|
||||
.extension<
|
||||
StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
|
@ -610,15 +649,16 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
shouldUseMaterialRoute:
|
||||
RouteGenerator
|
||||
.useMaterialPageRoute,
|
||||
builder: (BuildContext context) {
|
||||
builder:
|
||||
(BuildContext context) {
|
||||
return SendFromView(
|
||||
coin:
|
||||
coinFromTickerCaseInsensitive(
|
||||
model.trade!
|
||||
.payInCurrency),
|
||||
amount: model.sendAmount,
|
||||
address:
|
||||
model.trade!.payInAddress,
|
||||
address: model
|
||||
.trade!.payInAddress,
|
||||
trade: model.trade!,
|
||||
);
|
||||
},
|
||||
|
@ -630,10 +670,12 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
},
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(context),
|
||||
.getSecondaryEnabledButtonStyle(
|
||||
context),
|
||||
child: Text(
|
||||
buttonTitle,
|
||||
style: STextStyles.button(context).copyWith(
|
||||
style:
|
||||
STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextSecondary,
|
||||
|
@ -652,6 +694,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
|||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue