Commit 17269950 by Daniel Dahan

editor: moved Divider and Grid to struct types

parent 085dacdb
......@@ -31,7 +31,7 @@
965E80DB1DD4C50600D61E4B /* InterimSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7871CB40DC500C806FE /* InterimSpace.swift */; };
965E80DC1DD4C50600D61E4B /* Depth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7781CB40DC500C806FE /* Depth.swift */; };
965E80DD1DD4C50600D61E4B /* EdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77A1CB40DC500C806FE /* EdgeInsets.swift */; };
965E80DE1DD4C50600D61E4B /* MaterialGravity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */; };
965E80DE1DD4C50600D61E4B /* Gravity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB77C1CB40DC500C806FE /* Gravity.swift */; };
965E80DF1DD4C50600D61E4B /* CornerRadius.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7851CB40DC500C806FE /* CornerRadius.swift */; };
965E80E01DD4C50600D61E4B /* Shape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7861CB40DC500C806FE /* Shape.swift */; };
965E80E11DD4C50600D61E4B /* Offset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; };
......@@ -162,7 +162,7 @@
96BCB84E1CB4115200C806FE /* InterimSpace.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7871CB40DC500C806FE /* InterimSpace.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB84F1CB4115200C806FE /* Depth.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7781CB40DC500C806FE /* Depth.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8501CB4115200C806FE /* EdgeInsets.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77A1CB40DC500C806FE /* EdgeInsets.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8511CB4115200C806FE /* MaterialGravity.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8511CB4115200C806FE /* Gravity.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB77C1CB40DC500C806FE /* Gravity.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8521CB4115200C806FE /* CornerRadius.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7851CB40DC500C806FE /* CornerRadius.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8531CB4115200C806FE /* Shape.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7861CB40DC500C806FE /* Shape.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96BCB8551CB4115200C806FE /* PulseView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96BCB7841CB40DC500C806FE /* PulseView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -253,7 +253,7 @@
96BCB7791CB40DC500C806FE /* Device.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Device.swift; sourceTree = "<group>"; };
96BCB77A1CB40DC500C806FE /* EdgeInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EdgeInsets.swift; sourceTree = "<group>"; };
96BCB77B1CB40DC500C806FE /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialGravity.swift; sourceTree = "<group>"; };
96BCB77C1CB40DC500C806FE /* Gravity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Gravity.swift; sourceTree = "<group>"; };
96BCB77D1CB40DC500C806FE /* Icon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Icon.swift; sourceTree = "<group>"; };
96BCB77E1CB40DC500C806FE /* MotionKeyframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionKeyframe.swift; sourceTree = "<group>"; };
96BCB7801CB40DC500C806FE /* Layer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layer.swift; sourceTree = "<group>"; };
......@@ -684,7 +684,7 @@
96BCB7871CB40DC500C806FE /* InterimSpace.swift */,
96BCB7781CB40DC500C806FE /* Depth.swift */,
96BCB77A1CB40DC500C806FE /* EdgeInsets.swift */,
96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */,
96BCB77C1CB40DC500C806FE /* Gravity.swift */,
96BCB7851CB40DC500C806FE /* CornerRadius.swift */,
96BCB7861CB40DC500C806FE /* Shape.swift */,
968C99461D377849000074FF /* Offset.swift */,
......@@ -836,7 +836,7 @@
96BCB84E1CB4115200C806FE /* InterimSpace.swift in Headers */,
96BCB84F1CB4115200C806FE /* Depth.swift in Headers */,
96BCB8501CB4115200C806FE /* EdgeInsets.swift in Headers */,
96BCB8511CB4115200C806FE /* MaterialGravity.swift in Headers */,
96BCB8511CB4115200C806FE /* Gravity.swift in Headers */,
96BCB8521CB4115200C806FE /* CornerRadius.swift in Headers */,
96BCB8531CB4115200C806FE /* Shape.swift in Headers */,
96BCB8551CB4115200C806FE /* PulseView.swift in Headers */,
......@@ -1127,7 +1127,7 @@
965E80DB1DD4C50600D61E4B /* InterimSpace.swift in Sources */,
965E80DC1DD4C50600D61E4B /* Depth.swift in Sources */,
965E80DD1DD4C50600D61E4B /* EdgeInsets.swift in Sources */,
965E80DE1DD4C50600D61E4B /* MaterialGravity.swift in Sources */,
965E80DE1DD4C50600D61E4B /* Gravity.swift in Sources */,
965E80DF1DD4C50600D61E4B /* CornerRadius.swift in Sources */,
965E80FB1DD4D59500D61E4B /* SearchBar.swift in Sources */,
965E80E01DD4C50600D61E4B /* Shape.swift in Sources */,
......
......@@ -51,7 +51,7 @@ public struct Depth {
public var radius: CGFloat
/// Preset.
public var preset: DepthPreset = .none {
public var preset = DepthPreset.none {
didSet {
let depth = DepthPresetToValue(preset: preset)
offset = depth.offset
......@@ -66,7 +66,7 @@ public struct Depth {
- Parameter opacity: Float.
- Parameter radius: CGFloat.
*/
public init(offset: Offset = Offset.zero, opacity: Float = 0, radius: CGFloat = 0) {
public init(offset: Offset = .zero, opacity: Float = 0, radius: CGFloat = 0) {
self.offset = offset
self.opacity = opacity
self.radius = radius
......
......@@ -38,7 +38,7 @@ public enum DividerAlignment: Int {
case right
}
open class Divider {
public struct Divider {
/// A reference to the UIView.
internal weak var view: UIView?
......@@ -46,28 +46,28 @@ open class Divider {
internal var line: UIView?
/// A reference to the height.
open var thickness: CGFloat {
public var thickness: CGFloat {
didSet {
reload()
}
}
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset = EdgeInsetsPreset.none {
public var contentEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
contentEdgeInsets = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
}
}
/// A reference to EdgeInsets.
open var contentEdgeInsets = EdgeInsets.zero {
public var contentEdgeInsets = EdgeInsets.zero {
didSet {
reload()
}
}
/// A UIColor.
open var color: UIColor? {
public var color: UIColor? {
get {
return line?.backgroundColor
}
......@@ -88,7 +88,7 @@ open class Divider {
}
/// A reference to the dividerAlignment.
open var alignment = DividerAlignment.bottom {
public var alignment = DividerAlignment.bottom {
didSet {
reload()
}
......@@ -105,7 +105,7 @@ open class Divider {
}
/// Lays out the divider.
open func reload() {
public func reload() {
guard let l = line, let v = view else {
return
}
......
......@@ -128,12 +128,11 @@ public protocol EditorDelegate {
- Parameter in characterRange: A Range.
- Returns: A boolean indicating if the textView should interact with a URL in
a given character range, true if yes, false otherwise.
*/
@available(iOS, introduced: 8.0, obsoleted: 10.0)
@available(iOS, introduced: 8.0, deprecated: 10.0)
@objc
optional func editor(editor: Editor, textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool
/**
A delegation method that is executed when the textView should interact with
a text attachment in a given character range.
- Parameter editor: An Editor.
......@@ -142,12 +141,10 @@ public protocol EditorDelegate {
- Parameter in characterRange: A Range.
- Returns: A boolean indicating if the textView should interact with a
NSTextAttachment in a given character range, true if yes, false otherwise.
*/
@available(iOS, introduced: 8.0, obsoleted: 10.0)
@available(iOS, introduced: 8.0, deprecated: 10.0)
@objc
optional func editor(editor: Editor, textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange) -> Bool
/**
A delegation method that is executed when the textView should interact with
a URL in a given character range.
- Parameter editor: An Editor.
......@@ -157,12 +154,10 @@ public protocol EditorDelegate {
- Parameter interaction: A UITextItemInteraction.
- Returns: A boolean indicating if the textView should interact with a URL in
a given character range, true if yes, false otherwise.
*/
@available(iOS 10.0, *)
@objc
optional func editor(editor: Editor, textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
/**
A delegation method that is executed when the textView should interact with
a text attachment in a given character range.
- Parameter editor: An Editor.
......@@ -172,10 +167,10 @@ public protocol EditorDelegate {
- Parameter interaction: A UITextItemInteraction.
- Returns: A boolean indicating if the textView should interact with a
NSTextAttachment in a given character range, true if yes, false otherwise.
*/
@available(iOS 10.0, *)
@objc
optional func editor(editor: Editor, textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
*/
}
open class Editor: View {
......@@ -347,7 +342,8 @@ extension Editor: TextViewDelegate {
}
}
@available(iOS, introduced: 8.0, obsoleted: 10.0)
/*
@available(iOS, introduced: 8.0, deprecated: : 10.0)
extension Editor {
open func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: URL, in: characterRange) ?? true
......@@ -368,3 +364,4 @@ extension Editor {
return delegate?.editor?(editor: self, textView: textView, shouldInteractWith: textAttachment, in: characterRange, interaction: interaction) ?? true
}
}
*/
......@@ -76,7 +76,7 @@ public struct GridOffset {
}
}
public class Grid {
public struct Grid {
/// Defer the calculation.
public var deferred = false
......@@ -169,7 +169,7 @@ public class Grid {
- Parameter columns: The number of columns, horizontal axis the grid will use.
- Parameter interimSpace: The interim space between rows or columns.
*/
public init(context: UIView?, rows: Int = 0, columns: Int = 0, interimSpace: InterimSpace = 0) {
internal init(context: UIView?, rows: Int = 0, columns: Int = 0, interimSpace: InterimSpace = 0) {
self.context = context
self.rows = rows
self.columns = columns
......@@ -177,12 +177,12 @@ public class Grid {
}
/// Begins a deferred block.
public func begin() {
mutating public func begin() {
deferred = true
}
/// Completes a deferred block.
public func commit() {
mutating public func commit() {
deferred = false
reload()
}
......@@ -269,7 +269,7 @@ private var GridKey: UInt8 = 0
/// Grid extension for UIView.
extension UIView {
/// Grid reference.
public fileprivate(set) var grid: Grid {
public var grid: Grid {
get {
return AssociatedObject(base: self, key: &GridKey) {
return Grid(context: self)
......
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