2020-01-04 19:31:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
|
|
|
import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart';
|
|
|
|
|
|
|
|
class TradeRow extends StatelessWidget {
|
|
|
|
TradeRow(
|
|
|
|
{this.provider,
|
|
|
|
this.from,
|
|
|
|
this.to,
|
|
|
|
this.createdAtFormattedDate,
|
|
|
|
this.formattedAmount,
|
|
|
|
@required this.onTap});
|
|
|
|
|
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-04-25 16:17:59 +00:00
|
|
|
height: 60,
|
2020-04-18 09:17:52 +00:00
|
|
|
decoration: BoxDecoration(
|
2020-05-29 15:10:11 +00:00
|
|
|
color: Theme.of(context).backgroundColor,
|
2020-04-18 09:17:52 +00:00
|
|
|
border: Border.all(
|
2020-04-21 14:31:25 +00:00
|
|
|
width: 1,
|
2020-05-29 15:10:11 +00:00
|
|
|
color: Theme.of(context).backgroundColor
|
2020-04-18 09:17:52 +00:00
|
|
|
),
|
|
|
|
),
|
2020-04-17 19:40:11 +00:00
|
|
|
padding: EdgeInsets.only(top: 5, bottom: 5, left: 20, right: 20),
|
2020-01-04 19:31:52 +00:00
|
|
|
child: Row(children: <Widget>[
|
2020-04-16 18:41:04 +00:00
|
|
|
Container(
|
|
|
|
height: 36,
|
|
|
|
width: 36,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
2020-05-29 15:10:11 +00:00
|
|
|
color: Theme.of(context).backgroundColor
|
2020-04-16 18:41:04 +00:00
|
|
|
),
|
|
|
|
child: _getPoweredImage(provider),
|
|
|
|
),
|
2020-01-04 19:31:52 +00:00
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
2020-04-16 18:41:04 +00:00
|
|
|
padding: const EdgeInsets.only(left: 10),
|
2020-01-04 19:31:52 +00:00
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
|
|
|
Text('${from.toString()} → ${to.toString()}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
2020-05-29 15:10:11 +00:00
|
|
|
color: Theme.of(context).primaryTextTheme.title.color
|
2020-04-16 18:41:04 +00:00
|
|
|
)),
|
2020-01-04 19:31:52 +00:00
|
|
|
formattedAmount != null
|
|
|
|
? Text(formattedAmount + ' ' + amountCrypto,
|
2020-05-29 15:10:11 +00:00
|
|
|
style: TextStyle(
|
2020-04-17 19:40:11 +00:00
|
|
|
fontSize: 16,
|
2020-05-29 15:10:11 +00:00
|
|
|
color: Theme.of(context).primaryTextTheme.title.color
|
2020-04-17 19:40:11 +00:00
|
|
|
))
|
2020-01-04 19:31:52 +00:00
|
|
|
: Container()
|
|
|
|
]),
|
2020-04-16 18:41:04 +00:00
|
|
|
SizedBox(height: 5),
|
2020-01-04 19:31:52 +00:00
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(createdAtFormattedDate,
|
2020-05-29 15:10:11 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14, color: Theme.of(context).primaryTextTheme.headline.color))
|
2020-01-04 19:31:52 +00:00
|
|
|
]),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
))
|
|
|
|
]),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
Image _getPoweredImage(ExchangeProviderDescription provider) {
|
|
|
|
Image image;
|
|
|
|
switch (provider) {
|
|
|
|
case ExchangeProviderDescription.xmrto:
|
|
|
|
image = Image.asset('assets/images/xmr_btc.png');
|
|
|
|
break;
|
|
|
|
case ExchangeProviderDescription.changeNow:
|
|
|
|
image = Image.asset('assets/images/change_now.png');
|
|
|
|
break;
|
2020-02-05 20:54:55 +00:00
|
|
|
case ExchangeProviderDescription.morphToken:
|
|
|
|
image = Image.asset('assets/images/morph_icon.png');
|
|
|
|
break;
|
2020-01-04 19:31:52 +00:00
|
|
|
default:
|
|
|
|
image = null;
|
|
|
|
}
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
}
|