mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-22 10:45:08 +00:00
tor updates
This commit is contained in:
parent
77fa3e06ae
commit
464b96fc92
3 changed files with 38 additions and 9 deletions
18
lib/di.dart
18
lib/di.dart
|
@ -98,6 +98,7 @@ import 'package:cake_wallet/view_model/settings/other_settings_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/security_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/settings/security_settings_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
|
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
|
||||||
|
import 'package:cake_wallet/view_model/settings/tor_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/settings/trocador_providers_view_model.dart';
|
import 'package:cake_wallet/view_model/settings/trocador_providers_view_model.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_list/wallet_edit_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_list/wallet_edit_view_model.dart';
|
||||||
|
@ -227,6 +228,7 @@ import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart';
|
||||||
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
import 'package:cake_wallet/entities/qr_view_data.dart';
|
import 'package:cake_wallet/entities/qr_view_data.dart';
|
||||||
|
import 'package:tor/tor.dart';
|
||||||
|
|
||||||
import 'buy/dfx/dfx_buy_provider.dart';
|
import 'buy/dfx/dfx_buy_provider.dart';
|
||||||
import 'core/totp_request_details.dart';
|
import 'core/totp_request_details.dart';
|
||||||
|
@ -294,6 +296,11 @@ Future<void> setup({
|
||||||
: ThemeList.darkTheme,
|
: ThemeList.darkTheme,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (settingsStore.shouldStartTorOnLaunch) {
|
||||||
|
await Tor.instance.enable();
|
||||||
|
await Tor.instance.start();
|
||||||
|
}
|
||||||
|
|
||||||
if (_isSetupFinished) {
|
if (_isSetupFinished) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -710,6 +717,8 @@ Future<void> setup({
|
||||||
|
|
||||||
getIt.registerFactory(() => TrocadorProvidersViewModel(getIt.get<SettingsStore>()));
|
getIt.registerFactory(() => TrocadorProvidersViewModel(getIt.get<SettingsStore>()));
|
||||||
|
|
||||||
|
getIt.registerFactory(() => TorViewModel(getIt.get<SettingsStore>()));
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
return OtherSettingsViewModel(getIt.get<SettingsStore>(), getIt.get<AppStore>().wallet!);
|
return OtherSettingsViewModel(getIt.get<SettingsStore>(), getIt.get<AppStore>().wallet!);
|
||||||
});
|
});
|
||||||
|
@ -799,8 +808,8 @@ Future<void> setup({
|
||||||
getIt.registerFactory<RobinhoodBuyProvider>(
|
getIt.registerFactory<RobinhoodBuyProvider>(
|
||||||
() => RobinhoodBuyProvider(wallet: getIt.get<AppStore>().wallet!));
|
() => RobinhoodBuyProvider(wallet: getIt.get<AppStore>().wallet!));
|
||||||
|
|
||||||
getIt.registerFactory<DFXBuyProvider>(
|
getIt
|
||||||
() => DFXBuyProvider(wallet: getIt.get<AppStore>().wallet!));
|
.registerFactory<DFXBuyProvider>(() => DFXBuyProvider(wallet: getIt.get<AppStore>().wallet!));
|
||||||
|
|
||||||
getIt.registerFactory<OnRamperBuyProvider>(() => OnRamperBuyProvider(
|
getIt.registerFactory<OnRamperBuyProvider>(() => OnRamperBuyProvider(
|
||||||
settingsStore: getIt.get<AppStore>().settingsStore,
|
settingsStore: getIt.get<AppStore>().settingsStore,
|
||||||
|
@ -1125,8 +1134,7 @@ Future<void> setup({
|
||||||
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
|
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
|
||||||
|
|
||||||
getIt.registerFactory(() => AnonPayApi(
|
getIt.registerFactory(() => AnonPayApi(
|
||||||
apiMode: getIt.get<SettingsStore>().exchangeStatus,
|
apiMode: getIt.get<SettingsStore>().exchangeStatus, wallet: getIt.get<AppStore>().wallet!));
|
||||||
wallet: getIt.get<AppStore>().wallet!));
|
|
||||||
|
|
||||||
getIt.registerFactory(() =>
|
getIt.registerFactory(() =>
|
||||||
DesktopWalletSelectionDropDown(getIt.get<WalletListViewModel>(), getIt.get<AuthService>()));
|
DesktopWalletSelectionDropDown(getIt.get<WalletListViewModel>(), getIt.get<AuthService>()));
|
||||||
|
@ -1188,7 +1196,7 @@ Future<void> setup({
|
||||||
() => WalletConnectConnectionsView(web3walletService: getIt.get<Web3WalletService>()));
|
() => WalletConnectConnectionsView(web3walletService: getIt.get<Web3WalletService>()));
|
||||||
|
|
||||||
getIt.registerFactory(() => NFTViewModel(appStore, getIt.get<BottomSheetService>()));
|
getIt.registerFactory(() => NFTViewModel(appStore, getIt.get<BottomSheetService>()));
|
||||||
getIt.registerFactory<TorPage>(() => TorPage(getIt.get<AppStore>()));
|
getIt.registerFactory<TorPage>(() => TorPage(getIt.get<AppStore>(), getIt.get<TorViewModel>()));
|
||||||
|
|
||||||
_isSetupFinished = true;
|
_isSetupFinished = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,28 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||||
import 'package:cake_wallet/store/app_store.dart';
|
import 'package:cake_wallet/store/app_store.dart';
|
||||||
|
import 'package:cake_wallet/view_model/settings/tor_view_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:tor/tor.dart';
|
import 'package:tor/tor.dart';
|
||||||
|
|
||||||
class TorPage extends BasePage {
|
class TorPage extends BasePage {
|
||||||
final AppStore appStore;
|
final AppStore appStore;
|
||||||
|
final TorViewModel model;
|
||||||
|
|
||||||
TorPage(this.appStore);
|
TorPage(this.appStore, this.model);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) {
|
Widget body(BuildContext context) {
|
||||||
return TorPageBody(appStore);
|
return TorPageBody(appStore, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TorPageBody extends StatefulWidget {
|
class TorPageBody extends StatefulWidget {
|
||||||
final AppStore appStore;
|
final AppStore appStore;
|
||||||
|
final TorViewModel model;
|
||||||
|
|
||||||
const TorPageBody(this.appStore, {Key? key}) : super(key: key);
|
const TorPageBody(this.appStore, this.model, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TorPageBody> createState() => _TorPageBodyState();
|
State<TorPageBody> createState() => _TorPageBodyState();
|
||||||
|
@ -87,7 +90,7 @@ class _TorPageBodyState extends State<TorPageBody> {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
widget.appStore.settingsStore.shouldStartTorOnLaunch = value;
|
widget.model.updateStartOnLaunch(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
18
lib/view_model/settings/tor_view_model.dart
Normal file
18
lib/view_model/settings/tor_view_model.dart
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
|
part 'tor_view_model.g.dart';
|
||||||
|
|
||||||
|
class TorViewModel = TorViewModelBase with _$TorViewModel;
|
||||||
|
|
||||||
|
abstract class TorViewModelBase with Store {
|
||||||
|
|
||||||
|
TorViewModelBase(this._settingsStore);
|
||||||
|
|
||||||
|
final SettingsStore _settingsStore;
|
||||||
|
|
||||||
|
@action
|
||||||
|
Future<void> updateStartOnLaunch(bool value) async {
|
||||||
|
_settingsStore.shouldStartTorOnLaunch = value;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue