Commit 85b1f715 by Daniel Dahan

development: fixed grid calculations for ControlView and Navigation types

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