@@ -149,14 +149,6 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
149
149
private let showMuteButton : Bool
150
150
private let showCrossIcon : Bool
151
151
private let postButton = UIButton ( )
152
- private lazy var publishButton : UIButton = {
153
- let button = UIButton ( type: . custom)
154
- button. accessibilityIdentifier = " Media Clips Next Button "
155
- button. accessibilityLabel = " Next Button "
156
- button. setImage ( KanvasImages . nextImage, for: . normal)
157
- button. translatesAutoresizingMaskIntoConstraints = false
158
- return button
159
- } ( )
160
152
private let postLabel = UILabel ( )
161
153
private let tagButton = UIButton ( )
162
154
private let fakeOptionCell = UIImageView ( )
@@ -166,6 +158,7 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
166
158
private let showTagCollection : Bool
167
159
private let showQuickPostButton : Bool
168
160
private let showBlogSwitcher : Bool
161
+ private let confirmAtTop : Bool
169
162
private let metalContext : MetalContext ?
170
163
private let filterSelectionCircle = UIImageView ( )
171
164
private let navigationContainer = IgnoreTouchesView ( )
@@ -245,6 +238,7 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
245
238
showTagCollection: Bool ,
246
239
showQuickPostButton: Bool ,
247
240
showBlogSwitcher: Bool ,
241
+ confirmAtTop: Bool ,
248
242
quickBlogSelectorCoordinator: KanvasQuickBlogSelectorCoordinating ? ,
249
243
tagCollection: UIView ? ,
250
244
metalContext: MetalContext ? ,
@@ -260,6 +254,7 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
260
254
self . showCrossIcon = showCrossIcon
261
255
self . showQuickPostButton = showQuickPostButton
262
256
self . showBlogSwitcher = showBlogSwitcher
257
+ self . confirmAtTop = confirmAtTop
263
258
self . quickBlogSelectorCoordinator = quickBlogSelectorCoordinator
264
259
self . tagCollection = tagCollection
265
260
self . metalContext = metalContext
@@ -425,16 +420,27 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
425
420
private func setupConfirmButton( ) {
426
421
confirmButton. accessibilityLabel = " Confirm Button "
427
422
navigationContainer. addSubview ( confirmButton)
428
- confirmButton. setImage ( KanvasImages . nextImage, for: . normal)
423
+ confirmButton. setImage ( KanvasImages . shared . nextImage, for: . normal)
429
424
confirmButton. addTarget ( self , action: #selector( confirmButtonPressed) , for: . touchUpInside)
430
425
confirmButton. translatesAutoresizingMaskIntoConstraints = false
431
-
426
+
427
+ let positioningConstraints : [ NSLayoutConstraint ]
428
+ if confirmAtTop {
429
+ positioningConstraints = [
430
+ confirmButton. trailingAnchor. constraint ( equalTo: safeLayoutGuide. trailingAnchor, constant: - EditorViewConstants. confirmButtonHorizontalMargin) ,
431
+ confirmButton. centerYAnchor. constraint ( equalTo: closeButton. centerYAnchor)
432
+ ]
433
+ } else {
434
+ positioningConstraints = [
435
+ confirmButton. trailingAnchor. constraint ( equalTo: safeLayoutGuide. trailingAnchor, constant: - EditorViewConstants. confirmButtonHorizontalMargin) ,
436
+ confirmButton. bottomAnchor. constraint ( equalTo: safeLayoutGuide. bottomAnchor, constant: - EditorViewConstants. buttonBottomMargin)
437
+ ]
438
+ }
439
+
432
440
NSLayoutConstraint . activate ( [
433
- confirmButton. trailingAnchor. constraint ( equalTo: safeLayoutGuide. trailingAnchor, constant: - EditorViewConstants. confirmButtonHorizontalMargin) ,
434
441
confirmButton. heightAnchor. constraint ( equalToConstant: EditorViewConstants . confirmButtonSize) ,
435
442
confirmButton. widthAnchor. constraint ( equalToConstant: EditorViewConstants . confirmButtonSize) ,
436
- confirmButton. bottomAnchor. constraint ( equalTo: safeLayoutGuide. bottomAnchor, constant: - EditorViewConstants. buttonBottomMargin)
437
- ] )
443
+ ] + positioningConstraints)
438
444
}
439
445
440
446
private func setupPostOptionsButton( ) {
@@ -457,7 +463,7 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
457
463
] )
458
464
}
459
465
else {
460
- confirmButton. setImage ( KanvasImages . nextImage, for: . normal)
466
+ confirmButton. setImage ( KanvasImages . shared . nextImage, for: . normal)
461
467
462
468
NSLayoutConstraint . activate ( [
463
469
confirmButton. trailingAnchor. constraint ( equalTo: safeLayoutGuide. trailingAnchor, constant: - EditorViewConstants. confirmButtonHorizontalMargin) ,
@@ -474,28 +480,6 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
474
480
collectionContainer. accessibilityIdentifier = " Edition Menu Collection Container "
475
481
collectionContainer. clipsToBounds = false
476
482
collectionContainer. translatesAutoresizingMaskIntoConstraints = false
477
- let leftButton : UIView ?
478
- let rightButton : UIView ?
479
- let trailingMargin : CGFloat
480
- let leadingMargin : CGFloat
481
-
482
- if showMuteButton {
483
- leftButton = muteButton
484
- leadingMargin = EditorViewConstants . saveButtonHorizontalMargin
485
- } else {
486
- leftButton = nil
487
- leadingMargin = 0
488
- }
489
-
490
- if showSaveButton {
491
- rightButton = saveButton
492
- trailingMargin = EditorViewConstants . saveButtonHorizontalMargin
493
- }
494
- else {
495
- rightButton = confirmOrPostButton ( )
496
- trailingMargin = confirmOrPostButtonHorizontalMargin ( )
497
- }
498
-
499
483
if KanvasEditorDesign . shared. isVerticalMenu {
500
484
501
485
NSLayoutConstraint . activate ( [
@@ -507,21 +491,49 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
507
491
}
508
492
else {
509
493
510
- let verticalConstraint : NSLayoutConstraint
494
+ let leftButton : UIView ?
495
+ let leadingMargin : CGFloat
496
+ let xAnchor : NSLayoutXAxisAnchor
497
+ let trailingMargin : CGFloat
511
498
512
- if let button = rightButton {
513
- verticalConstraint = collectionContainer. centerYAnchor. constraint ( equalTo: button. centerYAnchor)
499
+ if showMuteButton {
500
+ leftButton = muteButton
501
+ leadingMargin = EditorViewConstants . saveButtonHorizontalMargin
514
502
} else {
515
- verticalConstraint = collectionContainer. bottomAnchor. constraint ( equalTo: safeAreaLayoutGuide. bottomAnchor)
503
+ leftButton = nil
504
+ leadingMargin = 0
516
505
}
517
506
507
+ if confirmAtTop {
508
+ xAnchor = safeAreaLayoutGuide. trailingAnchor
509
+ trailingMargin = 0
510
+ } else {
511
+ if showSaveButton {
512
+ xAnchor = saveButton. leadingAnchor
513
+ trailingMargin = EditorViewConstants . saveButtonHorizontalMargin
514
+ }
515
+ else {
516
+ xAnchor = confirmOrPostButton ( ) . leadingAnchor
517
+ trailingMargin = confirmOrPostButtonHorizontalMargin ( )
518
+ }
519
+ }
520
+
521
+ let verticalPositioning : [ NSLayoutConstraint ]
522
+ if confirmAtTop {
523
+ verticalPositioning = [ collectionContainer. bottomAnchor. constraint ( equalTo: safeAreaLayoutGuide. bottomAnchor) ]
524
+ } else {
525
+ verticalPositioning = [ collectionContainer. centerYAnchor. constraint ( equalTo: confirmOrPostButton ( ) . centerYAnchor) ]
526
+ }
527
+
528
+ let leftButtonConstraints = [
529
+ leftButton? . centerYAnchor. constraint ( equalTo: collectionContainer. centerYAnchor)
530
+ ] . compactMap { $0 }
531
+
518
532
NSLayoutConstraint . activate ( [
519
533
collectionContainer. leadingAnchor. constraint ( equalTo: leftButton? . trailingAnchor ?? safeAreaLayoutGuide. leadingAnchor, constant: leadingMargin) ,
520
- collectionContainer. trailingAnchor. constraint ( equalTo: rightButton? . leadingAnchor ?? trailingAnchor, constant: - trailingMargin / 2 ) ,
521
- verticalConstraint,
534
+ collectionContainer. trailingAnchor. constraint ( equalTo: xAnchor, constant: - trailingMargin / 2 ) ,
522
535
collectionContainer. heightAnchor. constraint ( equalToConstant: EditionMenuCollectionView . height) ,
523
- leftButton? . centerYAnchor. constraint ( equalTo: collectionContainer. centerYAnchor)
524
- ] . compactMap { $0 } )
536
+ ] + verticalPositioning + leftButtonConstraints)
525
537
}
526
538
}
527
539
@@ -632,7 +644,7 @@ final class EditorView: UIView, MovableViewCanvasDelegate, MediaPlayerViewDelega
632
644
updatePostButton ( avatarView: avatarView)
633
645
}
634
646
else {
635
- postButton. setImage ( KanvasImages . nextImage, for: . normal)
647
+ postButton. setImage ( KanvasImages . shared . nextImage, for: . normal)
636
648
}
637
649
postButton. contentHorizontalAlignment = . fill
638
650
postButton. contentVerticalAlignment = . fill
0 commit comments