mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 19:16:09 +00:00
CAKE-169 | added useSSL parameter to node.dart and to node_create_or_edit_view_model.dart; applied useSSL parameter in the connectToNode() method (monero_wallet.dart) and in the save() method (node_create_or_edit_view_model.dart); created standard_checkbox.dart and applied StandardCheckbox widget in the node_create_or_edit_page.dart
This commit is contained in:
parent
83fea0e9d3
commit
5ee278237f
5 changed files with 110 additions and 7 deletions
|
@ -14,7 +14,8 @@ class Node extends HiveObject with Keyable {
|
||||||
{@required this.uri,
|
{@required this.uri,
|
||||||
@required WalletType type,
|
@required WalletType type,
|
||||||
this.login,
|
this.login,
|
||||||
this.password}) {
|
this.password,
|
||||||
|
this.useSSL}) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +23,8 @@ class Node extends HiveObject with Keyable {
|
||||||
: uri = map['uri'] as String ?? '',
|
: uri = map['uri'] as String ?? '',
|
||||||
login = map['login'] as String,
|
login = map['login'] as String,
|
||||||
password = map['password'] as String,
|
password = map['password'] as String,
|
||||||
typeRaw = map['typeRaw'] as int;
|
typeRaw = map['typeRaw'] as int,
|
||||||
|
useSSL = map['useSSL'] as bool;
|
||||||
|
|
||||||
static const boxName = 'Nodes';
|
static const boxName = 'Nodes';
|
||||||
|
|
||||||
|
@ -38,6 +40,9 @@ class Node extends HiveObject with Keyable {
|
||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
int typeRaw;
|
int typeRaw;
|
||||||
|
|
||||||
|
@HiveField(4)
|
||||||
|
bool useSSL;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic get keyIndex {
|
dynamic get keyIndex {
|
||||||
_keyIndex ??= key;
|
_keyIndex ??= key;
|
||||||
|
|
|
@ -147,8 +147,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||||
address: node.uri,
|
address: node.uri,
|
||||||
login: node.login,
|
login: node.login,
|
||||||
password: node.password,
|
password: node.password,
|
||||||
useSSL: true,
|
useSSL: node.useSSL ?? false,
|
||||||
// FIXME: hardcoded value
|
|
||||||
isLightWallet: false); // FIXME: hardcoded value
|
isLightWallet: false); // FIXME: hardcoded value
|
||||||
syncStatus = ConnectedSyncStatus();
|
syncStatus = ConnectedSyncStatus();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
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/checkbox_widget.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:cake_wallet/view_model/node_list/connection_state.dart';
|
import 'package:cake_wallet/view_model/node_list/connection_state.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -130,7 +132,22 @@ class NodeCreateOrEditPage extends BasePage {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
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: 'Use SSL',
|
||||||
|
))
|
||||||
|
],
|
||||||
|
))
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
|
76
lib/src/widgets/standard_checkbox.dart
Normal file
76
lib/src/widgets/standard_checkbox.dart
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class StandardCheckbox extends StatefulWidget {
|
||||||
|
StandardCheckbox({
|
||||||
|
@required this.value,
|
||||||
|
this.caption = '',
|
||||||
|
@required this.onChanged});
|
||||||
|
|
||||||
|
final bool value;
|
||||||
|
final String caption;
|
||||||
|
final Function(bool) onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
StandardCheckboxState createState() =>
|
||||||
|
StandardCheckboxState(value, caption, onChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
class StandardCheckboxState extends State<StandardCheckbox> {
|
||||||
|
StandardCheckboxState(this.value, this.caption, this.onChanged);
|
||||||
|
|
||||||
|
bool value;
|
||||||
|
String caption;
|
||||||
|
Function(bool) onChanged;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
value = !value;
|
||||||
|
onChanged(value);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
height: 24.0,
|
||||||
|
width: 24.0,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
right: 10.0,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.primaryTextTheme
|
||||||
|
.caption
|
||||||
|
.color,
|
||||||
|
width: 1.0),
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(8.0)),
|
||||||
|
color: Theme.of(context).backgroundColor),
|
||||||
|
child: value
|
||||||
|
? Icon(
|
||||||
|
Icons.check,
|
||||||
|
color: Colors.blue,
|
||||||
|
size: 20.0,
|
||||||
|
)
|
||||||
|
: Offstage(),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
caption,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16.0,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.primaryTextTheme
|
||||||
|
.title
|
||||||
|
.color),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,8 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
|
||||||
abstract class NodeCreateOrEditViewModelBase with Store {
|
abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
|
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
|
||||||
: state = InitialExecutionState(),
|
: state = InitialExecutionState(),
|
||||||
connectionState = InitialConnectionState();
|
connectionState = InitialConnectionState(),
|
||||||
|
useSSL = false;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
ExecutionState state;
|
ExecutionState state;
|
||||||
|
@ -34,6 +35,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
@observable
|
@observable
|
||||||
ConnectionToNodeState connectionState;
|
ConnectionToNodeState connectionState;
|
||||||
|
|
||||||
|
@observable
|
||||||
|
bool useSSL;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get isReady =>
|
bool get isReady =>
|
||||||
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
||||||
|
@ -59,6 +63,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
port = '';
|
port = '';
|
||||||
login = '';
|
login = '';
|
||||||
password = '';
|
password = '';
|
||||||
|
useSSL = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -66,7 +71,8 @@ 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: _wallet.type, login: login, password: password,
|
||||||
|
useSSL: useSSL);
|
||||||
await _nodeSource.add(node);
|
await _nodeSource.add(node);
|
||||||
state = ExecutedSuccessfullyState();
|
state = ExecutedSuccessfullyState();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue