mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 09:47:35 +00:00
Separate node form to be more reusable
Add node form to privacy settings
This commit is contained in:
parent
6bbedde9b7
commit
299df3c087
6 changed files with 191 additions and 187 deletions
|
@ -478,8 +478,9 @@ Future setup(
|
||||||
|
|
||||||
getIt.registerFactory(() => NodeListPage(getIt.get<NodeListViewModel>()));
|
getIt.registerFactory(() => NodeListPage(getIt.get<NodeListViewModel>()));
|
||||||
|
|
||||||
getIt.registerFactory(() =>
|
getIt.registerFactoryParam<NodeCreateOrEditViewModel, WalletType, void>(
|
||||||
NodeCreateOrEditViewModel(_nodeSource, getIt.get<AppStore>().wallet));
|
(WalletType type, _) =>
|
||||||
|
NodeCreateOrEditViewModel(_nodeSource, type ?? getIt.get<AppStore>().wallet.type));
|
||||||
|
|
||||||
getIt.registerFactory(
|
getIt.registerFactory(
|
||||||
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
|
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
|
||||||
|
|
|
@ -20,6 +20,7 @@ import 'package:cake_wallet/src/screens/support/support_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
|
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
|
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
|
||||||
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
|
||||||
|
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -476,9 +477,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
case Routes.privacySettings:
|
case Routes.privacySettings:
|
||||||
final type = settings.arguments as WalletType;
|
final type = settings.arguments as WalletType;
|
||||||
final privacySettingsViewModel = getIt.get<PrivacySettingsViewModel>(param1: type);
|
final privacySettingsViewModel = getIt.get<PrivacySettingsViewModel>(param1: type);
|
||||||
|
final nodeCreateViewModel = getIt.get<NodeCreateOrEditViewModel>(param1: type);
|
||||||
|
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
builder: (_) => AdvancedPrivacySettingsPage(privacySettingsViewModel));
|
builder: (_) => AdvancedPrivacySettingsPage(privacySettingsViewModel, nodeCreateViewModel));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return MaterialPageRoute<void>(
|
return MaterialPageRoute<void>(
|
||||||
|
|
|
@ -1,49 +1,50 @@
|
||||||
import 'package:cake_wallet/entities/generate_name.dart';
|
import 'package:cake_wallet/src/screens/nodes/widgets/node_form.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
||||||
|
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/core/wallet_name_validator.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
|
|
||||||
class AdvancedPrivacySettingsPage extends BasePage {
|
class AdvancedPrivacySettingsPage extends BasePage {
|
||||||
AdvancedPrivacySettingsPage(this.privacySettingsViewModel);
|
AdvancedPrivacySettingsPage(this.privacySettingsViewModel, this.nodeViewModel);
|
||||||
|
|
||||||
final PrivacySettingsViewModel privacySettingsViewModel;
|
final PrivacySettingsViewModel privacySettingsViewModel;
|
||||||
|
final NodeCreateOrEditViewModel nodeViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.privacy_settings;
|
String get title => S.current.privacy_settings;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) =>
|
Widget body(BuildContext context) =>
|
||||||
AdvancedPrivacySettingsBody(privacySettingsViewModel);
|
AdvancedPrivacySettingsBody(privacySettingsViewModel, nodeViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdvancedPrivacySettingsBody extends StatefulWidget {
|
class AdvancedPrivacySettingsBody extends StatefulWidget {
|
||||||
const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, {Key key})
|
const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final PrivacySettingsViewModel privacySettingsViewModel;
|
final PrivacySettingsViewModel privacySettingsViewModel;
|
||||||
|
final NodeCreateOrEditViewModel nodeViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AdvancedPrivacySettingsBodyState createState() =>
|
_AdvancedPrivacySettingsBodyState createState() =>
|
||||||
_AdvancedPrivacySettingsBodyState(privacySettingsViewModel);
|
_AdvancedPrivacySettingsBodyState(privacySettingsViewModel, nodeViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AdvancedPrivacySettingsBodyState
|
class _AdvancedPrivacySettingsBodyState
|
||||||
extends State<AdvancedPrivacySettingsBody> {
|
extends State<AdvancedPrivacySettingsBody> {
|
||||||
_AdvancedPrivacySettingsBodyState(this.privacySettingsViewModel);
|
_AdvancedPrivacySettingsBodyState(this.privacySettingsViewModel, this.nodeViewModel);
|
||||||
|
|
||||||
final PrivacySettingsViewModel privacySettingsViewModel;
|
final PrivacySettingsViewModel privacySettingsViewModel;
|
||||||
|
final NodeCreateOrEditViewModel nodeViewModel;
|
||||||
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
final TextEditingController _controller = TextEditingController();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
@ -67,75 +68,9 @@ class _AdvancedPrivacySettingsBodyState
|
||||||
if (privacySettingsViewModel.addCustomNode) {
|
if (privacySettingsViewModel.addCustomNode) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(top: 24),
|
padding: EdgeInsets.only(top: 24),
|
||||||
child: Form(
|
child: NodeForm(
|
||||||
key: _formKey,
|
formKey: _formKey,
|
||||||
child: TextFormField(
|
nodeViewModel: nodeViewModel,
|
||||||
onChanged: (value) {},
|
|
||||||
controller: _controller,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20.0,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color:
|
|
||||||
Theme.of(context).primaryTextTheme.title.color),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 18.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.accentTextTheme
|
|
||||||
.display3
|
|
||||||
.color),
|
|
||||||
hintText: S.of(context).wallet_name,
|
|
||||||
focusedBorder: UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.accentTextTheme
|
|
||||||
.display3
|
|
||||||
.decorationColor,
|
|
||||||
width: 1.0),
|
|
||||||
),
|
|
||||||
enabledBorder: UnderlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.accentTextTheme
|
|
||||||
.display3
|
|
||||||
.decorationColor,
|
|
||||||
width: 1.0),
|
|
||||||
),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final rName = await generateName();
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus();
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_controller.text = rName;
|
|
||||||
_controller.selection =
|
|
||||||
TextSelection.fromPosition(
|
|
||||||
TextPosition(offset: _controller.text.length),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: Container(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(6.0),
|
|
||||||
color: Theme.of(context).hintColor,
|
|
||||||
),
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/refresh_icon.png',
|
|
||||||
color: Theme.of(context)
|
|
||||||
.primaryTextTheme
|
|
||||||
.display1
|
|
||||||
.decorationColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
validator: WalletNameValidator(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
import 'package:cake_wallet/core/execution_state.dart';
|
import 'package:cake_wallet/core/execution_state.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/nodes/widgets/node_form.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
|
|
||||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cake_wallet/generated/i18n.dart';
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
import 'package:cake_wallet/core/node_address_validator.dart';
|
|
||||||
import 'package:cake_wallet/core/node_port_validator.dart';
|
|
||||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||||
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
||||||
|
@ -108,91 +105,10 @@ class NodeCreateOrEditPage extends BasePage {
|
||||||
padding: EdgeInsets.only(left: 24, right: 24),
|
padding: EdgeInsets.only(left: 24, right: 24),
|
||||||
child: ScrollableWithBottomSection(
|
child: ScrollableWithBottomSection(
|
||||||
contentPadding: EdgeInsets.only(bottom: 24.0),
|
contentPadding: EdgeInsets.only(bottom: 24.0),
|
||||||
content: Form(
|
content: NodeForm(
|
||||||
key: _formKey,
|
formKey: _formKey,
|
||||||
child: Column(
|
nodeViewModel: nodeCreateOrEditViewModel,
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: BaseTextFormField(
|
|
||||||
controller: _addressController,
|
|
||||||
hintText: S.of(context).node_address,
|
|
||||||
validator: NodeAddressValidator(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: BaseTextFormField(
|
|
||||||
controller: _portController,
|
|
||||||
hintText: S.of(context).node_port,
|
|
||||||
keyboardType: TextInputType.numberWithOptions(
|
|
||||||
signed: false, decimal: false),
|
|
||||||
validator: NodePortValidator(),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 10.0),
|
|
||||||
if (nodeCreateOrEditViewModel.hasAuthCredentials) ...[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: BaseTextFormField(
|
|
||||||
controller: _loginController,
|
|
||||||
hintText: S.of(context).login,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: BaseTextFormField(
|
|
||||||
controller: _passwordController,
|
|
||||||
hintText: S.of(context).password,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(top: 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Observer(
|
|
||||||
builder: (_) => StandardCheckbox(
|
|
||||||
value: nodeCreateOrEditViewModel.useSSL,
|
|
||||||
onChanged: (value) =>
|
|
||||||
nodeCreateOrEditViewModel.useSSL = value,
|
|
||||||
caption: S.of(context).use_ssl,
|
|
||||||
))
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(top: 20),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Observer(
|
|
||||||
builder: (_) => StandardCheckbox(
|
|
||||||
value: nodeCreateOrEditViewModel.trusted,
|
|
||||||
onChanged: (value) =>
|
|
||||||
nodeCreateOrEditViewModel.trusted = value,
|
|
||||||
caption: S.of(context).trusted,
|
|
||||||
))
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
bottomSectionPadding: EdgeInsets.only(bottom: 24),
|
bottomSectionPadding: EdgeInsets.only(bottom: 24),
|
||||||
bottomSection: Observer(
|
bottomSection: Observer(
|
||||||
builder: (_) => Row(
|
builder: (_) => Row(
|
||||||
|
|
151
lib/src/screens/nodes/widgets/node_form.dart
Normal file
151
lib/src/screens/nodes/widgets/node_form.dart
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
import 'package:cake_wallet/core/node_address_validator.dart';
|
||||||
|
import 'package:cake_wallet/core/node_port_validator.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||||
|
import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
|
||||||
|
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
|
class NodeForm extends StatelessWidget {
|
||||||
|
NodeForm({
|
||||||
|
@required this.nodeViewModel,
|
||||||
|
@required this.formKey,
|
||||||
|
}) : _addressController = TextEditingController(),
|
||||||
|
_portController = TextEditingController(),
|
||||||
|
_loginController = TextEditingController(),
|
||||||
|
_passwordController = TextEditingController() {
|
||||||
|
reaction((_) => nodeViewModel.address, (String address) {
|
||||||
|
if (address != _addressController.text) {
|
||||||
|
_addressController.text = address;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reaction((_) => nodeViewModel.port, (String port) {
|
||||||
|
if (port != _portController.text) {
|
||||||
|
_portController.text = port;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (nodeViewModel.hasAuthCredentials) {
|
||||||
|
reaction((_) => nodeViewModel.login, (String login) {
|
||||||
|
if (login != _loginController.text) {
|
||||||
|
_loginController.text = login;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reaction((_) => nodeViewModel.password, (String password) {
|
||||||
|
if (password != _passwordController.text) {
|
||||||
|
_passwordController.text = password;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_addressController
|
||||||
|
.addListener(() => nodeViewModel.address = _addressController.text);
|
||||||
|
_portController
|
||||||
|
.addListener(() => nodeViewModel.port = _portController.text);
|
||||||
|
_loginController
|
||||||
|
.addListener(() => nodeViewModel.login = _loginController.text);
|
||||||
|
_passwordController
|
||||||
|
.addListener(() => nodeViewModel.password = _passwordController.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
final NodeCreateOrEditViewModel nodeViewModel;
|
||||||
|
final GlobalKey<FormState> formKey;
|
||||||
|
|
||||||
|
final TextEditingController _addressController;
|
||||||
|
final TextEditingController _portController;
|
||||||
|
final TextEditingController _loginController;
|
||||||
|
final TextEditingController _passwordController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Form(
|
||||||
|
key: formKey,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: BaseTextFormField(
|
||||||
|
controller: _addressController,
|
||||||
|
hintText: S.of(context).node_address,
|
||||||
|
validator: NodeAddressValidator(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: BaseTextFormField(
|
||||||
|
controller: _portController,
|
||||||
|
hintText: S.of(context).node_port,
|
||||||
|
keyboardType: TextInputType.numberWithOptions(
|
||||||
|
signed: false, decimal: false),
|
||||||
|
validator: NodePortValidator(),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 10.0),
|
||||||
|
if (nodeViewModel.hasAuthCredentials) ...[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: BaseTextFormField(
|
||||||
|
controller: _loginController,
|
||||||
|
hintText: S.of(context).login,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: BaseTextFormField(
|
||||||
|
controller: _passwordController,
|
||||||
|
hintText: S.of(context).password,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Observer(
|
||||||
|
builder: (_) => StandardCheckbox(
|
||||||
|
value: nodeViewModel.useSSL,
|
||||||
|
onChanged: (value) => nodeViewModel.useSSL = value,
|
||||||
|
caption: S.of(context).use_ssl,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(top: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Observer(
|
||||||
|
builder: (_) => StandardCheckbox(
|
||||||
|
value: nodeViewModel.trusted,
|
||||||
|
onChanged: (value) => nodeViewModel.trusted = value,
|
||||||
|
caption: S.of(context).trusted,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:cake_wallet/core/execution_state.dart';
|
import 'package:cake_wallet/core/execution_state.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
|
||||||
import 'package:cw_core/node.dart';
|
import 'package:cw_core/node.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
|
|
||||||
|
@ -11,7 +10,7 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
|
||||||
with _$NodeCreateOrEditViewModel;
|
with _$NodeCreateOrEditViewModel;
|
||||||
|
|
||||||
abstract class NodeCreateOrEditViewModelBase with Store {
|
abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
|
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType)
|
||||||
: state = InitialExecutionState(),
|
: state = InitialExecutionState(),
|
||||||
connectionState = InitialExecutionState(),
|
connectionState = InitialExecutionState(),
|
||||||
useSSL = false,
|
useSSL = false,
|
||||||
|
@ -45,8 +44,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
bool get isReady =>
|
bool get isReady =>
|
||||||
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
||||||
|
|
||||||
bool get hasAuthCredentials => _wallet.type == WalletType.monero ||
|
bool get hasAuthCredentials => _walletType == WalletType.monero ||
|
||||||
_wallet.type == WalletType.haven;
|
_walletType == WalletType.haven;
|
||||||
|
|
||||||
String get uri {
|
String get uri {
|
||||||
var uri = address;
|
var uri = address;
|
||||||
|
@ -58,7 +57,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
final WalletBase _wallet;
|
final WalletType _walletType;
|
||||||
final Box<Node> _nodeSource;
|
final Box<Node> _nodeSource;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -76,7 +75,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
try {
|
try {
|
||||||
state = IsExecutingState();
|
state = IsExecutingState();
|
||||||
final node =
|
final node =
|
||||||
Node(uri: uri, type: _wallet.type, login: login, password: password,
|
Node(uri: uri, type: _walletType, login: login, password: password,
|
||||||
useSSL: useSSL, trusted: trusted);
|
useSSL: useSSL, trusted: trusted);
|
||||||
await _nodeSource.add(node);
|
await _nodeSource.add(node);
|
||||||
state = ExecutedSuccessfullyState();
|
state = ExecutedSuccessfullyState();
|
||||||
|
@ -90,7 +89,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
try {
|
try {
|
||||||
connectionState = IsExecutingState();
|
connectionState = IsExecutingState();
|
||||||
final node =
|
final node =
|
||||||
Node(uri: uri, type: _wallet.type, login: login, password: password);
|
Node(uri: uri, type: _walletType, login: login, password: password);
|
||||||
final isAlive = await node.requestNode();
|
final isAlive = await node.requestNode();
|
||||||
connectionState = ExecutedSuccessfullyState(payload: isAlive);
|
connectionState = ExecutedSuccessfullyState(payload: isAlive);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue