Merge pull request #406 from James-Sangalli/remove-unused-preference-class

Remove unused Preference class
pull/405/head
James Sangalli 7 years ago committed by GitHub
commit c925655e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      AlphaWallet.xcodeproj/project.pbxproj
  2. 7
      AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift
  3. 22
      AlphaWallet/Settings/Controllers/PreferencesController.swift
  4. 13
      AlphaWallet/Settings/Types/PreferenceOption.swift
  5. 39
      AlphaWallet/Settings/ViewControllers/PreferencesViewController.swift
  6. 14
      AlphaWalletTests/Factories/PreferencesController.swift
  7. 21
      AlphaWalletTests/Settings/Controllers/PreferencesControllerTests.swift

@ -428,12 +428,7 @@
76F1DC92CDEB695115DBC47C /* UniversalLinkHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1D96298E216CBFC3DD78B /* UniversalLinkHandlerTests.swift */; };
76F1DD10DF9A6C844E5F57D6 /* CreateRedeemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1D8877226D5DD086B135D /* CreateRedeemTests.swift */; };
76F1DEFF94F9A1F67BDF2735 /* UniversalLinkHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F1DCD54618349AC91C6DF8 /* UniversalLinkHandler.swift */; };
771A847320322F2500528D28 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847220322F2500528D28 /* PreferencesViewController.swift */; };
771A847520322FD700528D28 /* PreferencesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847420322FD700528D28 /* PreferencesViewModel.swift */; };
771A847A2032344D00528D28 /* PreferencesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A84792032344D00528D28 /* PreferencesController.swift */; };
771A847D2032409000528D28 /* PreferenceOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847C2032409000528D28 /* PreferenceOption.swift */; };
771A8480203240BB00528D28 /* PreferencesControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A847F203240BB00528D28 /* PreferencesControllerTests.swift */; };
771A84822032423800528D28 /* PreferencesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A84812032423800528D28 /* PreferencesController.swift */; };
771A8485203242B400528D28 /* InCoordinatorViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771A8484203242B400528D28 /* InCoordinatorViewModelTests.swift */; };
771AA94E1FF971CD00D25403 /* DappAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA94D1FF971CD00D25403 /* DappAction.swift */; };
771AA960200D5E8800D25403 /* PassphraseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 771AA95F200D5E8800D25403 /* PassphraseView.swift */; };
@ -953,12 +948,7 @@
76F1DCD54618349AC91C6DF8 /* UniversalLinkHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UniversalLinkHandler.swift; sourceTree = "<group>"; };
76F1DE8ADA3176D0277EDF20 /* OrderSigningTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderSigningTests.swift; sourceTree = "<group>"; };
76F1DF80932454E9F58B7830 /* CreateRedeem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateRedeem.swift; sourceTree = "<group>"; };
771A847220322F2500528D28 /* PreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = "<group>"; };
771A847420322FD700528D28 /* PreferencesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewModel.swift; sourceTree = "<group>"; };
771A84792032344D00528D28 /* PreferencesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesController.swift; sourceTree = "<group>"; };
771A847C2032409000528D28 /* PreferenceOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceOption.swift; sourceTree = "<group>"; };
771A847F203240BB00528D28 /* PreferencesControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesControllerTests.swift; sourceTree = "<group>"; };
771A84812032423800528D28 /* PreferencesController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesController.swift; sourceTree = "<group>"; };
771A8484203242B400528D28 /* InCoordinatorViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InCoordinatorViewModelTests.swift; sourceTree = "<group>"; };
771AA94D1FF971CD00D25403 /* DappAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DappAction.swift; sourceTree = "<group>"; };
771AA95F200D5E8800D25403 /* PassphraseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PassphraseView.swift; sourceTree = "<group>"; };
@ -1097,7 +1087,6 @@
290B2B681F92C0300053C83E /* Settings */ = {
isa = PBXGroup;
children = (
771A847E203240AB00528D28 /* Controllers */,
778EAF7B1FF10AE000C8E2AB /* Coordinators */,
290B2B691F92C0440053C83E /* ConfigTests.swift */,
290B2B6B1F92C35B0053C83E /* RPCServerTests.swift */,
@ -1777,7 +1766,6 @@
2996F1441F6C9875005C33AE /* Settings */ = {
isa = PBXGroup;
children = (
771A84782032343600528D28 /* Controllers */,
298542F11FBD593900CB5081 /* ViewModels */,
2977CAE41F7E0B69009682A0 /* Coordinators */,
29FC9BC71F83144D000209CD /* ViewControllers */,
@ -2162,7 +2150,6 @@
children = (
29F1C85C2003698A003780D8 /* WellDoneViewController.swift */,
7721A6CB202EFBC5004DB16C /* AddCustomNetworkViewController.swift */,
771A847220322F2500528D28 /* PreferencesViewController.swift */,
5E7C7AFE9AF9FE6B58C925D4 /* SettingsViewController.swift */,
5E7C74C0C1803DD17FE9EBA7 /* ServersViewController.swift */,
5E7C7BF09AD68C113D58344C /* LocalesViewController.swift */,
@ -2184,7 +2171,6 @@
294EC1D71FD7FBAB0065EB20 /* BiometryAuthenticationType.swift */,
739533961FEFF5FD0084AFAB /* Currency.swift */,
7721A6C7202EF81B004DB16C /* CustomRPC.swift */,
771A847C2032409000528D28 /* PreferenceOption.swift */,
5E7C7564AF453BAB0BDAAA57 /* SettingsAction.swift */,
5E7C7B29A9E728402D144C05 /* AppLocale.swift */,
);
@ -2233,7 +2219,6 @@
29F1C864200384FE003780D8 /* Wallet.swift */,
732E0F512022754600B39C1F /* FakeLockProtocol.swift */,
73CBC760202139FB00374666 /* FakeGetBalanceCoordinator(.swift */,
771A84812032423800528D28 /* PreferencesController.swift */,
442FCE526E2089CAE88D5602 /* FakeClaimOrderCoordinator.swift */,
);
path = Factories;
@ -2620,22 +2605,6 @@
path = Market;
sourceTree = "<group>";
};
771A84782032343600528D28 /* Controllers */ = {
isa = PBXGroup;
children = (
771A84792032344D00528D28 /* PreferencesController.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
771A847E203240AB00528D28 /* Controllers */ = {
isa = PBXGroup;
children = (
771A847F203240BB00528D28 /* PreferencesControllerTests.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
771A8483203242A600528D28 /* ViewModels */ = {
isa = PBXGroup;
children = (
@ -3459,7 +3428,6 @@
2912CCF91F6A830700C6CBE3 /* AppDelegate.swift in Sources */,
29A0E1851F706B8C00BAAAED /* String.swift in Sources */,
296AF9A71F736EC70058AF78 /* RPCServers.swift in Sources */,
771A847A2032344D00528D28 /* PreferencesController.swift in Sources */,
296AF9A91F737F6F0058AF78 /* SendRawTransactionRequest.swift in Sources */,
293112121FC4F48400966EEA /* ServiceProvider.swift in Sources */,
2912CD2F1F6A83A100C6CBE3 /* ImportWalletViewController.swift in Sources */,
@ -3483,7 +3451,6 @@
29F1C84C1FEC4F6F003780D8 /* TokensFooterView.swift in Sources */,
29F114F41FA8117C00114A29 /* SendCoordinator.swift in Sources */,
293B8B411F707F4600356286 /* TransactionViewModel.swift in Sources */,
771A847D2032409000528D28 /* PreferenceOption.swift in Sources */,
77B3BF4A2019247200EEC15A /* BrowserNavigationBar.swift in Sources */,
29BB94951F6FC54C009B09CC /* EthereumUnit.swift in Sources */,
29C70C712016C7780072E454 /* SentTransaction.swift in Sources */,
@ -3496,7 +3463,6 @@
291F52B71F6B870400B369AB /* CastError.swift in Sources */,
664D11A12007D59F0041A0B0 /* EstimateGasRequest.swift in Sources */,
299B5E2B1FCA9A640051361C /* ApproveERC20.swift in Sources */,
771A847320322F2500528D28 /* PreferencesViewController.swift in Sources */,
291794FB1F95DC2200539A30 /* Web3Swift.swift in Sources */,
29DBF2A31F9DBFF400327C60 /* BackupCoordinator.swift in Sources */,
290B2B611F9179880053C83E /* AccountViewModel.swift in Sources */,
@ -3679,7 +3645,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
771A8480203240BB00528D28 /* PreferencesControllerTests.swift in Sources */,
29F1C85620036887003780D8 /* AppTrackerTests.swift in Sources */,
29BDF19F1FEE51650023A45F /* GasLimitConfigurationTests.swift in Sources */,
290B2B6C1F92C35B0053C83E /* RPCServerTests.swift in Sources */,
@ -3728,7 +3693,6 @@
29E14FD51F7F470C00185568 /* TransactionsStorageTests.swift in Sources */,
61C359E22002AC9D0097B04D /* TransactionSigningTests.swift in Sources */,
299B5E381FCBCDF70051361C /* RequestViewModelTests.swift in Sources */,
771A84822032423800528D28 /* PreferencesController.swift in Sources */,
293E62731FA3165C00CB0A66 /* InitialWalletCreationCoordinatorTests.swift in Sources */,
29FF130A1F75F67200AFD326 /* Address.swift in Sources */,
73ED85A92034C42D00593BF3 /* StringFormatterTest.swift in Sources */,

@ -5,14 +5,9 @@ import Foundation
struct InCoordinatorViewModel {
let config: Config
let preferences: PreferencesController
init(
config: Config,
preferences: PreferencesController = PreferencesController()
) {
init(config: Config) {
self.config = config
self.preferences = preferences
}
var tokensAvailable: Bool {

@ -1,22 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
class PreferencesController {
let userDefaults: UserDefaults
init(
userDefaults: UserDefaults = .standard
) {
self.userDefaults = userDefaults
}
func set(value: Bool, for option: PreferenceOption) {
userDefaults.set(value, forKey: option.key)
}
func get(for option: PreferenceOption) -> Bool {
return userDefaults.bool(forKey: option.key)
}
}

@ -1,13 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
enum PreferenceOption {
case showTokensOnLaunch
var key: String {
switch self {
case .showTokensOnLaunch: return "showTokensOnLaunch"
}
}
}

@ -1,39 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import UIKit
import Eureka
class PreferencesViewController: FormViewController {
let viewModel = PreferencesViewModel()
let preferences: PreferencesController
init(
preferences: PreferencesController = PreferencesController()
) {
self.preferences = preferences
super.init(nibName: nil, bundle: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = viewModel.title
form +++ Section()
<<< SwitchRow {
$0.title = viewModel.showTokensTabTitle
$0.value = preferences.get(for: .showTokensOnLaunch)
}.onChange { [unowned self] row in
self.preferences.set(value: row.value ?? false, for: .showTokensOnLaunch)
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.coins()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

@ -1,14 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
@testable import Trust
extension PreferencesController {
static func make(
userDefaults: UserDefaults = .test
) -> PreferencesController {
return PreferencesController(
userDefaults: userDefaults
)
}
}

@ -1,21 +0,0 @@
// Copyright SIX DAY LLC. All rights reserved.
import XCTest
@testable import Trust
class PreferencesControllerTests: XCTestCase {
func testShowTokensOnStartDefault() {
let controller = PreferencesController(userDefaults: .test)
XCTAssertEqual(controller.get(for: .showTokensOnLaunch), false)
}
func testShowTokensOnStartDisable() {
let controller = PreferencesController(userDefaults: .test)
controller.set(value: false, for: .showTokensOnLaunch)
XCTAssertEqual(controller.get(for: .showTokensOnLaunch), false)
}
}
Loading…
Cancel
Save