Added ability to track trade in trade details page

This commit is contained in:
Tanner Silva 2021-02-01 19:36:36 -06:00
parent 491c1ccccf
commit e08f665e4a
3 changed files with 26 additions and 6 deletions

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
class TrackTradeListItem extends StandartListRow {
class TrackTradeListItem extends StandartListItem {
TrackTradeListItem({String title, String value, this.onTap})
: super(title: title, value: value);
final Function() onTap;

View file

@ -8,6 +8,7 @@ import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart';
class TradeDetailsPage extends BasePage {
TradeDetailsPage(this.tradeDetailsViewModel);
@ -26,6 +27,16 @@ class TradeDetailsPage extends BasePage {
itemBuilder: (_, __, index) {
final item = tradeDetailsViewModel.items[index];
if (item is TrackTradeListItem) {
return GestureDetector(
onTap: item.onTap,
child: StandartListRow(
title: '${item.title}',
value: '${item.value}'
));
}
if (item is SectionStandardListItem) {
return GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: '${item.value}'));
@ -37,7 +48,7 @@ class TradeDetailsPage extends BasePage {
title: '${item.title}',
value: '${item.value}'
));
});
}
});
}
}

View file

@ -10,7 +10,8 @@ import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
import 'package:cake_wallet/src/screens/trade_details/track_trade_list_item.dart';
import 'package:url_launcher/url_launcher.dart';
part 'trade_details_view_model.g.dart';
class TradeDetailsViewModel = TradeDetailsViewModelBase
@ -90,6 +91,15 @@ abstract class TradeDetailsViewModelBase with Store {
value: trade.provider.toString()));
}
if (trade.provider.title == "ChangeNOW") {
items.add(TrackTradeListItem(
title: "Track",
value: "https://changenow.io/exchange/txs/${trade.id.toString()}",
onTap: () {
launch("https://www.blockchain.com/btc/tx/${tx.id}");
}));
}
if (trade.createdAt != null) {
items.add(StandartListItem(
title: S.current.trade_details_created_at,
@ -102,4 +112,4 @@ abstract class TradeDetailsViewModelBase with Store {
value: '${trade.from.toString()}${trade.to.toString()}'));
}
}
}
}