Allow marking Monero Nodes as trusted

OmarHatem committed Oct 4, 2022 at 14:54 UTC d748f12e4441a7383c0a86c169c94053a4815314
18 files changed +47 -6
cw_core/lib/node.dart
+9 -2
@@ -20,7 +20,8 @@ class Node extends HiveObject with Keyable {
20 @required WalletType type,
21 this.login,
22 this.password,
23 - this.useSSL}) {
23 + this.useSSL,
24 + this.trusted}) {
25 uriRaw = uri;
26 this.type = type;
27 }
@@ -30,7 +31,8 @@ class Node extends HiveObject with Keyable {
31 login = map['login'] as String,
32 password = map['password'] as String,
33 typeRaw = map['typeRaw'] as int,
33 - useSSL = map['useSSL'] as bool;
34 + useSSL = map['useSSL'] as bool,
35 + trusted = map['trusted'] as bool ?? false;
36
37 static const typeId = 1;
38 static const boxName = 'Nodes';
@@ -50,8 +52,13 @@ class Node extends HiveObject with Keyable {
52 @HiveField(4)
53 bool useSSL;
54
55 + @HiveField(5)
56 + bool trusted;
57 +
58 bool get isSSL => useSSL ?? false;
59
60 + bool get isTrusted => trusted ?? false;
61 +
62 Uri get uri {
63 switch (type) {
64 case WalletType.monero:
lib/src/screens/nodes/node_create_or_edit_page.dart
+16 -1
@@ -174,7 +174,22 @@ class NodeCreateOrEditPage extends BasePage {
174 caption: S.of(context).use_ssl,
175 ))
176 ],
177 - ))
177 + )),
178 + Padding(
179 + padding: EdgeInsets.only(top: 20),
180 + child: Row(
181 + mainAxisAlignment: MainAxisAlignment.start,
182 + mainAxisSize: MainAxisSize.max,
183 + children: [
184 + Observer(
185 + builder: (_) => StandardCheckbox(
186 + value: nodeCreateOrEditViewModel.trusted,
187 + onChanged: (value) =>
188 + nodeCreateOrEditViewModel.trusted = value,
189 + caption: S.of(context).trusted,
190 + ))
191 + ],
192 + )),
193 ]
194 ],
195 )),
lib/view_model/node_list/node_create_or_edit_view_model.dart
+7 -2
@@ -14,7 +14,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
14 NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
15 : state = InitialExecutionState(),
16 connectionState = InitialExecutionState(),
17 - useSSL = false;
17 + useSSL = false,
18 + trusted = false;
19
20 @observable
21 ExecutionState state;
@@ -37,6 +38,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
38 @observable
39 bool useSSL;
40
41 + @observable
42 + bool trusted;
43 +
44 @computed
45 bool get isReady =>
46 (address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
@@ -64,6 +68,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
68 login = '';
69 password = '';
70 useSSL = false;
71 + trusted = false;
72 }
73
74 @action
@@ -72,7 +77,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
77 state = IsExecutingState();
78 final node =
79 Node(uri: uri, type: _wallet.type, login: login, password: password,
75 - useSSL: useSSL);
80 + useSSL: useSSL, trusted: trusted);
81 await _nodeSource.add(node);
82 state = ExecutedSuccessfullyState();
83 } catch (e) {
res/values/strings_de.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider}-Fehler",
437
438 "use_ssl" : "SSL verwenden",
439 + "trusted" : "Vertrauenswürdige",
440
441 "color_theme" : "Farbthema",
442 "light_theme" : "Hell",
res/values/strings_en.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} error",
437
438 "use_ssl" : "Use SSL",
439 + "trusted" : "Trusted",
440
441 "color_theme" : "Color theme",
442 "light_theme" : "Light",
res/values/strings_es.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} error",
437
438 "use_ssl" : "Utilice SSL",
439 + "trusted" : "de confianza",
440
441 "color_theme" : "Tema de color",
442 "light_theme" : "Ligera",
res/values/strings_fr.arb
+1
@@ -434,6 +434,7 @@
434 "provider_error" : "Erreur de ${provider}",
435
436 "use_ssl" : "Utiliser SSL",
437 + "trusted" : "de confiance",
438
439 "color_theme" : "Thème",
440 "light_theme" : "Clair",
res/values/strings_hi.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} त्रुटि",
437
438 "use_ssl" : "उपयोग SSL",
439 + "trusted" : "भरोसा",
440
441 "color_theme" : "रंग विषय",
442 "light_theme" : "रोशनी",
res/values/strings_hr.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} greška",
437
438 "use_ssl" : "Koristi SSL",
439 + "trusted" : "vjerovao",
440
441 "color_theme" : "Shema boja",
442 "light_theme" : "Svijetla",
res/values/strings_it.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} errore",
437
438 "use_ssl" : "Usa SSL",
439 + "trusted" : "di fiducia",
440
441 "color_theme" : "Colore tema",
442 "light_theme" : "Bianco",
res/values/strings_ja.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} エラー",
437
438 "use_ssl" : "SSLを使用する",
439 + "trusted" : "信頼できる",
440
441 "color_theme" : "カラーテーマ",
442 "light_theme" : "光",
res/values/strings_ko.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} 오류",
437
438 "use_ssl" : "SSL 사용",
439 + "trusted" : "신뢰할 수 있는",
440
441 "color_theme" : "색상 테마",
442 "light_theme" : "빛",
res/values/strings_nl.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} fout",
437
438 "use_ssl" : "Gebruik SSL",
439 + "trusted" : "vertrouwd",
440
441 "color_theme" : "Kleur thema",
442 "light_theme" : "Licht",
res/values/strings_pl.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} pomyłka",
437
438 "use_ssl" : "Użyj SSL",
439 + "trusted" : "zaufany",
440
441 "color_theme" : "Motyw kolorystyczny",
442 "light_theme" : "Lekki",
res/values/strings_pt.arb
+1 -1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} erro",
437
438 "use_ssl" : "Use SSL",
439 + "trusted" : "confiável",
440
441 "color_theme" : "Tema de cor",
442 "light_theme" : "Luz",
@@ -544,7 +545,6 @@
545 "create_account": "Criar conta",
546 "privacy_policy": "Política de privacidade",
547 "welcome_to_cakepay": "Bem-vindo ao Cake Pay!",
547 - "create_account": "Registar-se",
548 "forgot_password": "Esqueci a senha",
549 "reset_password": "Redefinir senha",
550 "gift_cards": "Cartões de presente",
res/values/strings_ru.arb
+1
@@ -436,6 +436,7 @@
436 "provider_error" : "${provider} ошибка",
437
438 "use_ssl" : "Использовать SSL",
439 + "trusted" : "доверенный",
440
441 "color_theme" : "Цветовая тема",
442 "light_theme" : "Светлая",
res/values/strings_uk.arb
+1
@@ -435,6 +435,7 @@
435 "provider_error" : "${provider} помилка",
436
437 "use_ssl" : "Використати SSL",
438 + "trusted" : "довіряють",
439
440 "color_theme" : "Кольорова тема",
441 "light_theme" : "Світла",
res/values/strings_zh.arb
+1
@@ -435,6 +435,7 @@
435 "provider_error" : "${provider} 错误",
436
437 "use_ssl" : "使用SSL",
438 + "trusted" : "值得信赖",
439
440 "color_theme" : "主题",
441 "light_theme" : "艳丽",