Update branch to null safety Fix Conflicts with main

Update branch to null safety Fix Conflicts with main

OmarHatem committed Nov 9, 2022 at 17:53 UTC ba783982e43216fea584cc2cea096020adcf491b
6 files changed +25 -28
cw_core/lib/node.dart
+2 -4
@@ -17,7 +17,7 @@ class Node extends HiveObject with Keyable {
17 {this.login,
18 this.password,
19 this.useSSL,
20 - this.trusted,
20 + this.trusted = false,
21 String? uri,
22 WalletType? type,}) {
23 if (uri != null) {
@@ -33,7 +33,7 @@ class Node extends HiveObject with Keyable {
33 login = map['login'] as String?,
34 password = map['password'] as String?,
35 useSSL = map['useSSL'] as bool?,
36 - useSSL = map['trusted'] as bool? ?? false;
36 + trusted = map['trusted'] as bool? ?? false;
37
38 static const typeId = 1;
39 static const boxName = 'Nodes';
@@ -58,8 +58,6 @@ class Node extends HiveObject with Keyable {
58
59 bool get isSSL => useSSL ?? false;
60
61 - bool get isTrusted => trusted ?? false;
62 -
61 Uri get uri {
62 switch (type) {
63 case WalletType.monero:
lib/di.dart
+3 -2
@@ -478,8 +478,9 @@ Future setup(
478
479 getIt.registerFactory(() => NodeListPage(getIt.get<NodeListViewModel>()));
480
481 - getIt.registerFactory(() =>
482 - NodeCreateOrEditViewModel(_nodeSource, getIt.get<AppStore>().wallet!));
481 + getIt.registerFactoryParam<NodeCreateOrEditViewModel, WalletType?, void>(
482 + (WalletType? type, _) =>
483 + NodeCreateOrEditViewModel(_nodeSource, type ?? getIt.get<AppStore>().wallet!.type));
484
485 getIt.registerFactory(
486 () => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));
lib/src/screens/new_wallet/advanced_privacy_settings_page.dart
+3 -4
@@ -4,7 +4,6 @@ import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.
4 import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
5 import 'package:flutter_mobx/flutter_mobx.dart';
6 import 'package:flutter/material.dart';
7 -import 'package:flutter/cupertino.dart';
7 import 'package:cake_wallet/generated/i18n.dart';
8 import 'package:cake_wallet/src/screens/base_page.dart';
9 import 'package:cake_wallet/src/widgets/primary_button.dart';
@@ -25,7 +24,7 @@ class AdvancedPrivacySettingsPage extends BasePage {
24 }
25
26 class AdvancedPrivacySettingsBody extends StatefulWidget {
28 - const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key key})
27 + const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key? key})
28 : super(key: key);
29
30 final PrivacySettingsViewModel privacySettingsViewModel;
@@ -85,7 +84,7 @@ class _AdvancedPrivacySettingsBodyState
84 LoadingPrimaryButton(
85 onPressed: () {},
86 text: S.of(context).continue_text,
88 - color: Theme.of(context).accentTextTheme.body2.color,
87 + color: Theme.of(context).accentTextTheme.bodyText1!.color!,
88 textColor: Colors.white,
89 ),
90 const SizedBox(height: 25),
@@ -96,7 +95,7 @@ class _AdvancedPrivacySettingsBodyState
95 S.of(context).settings_can_be_changed_later,
96 textAlign: TextAlign.center,
97 style: TextStyle(
99 - color: Theme.of(context).accentTextTheme.display3.color,
98 + color: Theme.of(context).accentTextTheme.headline2?.color,
99 ),
100 ),
101 ),
lib/src/screens/nodes/widgets/node_form.dart
+2 -2
@@ -10,8 +10,8 @@ import 'package:mobx/mobx.dart';
10
11 class NodeForm extends StatelessWidget {
12 NodeForm({
13 - @required this.nodeViewModel,
14 - @required this.formKey,
13 + required this.nodeViewModel,
14 + required this.formKey,
15 }) : _addressController = TextEditingController(),
16 _portController = TextEditingController(),
17 _loginController = TextEditingController(),
lib/view_model/node_list/node_create_or_edit_view_model.dart
+6 -7
@@ -1,7 +1,6 @@
1 import 'package:cake_wallet/core/execution_state.dart';
2 import 'package:hive/hive.dart';
3 import 'package:mobx/mobx.dart';
4 -import 'package:cw_core/wallet_base.dart';
4 import 'package:cw_core/node.dart';
5 import 'package:cw_core/wallet_type.dart';
6
@@ -11,7 +10,7 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
10 with _$NodeCreateOrEditViewModel;
11
12 abstract class NodeCreateOrEditViewModelBase with Store {
14 - NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
13 + NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType)
14 : state = InitialExecutionState(),
15 connectionState = InitialExecutionState(),
16 useSSL = false,
@@ -49,8 +48,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
48 bool get isReady =>
49 address.isNotEmpty && port.isNotEmpty;
50
52 - bool get hasAuthCredentials => _wallet.type == WalletType.monero ||
53 - _wallet.type == WalletType.haven;
51 + bool get hasAuthCredentials => _walletType == WalletType.monero ||
52 + _walletType == WalletType.haven;
53
54 String get uri {
55 var uri = address;
@@ -62,7 +61,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
61 return uri;
62 }
63
65 - final WalletBase _wallet;
64 + final WalletType _walletType;
65 final Box<Node> _nodeSource;
66
67 @action
@@ -80,7 +79,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
79 try {
80 state = IsExecutingState();
81 final node =
83 - Node(uri: uri, type: _wallet.type, login: login, password: password,
82 + Node(uri: uri, type: _walletType, login: login, password: password,
83 useSSL: useSSL, trusted: trusted);
84 await _nodeSource.add(node);
85 state = ExecutedSuccessfullyState();
@@ -94,7 +93,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
93 try {
94 connectionState = IsExecutingState();
95 final node =
97 - Node(uri: uri, type: _wallet.type, login: login, password: password);
96 + Node(uri: uri, type: _walletType, login: login, password: password);
97 final isAlive = await node.requestNode();
98 connectionState = ExecutedSuccessfullyState(payload: isAlive);
99 } catch (e) {
lib/view_model/privacy_settings_view_model.dart
+9 -9
@@ -9,13 +9,13 @@ class PrivacySettingsViewModel = PrivacySettingsViewModelBase
9 with _$PrivacySettingsViewModel;
10
11 abstract class PrivacySettingsViewModelBase with Store {
12 - PrivacySettingsViewModelBase(this.type) {
13 - _disableFiat = false;
14 - _disableExchange = false;
15 - _addCustomNode = false;
16 -
12 + PrivacySettingsViewModelBase(this.type)
13 + : _disableFiat = false,
14 + _disableExchange = false,
15 + _addCustomNode = false {
16 settings = [
17 SwitcherListItem(
18 + // TODO: replace when Disable Fiat PR is merged
19 title: "Disable Fiat API",
20 // title: S.current.disable_fiat,
21 value: () => _disableFiat,
@@ -36,16 +36,16 @@ abstract class PrivacySettingsViewModelBase with Store {
36 ];
37 }
38
39 - List<SwitcherListItem> settings;
39 + late List<SwitcherListItem> settings;
40
41 @observable
42 - bool _disableFiat;
42 + bool _disableFiat = false;
43
44 @observable
45 - bool _disableExchange;
45 + bool _disableExchange = false;
46
47 @observable
48 - bool _addCustomNode;
48 + bool _addCustomNode = false;
49
50 final WalletType type;
51