Commit 74978847 by Daniel Dahan

minor code cleanup

parent cb070075
...@@ -110,9 +110,10 @@ open class Bar: View { ...@@ -110,9 +110,10 @@ open class Bar: View {
/// Left side UIViews. /// Left side UIViews.
open var leftViews = [UIView]() { open var leftViews = [UIView]() {
didSet { didSet {
for v in oldValue { oldValue.forEach {
v.removeFromSuperview() $0.removeFromSuperview()
} }
layoutSubviews() layoutSubviews()
} }
} }
...@@ -120,9 +121,10 @@ open class Bar: View { ...@@ -120,9 +121,10 @@ open class Bar: View {
/// Right side UIViews. /// Right side UIViews.
open var rightViews = [UIView]() { open var rightViews = [UIView]() {
didSet { didSet {
for v in oldValue { oldValue.forEach {
v.removeFromSuperview() $0.removeFromSuperview()
} }
layoutSubviews() layoutSubviews()
} }
} }
......
...@@ -69,9 +69,11 @@ open class Card: PulseView { ...@@ -69,9 +69,11 @@ open class Card: PulseView {
open var toolbar: Toolbar? { open var toolbar: Toolbar? {
didSet { didSet {
oldValue?.removeFromSuperview() oldValue?.removeFromSuperview()
if let v = toolbar { if let v = toolbar {
container.addSubview(v) container.addSubview(v)
} }
layoutSubviews() layoutSubviews()
} }
} }
...@@ -96,10 +98,12 @@ open class Card: PulseView { ...@@ -96,10 +98,12 @@ open class Card: PulseView {
open var contentView: UIView? { open var contentView: UIView? {
didSet { didSet {
oldValue?.removeFromSuperview() oldValue?.removeFromSuperview()
if let v = contentView { if let v = contentView {
v.clipsToBounds = true v.clipsToBounds = true
container.addSubview(v) container.addSubview(v)
} }
layoutSubviews() layoutSubviews()
} }
} }
...@@ -124,9 +128,11 @@ open class Card: PulseView { ...@@ -124,9 +128,11 @@ open class Card: PulseView {
open var bottomBar: Bar? { open var bottomBar: Bar? {
didSet { didSet {
oldValue?.removeFromSuperview() oldValue?.removeFromSuperview()
if let v = bottomBar { if let v = bottomBar {
container.addSubview(v) container.addSubview(v)
} }
layoutSubviews() layoutSubviews()
} }
} }
......
...@@ -207,8 +207,8 @@ open class ChipBar: Bar { ...@@ -207,8 +207,8 @@ open class ChipBar: Bar {
/// Buttons. /// Buttons.
open var chipItems = [ChipItem]() { open var chipItems = [ChipItem]() {
didSet { didSet {
for b in oldValue { oldValue.forEach {
b.removeFromSuperview() $0.removeFromSuperview()
} }
prepareChipItems() prepareChipItems()
......
...@@ -227,6 +227,7 @@ open class FABMenu: View { ...@@ -227,6 +227,7 @@ open class FABMenu: View {
} }
addSubview(v) addSubview(v)
v.addTarget(self, action: #selector(handleFABButton(button:)), for: .touchUpInside) v.addTarget(self, action: #selector(handleFABButton(button:)), for: .touchUpInside)
} }
} }
......
...@@ -157,9 +157,10 @@ public struct Grid { ...@@ -157,9 +157,10 @@ public struct Grid {
/// An Array of UIButtons. /// An Array of UIButtons.
public var views = [UIView]() { public var views = [UIView]() {
didSet { didSet {
for v in oldValue { oldValue.forEach {
v.removeFromSuperview() $0.removeFromSuperview()
} }
reload() reload()
} }
} }
......
...@@ -62,9 +62,11 @@ open class ImageCard: Card { ...@@ -62,9 +62,11 @@ open class ImageCard: Card {
open var imageView: UIImageView? { open var imageView: UIImageView? {
didSet { didSet {
oldValue?.removeFromSuperview() oldValue?.removeFromSuperview()
if let v = imageView { if let v = imageView {
container.addSubview(v) container.addSubview(v)
} }
layoutSubviews() layoutSubviews()
} }
} }
......
...@@ -51,10 +51,12 @@ open class PresenterCard: Card { ...@@ -51,10 +51,12 @@ open class PresenterCard: Card {
open var presenterView: UIView? { open var presenterView: UIView? {
didSet { didSet {
oldValue?.removeFromSuperview() oldValue?.removeFromSuperview()
if let v = presenterView { if let v = presenterView {
v.clipsToBounds = true v.clipsToBounds = true
container.addSubview(v) container.addSubview(v)
} }
layoutSubviews() layoutSubviews()
} }
} }
......
...@@ -212,12 +212,11 @@ open class TabBar: Bar { ...@@ -212,12 +212,11 @@ open class TabBar: Bar {
@objc @objc
open var tabItems = [TabItem]() { open var tabItems = [TabItem]() {
didSet { didSet {
for b in oldValue { oldValue.forEach {
b.removeFromSuperview() $0.removeFromSuperview()
} }
prepareTabItems() prepareTabItems()
layoutSubviews() layoutSubviews()
} }
} }
......
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