From 6f7c9ca9db50ee34b361a341424590a3237f8825 Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Wed, 3 Oct 2018 16:09:34 +0800 Subject: [PATCH] Make private properties private, reorganize properties order --- AlphaWallet.xcodeproj/project.pbxproj | 8 --- .../HelpContentsViewController.swift | 2 +- .../Views/ContactUsBannerView.swift | 7 +-- .../AlphaWalletHelp/Views/HelpViewCell.swift | 6 +-- .../AssetDefinitionsOverridesViewCell.swift | 4 +- AlphaWallet/AssetDefinition/XMLHandler.swift | 9 ++-- .../Coordinators/BrowserCoordinator.swift | 50 +++++++++---------- .../Browser/Storage/HistoryStore.swift | 4 +- .../Browser/Types/BrowserURLParser.swift | 4 +- .../BookmarkViewController.swift | 9 ++-- .../BrowserViewController.swift | 31 ++++++------ .../HistoryViewController.swift | 7 ++- .../MasterBrowserViewController.swift | 7 ++- .../Browser/ViewModel/BookmarkViewModel.swift | 2 +- .../ViewModel/BookmarksViewModel.swift | 2 +- .../ViewModel/HistoriesViewModel.swift | 2 +- .../Browser/ViewModel/HistoryViewModel.swift | 2 +- .../Browser/Views/BrowserErrorView.swift | 9 ++-- .../Browser/Views/BrowserNavigationBar.swift | 14 +++--- .../Coordinators/CheckDeviceCoordinator.swift | 11 ++-- .../Core/Helpers/ScriptMessageProxy.swift | 2 +- .../Initializers/MigrationInitializer.swift | 4 +- .../SkipBackupFilesInitializer.swift | 2 +- .../Core/ViewModels/GasViewModel.swift | 8 +-- .../ViewModels/InCoordinatorViewModel.swift | 3 +- .../Coordinators/DepositCoordinator.swift | 4 +- .../CoinMarket/Types/CoinTicker.swift | 9 ++-- AlphaWallet/EtherClient/EtherKeystore.swift | 7 +-- .../EtherClient/TransactionSigning.swift | 2 +- .../Coordinators/BackupCoordinator.swift | 4 +- .../PromptBackupCoordinator.swift | 3 +- .../BackUpViewController.swift | 4 +- .../Export/ViewModels/BackupViewModel.swift | 2 +- AlphaWallet/Lock/Views/LockView.swift | 26 ++++++---- .../Lock/Views/PasscodeCharacterView.swift | 8 ++- AlphaWallet/Market/MarketQueueHandler.swift | 4 +- .../ImportMagicTokenViewController.swift | 30 +++++------ .../StatusViewController.swift | 13 ++--- .../ImportMagicTokenCardRowViewModel.swift | 2 +- .../StatusViewControllerViewModel.swift | 8 +-- .../MarketplaceViewController.swift | 2 +- .../Coordinators/ProtectionCoordinator.swift | 12 +++-- .../Coordinators/SplashCoordinator.swift | 6 ++- .../SplashViewController.swift | 1 + AlphaWallet/Protection/Views/SplashView.swift | 1 + .../Redeem/Helpers/RedeemEventListener.swift | 1 - .../Redeem/Helpers/SignatureHelper.swift | 1 - AlphaWallet/Redeem/Rest/EventsRest.swift | 1 - ...nCardQuantitySelectionViewController.swift | 16 +++--- .../RedeemTokenViewController.swift | 12 ++--- .../TokenCardRedemptionViewController.swift | 16 +++--- ...mTokenCardQuantitySelectionViewModel.swift | 5 +- .../ViewModels/RedeemTokenCardViewModel.swift | 5 +- .../TokenCardRedemptionViewModel.swift | 4 +- AlphaWallet/Rest/RestClient.swift | 1 - ...okensCardPriceQuantityViewController.swift | 48 +++++++++--------- .../GenerateSellMagicLinkViewController.swift | 23 +++++---- .../SellTokensCardViewController.swift | 10 ++-- ...llTokensCardExpiryDateViewController.swift | 44 ++++++++-------- ...PriceQuantityViewControllerViewModel.swift | 5 +- ...SellMagicLinkViewControllerViewModel.swift | 6 +-- ...sferMagicLinkViewControllerViewModel.swift | 4 +- .../ViewModels/SellTokensCardViewModel.swift | 5 +- ...ardExpiryDateViewControllerViewModel.swift | 6 +-- AlphaWallet/Sell/Views/DateEntryField.swift | 3 +- AlphaWallet/Sell/Views/TimeEntryField.swift | 3 +- .../AddCustomNetworkCoordinator.swift | 11 ++-- .../Coordinators/HelpUsCoordinator.swift | 6 +-- .../Coordinators/LocalesCoordinator.swift | 3 +- .../Coordinators/ServersCoordinator.swift | 3 +- .../Coordinators/SettingsCoordinator.swift | 8 +-- AlphaWallet/Settings/Types/Config.swift | 1 - .../Settings/Types/ConfigExplorer.swift | 3 +- .../AddCustomNetworkViewController.swift | 7 ++- .../LocalesViewController.swift | 11 ++-- .../PreferencesController.swift | 3 +- .../ServersViewController.swift | 11 ++-- .../SettingsViewController.swift | 12 +++-- .../WellDoneViewController.swift | 1 - .../AddCustomNetworkViewModel.swift | 1 - .../Settings/ViewModels/HelpUsViewModel.swift | 1 - .../Settings/ViewModels/LocaleViewModel.swift | 4 +- .../Settings/ViewModels/ServerViewModel.swift | 4 +- .../ViewModels/ServersViewModel.swift | 3 +- .../ViewModels/SettingsViewModel.swift | 18 ------- .../Views/AlphaWalletSettingsSwitchRow.swift | 2 +- .../Views/AlphaWalletSettingsTextRow.swift | 3 +- .../Settings/Views/LocaleViewCell.swift | 6 +-- .../Settings/Views/ServerViewCell.swift | 6 +-- .../Coordinators/ClaimOrderCoordinator.swift | 4 +- .../Coordinators/GetBalanceCoordinator.swift | 1 - .../Coordinators/GetDecimalsCoordinator.swift | 1 - .../Coordinators/GetNameCoordinator.swift | 1 - .../Coordinators/GetSymbolCoordinator.swift | 1 - .../Coordinators/TokensCoordinator.swift | 14 +++--- AlphaWallet/Tokens/Helpers/TokenAdaptor.swift | 3 +- AlphaWallet/Tokens/Types/Token.swift | 4 +- AlphaWallet/Tokens/Types/TokenBalance.swift | 1 - AlphaWallet/Tokens/Types/TokenHolder.swift | 22 +++++--- AlphaWallet/Tokens/Types/TokenObject.swift | 7 ++- .../Tokens/Types/TokensDataStore.swift | 1 - .../NewTokenViewController.swift | 26 +++++----- .../StaticHTMLViewController.swift | 3 +- .../TokensCardViewController.swift | 21 ++++---- .../TokensViewController.swift | 20 ++++---- .../BaseTokenCardTableViewCellViewModel.swift | 4 +- .../CryptoKittyCardRowViewModel.swift | 6 +-- .../Tokens/ViewModels/EthCurrencyHelper.swift | 3 +- .../EthTokenViewCellViewModel.swift | 2 +- .../ImportWalletHelpBubbleViewViewModel.swift | 3 ++ .../TokenListFormatRowViewModel.swift | 4 +- .../ViewModels/TokensCardViewModel.swift | 5 +- .../Tokens/ViewModels/TokensViewModel.swift | 29 +++++------ .../CryptoKittyCardRowView.swift | 10 ++-- .../Views/NonFungibleTokenViewCell.swift | 10 ++-- AlphaWallet/Tokens/Views/TextField.swift | 7 ++- AlphaWallet/Tokens/Views/TokenViewCell.swift | 10 ++-- .../TokensCardViewControllerTitleHeader.swift | 4 +- .../Coordinators/BalanceCoordinator.swift | 7 ++- .../Coordinators/TokensCardCoordinator.swift | 11 ++-- .../Coordinators/TransactionCoordinator.swift | 4 +- .../TransactionDataCoordinator.swift | 16 +++--- .../Storage/TransactionsStorage.swift | 5 +- .../TransactionViewController.swift | 8 ++- .../TransactionsViewController.swift | 35 +++++++------ .../ViewModels/BalanceTokenViewModel.swift | 1 - .../ViewModels/BalanceViewModel.swift | 7 ++- .../ViewModels/TransactionCellViewModel.swift | 1 - .../TransactionDetailsViewModel.swift | 1 - .../ViewModels/TransactionViewModel.swift | 1 - .../ViewModels/TransactionsViewModel.swift | 5 +- .../Views/TransactionHeaderView.swift | 2 - .../Views/TransactionViewCell.swift | 11 ++-- .../Views/TransactionsEmptyView.swift | 14 +++--- .../Views/TransactionsFooterView.swift | 1 - .../Controllers/TransactionConfigurator.swift | 23 +++++---- .../Coordinators/ConfirmCoordinator.swift | 11 ++-- .../Coordinators/PaymentCoordinator.swift | 13 +++-- .../Coordinators/RequestCoordinator.swift | 16 +++--- .../Coordinators/SendCoordinator.swift | 22 ++++---- .../SendTransactionCoordinator.swift | 7 ++- .../Coordinators/SignMessageCoordinator.swift | 8 ++- .../Coordinators/TransferNFTCoordinator.swift | 25 +++++----- ...eTokenCardTransferModeViewController.swift | 16 +++--- .../ConfigureTransactionViewController.swift | 26 +++++----- .../ConfirmPaymentViewController.swift | 16 +++--- ...erateTransferMagicLinkViewController.swift | 21 ++++---- .../RequestViewController.swift | 22 ++++---- .../ViewControllers/SendViewController.swift | 48 +++++++++--------- ...erTokensCardExpiryDateViewController.swift | 34 ++++++------- ...sCardQuantitySelectionViewController.swift | 16 +++--- ...nsCardViaWalletAddressViewController.swift | 19 +++---- .../TransferTokensCardViewController.swift | 12 ++--- ...dTransferModeViewControllerViewModel.swift | 1 - .../ConfigureTransactionViewModel.swift | 5 +- .../ConfirmPaymentDetailsViewModel.swift | 33 ++++++------ .../ViewModels/ConfirmPaymentViewModel.swift | 1 - .../ViewModels/RequestViewModel.swift | 5 +- .../Transfer/ViewModels/SendViewModel.swift | 6 +-- ...ardExpiryDateViewControllerViewModel.swift | 5 +- ...TokensCardQuantitySelectionViewModel.swift | 5 +- ...WalletAddressViewControllerViewModel.swift | 5 +- .../TransferTokensCardViewModel.swift | 5 +- .../Transfer/Views/SendHeaderView.swift | 26 +++++----- AlphaWallet/UI/AddressTextField.swift | 3 +- AlphaWallet/UI/BalanceTitleView.swift | 6 +-- AlphaWallet/UI/EmptyView.swift | 9 ++-- AlphaWallet/UI/ErrorView.swift | 11 ++-- AlphaWallet/UI/Form/EthereumAddressRule.swift | 1 - AlphaWallet/UI/LoadingView.swift | 6 +-- AlphaWallet/UI/NumberStepper.swift | 9 ++-- .../UI/ViewModels/TokenCardRowViewModel.swift | 2 +- AlphaWallet/Vendors/Web3Swift/Web3Swift.swift | 4 +- .../InitialWalletCreationCoordinator.swift | 4 +- .../Coordinators/WalletCoordinator.swift | 6 +-- .../EnterPasswordCoordinator.swift | 11 ++-- .../EnterPasswordViewController.swift | 8 +-- .../ImportWalletViewController.swift | 29 +++++------ .../PassphraseViewController.swift | 5 +- .../Wallet/Views/ImportWalletTabBar.swift | 13 ++--- AlphaWallet/Wallet/Views/PassphraseView.swift | 6 +-- .../WelcomeViewController.swift | 17 +++---- .../ViewModels/OnboardingPageViewModel.swift | 4 +- .../Welcome/Views/OnboardingPage.swift | 6 +-- 184 files changed, 822 insertions(+), 851 deletions(-) diff --git a/AlphaWallet.xcodeproj/project.pbxproj b/AlphaWallet.xcodeproj/project.pbxproj index 0df3f1e19..db58bc267 100644 --- a/AlphaWallet.xcodeproj/project.pbxproj +++ b/AlphaWallet.xcodeproj/project.pbxproj @@ -1899,7 +1899,6 @@ isa = PBXGroup; children = ( 29E6E06F1FEA12910079265A /* TransactionConfigurator.swift */, - 5E7C7A5A98CE71365B6E80FF /* Views */, ); path = Controllers; sourceTree = ""; @@ -2630,13 +2629,6 @@ path = ViewModels; sourceTree = ""; }; - 5E7C7A5A98CE71365B6E80FF /* Views */ = { - isa = PBXGroup; - children = ( - ); - path = Views; - sourceTree = ""; - }; 5E7C7A968681D718C8A32B47 /* Commands */ = { isa = PBXGroup; children = ( diff --git a/AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift b/AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift index eaa7fb4d2..1ba0232be 100644 --- a/AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift +++ b/AlphaWallet/AlphaWalletHelp/ViewControllers/HelpContentsViewController.swift @@ -3,7 +3,7 @@ import UIKit class HelpContentsViewController: StaticHTMLViewController { - let banner = ContactUsBannerView() + private let banner = ContactUsBannerView() override init(delegate: StaticHTMLViewControllerDelegate?) { super.init(delegate: delegate) diff --git a/AlphaWallet/AlphaWalletHelp/Views/ContactUsBannerView.swift b/AlphaWallet/AlphaWalletHelp/Views/ContactUsBannerView.swift index 4563d74e9..48ad41402 100644 --- a/AlphaWallet/AlphaWalletHelp/Views/ContactUsBannerView.swift +++ b/AlphaWallet/AlphaWalletHelp/Views/ContactUsBannerView.swift @@ -8,10 +8,11 @@ protocol ContactUsBannerViewDelegate: class { } class ContactUsBannerView: UIView { + private let button = UIButton(type: .system) + private let imageView = UIImageView() + private let label = UILabel() + weak var delegate: ContactUsBannerViewDelegate? - let button = UIButton(type: .system) - let imageView = UIImageView() - let label = UILabel() let bannerHeight = CGFloat(60) override init(frame: CGRect) { diff --git a/AlphaWallet/AlphaWalletHelp/Views/HelpViewCell.swift b/AlphaWallet/AlphaWalletHelp/Views/HelpViewCell.swift index bf481e781..73edbec00 100644 --- a/AlphaWallet/AlphaWalletHelp/Views/HelpViewCell.swift +++ b/AlphaWallet/AlphaWalletHelp/Views/HelpViewCell.swift @@ -5,9 +5,9 @@ import UIKit class HelpViewCell: UITableViewCell { static let identifier = "HelpViewCell" - let background = UIView() - let titleLabel = UILabel() - let iconImageView = UIImageView() + private let background = UIView() + private let titleLabel = UILabel() + private let iconImageView = UIImageView() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/AssetDefinition/Views/AssetDefinitionsOverridesViewCell.swift b/AlphaWallet/AssetDefinition/Views/AssetDefinitionsOverridesViewCell.swift index 4c5442aa7..08dd809ac 100644 --- a/AlphaWallet/AssetDefinition/Views/AssetDefinitionsOverridesViewCell.swift +++ b/AlphaWallet/AssetDefinition/Views/AssetDefinitionsOverridesViewCell.swift @@ -5,8 +5,8 @@ import UIKit class AssetDefinitionsOverridesViewCell: UITableViewCell { static let identifier = "AssetDefinitionsOverridesViewCell" - let background = UIView() - let titleLabel = UILabel() + private let background = UIView() + private let titleLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/AssetDefinition/XMLHandler.swift b/AlphaWallet/AssetDefinition/XMLHandler.swift index e1ef7e16b..fc5d5080a 100644 --- a/AlphaWallet/AssetDefinition/XMLHandler.swift +++ b/AlphaWallet/AssetDefinition/XMLHandler.swift @@ -24,11 +24,10 @@ enum TitlecaseOrNot { private class PrivateXMLHandler { private let xml: XML.Accessor - let contractAddress: String - lazy var contract = xml["token"]["contract"].getElement(attributeName: "type", attributeValue: "holding", fallbackToFirst: true) - lazy var fields = extractFields() + private let contractAddress: String + private lazy var contract = xml["token"]["contract"].getElement(attributeName: "type", attributeValue: "holding", fallbackToFirst: true) + private lazy var fields = extractFields() private let isOfficial: Bool - let hasAssetDefinition: Bool private let signatureNamespace: String private var signatureNamespacePrefix: String { if signatureNamespace.isEmpty { @@ -38,6 +37,8 @@ private class PrivateXMLHandler { } } + let hasAssetDefinition: Bool + init(contract: String) { contractAddress = contract.add0x.lowercased() let assetDefinitionStore = AssetDefinitionStore() diff --git a/AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift b/AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift index fc6ebb39a..8de7e3079 100644 --- a/AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift +++ b/AlphaWallet/Browser/Coordinators/BrowserCoordinator.swift @@ -13,35 +13,22 @@ protocol BrowserCoordinatorDelegate: class { } final class BrowserCoordinator: NSObject, Coordinator { - var coordinators: [Coordinator] = [] - let session: WalletSession - let keystore: Keystore - let navigationController: NavigationController + private let session: WalletSession + private let keystore: Keystore - lazy var bookmarksViewController: BookmarkViewController = { + private lazy var bookmarksViewController: BookmarkViewController = { let controller = BookmarkViewController(bookmarksStore: bookmarksStore) controller.delegate = self return controller }() - lazy var historyViewController: HistoryViewController = { + private lazy var historyViewController: HistoryViewController = { let controller = HistoryViewController(store: historyStore) controller.delegate = self return controller }() - lazy var rootViewController: MasterBrowserViewController = { - let controller = MasterBrowserViewController( - bookmarksViewController: bookmarksViewController, - historyViewController: historyViewController, - browserViewController: browserViewController, - type: .browser - ) - controller.delegate = self - return controller - }() - - lazy var browserViewController: BrowserViewController = { + private lazy var browserViewController: BrowserViewController = { let controller = BrowserViewController(account: session.account, config: session.config, server: server) controller.delegate = self controller.webView.uiDelegate = self @@ -54,26 +41,39 @@ final class BrowserCoordinator: NSObject, Coordinator { private lazy var historyStore: HistoryStore = { return HistoryStore(realm: sharedRealm) }() - lazy var preferences: PreferencesController = { + private lazy var preferences: PreferencesController = { return PreferencesController() }() - var urlParser: BrowserURLParser { + private var urlParser: BrowserURLParser { let engine = SearchEngine(rawValue: preferences.get(for: .browserSearchEngine)) ?? .default return BrowserURLParser(engine: engine) } - var server: RPCServer { + private var server: RPCServer { return session.config.server } - - weak var delegate: BrowserCoordinatorDelegate? - - var enableToolbar: Bool = true { + private var enableToolbar: Bool = true { didSet { navigationController.isToolbarHidden = !enableToolbar } } + var coordinators: [Coordinator] = [] + let navigationController: NavigationController + + lazy var rootViewController: MasterBrowserViewController = { + let controller = MasterBrowserViewController( + bookmarksViewController: bookmarksViewController, + historyViewController: historyViewController, + browserViewController: browserViewController, + type: .browser + ) + controller.delegate = self + return controller + }() + + weak var delegate: BrowserCoordinatorDelegate? + init( session: WalletSession, keystore: Keystore, diff --git a/AlphaWallet/Browser/Storage/HistoryStore.swift b/AlphaWallet/Browser/Storage/HistoryStore.swift index b4af5ae1e..b5da4f28e 100644 --- a/AlphaWallet/Browser/Storage/HistoryStore.swift +++ b/AlphaWallet/Browser/Storage/HistoryStore.swift @@ -4,13 +4,13 @@ import Foundation import RealmSwift final class HistoryStore { + private let realm: Realm + var histories: Results { return realm.objects(History.self) .sorted(byKeyPath: "createdAt", ascending: false) } - let realm: Realm - init(realm: Realm) { self.realm = realm } diff --git a/AlphaWallet/Browser/Types/BrowserURLParser.swift b/AlphaWallet/Browser/Types/BrowserURLParser.swift index e935e4556..d677abf2f 100644 --- a/AlphaWallet/Browser/Types/BrowserURLParser.swift +++ b/AlphaWallet/Browser/Types/BrowserURLParser.swift @@ -3,8 +3,8 @@ import Foundation final class BrowserURLParser { - let urlRegEx = try! NSRegularExpression(pattern: "^(http(s)?://)?[a-z0-9-_]+(\\.[a-z0-9-_]+)+(/)?", options: .caseInsensitive) - let validSchemes = ["http", "https"] + private let urlRegEx = try! NSRegularExpression(pattern: "^(http(s)?://)?[a-z0-9-_]+(\\.[a-z0-9-_]+)+(/)?", options: .caseInsensitive) + private let validSchemes = ["http", "https"] let engine: SearchEngine init( diff --git a/AlphaWallet/Browser/ViewControllers/BookmarkViewController.swift b/AlphaWallet/Browser/ViewControllers/BookmarkViewController.swift index 9d8c19753..eb7a798e3 100644 --- a/AlphaWallet/Browser/ViewControllers/BookmarkViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/BookmarkViewController.swift @@ -9,19 +9,16 @@ protocol BookmarkViewControllerDelegate: class { } final class BookmarkViewController: UIViewController { - - let tableView = UITableView(frame: .zero, style: .plain) + private let tableView = UITableView(frame: .zero, style: .plain) + private let bookmarksStore: BookmarksStore weak var delegate: BookmarkViewControllerDelegate? - private let bookmarksStore: BookmarksStore lazy var viewModel: BookmarksViewModel = { return BookmarksViewModel(bookmarksStore: bookmarksStore) }() - init( - bookmarksStore: BookmarksStore - ) { + init(bookmarksStore: BookmarksStore) { self.bookmarksStore = bookmarksStore super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift b/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift index 3c369f3dd..ec8a5c23b 100644 --- a/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/BrowserViewController.swift @@ -22,10 +22,9 @@ protocol BrowserViewControllerDelegate: class { } final class BrowserViewController: UIViewController { - private var myContext = 0 - let account: Wallet - let sessionConfig: Config + private let account: Wallet + private let sessionConfig: Config private struct Keys { static let estimatedProgress = "estimatedProgress" @@ -38,6 +37,19 @@ final class BrowserViewController: UIViewController { return Keys.ClientName + "/" + (Bundle.main.versionNumber ?? "") }() + private lazy var errorView: BrowserErrorView = { + let errorView = BrowserErrorView() + errorView.translatesAutoresizingMaskIntoConstraints = false + errorView.delegate = self + return errorView + }() + + private var browserNavBar: BrowserNavigationBar? { + return navigationController?.navigationBar as? BrowserNavigationBar + } + + weak var delegate: BrowserViewControllerDelegate? + lazy var webView: WKWebView = { let webView = WKWebView( frame: .zero, @@ -52,19 +64,6 @@ final class BrowserViewController: UIViewController { return webView }() - lazy var errorView: BrowserErrorView = { - let errorView = BrowserErrorView() - errorView.translatesAutoresizingMaskIntoConstraints = false - errorView.delegate = self - return errorView - }() - - weak var delegate: BrowserViewControllerDelegate? - - private var browserNavBar: BrowserNavigationBar? { - return navigationController?.navigationBar as? BrowserNavigationBar - } - lazy var progressView: UIProgressView = { let progressView = UIProgressView(progressViewStyle: .default) progressView.translatesAutoresizingMaskIntoConstraints = false diff --git a/AlphaWallet/Browser/ViewControllers/HistoryViewController.swift b/AlphaWallet/Browser/ViewControllers/HistoryViewController.swift index 2710060cf..684a84982 100644 --- a/AlphaWallet/Browser/ViewControllers/HistoryViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/HistoryViewController.swift @@ -8,10 +8,9 @@ protocol HistoryViewControllerDelegate: class { } final class HistoryViewController: UIViewController { - - let store: HistoryStore - let tableView = UITableView(frame: .zero, style: .plain) - lazy var viewModel: HistoriesViewModel = { + private let store: HistoryStore + private let tableView = UITableView(frame: .zero, style: .plain) + private lazy var viewModel: HistoriesViewModel = { return HistoriesViewModel(store: store) }() diff --git a/AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift b/AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift index bff2a7a1f..e0b02cbf3 100644 --- a/AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift +++ b/AlphaWallet/Browser/ViewControllers/MasterBrowserViewController.swift @@ -19,7 +19,6 @@ enum BookmarksViewType: Int { } final class MasterBrowserViewController: UIViewController { - private lazy var segmentController: UISegmentedControl = { let items = [ R.string.localizable.new(), @@ -41,10 +40,10 @@ final class MasterBrowserViewController: UIViewController { return button }() - weak var delegate: MasterBrowserViewControllerDelegate? + private let bookmarksViewController: BookmarkViewController + private let historyViewController: HistoryViewController - let bookmarksViewController: BookmarkViewController - let historyViewController: HistoryViewController + weak var delegate: MasterBrowserViewControllerDelegate? let browserViewController: BrowserViewController init( diff --git a/AlphaWallet/Browser/ViewModel/BookmarkViewModel.swift b/AlphaWallet/Browser/ViewModel/BookmarkViewModel.swift index 9a2fabf4e..d803f6b1f 100644 --- a/AlphaWallet/Browser/ViewModel/BookmarkViewModel.swift +++ b/AlphaWallet/Browser/ViewModel/BookmarkViewModel.swift @@ -4,8 +4,8 @@ import Foundation import UIKit struct BookmarkViewModel: URLViewModel { + private let bookmark: Bookmark - let bookmark: Bookmark init( bookmark: Bookmark ) { diff --git a/AlphaWallet/Browser/ViewModel/BookmarksViewModel.swift b/AlphaWallet/Browser/ViewModel/BookmarksViewModel.swift index 4a6b0b0cd..2a4a36060 100644 --- a/AlphaWallet/Browser/ViewModel/BookmarksViewModel.swift +++ b/AlphaWallet/Browser/ViewModel/BookmarksViewModel.swift @@ -5,7 +5,7 @@ import RealmSwift struct BookmarksViewModel { - let bookmarksStore: BookmarksStore + private let bookmarksStore: BookmarksStore init( bookmarksStore: BookmarksStore diff --git a/AlphaWallet/Browser/ViewModel/HistoriesViewModel.swift b/AlphaWallet/Browser/ViewModel/HistoriesViewModel.swift index 61d97c6b1..1605ea671 100644 --- a/AlphaWallet/Browser/ViewModel/HistoriesViewModel.swift +++ b/AlphaWallet/Browser/ViewModel/HistoriesViewModel.swift @@ -4,7 +4,7 @@ import Foundation struct HistoriesViewModel { - let store: HistoryStore + private let store: HistoryStore init( store: HistoryStore diff --git a/AlphaWallet/Browser/ViewModel/HistoryViewModel.swift b/AlphaWallet/Browser/ViewModel/HistoryViewModel.swift index 9f1eaccc2..8e6d39c2a 100644 --- a/AlphaWallet/Browser/ViewModel/HistoryViewModel.swift +++ b/AlphaWallet/Browser/ViewModel/HistoryViewModel.swift @@ -5,7 +5,7 @@ import UIKit struct HistoryViewModel: URLViewModel { - let history: History + private let history: History init( history: History diff --git a/AlphaWallet/Browser/Views/BrowserErrorView.swift b/AlphaWallet/Browser/Views/BrowserErrorView.swift index 5ce5b200e..a2229dfba 100644 --- a/AlphaWallet/Browser/Views/BrowserErrorView.swift +++ b/AlphaWallet/Browser/Views/BrowserErrorView.swift @@ -7,14 +7,11 @@ protocol BrowserErrorViewDelegate: class { } final class BrowserErrorView: UIView { - - weak var delegate: BrowserErrorViewDelegate? - private let topMargin: CGFloat = 120 private let leftMargin: CGFloat = 40 private let buttonTopMargin: CGFloat = 6 - lazy var textLabel: UILabel = { + private lazy var textLabel: UILabel = { let label = UILabel() label.numberOfLines = 0 label.textColor = Colors.gray @@ -23,7 +20,7 @@ final class BrowserErrorView: UIView { return label }() - lazy var reloadButton: Button = { + private lazy var reloadButton: Button = { let button = Button(size: .normal, style: .borderless) button.addTarget(self, action: #selector(reloadTapped), for: .touchUpInside) button.setTitle(R.string.localizable.browserReloadButtonTitle(), for: .normal) @@ -32,6 +29,8 @@ final class BrowserErrorView: UIView { return button }() + weak var delegate: BrowserErrorViewDelegate? + init() { super.init(frame: CGRect.zero) finishInit() diff --git a/AlphaWallet/Browser/Views/BrowserNavigationBar.swift b/AlphaWallet/Browser/Views/BrowserNavigationBar.swift index ff8a12970..80699d027 100644 --- a/AlphaWallet/Browser/Views/BrowserNavigationBar.swift +++ b/AlphaWallet/Browser/Views/BrowserNavigationBar.swift @@ -7,19 +7,19 @@ protocol BrowserNavigationBarDelegate: class { } final class BrowserNavigationBar: UINavigationBar { - - let textField = UITextField() - let moreButton = UIButton() - let closeButton = UIButton() - let homeButton = UIButton() - let backButton = UIButton() - weak var browserDelegate: BrowserNavigationBarDelegate? + private let moreButton = UIButton() + private let homeButton = UIButton() private struct Layout { static let width: CGFloat = 34 static let moreButtonWidth: CGFloat = 24 } + let textField = UITextField() + let closeButton = UIButton() + let backButton = UIButton() + weak var browserDelegate: BrowserNavigationBarDelegate? + override init(frame: CGRect) { super.init(frame: frame) diff --git a/AlphaWallet/Core/Coordinators/CheckDeviceCoordinator.swift b/AlphaWallet/Core/Coordinators/CheckDeviceCoordinator.swift index 647a7ddad..d09ecedda 100644 --- a/AlphaWallet/Core/Coordinators/CheckDeviceCoordinator.swift +++ b/AlphaWallet/Core/Coordinators/CheckDeviceCoordinator.swift @@ -4,13 +4,10 @@ import Foundation import UIKit class CheckDeviceCoordinator: Coordinator { - var coordinators: [Coordinator] = [] - - let navigationController: UINavigationController - - let jailbreakChecker: JailbreakChecker + private let navigationController: UINavigationController + private let jailbreakChecker: JailbreakChecker - lazy var alertViewController: UIAlertController = { + private lazy var alertViewController: UIAlertController = { let controller = UIAlertController( title: R.string.localizable.appDeviceJailbreakTitle(), message: R.string.localizable.appDeviceJailbreakDescription(), @@ -22,6 +19,8 @@ class CheckDeviceCoordinator: Coordinator { return controller }() + var coordinators: [Coordinator] = [] + init( navigationController: UINavigationController, jailbreakChecker: JailbreakChecker diff --git a/AlphaWallet/Core/Helpers/ScriptMessageProxy.swift b/AlphaWallet/Core/Helpers/ScriptMessageProxy.swift index a989fe532..0f1885e85 100644 --- a/AlphaWallet/Core/Helpers/ScriptMessageProxy.swift +++ b/AlphaWallet/Core/Helpers/ScriptMessageProxy.swift @@ -6,7 +6,7 @@ import WebKit ///Reason for this class: https://stackoverflow.com/questions/26383031/wkwebview-causes-my-view-controller-to-leak final class ScriptMessageProxy: NSObject, WKScriptMessageHandler { - weak var delegate: WKScriptMessageHandler? + private weak var delegate: WKScriptMessageHandler? init(delegate: WKScriptMessageHandler) { self.delegate = delegate diff --git a/AlphaWallet/Core/Initializers/MigrationInitializer.swift b/AlphaWallet/Core/Initializers/MigrationInitializer.swift index 886cbb5de..bda572d3e 100644 --- a/AlphaWallet/Core/Initializers/MigrationInitializer.swift +++ b/AlphaWallet/Core/Initializers/MigrationInitializer.swift @@ -5,9 +5,9 @@ import RealmSwift import TrustKeystore class MigrationInitializer: Initializer { + private let account: Wallet + private let chainID: Int - let account: Wallet - let chainID: Int lazy var config: Realm.Configuration = { return RealmConfiguration.configuration(for: account, chainID: chainID) }() diff --git a/AlphaWallet/Core/Initializers/SkipBackupFilesInitializer.swift b/AlphaWallet/Core/Initializers/SkipBackupFilesInitializer.swift index d2e3a24c0..4ec001c47 100644 --- a/AlphaWallet/Core/Initializers/SkipBackupFilesInitializer.swift +++ b/AlphaWallet/Core/Initializers/SkipBackupFilesInitializer.swift @@ -4,7 +4,7 @@ import Foundation struct SkipBackupFilesInitializer: Initializer { - let urls: [URL] + private let urls: [URL] init(paths: [URL]) { self.urls = paths diff --git a/AlphaWallet/Core/ViewModels/GasViewModel.swift b/AlphaWallet/Core/ViewModels/GasViewModel.swift index 44ec0b739..ae036d626 100644 --- a/AlphaWallet/Core/ViewModels/GasViewModel.swift +++ b/AlphaWallet/Core/ViewModels/GasViewModel.swift @@ -4,10 +4,10 @@ import Foundation import BigInt struct GasViewModel { - let fee: BigInt - let symbol: String - let currencyRate: CurrencyRate? - let formatter: EtherNumberFormatter + private let fee: BigInt + private let symbol: String + private let currencyRate: CurrencyRate? + private let formatter: EtherNumberFormatter init( fee: BigInt, diff --git a/AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift b/AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift index 9b67df560..40a3f664b 100644 --- a/AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift +++ b/AlphaWallet/Core/ViewModels/InCoordinatorViewModel.swift @@ -3,8 +3,7 @@ import Foundation struct InCoordinatorViewModel { - - let config: Config + private let config: Config init(config: Config) { self.config = config diff --git a/AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift b/AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift index 9395bae44..77d75934d 100644 --- a/AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift +++ b/AlphaWallet/Deposit/Coordinators/DepositCoordinator.swift @@ -8,11 +8,11 @@ protocol DepositCoordinatorDelegate: class, CanOpenURL { } class DepositCoordinator: Coordinator { + private let account: Wallet + private weak var delegate: DepositCoordinatorDelegate? let navigationController: UINavigationController - let account: Wallet var coordinators: [Coordinator] = [] - weak var delegate: DepositCoordinatorDelegate? init( navigationController: UINavigationController, diff --git a/AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift b/AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift index 9031d3b4c..655c59e2f 100644 --- a/AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift +++ b/AlphaWallet/EtherClient/CoinMarket/Types/CoinTicker.swift @@ -4,12 +4,13 @@ import Foundation import RealmSwift struct CoinTicker: Codable { - let id: String - let symbol: String - var price_usd: String + private let id: String + private let symbol: String + private let image: String = "" + + let price_usd: String let percent_change_24h: String let contract: String = Constants.nullAddress - let image: String = "" lazy var rate: CurrencyRate = { CurrencyRate( diff --git a/AlphaWallet/EtherClient/EtherKeystore.swift b/AlphaWallet/EtherClient/EtherKeystore.swift index c6ab4da4a..b7af4ab93 100644 --- a/AlphaWallet/EtherClient/EtherKeystore.swift +++ b/AlphaWallet/EtherClient/EtherKeystore.swift @@ -12,17 +12,18 @@ enum EtherKeystoreError: LocalizedError { } open class EtherKeystore: Keystore { - struct Keys { + private struct Keys { static let recentlyUsedAddress: String = "recentlyUsedAddress" static let watchAddresses = "watchAddresses" } private let keychain: KeychainSwift private let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] - let keyStore: KeyStore + private let keyStore: KeyStore private let defaultKeychainAccess: KeychainSwiftAccessOptions = .accessibleWhenUnlockedThisDeviceOnly + private let userDefaults: UserDefaults + let keystoreDirectory: URL - let userDefaults: UserDefaults public init( keychain: KeychainSwift = KeychainSwift(keyPrefix: Constants.keychainKeyPrefix), diff --git a/AlphaWallet/EtherClient/TransactionSigning.swift b/AlphaWallet/EtherClient/TransactionSigning.swift index aa15b8112..91462bba8 100644 --- a/AlphaWallet/EtherClient/TransactionSigning.swift +++ b/AlphaWallet/EtherClient/TransactionSigning.swift @@ -9,7 +9,7 @@ protocol Signer { } struct EIP155Signer: Signer { - let chainId: BigInt + private let chainId: BigInt init(chainId: BigInt) { self.chainId = chainId diff --git a/AlphaWallet/Export/Coordinators/BackupCoordinator.swift b/AlphaWallet/Export/Coordinators/BackupCoordinator.swift index 3fe0e8193..8c346b707 100644 --- a/AlphaWallet/Export/Coordinators/BackupCoordinator.swift +++ b/AlphaWallet/Export/Coordinators/BackupCoordinator.swift @@ -12,11 +12,11 @@ protocol BackupCoordinatorDelegate: class { } class BackupCoordinator: Coordinator { + private let keystore: Keystore + private let account: Account let navigationController: UINavigationController weak var delegate: BackupCoordinatorDelegate? - let keystore: Keystore - let account: Account var coordinators: [Coordinator] = [] init( diff --git a/AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift b/AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift index 8752a4f15..cb68fdc5e 100644 --- a/AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift +++ b/AlphaWallet/Export/Coordinators/PromptBackupCoordinator.swift @@ -9,9 +9,10 @@ protocol PromptBackupCoordinatorDelegate: class { ///We allow user to switch wallets, so it's important to know which wallet we are prompting for. It might not be the current wallet class PromptBackupCoordinator: Coordinator { + private var walletAddress: String + var coordinators: [Coordinator] = [] weak var delegate: PromptBackupCoordinatorDelegate? - var walletAddress: String init(walletAddress: String) { self.walletAddress = walletAddress diff --git a/AlphaWallet/Export/ViewControllers/BackUpViewController.swift b/AlphaWallet/Export/ViewControllers/BackUpViewController.swift index 38d12ff46..aaf616008 100644 --- a/AlphaWallet/Export/ViewControllers/BackUpViewController.swift +++ b/AlphaWallet/Export/ViewControllers/BackUpViewController.swift @@ -9,10 +9,10 @@ protocol BackupViewControllerDelegate: class { } class BackupViewController: UIViewController { + private let account: Account + private let viewModel = BackupViewModel() - let account: Account weak var delegate: BackupViewControllerDelegate? - let viewModel = BackupViewModel() init(account: Account) { self.account = account diff --git a/AlphaWallet/Export/ViewModels/BackupViewModel.swift b/AlphaWallet/Export/ViewModels/BackupViewModel.swift index 48295ef55..c289206bc 100644 --- a/AlphaWallet/Export/ViewModels/BackupViewModel.swift +++ b/AlphaWallet/Export/ViewModels/BackupViewModel.swift @@ -4,7 +4,7 @@ import Foundation struct BackupViewModel { - let config: Config + private let config: Config init( config: Config = Config() diff --git a/AlphaWallet/Lock/Views/LockView.swift b/AlphaWallet/Lock/Views/LockView.swift index 4b92b7e05..5fd5c43a6 100644 --- a/AlphaWallet/Lock/Views/LockView.swift +++ b/AlphaWallet/Lock/Views/LockView.swift @@ -4,19 +4,12 @@ import UIKit class LockView: UIView { - var characterView = UIStackView() + private var characterView = UIStackView() + private var model: LockViewModel + var lockTitle = UILabel() - var model: LockViewModel var characters: [PasscodeCharacterView]! - init(_ model: LockViewModel) { - self.model = model - super.init(frame: CGRect.zero) - self.characters = passcodeCharacters() - configCharacterView() - configLabel() - addUiElements() - applyConstraints() - } + private func configCharacterView() { characterView = UIStackView(arrangedSubviews: characters) characterView.axis = .horizontal @@ -54,6 +47,17 @@ class LockView: UIView { } return characters } + + init(_ model: LockViewModel) { + self.model = model + super.init(frame: CGRect.zero) + self.characters = passcodeCharacters() + configCharacterView() + configLabel() + addUiElements() + applyConstraints() + } + func shake() { let keypath = "position" let animation = CABasicAnimation(keyPath: keypath) diff --git a/AlphaWallet/Lock/Views/PasscodeCharacterView.swift b/AlphaWallet/Lock/Views/PasscodeCharacterView.swift index f598dc0c4..56543162a 100644 --- a/AlphaWallet/Lock/Views/PasscodeCharacterView.swift +++ b/AlphaWallet/Lock/Views/PasscodeCharacterView.swift @@ -4,12 +4,14 @@ import UIKit class PasscodeCharacterView: UIView { - var isEmpty = true + private var isEmpty = true private var circle: CAShapeLayer? private var hyphen: CAShapeLayer? + override func layoutSubviews() { commonInit() } + private func commonInit() { isEmpty = true backgroundColor = UIColor.clear @@ -17,10 +19,12 @@ class PasscodeCharacterView: UIView { drawHyphen() redraw() } + private func redraw() { circle?.isHidden = isEmpty hyphen?.isHidden = !isEmpty } + private func drawCircle() { let borderWidth: CGFloat = 2 let radius: CGFloat = bounds.width / 2 - borderWidth @@ -33,6 +37,7 @@ class PasscodeCharacterView: UIView { layer.addSublayer(circle) self.circle = circle } + private func drawHyphen() { let horizontalMargin: CGFloat = 2 let hyphenHeight: CGFloat = bounds.height / 7 @@ -53,6 +58,7 @@ class PasscodeCharacterView: UIView { layer.addSublayer(hyphen) self.hyphen = hyphen } + func setEmpty(_ isEmpty: Bool) { if self.isEmpty != isEmpty { self.isEmpty = isEmpty diff --git a/AlphaWallet/Market/MarketQueueHandler.swift b/AlphaWallet/Market/MarketQueueHandler.swift index 7d081b028..fdef0121a 100644 --- a/AlphaWallet/Market/MarketQueueHandler.swift +++ b/AlphaWallet/Market/MarketQueueHandler.swift @@ -22,8 +22,8 @@ import BigInt public class MarketQueueHandler { - public let baseURL = "https://482kdh4npg.execute-api.ap-southeast-1.amazonaws.com/dev/" - public let contractAddress = "bC9a1026A4BC6F0BA8Bbe486d1D09dA5732B39e4".lowercased() + private let baseURL = "https://482kdh4npg.execute-api.ap-southeast-1.amazonaws.com/dev/" + private let contractAddress = "bC9a1026A4BC6F0BA8Bbe486d1D09dA5732B39e4".lowercased() public func getOrders(callback: @escaping (_ result: Any) -> Void) { Alamofire.request(baseURL + "contract/" + contractAddress, method: .get).responseJSON { [weak self] response in diff --git a/AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift b/AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift index 0c78ba1e2..4b006b03a 100644 --- a/AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift +++ b/AlphaWallet/Market/ViewControllers/ImportMagicTokenViewController.swift @@ -14,22 +14,24 @@ class ImportMagicTokenViewController: UIViewController, OptionalTokenVerifiableS case notReady } + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tokenCardRowView = TokenCardRowView() + private let statusLabel = UILabel() + private let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) + private var costStackView: UIStackView? + private let ethCostLabelLabel = UILabel() + private let ethCostLabel = UILabel() + private let dollarCostLabelLabel = UILabel() + private let dollarCostLabel = PaddedLabel() + private let buttonSeparator = UIView() + private let actionButton = UIButton(type: .system) + private let cancelButton = UIButton(type: .system) + private var viewModel: ImportMagicTokenViewControllerViewModel? + let config: Config weak var delegate: ImportMagicTokenViewControllerDelegate? - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tokenCardRowView = TokenCardRowView() - let statusLabel = UILabel() - let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) - var costStackView: UIStackView? - let ethCostLabelLabel = UILabel() - let ethCostLabel = UILabel() - let dollarCostLabelLabel = UILabel() - let dollarCostLabel = PaddedLabel() - let buttonSeparator = UIView() - let actionButton = UIButton(type: .system) - let cancelButton = UIButton(type: .system) - private var viewModel: ImportMagicTokenViewControllerViewModel? + var contract: String? { didSet { guard url != nil else { return } diff --git a/AlphaWallet/Market/ViewControllers/StatusViewController.swift b/AlphaWallet/Market/ViewControllers/StatusViewController.swift index c1470e90f..b0d475d2e 100644 --- a/AlphaWallet/Market/ViewControllers/StatusViewController.swift +++ b/AlphaWallet/Market/ViewControllers/StatusViewController.swift @@ -7,13 +7,14 @@ protocol StatusViewControllerDelegate: class { } class StatusViewController: UIViewController { + private let background = UIView() + private let imageView = UIImageView() + private let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) + private let titleLabel = UILabel() + private let actionButton = UIButton() + private var viewModel: StatusViewControllerViewModel? + weak var delegate: StatusViewControllerDelegate? - let background = UIView() - let imageView = UIImageView() - let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) - let titleLabel = UILabel() - let actionButton = UIButton() - var viewModel: StatusViewControllerViewModel? init() { super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Market/ViewModels/ImportMagicTokenCardRowViewModel.swift b/AlphaWallet/Market/ViewModels/ImportMagicTokenCardRowViewModel.swift index 3a1736104..3039a50eb 100644 --- a/AlphaWallet/Market/ViewModels/ImportMagicTokenCardRowViewModel.swift +++ b/AlphaWallet/Market/ViewModels/ImportMagicTokenCardRowViewModel.swift @@ -3,7 +3,7 @@ import Foundation struct ImportMagicTokenCardRowViewModel: TokenCardRowViewModelProtocol { - var importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel + private var importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel init(importMagicTokenViewControllerViewModel: ImportMagicTokenViewControllerViewModel) { self.importMagicTokenViewControllerViewModel = importMagicTokenViewControllerViewModel diff --git a/AlphaWallet/Market/ViewModels/StatusViewControllerViewModel.swift b/AlphaWallet/Market/ViewModels/StatusViewControllerViewModel.swift index 95a5053bc..9fc7c8bde 100644 --- a/AlphaWallet/Market/ViewModels/StatusViewControllerViewModel.swift +++ b/AlphaWallet/Market/ViewModels/StatusViewControllerViewModel.swift @@ -8,10 +8,12 @@ struct StatusViewControllerViewModel { case succeeded case failed } + + private let inProgressText: String + private let succeededTextText: String + private let failedText: String + var state: State - let inProgressText: String - let succeededTextText: String - let failedText: String var contentsBackgroundColor: UIColor { return Colors.appWhite diff --git a/AlphaWallet/MarketPlace/ViewControllers/MarketplaceViewController.swift b/AlphaWallet/MarketPlace/ViewControllers/MarketplaceViewController.swift index 6a207b0a8..6468984ea 100644 --- a/AlphaWallet/MarketPlace/ViewControllers/MarketplaceViewController.swift +++ b/AlphaWallet/MarketPlace/ViewControllers/MarketplaceViewController.swift @@ -3,7 +3,7 @@ import UIKit class MarketplaceViewController: UIViewController { - let comingSoonLabel = UILabel() + private let comingSoonLabel = UILabel() init() { super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Protection/Coordinators/ProtectionCoordinator.swift b/AlphaWallet/Protection/Coordinators/ProtectionCoordinator.swift index 3c8754a93..b2029c93e 100644 --- a/AlphaWallet/Protection/Coordinators/ProtectionCoordinator.swift +++ b/AlphaWallet/Protection/Coordinators/ProtectionCoordinator.swift @@ -4,14 +4,18 @@ import UIKit class ProtectionCoordinator: Coordinator { - var coordinators: [Coordinator] = [] - lazy var splashCoordinator: SplashCoordinator = { + private lazy var splashCoordinator: SplashCoordinator = { return SplashCoordinator(window: protectionWindow) }() - lazy var lockEnterPasscodeCoordinator: LockEnterPasscodeCoordinator = { + + private lazy var lockEnterPasscodeCoordinator: LockEnterPasscodeCoordinator = { return LockEnterPasscodeCoordinator(model: LockEnterPasscodeViewModel()) }() - let protectionWindow = UIWindow() + + private let protectionWindow = UIWindow() + + var coordinators: [Coordinator] = [] + init() { protectionWindow.windowLevel = UIWindowLevelStatusBar + 2.0 } diff --git a/AlphaWallet/Protection/Coordinators/SplashCoordinator.swift b/AlphaWallet/Protection/Coordinators/SplashCoordinator.swift index 4c476093a..bde73a6de 100644 --- a/AlphaWallet/Protection/Coordinators/SplashCoordinator.swift +++ b/AlphaWallet/Protection/Coordinators/SplashCoordinator.swift @@ -3,15 +3,19 @@ import UIKit class SplashCoordinator: Coordinator { - var coordinators: [Coordinator] = [] private let window: UIWindow + + var coordinators: [Coordinator] = [] + init(window: UIWindow) { self.window = window } + func start() { window.rootViewController = SplashViewController() window.isHidden = false } + func stop() { window.isHidden = true } diff --git a/AlphaWallet/Protection/ViewControllers/SplashViewController.swift b/AlphaWallet/Protection/ViewControllers/SplashViewController.swift index f612b149f..569c7a5db 100644 --- a/AlphaWallet/Protection/ViewControllers/SplashViewController.swift +++ b/AlphaWallet/Protection/ViewControllers/SplashViewController.swift @@ -5,6 +5,7 @@ import UIKit class SplashViewController: UIViewController { private var splashView = SplashView() + init() { super.init(nibName: nil, bundle: nil) splashView.translatesAutoresizingMaskIntoConstraints = false diff --git a/AlphaWallet/Protection/Views/SplashView.swift b/AlphaWallet/Protection/Views/SplashView.swift index 8aa209854..0d3b9f920 100644 --- a/AlphaWallet/Protection/Views/SplashView.swift +++ b/AlphaWallet/Protection/Views/SplashView.swift @@ -14,6 +14,7 @@ class SplashView: UIView { logoImageView.centerYAnchor.constraint(equalTo: centerYAnchor), ]) } + required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/AlphaWallet/Redeem/Helpers/RedeemEventListener.swift b/AlphaWallet/Redeem/Helpers/RedeemEventListener.swift index 8326776b8..682e105c4 100644 --- a/AlphaWallet/Redeem/Helpers/RedeemEventListener.swift +++ b/AlphaWallet/Redeem/Helpers/RedeemEventListener.swift @@ -10,7 +10,6 @@ import Foundation import TrustKeystore class RedeemEventListener { - var shouldListen = false func start(for address: Address, diff --git a/AlphaWallet/Redeem/Helpers/SignatureHelper.swift b/AlphaWallet/Redeem/Helpers/SignatureHelper.swift index 4c7e28e95..853b81f48 100644 --- a/AlphaWallet/Redeem/Helpers/SignatureHelper.swift +++ b/AlphaWallet/Redeem/Helpers/SignatureHelper.swift @@ -11,7 +11,6 @@ import TrustKeystore import BigInt class SignatureHelper { - class func signatureAsHex(for message: String, account: Account) -> String? { let keystore = try! EtherKeystore() let signature = keystore.signMessageData(message.data(using: String.Encoding.utf8), for: account) diff --git a/AlphaWallet/Redeem/Rest/EventsRest.swift b/AlphaWallet/Redeem/Rest/EventsRest.swift index 80093b3d0..4b7d822cc 100644 --- a/AlphaWallet/Redeem/Rest/EventsRest.swift +++ b/AlphaWallet/Redeem/Rest/EventsRest.swift @@ -11,7 +11,6 @@ import Result import TrustKeystore public class EventsRest { - func getEvents(for address: Address, completion: @escaping (Result<[Event], AnyError>) -> Void) { let endpoint = EndPoints.EventBaseUrl + "/" + address.description.lowercased() diff --git a/AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift b/AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift index 4e528cb4a..2ac5c7e47 100644 --- a/AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift +++ b/AlphaWallet/Redeem/ViewControllers/RedeemTokenCardQuantitySelectionViewController.swift @@ -14,19 +14,19 @@ protocol RedeemTokenCardQuantitySelectionViewControllerDelegate: class, CanOpenU } class RedeemTokenCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController { + private let token: TokenObject + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let subtitleLabel = UILabel() + private let quantityStepper = NumberStepper() + private let tokenRowView: TokenRowView & UIView + private let nextButton = UIButton(type: .system) + private var viewModel: RedeemTokenCardQuantitySelectionViewModel let config: Config var contract: String { return token.contract } - private let token: TokenObject - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let subtitleLabel = UILabel() - let quantityStepper = NumberStepper() - let tokenRowView: TokenRowView & UIView - let nextButton = UIButton(type: .system) - var viewModel: RedeemTokenCardQuantitySelectionViewModel weak var delegate: RedeemTokenCardQuantitySelectionViewControllerDelegate? init(config: Config, token: TokenObject, viewModel: RedeemTokenCardQuantitySelectionViewModel) { diff --git a/AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift b/AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift index a9d12fd4e..d9cfa208f 100644 --- a/AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift +++ b/AlphaWallet/Redeem/ViewControllers/RedeemTokenViewController.swift @@ -15,17 +15,17 @@ protocol RedeemTokenViewControllerDelegate: class, CanOpenURL { } class RedeemTokenViewController: UIViewController, TokenVerifiableStatusViewController { + private let token: TokenObject + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tableView = UITableView(frame: .zero, style: .plain) + private let nextButton = UIButton(type: .system) + private var viewModel: RedeemTokenCardViewModel let config: Config var contract: String { return token.contract } - private let token: TokenObject - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tableView = UITableView(frame: .zero, style: .plain) - let nextButton = UIButton(type: .system) - var viewModel: RedeemTokenCardViewModel weak var delegate: RedeemTokenViewControllerDelegate? init(config: Config, token: TokenObject, viewModel: RedeemTokenCardViewModel) { diff --git a/AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift b/AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift index cf1a56405..bb9fbc31c 100644 --- a/AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift +++ b/AlphaWallet/Redeem/ViewControllers/TokenCardRedemptionViewController.swift @@ -12,19 +12,19 @@ protocol TokenCardRedemptionViewControllerDelegate: class, CanOpenURL { } class TokenCardRedemptionViewController: UIViewController, TokenVerifiableStatusViewController { + private var viewModel: TokenCardRedemptionViewModel + private var titleLabel = UILabel() + private let imageView = UIImageView() + private let tokenRowView: TokenRowView & UIView + private var timer: Timer! + private var session: WalletSession + private let token: TokenObject + private let redeemListener = RedeemEventListener() let config: Config var contract: String { return token.contract } - var viewModel: TokenCardRedemptionViewModel - var titleLabel = UILabel() - let imageView = UIImageView() - let tokenRowView: TokenRowView & UIView - var timer: Timer! - var session: WalletSession - private let token: TokenObject - let redeemListener = RedeemEventListener() weak var delegate: TokenCardRedemptionViewControllerDelegate? init(config: Config, session: WalletSession, token: TokenObject, viewModel: TokenCardRedemptionViewModel) { diff --git a/AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift b/AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift index 0d90d825f..6643a8b64 100644 --- a/AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift +++ b/AlphaWallet/Redeem/ViewModels/RedeemTokenCardQuantitySelectionViewModel.swift @@ -10,9 +10,8 @@ import Foundation import UIKit struct RedeemTokenCardQuantitySelectionViewModel { - - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName() diff --git a/AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift b/AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift index 6b63a60b6..2b5c08ad9 100644 --- a/AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift +++ b/AlphaWallet/Redeem/ViewModels/RedeemTokenCardViewModel.swift @@ -10,9 +10,8 @@ import Foundation import UIKit struct RedeemTokenCardViewModel { - - var token: TokenObject - var tokenHolders: [TokenHolder] + let token: TokenObject + let tokenHolders: [TokenHolder] init(token: TokenObject) { self.token = token diff --git a/AlphaWallet/Redeem/ViewModels/TokenCardRedemptionViewModel.swift b/AlphaWallet/Redeem/ViewModels/TokenCardRedemptionViewModel.swift index 59db69679..52c32f964 100644 --- a/AlphaWallet/Redeem/ViewModels/TokenCardRedemptionViewModel.swift +++ b/AlphaWallet/Redeem/ViewModels/TokenCardRedemptionViewModel.swift @@ -10,8 +10,8 @@ import Foundation import UIKit struct TokenCardRedemptionViewModel { - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { return R.string.localizable.aWalletTokenRedeemShowQRCodeTitle() diff --git a/AlphaWallet/Rest/RestClient.swift b/AlphaWallet/Rest/RestClient.swift index 58ed77f43..e1124c385 100644 --- a/AlphaWallet/Rest/RestClient.swift +++ b/AlphaWallet/Rest/RestClient.swift @@ -14,7 +14,6 @@ enum RestError: Error { } struct RestClient { - static func get(endPoint: String, parameters: [String: AnyHashable]? = nil, completion: @escaping (_ response: DataResponse) -> Void) { diff --git a/AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift b/AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift index b8668c230..2a819c9f1 100644 --- a/AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift +++ b/AlphaWallet/Sell/ViewControllers/EnterSellTokensCardPriceQuantityViewController.swift @@ -9,29 +9,22 @@ protocol EnterSellTokensCardPriceQuantityViewControllerDelegate: class, CanOpenU } class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVerifiableStatusViewController { - - let config: Config - var contract: String { - return viewModel.token.contract - } - let storage: TokensDataStore - let roundedBackground = RoundedBackground() - let scrollView = UIScrollView() - let header = TokensCardViewControllerTitleHeader() - let pricePerTokenLabel = UILabel() - let pricePerTokenField = AmountTextField() - let quantityLabel = UILabel() - let quantityStepper = NumberStepper() - let ethCostLabelLabel = UILabel() - let ethCostLabel = UILabel() - let dollarCostLabelLabel = UILabel() - let dollarCostLabel = PaddedLabel() - let tokenRowView: TokenRowView & UIView - let nextButton = UIButton(type: .system) - var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel - let paymentFlow: PaymentFlow - let ethPrice: Subscribable - var totalEthCost: Ether { + private let storage: TokensDataStore + private let roundedBackground = RoundedBackground() + private let scrollView = UIScrollView() + private let header = TokensCardViewControllerTitleHeader() + private let pricePerTokenLabel = UILabel() + private let quantityLabel = UILabel() + private let quantityStepper = NumberStepper() + private let ethCostLabelLabel = UILabel() + private let ethCostLabel = UILabel() + private let dollarCostLabelLabel = UILabel() + private let dollarCostLabel = PaddedLabel() + private let tokenRowView: TokenRowView & UIView + private let nextButton = UIButton(type: .system) + private var viewModel: EnterSellTokensCardPriceQuantityViewControllerViewModel + private let ethPrice: Subscribable + private var totalEthCost: Ether { if let ethCostPerToken = Ether(string: pricePerTokenField.ethCost) { let quantity = Int(quantityStepper.value) return ethCostPerToken * quantity @@ -40,7 +33,7 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer } } - var totalDollarCost: String { + private var totalDollarCost: String { if let dollarCostPerToken = Double(pricePerTokenField.dollarCost) { let quantity = Double(quantityStepper.value) return StringFormatter().currency(with: dollarCostPerToken * quantity, and: "USD") @@ -48,6 +41,13 @@ class EnterSellTokensCardPriceQuantityViewController: UIViewController, TokenVer return "" } } + + let config: Config + var contract: String { + return viewModel.token.contract + } + let pricePerTokenField = AmountTextField() + let paymentFlow: PaymentFlow weak var delegate: EnterSellTokensCardPriceQuantityViewControllerDelegate? init( diff --git a/AlphaWallet/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift b/AlphaWallet/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift index 04a78938c..01c014140 100644 --- a/AlphaWallet/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift +++ b/AlphaWallet/Sell/ViewControllers/GenerateSellMagicLinkViewController.swift @@ -9,22 +9,23 @@ protocol GenerateSellMagicLinkViewControllerDelegate: class { } class GenerateSellMagicLinkViewController: UIViewController { + private let background = UIView() + private let header = TokensCardViewControllerTitleHeader() + private let detailsBackground = UIView() + private let subtitleLabel = UILabel() + private let tokenCountLabel = UILabel() + private let perTokenPriceLabel = UILabel() + private let totalEthLabel = UILabel() + private let descriptionLabel = UILabel() + private let actionButton = UIButton() + private let cancelButton = UIButton() + private var viewModel: GenerateSellMagicLinkViewControllerViewModel? + weak var delegate: GenerateSellMagicLinkViewControllerDelegate? - let background = UIView() - let header = TokensCardViewControllerTitleHeader() - let detailsBackground = UIView() - let subtitleLabel = UILabel() - let tokenCountLabel = UILabel() - let perTokenPriceLabel = UILabel() - let totalEthLabel = UILabel() - let descriptionLabel = UILabel() - let actionButton = UIButton() - let cancelButton = UIButton() let paymentFlow: PaymentFlow let tokenHolder: TokenHolder let ethCost: Ether let linkExpiryDate: Date - var viewModel: GenerateSellMagicLinkViewControllerViewModel? init(paymentFlow: PaymentFlow, tokenHolder: TokenHolder, ethCost: Ether, linkExpiryDate: Date) { self.paymentFlow = paymentFlow diff --git a/AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift b/AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift index 60335e99c..0e1cc14f4 100644 --- a/AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift +++ b/AlphaWallet/Sell/ViewControllers/SellTokensCardViewController.swift @@ -9,16 +9,16 @@ protocol SellTokensCardViewControllerDelegate: class, CanOpenURL { } class SellTokensCardViewController: UIViewController, TokenVerifiableStatusViewController { + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tableView = UITableView(frame: .zero, style: .plain) + private let nextButton = UIButton(type: .system) + private var viewModel: SellTokensCardViewModel let config: Config var contract: String { return viewModel.token.contract } - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tableView = UITableView(frame: .zero, style: .plain) - let nextButton = UIButton(type: .system) - var viewModel: SellTokensCardViewModel let paymentFlow: PaymentFlow weak var delegate: SellTokensCardViewControllerDelegate? diff --git a/AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift b/AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift index fbd3f272c..4211fc222 100644 --- a/AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift +++ b/AlphaWallet/Sell/ViewControllers/SetSellTokensCardExpiryDateViewController.swift @@ -8,34 +8,34 @@ protocol SetSellTokensCardExpiryDateViewControllerDelegate: class, CanOpenURL { } class SetSellTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController { + private let storage: TokensDataStore + private let roundedBackground = RoundedBackground() + private let scrollView = UIScrollView() + private let header = TokensCardViewControllerTitleHeader() + private let linkExpiryDateLabel = UILabel() + private let linkExpiryDateField = DateEntryField() + private let linkExpiryTimeLabel = UILabel() + private let linkExpiryTimeField = TimeEntryField() + private let tokenCountLabel = UILabel() + private let perTokenPriceLabel = UILabel() + private let totalEthLabel = UILabel() + private let descriptionLabel = UILabel() + private let noteTitleLabel = UILabel() + private let noteLabel = UILabel() + private let noteBorderView = UIView() + private let tokenRowView: TokenRowView & UIView + private let nextButton = UIButton(type: .system) + private let datePicker = UIDatePicker() + private let timePicker = UIDatePicker() + private var viewModel: SetSellTokensCardExpiryDateViewControllerViewModel + private let tokenHolder: TokenHolder + private let ethCost: Ether let config: Config var contract: String { return viewModel.token.contract } - let storage: TokensDataStore - let roundedBackground = RoundedBackground() - let scrollView = UIScrollView() - let header = TokensCardViewControllerTitleHeader() - let linkExpiryDateLabel = UILabel() - let linkExpiryDateField = DateEntryField() - let linkExpiryTimeLabel = UILabel() - let linkExpiryTimeField = TimeEntryField() - let tokenCountLabel = UILabel() - let perTokenPriceLabel = UILabel() - let totalEthLabel = UILabel() - let descriptionLabel = UILabel() - let noteTitleLabel = UILabel() - let noteLabel = UILabel() - let noteBorderView = UIView() - let tokenRowView: TokenRowView & UIView - let nextButton = UIButton(type: .system) - let datePicker = UIDatePicker() - let timePicker = UIDatePicker() - var viewModel: SetSellTokensCardExpiryDateViewControllerViewModel let paymentFlow: PaymentFlow - let tokenHolder: TokenHolder - let ethCost: Ether weak var delegate: SetSellTokensCardExpiryDateViewControllerDelegate? init( diff --git a/AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift b/AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift index 87ab60cb0..5598d9b33 100644 --- a/AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift +++ b/AlphaWallet/Sell/ViewModels/EnterSellTokensCardPriceQuantityViewControllerViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct EnterSellTokensCardPriceQuantityViewControllerViewModel { - - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var ethCost: Ether = .zero var dollarCost: String = "" diff --git a/AlphaWallet/Sell/ViewModels/GenerateSellMagicLinkViewControllerViewModel.swift b/AlphaWallet/Sell/ViewModels/GenerateSellMagicLinkViewControllerViewModel.swift index a90ff07e9..2a50b374e 100644 --- a/AlphaWallet/Sell/ViewModels/GenerateSellMagicLinkViewControllerViewModel.swift +++ b/AlphaWallet/Sell/ViewModels/GenerateSellMagicLinkViewControllerViewModel.swift @@ -3,9 +3,9 @@ import UIKit struct GenerateSellMagicLinkViewControllerViewModel { - let tokenHolder: TokenHolder - let ethCost: Ether - let linkExpiryDate: Date + private let tokenHolder: TokenHolder + private let ethCost: Ether + private let linkExpiryDate: Date var contentsBackgroundColor: UIColor { return Colors.appWhite diff --git a/AlphaWallet/Sell/ViewModels/GenerateTransferMagicLinkViewControllerViewModel.swift b/AlphaWallet/Sell/ViewModels/GenerateTransferMagicLinkViewControllerViewModel.swift index aaa0c265d..a3e20dfb7 100644 --- a/AlphaWallet/Sell/ViewModels/GenerateTransferMagicLinkViewControllerViewModel.swift +++ b/AlphaWallet/Sell/ViewModels/GenerateTransferMagicLinkViewControllerViewModel.swift @@ -3,8 +3,8 @@ import UIKit struct GenerateTransferMagicLinkViewControllerViewModel { - var tokenHolder: TokenHolder - var linkExpiryDate: Date + private let tokenHolder: TokenHolder + private let linkExpiryDate: Date var contentsBackgroundColor: UIColor { return Colors.appWhite diff --git a/AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift b/AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift index dd4662efe..26414ae34 100644 --- a/AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift +++ b/AlphaWallet/Sell/ViewModels/SellTokensCardViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct SellTokensCardViewModel { - - var token: TokenObject - var tokenHolders: [TokenHolder] + let token: TokenObject + let tokenHolders: [TokenHolder] init(token: TokenObject) { self.token = token diff --git a/AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift b/AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift index 2ae0b1111..c051bbda2 100644 --- a/AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift +++ b/AlphaWallet/Sell/ViewModels/SetSellTokensCardExpiryDateViewControllerViewModel.swift @@ -4,10 +4,10 @@ import Foundation import UIKit struct SetSellTokensCardExpiryDateViewControllerViewModel { + private let ethCost: Ether - var token: TokenObject - var tokenHolder: TokenHolder - var ethCost: Ether = .zero + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { return R.string.localizable.aWalletTokenSellEnterLinkExpiryDateTitle() diff --git a/AlphaWallet/Sell/Views/DateEntryField.swift b/AlphaWallet/Sell/Views/DateEntryField.swift index c3af08505..6054dcf89 100644 --- a/AlphaWallet/Sell/Views/DateEntryField.swift +++ b/AlphaWallet/Sell/Views/DateEntryField.swift @@ -7,7 +7,8 @@ protocol DateEntryFieldDelegate: class { } class DateEntryField: UIControl { - var leftButton = UIButton(type: .custom) + private let leftButton = UIButton(type: .custom) + var value = Date() { didSet { displayDateString() diff --git a/AlphaWallet/Sell/Views/TimeEntryField.swift b/AlphaWallet/Sell/Views/TimeEntryField.swift index 29ac9a46e..64d8040df 100644 --- a/AlphaWallet/Sell/Views/TimeEntryField.swift +++ b/AlphaWallet/Sell/Views/TimeEntryField.swift @@ -7,7 +7,8 @@ protocol TimeEntryFieldDelegate: class { } class TimeEntryField: UIControl { - var leftButton = UIButton(type: .custom) + private let leftButton = UIButton(type: .custom) + var value = Date() { didSet { displayTimeString() diff --git a/AlphaWallet/Settings/Coordinators/AddCustomNetworkCoordinator.swift b/AlphaWallet/Settings/Coordinators/AddCustomNetworkCoordinator.swift index ba512d312..5e3f728d9 100644 --- a/AlphaWallet/Settings/Coordinators/AddCustomNetworkCoordinator.swift +++ b/AlphaWallet/Settings/Coordinators/AddCustomNetworkCoordinator.swift @@ -9,11 +9,9 @@ protocol AddCustomNetworkCoordinatorDelegate: class { } class AddCustomNetworkCoordinator: Coordinator { - let navigationController: UINavigationController - var coordinators: [Coordinator] = [] - weak var delegate: AddCustomNetworkCoordinatorDelegate? + private let navigationController: UINavigationController - lazy var addNetworkItem: UIBarButtonItem = { + private lazy var addNetworkItem: UIBarButtonItem = { return UIBarButtonItem( barButtonSystemItem: .add, target: self, @@ -21,12 +19,15 @@ class AddCustomNetworkCoordinator: Coordinator { ) }() - lazy var addCustomNetworkController: AddCustomNetworkViewController = { + private lazy var addCustomNetworkController: AddCustomNetworkViewController = { let controller = AddCustomNetworkViewController() controller.navigationItem.rightBarButtonItem = addNetworkItem return controller }() + var coordinators: [Coordinator] = [] + weak var delegate: AddCustomNetworkCoordinatorDelegate? + init( navigationController: UINavigationController = NavigationController() ) { diff --git a/AlphaWallet/Settings/Coordinators/HelpUsCoordinator.swift b/AlphaWallet/Settings/Coordinators/HelpUsCoordinator.swift index 79aecb343..d2d37d2b0 100644 --- a/AlphaWallet/Settings/Coordinators/HelpUsCoordinator.swift +++ b/AlphaWallet/Settings/Coordinators/HelpUsCoordinator.swift @@ -4,12 +4,12 @@ import UIKit import StoreKit class HelpUsCoordinator: Coordinator { + private let navigationController: UINavigationController + private let appTracker: AppTracker + private let viewModel = HelpUsViewModel() - let navigationController: UINavigationController - let appTracker: AppTracker var coordinators: [Coordinator] = [] - private let viewModel = HelpUsViewModel() init( navigationController: UINavigationController = NavigationController(), appTracker: AppTracker = AppTracker() diff --git a/AlphaWallet/Settings/Coordinators/LocalesCoordinator.swift b/AlphaWallet/Settings/Coordinators/LocalesCoordinator.swift index 7e8fcf431..93e5710e2 100644 --- a/AlphaWallet/Settings/Coordinators/LocalesCoordinator.swift +++ b/AlphaWallet/Settings/Coordinators/LocalesCoordinator.swift @@ -7,8 +7,9 @@ protocol LocalesCoordinatorDelegate: class { } class LocalesCoordinator: Coordinator { + private var config: Config + var coordinators: [Coordinator] = [] - var config: Config lazy var localesViewController: LocalesViewController = { let locales: [AppLocale] = [ diff --git a/AlphaWallet/Settings/Coordinators/ServersCoordinator.swift b/AlphaWallet/Settings/Coordinators/ServersCoordinator.swift index 7fdc4a3ff..0c110f508 100644 --- a/AlphaWallet/Settings/Coordinators/ServersCoordinator.swift +++ b/AlphaWallet/Settings/Coordinators/ServersCoordinator.swift @@ -7,8 +7,9 @@ protocol ServersCoordinatorDelegate: class { } class ServersCoordinator: Coordinator { + private var config: Config + var coordinators: [Coordinator] = [] - var config: Config lazy var serversViewController: ServersViewController = { let servers: [RPCServer] = { diff --git a/AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift b/AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift index eba7667ea..900ec8dec 100644 --- a/AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift +++ b/AlphaWallet/Settings/Coordinators/SettingsCoordinator.swift @@ -14,12 +14,12 @@ protocol SettingsCoordinatorDelegate: class, CanOpenURL { } class SettingsCoordinator: Coordinator { + private let keystore: Keystore + private let session: WalletSession + private let storage: TransactionsStorage + private let balanceCoordinator: GetBalanceCoordinator let navigationController: UINavigationController - let keystore: Keystore - let session: WalletSession - let storage: TransactionsStorage - let balanceCoordinator: GetBalanceCoordinator weak var delegate: SettingsCoordinatorDelegate? var coordinators: [Coordinator] = [] diff --git a/AlphaWallet/Settings/Types/Config.swift b/AlphaWallet/Settings/Types/Config.swift index 864998696..48d082637 100644 --- a/AlphaWallet/Settings/Types/Config.swift +++ b/AlphaWallet/Settings/Types/Config.swift @@ -5,7 +5,6 @@ import ObjectiveC import TrustKeystore struct Config { - struct Keys { static let chainID = "chainID" static let isCryptoPrimaryCurrency = "isCryptoPrimaryCurrency" diff --git a/AlphaWallet/Settings/Types/ConfigExplorer.swift b/AlphaWallet/Settings/Types/ConfigExplorer.swift index 7ac0e6a8c..5cf3087e4 100644 --- a/AlphaWallet/Settings/Types/ConfigExplorer.swift +++ b/AlphaWallet/Settings/Types/ConfigExplorer.swift @@ -3,8 +3,7 @@ import Foundation struct ConfigExplorer { - - let server: RPCServer + private let server: RPCServer init( server: RPCServer diff --git a/AlphaWallet/Settings/ViewControllers/AddCustomNetworkViewController.swift b/AlphaWallet/Settings/ViewControllers/AddCustomNetworkViewController.swift index c7ba66545..86c868430 100644 --- a/AlphaWallet/Settings/ViewControllers/AddCustomNetworkViewController.swift +++ b/AlphaWallet/Settings/ViewControllers/AddCustomNetworkViewController.swift @@ -5,8 +5,7 @@ import Eureka import Result class AddCustomNetworkViewController: FormViewController { - - let viewModel = AddCustomNetworkViewModel() + private let viewModel = AddCustomNetworkViewModel() private struct Values { static let chainID = "chainID" @@ -15,8 +14,6 @@ class AddCustomNetworkViewController: FormViewController { static let endpoint = "endpoint" } - weak var delegate: NewTokenViewControllerDelegate? - private var chainIDRow: TextFloatLabelRow? { return form.rowBy(tag: Values.chainID) as? TextFloatLabelRow } @@ -30,6 +27,8 @@ class AddCustomNetworkViewController: FormViewController { return form.rowBy(tag: Values.endpoint) as? TextFloatLabelRow } + weak var delegate: NewTokenViewControllerDelegate? + override func viewDidLoad() { super.viewDidLoad() diff --git a/AlphaWallet/Settings/ViewControllers/LocalesViewController.swift b/AlphaWallet/Settings/ViewControllers/LocalesViewController.swift index 0811d2f35..0f7459e5b 100644 --- a/AlphaWallet/Settings/ViewControllers/LocalesViewController.swift +++ b/AlphaWallet/Settings/ViewControllers/LocalesViewController.swift @@ -8,12 +8,13 @@ protocol LocalesViewControllerDelegate: class { } class LocalesViewController: UIViewController { - let headerHeight = CGFloat(70) + private let headerHeight = CGFloat(70) + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tableView = UITableView(frame: .zero, style: .plain) + private var viewModel: LocalesViewModel? + weak var delegate: LocalesViewControllerDelegate? - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tableView = UITableView(frame: .zero, style: .plain) - var viewModel: LocalesViewModel? init() { super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Settings/ViewControllers/PreferencesController.swift b/AlphaWallet/Settings/ViewControllers/PreferencesController.swift index 270fbe486..aebe6d394 100644 --- a/AlphaWallet/Settings/ViewControllers/PreferencesController.swift +++ b/AlphaWallet/Settings/ViewControllers/PreferencesController.swift @@ -3,8 +3,7 @@ import Foundation final class PreferencesController { - - let userDefaults: UserDefaults + private let userDefaults: UserDefaults init( userDefaults: UserDefaults = .standard diff --git a/AlphaWallet/Settings/ViewControllers/ServersViewController.swift b/AlphaWallet/Settings/ViewControllers/ServersViewController.swift index 69561e96e..3461d7633 100644 --- a/AlphaWallet/Settings/ViewControllers/ServersViewController.swift +++ b/AlphaWallet/Settings/ViewControllers/ServersViewController.swift @@ -8,12 +8,13 @@ protocol ServersViewControllerDelegate: class { } class ServersViewController: UIViewController { - let headerHeight = CGFloat(70) + private let headerHeight = CGFloat(70) + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tableView = UITableView(frame: .zero, style: .plain) + private var viewModel: ServersViewModel? + weak var delegate: ServersViewControllerDelegate? - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tableView = UITableView(frame: .zero, style: .plain) - var viewModel: ServersViewModel? init() { super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Settings/ViewControllers/SettingsViewController.swift b/AlphaWallet/Settings/ViewControllers/SettingsViewController.swift index 3a83f22b4..78a22cca7 100644 --- a/AlphaWallet/Settings/ViewControllers/SettingsViewController.swift +++ b/AlphaWallet/Settings/ViewControllers/SettingsViewController.swift @@ -12,15 +12,17 @@ protocol SettingsViewControllerDelegate: class, CanOpenURL { } class SettingsViewController: FormViewController { - private var lock = Lock() - weak var delegate: SettingsViewControllerDelegate? - var isPasscodeEnabled: Bool { + private let lock = Lock() + private var isPasscodeEnabled: Bool { return lock.isPasscodeSet() } - lazy var viewModel: SettingsViewModel = { + private lazy var viewModel: SettingsViewModel = { return SettingsViewModel(isDebug: isDebug) }() - let session: WalletSession + private let session: WalletSession + + weak var delegate: SettingsViewControllerDelegate? + init(session: WalletSession) { self.session = session super.init(style: .plain) diff --git a/AlphaWallet/Settings/ViewControllers/WellDoneViewController.swift b/AlphaWallet/Settings/ViewControllers/WellDoneViewController.swift index c89daac76..cdac4c939 100644 --- a/AlphaWallet/Settings/ViewControllers/WellDoneViewController.swift +++ b/AlphaWallet/Settings/ViewControllers/WellDoneViewController.swift @@ -10,7 +10,6 @@ protocol WellDoneViewControllerDelegate: class { } class WellDoneViewController: UIViewController { - weak var delegate: WellDoneViewControllerDelegate? override func viewDidLoad() { diff --git a/AlphaWallet/Settings/ViewModels/AddCustomNetworkViewModel.swift b/AlphaWallet/Settings/ViewModels/AddCustomNetworkViewModel.swift index a47612b92..e9856afde 100644 --- a/AlphaWallet/Settings/ViewModels/AddCustomNetworkViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/AddCustomNetworkViewModel.swift @@ -3,7 +3,6 @@ import Foundation struct AddCustomNetworkViewModel { - var title: String { return R.string.localizable.settingsCustomNetworkNavigationTitle() } diff --git a/AlphaWallet/Settings/ViewModels/HelpUsViewModel.swift b/AlphaWallet/Settings/ViewModels/HelpUsViewModel.swift index 313345905..3420d8060 100644 --- a/AlphaWallet/Settings/ViewModels/HelpUsViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/HelpUsViewModel.swift @@ -3,7 +3,6 @@ import Foundation import UIKit struct HelpUsViewModel { - var title: String { return R.string.localizable.welldoneNavigationTitle() } diff --git a/AlphaWallet/Settings/ViewModels/LocaleViewModel.swift b/AlphaWallet/Settings/ViewModels/LocaleViewModel.swift index f66df026c..573ef0d48 100644 --- a/AlphaWallet/Settings/ViewModels/LocaleViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/LocaleViewModel.swift @@ -4,8 +4,8 @@ import Foundation import UIKit struct LocaleViewModel { - let locale: AppLocale - let isSelected: Bool + private let locale: AppLocale + private let isSelected: Bool init(locale: AppLocale, selected: Bool) { self.locale = locale diff --git a/AlphaWallet/Settings/ViewModels/ServerViewModel.swift b/AlphaWallet/Settings/ViewModels/ServerViewModel.swift index b51404e30..3ec9fe41c 100644 --- a/AlphaWallet/Settings/ViewModels/ServerViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/ServerViewModel.swift @@ -4,8 +4,8 @@ import Foundation import UIKit struct ServerViewModel { - let server: RPCServer - let isSelected: Bool + private let server: RPCServer + private let isSelected: Bool init(server: RPCServer, selected: Bool) { self.server = server diff --git a/AlphaWallet/Settings/ViewModels/ServersViewModel.swift b/AlphaWallet/Settings/ViewModels/ServersViewModel.swift index 1e567f848..59f71a64c 100644 --- a/AlphaWallet/Settings/ViewModels/ServersViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/ServersViewModel.swift @@ -4,8 +4,9 @@ import Foundation import TrustKeystore struct ServersViewModel { + private let selectedServer: RPCServer + let servers: [RPCServer] - let selectedServer: RPCServer var title: String { return R.string.localizable.settingsNetworkButtonTitle() diff --git a/AlphaWallet/Settings/ViewModels/SettingsViewModel.swift b/AlphaWallet/Settings/ViewModels/SettingsViewModel.swift index 09cc104e9..07ac045f9 100644 --- a/AlphaWallet/Settings/ViewModels/SettingsViewModel.swift +++ b/AlphaWallet/Settings/ViewModels/SettingsViewModel.swift @@ -3,7 +3,6 @@ import Foundation struct SettingsViewModel { - private let isDebug: Bool init( @@ -12,23 +11,6 @@ struct SettingsViewModel { self.isDebug = isDebug } - var servers: [RPCServer] { - return [ - RPCServer.main, - RPCServer.classic, - RPCServer.poa, - // RPCServer.callisto, TODO: Enable. - RPCServer.kovan, - RPCServer.ropsten, - RPCServer.rinkeby, - RPCServer.sokol, - ] - } - - var currency: [Currency] { - return Currency.allValues.map { $0 } - } - var passcodeTitle: String { switch BiometryAuthenticationType.current { case .faceID, .touchID: diff --git a/AlphaWallet/Settings/Views/AlphaWalletSettingsSwitchRow.swift b/AlphaWallet/Settings/Views/AlphaWalletSettingsSwitchRow.swift index f42495024..bcc1eb9b9 100644 --- a/AlphaWallet/Settings/Views/AlphaWalletSettingsSwitchRow.swift +++ b/AlphaWallet/Settings/Views/AlphaWalletSettingsSwitchRow.swift @@ -17,8 +17,8 @@ open class _AlphaWalletSettingsSwitchRow: Row { } open class AlphaWalletSwitchCell: Cell, CellType { + private let background = UIView() - let background = UIView() @IBOutlet public weak var switchControl: UISwitch! required public init(style: UITableViewCellStyle, reuseIdentifier: String?) { diff --git a/AlphaWallet/Settings/Views/AlphaWalletSettingsTextRow.swift b/AlphaWallet/Settings/Views/AlphaWalletSettingsTextRow.swift index 9f5393222..865bb0efc 100644 --- a/AlphaWallet/Settings/Views/AlphaWalletSettingsTextRow.swift +++ b/AlphaWallet/Settings/Views/AlphaWalletSettingsTextRow.swift @@ -16,7 +16,8 @@ open class _TextRow: FieldRow { } open class AlphaWalletSettingsTextCell: _FieldCell, CellType { - let background = UIView() + private let background = UIView() + let mainLabel = UILabel() let subLabel = UILabel() diff --git a/AlphaWallet/Settings/Views/LocaleViewCell.swift b/AlphaWallet/Settings/Views/LocaleViewCell.swift index 8e9a44ebf..4c1bba077 100644 --- a/AlphaWallet/Settings/Views/LocaleViewCell.swift +++ b/AlphaWallet/Settings/Views/LocaleViewCell.swift @@ -6,9 +6,9 @@ import UIKit class LocaleViewCell: UITableViewCell { static let identifier = "LocaleViewCell" - let background = UIView() - var selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) - var nameLabel = UILabel() + private let background = UIView() + private let selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) + private let nameLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/Settings/Views/ServerViewCell.swift b/AlphaWallet/Settings/Views/ServerViewCell.swift index 49ba6a4f1..a1e59be07 100644 --- a/AlphaWallet/Settings/Views/ServerViewCell.swift +++ b/AlphaWallet/Settings/Views/ServerViewCell.swift @@ -6,9 +6,9 @@ import UIKit class ServerViewCell: UITableViewCell { static let identifier = "ServerViewCell" - let background = UIView() - var selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) - var nameLabel = UILabel() + private let background = UIView() + private let selectedIcon = UIImageView(image: R.image.ticket_bundle_checked()) + private let nameLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift b/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift index 541eddf8a..672e79a97 100644 --- a/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/ClaimOrderCoordinator.swift @@ -16,9 +16,7 @@ import Result class ClaimOrderCoordinator { private let web3: Web3Swift - init( - web3: Web3Swift - ) { + init(web3: Web3Swift) { self.web3 = web3 } diff --git a/AlphaWallet/Tokens/Coordinators/GetBalanceCoordinator.swift b/AlphaWallet/Tokens/Coordinators/GetBalanceCoordinator.swift index aafbb5105..0f2b37130 100644 --- a/AlphaWallet/Tokens/Coordinators/GetBalanceCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/GetBalanceCoordinator.swift @@ -9,7 +9,6 @@ import TrustKeystore import web3swift class GetBalanceCoordinator { - private let config: Config init(config: Config) { diff --git a/AlphaWallet/Tokens/Coordinators/GetDecimalsCoordinator.swift b/AlphaWallet/Tokens/Coordinators/GetDecimalsCoordinator.swift index c984b191c..02bf95a81 100644 --- a/AlphaWallet/Tokens/Coordinators/GetDecimalsCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/GetDecimalsCoordinator.swift @@ -6,7 +6,6 @@ import TrustKeystore import web3swift class GetDecimalsCoordinator { - private let config: Config init(config: Config) { diff --git a/AlphaWallet/Tokens/Coordinators/GetNameCoordinator.swift b/AlphaWallet/Tokens/Coordinators/GetNameCoordinator.swift index b10fecd53..fc3e8b06a 100644 --- a/AlphaWallet/Tokens/Coordinators/GetNameCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/GetNameCoordinator.swift @@ -6,7 +6,6 @@ import TrustKeystore import web3swift class GetNameCoordinator { - private let config: Config init(config: Config) { diff --git a/AlphaWallet/Tokens/Coordinators/GetSymbolCoordinator.swift b/AlphaWallet/Tokens/Coordinators/GetSymbolCoordinator.swift index 0004a0bde..a82bd79ef 100644 --- a/AlphaWallet/Tokens/Coordinators/GetSymbolCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/GetSymbolCoordinator.swift @@ -6,7 +6,6 @@ import TrustKeystore import web3swift class GetSymbolCoordinator { - private let config: Config init(config: Config) { diff --git a/AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift b/AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift index 3e2dba2bc..516099348 100644 --- a/AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift +++ b/AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift @@ -24,15 +24,12 @@ private enum ContractData { } class TokensCoordinator: Coordinator { - - let navigationController: UINavigationController - let session: WalletSession - let keystore: Keystore - var coordinators: [Coordinator] = [] - let storage: TokensDataStore + private let session: WalletSession + private let keystore: Keystore + private let storage: TokensDataStore private let assetDefinitionStore: AssetDefinitionStore - lazy var tokensViewController: TokensViewController = { + private lazy var tokensViewController: TokensViewController = { let controller = TokensViewController( session: session, account: session.account, @@ -41,6 +38,9 @@ class TokensCoordinator: Coordinator { controller.delegate = self return controller }() + + let navigationController: UINavigationController + var coordinators: [Coordinator] = [] weak var delegate: TokensCoordinatorDelegate? lazy var rootViewController: TokensViewController = { diff --git a/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift b/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift index 198d73cf4..f89978771 100644 --- a/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift +++ b/AlphaWallet/Tokens/Helpers/TokenAdaptor.swift @@ -11,7 +11,8 @@ import RealmSwift import BigInt class TokenAdaptor { - var token: TokenObject + private let token: TokenObject + init(token: TokenObject) { self.token = token } diff --git a/AlphaWallet/Tokens/Types/Token.swift b/AlphaWallet/Tokens/Types/Token.swift index 585381b30..16ff8225c 100644 --- a/AlphaWallet/Tokens/Types/Token.swift +++ b/AlphaWallet/Tokens/Types/Token.swift @@ -16,8 +16,8 @@ struct Token { let id: BigUInt let index: UInt16 - var name: String - var status: Status + let name: String + let status: Status let values: [String: AssetAttributeValue] static var empty: Token { diff --git a/AlphaWallet/Tokens/Types/TokenBalance.swift b/AlphaWallet/Tokens/Types/TokenBalance.swift index d23cd7859..9b74d087d 100644 --- a/AlphaWallet/Tokens/Types/TokenBalance.swift +++ b/AlphaWallet/Tokens/Types/TokenBalance.swift @@ -5,7 +5,6 @@ import RealmSwift import BigInt class TokenBalance: Object { - @objc dynamic var balance = "0" convenience init(balance: String = "0") { diff --git a/AlphaWallet/Tokens/Types/TokenHolder.swift b/AlphaWallet/Tokens/Types/TokenHolder.swift index f1994eb35..fd2c1ed86 100644 --- a/AlphaWallet/Tokens/Types/TokenHolder.swift +++ b/AlphaWallet/Tokens/Types/TokenHolder.swift @@ -9,14 +9,12 @@ import Foundation class TokenHolder { - var tokens: [Token] - var name: String { return tokens[0].name } - var values: [String: AssetAttributeValue] { return tokens[0].values } - var status: Token.Status { return tokens[0].status } + let tokens: [Token] + let contractAddress: String + let hasAssetDefinition: Bool + var isSelected = false var areDetailsVisible = false - var contractAddress: String - var hasAssetDefinition: Bool init(tokens: [Token], contractAddress: String, hasAssetDefinition: Bool) { self.tokens = tokens @@ -31,4 +29,16 @@ class TokenHolder { var indices: [UInt16] { return tokens.map { $0.index } } + + var name: String { + return tokens[0].name + } + + var values: [String: AssetAttributeValue] { + return tokens[0].values + } + + var status: Token.Status { + return tokens[0].status + } } diff --git a/AlphaWallet/Tokens/Types/TokenObject.swift b/AlphaWallet/Tokens/Types/TokenObject.swift index d8dec9707..f5baa9c96 100644 --- a/AlphaWallet/Tokens/Types/TokenObject.swift +++ b/AlphaWallet/Tokens/Types/TokenObject.swift @@ -12,11 +12,14 @@ class TokenObject: Object { @objc dynamic var decimals: Int = 0 @objc dynamic var value: String = "" @objc dynamic var isDisabled: Bool = false - var balance = List() + @objc dynamic var rawType: String = TokenType.erc20.rawValue + + let balance = List() + var nonZeroBalance: [TokenBalance] { return Array(balance.filter { isNonZeroBalance($0.balance) }) } - @objc dynamic var rawType: String = TokenType.erc20.rawValue + var type: TokenType { get { return TokenType(rawValue: rawType)! diff --git a/AlphaWallet/Tokens/Types/TokensDataStore.swift b/AlphaWallet/Tokens/Types/TokensDataStore.swift index b412d6715..030cd97d0 100644 --- a/AlphaWallet/Tokens/Types/TokensDataStore.swift +++ b/AlphaWallet/Tokens/Types/TokensDataStore.swift @@ -19,7 +19,6 @@ protocol TokensDataStoreDelegate: class { } class TokensDataStore { - private lazy var getBalanceCoordinator: GetBalanceCoordinator = { return GetBalanceCoordinator(config: config) }() diff --git a/AlphaWallet/Tokens/ViewControllers/NewTokenViewController.swift b/AlphaWallet/Tokens/ViewControllers/NewTokenViewController.swift index d6f8cedf4..826390fed 100644 --- a/AlphaWallet/Tokens/ViewControllers/NewTokenViewController.swift +++ b/AlphaWallet/Tokens/ViewControllers/NewTokenViewController.swift @@ -11,25 +11,25 @@ protocol NewTokenViewControllerDelegate: class { } class NewTokenViewController: UIViewController, CanScanQRCode { - let roundedBackground = RoundedBackground() - let scrollView = UIScrollView() - let footerBar = UIView() - let header = TokensCardViewControllerTitleHeader() - var viewModel = NewTokenViewModel() - var tokenType: TokenType? = nil { + private let roundedBackground = RoundedBackground() + private let scrollView = UIScrollView() + private let footerBar = UIView() + private let header = TokensCardViewControllerTitleHeader() + private var viewModel = NewTokenViewModel() + private var tokenType: TokenType? = nil { didSet { updateSaveButtonBasedOnTokenTypeDetected() } } - let addressTextField = AddressTextField() - let symbolTextField = TextField() - let decimalsTextField = TextField() - let balanceTextField = TextField() - let nameTextField = TextField() - let saveButton = UIButton(type: .system) + private let addressTextField = AddressTextField() + private let symbolTextField = TextField() + private let decimalsTextField = TextField() + private let balanceTextField = TextField() + private let nameTextField = TextField() + private let saveButton = UIButton(type: .system) - var scrollViewBottomAnchorConstraint: NSLayoutConstraint! + private var scrollViewBottomAnchorConstraint: NSLayoutConstraint! weak var delegate: NewTokenViewControllerDelegate? diff --git a/AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift b/AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift index c0317fe69..460a0ac62 100644 --- a/AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift +++ b/AlphaWallet/Tokens/ViewControllers/StaticHTMLViewController.swift @@ -6,7 +6,8 @@ protocol StaticHTMLViewControllerDelegate: class, CanOpenURL { } class StaticHTMLViewController: UIViewController { - let webView = UIWebView() + private let webView = UIWebView() + let footer = UIView() weak var delegate: StaticHTMLViewControllerDelegate? diff --git a/AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift b/AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift index e6341c6d3..f0662f077 100644 --- a/AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift +++ b/AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift @@ -21,23 +21,22 @@ protocol TokensCardViewControllerDelegate: class, CanOpenURL { } class TokensCardViewController: UIViewController, TokenVerifiableStatusViewController { + private let tokenObject: TokenObject + private var viewModel: TokensCardViewModel + private let tokensStorage: TokensDataStore + private let account: Wallet + private let header = TokenCardsViewControllerHeader() + private let roundedBackground = RoundedBackground() + private let tableView = UITableView(frame: .zero, style: .plain) + private let redeemButton = UIButton(type: .system) + private let sellButton = UIButton(type: .system) + private let transferButton = UIButton(type: .system) let config: Config var contract: String { return tokenObject.contract } - let tokenObject: TokenObject - var viewModel: TokensCardViewModel - let tokensStorage: TokensDataStore - let account: Wallet weak var delegate: TokensCardViewControllerDelegate? - let header = TokenCardsViewControllerHeader() - let roundedBackground = RoundedBackground() - let tableView = UITableView(frame: .zero, style: .plain) - - let redeemButton = UIButton(type: .system) - let sellButton = UIButton(type: .system) - let transferButton = UIButton(type: .system) var isReadOnly = false { didSet { diff --git a/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift b/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift index 4204c98af..7ad427283 100644 --- a/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift +++ b/AlphaWallet/Tokens/ViewControllers/TokensViewController.swift @@ -12,23 +12,23 @@ protocol TokensViewControllerDelegate: class { } class TokensViewController: UIViewController { - private let dataStore: TokensDataStore - var viewModel: TokensViewModel { + private var viewModel: TokensViewModel { didSet { viewModel.filter = oldValue.filter refreshView(viewModel: viewModel) } } - let session: WalletSession - let account: Wallet - let filterView = WalletFilterView() - var importWalletView: UIView? - var importWalletLayer = CAShapeLayer() - var importWalletHelpBubbleView: ImportWalletHelpBubbleView? - let tableView: UITableView - let refreshControl = UIRefreshControl() + private let session: WalletSession + private let account: Wallet + private let filterView = WalletFilterView() + private var importWalletView: UIView? + private var importWalletLayer = CAShapeLayer() + private var importWalletHelpBubbleView: ImportWalletHelpBubbleView? + private let tableView: UITableView + private let refreshControl = UIRefreshControl() + weak var delegate: TokensViewControllerDelegate? init(session: WalletSession, diff --git a/AlphaWallet/Tokens/ViewModels/BaseTokenCardTableViewCellViewModel.swift b/AlphaWallet/Tokens/ViewModels/BaseTokenCardTableViewCellViewModel.swift index 366bf5b5f..061dbb96e 100644 --- a/AlphaWallet/Tokens/ViewModels/BaseTokenCardTableViewCellViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/BaseTokenCardTableViewCellViewModel.swift @@ -5,9 +5,7 @@ import UIKit struct BaseTokenCardTableViewCellViewModel { let tokenHolder: TokenHolder - init( - tokenHolder: TokenHolder - ) { + init(tokenHolder: TokenHolder) { self.tokenHolder = tokenHolder } diff --git a/AlphaWallet/Tokens/ViewModels/CryptoKittyCardRowViewModel.swift b/AlphaWallet/Tokens/ViewModels/CryptoKittyCardRowViewModel.swift index 9924d5d1d..4d33724ad 100644 --- a/AlphaWallet/Tokens/ViewModels/CryptoKittyCardRowViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/CryptoKittyCardRowViewModel.swift @@ -4,12 +4,10 @@ import UIKit import PromiseKit struct CryptoKittyCardRowViewModel { - static var imageGenerator = GenerateCryptoKittyPNGFromSVG() - - let tokenHolder: TokenHolder + private static var imageGenerator = GenerateCryptoKittyPNGFromSVG() + private let tokenHolder: TokenHolder let areDetailsVisible: Bool - var bigImage: Promise? init(tokenHolder: TokenHolder, areDetailsVisible: Bool) { diff --git a/AlphaWallet/Tokens/ViewModels/EthCurrencyHelper.swift b/AlphaWallet/Tokens/ViewModels/EthCurrencyHelper.swift index 8e4a12c1b..d40644503 100644 --- a/AlphaWallet/Tokens/ViewModels/EthCurrencyHelper.swift +++ b/AlphaWallet/Tokens/ViewModels/EthCurrencyHelper.swift @@ -8,7 +8,8 @@ class EthCurrencyHelper { case depreciate(percentageChange24h: Double) case none } - var ticker: CoinTicker? + private var ticker: CoinTicker? + var change24h: Change24h { if let value = percentageChange24h { if isValueAppreciated24h { diff --git a/AlphaWallet/Tokens/ViewModels/EthTokenViewCellViewModel.swift b/AlphaWallet/Tokens/ViewModels/EthTokenViewCellViewModel.swift index 8bc3e8972..6ab45cede 100644 --- a/AlphaWallet/Tokens/ViewModels/EthTokenViewCellViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/EthTokenViewCellViewModel.swift @@ -9,7 +9,7 @@ struct EthTokenViewCellViewModel { private let token: TokenObject private let currencyAmount: String? private let currencyAmountWithoutSymbol: Double? - let ticker: CoinTicker? + private let ticker: CoinTicker? init( token: TokenObject, diff --git a/AlphaWallet/Tokens/ViewModels/ImportWalletHelpBubbleViewViewModel.swift b/AlphaWallet/Tokens/ViewModels/ImportWalletHelpBubbleViewViewModel.swift index 645f8e4cd..ec93113c4 100644 --- a/AlphaWallet/Tokens/ViewModels/ImportWalletHelpBubbleViewViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/ImportWalletHelpBubbleViewViewModel.swift @@ -6,12 +6,15 @@ struct ImportWalletHelpBubbleViewViewModel { var textColor: UIColor { return UIColor(red: 250, green: 209, blue: 0) } + var textFont: UIFont { return Fonts.semibold(size: 18)! } + var descriptionColor: UIColor { return Colors.appText } + var descriptionFont: UIFont { return Fonts.regular(size: 15)! } diff --git a/AlphaWallet/Tokens/ViewModels/TokenListFormatRowViewModel.swift b/AlphaWallet/Tokens/ViewModels/TokenListFormatRowViewModel.swift index f54876fd1..2b62de36d 100644 --- a/AlphaWallet/Tokens/ViewModels/TokenListFormatRowViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/TokenListFormatRowViewModel.swift @@ -3,7 +3,7 @@ import UIKit struct TokenListFormatRowViewModel { - var tokenHolder: TokenHolder + let tokenHolder: TokenHolder var contentsBackgroundColor: UIColor { return Colors.appWhite @@ -66,7 +66,7 @@ struct TokenListFormatRowViewModel { } var tokenCount: String { - return "x\(tokenHolder.tokens.count)" + return "x\(tokenHolder.count)" } var title: String { diff --git a/AlphaWallet/Tokens/ViewModels/TokensCardViewModel.swift b/AlphaWallet/Tokens/ViewModels/TokensCardViewModel.swift index 23be7f240..0ac8b8457 100644 --- a/AlphaWallet/Tokens/ViewModels/TokensCardViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/TokensCardViewModel.swift @@ -10,9 +10,8 @@ import Foundation import UIKit struct TokensCardViewModel { - - var token: TokenObject - var tokenHolders: [TokenHolder] + let token: TokenObject + let tokenHolders: [TokenHolder] init(token: TokenObject) { self.token = token diff --git a/AlphaWallet/Tokens/ViewModels/TokensViewModel.swift b/AlphaWallet/Tokens/ViewModels/TokensViewModel.swift index 00fda00ae..01500c381 100644 --- a/AlphaWallet/Tokens/ViewModels/TokensViewModel.swift +++ b/AlphaWallet/Tokens/ViewModels/TokensViewModel.swift @@ -5,20 +5,8 @@ import UIKit //Must be a class, and not a struct, otherwise changing `filter` will silently create a copy of TokensViewModel when user taps to change the filter in the UI and break filtering class TokensViewModel { - var tokens: [TokenObject] = [] - var tickers: [String: CoinTicker]? - var etherTokenContract: String - var filter: WalletFilter = .all - var filteredTokens: [TokenObject] { - switch filter { - case .all: - return tokens - case .currencyOnly: - return tokens.filter { $0.type == .ether || $0.type == .erc20 } - case .assetsOnly: - return tokens.filter { $0.type != .ether && $0.type != .erc20 } - } - } + private let tokens: [TokenObject] + private let tickers: [String: CoinTicker]? private var amount: String? { var totalAmount: Double = 0 @@ -37,6 +25,19 @@ class TokensViewModel { return tokenValue * price } + let etherTokenContract: String + var filter: WalletFilter = .all + var filteredTokens: [TokenObject] { + switch filter { + case .all: + return tokens + case .currencyOnly: + return tokens.filter { $0.type == .ether || $0.type == .erc20 } + case .assetsOnly: + return tokens.filter { $0.type != .ether && $0.type != .erc20 } + } + } + var headerBackgroundColor: UIColor { return .white } diff --git a/AlphaWallet/Tokens/Views/CryptoKitties/CryptoKittyCardRowView.swift b/AlphaWallet/Tokens/Views/CryptoKitties/CryptoKittyCardRowView.swift index daad69af4..ddc58947d 100644 --- a/AlphaWallet/Tokens/Views/CryptoKitties/CryptoKittyCardRowView.swift +++ b/AlphaWallet/Tokens/Views/CryptoKitties/CryptoKittyCardRowView.swift @@ -8,11 +8,7 @@ protocol CryptoKittyCardRowViewDelegate: class { } class CryptoKittyCardRowView: UIView { - let checkboxImageView = UIImageView(image: R.image.ticket_bundle_unchecked()) - weak var delegate: CryptoKittyCardRowViewDelegate? - let background = UIView() private let mainVerticalStackView: UIStackView = [].asStackView(axis: .vertical, contentHuggingPriority: .required) - let stateLabel = UILabel() private let thumbnailImageView = UIImageView() private let bigImageBackground = UIView() private let bigImageView = UIImageView() @@ -62,6 +58,12 @@ class CryptoKittyCardRowView: UIView { private var viewsVisibleWhenDetailsAreNotVisibleImagesNotAvailable = [UIView]() private var currentDisplayedImageUrl: URL? + var background = UIView() + var stateLabel = UILabel() + + let checkboxImageView = UIImageView(image: R.image.ticket_bundle_unchecked()) + weak var delegate: CryptoKittyCardRowViewDelegate? + init(showCheckbox: Bool = false) { self.showCheckbox = showCheckbox diff --git a/AlphaWallet/Tokens/Views/NonFungibleTokenViewCell.swift b/AlphaWallet/Tokens/Views/NonFungibleTokenViewCell.swift index 3f4cb9dfb..9f59f0fe9 100644 --- a/AlphaWallet/Tokens/Views/NonFungibleTokenViewCell.swift +++ b/AlphaWallet/Tokens/Views/NonFungibleTokenViewCell.swift @@ -7,11 +7,11 @@ import Kingfisher class NonFungibleTokenViewCell: UITableViewCell { static let identifier = "NonFugibleTokenViewCell" - let background = UIView() - let titleLabel = UILabel() - let blockchainLabel = UILabel() - let separator = UILabel() - let issuerLabel = UILabel() + private let background = UIView() + private let titleLabel = UILabel() + private let blockchainLabel = UILabel() + private let separator = UILabel() + private let issuerLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/Tokens/Views/TextField.swift b/AlphaWallet/Tokens/Views/TextField.swift index 6529922f9..3de8d734e 100644 --- a/AlphaWallet/Tokens/Views/TextField.swift +++ b/AlphaWallet/Tokens/Views/TextField.swift @@ -15,8 +15,12 @@ class TextField: UIControl { case none } + private var isConfigured = false + let label = UILabel() let textField = UITextField() + weak var delegate: TextFieldDelegate? + var value: String { get { return textField.text ?? "" @@ -25,6 +29,7 @@ class TextField: UIControl { textField.text = newValue } } + var inputAccessoryButtonType = InputAccessoryButtonType.none { didSet { switch inputAccessoryButtonType { @@ -37,8 +42,6 @@ class TextField: UIControl { } } } - private var isConfigured = false - weak var delegate: TextFieldDelegate? init() { super.init(frame: .zero) diff --git a/AlphaWallet/Tokens/Views/TokenViewCell.swift b/AlphaWallet/Tokens/Views/TokenViewCell.swift index 6b51938fa..b48296ced 100644 --- a/AlphaWallet/Tokens/Views/TokenViewCell.swift +++ b/AlphaWallet/Tokens/Views/TokenViewCell.swift @@ -7,11 +7,11 @@ import Kingfisher class TokenViewCell: UITableViewCell { static let identifier = "TokenViewCell" - let background = UIView() - let titleLabel = UILabel() - let blockchainLabel = UILabel() - let separator = UILabel() - let issuerLabel = UILabel() + private let background = UIView() + private let titleLabel = UILabel() + private let blockchainLabel = UILabel() + private let separator = UILabel() + private let issuerLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/Tokens/Views/TokensCardViewControllerTitleHeader.swift b/AlphaWallet/Tokens/Views/TokensCardViewControllerTitleHeader.swift index cddcbab8b..105ac6bab 100644 --- a/AlphaWallet/Tokens/Views/TokensCardViewControllerTitleHeader.swift +++ b/AlphaWallet/Tokens/Views/TokensCardViewControllerTitleHeader.swift @@ -3,8 +3,8 @@ import UIKit class TokensCardViewControllerTitleHeader: UIView { - let background = UIView() - let titleLabel = UILabel() + private let background = UIView() + private let titleLabel = UILabel() override init(frame: CGRect) { super.init(frame: frame) diff --git a/AlphaWallet/Transactions/Coordinators/BalanceCoordinator.swift b/AlphaWallet/Transactions/Coordinators/BalanceCoordinator.swift index d662f047f..d7312deef 100644 --- a/AlphaWallet/Transactions/Coordinators/BalanceCoordinator.swift +++ b/AlphaWallet/Transactions/Coordinators/BalanceCoordinator.swift @@ -11,17 +11,20 @@ protocol BalanceCoordinatorDelegate: class { } class BalanceCoordinator { - let wallet: Wallet - let storage: TokensDataStore + private let wallet: Wallet + private let storage: TokensDataStore + var balance: Balance? var currencyRate: CurrencyRate? weak var delegate: BalanceCoordinatorDelegate? + var viewModel: BalanceViewModel { return BalanceViewModel( balance: balance, rate: currencyRate ) } + init( wallet: Wallet, config: Config, diff --git a/AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift b/AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift index 973d89a9d..349e85563 100644 --- a/AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift +++ b/AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift @@ -27,7 +27,6 @@ protocol TokensCardCoordinatorDelegate: class, CanOpenURL { } class TokensCardCoordinator: NSObject, Coordinator { - private let keystore: Keystore private let token: TokenObject private lazy var rootViewController: TokensCardViewController = { @@ -35,19 +34,21 @@ class TokensCardCoordinator: NSObject, Coordinator { return makeTokensCardViewController(with: session.account, viewModel: viewModel) }() - weak var delegate: TokensCardCoordinatorDelegate? - private let session: WalletSession private let tokensStorage: TokensDataStore - let navigationController: UINavigationController - var coordinators: [Coordinator] = [] private let ethPrice: Subscribable private let assetDefinitionStore: AssetDefinitionStore + + weak var delegate: TokensCardCoordinatorDelegate? + let navigationController: UINavigationController + var coordinators: [Coordinator] = [] + var isReadOnly = false { didSet { rootViewController.isReadOnly = isReadOnly } } + init( session: WalletSession, navigationController: UINavigationController = NavigationController(), diff --git a/AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift b/AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift index f99bd340e..122147e1f 100644 --- a/AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift +++ b/AlphaWallet/Transactions/Coordinators/TransactionCoordinator.swift @@ -11,9 +11,9 @@ protocol TransactionCoordinatorDelegate: class, CanOpenURL { } class TransactionCoordinator: Coordinator { - private let keystore: Keystore - let storage: TransactionsStorage + private let storage: TransactionsStorage + lazy var rootViewController: TransactionsViewController = { return makeTransactionsController(with: session.account) }() diff --git a/AlphaWallet/Transactions/Coordinators/TransactionDataCoordinator.swift b/AlphaWallet/Transactions/Coordinators/TransactionDataCoordinator.swift index 9d2fe8e39..a68b16009 100644 --- a/AlphaWallet/Transactions/Coordinators/TransactionDataCoordinator.swift +++ b/AlphaWallet/Transactions/Coordinators/TransactionDataCoordinator.swift @@ -20,29 +20,29 @@ protocol TransactionDataCoordinatorDelegate: class { } class TransactionDataCoordinator { - struct Config { static let deleteMissingInternalSeconds: Double = 60.0 static let deleyedTransactionInternalSeconds: Double = 60.0 } - let storage: TransactionsStorage - let session: WalletSession + private let storage: TransactionsStorage + private let session: WalletSession private let keystore: Keystore - let config = Config() - var viewModel: TransactionsViewModel { + private let config = Config() + private var viewModel: TransactionsViewModel { return .init(transactions: storage.objects) } - var timer: Timer? - var updateTransactionsTimer: Timer? + private var timer: Timer? + private var updateTransactionsTimer: Timer? - weak var delegate: TransactionDataCoordinatorDelegate? private lazy var transactionsTracker: TransactionsTracker = { return TransactionsTracker(sessionID: session.sessionID) }() private let trustProvider = TrustProviderFactory.makeProvider() private var previousTransactions: [Transaction]? + weak var delegate: TransactionDataCoordinatorDelegate? + init( session: WalletSession, storage: TransactionsStorage, diff --git a/AlphaWallet/Transactions/Storage/TransactionsStorage.swift b/AlphaWallet/Transactions/Storage/TransactionsStorage.swift index 0dcea45d7..80182c416 100644 --- a/AlphaWallet/Transactions/Storage/TransactionsStorage.swift +++ b/AlphaWallet/Transactions/Storage/TransactionsStorage.swift @@ -5,12 +5,9 @@ import RealmSwift import TrustKeystore class TransactionsStorage { - let realm: Realm - init( - realm: Realm - ) { + init(realm: Realm) { self.realm = realm } diff --git a/AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift b/AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift index 73c21d317..e120f16d5 100644 --- a/AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift +++ b/AlphaWallet/Transactions/ViewControllers/TransactionViewController.swift @@ -9,7 +9,6 @@ protocol TransactionViewControllerDelegate: class, CanOpenURL { } class TransactionViewController: UIViewController { - private lazy var viewModel: TransactionDetailsViewModel = { return .init( transaction: transaction, @@ -19,10 +18,9 @@ class TransactionViewController: UIViewController { currencyRate: session.balanceCoordinator.currencyRate ) }() - let stackViewController = StackViewController() - - let session: WalletSession - let transaction: Transaction + private let stackViewController = StackViewController() + private let session: WalletSession + private let transaction: Transaction weak var delegate: TransactionViewControllerDelegate? diff --git a/AlphaWallet/Transactions/ViewControllers/TransactionsViewController.swift b/AlphaWallet/Transactions/ViewControllers/TransactionsViewController.swift index 68ecebe3e..220779ccd 100644 --- a/AlphaWallet/Transactions/ViewControllers/TransactionsViewController.swift +++ b/AlphaWallet/Transactions/ViewControllers/TransactionsViewController.swift @@ -14,21 +14,25 @@ protocol TransactionsViewControllerDelegate: class { } class TransactionsViewController: UIViewController { + private var viewModel: TransactionsViewModel + private let tokensStorage: TokensDataStore + private let account: Wallet + private let tableView = UITableView(frame: .zero, style: .plain) + private let refreshControl = UIRefreshControl() + private let dataCoordinator: TransactionDataCoordinator + private let session: WalletSession + private var actionButtonsVisibleConstraint: NSLayoutConstraint? + private var actionButtonsInVisibleConstraint: NSLayoutConstraint? + private let footerBar: UIView = { + let footerBar = UIView() + footerBar.translatesAutoresizingMaskIntoConstraints = false + footerBar.backgroundColor = Colors.appHighlightGreen + return footerBar + }() - var viewModel: TransactionsViewModel var paymentType: PaymentFlow? - - let tokensStorage: TokensDataStore - let account: Wallet - - let tableView = UITableView(frame: .zero, style: .plain) - let refreshControl = UIRefreshControl() - weak var delegate: TransactionsViewControllerDelegate? - let dataCoordinator: TransactionDataCoordinator - let session: WalletSession - var actionButtonsVisibleConstraint: NSLayoutConstraint? - var actionButtonsInVisibleConstraint: NSLayoutConstraint? + var showActionButtons = false { didSet { reflectActionButtonsVisibility() @@ -41,12 +45,7 @@ class TransactionsViewController: UIViewController { footerView.sendButton.addTarget(self, action: #selector(send), for: .touchUpInside) return footerView }() - let footerBar: UIView = { - let footerBar = UIView() - footerBar.translatesAutoresizingMaskIntoConstraints = false - footerBar.backgroundColor = Colors.appHighlightGreen - return footerBar - }() + init( account: Wallet, diff --git a/AlphaWallet/Transactions/ViewModels/BalanceTokenViewModel.swift b/AlphaWallet/Transactions/ViewModels/BalanceTokenViewModel.swift index 36d71b32e..d81d28729 100644 --- a/AlphaWallet/Transactions/ViewModels/BalanceTokenViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/BalanceTokenViewModel.swift @@ -3,7 +3,6 @@ import Foundation struct BalanceTokenViewModel: BalanceBaseViewModel { - let token: TokenObject var currencyAmount: String? { diff --git a/AlphaWallet/Transactions/ViewModels/BalanceViewModel.swift b/AlphaWallet/Transactions/ViewModels/BalanceViewModel.swift index 8d56abc1d..5227c1080 100644 --- a/AlphaWallet/Transactions/ViewModels/BalanceViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/BalanceViewModel.swift @@ -4,10 +4,9 @@ import Foundation import UIKit struct BalanceViewModel: BalanceBaseViewModel { - - let balance: Balance? - let rate: CurrencyRate? - let config: Config + private let balance: Balance? + private let rate: CurrencyRate? + private let config: Config init( balance: Balance? = .none, diff --git a/AlphaWallet/Transactions/ViewModels/TransactionCellViewModel.swift b/AlphaWallet/Transactions/ViewModels/TransactionCellViewModel.swift index 54157d628..5c5eb2fd8 100644 --- a/AlphaWallet/Transactions/ViewModels/TransactionCellViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/TransactionCellViewModel.swift @@ -5,7 +5,6 @@ import Foundation import UIKit struct TransactionCellViewModel { - private let transaction: Transaction private let config: Config private let chainState: ChainState diff --git a/AlphaWallet/Transactions/ViewModels/TransactionDetailsViewModel.swift b/AlphaWallet/Transactions/ViewModels/TransactionDetailsViewModel.swift index 5fd980baa..fa58fcce5 100644 --- a/AlphaWallet/Transactions/ViewModels/TransactionDetailsViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/TransactionDetailsViewModel.swift @@ -6,7 +6,6 @@ import UIKit struct TransactionDetailsViewModel { private let transactionViewModel: TransactionViewModel - private let transaction: Transaction private let config: Config private let chainState: ChainState diff --git a/AlphaWallet/Transactions/ViewModels/TransactionViewModel.swift b/AlphaWallet/Transactions/ViewModels/TransactionViewModel.swift index 007a32ad5..e1ba7a3a0 100644 --- a/AlphaWallet/Transactions/ViewModels/TransactionViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/TransactionViewModel.swift @@ -5,7 +5,6 @@ import UIKit import BigInt struct TransactionViewModel { - private let transaction: Transaction private let config: Config private let chainState: ChainState diff --git a/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift b/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift index c88b2e980..5e159096d 100644 --- a/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift @@ -7,9 +7,8 @@ struct TransactionsViewModel { private var formatter: DateFormatter { return Date.formatter(with: "dd MMM yyyy") } - - var items: [(date: String, transactions: [Transaction])] = [] - let config: Config + private var items: [(date: String, transactions: [Transaction])] = [] + private let config: Config init( transactions: [Transaction] = [], diff --git a/AlphaWallet/Transactions/Views/TransactionHeaderView.swift b/AlphaWallet/Transactions/Views/TransactionHeaderView.swift index 15d7af5b8..08bbfd8bd 100644 --- a/AlphaWallet/Transactions/Views/TransactionHeaderView.swift +++ b/AlphaWallet/Transactions/Views/TransactionHeaderView.swift @@ -4,11 +4,9 @@ import Foundation import UIKit class TransactionHeaderView: UIView { - let amountLabel = UILabel(frame: .zero) override init(frame: CGRect = .zero) { - super.init(frame: frame) amountLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/AlphaWallet/Transactions/Views/TransactionViewCell.swift b/AlphaWallet/Transactions/Views/TransactionViewCell.swift index 57fc8c2e4..1572a787a 100644 --- a/AlphaWallet/Transactions/Views/TransactionViewCell.swift +++ b/AlphaWallet/Transactions/Views/TransactionViewCell.swift @@ -3,14 +3,13 @@ import UIKit class TransactionViewCell: UITableViewCell { - static let identifier = "TransactionTableViewCell" - let background = UIView() - let statusImageView = UIImageView() - let titleLabel = UILabel() - let amountLabel = UILabel() - let subTitleLabel = UILabel() + private let background = UIView() + private let statusImageView = UIImageView() + private let titleLabel = UILabel() + private let amountLabel = UILabel() + private let subTitleLabel = UILabel() override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) diff --git a/AlphaWallet/Transactions/Views/TransactionsEmptyView.swift b/AlphaWallet/Transactions/Views/TransactionsEmptyView.swift index c7483630e..730846237 100644 --- a/AlphaWallet/Transactions/Views/TransactionsEmptyView.swift +++ b/AlphaWallet/Transactions/Views/TransactionsEmptyView.swift @@ -5,16 +5,16 @@ import UIKit import StatefulViewController class TransactionsEmptyView: UIView { - - let titleLabel = UILabel() - let imageView = UIImageView() - let button = Button(size: .normal, style: .solid) - let depositButton = Button(size: .normal, style: .solid) - let insets: UIEdgeInsets + private let titleLabel = UILabel() + private let imageView = UIImageView() + private let button = Button(size: .normal, style: .solid) + private let depositButton = Button(size: .normal, style: .solid) + private let insets: UIEdgeInsets private var onRetry: (() -> Void)? = .none - var onDeposit: ((_ sender: UIButton) -> Void)? = .none private let viewModel = StateViewModel() + var onDeposit: ((_ sender: UIButton) -> Void)? = .none + var isDepositAvailable: Bool = true { didSet { depositButton.isHidden = !isDepositAvailable diff --git a/AlphaWallet/Transactions/Views/TransactionsFooterView.swift b/AlphaWallet/Transactions/Views/TransactionsFooterView.swift index df4f5c51a..93f55eafb 100644 --- a/AlphaWallet/Transactions/Views/TransactionsFooterView.swift +++ b/AlphaWallet/Transactions/Views/TransactionsFooterView.swift @@ -4,7 +4,6 @@ import Foundation import UIKit class TransactionsFooterView: UIView { - lazy var sendButton: UIButton = { let sendButton = UIButton(type: .system) sendButton.translatesAutoresizingMaskIntoConstraints = false diff --git a/AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift b/AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift index 78004c5d0..b85a98b87 100644 --- a/AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift +++ b/AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift @@ -20,26 +20,27 @@ public struct PreviewTransaction { } class TransactionConfigurator { + private let session: WalletSession + private let account: Account - let session: WalletSession - let account: Account - let transaction: UnconfirmedTransaction - var configuration: TransactionConfiguration { - didSet { - configurationUpdate.value = configuration - } - } - - lazy var calculatedGasPrice: BigInt = { + private lazy var calculatedGasPrice: BigInt = { return transaction.gasPrice ?? configuration.gasPrice }() - var requestEstimateGas: Bool { + private var requestEstimateGas: Bool { return transaction.gasLimit == .none } + let transaction: UnconfirmedTransaction + var configurationUpdate: Subscribable = Subscribable(nil) + var configuration: TransactionConfiguration { + didSet { + configurationUpdate.value = configuration + } + } + init( session: WalletSession, account: Account, diff --git a/AlphaWallet/Transfer/Coordinators/ConfirmCoordinator.swift b/AlphaWallet/Transfer/Coordinators/ConfirmCoordinator.swift index b2da12ae2..bd8fca38a 100644 --- a/AlphaWallet/Transfer/Coordinators/ConfirmCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/ConfirmCoordinator.swift @@ -10,15 +10,14 @@ protocol ConfirmCoordinatorDelegate: class { } class ConfirmCoordinator: Coordinator { + private let session: WalletSession + private let account: Account + private let keystore: Keystore + private let configurator: TransactionConfigurator + private let type: ConfirmType let navigationController: UINavigationController - let session: WalletSession - let account: Account - let keystore: Keystore - let configurator: TransactionConfigurator var didCompleted: ((Result) -> Void)? - let type: ConfirmType - var coordinators: [Coordinator] = [] weak var delegate: ConfirmCoordinatorDelegate? diff --git a/AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift b/AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift index 91f534bfb..a4106fe50 100644 --- a/AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift @@ -10,17 +10,16 @@ protocol PaymentCoordinatorDelegate: class, CanOpenURL { } class PaymentCoordinator: Coordinator { + private let session: WalletSession + private let flow: PaymentFlow + private let keystore: Keystore + private let storage: TokensDataStore + private let ethPrice: Subscribable + private let tokenHolders: [TokenHolder]! - let session: WalletSession weak var delegate: PaymentCoordinatorDelegate? - - let flow: PaymentFlow var coordinators: [Coordinator] = [] let navigationController: UINavigationController - let keystore: Keystore - let storage: TokensDataStore - let ethPrice: Subscribable - let tokenHolders: [TokenHolder]! init( navigationController: UINavigationController = UINavigationController(), diff --git a/AlphaWallet/Transfer/Coordinators/RequestCoordinator.swift b/AlphaWallet/Transfer/Coordinators/RequestCoordinator.swift index 2881b228f..cc2f98651 100644 --- a/AlphaWallet/Transfer/Coordinators/RequestCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/RequestCoordinator.swift @@ -8,18 +8,20 @@ protocol RequestCoordinatorDelegate: class { } class RequestCoordinator: Coordinator { + private let session: WalletSession - let session: WalletSession - let navigationController: UINavigationController - var coordinators: [Coordinator] = [] - weak var delegate: RequestCoordinatorDelegate? - lazy var requestViewController: RequestViewController = { - return makeRequestViewController() - }() private lazy var viewModel: RequestViewModel = { return .init(account: session.account, config: session.config) }() + private lazy var requestViewController: RequestViewController = { + return makeRequestViewController() + }() + + let navigationController: UINavigationController + var coordinators: [Coordinator] = [] + weak var delegate: RequestCoordinatorDelegate? + init( navigationController: UINavigationController = UINavigationController(), session: WalletSession diff --git a/AlphaWallet/Transfer/Coordinators/SendCoordinator.swift b/AlphaWallet/Transfer/Coordinators/SendCoordinator.swift index a003ab927..882b7ba7c 100644 --- a/AlphaWallet/Transfer/Coordinators/SendCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/SendCoordinator.swift @@ -11,22 +11,22 @@ protocol SendCoordinatorDelegate: class, CanOpenURL { } class SendCoordinator: Coordinator { + private let transferType: TransferType + private let session: WalletSession + private let account: Account + private let keystore: Keystore + private let storage: TokensDataStore + private let ethPrice: Subscribable + private let tokenHolders: [TokenHolder]! - let transferType: TransferType - let session: WalletSession - let account: Account - let navigationController: UINavigationController - let keystore: Keystore - let storage: TokensDataStore - let ethPrice: Subscribable - let tokenHolders: [TokenHolder]! - - var coordinators: [Coordinator] = [] - weak var delegate: SendCoordinatorDelegate? lazy var sendViewController: SendViewController = { return makeSendViewController() }() + let navigationController: UINavigationController + var coordinators: [Coordinator] = [] + weak var delegate: SendCoordinatorDelegate? + init( transferType: TransferType, navigationController: UINavigationController = UINavigationController(), diff --git a/AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift b/AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift index 6defd4caf..9c08b68ca 100644 --- a/AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift @@ -7,11 +7,10 @@ import JSONRPCKit import Result class SendTransactionCoordinator { - private let keystore: Keystore - let session: WalletSession - let formatter = EtherNumberFormatter.full - let confirmType: ConfirmType + private let session: WalletSession + private let formatter = EtherNumberFormatter.full + private let confirmType: ConfirmType init( session: WalletSession, diff --git a/AlphaWallet/Transfer/Coordinators/SignMessageCoordinator.swift b/AlphaWallet/Transfer/Coordinators/SignMessageCoordinator.swift index fa139c97d..38371f3af 100644 --- a/AlphaWallet/Transfer/Coordinators/SignMessageCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/SignMessageCoordinator.swift @@ -17,13 +17,11 @@ protocol SignMessageCoordinatorDelegate: class { } class SignMessageCoordinator: Coordinator { + private let navigationController: UINavigationController + private let keystore: Keystore + private let account: Account var coordinators: [Coordinator] = [] - - let navigationController: UINavigationController - let keystore: Keystore - let account: Account - weak var delegate: SignMessageCoordinatorDelegate? var didComplete: ((Result) -> Void)? diff --git a/AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift b/AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift index 55585d9c9..09017e476 100644 --- a/AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift +++ b/AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift @@ -11,18 +11,16 @@ protocol TransferNFTCoordinatorDelegate: class { } class TransferNFTCoordinator: Coordinator { - var coordinators: [Coordinator] = [] - let tokenHolder: TokenHolder - let walletAddress: String - let paymentFlow: PaymentFlow - let keystore: Keystore - let session: WalletSession - let account: Account - let viewController: UIViewController - var statusViewController: StatusViewController? - var address: Address? - weak var delegate: TransferNFTCoordinatorDelegate? - var status = StatusViewControllerViewModel.State.processing { + private let tokenHolder: TokenHolder + private let walletAddress: String + private let paymentFlow: PaymentFlow + private let keystore: Keystore + private let session: WalletSession + private let account: Account + private let viewController: UIViewController + private var statusViewController: StatusViewController? + private var address: Address? + private var status = StatusViewControllerViewModel.State.processing { didSet { guard let address = address else { return } let tokenTypeName = XMLHandler(contract: address.eip55String).getTokenTypeName(.singular) @@ -35,6 +33,9 @@ class TransferNFTCoordinator: Coordinator { } } + var coordinators: [Coordinator] = [] + weak var delegate: TransferNFTCoordinatorDelegate? + init(tokenHolder: TokenHolder, walletAddress: String, paymentFlow: PaymentFlow, keystore: Keystore, session: WalletSession, account: Account, on viewController: UIViewController) { self.tokenHolder = tokenHolder self.walletAddress = walletAddress diff --git a/AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift b/AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift index bfd57b7e3..3be267ed6 100644 --- a/AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/ChooseTokenCardTransferModeViewController.swift @@ -9,19 +9,19 @@ protocol ChooseTokenCardTransferModeViewControllerDelegate: class, CanOpenURL { } class ChooseTokenCardTransferModeViewController: UIViewController, TokenVerifiableStatusViewController { - let horizontalAdjustmentForLongMagicLinkButtonTitle = CGFloat(20) + private let horizontalAdjustmentForLongMagicLinkButtonTitle = CGFloat(20) + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tokenRowView: TokenRowView & UIView + private let generateMagicLinkButton = UIButton(type: .system) + private let transferNowButton = UIButton(type: .system) + private var viewModel: ChooseTokenCardTransferModeViewControllerViewModel + private let tokenHolder: TokenHolder let config: Config var contract: String { return viewModel.token.contract } - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tokenRowView: TokenRowView & UIView - let generateMagicLinkButton = UIButton(type: .system) - let transferNowButton = UIButton(type: .system) - var viewModel: ChooseTokenCardTransferModeViewControllerViewModel - let tokenHolder: TokenHolder let paymentFlow: PaymentFlow weak var delegate: ChooseTokenCardTransferModeViewControllerDelegate? diff --git a/AlphaWallet/Transfer/ViewControllers/ConfigureTransactionViewController.swift b/AlphaWallet/Transfer/ViewControllers/ConfigureTransactionViewController.swift index fe9cc1687..0675c356d 100644 --- a/AlphaWallet/Transfer/ViewControllers/ConfigureTransactionViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/ConfigureTransactionViewController.swift @@ -9,27 +9,19 @@ protocol ConfigureTransactionViewControllerDelegate: class { } class ConfigureTransactionViewController: FormViewController { - - let configuration: TransactionConfiguration - let config: Config - let transferType: TransferType - let currencyRate: CurrencyRate? + private let configuration: TransactionConfiguration + private let config: Config + private let transferType: TransferType + private let currencyRate: CurrencyRate? private let fullFormatter = EtherNumberFormatter.full - struct Values { + private struct Values { static let gasPrice = "gasPrice" static let gasLimit = "gasLimit" static let totalFee = "totalFee" static let data = "data" } - lazy var viewModel: ConfigureTransactionViewModel = { - return ConfigureTransactionViewModel( - config: config, - transferType: transferType - ) - }() - private var gasPriceRow: SliderTextFieldRow? { return form.rowBy(tag: Values.gasPrice) as? SliderTextFieldRow } @@ -60,6 +52,14 @@ class ConfigureTransactionViewController: FormViewController { return GasViewModel(fee: totalFee, symbol: config.server.symbol, currencyRate: currencyRate, formatter: fullFormatter) } + lazy var viewModel: ConfigureTransactionViewModel = { + return ConfigureTransactionViewModel( + config: config, + transferType: transferType + ) + }() + + weak var delegate: ConfigureTransactionViewControllerDelegate? init( diff --git a/AlphaWallet/Transfer/ViewControllers/ConfirmPaymentViewController.swift b/AlphaWallet/Transfer/ViewControllers/ConfirmPaymentViewController.swift index e74946fe9..4276008f6 100644 --- a/AlphaWallet/Transfer/ViewControllers/ConfirmPaymentViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/ConfirmPaymentViewController.swift @@ -17,24 +17,24 @@ enum ConfirmResult { } class ConfirmPaymentViewController: UIViewController { - private let keystore: Keystore //let transaction: UnconfirmedTransaction - let session: WalletSession - let stackViewController = StackViewController() - lazy var sendTransactionCoordinator = { + private let session: WalletSession + private let stackViewController = StackViewController() + private lazy var sendTransactionCoordinator = { return SendTransactionCoordinator(session: session, keystore: keystore, confirmType: confirmType) }() - lazy var submitButton: UIButton = { + private lazy var submitButton: UIButton = { let button = Button(size: .large, style: .solid) button.translatesAutoresizingMaskIntoConstraints = false button.setTitle(viewModel.sendButtonText, for: .normal) button.addTarget(self, action: #selector(send), for: .touchUpInside) return button }() - let viewModel = ConfirmPaymentViewModel() - var configurator: TransactionConfigurator - let confirmType: ConfirmType + private let viewModel = ConfirmPaymentViewModel() + private var configurator: TransactionConfigurator + private let confirmType: ConfirmType + var didCompleted: ((Result) -> Void)? init( diff --git a/AlphaWallet/Transfer/ViewControllers/GenerateTransferMagicLinkViewController.swift b/AlphaWallet/Transfer/ViewControllers/GenerateTransferMagicLinkViewController.swift index f4d9df30b..2a8ffc164 100644 --- a/AlphaWallet/Transfer/ViewControllers/GenerateTransferMagicLinkViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/GenerateTransferMagicLinkViewController.swift @@ -9,19 +9,20 @@ protocol GenerateTransferMagicLinkViewControllerDelegate: class { } class GenerateTransferMagicLinkViewController: UIViewController { - weak var delegate: GenerateTransferMagicLinkViewControllerDelegate? - let background = UIView() - let header = TokensCardViewControllerTitleHeader() - let detailsBackground = UIView() - let subtitleLabel = UILabel() - let tokenCountLabel = UILabel() - let descriptionLabel = UILabel() - let actionButton = UIButton() - let cancelButton = UIButton() + private let background = UIView() + private let header = TokensCardViewControllerTitleHeader() + private let detailsBackground = UIView() + private let subtitleLabel = UILabel() + private let tokenCountLabel = UILabel() + private let descriptionLabel = UILabel() + private let actionButton = UIButton() + private let cancelButton = UIButton() + private var viewModel: GenerateTransferMagicLinkViewControllerViewModel? + let paymentFlow: PaymentFlow let tokenHolder: TokenHolder let linkExpiryDate: Date - var viewModel: GenerateTransferMagicLinkViewControllerViewModel? + weak var delegate: GenerateTransferMagicLinkViewControllerDelegate? init(paymentFlow: PaymentFlow, tokenHolder: TokenHolder, linkExpiryDate: Date) { self.paymentFlow = paymentFlow diff --git a/AlphaWallet/Transfer/ViewControllers/RequestViewController.swift b/AlphaWallet/Transfer/ViewControllers/RequestViewController.swift index 8078cd67a..a687e2bdd 100644 --- a/AlphaWallet/Transfer/ViewControllers/RequestViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/RequestViewController.swift @@ -9,21 +9,21 @@ import StackViewController //Careful to fit in shorter phone like iPhone 5s without needing to scroll class RequestViewController: UIViewController { - let roundedBackground: RoundedBackground = { + private let roundedBackground: RoundedBackground = { let roundedBackground = RoundedBackground() roundedBackground.translatesAutoresizingMaskIntoConstraints = false return roundedBackground }() - let stackViewController = StackViewController() + private let stackViewController = StackViewController() - lazy var imageView: UIImageView = { + private lazy var imageView: UIImageView = { let imageView = UIImageView() imageView.translatesAutoresizingMaskIntoConstraints = false return imageView }() - lazy var copyButton: UIButton = { + private lazy var copyButton: UIButton = { let button = Button(size: .normal, style: .border) button.translatesAutoresizingMaskIntoConstraints = false button.titleLabel?.font = viewModel.buttonFont @@ -34,7 +34,7 @@ class RequestViewController: UIViewController { return button }() - lazy var addressHintLabel: UILabel = { + private lazy var addressHintLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.textColor = viewModel.labelColor @@ -44,7 +44,7 @@ class RequestViewController: UIViewController { return label }() - lazy var instructionLabel: UILabel = { + private lazy var instructionLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.textColor = viewModel.labelColor @@ -54,14 +54,14 @@ class RequestViewController: UIViewController { return label }() - lazy var addressContainerView: UIView = { + private lazy var addressContainerView: UIView = { let v = UIView() v.translatesAutoresizingMaskIntoConstraints = false v.backgroundColor = viewModel.addressBackgroundColor return v }() - lazy var addressLabel: UILabel = { + private lazy var addressLabel: UILabel = { let label = UILabel(frame: .zero) label.translatesAutoresizingMaskIntoConstraints = false label.textColor = viewModel.labelColor @@ -73,11 +73,9 @@ class RequestViewController: UIViewController { return label }() - let viewModel: RequestViewModel + private let viewModel: RequestViewModel - init( - viewModel: RequestViewModel - ) { + init(viewModel: RequestViewModel) { self.viewModel = viewModel stackViewController.scrollView.alwaysBounceVertical = true diff --git a/AlphaWallet/Transfer/ViewControllers/SendViewController.swift b/AlphaWallet/Transfer/ViewControllers/SendViewController.swift index 0a366b207..400e1f02d 100644 --- a/AlphaWallet/Transfer/ViewControllers/SendViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/SendViewController.swift @@ -20,15 +20,14 @@ protocol SendViewControllerDelegate: class, CanOpenURL { } class SendViewController: UIViewController, CanScanQRCode, TokenVerifiableStatusViewController { - let roundedBackground = RoundedBackground() - let header = SendHeaderView() - let targetAddressTextField = AddressTextField() - let amountTextField = AmountTextField() - let targetAddressLabel = UILabel() - let amountLabel = UILabel() - let myAddressContainer = UIView() - let myAddressLabelLabel = UILabel() - let myAddressLabel: UILabel = { + private let roundedBackground = RoundedBackground() + private let header = SendHeaderView() + private let amountTextField = AmountTextField() + private let targetAddressLabel = UILabel() + private let amountLabel = UILabel() + private let myAddressContainer = UIView() + private let myAddressLabelLabel = UILabel() + private let myAddressLabel: UILabel = { let label = UILabel(frame: .zero) label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 @@ -37,24 +36,32 @@ class SendViewController: UIViewController, CanScanQRCode, TokenVerifiableStatus label.adjustsFontSizeToFitWidth = true return label }() - let copyButton: UIButton = { + private let copyButton: UIButton = { let button = Button(size: .normal, style: .border) button.translatesAutoresizingMaskIntoConstraints = false button.addTarget(self, action: #selector(copyAddress), for: .touchUpInside) return button }() - let imageView: UIImageView = { + private let imageView: UIImageView = { let imageView = UIImageView() imageView.translatesAutoresizingMaskIntoConstraints = false return imageView }() - let nextButton = UIButton(type: .system) + private let nextButton = UIButton(type: .system) + private var viewModel: SendViewModel! + private var headerViewModel = SendHeaderViewViewModel() + private var balanceViewModel: BalanceBaseViewModel? + private let session: WalletSession + private let account: Account + private let ethPrice: Subscribable + private var gasPrice: BigInt? + private var data = Data() + private lazy var decimalFormatter: DecimalFormatter = { + return DecimalFormatter() + }() - var viewModel: SendViewModel! - var headerViewModel = SendHeaderViewViewModel() - var balanceViewModel: BalanceBaseViewModel? + let targetAddressTextField = AddressTextField() weak var delegate: SendViewControllerDelegate? - let config: Config var contract: String { //Only ERC20 tokens are relevant here @@ -73,17 +80,8 @@ class SendViewController: UIViewController, CanScanQRCode, TokenVerifiableStatus return "0x" } } - - let session: WalletSession - let account: Account let transferType: TransferType let storage: TokensDataStore - let ethPrice: Subscribable - private var gasPrice: BigInt? - private var data = Data() - lazy var decimalFormatter: DecimalFormatter = { - return DecimalFormatter() - }() init( session: WalletSession, diff --git a/AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift b/AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift index b689a8f62..6c8d11fb1 100644 --- a/AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/SetTransferTokensCardExpiryDateViewController.swift @@ -8,28 +8,28 @@ protocol SetTransferTokensCardExpiryDateViewControllerDelegate: class, CanOpenUR } class SetTransferTokensCardExpiryDateViewController: UIViewController, TokenVerifiableStatusViewController { + private let roundedBackground = RoundedBackground() + private let scrollView = UIScrollView() + private let header = TokensCardViewControllerTitleHeader() + private let tokenRowView: TokenRowView & UIView + private let linkExpiryDateLabel = UILabel() + private let linkExpiryDateField = DateEntryField() + private let linkExpiryTimeLabel = UILabel() + private let linkExpiryTimeField = TimeEntryField() + private let datePicker = UIDatePicker() + private let timePicker = UIDatePicker() + private let descriptionLabel = UILabel() + private let noteTitleLabel = UILabel() + private let noteLabel = UILabel() + private let noteBorderView = UIView() + private let nextButton = UIButton(type: .system) + private var viewModel: SetTransferTokensCardExpiryDateViewControllerViewModel + private let tokenHolder: TokenHolder let config: Config var contract: String { return viewModel.token.contract } - let roundedBackground = RoundedBackground() - let scrollView = UIScrollView() - let header = TokensCardViewControllerTitleHeader() - let tokenRowView: TokenRowView & UIView - let linkExpiryDateLabel = UILabel() - let linkExpiryDateField = DateEntryField() - let linkExpiryTimeLabel = UILabel() - let linkExpiryTimeField = TimeEntryField() - let datePicker = UIDatePicker() - let timePicker = UIDatePicker() - let descriptionLabel = UILabel() - let noteTitleLabel = UILabel() - let noteLabel = UILabel() - let noteBorderView = UIView() - let nextButton = UIButton(type: .system) - var viewModel: SetTransferTokensCardExpiryDateViewControllerViewModel - let tokenHolder: TokenHolder let paymentFlow: PaymentFlow weak var delegate: SetTransferTokensCardExpiryDateViewControllerDelegate? diff --git a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift index e15ac133f..6d0dfc8cb 100644 --- a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardQuantitySelectionViewController.swift @@ -8,20 +8,20 @@ protocol TransferTokenCardQuantitySelectionViewControllerDelegate: class, CanOpe } class TransferTokensCardQuantitySelectionViewController: UIViewController, TokenVerifiableStatusViewController { + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let subtitleLabel = UILabel() + private let quantityStepper = NumberStepper() + private let tokenRowView: TokenRowView & UIView + private let nextButton = UIButton(type: .system) + private var viewModel: TransferTokensCardQuantitySelectionViewModel + private let token: TokenObject let config: Config var contract: String { return token.contract } - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let subtitleLabel = UILabel() - let quantityStepper = NumberStepper() - let tokenRowView: TokenRowView & UIView - let nextButton = UIButton(type: .system) - var viewModel: TransferTokensCardQuantitySelectionViewModel let paymentFlow: PaymentFlow - private let token: TokenObject weak var delegate: TransferTokenCardQuantitySelectionViewControllerDelegate? init( diff --git a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift index 9ad7d73a2..b34d9031e 100644 --- a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViaWalletAddressViewController.swift @@ -9,19 +9,20 @@ protocol TransferTokensCardViaWalletAddressViewControllerDelegate: class, CanOpe } class TransferTokensCardViaWalletAddressViewController: UIViewController, TokenVerifiableStatusViewController, CanScanQRCode { + private let token: TokenObject + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tokenRowView: TokenRowView & UIView + private let targetAddressTextField = AddressTextField() + private let nextButton = UIButton(type: .system) + private var viewModel: TransferTokensCardViaWalletAddressViewControllerViewModel + private var tokenHolder: TokenHolder + private var paymentFlow: PaymentFlow + let config: Config var contract: String { return token.contract } - private let token: TokenObject - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tokenRowView: TokenRowView & UIView - let targetAddressTextField = AddressTextField() - let nextButton = UIButton(type: .system) - var viewModel: TransferTokensCardViaWalletAddressViewControllerViewModel - var tokenHolder: TokenHolder - var paymentFlow: PaymentFlow weak var delegate: TransferTokensCardViaWalletAddressViewControllerDelegate? init( diff --git a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift index ba809a91e..e868b5a24 100644 --- a/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift +++ b/AlphaWallet/Transfer/ViewControllers/TransferTokensCardViewController.swift @@ -9,18 +9,18 @@ protocol TransferTokensCardViewControllerDelegate: class, CanOpenURL { } class TransferTokensCardViewController: UIViewController, TokenVerifiableStatusViewController { + private let roundedBackground = RoundedBackground() + private let header = TokensCardViewControllerTitleHeader() + private let tableView = UITableView(frame: .zero, style: .plain) + private let nextButton = UIButton(type: .system) + private var viewModel: TransferTokensCardViewModel + private let token: TokenObject let config: Config var contract: String { return viewModel.token.contract } - let roundedBackground = RoundedBackground() - let header = TokensCardViewControllerTitleHeader() - let tableView = UITableView(frame: .zero, style: .plain) - let nextButton = UIButton(type: .system) - var viewModel: TransferTokensCardViewModel var paymentFlow: PaymentFlow - private let token: TokenObject weak var delegate: TransferTokensCardViewControllerDelegate? init(config: Config, paymentFlow: PaymentFlow, token: TokenObject, viewModel: TransferTokensCardViewModel) { diff --git a/AlphaWallet/Transfer/ViewModels/ChooseTokenCardTransferModeViewControllerViewModel.swift b/AlphaWallet/Transfer/ViewModels/ChooseTokenCardTransferModeViewControllerViewModel.swift index 41a4be22e..aa905db31 100644 --- a/AlphaWallet/Transfer/ViewModels/ChooseTokenCardTransferModeViewControllerViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/ChooseTokenCardTransferModeViewControllerViewModel.swift @@ -4,7 +4,6 @@ import Foundation import UIKit struct ChooseTokenCardTransferModeViewControllerViewModel { - var token: TokenObject var tokenHolder: TokenHolder diff --git a/AlphaWallet/Transfer/ViewModels/ConfigureTransactionViewModel.swift b/AlphaWallet/Transfer/ViewModels/ConfigureTransactionViewModel.swift index ddb40b7ad..cef8899f0 100644 --- a/AlphaWallet/Transfer/ViewModels/ConfigureTransactionViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/ConfigureTransactionViewModel.swift @@ -3,9 +3,8 @@ import Foundation struct ConfigureTransactionViewModel { - - let config: Config - let transferType: TransferType + private let config: Config + private let transferType: TransferType init( config: Config, diff --git a/AlphaWallet/Transfer/ViewModels/ConfirmPaymentDetailsViewModel.swift b/AlphaWallet/Transfer/ViewModels/ConfirmPaymentDetailsViewModel.swift index ea47451ee..bdfd6ead8 100644 --- a/AlphaWallet/Transfer/ViewModels/ConfirmPaymentDetailsViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/ConfirmPaymentDetailsViewModel.swift @@ -4,25 +4,12 @@ import Foundation import BigInt struct ConfirmPaymentDetailsViewModel { - - let transaction: PreviewTransaction - let currentBalance: BalanceProtocol? - let currencyRate: CurrencyRate? - let config: Config + private let transaction: PreviewTransaction + private let currentBalance: BalanceProtocol? + private let currencyRate: CurrencyRate? + private let config: Config private let fullFormatter = EtherNumberFormatter.full - init( - transaction: PreviewTransaction, - config: Config = Config(), - currentBalance: BalanceProtocol?, - currencyRate: CurrencyRate? - ) { - self.transaction = transaction - self.currentBalance = currentBalance - self.config = config - self.currencyRate = currencyRate - } - private var gasViewModel: GasViewModel { return GasViewModel(fee: totalFee, symbol: config.server.symbol, currencyRate: currencyRate, formatter: fullFormatter) } @@ -35,6 +22,18 @@ struct ConfirmPaymentDetailsViewModel { return transaction.gasLimit } + init( + transaction: PreviewTransaction, + config: Config = Config(), + currentBalance: BalanceProtocol?, + currencyRate: CurrencyRate? + ) { + self.transaction = transaction + self.currentBalance = currentBalance + self.config = config + self.currencyRate = currencyRate + } + var amount: String { return fullFormatter.string(from: transaction.value) } diff --git a/AlphaWallet/Transfer/ViewModels/ConfirmPaymentViewModel.swift b/AlphaWallet/Transfer/ViewModels/ConfirmPaymentViewModel.swift index a0609eafd..0ee71a776 100644 --- a/AlphaWallet/Transfer/ViewModels/ConfirmPaymentViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/ConfirmPaymentViewModel.swift @@ -4,7 +4,6 @@ import Foundation import UIKit struct ConfirmPaymentViewModel { - var title: String { return R.string.localizable.confirmPaymentConfirmButtonTitle() } diff --git a/AlphaWallet/Transfer/ViewModels/RequestViewModel.swift b/AlphaWallet/Transfer/ViewModels/RequestViewModel.swift index ce3ea8e75..0c64c3832 100644 --- a/AlphaWallet/Transfer/ViewModels/RequestViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/RequestViewModel.swift @@ -6,9 +6,8 @@ import TrustKeystore import UIKit struct RequestViewModel { - - let account: Wallet - let config: Config + private let account: Wallet + private let config: Config init( account: Wallet, diff --git a/AlphaWallet/Transfer/ViewModels/SendViewModel.swift b/AlphaWallet/Transfer/ViewModels/SendViewModel.swift index 1ef369eea..73f249557 100644 --- a/AlphaWallet/Transfer/ViewModels/SendViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/SendViewModel.swift @@ -5,9 +5,9 @@ import UIKit import TrustKeystore struct SendViewModel { - let transferType: TransferType - let session: WalletSession - let storage: TokensDataStore + private let transferType: TransferType + private let session: WalletSession + private let storage: TokensDataStore init(transferType: TransferType, session: WalletSession, storage: TokensDataStore) { self.transferType = transferType diff --git a/AlphaWallet/Transfer/ViewModels/SetTransferTokensCardExpiryDateViewControllerViewModel.swift b/AlphaWallet/Transfer/ViewModels/SetTransferTokensCardExpiryDateViewControllerViewModel.swift index 74cc158a6..fe8a3c115 100644 --- a/AlphaWallet/Transfer/ViewModels/SetTransferTokensCardExpiryDateViewControllerViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/SetTransferTokensCardExpiryDateViewControllerViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct SetTransferTokensCardExpiryDateViewControllerViewModel { - - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName(.plural, titlecase: .titlecase) diff --git a/AlphaWallet/Transfer/ViewModels/TransferTokensCardQuantitySelectionViewModel.swift b/AlphaWallet/Transfer/ViewModels/TransferTokensCardQuantitySelectionViewModel.swift index c1ff84d6b..e13ca4677 100644 --- a/AlphaWallet/Transfer/ViewModels/TransferTokensCardQuantitySelectionViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/TransferTokensCardQuantitySelectionViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct TransferTokensCardQuantitySelectionViewModel { - - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName(.plural, titlecase: .titlecase) diff --git a/AlphaWallet/Transfer/ViewModels/TransferTokensCardViaWalletAddressViewControllerViewModel.swift b/AlphaWallet/Transfer/ViewModels/TransferTokensCardViaWalletAddressViewControllerViewModel.swift index 3281b0ba3..2dd72bf6b 100644 --- a/AlphaWallet/Transfer/ViewModels/TransferTokensCardViaWalletAddressViewControllerViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/TransferTokensCardViaWalletAddressViewControllerViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct TransferTokensCardViaWalletAddressViewControllerViewModel { - - var token: TokenObject - var tokenHolder: TokenHolder + let token: TokenObject + let tokenHolder: TokenHolder var headerTitle: String { let tokenTypeName = XMLHandler(contract: token.address.eip55String).getTokenTypeName(.plural, titlecase: .titlecase) diff --git a/AlphaWallet/Transfer/ViewModels/TransferTokensCardViewModel.swift b/AlphaWallet/Transfer/ViewModels/TransferTokensCardViewModel.swift index 48c1bfabb..346ecd00e 100644 --- a/AlphaWallet/Transfer/ViewModels/TransferTokensCardViewModel.swift +++ b/AlphaWallet/Transfer/ViewModels/TransferTokensCardViewModel.swift @@ -4,9 +4,8 @@ import Foundation import UIKit struct TransferTokensCardViewModel { - - var token: TokenObject - var tokenHolders: [TokenHolder] + let token: TokenObject + let tokenHolders: [TokenHolder] init(token: TokenObject) { self.token = token diff --git a/AlphaWallet/Transfer/Views/SendHeaderView.swift b/AlphaWallet/Transfer/Views/SendHeaderView.swift index 17717d207..d7f80784b 100644 --- a/AlphaWallet/Transfer/Views/SendHeaderView.swift +++ b/AlphaWallet/Transfer/Views/SendHeaderView.swift @@ -2,20 +2,18 @@ import UIKit class SendHeaderView: UIView { - let background = UIView() - let titleLabel = UILabel() - let blockchainLabel = UILabel() - let issuerLabel = UILabel() - - let middleBorder = UIView() - - var footerStackView: UIStackView? - let valuePercentageChangeValueLabel = UILabel() - let valuePercentageChangePeriodLabel = UILabel() - let valueChangeLabel = UILabel() - let valueChangeNameLabel = UILabel() - let valueLabel = UILabel() - let valueNameLabel = UILabel() + private let background = UIView() + private let titleLabel = UILabel() + private let blockchainLabel = UILabel() + private let issuerLabel = UILabel() + private let middleBorder = UIView() + private var footerStackView: UIStackView? + private let valuePercentageChangeValueLabel = UILabel() + private let valuePercentageChangePeriodLabel = UILabel() + private let valueChangeLabel = UILabel() + private let valueChangeNameLabel = UILabel() + private let valueLabel = UILabel() + private let valueNameLabel = UILabel() override init(frame: CGRect) { super.init(frame: frame) diff --git a/AlphaWallet/UI/AddressTextField.swift b/AlphaWallet/UI/AddressTextField.swift index 2dee55708..d2851ad9e 100644 --- a/AlphaWallet/UI/AddressTextField.swift +++ b/AlphaWallet/UI/AddressTextField.swift @@ -11,6 +11,8 @@ protocol AddressTextFieldDelegate: class { } class AddressTextField: UIControl { + private var isConfigured = false + let label = UILabel() let textField = UITextField() var value: String { @@ -21,7 +23,6 @@ class AddressTextField: UIControl { textField.text = newValue } } - private var isConfigured = false weak var delegate: AddressTextFieldDelegate? override init(frame: CGRect) { diff --git a/AlphaWallet/UI/BalanceTitleView.swift b/AlphaWallet/UI/BalanceTitleView.swift index be879cba6..9af55b2f2 100644 --- a/AlphaWallet/UI/BalanceTitleView.swift +++ b/AlphaWallet/UI/BalanceTitleView.swift @@ -8,6 +8,9 @@ enum BalanceMode { } class BalanceTitleView: UIView { + private let titleLabel = UILabel() + private let subTitleLabel = UILabel() + private var mode = BalanceMode.short @objc dynamic var titleTextColor: UIColor? { get { return titleLabel.textColor } @@ -19,15 +22,12 @@ class BalanceTitleView: UIView { set { subTitleLabel.textColor = newValue } } - let titleLabel = UILabel() - let subTitleLabel = UILabel() var viewModel: BalanceBaseViewModel? { didSet { guard let viewModel = viewModel else { return } configure(viewModel: viewModel) } } - private var mode = BalanceMode.short override init(frame: CGRect) { super.init(frame: .zero) diff --git a/AlphaWallet/UI/EmptyView.swift b/AlphaWallet/UI/EmptyView.swift index 1b5e6a12b..e93e88ecb 100644 --- a/AlphaWallet/UI/EmptyView.swift +++ b/AlphaWallet/UI/EmptyView.swift @@ -5,11 +5,10 @@ import UIKit import StatefulViewController class EmptyView: UIView { - - let titleLabel = UILabel() - let imageView = UIImageView() - let button = Button(size: .normal, style: .solid) - let insets: UIEdgeInsets + private let titleLabel = UILabel() + private let imageView = UIImageView() + private let button = Button(size: .normal, style: .solid) + private let insets: UIEdgeInsets private var onRetry: (() -> Void)? = .none private let viewModel = StateViewModel() diff --git a/AlphaWallet/UI/ErrorView.swift b/AlphaWallet/UI/ErrorView.swift index 932ca323b..beef69d43 100644 --- a/AlphaWallet/UI/ErrorView.swift +++ b/AlphaWallet/UI/ErrorView.swift @@ -5,12 +5,11 @@ import UIKit import StatefulViewController class ErrorView: UIView { - - let descriptionLabel = UILabel() - let imageView = UIImageView() - let button = Button(size: .normal, style: .solid) - let insets: UIEdgeInsets - var onRetry: (() -> Void)? = .none + private let descriptionLabel = UILabel() + private let imageView = UIImageView() + private let button = Button(size: .normal, style: .solid) + private let insets: UIEdgeInsets + private var onRetry: (() -> Void)? = .none private let viewModel = StateViewModel() init( diff --git a/AlphaWallet/UI/Form/EthereumAddressRule.swift b/AlphaWallet/UI/Form/EthereumAddressRule.swift index 30027a50f..c59454861 100644 --- a/AlphaWallet/UI/Form/EthereumAddressRule.swift +++ b/AlphaWallet/UI/Form/EthereumAddressRule.swift @@ -4,7 +4,6 @@ import Foundation import Eureka public struct EthereumAddressRule: RuleType { - public init(msg: String = "") { let msg = msg.isEmpty ? R.string.localizable.importWalletImportInvalidAddress() : msg self.validationError = ValidationError(msg: msg) diff --git a/AlphaWallet/UI/LoadingView.swift b/AlphaWallet/UI/LoadingView.swift index 204645795..9d4f10edb 100644 --- a/AlphaWallet/UI/LoadingView.swift +++ b/AlphaWallet/UI/LoadingView.swift @@ -5,12 +5,12 @@ import UIKit import StatefulViewController class LoadingView: UIView { + private let imageView = UIImageView() + private let insets: UIEdgeInsets + private let viewModel = StateViewModel() let label = UILabel() - let imageView = UIImageView() let loadingIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) - let insets: UIEdgeInsets - private let viewModel = StateViewModel() init( frame: CGRect = .zero, diff --git a/AlphaWallet/UI/NumberStepper.swift b/AlphaWallet/UI/NumberStepper.swift index 3d4cc0af1..3339f24b8 100755 --- a/AlphaWallet/UI/NumberStepper.swift +++ b/AlphaWallet/UI/NumberStepper.swift @@ -10,7 +10,6 @@ import UIKit @IBDesignable class NumberStepper: UIControl { - @IBInspectable public var stepValue: Int = 1 @IBInspectable public var minimumValue: Int = 0 @IBInspectable public var maximumValue: Int = 100 @@ -87,7 +86,7 @@ class NumberStepper: UIControl { } } - lazy var rightButton: UIButton = { + private lazy var rightButton: UIButton = { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("-", for: .normal) @@ -101,7 +100,7 @@ class NumberStepper: UIControl { return button }() - lazy var leftButton: UIButton = { + private lazy var leftButton: UIButton = { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.setTitle("+", for: .normal) @@ -115,7 +114,7 @@ class NumberStepper: UIControl { return button }() - lazy var label: UILabel = { + private lazy var label: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false label.textAlignment = .center @@ -130,7 +129,7 @@ class NumberStepper: UIControl { case Stable, ShouldIncrease, ShouldDecrease } - var stepperState = StepperState.Stable { + private var stepperState = StepperState.Stable { didSet { if stepperState != .Stable { updateValue() diff --git a/AlphaWallet/UI/ViewModels/TokenCardRowViewModel.swift b/AlphaWallet/UI/ViewModels/TokenCardRowViewModel.swift index f3806b9f3..1899bcbdd 100644 --- a/AlphaWallet/UI/ViewModels/TokenCardRowViewModel.swift +++ b/AlphaWallet/UI/ViewModels/TokenCardRowViewModel.swift @@ -3,7 +3,7 @@ import UIKit struct TokenCardRowViewModel: TokenCardRowViewModelProtocol { - var tokenHolder: TokenHolder + let tokenHolder: TokenHolder var tokenCount: String { return "x\(tokenHolder.tokens.count)" diff --git a/AlphaWallet/Vendors/Web3Swift/Web3Swift.swift b/AlphaWallet/Vendors/Web3Swift/Web3Swift.swift index 28acbba2d..6a3892c83 100644 --- a/AlphaWallet/Vendors/Web3Swift/Web3Swift.swift +++ b/AlphaWallet/Vendors/Web3Swift/Web3Swift.swift @@ -7,9 +7,9 @@ import Result import JavaScriptCore class Web3Swift: NSObject { + private let webView = WKWebView() + private let url: URL - let webView = WKWebView() - let url: URL var isLoaded = false init(url: URL = URL(string: "https://ropsten.infura.io/llyrtzQ3YhkdESt2Fzrk")!) { diff --git a/AlphaWallet/Wallet/Coordinators/InitialWalletCreationCoordinator.swift b/AlphaWallet/Wallet/Coordinators/InitialWalletCreationCoordinator.swift index 2265ff666..6e62dbc03 100644 --- a/AlphaWallet/Wallet/Coordinators/InitialWalletCreationCoordinator.swift +++ b/AlphaWallet/Wallet/Coordinators/InitialWalletCreationCoordinator.swift @@ -10,12 +10,12 @@ protocol InitialWalletCreationCoordinatorDelegate: class { } class InitialWalletCreationCoordinator: Coordinator { + private let keystore: Keystore + private let entryPoint: WalletEntryPoint let navigationController: UINavigationController - let keystore: Keystore var coordinators: [Coordinator] = [] weak var delegate: InitialWalletCreationCoordinatorDelegate? - let entryPoint: WalletEntryPoint init( navigationController: UINavigationController = NavigationController(), diff --git a/AlphaWallet/Wallet/Coordinators/WalletCoordinator.swift b/AlphaWallet/Wallet/Coordinators/WalletCoordinator.swift index 03f64b890..24a112090 100644 --- a/AlphaWallet/Wallet/Coordinators/WalletCoordinator.swift +++ b/AlphaWallet/Wallet/Coordinators/WalletCoordinator.swift @@ -10,12 +10,12 @@ protocol WalletCoordinatorDelegate: class { } class WalletCoordinator: Coordinator { - private let config: Config + private var entryPoint: WalletEntryPoint? + private var keystore: Keystore + var navigationController: UINavigationController weak var delegate: WalletCoordinatorDelegate? - var entryPoint: WalletEntryPoint? - var keystore: Keystore var coordinators: [Coordinator] = [] init( diff --git a/AlphaWallet/Wallet/ViewControllers/EnterPasswordCoordinator.swift b/AlphaWallet/Wallet/ViewControllers/EnterPasswordCoordinator.swift index 3e05cec87..2ae53f963 100644 --- a/AlphaWallet/Wallet/ViewControllers/EnterPasswordCoordinator.swift +++ b/AlphaWallet/Wallet/ViewControllers/EnterPasswordCoordinator.swift @@ -9,19 +9,18 @@ protocol EnterPasswordCoordinatorDelegate: class { } class EnterPasswordCoordinator: Coordinator { - var coordinators: [Coordinator] = [] - - weak var delegate: EnterPasswordCoordinatorDelegate? - - lazy var enterPasswordController: EnterPasswordViewController = { + private lazy var enterPasswordController: EnterPasswordViewController = { let controller = EnterPasswordViewController(account: account) controller.navigationItem.leftBarButtonItem = UIBarButtonItem(title: R.string.localizable.cancel(), style: .plain, target: self, action: #selector(dismiss)) controller.delegate = self return controller }() - let navigationController: UINavigationController private let account: Account + let navigationController: UINavigationController + var coordinators: [Coordinator] = [] + weak var delegate: EnterPasswordCoordinatorDelegate? + init( navigationController: UINavigationController = UINavigationController(), account: Account diff --git a/AlphaWallet/Wallet/ViewControllers/EnterPasswordViewController.swift b/AlphaWallet/Wallet/ViewControllers/EnterPasswordViewController.swift index f74292920..0c14ed87b 100644 --- a/AlphaWallet/Wallet/ViewControllers/EnterPasswordViewController.swift +++ b/AlphaWallet/Wallet/ViewControllers/EnterPasswordViewController.swift @@ -20,19 +20,21 @@ class EnterPasswordViewController: FormViewController { static var password = "password" static var confirmPassword = "confirmPassword" } - weak var delegate: EnterPasswordViewControllerDelegate? + private let viewModel = EnterPasswordViewModel() - var passwordRow: TextFloatLabelRow? { + private var passwordRow: TextFloatLabelRow? { return form.rowBy(tag: Values.password) as? TextFloatLabelRow } - var confirmPasswordRow: TextFloatLabelRow? { + private var confirmPasswordRow: TextFloatLabelRow? { return form.rowBy(tag: Values.confirmPassword) as? TextFloatLabelRow } private let account: Account + weak var delegate: EnterPasswordViewControllerDelegate? + init( account: Account ) { diff --git a/AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift b/AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift index 68db9f039..88a952ebd 100644 --- a/AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift +++ b/AlphaWallet/Wallet/ViewControllers/ImportWalletViewController.swift @@ -16,24 +16,21 @@ class ImportWalletViewController: UIViewController, CanScanQRCode { } } - let keystore: Keystore + private let keystore: Keystore private let viewModel = ImportWalletViewModel() - //We don't actually use the rounded corner here, but it's a useful "content" view here - let roundedBackground = RoundedBackground() - let scrollView = UIScrollView() - let footerBar = UIView() - let tabBar = ImportWalletTabBar() - let keystoreJSONTextView = TextView() - let passwordTextField = TextField() - let privateKeyTextView = TextView() - let watchAddressTextField = AddressTextField() - - var keystoreJSONControlsStackView: UIStackView! - var privateKeyControlsStackView: UIStackView! - var watchControlsStackView: UIStackView! - - let importButton = UIButton(type: .system) + private let roundedBackground = RoundedBackground() + private let scrollView = UIScrollView() + private let footerBar = UIView() + private let tabBar = ImportWalletTabBar() + private let keystoreJSONTextView = TextView() + private let passwordTextField = TextField() + private let privateKeyTextView = TextView() + private let watchAddressTextField = AddressTextField() + private var keystoreJSONControlsStackView: UIStackView! + private var privateKeyControlsStackView: UIStackView! + private var watchControlsStackView: UIStackView! + private let importButton = UIButton(type: .system) weak var delegate: ImportWalletViewControllerDelegate? diff --git a/AlphaWallet/Wallet/ViewControllers/PassphraseViewController.swift b/AlphaWallet/Wallet/ViewControllers/PassphraseViewController.swift index d0c99a65a..eaa11ed4e 100644 --- a/AlphaWallet/Wallet/ViewControllers/PassphraseViewController.swift +++ b/AlphaWallet/Wallet/ViewControllers/PassphraseViewController.swift @@ -4,9 +4,8 @@ import Foundation import UIKit class PassphraseViewController: UIViewController { - - let passphraseView = PassphraseView(frame: .zero) - let viewModel = PassphraseViewModel() + private let passphraseView = PassphraseView(frame: .zero) + private let viewModel = PassphraseViewModel() init(words: [String]) { super.init(nibName: nil, bundle: nil) diff --git a/AlphaWallet/Wallet/Views/ImportWalletTabBar.swift b/AlphaWallet/Wallet/Views/ImportWalletTabBar.swift index f97f2f8c1..5cf12c3d7 100644 --- a/AlphaWallet/Wallet/Views/ImportWalletTabBar.swift +++ b/AlphaWallet/Wallet/Views/ImportWalletTabBar.swift @@ -7,10 +7,13 @@ protocol ImportWalletTabBarDelegate: class { } class ImportWalletTabBar: UIView { - let keystoreButton = UIButton(type: .system) - let privateKeyButton = UIButton(type: .system) - let watchButton = UIButton(type: .system) - let tabHighlightView = UIView() + private let keystoreButton = UIButton(type: .system) + private let privateKeyButton = UIButton(type: .system) + private let watchButton = UIButton(type: .system) + private let tabHighlightView = UIView() + private var highlightBarHorizontalConstraints: [NSLayoutConstraint]? + private lazy var viewModel = ImportWalletTabBarViewModel(tab: tab) + var tab: ImportWalletTab = .keystore { didSet { viewModel.currentTab = tab @@ -18,9 +21,7 @@ class ImportWalletTabBar: UIView { configure() } } - var highlightBarHorizontalConstraints: [NSLayoutConstraint]? weak var delegate: ImportWalletTabBarDelegate? - lazy var viewModel = ImportWalletTabBarViewModel(tab: tab) override init(frame: CGRect) { super.init(frame: frame) diff --git a/AlphaWallet/Wallet/Views/PassphraseView.swift b/AlphaWallet/Wallet/Views/PassphraseView.swift index 0d5e05336..204f6b73d 100644 --- a/AlphaWallet/Wallet/Views/PassphraseView.swift +++ b/AlphaWallet/Wallet/Views/PassphraseView.swift @@ -4,15 +4,15 @@ import Foundation import UIKit class PassphraseView: UIView { - - lazy var layout: UICollectionViewLayout = { + private lazy var layout: UICollectionViewLayout = { let layout = UICollectionViewFlowLayout() layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = 0 layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) return layout }() - lazy var collectionView: UICollectionView = { + + private lazy var collectionView: UICollectionView = { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.isScrollEnabled = false return collectionView diff --git a/AlphaWallet/Welcome/ViewControllers/WelcomeViewController.swift b/AlphaWallet/Welcome/ViewControllers/WelcomeViewController.swift index 11292892d..289c4c06f 100644 --- a/AlphaWallet/Welcome/ViewControllers/WelcomeViewController.swift +++ b/AlphaWallet/Welcome/ViewControllers/WelcomeViewController.swift @@ -8,11 +8,7 @@ protocol WelcomeViewControllerDelegate: class { } class WelcomeViewController: UIViewController { - - var viewModel = WelcomeViewModel() - weak var delegate: WelcomeViewControllerDelegate? - - lazy var collectionViewController: OnboardingCollectionViewController = { + private lazy var collectionViewController: OnboardingCollectionViewController = { let layout = UICollectionViewFlowLayout() layout.minimumLineSpacing = 0 layout.minimumInteritemSpacing = 0 @@ -26,12 +22,12 @@ class WelcomeViewController: UIViewController { collectionViewController.collectionView?.backgroundColor = viewModel.backgroundColor return collectionViewController }() - let pageControl: UIPageControl = { + private let pageControl: UIPageControl = { let pageControl = UIPageControl() pageControl.translatesAutoresizingMaskIntoConstraints = false return pageControl }() - let createWalletButton: UIButton = { + private let createWalletButton: UIButton = { let button = Button(size: .large, style: .squared) button.translatesAutoresizingMaskIntoConstraints = false button.setTitle(R.string.localizable.aWelcomeOnboardingCreatewalletButtonTitle(), for: .normal) @@ -40,8 +36,7 @@ class WelcomeViewController: UIViewController { button.setTitleColor(Colors.appWhite, for: .normal) return button }() - let pages: [OnboardingPageViewModel] = [ - + private let pages: [OnboardingPageViewModel] = [ OnboardingPageViewModel( title: R.string.localizable.aWelcomeOnboarding1(), image: R.image.onboarding_1()! @@ -56,6 +51,10 @@ class WelcomeViewController: UIViewController { ), ] + private var viewModel = WelcomeViewModel() + + weak var delegate: WelcomeViewControllerDelegate? + override func viewDidLoad() { super.viewDidLoad() viewModel.numberOfPages = pages.count diff --git a/AlphaWallet/Welcome/ViewModels/OnboardingPageViewModel.swift b/AlphaWallet/Welcome/ViewModels/OnboardingPageViewModel.swift index 0420ceaf8..6b8ab6dbc 100644 --- a/AlphaWallet/Welcome/ViewModels/OnboardingPageViewModel.swift +++ b/AlphaWallet/Welcome/ViewModels/OnboardingPageViewModel.swift @@ -4,8 +4,8 @@ import UIKit struct OnboardingPageViewModel { - var title: String - var image: UIImage + let title: String + let image: UIImage init() { title = "" diff --git a/AlphaWallet/Welcome/Views/OnboardingPage.swift b/AlphaWallet/Welcome/Views/OnboardingPage.swift index caf5d7e21..cb1d99822 100644 --- a/AlphaWallet/Welcome/Views/OnboardingPage.swift +++ b/AlphaWallet/Welcome/Views/OnboardingPage.swift @@ -4,12 +4,12 @@ import UIKit final class OnboardingPage: UICollectionViewCell { - static let identifier = "Page" - let style = OnboardingPageStyle() - + private let style = OnboardingPageStyle() private var imageView: UIImageView! private var titleLabel: UILabel! + static let identifier = "Page" + override var reuseIdentifier: String? { return OnboardingPage.identifier }