diff --git a/assets/images/moonpay-icon.png b/assets/images/moonpay-icon.png new file mode 100644 index 000000000..1fbc2b6fc Binary files /dev/null and b/assets/images/moonpay-icon.png differ diff --git a/lib/buy/get_buy_provider_icon.dart b/lib/buy/get_buy_provider_icon.dart index d58fe19d4..bbd599e24 100644 --- a/lib/buy/get_buy_provider_icon.dart +++ b/lib/buy/get_buy_provider_icon.dart @@ -5,15 +5,14 @@ Image getBuyProviderIcon(BuyProviderDescription providerDescription) { final _wyreIcon = Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); final _moonPayIcon = - Image.asset('assets/images/wyre-icon.png', width: 36, height: 36); + Image.asset('assets/images/moonpay-icon.png', width: 36, height: 34); if (providerDescription != null) { switch (providerDescription) { case BuyProviderDescription.wyre: return _wyreIcon; case BuyProviderDescription.moonPay: - //return _moonPayIcon; - return null; + return _moonPayIcon; default: return null; } diff --git a/lib/buy/moonpay/moonpay_buy_provider.dart b/lib/buy/moonpay/moonpay_buy_provider.dart index 2fde667e4..5b2fd7326 100644 --- a/lib/buy/moonpay/moonpay_buy_provider.dart +++ b/lib/buy/moonpay/moonpay_buy_provider.dart @@ -94,8 +94,9 @@ class MoonPayBuyProvider extends BuyProvider { final responseJSON = json.decode(response.body) as Map; final status = responseJSON['status'] as String; - final state = TradeState.deserialize(raw: status.toLowerCase()); - final createdAt = responseJSON['createdAt'] as DateTime; + final state = TradeState.deserialize(raw: status); + final createdAtRaw = responseJSON['createdAt'] as String; + final createdAt = DateTime.parse(createdAtRaw).toLocal(); final amount = responseJSON['quoteCurrencyAmount'] as double; return Order( diff --git a/lib/exchange/trade_state.dart b/lib/exchange/trade_state.dart index 7095626b9..9f08b4df2 100644 --- a/lib/exchange/trade_state.dart +++ b/lib/exchange/trade_state.dart @@ -27,6 +27,12 @@ class TradeState extends EnumerableItem with Serializable { static const finished = TradeState(raw: 'finished', title: 'Finished'); static const waiting = TradeState(raw: 'waiting', title: 'Waiting'); static const processing = TradeState(raw: 'processing', title: 'Processing'); + static const waitingPayment = + TradeState(raw: 'waitingPayment', title: 'Waiting payment'); + static const waitingAuthorization = + TradeState(raw: 'waitingAuthorization', title: 'Waiting authorization'); + static const failed = TradeState(raw: 'failed', title: 'Failed'); + static const completed = TradeState(raw: 'completed', title: 'Completed'); static TradeState deserialize({String raw}) { switch (raw) { @@ -62,6 +68,14 @@ class TradeState extends EnumerableItem with Serializable { return waiting; case 'processing': return processing; + case 'waitingPayment': + return waitingPayment; + case 'waitingAuthorization': + return waitingAuthorization; + case 'failed': + return failed; + case 'completed': + return completed; default: return null; } diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart index 91e93f902..d5ab59482 100644 --- a/lib/src/screens/buy/buy_webview_page.dart +++ b/lib/src/screens/buy/buy_webview_page.dart @@ -92,7 +92,23 @@ class BuyWebViewPageBodyState extends State { } if (_provider is MoonPayBuyProvider) { - // FIXME: fetch orderId + /*_timer?.cancel(); + _timer = Timer.periodic(Duration(seconds: 1), (timer) async { + + try { + if (_webViewController == null || _isSaving) { + return; + } + + final url = await _webViewController.currentUrl(); + print('MoonPay Url = $url'); + + timer.cancel(); + } catch (e) { + _isSaving = false; + print(e); + } + });*/ } } diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index 0cf6a1f88..44162d7ec 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -14,6 +14,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; +import 'package:cake_wallet/src/widgets/trail_button.dart'; import 'package:mobx/mobx.dart'; class PreOrderPage extends BasePage { @@ -61,6 +62,13 @@ class PreOrderPage extends BasePage { @override AppBarStyle get appBarStyle => AppBarStyle.transparent; + @override + Widget trailing(context) => TrailButton( + caption: S.of(context).clear, + onPressed: () { + buyViewModel.reset(); + }); + @override Widget body(BuildContext context) { return KeyboardActions( @@ -96,43 +104,49 @@ class PreOrderPage extends BasePage { ], begin: Alignment.topLeft, end: Alignment.bottomRight), ), child: Padding( - padding: EdgeInsets.fromLTRB(100, 100, 100, 65), - child: BaseTextFormField( - focusNode: _amountFocus, - controller: _amountController, - keyboardType: - TextInputType.numberWithOptions( - signed: false, decimal: true), - inputFormatters: [ - FilteringTextInputFormatter - .allow(RegExp(_amountPattern)) - ], - prefixIcon: Padding( - padding: EdgeInsets.only(top: 2), - child: - Text(buyViewModel.fiatCurrency.title + ': ', - style: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w600, - color: Colors.white, - )), - ), - hintText: '0.00', - borderColor: Theme.of(context) - .primaryTextTheme - .headline - .color, - textStyle: TextStyle( - fontSize: 36, - fontWeight: FontWeight.w500, - color: Colors.white), - placeholderTextStyle: TextStyle( - color: Theme.of(context) + padding: EdgeInsets.only(top: 100, bottom: 65), + child: Center( + child: Container( + width: 165, + child: BaseTextFormField( + focusNode: _amountFocus, + controller: _amountController, + keyboardType: + TextInputType.numberWithOptions( + signed: false, decimal: true), + inputFormatters: [ + FilteringTextInputFormatter + .allow(RegExp(_amountPattern)) + ], + prefixIcon: Padding( + padding: EdgeInsets.only(top: 2), + child: + Text(buyViewModel.fiatCurrency.title + ': ', + style: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w600, + color: Colors.white, + )), + ), + hintText: '0.00', + borderColor: Theme.of(context) .primaryTextTheme - .headline + .body2 .decorationColor, - fontWeight: FontWeight.w500, - fontSize: 36), + borderWidth: 0.5, + textStyle: TextStyle( + fontSize: 36, + fontWeight: FontWeight.w500, + color: Colors.white), + placeholderTextStyle: TextStyle( + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor, + fontWeight: FontWeight.w500, + fontSize: 36), + ) + ) ) ) ), @@ -144,7 +158,7 @@ class PreOrderPage extends BasePage { style: TextStyle( color: Theme.of(context).primaryTextTheme.title.color, fontSize: 18, - fontWeight: FontWeight.w500 + fontWeight: FontWeight.bold ), ) ), diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart index 8ee3950aa..7c18893a6 100644 --- a/lib/src/screens/buy/widgets/buy_list_item.dart +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -52,62 +52,67 @@ class BuyListItem extends StatelessWidget { height: 102, padding: EdgeInsets.only( left: 20, + //top: 33, right: 20 ), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(25)), color: backgroundColor ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, + child: Stack( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (providerIcon != null) Padding( - padding: EdgeInsets.only(right: 10), - child: providerIcon - ), - Text( - provider.description.title, - style: TextStyle( - color: primaryTextColor, - fontSize: 24, - fontWeight: FontWeight.w500 + Positioned( + top: 33, + left: 0, + right: 0, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (providerIcon != null) Padding( + padding: EdgeInsets.only(right: 10), + child: providerIcon + ), + Text( + provider.description.title, + style: TextStyle( + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold + ), + ) + ], ), - ) - ], - ), - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - '${destAmount?.toString()} ${destCurrency.title}', - style: TextStyle( - color: secondaryTextColor, - fontSize: 18, - fontWeight: FontWeight.w500 - ), - ), - Padding( - padding: EdgeInsets.only(top: 5), - child: Text( - '${sourceAmount?.toString()} ${sourceCurrency.title}', + Text( + '${destAmount?.toString()} ${destCurrency.title}', style: TextStyle( - color: primaryTextColor, - fontSize: 18, - fontWeight: FontWeight.w500 + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold ), ), - ) - ], + ], + ) + ), + Positioned( + top: 65, + right: 0, + child: Text( + '${sourceAmount?.toString()} ${sourceCurrency.title}', + style: TextStyle( + color: primaryTextColor, + fontSize: 16, + fontWeight: FontWeight.bold + ), + ), ) ], - ), + ) ) ); } diff --git a/lib/src/screens/dashboard/widgets/order_row.dart b/lib/src/screens/dashboard/widgets/order_row.dart index 49afa7a25..56a69122e 100644 --- a/lib/src/screens/dashboard/widgets/order_row.dart +++ b/lib/src/screens/dashboard/widgets/order_row.dart @@ -30,8 +30,10 @@ class OrderRow extends StatelessWidget { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ - providerIcon ?? Offstage(), - SizedBox(width: 12), + if (providerIcon != null) Padding( + padding: EdgeInsets.only(right: 12), + child: providerIcon, + ), Expanded( child: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/src/widgets/base_text_form_field.dart b/lib/src/widgets/base_text_form_field.dart index b9148bf2c..385cba8cd 100644 --- a/lib/src/widgets/base_text_form_field.dart +++ b/lib/src/widgets/base_text_form_field.dart @@ -26,7 +26,8 @@ class BaseTextFormField extends StatelessWidget { this.placeholderTextStyle, this.maxLength, this.focusNode, - this.initialValue}); + this.initialValue, + this.borderWidth = 1.0}); final TextEditingController controller; final TextInputType keyboardType; @@ -52,6 +53,7 @@ class BaseTextFormField extends StatelessWidget { final bool readOnly; final bool enableInteractiveSelection; final String initialValue; + final double borderWidth; @override Widget build(BuildContext context) { @@ -88,17 +90,17 @@ class BaseTextFormField extends StatelessWidget { borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0)), + width: borderWidth)), disabledBorder: UnderlineInputBorder( borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0)), + width: borderWidth)), enabledBorder: UnderlineInputBorder( borderSide: BorderSide( color: borderColor ?? Theme.of(context).primaryTextTheme.title.backgroundColor, - width: 1.0))), + width: borderWidth))), validator: validator, ); } diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 8e8ed3c18..328b0c93c 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -58,6 +58,9 @@ abstract class OrderDetailsViewModelBase with Store { final updatedOrder = await _provider.findOrderById(order.id); updatedOrder.receiveAddress = order.receiveAddress; updatedOrder.walletId = order.walletId; + if (order.provider != null) { + updatedOrder.providerRaw = order.provider.raw; + } order = updatedOrder; _updateItems(); } @@ -90,7 +93,7 @@ abstract class OrderDetailsViewModelBase with Store { ); } - if (_provider.trackUrl.isNotEmpty) { + if (_provider?.trackUrl?.isNotEmpty ?? false) { final buildURL = _provider.trackUrl + '${order.transferId}'; items.add( TrackTradeListItem(