mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Merge branch '4.1.0' into CAKE-198-notes-for-transactions
This commit is contained in:
commit
d55b689636
6 changed files with 151 additions and 81 deletions
|
@ -28,6 +28,7 @@ import 'package:cake_wallet/src/screens/send/send_template_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/change_language.dart';
|
import 'package:cake_wallet/src/screens/settings/change_language.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/settings.dart';
|
import 'package:cake_wallet/src/screens/settings/settings.dart';
|
||||||
import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
|
import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/trade_details/trade_details_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_page.dart';
|
import 'package:cake_wallet/src/screens/transaction_details/transaction_details_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
|
import 'package:cake_wallet/src/screens/wallet_keys/wallet_keys_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
|
import 'package:cake_wallet/src/screens/exchange/exchange_page.dart';
|
||||||
|
@ -56,6 +57,7 @@ import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.
|
||||||
import 'package:cake_wallet/view_model/rescan_view_model.dart';
|
import 'package:cake_wallet/view_model/rescan_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
|
import 'package:cake_wallet/view_model/setup_pin_code_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/transaction_details_view_model.dart';
|
import 'package:cake_wallet/view_model/transaction_details_view_model.dart';
|
||||||
|
import 'package:cake_wallet/view_model/trade_details_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_edit_or_create_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/auth_view_model.dart';
|
import 'package:cake_wallet/view_model/auth_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||||
|
@ -436,4 +438,10 @@ Future setup(
|
||||||
|
|
||||||
getIt.registerFactoryParam<PreSeedPage, WalletType, void>(
|
getIt.registerFactoryParam<PreSeedPage, WalletType, void>(
|
||||||
(WalletType type, _) => PreSeedPage(type));
|
(WalletType type, _) => PreSeedPage(type));
|
||||||
|
|
||||||
|
getIt.registerFactoryParam<TradeDetailsViewModel, Trade, void>((trade, _) =>
|
||||||
|
TradeDetailsViewModel(tradeForDetails: trade, trades: tradesSource));
|
||||||
|
|
||||||
|
getIt.registerFactoryParam<TradeDetailsPage, Trade, void>((Trade trade, _) =>
|
||||||
|
TradeDetailsPage(getIt.get<TradeDetailsViewModel>(param1: trade)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
|
|
||||||
case Routes.tradeDetails:
|
case Routes.tradeDetails:
|
||||||
return MaterialPageRoute<void>(
|
return MaterialPageRoute<void>(
|
||||||
builder: (_) => TradeDetailsPage(settings.arguments as Trade));
|
builder: (_) =>
|
||||||
|
getIt.get<TradeDetailsPage>(param1: settings.arguments as Trade));
|
||||||
|
|
||||||
case Routes.restoreWalletFromSeedDetails:
|
case Routes.restoreWalletFromSeedDetails:
|
||||||
final args = settings.arguments as List;
|
final args = settings.arguments as List;
|
||||||
|
|
|
@ -6,8 +6,6 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/core/execution_state.dart';
|
import 'package:cake_wallet/core/execution_state.dart';
|
||||||
import 'package:cake_wallet/entities/crypto_currency.dart';
|
|
||||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
|
import 'package:cake_wallet/src/screens/exchange_trade/information_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
||||||
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
||||||
|
@ -172,36 +170,14 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = widget.exchangeTradeViewModel.items[index];
|
final item = widget.exchangeTradeViewModel.items[index];
|
||||||
String value;
|
final value = item.data ?? fetchingLabel;
|
||||||
|
|
||||||
final content = Observer(builder: (_) {
|
final content = StandartListRow(
|
||||||
switch (index) {
|
title: item.title,
|
||||||
case 0:
|
value: value,
|
||||||
value =
|
valueFontSize: 14,
|
||||||
'${widget.exchangeTradeViewModel.trade.id ?? fetchingLabel}';
|
image: item.isCopied ? copyImage : null,
|
||||||
break;
|
);
|
||||||
case 1:
|
|
||||||
value =
|
|
||||||
'${widget.exchangeTradeViewModel.trade.amount ?? fetchingLabel}';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
value =
|
|
||||||
'${widget.exchangeTradeViewModel.trade.state ?? fetchingLabel}';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
value = widget.exchangeTradeViewModel.trade
|
|
||||||
.inputAddress ??
|
|
||||||
fetchingLabel;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return StandartListRow(
|
|
||||||
title: item.title,
|
|
||||||
value: value,
|
|
||||||
valueFontSize: 14,
|
|
||||||
image: item.isCopied ? copyImage : null,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return item.isCopied
|
return item.isCopied
|
||||||
? Builder(
|
? Builder(
|
||||||
|
|
|
@ -1,51 +1,20 @@
|
||||||
import 'package:cake_wallet/utils/show_bar.dart';
|
import 'package:cake_wallet/utils/show_bar.dart';
|
||||||
|
import 'package:cake_wallet/view_model/trade_details_view_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:cake_wallet/exchange/trade.dart';
|
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/utils/date_formatter.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
|
||||||
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
||||||
|
|
||||||
class TradeDetailsPage extends BasePage {
|
class TradeDetailsPage extends BasePage {
|
||||||
TradeDetailsPage(this.trade) : _items = [] {
|
TradeDetailsPage(this.tradeDetailsViewModel);
|
||||||
final dateFormat = DateFormatter.withCurrentLocal();
|
|
||||||
_items.addAll([
|
|
||||||
StandartListItem(title: S.current.trade_details_id, value: trade.id),
|
|
||||||
StandartListItem(
|
|
||||||
title: S.current.trade_details_state,
|
|
||||||
value: trade.state != null
|
|
||||||
? trade.state.toString()
|
|
||||||
: S.current.trade_details_fetching)
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (trade.provider != null) {
|
|
||||||
_items.add(StandartListItem(
|
|
||||||
title: S.current.trade_details_provider,
|
|
||||||
value: trade.provider.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trade.createdAt != null) {
|
|
||||||
_items.add(StandartListItem(
|
|
||||||
title: S.current.trade_details_created_at,
|
|
||||||
value: dateFormat.format(trade.createdAt).toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trade.from != null && trade.to != null) {
|
|
||||||
_items.add(StandartListItem(
|
|
||||||
title: S.current.trade_details_pair,
|
|
||||||
value: '${trade.from.toString()} → ${trade.to.toString()}'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.trade_details_title;
|
String get title => S.current.trade_details_title;
|
||||||
|
|
||||||
final Trade trade;
|
final TradeDetailsViewModel tradeDetailsViewModel;
|
||||||
final List<StandartListItem> _items;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
|
@ -61,10 +30,11 @@ class TradeDetailsPage extends BasePage {
|
||||||
.primaryTextTheme
|
.primaryTextTheme
|
||||||
.title
|
.title
|
||||||
.backgroundColor)),
|
.backgroundColor)),
|
||||||
itemCount: _items.length,
|
itemCount: tradeDetailsViewModel.items.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final item = _items[index];
|
final item = tradeDetailsViewModel.items[index];
|
||||||
final isDrawBottom = index == _items.length - 1 ? true : false;
|
final isDrawBottom =
|
||||||
|
index == tradeDetailsViewModel.items.length - 1 ? true : false;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
@ -39,20 +39,11 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
items = ObservableList<ExchangeTradeItem>();
|
items = ObservableList<ExchangeTradeItem>();
|
||||||
items.addAll([
|
|
||||||
ExchangeTradeItem(
|
_updateItems();
|
||||||
title: S.current.id, data: '${trade.id}', isCopied: true),
|
|
||||||
ExchangeTradeItem(
|
|
||||||
title: S.current.amount, data: '${trade.amount}', isCopied: false),
|
|
||||||
ExchangeTradeItem(
|
|
||||||
title: S.current.status, data: '${trade.state}', isCopied: false),
|
|
||||||
ExchangeTradeItem(
|
|
||||||
title: S.current.widgets_address + ':',
|
|
||||||
data: trade.inputAddress,
|
|
||||||
isCopied: true),
|
|
||||||
]);
|
|
||||||
|
|
||||||
_updateTrade();
|
_updateTrade();
|
||||||
|
|
||||||
_timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade());
|
_timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +86,27 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
trade = updatedTrade;
|
trade = updatedTrade;
|
||||||
|
|
||||||
|
_updateItems();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e.toString());
|
print(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _updateItems() {
|
||||||
|
items?.clear();
|
||||||
|
|
||||||
|
items.addAll([
|
||||||
|
ExchangeTradeItem(
|
||||||
|
title: S.current.id, data: '${trade.id}', isCopied: true),
|
||||||
|
ExchangeTradeItem(
|
||||||
|
title: S.current.amount, data: '${trade.amount}', isCopied: false),
|
||||||
|
ExchangeTradeItem(
|
||||||
|
title: S.current.status, data: '${trade.state}', isCopied: false),
|
||||||
|
ExchangeTradeItem(
|
||||||
|
title: S.current.widgets_address + ':',
|
||||||
|
data: trade.inputAddress,
|
||||||
|
isCopied: true),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
105
lib/view_model/trade_details_view_model.dart
Normal file
105
lib/view_model/trade_details_view_model.dart
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:cake_wallet/exchange/changenow/changenow_exchange_provider.dart';
|
||||||
|
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
||||||
|
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||||
|
import 'package:cake_wallet/exchange/morphtoken/morphtoken_exchange_provider.dart';
|
||||||
|
import 'package:cake_wallet/exchange/trade.dart';
|
||||||
|
import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
|
||||||
|
import 'package:cake_wallet/utils/date_formatter.dart';
|
||||||
|
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';
|
||||||
|
|
||||||
|
part 'trade_details_view_model.g.dart';
|
||||||
|
|
||||||
|
class TradeDetailsViewModel = TradeDetailsViewModelBase
|
||||||
|
with _$TradeDetailsViewModel;
|
||||||
|
|
||||||
|
abstract class TradeDetailsViewModelBase with Store {
|
||||||
|
TradeDetailsViewModelBase({Trade tradeForDetails, this.trades}) {
|
||||||
|
trade = tradeForDetails;
|
||||||
|
|
||||||
|
switch (trade.provider) {
|
||||||
|
case ExchangeProviderDescription.xmrto:
|
||||||
|
_provider = XMRTOExchangeProvider();
|
||||||
|
break;
|
||||||
|
case ExchangeProviderDescription.changeNow:
|
||||||
|
_provider = ChangeNowExchangeProvider();
|
||||||
|
break;
|
||||||
|
case ExchangeProviderDescription.morphToken:
|
||||||
|
_provider = MorphTokenExchangeProvider(trades: trades);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
items = ObservableList<StandartListItem>();
|
||||||
|
|
||||||
|
_updateItems();
|
||||||
|
|
||||||
|
_updateTrade();
|
||||||
|
|
||||||
|
_timer = Timer.periodic(Duration(seconds: 20), (_) async => _updateTrade());
|
||||||
|
}
|
||||||
|
|
||||||
|
final Box<Trade> trades;
|
||||||
|
|
||||||
|
@observable
|
||||||
|
Trade trade;
|
||||||
|
|
||||||
|
@observable
|
||||||
|
ObservableList<StandartListItem> items;
|
||||||
|
|
||||||
|
ExchangeProvider _provider;
|
||||||
|
|
||||||
|
Timer _timer;
|
||||||
|
|
||||||
|
@action
|
||||||
|
Future<void> _updateTrade() async {
|
||||||
|
try {
|
||||||
|
final updatedTrade = await _provider.findTradeById(id: trade.id);
|
||||||
|
|
||||||
|
if (updatedTrade.createdAt == null && trade.createdAt != null) {
|
||||||
|
updatedTrade.createdAt = trade.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
trade = updatedTrade;
|
||||||
|
|
||||||
|
_updateItems();
|
||||||
|
} catch (e) {
|
||||||
|
print(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateItems() {
|
||||||
|
final dateFormat = DateFormatter.withCurrentLocal();
|
||||||
|
|
||||||
|
items?.clear();
|
||||||
|
|
||||||
|
items.addAll([
|
||||||
|
StandartListItem(title: S.current.trade_details_id, value: trade.id),
|
||||||
|
StandartListItem(
|
||||||
|
title: S.current.trade_details_state,
|
||||||
|
value: trade.state != null
|
||||||
|
? trade.state.toString()
|
||||||
|
: S.current.trade_details_fetching)
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (trade.provider != null) {
|
||||||
|
items.add(StandartListItem(
|
||||||
|
title: S.current.trade_details_provider,
|
||||||
|
value: trade.provider.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trade.createdAt != null) {
|
||||||
|
items.add(StandartListItem(
|
||||||
|
title: S.current.trade_details_created_at,
|
||||||
|
value: dateFormat.format(trade.createdAt).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trade.from != null && trade.to != null) {
|
||||||
|
items.add(StandartListItem(
|
||||||
|
title: S.current.trade_details_pair,
|
||||||
|
value: '${trade.from.toString()} → ${trade.to.toString()}'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue