mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 09:29:48 +00:00
CAKE-306 | reworked buy_list_item.dart and pre_order_page.dart; added clear button to pre_order_page.dart; fixed order_row.dart and order_details_view_model.dart; added MoonPay statuses to trade_state.dart
This commit is contained in:
parent
19ffffa6cc
commit
697fc7f5a5
10 changed files with 148 additions and 92 deletions
BIN
assets/images/moonpay-icon.png
Normal file
BIN
assets/images/moonpay-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -94,8 +94,9 @@ class MoonPayBuyProvider extends BuyProvider {
|
|||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
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(
|
||||
|
|
|
@ -27,6 +27,12 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
|||
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<String> with Serializable<String> {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,23 @@ class BuyWebViewPageBodyState extends State<BuyWebViewPageBody> {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
),
|
||||
)
|
||||
),
|
||||
|
|
|
@ -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
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue