@@ -14,7 +14,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
14
14
/// A model that defines the appearance properties.
15
15
public let model : VM
16
16
17
- private var containerWidthConstraint : NSLayoutConstraint ?
17
+ private var contentViewWidthConstraint : NSLayoutConstraint ?
18
18
19
19
// MARK: - Subviews
20
20
@@ -24,10 +24,8 @@ open class UKModalController<VM: ModalVM>: UIViewController {
24
24
public var body = UIView ( )
25
25
/// The optional footer view of the modal.
26
26
public var footer : UIView ?
27
- /// The container view that holds the modal's content.
28
- public let container = UIView ( )
29
- /// The content view inside the container, holding the header, body, and footer.
30
- public let content = UIView ( )
27
+ /// The content view, holding the header, body, and footer.
28
+ public let contentView = UIView ( )
31
29
/// A scrollable wrapper for the body content.
32
30
public let bodyWrapper : UIScrollView = ContentSizedScrollView ( )
33
31
/// The overlay view that appears behind the modal.
@@ -70,14 +68,13 @@ open class UKModalController<VM: ModalVM>: UIViewController {
70
68
/// Sets up the modal's subviews and gesture recognizers.
71
69
open func setup( ) {
72
70
self . view. addSubview ( self . overlay)
73
- self . view. addSubview ( self . container)
74
- self . container. addSubview ( self . content)
71
+ self . view. addSubview ( self . contentView)
75
72
if let header {
76
- self . content . addSubview ( header)
73
+ self . contentView . addSubview ( header)
77
74
}
78
- self . content . addSubview ( self . bodyWrapper)
75
+ self . contentView . addSubview ( self . bodyWrapper)
79
76
if let footer {
80
- self . content . addSubview ( footer)
77
+ self . contentView . addSubview ( footer)
81
78
}
82
79
83
80
self . bodyWrapper. addSubview ( self . body)
@@ -104,8 +101,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
104
101
/// Applies styling to the modal's subviews.
105
102
open func style( ) {
106
103
Self . Style. overlay ( self . overlay, model: self . model)
107
- Self . Style. container ( self . container, model: self . model)
108
- Self . Style. content ( self . content, model: self . model)
104
+ Self . Style. contentView ( self . contentView, model: self . model)
109
105
Self . Style. bodyWrapper ( self . bodyWrapper)
110
106
}
111
107
@@ -114,7 +110,6 @@ open class UKModalController<VM: ModalVM>: UIViewController {
114
110
/// Configures the layout of the modal's subviews.
115
111
open func layout( ) {
116
112
self . overlay. allEdges ( )
117
- self . content. allEdges ( )
118
113
119
114
if let header {
120
115
header. top ( self . model. contentPaddings. top)
@@ -145,38 +140,38 @@ open class UKModalController<VM: ModalVM>: UIViewController {
145
140
self . bodyWrapper. horizontally ( )
146
141
self . bodyWrapper. setContentCompressionResistancePriority ( . defaultLow, for: . vertical)
147
142
148
- self . body. leading ( self . model. contentPaddings. leading, to: self . container )
149
- self . body. trailing ( self . model. contentPaddings. trailing, to: self . container )
143
+ self . body. leading ( self . model. contentPaddings. leading, to: self . contentView )
144
+ self . body. trailing ( self . model. contentPaddings. trailing, to: self . contentView )
150
145
151
- self . container . topAnchor. constraint (
146
+ self . contentView . topAnchor. constraint (
152
147
greaterThanOrEqualTo: self . view. safeAreaLayoutGuide. topAnchor,
153
148
constant: self . model. outerPaddings. top
154
149
) . isActive = true
155
- self . container . leadingAnchor. constraint (
150
+ self . contentView . leadingAnchor. constraint (
156
151
greaterThanOrEqualTo: self . view. safeAreaLayoutGuide. leadingAnchor,
157
152
constant: self . model. outerPaddings. leading
158
153
) . isActive = true
159
- self . container . trailingAnchor. constraint (
154
+ self . contentView . trailingAnchor. constraint (
160
155
lessThanOrEqualTo: self . view. safeAreaLayoutGuide. trailingAnchor,
161
156
constant: - self . model. outerPaddings. trailing
162
157
) . isActive = true
163
- self . container . heightAnchor. constraint (
158
+ self . contentView . heightAnchor. constraint (
164
159
greaterThanOrEqualToConstant: 80
165
160
) . isActive = true
166
161
167
- self . containerWidthConstraint = self . container . width ( self . model. size. maxWidth) . width
168
- self . containerWidthConstraint ? . priority = . defaultHigh
162
+ self . contentViewWidthConstraint = self . contentView . width ( self . model. size. maxWidth) . width
163
+ self . contentViewWidthConstraint ? . priority = . defaultHigh
169
164
170
- self . bodyWrapper. widthAnchor. constraint ( equalTo: self . container . widthAnchor) . isActive = true
165
+ self . bodyWrapper. widthAnchor. constraint ( equalTo: self . contentView . widthAnchor) . isActive = true
171
166
172
- self . container . centerHorizontally ( )
167
+ self . contentView . centerHorizontally ( )
173
168
}
174
169
175
170
open override func viewWillTransition(
176
171
to size: CGSize ,
177
172
with coordinator: any UIViewControllerTransitionCoordinator
178
173
) {
179
- self . containerWidthConstraint ? . isActive = false
174
+ self . contentViewWidthConstraint ? . isActive = false
180
175
super. viewWillTransition ( to: size, with: coordinator)
181
176
}
182
177
@@ -188,11 +183,11 @@ open class UKModalController<VM: ModalVM>: UIViewController {
188
183
+ self . model. outerPaddings. leading
189
184
+ self . model. outerPaddings. trailing
190
185
if availableWidth > requiredWidth {
191
- self . containerWidthConstraint ? . priority = . required
186
+ self . contentViewWidthConstraint ? . priority = . required
192
187
} else {
193
- self . containerWidthConstraint ? . priority = . defaultHigh
188
+ self . contentViewWidthConstraint ? . priority = . defaultHigh
194
189
}
195
- self . containerWidthConstraint ? . isActive = true
190
+ self . contentViewWidthConstraint ? . isActive = true
196
191
}
197
192
198
193
// MARK: - UIViewController Methods
@@ -207,7 +202,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
207
202
// MARK: - Helpers
208
203
209
204
@objc private func handleTraitChanges( ) {
210
- Self . Style. content ( self . content , model: self . model)
205
+ Self . Style. contentView ( self . contentView , model: self . model)
211
206
}
212
207
}
213
208
@@ -225,11 +220,7 @@ extension UKModalController {
225
220
( view as? UIVisualEffectView ) ? . effect = UIBlurEffect ( style: . systemUltraThinMaterial)
226
221
}
227
222
}
228
- static func container( _ view: UIView , model: VM ) {
229
- view. backgroundColor = UniversalColor . background. uiColor
230
- view. layer. cornerRadius = model. cornerRadius. value
231
- }
232
- static func content( _ view: UIView , model: VM ) {
223
+ static func contentView( _ view: UIView , model: VM ) {
233
224
view. backgroundColor = model. preferredBackgroundColor. uiColor
234
225
view. layer. cornerRadius = model. cornerRadius. value
235
226
view. layer. borderColor = UniversalColor . divider. cgColor
0 commit comments