@@ -14,7 +14,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
1414 /// A model that defines the appearance properties.
1515 public let model : VM
1616
17- private var containerWidthConstraint : NSLayoutConstraint ?
17+ private var contentViewWidthConstraint : NSLayoutConstraint ?
1818
1919 // MARK: - Subviews
2020
@@ -24,10 +24,8 @@ open class UKModalController<VM: ModalVM>: UIViewController {
2424 public var body = UIView ( )
2525 /// The optional footer view of the modal.
2626 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 ( )
3129 /// A scrollable wrapper for the body content.
3230 public let bodyWrapper : UIScrollView = ContentSizedScrollView ( )
3331 /// The overlay view that appears behind the modal.
@@ -70,14 +68,13 @@ open class UKModalController<VM: ModalVM>: UIViewController {
7068 /// Sets up the modal's subviews and gesture recognizers.
7169 open func setup( ) {
7270 self . view. addSubview ( self . overlay)
73- self . view. addSubview ( self . container)
74- self . container. addSubview ( self . content)
71+ self . view. addSubview ( self . contentView)
7572 if let header {
76- self . content . addSubview ( header)
73+ self . contentView . addSubview ( header)
7774 }
78- self . content . addSubview ( self . bodyWrapper)
75+ self . contentView . addSubview ( self . bodyWrapper)
7976 if let footer {
80- self . content . addSubview ( footer)
77+ self . contentView . addSubview ( footer)
8178 }
8279
8380 self . bodyWrapper. addSubview ( self . body)
@@ -104,8 +101,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
104101 /// Applies styling to the modal's subviews.
105102 open func style( ) {
106103 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)
109105 Self . Style. bodyWrapper ( self . bodyWrapper)
110106 }
111107
@@ -114,7 +110,6 @@ open class UKModalController<VM: ModalVM>: UIViewController {
114110 /// Configures the layout of the modal's subviews.
115111 open func layout( ) {
116112 self . overlay. allEdges ( )
117- self . content. allEdges ( )
118113
119114 if let header {
120115 header. top ( self . model. contentPaddings. top)
@@ -145,38 +140,38 @@ open class UKModalController<VM: ModalVM>: UIViewController {
145140 self . bodyWrapper. horizontally ( )
146141 self . bodyWrapper. setContentCompressionResistancePriority ( . defaultLow, for: . vertical)
147142
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 )
150145
151- self . container . topAnchor. constraint (
146+ self . contentView . topAnchor. constraint (
152147 greaterThanOrEqualTo: self . view. safeAreaLayoutGuide. topAnchor,
153148 constant: self . model. outerPaddings. top
154149 ) . isActive = true
155- self . container . leadingAnchor. constraint (
150+ self . contentView . leadingAnchor. constraint (
156151 greaterThanOrEqualTo: self . view. safeAreaLayoutGuide. leadingAnchor,
157152 constant: self . model. outerPaddings. leading
158153 ) . isActive = true
159- self . container . trailingAnchor. constraint (
154+ self . contentView . trailingAnchor. constraint (
160155 lessThanOrEqualTo: self . view. safeAreaLayoutGuide. trailingAnchor,
161156 constant: - self . model. outerPaddings. trailing
162157 ) . isActive = true
163- self . container . heightAnchor. constraint (
158+ self . contentView . heightAnchor. constraint (
164159 greaterThanOrEqualToConstant: 80
165160 ) . isActive = true
166161
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
169164
170- self . bodyWrapper. widthAnchor. constraint ( equalTo: self . container . widthAnchor) . isActive = true
165+ self . bodyWrapper. widthAnchor. constraint ( equalTo: self . contentView . widthAnchor) . isActive = true
171166
172- self . container . centerHorizontally ( )
167+ self . contentView . centerHorizontally ( )
173168 }
174169
175170 open override func viewWillTransition(
176171 to size: CGSize ,
177172 with coordinator: any UIViewControllerTransitionCoordinator
178173 ) {
179- self . containerWidthConstraint ? . isActive = false
174+ self . contentViewWidthConstraint ? . isActive = false
180175 super. viewWillTransition ( to: size, with: coordinator)
181176 }
182177
@@ -188,11 +183,11 @@ open class UKModalController<VM: ModalVM>: UIViewController {
188183 + self . model. outerPaddings. leading
189184 + self . model. outerPaddings. trailing
190185 if availableWidth > requiredWidth {
191- self . containerWidthConstraint ? . priority = . required
186+ self . contentViewWidthConstraint ? . priority = . required
192187 } else {
193- self . containerWidthConstraint ? . priority = . defaultHigh
188+ self . contentViewWidthConstraint ? . priority = . defaultHigh
194189 }
195- self . containerWidthConstraint ? . isActive = true
190+ self . contentViewWidthConstraint ? . isActive = true
196191 }
197192
198193 // MARK: - UIViewController Methods
@@ -207,7 +202,7 @@ open class UKModalController<VM: ModalVM>: UIViewController {
207202 // MARK: - Helpers
208203
209204 @objc private func handleTraitChanges( ) {
210- Self . Style. content ( self . content , model: self . model)
205+ Self . Style. contentView ( self . contentView , model: self . model)
211206 }
212207}
213208
@@ -225,11 +220,7 @@ extension UKModalController {
225220 ( view as? UIVisualEffectView ) ? . effect = UIBlurEffect ( style: . systemUltraThinMaterial)
226221 }
227222 }
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 ) {
233224 view. backgroundColor = model. preferredBackgroundColor. uiColor
234225 view. layer. cornerRadius = model. cornerRadius. value
235226 view. layer. borderColor = UniversalColor . divider. cgColor
0 commit comments