mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
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:
commit
86a8174100
3 changed files with 37 additions and 14 deletions
7
lib/src/screens/trade_details/track_trade_list_item.dart
Normal file
7
lib/src/screens/trade_details/track_trade_list_item.dart
Normal 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;
|
||||
}
|
|
@ -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}'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()}'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue