Set default customisation

This commit is contained in:
Florian Gabach
2017-03-08 17:17:09 +01:00
parent 5acb789a62
commit 599de6b72a
3 changed files with 20 additions and 12 deletions
@@ -76,18 +76,24 @@ class OpenSourceViewController: UITableViewController {
self.tableView.dataSource = self
self.tableView.delegate = self
self.tableView.separatorStyle = .singleLine
self.tableView.backgroundColor = config.uiConfig.backgroundColor
if let backgroundColor = self.config.uiConfig.backgroundColor {
self.tableView.backgroundColor = backgroundColor
}
// Navigation bar
self.navigationController?.navigationBar.barTintColor = self.config.uiConfig.barTintColor
let attribut = [NSForegroundColorAttributeName: self.config.uiConfig.titleColor]
self.navigationController?.navigationBar.titleTextAttributes = attribut
if let tintColor = self.config.uiConfig.barTintColor {
self.navigationController?.navigationBar.barTintColor = tintColor
}
if let textColor = self.config.uiConfig.titleColor {
let attribut = [NSForegroundColorAttributeName: textColor]
self.navigationController?.navigationBar.titleTextAttributes = attribut
}
// Close button (on the right corner of navigation bar)
let closeButton = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(self.closePicker))
closeButton.tintColor = config.uiConfig.closeButtonColor
closeButton.tintColor = config.uiConfig.closeButtonColor ?? UIColor.black
self.navigationItem.rightBarButtonItem = closeButton
// Loading indicator
@@ -12,22 +12,22 @@ public struct OpenSourceControllerConfig {
/// Sub-stuct holding configuration relevant to UI presentation !
public struct UIConfig {
/// Will be applied to the navigation bar
public var barTintColor: UIColor = UIColor(red: 246/255.0, green: 246/255.0, blue: 246/255.0, alpha: 1.0)
public var barTintColor: UIColor?
/// Will be applied to the navigation bar
public var backgroundColor: UIColor = UIColor(red: 246/255.0, green: 246/255.0, blue: 246/255.0, alpha: 1.0)
public var backgroundColor: UIColor?
/// Will be applied to licence text
public var licenceBackgroundColor: UIColor = UIColor.white
public var licenceBackgroundColor: UIColor?
/// Will be applied to the navigation bar
public var closeButtonColor: UIColor = UIColor.black
public var closeButtonColor: UIColor?
/// Will be applied to licence text
public var licenceTextColor: UIColor = UIColor.black
public var licenceTextColor: UIColor?
/// Will be applied to licence text
public var titleColor: UIColor = UIColor.black
public var titleColor: UIColor?
}
/// Will be applied to the navigation bar title
@@ -64,6 +64,8 @@ class OpenSourceTableViewCell: UITableViewCell {
self.textLabel?.textColor = config.uiConfig.licenceTextColor
// Background
self.backgroundColor = config.uiConfig.licenceBackgroundColor
if let backgroundColor = config.uiConfig.licenceBackgroundColor {
self.backgroundColor = backgroundColor
}
}
}