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 =
|
final _wyreIcon =
|
||||||
Image.asset('assets/images/wyre-icon.png', width: 36, height: 36);
|
Image.asset('assets/images/wyre-icon.png', width: 36, height: 36);
|
||||||
final _moonPayIcon =
|
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) {
|
if (providerDescription != null) {
|
||||||
switch (providerDescription) {
|
switch (providerDescription) {
|
||||||
case BuyProviderDescription.wyre:
|
case BuyProviderDescription.wyre:
|
||||||
return _wyreIcon;
|
return _wyreIcon;
|
||||||
case BuyProviderDescription.moonPay:
|
case BuyProviderDescription.moonPay:
|
||||||
//return _moonPayIcon;
|
return _moonPayIcon;
|
||||||
return null;
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,9 @@ class MoonPayBuyProvider extends BuyProvider {
|
||||||
|
|
||||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||||
final status = responseJSON['status'] as String;
|
final status = responseJSON['status'] as String;
|
||||||
final state = TradeState.deserialize(raw: status.toLowerCase());
|
final state = TradeState.deserialize(raw: status);
|
||||||
final createdAt = responseJSON['createdAt'] as DateTime;
|
final createdAtRaw = responseJSON['createdAt'] as String;
|
||||||
|
final createdAt = DateTime.parse(createdAtRaw).toLocal();
|
||||||
final amount = responseJSON['quoteCurrencyAmount'] as double;
|
final amount = responseJSON['quoteCurrencyAmount'] as double;
|
||||||
|
|
||||||
return Order(
|
return Order(
|
||||||
|
|
|
@ -27,6 +27,12 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
||||||
static const finished = TradeState(raw: 'finished', title: 'Finished');
|
static const finished = TradeState(raw: 'finished', title: 'Finished');
|
||||||
static const waiting = TradeState(raw: 'waiting', title: 'Waiting');
|
static const waiting = TradeState(raw: 'waiting', title: 'Waiting');
|
||||||
static const processing = TradeState(raw: 'processing', title: 'Processing');
|
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}) {
|
static TradeState deserialize({String raw}) {
|
||||||
switch (raw) {
|
switch (raw) {
|
||||||
|
@ -62,6 +68,14 @@ class TradeState extends EnumerableItem<String> with Serializable<String> {
|
||||||
return waiting;
|
return waiting;
|
||||||
case 'processing':
|
case 'processing':
|
||||||
return processing;
|
return processing;
|
||||||
|
case 'waitingPayment':
|
||||||
|
return waitingPayment;
|
||||||
|
case 'waitingAuthorization':
|
||||||
|
return waitingAuthorization;
|
||||||
|
case 'failed':
|
||||||
|
return failed;
|
||||||
|
case 'completed':
|
||||||
|
return completed;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,23 @@ class BuyWebViewPageBodyState extends State<BuyWebViewPageBody> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_provider is MoonPayBuyProvider) {
|
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/src/widgets/scollable_with_bottom_section.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.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/base_text_form_field.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
class PreOrderPage extends BasePage {
|
class PreOrderPage extends BasePage {
|
||||||
|
@ -61,6 +62,13 @@ class PreOrderPage extends BasePage {
|
||||||
@override
|
@override
|
||||||
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget trailing(context) => TrailButton(
|
||||||
|
caption: S.of(context).clear,
|
||||||
|
onPressed: () {
|
||||||
|
buyViewModel.reset();
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
return KeyboardActions(
|
return KeyboardActions(
|
||||||
|
@ -96,43 +104,49 @@ class PreOrderPage extends BasePage {
|
||||||
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.fromLTRB(100, 100, 100, 65),
|
padding: EdgeInsets.only(top: 100, bottom: 65),
|
||||||
child: BaseTextFormField(
|
child: Center(
|
||||||
focusNode: _amountFocus,
|
child: Container(
|
||||||
controller: _amountController,
|
width: 165,
|
||||||
keyboardType:
|
child: BaseTextFormField(
|
||||||
TextInputType.numberWithOptions(
|
focusNode: _amountFocus,
|
||||||
signed: false, decimal: true),
|
controller: _amountController,
|
||||||
inputFormatters: [
|
keyboardType:
|
||||||
FilteringTextInputFormatter
|
TextInputType.numberWithOptions(
|
||||||
.allow(RegExp(_amountPattern))
|
signed: false, decimal: true),
|
||||||
],
|
inputFormatters: [
|
||||||
prefixIcon: Padding(
|
FilteringTextInputFormatter
|
||||||
padding: EdgeInsets.only(top: 2),
|
.allow(RegExp(_amountPattern))
|
||||||
child:
|
],
|
||||||
Text(buyViewModel.fiatCurrency.title + ': ',
|
prefixIcon: Padding(
|
||||||
style: TextStyle(
|
padding: EdgeInsets.only(top: 2),
|
||||||
fontSize: 36,
|
child:
|
||||||
fontWeight: FontWeight.w600,
|
Text(buyViewModel.fiatCurrency.title + ': ',
|
||||||
color: Colors.white,
|
style: TextStyle(
|
||||||
)),
|
fontSize: 36,
|
||||||
),
|
fontWeight: FontWeight.w600,
|
||||||
hintText: '0.00',
|
color: Colors.white,
|
||||||
borderColor: Theme.of(context)
|
)),
|
||||||
.primaryTextTheme
|
),
|
||||||
.headline
|
hintText: '0.00',
|
||||||
.color,
|
borderColor: Theme.of(context)
|
||||||
textStyle: TextStyle(
|
|
||||||
fontSize: 36,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.white),
|
|
||||||
placeholderTextStyle: TextStyle(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
.primaryTextTheme
|
||||||
.headline
|
.body2
|
||||||
.decorationColor,
|
.decorationColor,
|
||||||
fontWeight: FontWeight.w500,
|
borderWidth: 0.5,
|
||||||
fontSize: 36),
|
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(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryTextTheme.title.color,
|
color: Theme.of(context).primaryTextTheme.title.color,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w500
|
fontWeight: FontWeight.bold
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
|
@ -52,62 +52,67 @@ class BuyListItem extends StatelessWidget {
|
||||||
height: 102,
|
height: 102,
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 20,
|
left: 20,
|
||||||
|
//top: 33,
|
||||||
right: 20
|
right: 20
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(25)),
|
borderRadius: BorderRadius.all(Radius.circular(25)),
|
||||||
color: backgroundColor
|
color: backgroundColor
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Stack(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Positioned(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
top: 33,
|
||||||
mainAxisSize: MainAxisSize.min,
|
left: 0,
|
||||||
children: [
|
right: 0,
|
||||||
if (providerIcon != null) Padding(
|
child: Row(
|
||||||
padding: EdgeInsets.only(right: 10),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: providerIcon
|
mainAxisSize: MainAxisSize.max,
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
Text(
|
children: [
|
||||||
provider.description.title,
|
Row(
|
||||||
style: TextStyle(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
color: primaryTextColor,
|
mainAxisSize: MainAxisSize.min,
|
||||||
fontSize: 24,
|
children: [
|
||||||
fontWeight: FontWeight.w500
|
if (providerIcon != null) Padding(
|
||||||
|
padding: EdgeInsets.only(right: 10),
|
||||||
|
child: providerIcon
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
provider.description.title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: secondaryTextColor,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
Text(
|
||||||
],
|
'${destAmount?.toString()} ${destCurrency.title}',
|
||||||
),
|
|
||||||
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}',
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: primaryTextColor,
|
color: secondaryTextColor,
|
||||||
fontSize: 18,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w500
|
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,
|
mainAxisSize: MainAxisSize.max,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
providerIcon ?? Offstage(),
|
if (providerIcon != null) Padding(
|
||||||
SizedBox(width: 12),
|
padding: EdgeInsets.only(right: 12),
|
||||||
|
child: providerIcon,
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
@ -26,7 +26,8 @@ class BaseTextFormField extends StatelessWidget {
|
||||||
this.placeholderTextStyle,
|
this.placeholderTextStyle,
|
||||||
this.maxLength,
|
this.maxLength,
|
||||||
this.focusNode,
|
this.focusNode,
|
||||||
this.initialValue});
|
this.initialValue,
|
||||||
|
this.borderWidth = 1.0});
|
||||||
|
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final TextInputType keyboardType;
|
final TextInputType keyboardType;
|
||||||
|
@ -52,6 +53,7 @@ class BaseTextFormField extends StatelessWidget {
|
||||||
final bool readOnly;
|
final bool readOnly;
|
||||||
final bool enableInteractiveSelection;
|
final bool enableInteractiveSelection;
|
||||||
final String initialValue;
|
final String initialValue;
|
||||||
|
final double borderWidth;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -88,17 +90,17 @@ class BaseTextFormField extends StatelessWidget {
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: borderColor ??
|
color: borderColor ??
|
||||||
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||||
width: 1.0)),
|
width: borderWidth)),
|
||||||
disabledBorder: UnderlineInputBorder(
|
disabledBorder: UnderlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: borderColor ??
|
color: borderColor ??
|
||||||
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||||
width: 1.0)),
|
width: borderWidth)),
|
||||||
enabledBorder: UnderlineInputBorder(
|
enabledBorder: UnderlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: borderColor ??
|
color: borderColor ??
|
||||||
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
||||||
width: 1.0))),
|
width: borderWidth))),
|
||||||
validator: validator,
|
validator: validator,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,9 @@ abstract class OrderDetailsViewModelBase with Store {
|
||||||
final updatedOrder = await _provider.findOrderById(order.id);
|
final updatedOrder = await _provider.findOrderById(order.id);
|
||||||
updatedOrder.receiveAddress = order.receiveAddress;
|
updatedOrder.receiveAddress = order.receiveAddress;
|
||||||
updatedOrder.walletId = order.walletId;
|
updatedOrder.walletId = order.walletId;
|
||||||
|
if (order.provider != null) {
|
||||||
|
updatedOrder.providerRaw = order.provider.raw;
|
||||||
|
}
|
||||||
order = updatedOrder;
|
order = updatedOrder;
|
||||||
_updateItems();
|
_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}';
|
final buildURL = _provider.trackUrl + '${order.transferId}';
|
||||||
items.add(
|
items.add(
|
||||||
TrackTradeListItem(
|
TrackTradeListItem(
|
||||||
|
|
Loading…
Reference in a new issue