@@ -110,29 +110,65 @@ extension ImagePickerController {
110110 relatedBy: . equal, toItem: view, attribute: attribute,
111111 multiplier: 1 , constant: 0 ) )
112112 }
113-
114- for attribute : NSLayoutConstraint . Attribute in [ . left, . top, . width] {
115- view. addConstraint ( NSLayoutConstraint ( item: cameraController. view!, attribute: attribute,
116- relatedBy: . equal, toItem: view, attribute: attribute,
117- multiplier: 1 , constant: 0 ) )
118- }
119-
120- for attribute in topViewAttributes {
121- view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: attribute,
122- relatedBy: . equal, toItem: self . view, attribute: attribute,
123- multiplier: 1 , constant: 0 ) )
124- }
125-
126- if #available( iOS 11 . 0 , * ) {
127- view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . top,
128- relatedBy: . equal, toItem: view. safeAreaLayoutGuide,
129- attribute: . top,
130- multiplier: 1 , constant: 0 ) )
113+
114+ if configuration. galleryOnly {
115+
116+ for attribute : NSLayoutConstraint . Attribute in [ . left, . right] {
117+ view. addConstraint ( NSLayoutConstraint ( item: galleryView, attribute: attribute,
118+ relatedBy: . equal, toItem: view, attribute: attribute,
119+ multiplier: 1 , constant: 0 ) )
120+ }
121+ let bottomHeightPadding : CGFloat
122+ if #available( iOS 11 . 0 , * ) {
123+ view. addConstraint ( NSLayoutConstraint ( item: galleryView, attribute: . top,
124+ relatedBy: . equal, toItem: view. safeAreaLayoutGuide,
125+ attribute: . top,
126+ multiplier: 1 , constant: 0 ) )
127+ bottomHeightPadding = UIApplication . shared. keyWindow!. safeAreaInsets. bottom
128+ } else {
129+ view. addConstraint ( NSLayoutConstraint ( item: galleryView, attribute: . top,
130+ relatedBy: . equal, toItem: view,
131+ attribute: . top,
132+ multiplier: 1 , constant: 0 ) )
133+ bottomHeightPadding = 0
134+ }
135+ view. addConstraint ( NSLayoutConstraint ( item: galleryView, attribute: . height,
136+ relatedBy: . equal, toItem: view, attribute: . height,
137+ multiplier: 1 , constant: - ( BottomContainerView . Dimensions. height + bottomHeightPadding) ) )
138+
131139 } else {
132- view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . top,
133- relatedBy: . equal, toItem: view,
134- attribute: . top,
135- multiplier: 1 , constant: 0 ) )
140+
141+ for attribute : NSLayoutConstraint . Attribute in [ . left, . top, . width] {
142+ view. addConstraint ( NSLayoutConstraint ( item: cameraController. view!, attribute: attribute,
143+ relatedBy: . equal, toItem: view, attribute: attribute,
144+ multiplier: 1 , constant: 0 ) )
145+ }
146+
147+ for attribute in topViewAttributes {
148+ view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: attribute,
149+ relatedBy: . equal, toItem: self . view, attribute: attribute,
150+ multiplier: 1 , constant: 0 ) )
151+ }
152+
153+ if #available( iOS 11 . 0 , * ) {
154+ view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . top,
155+ relatedBy: . equal, toItem: view. safeAreaLayoutGuide,
156+ attribute: . top,
157+ multiplier: 1 , constant: 0 ) )
158+ } else {
159+ view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . top,
160+ relatedBy: . equal, toItem: view,
161+ attribute: . top,
162+ multiplier: 1 , constant: 0 ) )
163+ }
164+
165+ view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . height,
166+ relatedBy: . equal, toItem: nil , attribute: . notAnAttribute,
167+ multiplier: 1 , constant: TopView . Dimensions. height) )
168+
169+ view. addConstraint ( NSLayoutConstraint ( item: cameraController. view!, attribute: . height,
170+ relatedBy: . equal, toItem: view, attribute: . height,
171+ multiplier: 1 , constant: - BottomContainerView. Dimensions. height) )
136172 }
137173
138174 if #available( iOS 11 . 0 , * ) {
@@ -149,14 +185,6 @@ extension ImagePickerController {
149185 multiplier: 1 ,
150186 constant: BottomContainerView . Dimensions. height) )
151187 }
152-
153- view. addConstraint ( NSLayoutConstraint ( item: topView, attribute: . height,
154- relatedBy: . equal, toItem: nil , attribute: . notAnAttribute,
155- multiplier: 1 , constant: TopView . Dimensions. height) )
156-
157- view. addConstraint ( NSLayoutConstraint ( item: cameraController. view!, attribute: . height,
158- relatedBy: . equal, toItem: view, attribute: . height,
159- multiplier: 1 , constant: - BottomContainerView. Dimensions. height) )
160188 }
161189}
162190
0 commit comments