Commit 85b1f715 by Daniel Dahan

development: fixed grid calculations for ControlView and Navigation types

parent 838fadf0
......@@ -195,8 +195,6 @@ open class ControlView: View {
grid.views.append(v)
}
grid.commit()
contentView.grid.begin()
if .center == contentViewAlignment {
if lc < rc {
......@@ -209,6 +207,8 @@ open class ControlView: View {
} else {
contentView.grid.columns = columns - lc - rc
}
grid.commit()
contentView.grid.commit()
}
}
......
......@@ -230,10 +230,6 @@ open class NavigationBar: UINavigationBar {
item.titleView!.grid.views.append(v)
}
item.titleView!.grid.interimSpace = interimSpace
item.titleView!.grid.contentEdgeInsets = contentEdgeInsets
item.titleView!.grid.commit()
item.contentView.grid.begin()
if .center == item.contentViewAlignment {
if lc < rc {
......@@ -246,6 +242,10 @@ open class NavigationBar: UINavigationBar {
} else {
item.contentView.grid.columns = columns - lc - rc
}
item.titleView!.grid.interimSpace = interimSpace
item.titleView!.grid.contentEdgeInsets = contentEdgeInsets
item.titleView!.grid.commit()
item.contentView.grid.commit()
// contentView alignment.
......
......@@ -176,7 +176,6 @@ open class RootController: UIViewController {
addChildViewController(v)
container.addSubview(v.view)
v.didMove(toParentViewController: self)
v.view.frame = container.bounds
v.view.clipsToBounds = true
v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
v.view.contentScaleFactor = Device.scale
......
......@@ -77,6 +77,13 @@ open class Snackbar: BarView {
return super.hitTest(point, with: event)
}
open override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
textLabel.frame = contentView.bounds
}
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
......@@ -102,8 +109,6 @@ open class Snackbar: BarView {
textLabel.textAlignment = .left
textLabel.textColor = Color.white
textLabel.numberOfLines = 0
contentView.backgroundColor = Color.green.base
contentView.grid.views.append(textLabel)
contentView.addSubview(textLabel)
}
}
......@@ -78,7 +78,7 @@ open class TabBar: BarView {
b.removeFromSuperview()
}
grid.views = buttons as [UIView]
contentView.grid.views = buttons as [UIView]
layoutSubviews()
}
......@@ -130,25 +130,28 @@ open class TabBar: BarView {
open override func layoutSubviews() {
super.layoutSubviews()
if willRenderView {
if 0 < buttons.count {
let columns: Int = grid.axis.columns / buttons.count
for b in buttons {
b.grid.columns = columns
b.contentEdgeInsets = .zero
b.layer.cornerRadius = 0
if isLineAnimated {
prepareLineAnimationHandler(button: b)
}
}
grid.reload()
guard 0 < buttons.count else {
return
}
let columns: Int = contentView.grid.axis.columns / buttons.count
for b in buttons {
b.grid.columns = columns
b.contentEdgeInsets = .zero
b.cornerRadius = 0
if nil == selected {
selected = buttons.first
if isLineAnimated {
prepareLineAnimationHandler(button: b)
}
}
contentView.grid.reload()
line.frame = CGRect(x: selected!.x, y: .bottom == lineAlignment ? height - lineHeight : 0, width: selected!.width, height: lineHeight)
if nil == selected {
selected = buttons.first
}
}
line.frame = CGRect(x: selected!.x, y: .bottom == lineAlignment ? height - lineHeight : 0, width: selected!.width, height: lineHeight)
}
}
/// Handles the button touch event.
......
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