Commit 6f688295 by Daniel Dahan

Merge branch 'development' into editor

parents 689434d3 d8ec48b9
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '2.3.2' s.version = '2.3.4'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'
s.summary = 'Material is an animation and graphics framework that is used to create beautiful applications.' s.summary = 'Material is an animation and graphics framework that is used to create beautiful applications.'
s.homepage = 'http://materialswift.com' s.homepage = 'http://materialswift.com'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.3.2</string> <string>2.3.4</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -35,8 +35,8 @@ open class ErrorTextField: TextField { ...@@ -35,8 +35,8 @@ open class ErrorTextField: TextField {
@IBInspectable @IBInspectable
open var isErrorRevealed = false { open var isErrorRevealed = false {
didSet { didSet {
layoutDetailLabel()
detailLabel.isHidden = !isErrorRevealed detailLabel.isHidden = !isErrorRevealed
layoutSubviews()
} }
} }
......
...@@ -37,70 +37,40 @@ public enum GridAxisDirection: Int { ...@@ -37,70 +37,40 @@ public enum GridAxisDirection: Int {
case vertical case vertical
} }
public class GridAxis { public struct GridAxis {
/// Grid reference.
unowned var grid: Grid
/// The direction the grid lays its views out. /// The direction the grid lays its views out.
open var direction: GridAxisDirection = .horizontal { var direction = GridAxisDirection.horizontal
didSet {
grid.reload()
}
}
/// The rows size. /// The rows size.
public var rows: Int { public var rows: Int
didSet {
grid.reload()
}
}
/// The columns size. /// The columns size.
public var columns: Int { public var columns: Int
didSet {
grid.reload()
}
}
/** /**
Initializer. Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, vertical axis the grid will use. - Parameter rows: The number of rows, vertical axis the grid will use.
- Parameter columns: The number of columns, horizontal axis the grid will use. - Parameter columns: The number of columns, horizontal axis the grid will use.
*/ */
public init(grid: Grid, rows: Int = 12, columns: Int = 12) { public init(rows: Int = 12, columns: Int = 12) {
self.grid = grid
self.rows = rows self.rows = rows
self.columns = columns self.columns = columns
} }
} }
public class GridOffset { public struct GridOffset {
/// Grid reference.
unowned var grid: Grid
/// The rows size. /// The rows size.
public var rows: Int { public var rows: Int
didSet {
grid.reload()
}
}
/// The columns size. /// The columns size.
public var columns: Int { public var columns: Int
didSet {
grid.reload()
}
}
/** /**
Initializer. Initializer.
- Parameter grid: The Grid reference used for offset values.
- Parameter rows: The number of rows, vertical axis the grid will use. - Parameter rows: The number of rows, vertical axis the grid will use.
- Parameter columns: The number of columns, horizontal axis the grid will use. - Parameter columns: The number of columns, horizontal axis the grid will use.
*/ */
public init(grid: Grid, rows: Int = 0, columns: Int = 0) { public init(rows: Int = 0, columns: Int = 0) {
self.grid = grid
self.rows = rows self.rows = rows
self.columns = columns self.columns = columns
} }
...@@ -128,10 +98,18 @@ public class Grid { ...@@ -128,10 +98,18 @@ public class Grid {
} }
/// Offsets for rows and columns. /// Offsets for rows and columns.
public private(set) var offset: GridOffset! public var offset = GridOffset() {
didSet {
reload()
}
}
/// The axis in which the Grid is laying out its views. /// The axis in which the Grid is laying out its views.
public private(set) var axis: GridAxis! public var axis = GridAxis() {
didSet {
reload()
}
}
/// Preset inset value for grid. /// Preset inset value for grid.
public var layoutEdgeInsetsPreset = EdgeInsetsPreset.none { public var layoutEdgeInsetsPreset = EdgeInsetsPreset.none {
...@@ -178,6 +156,9 @@ public class Grid { ...@@ -178,6 +156,9 @@ public class Grid {
/// An Array of UIButtons. /// An Array of UIButtons.
public var views = [UIView]() { public var views = [UIView]() {
didSet { didSet {
for v in oldValue {
v.removeFromSuperview()
}
reload() reload()
} }
} }
...@@ -193,8 +174,6 @@ public class Grid { ...@@ -193,8 +174,6 @@ public class Grid {
self.rows = rows self.rows = rows
self.columns = columns self.columns = columns
self.interimSpace = interimSpace self.interimSpace = interimSpace
offset = GridOffset(grid: self)
axis = GridAxis(grid: self)
} }
/// Begins a deferred block. /// Begins a deferred block.
...@@ -214,6 +193,14 @@ public class Grid { ...@@ -214,6 +193,14 @@ public class Grid {
return return
} }
guard let canvas = context else {
return
}
guard 0 < canvas.width && 0 < canvas.height else {
return
}
let count = views.count let count = views.count
guard 0 < count else { guard 0 < count else {
...@@ -224,14 +211,6 @@ public class Grid { ...@@ -224,14 +211,6 @@ public class Grid {
var i = 0 var i = 0
for v in views { for v in views {
guard let canvas = context else {
return
}
guard 0 < canvas.width && 0 < canvas.height else {
return
}
if canvas != v.superview { if canvas != v.superview {
v.removeFromSuperview() v.removeFromSuperview()
canvas.addSubview(v) canvas.addSubview(v)
......
...@@ -36,11 +36,11 @@ ...@@ -36,11 +36,11 @@
- Returns: The associated reference for the initializer object. - Returns: The associated reference for the initializer object.
*/ */
internal func AssociatedObject<T: Any>(base: Any, key: UnsafePointer<UInt8>, initializer: () -> T) -> T { internal func AssociatedObject<T: Any>(base: Any, key: UnsafePointer<UInt8>, initializer: () -> T) -> T {
if let v: T = objc_getAssociatedObject(base, key) as? T { if let v = objc_getAssociatedObject(base, key) as? T {
return v return v
} }
let v: T = initializer() let v = initializer()
objc_setAssociatedObject(base, key, v, .OBJC_ASSOCIATION_RETAIN) objc_setAssociatedObject(base, key, v, .OBJC_ASSOCIATION_RETAIN)
return v return v
} }
......
...@@ -103,7 +103,7 @@ open class PageTabBarController: RootController { ...@@ -103,7 +103,7 @@ open class PageTabBarController: RootController {
/// Reference to the PageTabBar. /// Reference to the PageTabBar.
open private(set) lazy var pageTabBar: PageTabBar = PageTabBar() open private(set) lazy var pageTabBar: PageTabBar = PageTabBar()
/// A boolean that indicates whether bounds is enabled. /// A boolean that indicates whether bounce is enabled.
open var isBounceEnabled: Bool { open var isBounceEnabled: Bool {
didSet { didSet {
scrollView?.bounces = isBounceEnabled scrollView?.bounces = isBounceEnabled
......
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