IOS-469 handling pEp status colors more systematically
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 13 Mar 2017 17:37:36 +0100
changeset 1826f8fe61819ba6
parent 1821 8aeab0673525
child 1830 63ce3e365ee9
child 1831 eeada9973971
IOS-469 handling pEp status colors more systematically
pEpForiOS/AppDelegate.swift
pEpForiOS/UI/Compose/ComposeTableViewController.swift
pEpForiOS/UI/EmailDisplay/EmailListViewController.swift
pEpForiOS/UI/EmailDisplay/EmailViewController.swift
pEpForiOS/UI/UIViewController+Extension.swift
pEpForiOS/Util/Appearance.swift
     1.1 --- a/pEpForiOS/AppDelegate.swift	Mon Mar 13 15:58:19 2017 +0100
     1.2 +++ b/pEpForiOS/AppDelegate.swift	Mon Mar 13 17:37:36 2017 +0100
     1.3 @@ -59,7 +59,7 @@
     1.4          // set up logging for libraries
     1.5          MessageModelConfig.logger = Log.shared
     1.6  
     1.7 -        Appearance.standard()
     1.8 +        Appearance.pep()
     1.9  
    1.10          Log.warn(component: comp, content: "Library url: \(applicationDirectory())")
    1.11  
     2.1 --- a/pEpForiOS/UI/Compose/ComposeTableViewController.swift	Mon Mar 13 15:58:19 2017 +0100
     2.2 +++ b/pEpForiOS/UI/Compose/ComposeTableViewController.swift	Mon Mar 13 17:37:36 2017 +0100
     2.3 @@ -69,7 +69,7 @@
     2.4  
     2.5      override func viewWillAppear(_ animated: Bool) {
     2.6          super.viewWillAppear(animated)
     2.7 -        setDefaultBarColors()
     2.8 +        setNoColor()
     2.9      }
    2.10  
    2.11      func prepareColor() {
     3.1 --- a/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Mon Mar 13 15:58:19 2017 +0100
     3.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailListViewController.swift	Mon Mar 13 17:37:36 2017 +0100
     3.3 @@ -49,6 +49,7 @@
     3.4              return
     3.5          }
     3.6  
     3.7 +        setDefaultColors()
     3.8          initialConfig()
     3.9          updateModel()
    3.10  
     4.1 --- a/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon Mar 13 15:58:19 2017 +0100
     4.2 +++ b/pEpForiOS/UI/EmailDisplay/EmailViewController.swift	Mon Mar 13 17:37:36 2017 +0100
     4.3 @@ -53,7 +53,7 @@
     4.4      
     4.5      override func viewWillDisappear(_ animated: Bool) {
     4.6          super.viewWillDisappear(animated)
     4.7 -        setDefaultBarColors()
     4.8 +        setNoColor()
     4.9      }
    4.10  
    4.11      func checkMessageReEvaluation() {
     5.1 --- a/pEpForiOS/UI/UIViewController+Extension.swift	Mon Mar 13 15:58:19 2017 +0100
     5.2 +++ b/pEpForiOS/UI/UIViewController+Extension.swift	Mon Mar 13 17:37:36 2017 +0100
     5.3 @@ -9,34 +9,14 @@
     5.4  import Foundation
     5.5  import UIKit
     5.6  
     5.7 -class NavigationBarData {
     5.8 -    var handledDefault: Bool = false
     5.9 -    var defaultNavigationBarColor: UIColor?
    5.10 -    var defaultToolBarColor: UIColor?
    5.11 -
    5.12 -    static var sharedData: NavigationBarData = {
    5.13 -        return NavigationBarData()
    5.14 -    }()
    5.15 -
    5.16 -    func handleDefaults(navigationController: UINavigationController?) {
    5.17 -        if !handledDefault {
    5.18 -            handledDefault = true
    5.19 -            defaultNavigationBarColor = navigationController?.navigationBar.barTintColor
    5.20 -            defaultToolBarColor = navigationController?.toolbar.barTintColor
    5.21 -        }
    5.22 -    }
    5.23 -}
    5.24 -
    5.25  extension UIViewController {
    5.26      func showPepRating(pEpRating: PEP_rating?) {
    5.27 -        NavigationBarData.sharedData.handleDefaults(navigationController: navigationController)
    5.28 -
    5.29          // color
    5.30          if let color = pEpRating?.uiColor() {
    5.31              navigationController?.navigationBar.barTintColor = color
    5.32              navigationController?.toolbar.barTintColor = color
    5.33          } else {
    5.34 -            setDefaultBarColors()
    5.35 +            setNoColor()
    5.36          }
    5.37  
    5.38          // icon
    5.39 @@ -48,11 +28,19 @@
    5.40          }
    5.41      }
    5.42  
    5.43 -    func setDefaultBarColors() {
    5.44 +    func setNoColor() {
    5.45 +        navigationController?.navigationBar.barTintColor = nil
    5.46 +        navigationController?.toolbar.barTintColor = nil
    5.47 +        navigationController?.navigationItem.rightBarButtonItem = nil
    5.48 +        navigationController?.navigationBar.backgroundColor = nil
    5.49 +    }
    5.50 +
    5.51 +    func setDefaultColors() {
    5.52          navigationController?.navigationBar.barTintColor =
    5.53 -            NavigationBarData.sharedData.defaultNavigationBarColor
    5.54 +            UINavigationBar.appearance().barTintColor
    5.55          navigationController?.toolbar.barTintColor =
    5.56 -            NavigationBarData.sharedData.defaultToolBarColor
    5.57 -        navigationController?.navigationItem.rightBarButtonItem = nil
    5.58 +            UIToolbar.appearance().barTintColor
    5.59 +        navigationController?.navigationBar.backgroundColor =
    5.60 +            UINavigationBar.appearance().backgroundColor
    5.61      }
    5.62  }
     6.1 --- a/pEpForiOS/Util/Appearance.swift	Mon Mar 13 15:58:19 2017 +0100
     6.2 +++ b/pEpForiOS/Util/Appearance.swift	Mon Mar 13 17:37:36 2017 +0100
     6.3 @@ -10,7 +10,6 @@
     6.4  import UIKit
     6.5  
     6.6  class Appearance {
     6.7 -    
     6.8      static func standard() {
     6.9          UINavigationBar.appearance().backgroundColor = .white
    6.10          UINavigationBar.appearance().barTintColor = .white