Update branch to null safety

Fix Conflicts with main
This commit is contained in:
OmarHatem 2022-11-09 17:53:50 +02:00
parent 6210d8fba6
commit ba783982e4
6 changed files with 25 additions and 28 deletions

View file

@ -17,7 +17,7 @@ class Node extends HiveObject with Keyable {
{this.login,
this.password,
this.useSSL,
this.trusted,
this.trusted = false,
String? uri,
WalletType? type,}) {
if (uri != null) {
@ -33,7 +33,7 @@ class Node extends HiveObject with Keyable {
login = map['login'] as String?,
password = map['password'] as String?,
useSSL = map['useSSL'] as bool?,
useSSL = map['trusted'] as bool? ?? false;
trusted = map['trusted'] as bool? ?? false;
static const typeId = 1;
static const boxName = 'Nodes';
@ -58,8 +58,6 @@ class Node extends HiveObject with Keyable {
bool get isSSL => useSSL ?? false;
bool get isTrusted => trusted ?? false;
Uri get uri {
switch (type) {
case WalletType.monero:

View file

@ -478,8 +478,9 @@ Future setup(
getIt.registerFactory(() => NodeListPage(getIt.get<NodeListViewModel>()));
getIt.registerFactory(() =>
NodeCreateOrEditViewModel(_nodeSource, getIt.get<AppStore>().wallet!));
getIt.registerFactoryParam<NodeCreateOrEditViewModel, WalletType?, void>(
(WalletType? type, _) =>
NodeCreateOrEditViewModel(_nodeSource, type ?? getIt.get<AppStore>().wallet!.type));
getIt.registerFactory(
() => NodeCreateOrEditPage(getIt.get<NodeCreateOrEditViewModel>()));

View file

@ -4,7 +4,6 @@ import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.
import 'package:cake_wallet/view_model/privacy_settings_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@ -25,7 +24,7 @@ class AdvancedPrivacySettingsPage extends BasePage {
}
class AdvancedPrivacySettingsBody extends StatefulWidget {
const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key key})
const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key? key})
: super(key: key);
final PrivacySettingsViewModel privacySettingsViewModel;
@ -85,7 +84,7 @@ class _AdvancedPrivacySettingsBodyState
LoadingPrimaryButton(
onPressed: () {},
text: S.of(context).continue_text,
color: Theme.of(context).accentTextTheme.body2.color,
color: Theme.of(context).accentTextTheme.bodyText1!.color!,
textColor: Colors.white,
),
const SizedBox(height: 25),
@ -96,7 +95,7 @@ class _AdvancedPrivacySettingsBodyState
S.of(context).settings_can_be_changed_later,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentTextTheme.display3.color,
color: Theme.of(context).accentTextTheme.headline2?.color,
),
),
),

View file

@ -10,8 +10,8 @@ import 'package:mobx/mobx.dart';
class NodeForm extends StatelessWidget {
NodeForm({
@required this.nodeViewModel,
@required this.formKey,
required this.nodeViewModel,
required this.formKey,
}) : _addressController = TextEditingController(),
_portController = TextEditingController(),
_loginController = TextEditingController(),

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/core/execution_state.dart';
import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/node.dart';
import 'package:cw_core/wallet_type.dart';
@ -11,7 +10,7 @@ class NodeCreateOrEditViewModel = NodeCreateOrEditViewModelBase
with _$NodeCreateOrEditViewModel;
abstract class NodeCreateOrEditViewModelBase with Store {
NodeCreateOrEditViewModelBase(this._nodeSource, this._wallet)
NodeCreateOrEditViewModelBase(this._nodeSource, this._walletType)
: state = InitialExecutionState(),
connectionState = InitialExecutionState(),
useSSL = false,
@ -49,8 +48,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
bool get isReady =>
address.isNotEmpty && port.isNotEmpty;
bool get hasAuthCredentials => _wallet.type == WalletType.monero ||
_wallet.type == WalletType.haven;
bool get hasAuthCredentials => _walletType == WalletType.monero ||
_walletType == WalletType.haven;
String get uri {
var uri = address;
@ -62,7 +61,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
return uri;
}
final WalletBase _wallet;
final WalletType _walletType;
final Box<Node> _nodeSource;
@action
@ -80,7 +79,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
try {
state = IsExecutingState();
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);
await _nodeSource.add(node);
state = ExecutedSuccessfullyState();
@ -94,7 +93,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
try {
connectionState = IsExecutingState();
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();
connectionState = ExecutedSuccessfullyState(payload: isAlive);
} catch (e) {

View file

@ -9,13 +9,13 @@ class PrivacySettingsViewModel = PrivacySettingsViewModelBase
with _$PrivacySettingsViewModel;
abstract class PrivacySettingsViewModelBase with Store {
PrivacySettingsViewModelBase(this.type) {
_disableFiat = false;
_disableExchange = false;
_addCustomNode = false;
PrivacySettingsViewModelBase(this.type)
: _disableFiat = false,
_disableExchange = false,
_addCustomNode = false {
settings = [
SwitcherListItem(
// TODO: replace when Disable Fiat PR is merged
title: "Disable Fiat API",
// title: S.current.disable_fiat,
value: () => _disableFiat,
@ -36,16 +36,16 @@ abstract class PrivacySettingsViewModelBase with Store {
];
}
List<SwitcherListItem> settings;
late List<SwitcherListItem> settings;
@observable
bool _disableFiat;
bool _disableFiat = false;
@observable
bool _disableExchange;
bool _disableExchange = false;
@observable
bool _addCustomNode;
bool _addCustomNode = false;
final WalletType type;