Commit fd0b041e by Daniel Dahan

development: updated Toolbar title and detail to be @IBInspectable

parent 8d997a6d
...@@ -33,8 +33,9 @@ import UIKit ...@@ -33,8 +33,9 @@ import UIKit
private var ToolbarContext: UInt8 = 0 private var ToolbarContext: UInt8 = 0
open class Toolbar: Bar { open class Toolbar: Bar {
/// A convenience property to set the titleLabel text. /// A convenience property to set the titleLabel.text.
open var title: String? { @IBInspectable
open var title: String? {
get { get {
return titleLabel.text return titleLabel.text
} }
...@@ -45,10 +46,12 @@ open class Toolbar: Bar { ...@@ -45,10 +46,12 @@ open class Toolbar: Bar {
} }
/// Title label. /// Title label.
open fileprivate(set) lazy var titleLabel = UILabel() @IBInspectable
open let titleLabel = UILabel()
/// A convenience property to set the detailLabel text. /// A convenience property to set the detailLabel.text.
open var detail: String? { @IBInspectable
open var detail: String? {
get { get {
return detailLabel.text return detailLabel.text
} }
...@@ -59,7 +62,8 @@ open class Toolbar: Bar { ...@@ -59,7 +62,8 @@ open class Toolbar: Bar {
} }
/// Detail label. /// Detail label.
open fileprivate(set) lazy var detailLabel = UILabel() @IBInspectable
open let detailLabel = UILabel()
deinit { deinit {
removeObserver(self, forKeyPath: "titleLabel.textAlignment") removeObserver(self, forKeyPath: "titleLabel.textAlignment")
...@@ -142,21 +146,23 @@ open class Toolbar: Bar { ...@@ -142,21 +146,23 @@ open class Toolbar: Bar {
prepareTitleLabel() prepareTitleLabel()
prepareDetailLabel() prepareDetailLabel()
} }
}
/// Prepares the titleLabel.
private func prepareTitleLabel() { extension Toolbar {
/// Prepares the titleLabel.
fileprivate func prepareTitleLabel() {
titleLabel.textAlignment = .center titleLabel.textAlignment = .center
titleLabel.contentScaleFactor = Screen.scale titleLabel.contentScaleFactor = Screen.scale
titleLabel.font = RobotoFont.medium(with: 17) titleLabel.font = RobotoFont.medium(with: 17)
titleLabel.textColor = Color.darkText.primary titleLabel.textColor = Color.darkText.primary
addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &ToolbarContext) addObserver(self, forKeyPath: "titleLabel.textAlignment", options: [], context: &ToolbarContext)
} }
/// Prepares the detailLabel. /// Prepares the detailLabel.
private func prepareDetailLabel() { fileprivate func prepareDetailLabel() {
detailLabel.textAlignment = .center detailLabel.textAlignment = .center
detailLabel.contentScaleFactor = Screen.scale detailLabel.contentScaleFactor = Screen.scale
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.textColor = Color.darkText.secondary detailLabel.textColor = Color.darkText.secondary
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment