Commit ff32d538 by Daniel Dahan

removed reload calls where layoutSubviews is sufficient

parent 47afc002
...@@ -39,7 +39,7 @@ public enum ContentViewAlignment: Int { ...@@ -39,7 +39,7 @@ public enum ContentViewAlignment: Int {
open class Bar: View { open class Bar: View {
/// Will layout the view. /// Will layout the view.
open var willLayout: Bool { open var willLayout: Bool {
return 0 < width && 0 < height && nil != superview return 0 < width && 0 < height && nil != superview && !grid.deferred
} }
open override var intrinsicContentSize: CGSize { open override var intrinsicContentSize: CGSize {
...@@ -183,15 +183,6 @@ open class Bar: View { ...@@ -183,15 +183,6 @@ open class Bar: View {
return return
} }
guard !grid.deferred else {
return
}
reload()
}
/// Reloads the view.
open func reload() {
var lc = 0 var lc = 0
var rc = 0 var rc = 0
......
...@@ -53,19 +53,7 @@ open class CollectionViewCard: Card { ...@@ -53,19 +53,7 @@ open class CollectionViewCard: Card {
@IBInspectable @IBInspectable
open let collectionView = CollectionView() open let collectionView = CollectionView()
open override func layoutSubviews() { /// Reloads the view.
super.layoutSubviews()
reload()
}
open override func prepare() {
super.prepare()
pulseAnimation = .none
prepareCollectionView()
prepareContentView()
}
open override func reload() { open override func reload() {
if 0 == collectionView.height { if 0 == collectionView.height {
var h: CGFloat = 0 var h: CGFloat = 0
...@@ -79,7 +67,22 @@ open class CollectionViewCard: Card { ...@@ -79,7 +67,22 @@ open class CollectionViewCard: Card {
collectionView.reloadData() collectionView.reloadData()
super.reload() super.layoutSubviews()
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open override func prepare() {
super.prepare()
pulseAnimation = .none
prepareCollectionView()
prepareContentView()
} }
} }
......
...@@ -82,6 +82,7 @@ open class ImageCard: Card { ...@@ -82,6 +82,7 @@ open class ImageCard: Card {
} }
} }
/// Reloads the view.
open override func reload() { open override func reload() {
var h: CGFloat = 0 var h: CGFloat = 0
......
...@@ -70,9 +70,11 @@ open class Snackbar: Bar { ...@@ -70,9 +70,11 @@ open class Snackbar: Bar {
return super.hitTest(point, with: event) return super.hitTest(point, with: event)
} }
/// Reloads the view. open override func layoutSubviews() {
open override func reload() { super.layoutSubviews()
super.reload() guard willLayout else {
return
}
centerViews = [textLabel] centerViews = [textLabel]
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
import UIKit import UIKit
/// A memory reference to the TabMenuBarItem instance for UIViewController extensions. /// A memory reference to the TabMenuBarItem instance for UIViewController extensions.
fileprivate var TabMenuBarItemKey: UInt8 = 0 fileprivate var TabMenuBarItemKey: UInt8 = 0
......
...@@ -378,7 +378,12 @@ open class TextField: UITextField { ...@@ -378,7 +378,12 @@ open class TextField: UITextField {
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
layoutShape() layoutShape()
reload() layoutPlaceholderLabel()
layoutDetailLabel()
layoutButton(button: clearIconButton)
layoutButton(button: visibilityIconButton)
layoutDivider()
layoutLeftView()
} }
open override func becomeFirstResponder() -> Bool { open override func becomeFirstResponder() -> Bool {
...@@ -421,16 +426,6 @@ open class TextField: UITextField { ...@@ -421,16 +426,6 @@ open class TextField: UITextField {
prepareTargetHandlers() prepareTargetHandlers()
prepareTextAlignment() prepareTextAlignment()
} }
/// Ensures that the components are sized correctly.
open func reload() {
layoutPlaceholderLabel()
layoutDetailLabel()
layoutButton(button: clearIconButton)
layoutButton(button: visibilityIconButton)
layoutDivider()
layoutLeftView()
}
} }
extension TextField { extension TextField {
......
...@@ -95,9 +95,11 @@ open class Toolbar: Bar { ...@@ -95,9 +95,11 @@ open class Toolbar: Bar {
contentViewAlignment = .center == titleLabel.textAlignment ? .center : .full contentViewAlignment = .center == titleLabel.textAlignment ? .center : .full
} }
/// Reloads the view. open override func layoutSubviews() {
open override func reload() { super.layoutSubviews()
super.reload() guard willLayout else {
return
}
if nil != title && "" != title { if nil != title && "" != title {
if nil == titleLabel.superview { if nil == titleLabel.superview {
......
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