@@ -14,7 +14,7 @@ import UIKit
14
14
of the optional SwiftMessages protocols and provides some convenience functions
15
15
and a configurable tap handler. Message views do not need to inherit from `BaseVew`.
16
16
*/
17
- open class BaseView : UIView , BackgroundViewable , MarginAdjustable , MessageSizeable {
17
+ open class BaseView : UIView , BackgroundViewable , MarginAdjustable , LayoutDefining {
18
18
19
19
/*
20
20
MARK: - IB outlets
@@ -63,6 +63,7 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable, MessageSizeab
63
63
*/
64
64
65
65
/**
66
+ TODO SIZE - update documentation
66
67
A convenience function for installing a content view as a subview of `backgroundView`
67
68
and pinning the edges to `backgroundView` with the specified `insets`.
68
69
@@ -82,6 +83,7 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable, MessageSizeab
82
83
}
83
84
84
85
/**
86
+ TODO SIZE - update documentation - insets removed
85
87
A convenience function for installing a background view and pinning to the layout margins.
86
88
This is useful for creating programatic layouts where the background view needs to be
87
89
inset from the message view's edges (like a card-style layout).
@@ -90,7 +92,7 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable, MessageSizeab
90
92
assigned to the `backgroundView` property.
91
93
- Parameter insets: The amount to inset the content view from the margins. Default is zero inset.
92
94
*/
93
- open func installBackgroundView( _ backgroundView: UIView , insets : UIEdgeInsets = UIEdgeInsets . zero ) {
95
+ open func installBackgroundView( _ backgroundView: UIView ) {
94
96
backgroundView. translatesAutoresizingMaskIntoConstraints = false
95
97
if backgroundView != self {
96
98
backgroundView. removeFromSuperview ( )
@@ -100,65 +102,57 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable, MessageSizeab
100
102
NSLayoutConstraint . activate ( [
101
103
backgroundView. centerXAnchor. constraint ( equalTo: centerXAnchor)
102
104
. with ( priority: . belowMessageSizeable) ,
103
- backgroundView. topAnchor. constraint (
104
- equalTo: layoutMarginsGuide. topAnchor,
105
- constant: insets. top
106
- ) . with ( priority: . belowMessageSizeable) ,
107
- backgroundView. bottomAnchor. constraint (
108
- equalTo: layoutMarginsGuide. bottomAnchor,
109
- constant: - insets. bottom
110
- ) . with ( priority: . belowMessageSizeable) ,
111
- backgroundView. heightAnchor. constraint ( equalToConstant: 350 )
112
- . with ( priority: UILayoutPriority ( rawValue: 200 ) ) ,
113
- backgroundView. leftAnchor. constraint (
114
- equalTo: layoutMarginsGuide. leftAnchor,
115
- constant: insets. left
116
- ) . with ( priority: . belowMessageSizeable) ,
117
- backgroundView. rightAnchor. constraint (
118
- equalTo: layoutMarginsGuide. rightAnchor,
119
- constant: - insets. right
120
- ) . with ( priority: . belowMessageSizeable) ,
121
- ] )
122
- installTapRecognizer ( )
123
- }
124
-
125
- /**
126
- A convenience function for installing a background view and pinning to the horizontal
127
- layout margins and to the vertical edges. This is useful for creating programatic layouts where
128
- the background view needs to be inset from the message view's horizontal edges (like a tab-style layout).
129
-
130
- - Parameter backgroundView: The view to be installed as a subview and
131
- assigned to the `backgroundView` property.
132
- - Parameter insets: The amount to inset the content view from the horizontal margins and vertical edges.
133
- Default is zero inset.
134
- */
135
- open func installBackgroundVerticalView( _ backgroundView: UIView , insets: UIEdgeInsets = UIEdgeInsets . zero) {
136
- backgroundView. translatesAutoresizingMaskIntoConstraints = false
137
- if backgroundView != self {
138
- backgroundView. removeFromSuperview ( )
139
- }
140
- addSubview ( backgroundView)
141
- self . backgroundView = backgroundView
142
- NSLayoutConstraint . activate ( [
143
- backgroundView. centerXAnchor. constraint ( equalTo: centerXAnchor)
105
+ backgroundView. topAnchor. constraint ( equalTo: topAnchor)
106
+ . with ( priority: . belowMessageSizeable) ,
107
+ backgroundView. bottomAnchor. constraint ( equalTo: bottomAnchor)
144
108
. with ( priority: . belowMessageSizeable) ,
145
- backgroundView. topAnchor. constraint ( equalTo: topAnchor, constant: insets. top)
146
- . with ( priority: . required) ,
147
- backgroundView. bottomAnchor. constraint ( equalTo: bottomAnchor, constant: - insets. bottom)
148
- . with ( priority: . required) ,
149
109
backgroundView. heightAnchor. constraint ( equalToConstant: 350 )
150
110
. with ( priority: UILayoutPriority ( rawValue: 200 ) ) ,
151
- backgroundView. leftAnchor. constraint (
152
- equalTo: layoutMarginsGuide. leftAnchor, constant: insets. left
153
- ) . with ( priority: . belowMessageSizeable) ,
154
- backgroundView. rightAnchor. constraint (
155
- equalTo: layoutMarginsGuide. rightAnchor,
156
- constant: - insets. right
157
- ) . with ( priority: . belowMessageSizeable) ,
111
+ backgroundView. leadingAnchor. constraint ( equalTo: leadingAnchor)
112
+ . with ( priority: . belowMessageSizeable) ,
113
+ backgroundView. trailingAnchor. constraint ( equalTo: trailingAnchor)
114
+ . with ( priority: . belowMessageSizeable) ,
158
115
] )
159
116
installTapRecognizer ( )
160
117
}
161
118
119
+ // /**
120
+ // A convenience function for installing a background view and pinning to the horizontal
121
+ // layout margins and to the vertical edges. This is useful for creating programatic layouts where
122
+ // the background view needs to be inset from the message view's horizontal edges (like a tab-style layout).
123
+ //
124
+ // - Parameter backgroundView: The view to be installed as a subview and
125
+ // assigned to the `backgroundView` property.
126
+ // - Parameter insets: The amount to inset the content view from the horizontal margins and vertical edges.
127
+ // Default is zero inset.
128
+ // */
129
+ // open func installBackgroundVerticalView(_ backgroundView: UIView, insets: UIEdgeInsets = UIEdgeInsets.zero) {
130
+ // backgroundView.translatesAutoresizingMaskIntoConstraints = false
131
+ // if backgroundView != self {
132
+ // backgroundView.removeFromSuperview()
133
+ // }
134
+ // addSubview(backgroundView)
135
+ // self.backgroundView = backgroundView
136
+ // NSLayoutConstraint.activate([
137
+ // backgroundView.centerXAnchor.constraint(equalTo: centerXAnchor)
138
+ // .with(priority: .belowMessageSizeable),
139
+ // backgroundView.topAnchor.constraint(equalTo: topAnchor, constant: insets.top)
140
+ // .with(priority: .required),
141
+ // backgroundView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -insets.bottom)
142
+ // .with(priority: .required),
143
+ // backgroundView.heightAnchor.constraint(equalToConstant: 350)
144
+ // .with(priority: UILayoutPriority(rawValue: 200)),
145
+ // backgroundView.leftAnchor.constraint(
146
+ // equalTo: layoutMarginsGuide.leftAnchor, constant: insets.left
147
+ // ).with(priority: .belowMessageSizeable),
148
+ // backgroundView.rightAnchor.constraint(
149
+ // equalTo: layoutMarginsGuide.rightAnchor,
150
+ // constant: -insets.right
151
+ // ).with(priority: .belowMessageSizeable),
152
+ // ])
153
+ // installTapRecognizer()
154
+ // }
155
+
162
156
/*
163
157
MARK: - Tap handler
164
158
*/
@@ -203,11 +197,8 @@ open class BaseView: UIView, BackgroundViewable, MarginAdjustable, MessageSizeab
203
197
204
198
// MARK: - MessageSizeable
205
199
206
- /// Configure the view's size
207
- public var messageSize = MessageSize ( )
208
-
209
- /// Configure the view's insets from the container
210
- public var messageInsets = MessageInsets ( )
200
+ /// Configure the view's layout
201
+ public var layout = Layout ( )
211
202
212
203
/*
213
204
MARK: - MarginAdjustable
0 commit comments