diff --git a/App/Modules/AppTimeout/AutoLockViewController.swift b/App/Modules/AppTimeout/AutoLockViewController.swift index 8ee77915..0c55e7c8 100644 --- a/App/Modules/AppTimeout/AutoLockViewController.swift +++ b/App/Modules/AppTimeout/AutoLockViewController.swift @@ -21,7 +21,14 @@ class AutoLockViewController:BaseViewController { }() let cellIdentifier = "TimerCell" - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } weak var delegate:AutoLockViewControllerDelegate? override func viewDidLoad() { diff --git a/App/Modules/CompanyProducts/ProductsViewController.swift b/App/Modules/CompanyProducts/ProductsViewController.swift index 80275657..f0311e62 100644 --- a/App/Modules/CompanyProducts/ProductsViewController.swift +++ b/App/Modules/CompanyProducts/ProductsViewController.swift @@ -19,6 +19,14 @@ class ProductsViewController: BaseViewController { let viewIdentifer = "ProductDetailView" let heightCell:CGFloat = 70 let inset:CGFloat = 15 + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { super.viewDidLoad() title = "BANKEX Products" diff --git a/App/Modules/ContactAdd/AddContactViewController.swift b/App/Modules/ContactAdd/AddContactViewController.swift index fbd345d9..c79e8749 100644 --- a/App/Modules/ContactAdd/AddContactViewController.swift +++ b/App/Modules/ContactAdd/AddContactViewController.swift @@ -48,6 +48,14 @@ class AddContactViewController: BaseViewController,UITextFieldDelegate { } } } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .blueStyle + } + set { + super.navigationBarAppearance = newValue + } + } var service = ContactService() override func viewDidLoad() { @@ -83,10 +91,6 @@ class AddContactViewController: BaseViewController,UITextFieldDelegate { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) state = .noAvailable - navigationController?.navigationBar.barTintColor = UIDevice.isIpad ? .white : UIColor.mainColor - navigationController?.navigationBar.tintColor = .white - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .clear : UIColor.mainColor - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent doneButton.isHidden = UIDevice.isIpad ? true : false title = UIDevice.isIpad ? "New Contact" : "" } @@ -96,17 +100,6 @@ class AddContactViewController: BaseViewController,UITextFieldDelegate { nameContactTextField.becomeFirstResponder() } - override func willMove(toParentViewController parent: UIViewController?) { - navigationController?.navigationBar.barTintColor = .white - } - - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - //navigationController?.navigationBar.tintColor = UIColor.mainColor - UIApplication.shared.statusBarView?.backgroundColor = .white - UIApplication.shared.statusBarStyle = .default - } - override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) clearInfo() diff --git a/App/Modules/ContactDetails/ProfileContactViewController.swift b/App/Modules/ContactDetails/ProfileContactViewController.swift index 7101d91f..db5d840e 100644 --- a/App/Modules/ContactDetails/ProfileContactViewController.swift +++ b/App/Modules/ContactDetails/ProfileContactViewController.swift @@ -60,6 +60,14 @@ class ProfileContactViewController: BaseViewController,UITextFieldDelegate,UITex alertVC.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .default)) return alertVC }() + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } var state:State = .loading { didSet { switch state { @@ -169,16 +177,9 @@ class ProfileContactViewController: BaseViewController,UITextFieldDelegate,UITex private func manageTop(isHide:Bool = true) { if isHide { navigationController?.setNavigationBarHidden(isHide, animated: false) - navigationController?.navigationBar.barTintColor = UIColor.mainColor - navigationController?.navigationBar.tintColor = .white - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .white : UIColor.mainColor - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent return } navigationController?.isNavigationBarHidden = isHide - navigationController?.navigationBar.barTintColor = .white - navigationController?.navigationBar.tintColor = UIColor.mainColor - UIApplication.shared.statusBarStyle = .default } @IBAction func seeAll() { diff --git a/App/Modules/ContactEdit/EditViewController.swift b/App/Modules/ContactEdit/EditViewController.swift index 6a232e70..abfdfe2d 100644 --- a/App/Modules/ContactEdit/EditViewController.swift +++ b/App/Modules/ContactEdit/EditViewController.swift @@ -35,6 +35,14 @@ class EditViewController: BaseViewController { } } } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .blueStyle + } + set { + super.navigationBarAppearance = newValue + } + } let service = ContactService() override func viewDidLoad() { super.viewDidLoad() @@ -58,19 +66,9 @@ class EditViewController: BaseViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) title = UIDevice.isIpad ? "Edit Contact" : "" - navigationController?.navigationBar.barTintColor = UIDevice.isIpad ? UIColor.white : UIColor.mainColor - navigationController?.navigationBar.tintColor = .white - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? nil : UIColor.mainColor - UIApplication.shared.statusBarStyle = .lightContent updateUI() } - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .lightContent : .default - navigationController?.navigationBar.barTintColor = .white - navigationController?.navigationBar.tintColor = UIColor.mainColor - } private func prepareTFs() { [nameTextField,addrTextField].forEach { diff --git a/App/Modules/ContactList/ListContactsViewController.swift b/App/Modules/ContactList/ListContactsViewController.swift index cbf20bca..f7a5bc0d 100644 --- a/App/Modules/ContactList/ListContactsViewController.swift +++ b/App/Modules/ContactList/ListContactsViewController.swift @@ -37,6 +37,14 @@ class ListContactsViewController: BaseViewController,UISearchBarDelegate { tableView.reloadData() } } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } @IBOutlet weak var searchBar:UISearchBar! @IBOutlet weak var emptyView:UIView! @@ -58,9 +66,6 @@ class ListContactsViewController: BaseViewController,UISearchBarDelegate { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.setNavigationBarHidden(false, animated: false) - navigationController?.navigationBar.barTintColor = .white - navigationController?.navigationBar.tintColor = UIColor.mainColor - UIApplication.shared.statusBarView?.backgroundColor = .white if fromSendScreen { addLeftBtn() hideAddRightButton() diff --git a/App/Modules/Home/HomeViewController.swift b/App/Modules/Home/HomeViewController.swift index c3ee141b..9ceaae92 100644 --- a/App/Modules/Home/HomeViewController.swift +++ b/App/Modules/Home/HomeViewController.swift @@ -43,6 +43,14 @@ class HomeViewController: BaseViewController { } } } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } private struct ViewModel { @@ -183,7 +191,6 @@ class HomeViewController: BaseViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) TokenShortService.arrayTokensShort.removeAll() - setupStatusBarColor() state = isFromContact ? .fromContact : .home updateTableView() } @@ -232,10 +239,7 @@ class HomeViewController: BaseViewController { @IBAction func unwindToHome(_ unwindSegue: UIStoryboardSegue) {} //Methods - fileprivate func setupStatusBarColor() { - UIApplication.shared.statusBarView?.backgroundColor = .white - UIApplication.shared.statusBarStyle = .default - } + func catchUserActivity() { let appDelegate = UIApplication.shared.delegate as! AppDelegate diff --git a/App/Modules/Menu/MenuPad.storyboard b/App/Modules/Menu/MenuPad.storyboard index 8751eaf3..f3fb85c3 100644 --- a/App/Modules/Menu/MenuPad.storyboard +++ b/App/Modules/Menu/MenuPad.storyboard @@ -13,7 +13,7 @@ - + diff --git a/App/Modules/Menu/MenuPhone.storyboard b/App/Modules/Menu/MenuPhone.storyboard index d8df4a7f..3e587309 100644 --- a/App/Modules/Menu/MenuPhone.storyboard +++ b/App/Modules/Menu/MenuPhone.storyboard @@ -33,7 +33,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -93,7 +93,7 @@ - + diff --git a/App/Modules/NetworkAdd/CreateNetworkViewController.swift b/App/Modules/NetworkAdd/CreateNetworkViewController.swift index f199da2b..8c279494 100644 --- a/App/Modules/NetworkAdd/CreateNetworkViewController.swift +++ b/App/Modules/NetworkAdd/CreateNetworkViewController.swift @@ -23,7 +23,14 @@ class CreateNetworkViewController: UITableViewController,UITextFieldDelegate { @IBOutlet weak var networkIDTextField:UITextField! @IBOutlet var textFields:[UITextField]! - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } var joinButton = UIBarButtonItem(title: NSLocalizedString("Join", comment: ""), style: .done, target: self, action: #selector(joinToConnection)) var state:State = .unavailable { didSet { diff --git a/App/Modules/QRCodeGeneration/AddressQRCodeController.swift b/App/Modules/QRCodeGeneration/AddressQRCodeController.swift index af04186c..04af9598 100644 --- a/App/Modules/QRCodeGeneration/AddressQRCodeController.swift +++ b/App/Modules/QRCodeGeneration/AddressQRCodeController.swift @@ -27,7 +27,15 @@ class AddressQRCodeController: BaseViewController { clipView.backgroundColor = UIColor(hex: "B8BFC9") return clipView }() - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setupClipboardView() diff --git a/App/Modules/SettingsMain/SettingsViewController.swift b/App/Modules/SettingsMain/SettingsViewController.swift index 7b52646e..a29e8d12 100644 --- a/App/Modules/SettingsMain/SettingsViewController.swift +++ b/App/Modules/SettingsMain/SettingsViewController.swift @@ -25,7 +25,14 @@ class SettingsViewController: UITableViewController { let walletService = SingleKeyServiceImplementation() let networkService = NetworksServiceImplementation() var selectedSection:Int! - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { @@ -38,7 +45,6 @@ class SettingsViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - UIApplication.shared.statusBarView?.backgroundColor = .white walletService.updateSelectedWallet() updateUI() } @@ -95,7 +101,6 @@ class SettingsViewController: UITableViewController { private func prepareNavbar() { navigationItem.title = NSLocalizedString("Settings", comment: "") - navigationController?.navigationBar.shadowImage = UIImage() } diff --git a/App/Modules/SettingsNetworks/NetworksViewController.swift b/App/Modules/SettingsNetworks/NetworksViewController.swift index 9b797235..faf162ca 100644 --- a/App/Modules/SettingsNetworks/NetworksViewController.swift +++ b/App/Modules/SettingsNetworks/NetworksViewController.swift @@ -25,7 +25,14 @@ class NetworksViewController: BaseViewController { enum NetworksSections:Int,CaseIterable { case CurrentNetwork = 0,DefaultNetwork,CustomNetwork } - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } weak var delegate:NetworkDelegate? var selectedNetwork:CustomNetwork { diff --git a/App/Modules/SettingsSecurity/SecurityViewController.swift b/App/Modules/SettingsSecurity/SecurityViewController.swift index 2196d321..7b0cbd2d 100644 --- a/App/Modules/SettingsSecurity/SecurityViewController.swift +++ b/App/Modules/SettingsSecurity/SecurityViewController.swift @@ -27,7 +27,14 @@ class SecurityViewController: UITableViewController { enum SecuritySections:Int { case First = 0,Second,Third } - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { super.viewDidLoad() setupNavbar() diff --git a/App/Modules/TokenAddConfirmation/TokenInfoController.swift b/App/Modules/TokenAddConfirmation/TokenInfoController.swift index d2481f60..b7cbb792 100644 --- a/App/Modules/TokenAddConfirmation/TokenInfoController.swift +++ b/App/Modules/TokenAddConfirmation/TokenInfoController.swift @@ -23,7 +23,14 @@ class TokenInfoController: BaseViewController, UITableViewDelegate, UITableViewD let tokensService: CustomERC20TokensService = CustomERC20TokensServiceImplementation() var token: ERC20TokenModel? let utilsService = CustomTokenUtilsServiceImplementation() - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } var forAdding: Bool = false diff --git a/App/Modules/TokenAddSearch/CreateTokenController.swift b/App/Modules/TokenAddSearch/CreateTokenController.swift index 2c07e67a..729a3c64 100644 --- a/App/Modules/TokenAddSearch/CreateTokenController.swift +++ b/App/Modules/TokenAddSearch/CreateTokenController.swift @@ -40,7 +40,14 @@ class CreateTokenController: BaseViewController { label.textAlignment = .center return label }() - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { @@ -77,7 +84,6 @@ class CreateTokenController: BaseViewController { fileprivate func setupNavBar() { navigationController?.navigationBar.topItem?.title = NSLocalizedString("Wallet", comment: "") - navigationController?.navigationBar.shadowImage = UIImage() } private func showScanner() { diff --git a/App/Modules/TransactionConfirmation/ConfirmViewController.swift b/App/Modules/TransactionConfirmation/ConfirmViewController.swift index af606eb2..2d16adbd 100644 --- a/App/Modules/TransactionConfirmation/ConfirmViewController.swift +++ b/App/Modules/TransactionConfirmation/ConfirmViewController.swift @@ -22,13 +22,21 @@ class ConfirmViewController: UITableViewController { @IBOutlet weak var walletNameLabel: UILabel! @IBOutlet weak var totalLabel:UILabel! - //Properties - - var fromAddr:String { let addr = keyService.selectedAddress() ?? "" return addr } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + let barTintColor: UIColor = UIDevice.isIpad ? .white : .mainColor + let tintColor: UIColor = UIDevice.isIpad ? .black : .white + let statusBarStyle: UIStatusBarStyle = UIDevice.isIpad ? .default : .lightContent + return super.navigationBarAppearance ?? NavigationBarAppearance(barTintColor: barTintColor, tintColor: tintColor, titleTextAttributes: nil, statusBarStyle: statusBarStyle, shadowImage: UIImage()) + } + set { + super.navigationBarAppearance = newValue + } + } var gasPrice:String! var gasLimit:String! var transaction:TransactionIntermediate! @@ -91,16 +99,10 @@ class ConfirmViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - appearanceNavBar(false) if isPinAccepted { self.sendFunds() } updateUI() } - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - appearanceNavBar(true) - } - //Helper func formattedFee() -> String? { @@ -166,19 +168,5 @@ class ConfirmViewController: UITableViewController { self.sendFunds() } } - - func appearanceNavBar(_ exit:Bool) { - if exit { - navBarColor(.white) - navBarTintColor(UIColor.mainColor) - statusBarColor(.white) - UIApplication.shared.statusBarStyle = .default - return - } - navBarColor(UIDevice.isIpad ? .white : UIColor.mainColor) - navBarTintColor(UIDevice.isIpad ? UIColor.mainColor : .white) - statusBarColor(UIDevice.isIpad ? nil : UIColor.mainColor) - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent - } } diff --git a/App/Modules/TransactionCreate/SendTokenViewController.swift b/App/Modules/TransactionCreate/SendTokenViewController.swift index 3d15ccf3..6a0569e9 100644 --- a/App/Modules/TransactionCreate/SendTokenViewController.swift +++ b/App/Modules/TransactionCreate/SendTokenViewController.swift @@ -64,7 +64,15 @@ Retriable,UITextFieldDelegate { var tokensTableViewManager = TokensTableViewManager() let keysService: SingleKeyService = SingleKeyServiceImplementation() var transaction:TransactionIntermediate? - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + let statusBarStyle: UIStatusBarStyle = UIDevice.isIpad ? .default : .lightContent + return NavigationBarAppearance(barTintColor: .mainColor, tintColor: .white, titleTextAttributes: [NSAttributedStringKey.foregroundColor : UIColor.white], statusBarStyle: statusBarStyle, shadowImage: UIImage()) + } + set { + super.navigationBarAppearance = newValue + } + } // MARK: Inputs var selectedToken:ERC20TokenModel { return tokensService.selectedERC20Token() @@ -130,8 +138,6 @@ Retriable,UITextFieldDelegate { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.isNavigationBarHidden = true - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .white : UIColor.mainColor - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent updateUI() } diff --git a/App/Modules/TransactionFailure/SendingErrorViewController.swift b/App/Modules/TransactionFailure/SendingErrorViewController.swift index 25300631..1856691f 100644 --- a/App/Modules/TransactionFailure/SendingErrorViewController.swift +++ b/App/Modules/TransactionFailure/SendingErrorViewController.swift @@ -19,6 +19,15 @@ class SendingErrorViewController: BaseViewController { @IBOutlet weak var retryButton: UIButton! @IBOutlet weak var errorMessageLabel: UILabel! + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .blueStyle + } + set { + super.navigationBarAppearance = newValue + } + } + override func viewDidLoad() { super.viewDidLoad() addBackButton() @@ -61,18 +70,11 @@ class SendingErrorViewController: BaseViewController { super.viewWillAppear(animated) splitViewController?.show() navigationController?.setNavigationBarHidden(false, animated: false) - navigationController?.navigationBar.barTintColor = UIDevice.isIpad ? .white : UIColor.mainColor - statusBarColor(UIDevice.isIpad ? .white : UIColor.mainColor) - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent - navigationController?.navigationBar.tintColor = UIDevice.isIpad ? UIColor.mainColor : .white } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.setNavigationBarHidden(true, animated: false) - navigationController?.navigationBar.barTintColor = .white - UIApplication.shared.statusBarView?.backgroundColor = .white - navigationController?.navigationBar.tintColor = UIColor.mainColor } func addBackButton() { diff --git a/App/Modules/TransactionFee/ChooseFeeViewController.swift b/App/Modules/TransactionFee/ChooseFeeViewController.swift index f9624dcf..41263433 100644 --- a/App/Modules/TransactionFee/ChooseFeeViewController.swift +++ b/App/Modules/TransactionFee/ChooseFeeViewController.swift @@ -39,6 +39,15 @@ class ChooseFeeViewController: BaseViewController { } } } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + let statusBarStyle: UIStatusBarStyle = UIDevice.isIpad ? .default : .lightContent + return super.navigationBarAppearance ?? NavigationBarAppearance(barTintColor: .mainColor, tintColor: .white, titleTextAttributes: [NSAttributedStringKey.foregroundColor: UIColor.white], statusBarStyle: statusBarStyle, shadowImage: UIImage()) + } + set { + super.navigationBarAppearance = newValue + } + } lazy var unitLabel:UILabel = { let label = UILabel() label.font = UIFont.systemFont(ofSize: 17.0) @@ -87,15 +96,12 @@ class ChooseFeeViewController: BaseViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.isNavigationBarHidden = true - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .white : UIColor.mainColor updateUI() } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.isNavigationBarHidden = false - UIApplication.shared.statusBarStyle = .default } diff --git a/App/Modules/TransactionHistory/TransactionHistoryViewController.swift b/App/Modules/TransactionHistory/TransactionHistoryViewController.swift index 132efa3a..ff6358db 100644 --- a/App/Modules/TransactionHistory/TransactionHistoryViewController.swift +++ b/App/Modules/TransactionHistory/TransactionHistoryViewController.swift @@ -31,6 +31,14 @@ class TransactionHistoryViewController: BaseViewController, UITableViewDataSourc .arrowSize(CGSize(width: 29, height: 16)), .cornerRadius(8.0) ] + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } var state:State = .empty { didSet { if state == .empty { @@ -98,7 +106,6 @@ class TransactionHistoryViewController: BaseViewController, UITableViewDataSourc tokenFilterBarButtonItem.isEnabled = availableTokensList.count > 0 navigationController?.navigationBar.isHidden = false navigationController?.interactivePopGestureRecognizer?.isEnabled = false - UIApplication.shared.statusBarView?.backgroundColor = .white } //MARK: - Refresh Control diff --git a/App/Modules/TransactionProcessing/SendingInProcessViewController.swift b/App/Modules/TransactionProcessing/SendingInProcessViewController.swift index 9cd46de4..0eca14b6 100644 --- a/App/Modules/TransactionProcessing/SendingInProcessViewController.swift +++ b/App/Modules/TransactionProcessing/SendingInProcessViewController.swift @@ -34,7 +34,14 @@ SendingResultInformation { var fromEnterScreen = false var textToShow: String? - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let controller = segue.destination as? SendingSuccessViewController { @@ -57,7 +64,6 @@ SendingResultInformation { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) splitViewController?.hide() - UIApplication.shared.statusBarStyle = .default activityView.startAnimating() self.navigationController?.setNavigationBarHidden(true, animated: false) titleLabel?.text = textToShow == nil ? NSLocalizedString("Sending funds", comment: "") : textToShow! diff --git a/App/Modules/TransactionSuccess/SendingSuccessViewController.swift b/App/Modules/TransactionSuccess/SendingSuccessViewController.swift index 4ace6b4b..fa20f536 100644 --- a/App/Modules/TransactionSuccess/SendingSuccessViewController.swift +++ b/App/Modules/TransactionSuccess/SendingSuccessViewController.swift @@ -15,6 +15,14 @@ class SendingSuccessViewController: UIViewController { var addressToSend: String? let favoritesService: ContactServiceProtocol = ContactService() let tokenService: CustomERC20TokensService = CustomERC20TokensServiceImplementation() + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } // MARK: Outlets @IBOutlet weak var transactionSucceedLabel: UILabel! diff --git a/App/Modules/WalletDetails/WalletInfoViewController.swift b/App/Modules/WalletDetails/WalletInfoViewController.swift index db9a1ed7..2b299b52 100644 --- a/App/Modules/WalletDetails/WalletInfoViewController.swift +++ b/App/Modules/WalletDetails/WalletInfoViewController.swift @@ -20,6 +20,14 @@ class WalletInfoViewController: BaseViewController { let infoCellIdentifier = "InfoCell" var publicName:String? var secondWidth:CGFloat? + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { super.viewDidLoad() @@ -40,7 +48,6 @@ class WalletInfoViewController: BaseViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.setNavigationBarHidden(false, animated: false) - UIApplication.shared.statusBarView?.backgroundColor = .white } func setupClipboard() { diff --git a/App/Modules/WalletList/WalletsViewController.swift b/App/Modules/WalletList/WalletsViewController.swift index 04a57479..6d25ced0 100644 --- a/App/Modules/WalletList/WalletsViewController.swift +++ b/App/Modules/WalletList/WalletsViewController.swift @@ -27,7 +27,14 @@ class WalletsViewController: BaseViewController, WalletSelectedDelegate { var selectedWallet:HDKey? { return service.selectedKey() } - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } weak var delegate:WalletsDelegate? override func viewDidLoad() { diff --git a/App/Modules/WalletRename/RenameViewController.swift b/App/Modules/WalletRename/RenameViewController.swift index 6a3bc25c..890b5496 100644 --- a/App/Modules/WalletRename/RenameViewController.swift +++ b/App/Modules/WalletRename/RenameViewController.swift @@ -26,6 +26,14 @@ class RenameViewController: BaseViewController { } return true } + override var navigationBarAppearance: NavigationBarAppearance? { + get { + return super.navigationBarAppearance ?? .whiteStyle + } + set { + super.navigationBarAppearance = newValue + } + } override func touchesBegan(_ touches: Set, with event: UIEvent?) { view.endEditing(true) @@ -79,9 +87,6 @@ class RenameViewController: BaseViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - if UIDevice.isIpad { - UIApplication.shared.statusBarView?.backgroundColor = nil - } updateUI() } diff --git a/App/Modules/Warning/AttentionViewController.swift b/App/Modules/Warning/AttentionViewController.swift index b897e4b2..f40159f2 100644 --- a/App/Modules/Warning/AttentionViewController.swift +++ b/App/Modules/Warning/AttentionViewController.swift @@ -39,7 +39,15 @@ class AttentionViewController: BaseViewController { } } let keysService = SingleKeyServiceImplementation() - + override var navigationBarAppearance: NavigationBarAppearance? { + get { + let statusBarStyle: UIStatusBarStyle = UIDevice.isIpad ? .default : .lightContent + return super.navigationBarAppearance ?? NavigationBarAppearance(barTintColor: .errorColor, tintColor: .white, titleTextAttributes: [NSAttributedStringKey.foregroundColor : UIColor.white], statusBarStyle: statusBarStyle, shadowImage: UIImage()) + } + set { + super.navigationBarAppearance = newValue + } + } override func viewDidLoad() { super.viewDidLoad() _ = heightConstraint.setMultiplier(multiplier: UIDevice.isIpad ? 0.17 : 0.27) @@ -51,14 +59,11 @@ class AttentionViewController: BaseViewController { state = isFromDeveloper ? .CustomNetwork : .PrivateKey navigationItem.title = state == .CustomNetwork ? NSLocalizedString("CustomNetworks", comment: "") : NSLocalizedString("Private Key", comment: "") navigationController?.setNavigationBarHidden(true, animated: true) - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .white : UIColor.errorColor - UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .lightContent } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.setNavigationBarHidden(false, animated: true) - UIApplication.shared.statusBarStyle = .default } @IBAction func proceed() { diff --git a/BankexWallet.xcodeproj/project.pbxproj b/BankexWallet.xcodeproj/project.pbxproj index b58434fa..665840a5 100644 --- a/BankexWallet.xcodeproj/project.pbxproj +++ b/BankexWallet.xcodeproj/project.pbxproj @@ -151,6 +151,7 @@ 864171792177597300F85F19 /* ProductsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864171782177597300F85F19 /* ProductsViewController.swift */; }; 8641717C2177599A00F85F19 /* ProductViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8641717A2177599A00F85F19 /* ProductViewCell.swift */; }; 8641717D2177599A00F85F19 /* ProductViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8641717B2177599A00F85F19 /* ProductViewCell.xib */; }; + 8643179121ECD6C8007473D7 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8643179021ECD6C8007473D7 /* NavigationController.swift */; }; 864732C9214FC2A000519AE1 /* UIView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864732C8214FC2A000519AE1 /* UIView+Extensions.swift */; }; 864732CB214FC2CB00519AE1 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864732CA214FC2CB00519AE1 /* Date+Extensions.swift */; }; 864732CD214FC2F200519AE1 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 864732CC214FC2F200519AE1 /* String+Extensions.swift */; }; @@ -482,6 +483,7 @@ 864171782177597300F85F19 /* ProductsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsViewController.swift; sourceTree = ""; }; 8641717A2177599A00F85F19 /* ProductViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductViewCell.swift; sourceTree = ""; }; 8641717B2177599A00F85F19 /* ProductViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProductViewCell.xib; sourceTree = ""; }; + 8643179021ECD6C8007473D7 /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; 864732C8214FC2A000519AE1 /* UIView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extensions.swift"; sourceTree = ""; }; 864732CA214FC2CB00519AE1 /* Date+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = ""; }; 864732CC214FC2F200519AE1 /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = ""; }; @@ -1336,6 +1338,7 @@ 861D2CD7214AF69E00A108C4 /* BaseTabBarController.swift */, 861D2CDA214AF6B500A108C4 /* BaseNavigationController.swift */, 864D0741214DAA9700BCC8BB /* BaseViewController.swift */, + 8643179021ECD6C8007473D7 /* NavigationController.swift */, ); name = Main; path = InterfaceElements/DesignElements/Main; @@ -2082,6 +2085,7 @@ F0FF1C73205551350051D894 /* ContactServiceProtocol.swift in Sources */, 862F877821527A10001D7DDE /* TransactionInfoCell.swift in Sources */, 8631569A2103940300914F31 /* SettingsViewController.swift in Sources */, + 8643179121ECD6C8007473D7 /* NavigationController.swift in Sources */, 864732EA214FF43900519AE1 /* BaseButton.swift in Sources */, 864D0FF621393B8100176803 /* SearchManager.swift in Sources */, 86219C072180AB1300185EF6 /* SectionTableCell.swift in Sources */, diff --git a/BankexWallet/Extensions/ViewController+Extensions.swift b/BankexWallet/Extensions/ViewController+Extensions.swift index 8b799819..6b1c9063 100644 --- a/BankexWallet/Extensions/ViewController+Extensions.swift +++ b/BankexWallet/Extensions/ViewController+Extensions.swift @@ -116,3 +116,17 @@ extension UIViewController { } } + +private var UIViewControllerNavigationBarAppearance: UInt8 = 0 + +extension UIViewController: NavigationBarAppearanceProvider { + + @objc var navigationBarAppearance: NavigationBarAppearance? { + get { + return objc_getAssociatedObject(self, &UIViewControllerNavigationBarAppearance) as? NavigationBarAppearance + } + set { + objc_setAssociatedObject(self, &UIViewControllerNavigationBarAppearance, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) + } + } +} diff --git a/BankexWallet/InterfaceElements/DesignElements/Main/NavigationController.swift b/BankexWallet/InterfaceElements/DesignElements/Main/NavigationController.swift new file mode 100644 index 00000000..a9d4cf84 --- /dev/null +++ b/BankexWallet/InterfaceElements/DesignElements/Main/NavigationController.swift @@ -0,0 +1,106 @@ +// +// NavigationController.swift +// BankexWallet +// +// Created by Vladislav on 14/01/2019. +// Copyright © 2019 BANKEX Foundation. All rights reserved. +// + +import UIKit + +protocol NavigationBarAppearanceProvider { + var navigationBarAppearance : NavigationBarAppearance? { get } +} + + +class NavigationController: UINavigationController { + + override init(rootViewController: UIViewController) { + super.init(rootViewController: rootViewController) + updateAppearance() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + updateAppearance() + } + + override var viewControllers: [UIViewController] { + didSet { + updateAppearance() + } + } + + override func awakeAfter(using aDecoder: NSCoder) -> Any? { + return super.awakeAfter(using: aDecoder) + } + + override func awakeFromNib() { + super.awakeFromNib() + updateAppearance() + } + + override func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) { + super.setViewControllers(viewControllers, animated: animated) + updateAppearance() + } + + override func pushViewController(_ viewController: UIViewController, animated: Bool) { + super.pushViewController(viewController, animated: animated) + updateAppearance() + } + + override func popViewController(animated: Bool) -> UIViewController? { + let result = super.popViewController(animated: animated) + updateAppearance() + return result + } + + override func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? { + let result = super.popToViewController(viewController, animated: animated) + updateAppearance() + return result + } + + override func popToRootViewController(animated: Bool) -> [UIViewController]? { + let result = super.popToRootViewController(animated: animated) + updateAppearance() + return result + } + + func updateAppearance() { + guard let navigationBarAppearance = (self.visibleViewController)?.navigationBarAppearance else { return } + self.navigationBar.barTintColor = navigationBarAppearance.barTintColor + self.navigationBar.tintColor = navigationBarAppearance.tintColor + self.navigationBar.shadowImage = navigationBarAppearance.shadowImage + self.navigationBar.titleTextAttributes = navigationBarAppearance.titleTextAttributes + setNeedsStatusBarAppearanceUpdate() + } + + override var preferredStatusBarStyle: UIStatusBarStyle { + return (self.visibleViewController)?.navigationBarAppearance?.statusBarStyle ?? super.preferredStatusBarStyle + } + +} + +class NavigationBarAppearance: NSObject { + + var barTintColor: UIColor? + var tintColor: UIColor? + var titleTextAttributes: [NSAttributedString.Key : Any]? + var statusBarStyle: UIStatusBarStyle? + var shadowImage: UIImage? + + init(barTintColor: UIColor?, tintColor: UIColor?,titleTextAttributes:[NSAttributedStringKey : Any]?,statusBarStyle: UIStatusBarStyle?, shadowImage: UIImage?) { + self.barTintColor = barTintColor + self.tintColor = tintColor + self.titleTextAttributes = titleTextAttributes + self.statusBarStyle = statusBarStyle + self.shadowImage = shadowImage + } + + + static let whiteStyle: NavigationBarAppearance = NavigationBarAppearance(barTintColor: .white, tintColor: .mainColor, titleTextAttributes: [NSAttributedStringKey.foregroundColor : UIColor.black], statusBarStyle: .default, shadowImage: UIImage()) + + static let blueStyle: NavigationBarAppearance = NavigationBarAppearance(barTintColor: .mainColor, tintColor: .white, titleTextAttributes: [NSAttributedStringKey.foregroundColor : UIColor.white], statusBarStyle: .lightContent, shadowImage: UIImage()) +} diff --git a/BankexWallet/TransactionDetails/TransactionDetailsViewController.swift b/BankexWallet/TransactionDetails/TransactionDetailsViewController.swift index feb5b0eb..6eae1c70 100644 --- a/BankexWallet/TransactionDetails/TransactionDetailsViewController.swift +++ b/BankexWallet/TransactionDetails/TransactionDetailsViewController.swift @@ -22,6 +22,15 @@ class TransactionDetailsViewController: UIViewController { var transactionDetails: TransactionDetails? var transactionStatus: TransactionReceipt.TXStatus? + override var navigationBarAppearance: NavigationBarAppearance? { + get { + let statusBarStyle: UIStatusBarStyle = UIDevice.isIpad ? .default : .`default` + return super.navigationBarAppearance ?? NavigationBarAppearance(barTintColor: .disableColor, tintColor: .white, titleTextAttributes: [NSAttributedStringKey.foregroundColor : UIColor.white], statusBarStyle: statusBarStyle, shadowImage: UIImage()) + } + set { + super.navigationBarAppearance = newValue + } + } @IBOutlet private var amountLabel: UILabel! @IBOutlet private var symbolLabel: UILabel! @@ -100,7 +109,6 @@ class TransactionDetailsViewController: UIViewController { private func configureNavBar() { navigationController?.navigationBar.isHidden = true - UIApplication.shared.statusBarView?.backgroundColor = UIDevice.isIpad ? .white : .disableColor UIApplication.shared.statusBarStyle = UIDevice.isIpad ? .default : .`default` }