-
Notifications
You must be signed in to change notification settings - Fork 2
/
UniLayoutProperties.swift
76 lines (53 loc) · 1.72 KB
/
UniLayoutProperties.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// UniLayoutProperties.swift
// UniLayout Pod
//
// Library helper: layout properties
// Used in combination with each UniLayout view, container or component to customize layout behavior
//
import UIKit
public enum UniMeasureSpec {
case unspecified
case limitSize
case exactSize
}
public protocol UniLayoutPaddedView {
var padding: UIEdgeInsets { get set }
}
public protocol UniLayoutView {
var layoutProperties: UniLayoutProperties { get set }
func measuredSize(sizeSpec: CGSize, widthSpec: UniMeasureSpec, heightSpec: UniMeasureSpec) -> CGSize
}
public class UniLayoutProperties {
// ---
// MARK: Constants for measuring
// ---
public static let unspecified: Int = 0
public static let limitSize: Int = 1
public static let exactSize: Int = 2
// ---
// MARK: Constants for automatic sizing
// ---
public static let stretchToParent: CGFloat = -1
public static let fitContent: CGFloat = -2
// ---
// MARK: Properties for layout
// ---
public var margin = UIEdgeInsetsMake(0, 0, 0, 0)
public var minWidth: CGFloat = 0
public var maxWidth: CGFloat = 0xFFFFFF
public var minHeight: CGFloat = 0
public var maxHeight: CGFloat = 0xFFFFFF
public var width: CGFloat = UniLayoutProperties.fitContent
public var height: CGFloat = UniLayoutProperties.fitContent
public var horizontalGravity: CGFloat = 0
public var verticalGravity: CGFloat = 0
public var weight: CGFloat = 0
public var hiddenTakesSpace = false
// ---
// MARK: Public initializer
// ---
public init() {
// Required to be able to create UniLayoutView implementations outside of the library
}
}