mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Fixes
This commit is contained in:
parent
8a55d566c6
commit
b17e7744c6
12 changed files with 273 additions and 197 deletions
|
@ -212,13 +212,14 @@ String getPublicSpendKey() =>
|
|||
convertUTF8ToString(pointer: getPublicSpendKeyNative());
|
||||
|
||||
class SyncListener {
|
||||
SyncListener({this.onNewBlock}) {
|
||||
SyncListener(this.onNewBlock, this.onNewTransaction) {
|
||||
_cachedBlockchainHeight = 0;
|
||||
_lastKnownBlockHeight = 0;
|
||||
_initialSyncHeight = 0;
|
||||
}
|
||||
|
||||
void Function(int, int, double) onNewBlock;
|
||||
void Function() onNewTransaction;
|
||||
|
||||
Timer _updateSyncInfoTimer;
|
||||
int _cachedBlockchainHeight;
|
||||
|
@ -239,6 +240,10 @@ class SyncListener {
|
|||
_initialSyncHeight = 0;
|
||||
_updateSyncInfoTimer ??=
|
||||
Timer.periodic(Duration(milliseconds: 1200), (_) async {
|
||||
if (isNewTransactionExist() ?? false) {
|
||||
onNewTransaction?.call();
|
||||
}
|
||||
|
||||
var syncHeight = getSyncingHeight();
|
||||
|
||||
if (syncHeight <= 0) {
|
||||
|
@ -273,8 +278,9 @@ class SyncListener {
|
|||
void stop() => _updateSyncInfoTimer?.cancel();
|
||||
}
|
||||
|
||||
SyncListener setListeners(void Function(int, int, double) onNewBlock) {
|
||||
final listener = SyncListener(onNewBlock: onNewBlock);
|
||||
SyncListener setListeners(void Function(int, int, double) onNewBlock,
|
||||
void Function() onNewTransaction) {
|
||||
final listener = SyncListener(onNewBlock, onNewTransaction);
|
||||
setListenerNative();
|
||||
return listener;
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -371,7 +371,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 4.0.0;
|
||||
MARKETING_VERSION = 4.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
@ -494,7 +494,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -511,7 +511,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 4.0.0;
|
||||
MARKETING_VERSION = 4.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
@ -528,7 +528,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -545,7 +545,7 @@
|
|||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
);
|
||||
MARKETING_VERSION = 4.0.0;
|
||||
MARKETING_VERSION = 4.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.fotolockr.cakewallet;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
mixin PendingTransaction {
|
||||
String get id;
|
||||
String get amountFormatted;
|
||||
String get feeFormatted;
|
||||
|
||||
|
|
16
lib/di.dart
16
lib/di.dart
|
@ -1,8 +1,9 @@
|
|||
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_service.dart';
|
||||
import 'package:cake_wallet/core/wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/biometric_auth.dart';
|
||||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/monero/monero_wallet_service.dart';
|
||||
import 'package:cake_wallet/entities/contact.dart';
|
||||
import 'package:cake_wallet/entities/node.dart';
|
||||
|
@ -23,6 +24,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/settings.dart';
|
||||
import 'package:cake_wallet/src/screens/setup_pin_code/setup_pin_code.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/exchange/exchange_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
|
||||
|
@ -92,7 +94,8 @@ Future setup(
|
|||
Box<Contact> contactSource,
|
||||
Box<Trade> tradesSource,
|
||||
Box<Template> templates,
|
||||
Box<ExchangeTemplate> exchangeTemplates}) async {
|
||||
Box<ExchangeTemplate> exchangeTemplates,
|
||||
Box<TransactionDescription> transactionDescriptionBox}) async {
|
||||
getIt.registerSingletonAsync<SharedPreferences>(
|
||||
() => SharedPreferences.getInstance());
|
||||
|
||||
|
@ -230,7 +233,8 @@ Future setup(
|
|||
getIt.get<AppStore>().wallet,
|
||||
getIt.get<AppStore>().settingsStore,
|
||||
getIt.get<SendTemplateStore>(),
|
||||
getIt.get<FiatConversionStore>()));
|
||||
getIt.get<FiatConversionStore>(),
|
||||
transactionDescriptionBox));
|
||||
|
||||
getIt.registerFactory(
|
||||
() => SendPage(sendViewModel: getIt.get<SendViewModel>()));
|
||||
|
@ -387,4 +391,10 @@ Future setup(
|
|||
|
||||
getIt.registerFactoryParam<WalletRestorePage, WalletType, void>((type, _) =>
|
||||
WalletRestorePage(getIt.get<WalletRestoreViewModel>(param1: type)));
|
||||
|
||||
getIt.registerFactoryParam<TransactionDetailsPage, TransactionInfo, void>(
|
||||
(TransactionInfo transactionInfo, _) => TransactionDetailsPage(
|
||||
transactionInfo,
|
||||
getIt.get<SettingsStore>().shouldSaveRecipientAddress,
|
||||
transactionDescriptionBox));
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ void main() async {
|
|||
// fiatConvertationService: fiatConvertationService,
|
||||
templates: templates,
|
||||
exchangeTemplates: exchangeTemplates,
|
||||
transactionDescriptions: transactionDescriptions,
|
||||
initialMigrationVersion: 4);
|
||||
runApp(App());
|
||||
}
|
||||
|
@ -80,6 +81,7 @@ Future<void> initialSetup(
|
|||
// @required FiatConvertationService fiatConvertationService,
|
||||
@required Box<Template> templates,
|
||||
@required Box<ExchangeTemplate> exchangeTemplates,
|
||||
@required Box<TransactionDescription> transactionDescriptions,
|
||||
int initialMigrationVersion = 5}) async {
|
||||
await defaultSettingsMigration(
|
||||
version: initialMigrationVersion,
|
||||
|
@ -94,7 +96,8 @@ Future<void> initialSetup(
|
|||
contactSource: contactSource,
|
||||
tradesSource: tradesSource,
|
||||
templates: templates,
|
||||
exchangeTemplates: exchangeTemplates);
|
||||
exchangeTemplates: exchangeTemplates,
|
||||
transactionDescriptionBox: transactionDescriptions);
|
||||
bootstrap(navigatorKey);
|
||||
monero_wallet.onStartup();
|
||||
}
|
||||
|
|
|
@ -52,5 +52,6 @@ class MoneroTransactionInfo extends TransactionInfo {
|
|||
@override
|
||||
String fiatAmount() => _fiatAmount ?? '';
|
||||
|
||||
@override
|
||||
void changeFiatAmount(String amount) => _fiatAmount = formatAmount(amount);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
|
||||
void _setListeners() {
|
||||
_listener?.stop();
|
||||
_listener = monero_wallet.setListeners(_onNewBlock);
|
||||
_listener = monero_wallet.setListeners(_onNewBlock, _onNewTransaction);
|
||||
}
|
||||
|
||||
void _setInitialHeight() {
|
||||
|
@ -308,14 +308,23 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
}
|
||||
|
||||
void _onNewBlock(int height, int blocksLeft, double ptc) async {
|
||||
_askForUpdateTransactionHistory();
|
||||
if (walletInfo.isRecovery) {
|
||||
_askForUpdateTransactionHistory();
|
||||
}
|
||||
|
||||
_askForUpdateBalance();
|
||||
|
||||
if (blocksLeft < moneroBlockSize) {
|
||||
if (blocksLeft < 100) {
|
||||
syncStatus = SyncedSyncStatus();
|
||||
await _afterSyncSave();
|
||||
} else {
|
||||
syncStatus = SyncingSyncStatus(blocksLeft, ptc);
|
||||
}
|
||||
}
|
||||
|
||||
void _onNewTransaction() {
|
||||
_askForUpdateTransactionHistory();
|
||||
_askForUpdateBalance();
|
||||
_afterSyncSave();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ class PendingMoneroTransaction with PendingTransaction {
|
|||
|
||||
final PendingTransactionDescription pendingTransactionDescription;
|
||||
|
||||
@override
|
||||
String get id => pendingTransactionDescription.hash;
|
||||
|
||||
@override
|
||||
String get amountFormatted => AmountConverter.amountIntToString(
|
||||
CryptoCurrency.xmr, pendingTransactionDescription.amount);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:cake_wallet/entities/contact_record.dart';
|
||||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
|
||||
import 'package:cake_wallet/src/screens/restore/wallet_restore_page.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
@ -49,6 +51,7 @@ import 'package:cake_wallet/src/screens/send/send_template_page.dart';
|
|||
import 'package:cake_wallet/src/screens/exchange/exchange_template_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_confirm_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_page.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
Route<dynamic> createRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
|
@ -57,15 +60,19 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
|
||||
case Routes.newWalletFromWelcome:
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) => getIt.get<SetupPinCodePage>(
|
||||
param1: (PinCodeState<PinCodeWidget> context, dynamic _) async {
|
||||
builder: (_) => getIt.get<SetupPinCodePage>(param1:
|
||||
(PinCodeState<PinCodeWidget> context, dynamic _) async {
|
||||
try {
|
||||
context.changeProcessText('Creating new wallet'); // FIXME: Unnamed constant
|
||||
final newWalletVM = getIt.get<WalletNewVM>(param1: WalletType.monero);
|
||||
await newWalletVM.create(options: 'English'); // FIXME: Unnamed constant
|
||||
context.changeProcessText(
|
||||
'Creating new wallet'); // FIXME: Unnamed constant
|
||||
final newWalletVM =
|
||||
getIt.get<WalletNewVM>(param1: WalletType.monero);
|
||||
await newWalletVM.create(
|
||||
options: 'English'); // FIXME: Unnamed constant
|
||||
context.hideProgressText();
|
||||
await Navigator.of(context.context).pushNamed(Routes.seed, arguments: true);
|
||||
} catch(e) {
|
||||
await Navigator.of(context.context)
|
||||
.pushNamed(Routes.seed, arguments: true);
|
||||
} catch (e) {
|
||||
context.changeProcessText('Error: ${e.toString()}');
|
||||
}
|
||||
}),
|
||||
|
@ -88,7 +95,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
Function(PinCodeState<PinCodeWidget>, String) callback;
|
||||
|
||||
if (settings.arguments is Function(PinCodeState<PinCodeWidget>, String)) {
|
||||
callback = settings.arguments as Function(PinCodeState<PinCodeWidget>, String);
|
||||
callback =
|
||||
settings.arguments as Function(PinCodeState<PinCodeWidget>, String);
|
||||
}
|
||||
|
||||
return CupertinoPageRoute<void>(
|
||||
|
@ -194,8 +202,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
case Routes.transactionDetails:
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) =>
|
||||
TransactionDetailsPage(settings.arguments as TransactionInfo));
|
||||
builder: (_) => getIt.get<TransactionDetailsPage>(
|
||||
param1: settings.arguments as TransactionInfo));
|
||||
|
||||
case Routes.newSubaddress:
|
||||
return CupertinoPageRoute<void>(
|
||||
|
@ -320,4 +328,4 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
body: Center(
|
||||
child: Text(S.current.router_no_route(settings.name)))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,11 @@ class SendPage extends BasePage {
|
|||
|
||||
@override
|
||||
Widget trailing(context) => TrailButton(
|
||||
caption: S.of(context).clear, onPressed: () {
|
||||
_formKey.currentState.reset();
|
||||
sendViewModel.reset();
|
||||
});
|
||||
caption: S.of(context).clear,
|
||||
onPressed: () {
|
||||
_formKey.currentState.reset();
|
||||
sendViewModel.reset();
|
||||
});
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
|
@ -166,72 +167,75 @@ class SendPage extends BasePage {
|
|||
.decorationColor),
|
||||
validator: sendViewModel.addressValidator,
|
||||
),
|
||||
Observer(builder: (_) => Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
focusNode: _cryptoAmountFocus,
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
child: Text(
|
||||
sendViewModel.currency.title + ':',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
suffixIcon: Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
margin: EdgeInsets.only(
|
||||
left: 14, top: 4, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.display1
|
||||
.color,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(6))),
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
sendViewModel.setSendAll(),
|
||||
child: Center(
|
||||
child: Text(S.of(context).all,
|
||||
textAlign: TextAlign.center,
|
||||
Observer(
|
||||
builder: (_) => Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
focusNode: _cryptoAmountFocus,
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
child: Text(
|
||||
sendViewModel.currency.title +
|
||||
':',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.display1
|
||||
.decorationColor)),
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
hintText: '0.0000',
|
||||
borderColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white),
|
||||
placeholderTextStyle: TextStyle(
|
||||
color: Theme.of(context)
|
||||
suffixIcon: Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
margin: EdgeInsets.only(
|
||||
left: 14, top: 4, bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.display1
|
||||
.color,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(6))),
|
||||
child: InkWell(
|
||||
onTap: () =>
|
||||
sendViewModel.setSendAll(),
|
||||
child: Center(
|
||||
child: Text(S.of(context).all,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.display1
|
||||
.decorationColor)),
|
||||
),
|
||||
),
|
||||
),
|
||||
hintText: '0.0000',
|
||||
borderColor: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.decorationColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator:
|
||||
sendViewModel.sendAll
|
||||
? sendViewModel.allAmountValidator
|
||||
: sendViewModel.amountValidator))),
|
||||
.color,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white),
|
||||
placeholderTextStyle: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.decorationColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator: sendViewModel.sendAll
|
||||
? sendViewModel.allAmountValidator
|
||||
: sendViewModel
|
||||
.amountValidator))),
|
||||
Observer(
|
||||
builder: (_) => Padding(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
|
@ -423,53 +427,60 @@ class SendPage extends BasePage {
|
|||
)),
|
||||
),
|
||||
),
|
||||
Observer(
|
||||
builder: (_) {
|
||||
final templates = sendViewModel.templates;
|
||||
final itemCount = templates.length;
|
||||
Observer(builder: (_) {
|
||||
final templates = sendViewModel.templates;
|
||||
final itemCount = templates.length;
|
||||
|
||||
return ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
final template = templates[index];
|
||||
return ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
final template = templates[index];
|
||||
|
||||
return TemplateTile(
|
||||
key: UniqueKey(),
|
||||
to: template.name,
|
||||
amount: template.amount,
|
||||
from: template.cryptoCurrency,
|
||||
onTap: () {
|
||||
_addressController.text = template.address;
|
||||
_cryptoAmountController.text = template.amount;
|
||||
getOpenaliasRecord(context);
|
||||
},
|
||||
onRemove: () {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).template,
|
||||
alertContent: S.of(context).confirm_delete_template,
|
||||
rightButtonText: S.of(context).delete,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
sendViewModel.removeTemplate(template: template);
|
||||
sendViewModel.updateTemplate();
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(dialogContext).pop()
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
return TemplateTile(
|
||||
key: UniqueKey(),
|
||||
to: template.name,
|
||||
amount: template.amount,
|
||||
from: template.cryptoCurrency,
|
||||
onTap: () {
|
||||
_addressController.text =
|
||||
template.address;
|
||||
_cryptoAmountController.text =
|
||||
template.amount;
|
||||
getOpenaliasRecord(context);
|
||||
},
|
||||
onRemove: () {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle:
|
||||
S.of(context).template,
|
||||
alertContent: S
|
||||
.of(context)
|
||||
.confirm_delete_template,
|
||||
rightButtonText:
|
||||
S.of(context).delete,
|
||||
leftButtonText:
|
||||
S.of(context).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(dialogContext)
|
||||
.pop();
|
||||
sendViewModel.removeTemplate(
|
||||
template: template);
|
||||
sendViewModel
|
||||
.updateTemplate();
|
||||
},
|
||||
actionLeftButton: () =>
|
||||
Navigator.of(dialogContext)
|
||||
.pop());
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -486,13 +497,11 @@ class SendPage extends BasePage {
|
|||
}
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color: Theme
|
||||
.of(context)
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.subtitle
|
||||
.decorationColor,
|
||||
textColor: Theme
|
||||
.of(context)
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.headline
|
||||
.decorationColor,
|
||||
|
@ -606,6 +615,10 @@ class SendPage extends BasePage {
|
|||
return Observer(builder: (_) {
|
||||
final state = sendViewModel.state;
|
||||
|
||||
if (state is FailureState) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
|
@ -652,45 +665,49 @@ class SendPage extends BasePage {
|
|||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(
|
||||
sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.backgroundColor
|
||||
.withOpacity(0.25)),
|
||||
if (state is TransactionCommitting) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220),
|
||||
child: Text(
|
||||
S.of(context).send_sending,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
decoration: TextDecoration.none,
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(
|
||||
sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.backgroundColor
|
||||
.withOpacity(0.25)),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220),
|
||||
child: Text(
|
||||
S.of(context).send_sending,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Container();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -9,9 +10,11 @@ import 'package:cake_wallet/src/widgets/standart_list_row.dart';
|
|||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/utils/date_formatter.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
class TransactionDetailsPage extends BasePage {
|
||||
TransactionDetailsPage(this.transactionInfo) : _items = [] {
|
||||
TransactionDetailsPage(this.transactionInfo, bool showRecipientAddress, Box<TransactionDescription> transactionDescriptionBox)
|
||||
: _items = [] {
|
||||
final dateFormat = DateFormatter.withCurrentLocal();
|
||||
final tx = transactionInfo;
|
||||
|
||||
|
@ -28,15 +31,18 @@ class TransactionDetailsPage extends BasePage {
|
|||
title: S.current.transaction_details_amount,
|
||||
value: tx.amountFormatted())
|
||||
];
|
||||
// FIXME
|
||||
// if (widget.settingsStore.shouldSaveRecipientAddress &&
|
||||
// tx.recipientAddress != null) {
|
||||
// items.add(StandartListItem(
|
||||
// title: S.current.transaction_details_recipient_address,
|
||||
// value: tx.recipientAddress));
|
||||
// }
|
||||
|
||||
if (tx.key?.isNotEmpty) {
|
||||
if (showRecipientAddress) {
|
||||
final recipientAddress = transactionDescriptionBox.values.firstWhere((val) => val.id == transactionInfo.id, orElse: () => null)?.recipientAddress;
|
||||
|
||||
if (recipientAddress?.isNotEmpty ?? false) {
|
||||
items.add(StandartListItem(
|
||||
title: S.current.transaction_details_recipient_address,
|
||||
value: recipientAddress));
|
||||
}
|
||||
}
|
||||
|
||||
if (tx.key?.isNotEmpty ?? null) {
|
||||
// FIXME: add translation
|
||||
items.add(StandartListItem(title: 'Transaction Key', value: tx.key));
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:cake_wallet/entities/transaction_description.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/entities/openalias_record.dart';
|
||||
|
@ -30,9 +32,8 @@ part 'send_view_model.g.dart';
|
|||
class SendViewModel = SendViewModelBase with _$SendViewModel;
|
||||
|
||||
abstract class SendViewModelBase with Store {
|
||||
SendViewModelBase(
|
||||
this._wallet, this._settingsStore, this._sendTemplateStore,
|
||||
this._fiatConversationStore)
|
||||
SendViewModelBase(this._wallet, this._settingsStore, this._sendTemplateStore,
|
||||
this._fiatConversationStore, this.transactionDescriptionBox)
|
||||
: state = InitialExecutionState(),
|
||||
_cryptoNumberFormat = NumberFormat(),
|
||||
sendAll = false {
|
||||
|
@ -101,6 +102,7 @@ abstract class SendViewModelBase with Store {
|
|||
final SendTemplateStore _sendTemplateStore;
|
||||
final FiatConversionStore _fiatConversationStore;
|
||||
final NumberFormat _cryptoNumberFormat;
|
||||
final Box<TransactionDescription> transactionDescriptionBox;
|
||||
|
||||
@action
|
||||
void setSendAll() => sendAll = true;
|
||||
|
@ -129,6 +131,13 @@ abstract class SendViewModelBase with Store {
|
|||
try {
|
||||
state = TransactionCommitting();
|
||||
await pendingTransaction.commit();
|
||||
|
||||
if (_settingsStore.shouldSaveRecipientAddress &&
|
||||
(pendingTransaction.id?.isNotEmpty ?? false)) {
|
||||
await transactionDescriptionBox.add(TransactionDescription(
|
||||
id: pendingTransaction.id, recipientAddress: address));
|
||||
}
|
||||
|
||||
state = TransactionCommitted();
|
||||
} catch (e) {
|
||||
state = FailureState(e.toString());
|
||||
|
@ -156,8 +165,8 @@ abstract class SendViewModelBase with Store {
|
|||
_settingsStore.transactionPriority = priority;
|
||||
|
||||
Future<OpenaliasRecord> decodeOpenaliasRecord(String name) async {
|
||||
final record = await OpenaliasRecord
|
||||
.fetchAddressAndName(OpenaliasRecord.formatDomainName(name));
|
||||
final record = await OpenaliasRecord.fetchAddressAndName(
|
||||
OpenaliasRecord.formatDomainName(name));
|
||||
|
||||
return record.name != name ? record : null;
|
||||
}
|
||||
|
@ -232,13 +241,16 @@ abstract class SendViewModelBase with Store {
|
|||
|
||||
void updateTemplate() => _sendTemplateStore.update();
|
||||
|
||||
void addTemplate({String name, String address, String cryptoCurrency,
|
||||
String amount}) => _sendTemplateStore
|
||||
.addTemplate(
|
||||
name: name,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
amount: amount);
|
||||
void addTemplate(
|
||||
{String name,
|
||||
String address,
|
||||
String cryptoCurrency,
|
||||
String amount}) =>
|
||||
_sendTemplateStore.addTemplate(
|
||||
name: name,
|
||||
address: address,
|
||||
cryptoCurrency: cryptoCurrency,
|
||||
amount: amount);
|
||||
|
||||
void removeTemplate({Template template}) =>
|
||||
_sendTemplateStore.remove(template: template);
|
||||
|
|
Loading…
Reference in a new issue