mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
handle refund address support
This commit is contained in:
parent
b19a3dbbf8
commit
8061f0811d
2 changed files with 285 additions and 250 deletions
|
@ -8,6 +8,7 @@ import 'package:stackwallet/pages/exchange_view/choose_from_stack_view.dart';
|
|||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
|
@ -123,6 +124,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final supportsRefund =
|
||||
ref.watch(currentExchangeNameStateProvider.state).state !=
|
||||
MajesticBankExchange.exchangeName;
|
||||
|
||||
return Background(
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
|
@ -217,8 +222,9 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
setState(() {
|
||||
enableNext =
|
||||
_toController.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController
|
||||
.text.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -291,8 +297,9 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController.text
|
||||
.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
},
|
||||
child: const XIcon(),
|
||||
|
@ -318,8 +325,10 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
enableNext = _toController
|
||||
.text
|
||||
.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController
|
||||
.text
|
||||
.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -367,8 +376,9 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController.text
|
||||
.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -396,8 +406,9 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController.text
|
||||
.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
} else {
|
||||
_toController.text =
|
||||
|
@ -408,8 +419,9 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
(_refundController.text
|
||||
.isNotEmpty ||
|
||||
!supportsRefund);
|
||||
});
|
||||
}
|
||||
} on PlatformException catch (e, s) {
|
||||
|
@ -440,6 +452,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
if (supportsRefund)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
@ -474,22 +487,25 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
.currentReceivingAddress;
|
||||
}
|
||||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
_refundController.text.isNotEmpty;
|
||||
enableNext =
|
||||
_toController.text.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
});
|
||||
});
|
||||
} catch (e, s) {
|
||||
Logging.instance
|
||||
.log("$e\n$s", level: LogLevel.Info);
|
||||
Logging.instance.log("$e\n$s",
|
||||
level: LogLevel.Info);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (supportsRefund)
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
if (supportsRefund)
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
|
@ -546,7 +562,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
|
||||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
.text
|
||||
.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
});
|
||||
|
@ -559,23 +576,27 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
onTap: () async {
|
||||
final ClipboardData? data =
|
||||
await clipboard.getData(
|
||||
Clipboard.kTextPlain);
|
||||
Clipboard
|
||||
.kTextPlain);
|
||||
if (data?.text != null &&
|
||||
data!.text!.isNotEmpty) {
|
||||
data!
|
||||
.text!.isNotEmpty) {
|
||||
final content =
|
||||
data.text!.trim();
|
||||
|
||||
_refundController.text =
|
||||
content;
|
||||
model.refundAddress =
|
||||
_refundController.text;
|
||||
_refundController
|
||||
.text;
|
||||
|
||||
setState(() {
|
||||
enableNext = _toController
|
||||
.text
|
||||
.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
.text
|
||||
.isNotEmpty;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -640,13 +661,15 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
if (results.isNotEmpty) {
|
||||
// auto fill address
|
||||
_refundController.text =
|
||||
results["address"] ?? "";
|
||||
results["address"] ??
|
||||
"";
|
||||
model.refundAddress =
|
||||
_refundController.text;
|
||||
|
||||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
.text
|
||||
.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
});
|
||||
|
@ -658,7 +681,8 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
|
||||
setState(() {
|
||||
enableNext = _toController
|
||||
.text.isNotEmpty &&
|
||||
.text
|
||||
.isNotEmpty &&
|
||||
_refundController
|
||||
.text.isNotEmpty;
|
||||
});
|
||||
|
@ -679,9 +703,11 @@ class _Step2ViewState extends ConsumerState<Step2View> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (supportsRefund)
|
||||
const SizedBox(
|
||||
height: 6,
|
||||
),
|
||||
if (supportsRefund)
|
||||
RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"In case something goes wrong during the exchange, we might need a refund address so we can return your coins back to you.",
|
||||
|
|
|
@ -7,9 +7,11 @@ import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
|||
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
|
||||
import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart';
|
||||
import 'package:stackwallet/providers/exchange/current_exchange_name_state_provider.dart';
|
||||
import 'package:stackwallet/providers/exchange/exchange_provider.dart';
|
||||
import 'package:stackwallet/providers/global/trades_service_provider.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/services/notifications_api.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||
|
@ -51,6 +53,10 @@ class _Step3ViewState extends ConsumerState<Step3View> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final supportsRefund =
|
||||
ref.watch(currentExchangeNameStateProvider.state).state !=
|
||||
MajesticBankExchange.exchangeName;
|
||||
|
||||
return Background(
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
|
@ -174,9 +180,11 @@ class _Step3ViewState extends ConsumerState<Step3View> {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (supportsRefund)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
if (supportsRefund)
|
||||
RoundedWhiteContainer(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -259,8 +267,9 @@ class _Step3ViewState extends ConsumerState<Step3View> {
|
|||
addressTo:
|
||||
model.recipientAddress!,
|
||||
extraId: null,
|
||||
addressRefund:
|
||||
model.refundAddress!,
|
||||
addressRefund: supportsRefund
|
||||
? model.refundAddress!
|
||||
: "",
|
||||
refundExtraId: "",
|
||||
rateId: model.rateId,
|
||||
reversed: model.reversed,
|
||||
|
|
Loading…
Reference in a new issue