cake_wallet/lib/src/screens/dashboard/widgets/trade_row.dart

95 lines
3.4 KiB
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
import 'package:flutter/material.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/crypto_currency.dart';
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
2020-01-04 19:31:52 +00:00
class TradeRow extends StatelessWidget {
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) {
final amountCrypto = from.toString();
2020-01-04 19:31:52 +00:00
return InkWell(
onTap: onTap,
child: Container(
padding: EdgeInsets.fromLTRB(24, 8, 24, 8),
color: Colors.transparent,
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_getPoweredImage(provider),
SizedBox(width: 12),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('${from.toString()}${to.toString()}',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.
display3.backgroundColor
)),
formattedAmount != null
? Text(formattedAmount + ' ' + amountCrypto,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.
display3.backgroundColor
))
: 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:
image = Image.asset('assets/images/xmrto.png', height: 36, width: 36);
2020-01-04 19:31:52 +00:00
break;
case ExchangeProviderDescription.changeNow:
image = Image.asset('assets/images/changenow.png', height: 36, width: 36);
2020-01-04 19:31:52 +00:00
break;
case ExchangeProviderDescription.morphToken:
image = Image.asset('assets/images/morph.png', height: 36, width: 36);
break;
2020-01-04 19:31:52 +00:00
default:
image = null;
}
return image;
}
}