Commit ff32d538 by Daniel Dahan

removed reload calls where layoutSubviews is sufficient

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