Merge pull request #75 from cake-tech/cake-254

[cake-254] Added ability to track trade directly with a web browser for ChangeNow transactions
This commit is contained in:
M 2021-02-09 18:35:26 +02:00
commit 86a8174100
3 changed files with 37 additions and 14 deletions

View file

@ -0,0 +1,7 @@
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
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,18 +27,21 @@ class TradeDetailsPage extends BasePage {
itemBuilder: (_, __, index) {
final item = tradeDetailsViewModel.items[index];
return GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: '${item.value}'));
showBar<void>(context, S
.of(context)
.copied_to_clipboard);
},
child: StandartListRow(
title: '${item.title}',
value: '${item.value}'
));
if (item is TrackTradeListItem) {
return GestureDetector(
onTap: item.onTap,
child: StandartListRow(
title: '${item.title}', value: '${item.value}'));
} else {
return GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: '${item.value}'));
showBar<void>(context, S.of(context).copied_to_clipboard);
},
child: StandartListRow(
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,17 @@ abstract class TradeDetailsViewModelBase with Store {
value: trade.provider.toString()));
}
if (trade.provider == ExchangeProviderDescription.changeNow) {
final buildURL =
'https://changenow.io/exchange/txs/${trade.id.toString()}';
items.add(TrackTradeListItem(
title: 'Track',
value: buildURL,
onTap: () {
launch(buildURL);
}));
}
if (trade.createdAt != null) {
items.add(StandartListItem(
title: S.current.trade_details_created_at,
@ -102,4 +114,4 @@ abstract class TradeDetailsViewModelBase with Store {
value: '${trade.from.toString()}${trade.to.toString()}'));
}
}
}
}