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
OleksandrSobol committed
Nov 30, 2020 at 19:05 UTC
5ee278237f3efa446126fb31331df14fc91942b3
5 files changed
+110
-7
lib/entities/node.dart
+7
-2
@@ -14,7 +14,8 @@ class Node extends HiveObject with Keyable {
14
{@required this.uri,
15
@required WalletType type,
16
this.login,
17
- this.password}) {
17
+ this.password,
18
+ this.useSSL}) {
19
this.type = type;
20
}
21
@@ -22,7 +23,8 @@ class Node extends HiveObject with Keyable {
23
: uri = map['uri'] as String ?? '',
24
login = map['login'] as String,
25
password = map['password'] as String,
25
- typeRaw = map['typeRaw'] as int;
26
+ typeRaw = map['typeRaw'] as int,
27
+ useSSL = map['useSSL'] as bool;
28
29
static const boxName = 'Nodes';
30
@@ -38,6 +40,9 @@ class Node extends HiveObject with Keyable {
40
@HiveField(3)
41
int typeRaw;
42
43
+ @HiveField(4)
44
+ bool useSSL;
45
+
46
@override
47
dynamic get keyIndex {
48
_keyIndex ??= key;
lib/monero/monero_wallet.dart
+1
-2
@@ -147,8 +147,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
147
address: node.uri,
148
login: node.login,
149
password: node.password,
150
- useSSL: true,
151
- // FIXME: hardcoded value
150
+ useSSL: node.useSSL ?? false,
151
isLightWallet: false); // FIXME: hardcoded value
152
syncStatus = ConnectedSyncStatus();
153
} catch (e) {
lib/src/screens/nodes/node_create_or_edit_page.dart
+18
-1
@@ -1,4 +1,6 @@
1
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
2
+import 'package:cake_wallet/src/widgets/checkbox_widget.dart';
3
+import 'package:cake_wallet/src/widgets/standard_checkbox.dart';
4
import 'package:cake_wallet/utils/show_pop_up.dart';
5
import 'package:cake_wallet/view_model/node_list/connection_state.dart';
6
import 'package:flutter/material.dart';
@@ -130,7 +132,22 @@ class NodeCreateOrEditPage extends BasePage {
132
)
133
)
134
],
133
- )
135
+ ),
136
+ Padding(
137
+ padding: EdgeInsets.only(top: 20),
138
+ child: Row(
139
+ mainAxisAlignment: MainAxisAlignment.start,
140
+ mainAxisSize: MainAxisSize.max,
141
+ children: [
142
+ Observer(
143
+ builder: (_) => StandardCheckbox(
144
+ value: nodeCreateOrEditViewModel.useSSL,
145
+ onChanged: (value) =>
146
+ nodeCreateOrEditViewModel.useSSL = value,
147
+ caption: 'Use SSL',
148
+ ))
149
+ ],
150
+ ))
151
]
152
],
153
)),
lib/src/widgets/standard_checkbox.dart
new
+76
@@ -0,0 +1,76 @@
1
+import 'dart:ui';
2
+import 'package:flutter/cupertino.dart';
3
+import 'package:flutter/material.dart';
4
+
5
+class StandardCheckbox extends StatefulWidget {
6
+ StandardCheckbox({
7
+ @required this.value,
8
+ this.caption = '',
9
+ @required this.onChanged});
10
+
11
+ final bool value;
12
+ final String caption;
13
+ final Function(bool) onChanged;
14
+
15
+ @override
16
+ StandardCheckboxState createState() =>
17
+ StandardCheckboxState(value, caption, onChanged);
18
+}
19
+
20
+class StandardCheckboxState extends State<StandardCheckbox> {
21
+ StandardCheckboxState(this.value, this.caption, this.onChanged);
22
+
23
+ bool value;
24
+ String caption;
25
+ Function(bool) onChanged;
26
+
27
+ @override
28
+ Widget build(BuildContext context) {
29
+ return GestureDetector(
30
+ onTap: () {
31
+ value = !value;
32
+ onChanged(value);
33
+ setState(() {});
34
+ },
35
+ child: Row(
36
+ mainAxisSize: MainAxisSize.min,
37
+ mainAxisAlignment: MainAxisAlignment.start,
38
+ children: <Widget>[
39
+ Container(
40
+ height: 24.0,
41
+ width: 24.0,
42
+ margin: EdgeInsets.only(
43
+ right: 10.0,
44
+ ),
45
+ decoration: BoxDecoration(
46
+ border: Border.all(
47
+ color: Theme.of(context)
48
+ .primaryTextTheme
49
+ .caption
50
+ .color,
51
+ width: 1.0),
52
+ borderRadius: BorderRadius.all(
53
+ Radius.circular(8.0)),
54
+ color: Theme.of(context).backgroundColor),
55
+ child: value
56
+ ? Icon(
57
+ Icons.check,
58
+ color: Colors.blue,
59
+ size: 20.0,
60
+ )
61
+ : Offstage(),
62
+ ),
63
+ Text(
64
+ caption,
65
+ style: TextStyle(
66
+ fontSize: 16.0,
67
+ color: Theme.of(context)
68
+ .primaryTextTheme
69
+ .title
70
+ .color),
71
+ )
72
+ ],
73
+ ),
74
+ );
75
+ }
76
+}
\ No newline at end of file
lib/view_model/node_list/node_create_or_edit_view_model.dart
+8
-2
@@ -14,7 +14,8 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
14
abstract class NodeCreateOrEditViewModelBase with Store {
15
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
16
: state = InitialExecutionState(),
17
- connectionState = InitialConnectionState();
17
+ connectionState = InitialConnectionState(),
18
+ useSSL = false;
19
20
@observable
21
ExecutionState state;
@@ -34,6 +35,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
35
@observable
36
ConnectionToNodeState connectionState;
37
38
+ @observable
39
+ bool useSSL;
40
+
41
@computed
42
bool get isReady =>
43
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
@@ -59,6 +63,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
63
port = '';
64
login = '';
65
password = '';
66
+ useSSL = false;
67
}
68
69
@action
@@ -66,7 +71,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
71
try {
72
state = IsExecutingState();
73
final node =
69
- Node(uri: uri, type: _wallet.type, login: login, password: password);
74
+ Node(uri: uri, type: _wallet.type, login: login, password: password,
75
+ useSSL: useSSL);
76
await _nodeSource.add(node);
77
state = ExecutedSuccessfullyState();
78
} catch (e) {