2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
class TradeRow extends StatelessWidget {
|
2020-07-22 10:04:11 +00:00
|
|
|
TradeRow({
|
|
|
|
this.provider,
|
|
|
|
this.from,
|
|
|
|
this.to,
|
|
|
|
this.createdAtFormattedDate,
|
|
|
|
this.formattedAmount,
|
|
|
|
@required this.onTap});
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
final VoidCallback onTap;
|
|
|
|
final ExchangeProviderDescription provider;
|
|
|
|
final CryptoCurrency from;
|
|
|
|
final CryptoCurrency to;
|
|
|
|
final String createdAtFormattedDate;
|
|
|
|
final String formattedAmount;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-04-16 18:41:04 +00:00
|
|
|
final amountCrypto = from.toString();
|
2020-01-04 19:31:52 +00:00
|
|
|
|
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
2020-12-18 18:02:08 +00:00
|
|
|
padding: EdgeInsets.fromLTRB(24, 8, 24, 8),
|
2020-07-22 10:04:11 +00:00
|
|
|
color: Colors.transparent,
|
|
|
|
child: Row(
|
2020-12-18 18:02:08 +00:00
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
_getPoweredImage(provider),
|
|
|
|
SizedBox(width: 12),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Row(
|
2020-07-22 10:04:11 +00:00
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
2020-12-18 18:02:08 +00:00
|
|
|
Text('${from.toString()} → ${to.toString()}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
2020-12-18 19:24:05 +00:00
|
|
|
color: Theme.of(context).accentTextTheme.
|
|
|
|
display3.backgroundColor
|
2020-12-18 18:02:08 +00:00
|
|
|
)),
|
|
|
|
formattedAmount != null
|
|
|
|
? Text(formattedAmount + ' ' + amountCrypto,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w500,
|
2020-12-18 19:24:05 +00:00
|
|
|
color: Theme.of(context).accentTextTheme.
|
|
|
|
display3.backgroundColor
|
2020-12-18 18:02:08 +00:00
|
|
|
))
|
|
|
|
: Container()
|
|
|
|
]),
|
|
|
|
SizedBox(height: 5),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(createdAtFormattedDate,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Theme.of(context).textTheme
|
|
|
|
.overline.backgroundColor))
|
|
|
|
])
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2020-01-04 19:31:52 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
Image _getPoweredImage(ExchangeProviderDescription provider) {
|
|
|
|
Image image;
|
|
|
|
switch (provider) {
|
|
|
|
case ExchangeProviderDescription.xmrto:
|
2020-07-22 10:04:11 +00:00
|
|
|
image = Image.asset('assets/images/xmrto.png', height: 36, width: 36);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
|
|
|
case ExchangeProviderDescription.changeNow:
|
2020-07-22 10:04:11 +00:00
|
|
|
image = Image.asset('assets/images/changenow.png', height: 36, width: 36);
|
2020-01-04 19:31:52 +00:00
|
|
|
break;
|
2020-02-05 20:54:55 +00:00
|
|
|
case ExchangeProviderDescription.morphToken:
|
2020-07-22 10:04:11 +00:00
|
|
|
image = Image.asset('assets/images/morph.png', height: 36, width: 36);
|
2020-02-05 20:54:55 +00:00
|
|
|
break;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
|
|
|
image = null;
|
|
|
|
}
|
|
|
|
return image;
|
|
|
|
}
|
2020-07-22 10:04:11 +00:00
|
|
|
}
|