mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Fixes and improvments.
This commit is contained in:
parent
b506f9c953
commit
04e7c18841
13 changed files with 246 additions and 240 deletions
|
@ -354,7 +354,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -493,7 +493,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -526,7 +526,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
|
|
@ -180,9 +180,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
|
||||
@override
|
||||
Future<void> save() async {
|
||||
print('SAVE CALLED');
|
||||
await monero_wallet.store();
|
||||
print('SAVE FINISHED');
|
||||
}
|
||||
|
||||
Future<int> getNodeHeight() async => monero_wallet.getNodeHeight();
|
||||
|
|
|
@ -14,8 +14,6 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
|
|||
|
||||
if (state == AuthenticationState.installed) {
|
||||
await loadCurrentWallet();
|
||||
// await navigatorKey.currentState
|
||||
// .pushNamedAndRemoveUntil(Routes.login, (_) => false);
|
||||
}
|
||||
|
||||
if (state == AuthenticationState.allowed) {
|
||||
|
|
|
@ -65,12 +65,12 @@ class ContactListPage extends BasePage {
|
|||
? SectionStandardList(
|
||||
sectionCount: 1,
|
||||
context: context,
|
||||
itemCounter: (int sectionIndex) => contactListViewModel.contacts.length,
|
||||
itemCounter: (int sectionIndex) =>
|
||||
contactListViewModel.contacts.length,
|
||||
itemBuilder: (_, sectionIndex, index) {
|
||||
final contact = contactListViewModel.contacts[index];
|
||||
final image = _getCurrencyImage(contact.type);
|
||||
final content = Builder(
|
||||
builder: (context) => GestureDetector(
|
||||
final content = GestureDetector(
|
||||
onTap: () async {
|
||||
if (!isEditable) {
|
||||
Navigator.of(context).pop(contact);
|
||||
|
@ -83,22 +83,18 @@ class ContactListPage extends BasePage {
|
|||
if (isCopied != null && isCopied) {
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: contact.address));
|
||||
await showBar<void>(context,
|
||||
S.of(context).copied_to_clipboard);
|
||||
await showBar<void>(
|
||||
context, S.of(context).copied_to_clipboard);
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 24, top: 16, bottom: 16, right: 24),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
image ?? Offstage(),
|
||||
Padding(
|
||||
|
@ -117,11 +113,8 @@ class ContactListPage extends BasePage {
|
|||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return !isEditable
|
||||
|
@ -135,8 +128,9 @@ class ContactListPage extends BasePage {
|
|||
caption: S.of(context).edit,
|
||||
color: Colors.blue,
|
||||
icon: Icons.edit,
|
||||
onTap: () async => await Navigator.of(context)
|
||||
.pushNamed(Routes.addressBookAddContact,
|
||||
onTap: () async =>
|
||||
await Navigator.of(context).pushNamed(
|
||||
Routes.addressBookAddContact,
|
||||
arguments: contact),
|
||||
),
|
||||
IconSlideAction(
|
||||
|
@ -145,7 +139,8 @@ class ContactListPage extends BasePage {
|
|||
icon: CupertinoIcons.delete,
|
||||
onTap: () async {
|
||||
final isDelete =
|
||||
await showAlertDialog(context) ?? false;
|
||||
await showAlertDialog(context) ??
|
||||
false;
|
||||
|
||||
if (isDelete) {
|
||||
await contactListViewModel
|
||||
|
@ -153,24 +148,14 @@ class ContactListPage extends BasePage {
|
|||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
dismissal: SlidableDismissal(
|
||||
child: SlidableDrawerDismissal(),
|
||||
onDismissed: (actionType) async => null,
|
||||
// await contactListViewModel.delete(contact),
|
||||
onWillDismiss: (actionType) async =>
|
||||
showAlertDialog(context),
|
||||
),
|
||||
);
|
||||
]);
|
||||
},
|
||||
)
|
||||
: Center(
|
||||
child: Text(
|
||||
S.of(context).placeholder_contacts,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 14),
|
||||
style: TextStyle(color: Colors.grey, fontSize: 14),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -181,7 +166,8 @@ class ContactListPage extends BasePage {
|
|||
Image image;
|
||||
switch (currency) {
|
||||
case CryptoCurrency.xmr:
|
||||
image = Image.asset('assets/images/monero_logo.png', height: 24, width: 24);
|
||||
image =
|
||||
Image.asset('assets/images/monero_logo.png', height: 24, width: 24);
|
||||
break;
|
||||
case CryptoCurrency.ada:
|
||||
image = Image.asset('assets/images/ada.png', height: 24, width: 24);
|
||||
|
|
|
@ -29,8 +29,21 @@ class TransactionRow extends StatelessWidget {
|
|||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 36,
|
||||
width: 36,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).textTheme.overline.decorationColor
|
||||
),
|
||||
child: Image.asset(
|
||||
direction == TransactionDirection.incoming
|
||||
? 'assets/images/down_arrow.png'
|
||||
: 'assets/images/up_arrow.png'),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
height: 56,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
@ -48,25 +61,11 @@ class TransactionRow extends StatelessWidget {
|
|||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white)),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(10)),
|
||||
color: (direction ==
|
||||
TransactionDirection.incoming
|
||||
? Colors.green.withOpacity(0.8)
|
||||
: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.body2
|
||||
.decorationColor
|
||||
.withOpacity(0.8))),
|
||||
padding: EdgeInsets.only(
|
||||
top: 3, bottom: 3, left: 10, right: 10),
|
||||
child: Text(formattedAmount,
|
||||
Text(formattedAmount,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white)))
|
||||
color: Colors.white))
|
||||
]),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:cake_wallet/src/screens/nodes/widgets/node_list_row.dart';
|
|||
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/view_model/node_list/node_list_view_model.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
|
||||
class NodeListPage extends BasePage {
|
||||
NodeListPage(this.nodeListViewModel);
|
||||
|
@ -59,15 +60,23 @@ class NodeListPage extends BasePage {
|
|||
}
|
||||
|
||||
@override
|
||||
Widget body(context) {
|
||||
Widget body(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: Observer(
|
||||
builder: (_) => SectionStandardList(
|
||||
builder: (BuildContext context) {
|
||||
return nodeListViewModel.nodes.isNotEmpty
|
||||
? SectionStandardList(
|
||||
sectionCount: 2,
|
||||
context: context,
|
||||
itemCounter: (int sectionIndex) {
|
||||
if (sectionIndex == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return nodeListViewModel.nodes.length;
|
||||
},
|
||||
itemBuilder: (_, sectionIndex, index) {
|
||||
return Observer(builder: (_) {
|
||||
if (sectionIndex == 0) {
|
||||
return NodeHeaderListRow(
|
||||
title: S.of(context).add_new_node,
|
||||
|
@ -93,68 +102,62 @@ class NodeListPage extends BasePage {
|
|||
// FIXME: Add translation.
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: 'Change current node',
|
||||
alertContent:
|
||||
S.of(context).change_current_node(node.uri),
|
||||
alertContent: S
|
||||
.of(context)
|
||||
.change_current_node(node.uri),
|
||||
leftButtonText: S.of(context).cancel,
|
||||
rightButtonText: S.of(context).change,
|
||||
actionLeftButton: () =>
|
||||
Navigator.of(context).pop(),
|
||||
actionRightButton: () async {
|
||||
await nodeListViewModel.setAsCurrent(node);
|
||||
await nodeListViewModel
|
||||
.setAsCurrent(node);
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
final dismissibleRow = Dismissible(
|
||||
final dismissibleRow = Slidable(
|
||||
key: Key('${node.keyIndex}'),
|
||||
confirmDismiss: (direction) async {
|
||||
return await showPopUp(
|
||||
actionPane: SlidableDrawerActionPane(),
|
||||
child: nodeListRow,
|
||||
secondaryActions: <Widget>[
|
||||
IconSlideAction(
|
||||
caption: S.of(context).delete,
|
||||
color: Colors.red,
|
||||
icon: CupertinoIcons.delete,
|
||||
onTap: () async {
|
||||
final confirmed = await showPopUp<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).remove_node,
|
||||
alertContent: S.of(context).remove_node_message,
|
||||
rightButtonText: S.of(context).remove,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
alertTitle:
|
||||
S.of(context).remove_node,
|
||||
alertContent: S
|
||||
.of(context)
|
||||
.remove_node_message,
|
||||
rightButtonText:
|
||||
S.of(context).remove,
|
||||
leftButtonText:
|
||||
S.of(context).cancel,
|
||||
actionRightButton: () =>
|
||||
Navigator.pop(context, true),
|
||||
actionLeftButton: () =>
|
||||
Navigator.pop(context, false));
|
||||
});
|
||||
}) ??
|
||||
false;
|
||||
|
||||
if (confirmed) {
|
||||
await nodeListViewModel.delete(node);
|
||||
}
|
||||
},
|
||||
onDismissed: (direction) async =>
|
||||
nodeListViewModel.delete(node),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
color: Palette.red,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
const Icon(
|
||||
CupertinoIcons.delete,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
S.of(context).delete,
|
||||
style: TextStyle(color: Colors.white),
|
||||
)
|
||||
],
|
||||
)),
|
||||
child: nodeListRow);
|
||||
]);
|
||||
|
||||
return isSelected ? nodeListRow : dismissibleRow;
|
||||
});
|
||||
})
|
||||
: Container();
|
||||
},
|
||||
itemCounter: (int sectionIndex) {
|
||||
if (sectionIndex == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return nodeListViewModel.nodes.length;
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ class PinCodeState<T extends PinCodeWidget> extends State<T> {
|
|||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
Scaffold(key: _key, body: body(context));
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
key: _key, body: body(context), resizeToAvoidBottomPadding: false);
|
||||
|
||||
Widget body(BuildContext context) {
|
||||
final deleteIconImage = Image.asset(
|
||||
|
|
|
@ -25,15 +25,29 @@ import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart'
|
|||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
||||
class SendPage extends BasePage {
|
||||
SendPage({@required this.sendViewModel});
|
||||
SendPage({@required this.sendViewModel})
|
||||
: _addressController = TextEditingController(),
|
||||
_cryptoAmountController = TextEditingController(),
|
||||
_fiatAmountController = TextEditingController(),
|
||||
_formKey = GlobalKey<FormState>(),
|
||||
_cryptoAmountFocus = FocusNode(),
|
||||
_fiatAmountFocus = FocusNode(),
|
||||
_addressFocusNode = FocusNode() {
|
||||
_addressFocusNode.addListener(() {
|
||||
if (!_addressFocusNode.hasFocus && _addressController.text.isNotEmpty) {
|
||||
getOpenaliasRecord(_addressFocusNode.context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final SendViewModel sendViewModel;
|
||||
final _addressController = TextEditingController();
|
||||
final _cryptoAmountController = TextEditingController();
|
||||
final _fiatAmountController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _cryptoAmountFocus = FocusNode();
|
||||
final _fiatAmountFocus = FocusNode();
|
||||
final TextEditingController _addressController;
|
||||
final TextEditingController _cryptoAmountController;
|
||||
final TextEditingController _fiatAmountController;
|
||||
final GlobalKey<FormState> _formKey;
|
||||
final FocusNode _cryptoAmountFocus;
|
||||
final FocusNode _fiatAmountFocus;
|
||||
final FocusNode _addressFocusNode;
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
|
||||
|
@ -105,6 +119,7 @@ class SendPage extends BasePage {
|
|||
child: Column(
|
||||
children: <Widget>[
|
||||
AddressTextField(
|
||||
focusNode: _addressFocusNode,
|
||||
controller: _addressController,
|
||||
onURIScanned: (uri) {
|
||||
var address = '';
|
||||
|
@ -672,24 +687,23 @@ class SendPage extends BasePage {
|
|||
}
|
||||
|
||||
Future<void> getOpenaliasRecord(BuildContext context) async {
|
||||
// final isOpenalias =
|
||||
// await sendViewModel.isOpenaliasRecord(_addressController.text);
|
||||
final record =
|
||||
await sendViewModel.decodeOpenaliasRecord(_addressController.text);
|
||||
|
||||
// if (isOpenalias) {
|
||||
// _addressController.text = sendViewModel.recordAddress;
|
||||
if (record != null) {
|
||||
_addressController.text = record.address;
|
||||
|
||||
// await showPopUp<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertWithOneAction(
|
||||
// alertTitle: S.of(context).openalias_alert_title,
|
||||
// alertContent: S
|
||||
// .of(context)
|
||||
// .openalias_alert_content(sendViewModel.recordName),
|
||||
// buttonText: S.of(context).ok,
|
||||
// buttonAction: () => Navigator.of(context).pop());
|
||||
// });
|
||||
// }
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).openalias_alert_title,
|
||||
alertContent:
|
||||
S.of(context).openalias_alert_content(record.name),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setTransactionPriority(BuildContext context) async {
|
||||
|
|
|
@ -131,7 +131,7 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
wallet.name,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
|
|
|
@ -61,7 +61,7 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
|||
}
|
||||
|
||||
return watch().listen((event) {
|
||||
if (filter != null && !filter(event.value as T)) {
|
||||
if (filter != null && event.value != null && !filter(event.value as T)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
|||
}
|
||||
|
||||
return watch().listen((event) {
|
||||
if (filter != null && !filter(event.value as T)) {
|
||||
if (filter != null && event.value != null && !filter(event.value as T)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -124,15 +124,13 @@ extension HiveBindable<T extends Keyable> on ObservableList<T> {
|
|||
listen().listen((event) => dest.acceptEntityChange(event));
|
||||
|
||||
void acceptBoxChange(BoxEvent event, {T transformed}) {
|
||||
print('---------------------');
|
||||
print('event.key: ${event.key}; event.deleted: ${event.deleted};');
|
||||
if (event.deleted) {
|
||||
removeWhere((el) {
|
||||
print('el.keyIndex ${el.keyIndex}');
|
||||
return el.keyIndex == event.key; });
|
||||
}
|
||||
return el.keyIndex == event.key;
|
||||
});
|
||||
|
||||
print('---------------------');
|
||||
return;
|
||||
}
|
||||
|
||||
final dynamic value = transformed ?? event.value;
|
||||
|
||||
|
@ -150,6 +148,7 @@ extension HiveBindable<T extends Keyable> on ObservableList<T> {
|
|||
void acceptEntityChange(EntityChange<T> event) {
|
||||
if (event.type == ChangeType.delete) {
|
||||
removeWhere((el) => el.keyIndex == event.key);
|
||||
return;
|
||||
}
|
||||
|
||||
final dynamic value = event.value;
|
||||
|
|
|
@ -14,8 +14,8 @@ Future<T> showPopUp<T>({
|
|||
context: context,
|
||||
builder: builder,
|
||||
barrierDismissible: barrierDismissible,
|
||||
//barrierColor: barrierColor,
|
||||
//useSafeArea: useSafeArea,
|
||||
barrierColor: barrierColor,
|
||||
useSafeArea: useSafeArea,
|
||||
useRootNavigator: useRootNavigator,
|
||||
routeSettings: routeSettings,
|
||||
child: child);
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class NodeListViewModelBase with Store {
|
|||
NodeListViewModelBase(this._nodeSource, this._wallet, this.settingsStore)
|
||||
: nodes = ObservableList<Node>() {
|
||||
_nodeSource.bindToList(nodes,
|
||||
filter: (Node val) => val.type == _wallet.type, initialFire: true);
|
||||
filter: (Node val) => val?.type == _wallet.type, initialFire: true);
|
||||
}
|
||||
|
||||
final ObservableList<Node> nodes;
|
||||
|
@ -46,7 +46,8 @@ abstract class NodeListViewModelBase with Store {
|
|||
await setAsCurrent(node);
|
||||
}
|
||||
|
||||
Future<void> delete(Node node) async => _nodeSource.delete(node.key);
|
||||
@action
|
||||
Future<void> delete(Node node) async => node.delete();
|
||||
|
||||
Future<void> setAsCurrent(Node node) async =>
|
||||
settingsStore.currentNode = node;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/entities/openalias_record.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/core/template_validator.dart';
|
||||
|
@ -144,6 +145,13 @@ abstract class SendViewModelBase with Store {
|
|||
void setTransactionPriority(TransactionPriority priority) =>
|
||||
_settingsStore.transactionPriority = priority;
|
||||
|
||||
Future<OpenaliasRecord> decodeOpenaliasRecord(String name) async {
|
||||
final record = await OpenaliasRecord
|
||||
.fetchAddressAndName(OpenaliasRecord.formatDomainName(name));
|
||||
|
||||
return record.name != name ? record : null;
|
||||
}
|
||||
|
||||
@action
|
||||
void _updateFiatAmount() {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue