@@ -119,6 +119,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
119119 let cameraState : CameraState
120120 let containerSize : CGSize
121121 let previewFrame : CGRect
122+ let safeInsets : UIEdgeInsets
122123 let isPreviewing : Bool
123124 let isMuted : Bool
124125 let totalDuration : Double
@@ -135,6 +136,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
135136 cameraState: CameraState ,
136137 containerSize: CGSize ,
137138 previewFrame: CGRect ,
139+ safeInsets: UIEdgeInsets ,
138140 isPreviewing: Bool ,
139141 isMuted: Bool ,
140142 totalDuration: Double ,
@@ -150,6 +152,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
150152 self . cameraState = cameraState
151153 self . containerSize = containerSize
152154 self . previewFrame = previewFrame
155+ self . safeInsets = safeInsets
153156 self . isPreviewing = isPreviewing
154157 self . isMuted = isMuted
155158 self . totalDuration = totalDuration
@@ -169,6 +172,9 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
169172 if lhs. previewFrame != rhs. previewFrame {
170173 return false
171174 }
175+ if lhs. safeInsets != rhs. safeInsets {
176+ return false
177+ }
172178 if lhs. cameraState != rhs. cameraState {
173179 return false
174180 }
@@ -529,6 +535,11 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
529535 let state = context. state
530536 let availableSize = context. component. containerSize
531537
538+ var sideInset : CGFloat = 8.0
539+ if component. safeInsets. bottom <= 32.0 {
540+ sideInset += 18.0
541+ }
542+
532543 state. cameraState = component. cameraState
533544
534545 var viewOnceOffset : CGFloat = 102.0
@@ -619,12 +630,12 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
619630 )
620631
621632 context. add ( flipButtonBackground
622- . position ( CGPoint ( x: flipButton. size. width / 2.0 + 8.0 , y: availableSize. height - flipButton. size. height / 2.0 - 8.0 ) )
633+ . position ( CGPoint ( x: flipButton. size. width / 2.0 + sideInset , y: availableSize. height - flipButton. size. height / 2.0 - 8.0 ) )
623634 . appear ( . default( scale: true , alpha: true ) )
624635 . disappear ( . default( scale: true , alpha: true ) )
625636 )
626637 context. add ( flipButton
627- . position ( CGPoint ( x: flipButton. size. width / 2.0 + 8.0 , y: availableSize. height - flipButton. size. height / 2.0 - 8.0 ) )
638+ . position ( CGPoint ( x: flipButton. size. width / 2.0 + sideInset , y: availableSize. height - flipButton. size. height / 2.0 - 8.0 ) )
628639 . appear ( . default( scale: true , alpha: true ) )
629640 . disappear ( . default( scale: true , alpha: true ) )
630641 )
@@ -698,13 +709,13 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
698709 )
699710
700711 context. add ( flashButtonBackground
701- . position ( CGPoint ( x: flipButton. size. width + 8.0 + flashButton. size. width / 2.0 + 11.0 , y: availableSize. height - flashButton. size. height / 2.0 - 8.0 ) )
712+ . position ( CGPoint ( x: flipButton. size. width + sideInset + flashButton. size. width / 2.0 + 11.0 , y: availableSize. height - flashButton. size. height / 2.0 - 8.0 ) )
702713 . appear ( . default( scale: true , alpha: true ) )
703714 . disappear ( . default( scale: true , alpha: true ) )
704715 )
705716
706717 context. add ( flashButton
707- . position ( CGPoint ( x: flipButton. size. width + 8.0 + flashButton. size. width / 2.0 + 11.0 , y: availableSize. height - flashButton. size. height / 2.0 - 8.0 ) )
718+ . position ( CGPoint ( x: flipButton. size. width + sideInset + flashButton. size. width / 2.0 + 11.0 , y: availableSize. height - flashButton. size. height / 2.0 - 8.0 ) )
708719 . appear ( . default( scale: true , alpha: true ) )
709720 . disappear ( . default( scale: true , alpha: true ) )
710721 )
@@ -751,7 +762,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
751762 transition: context. transition
752763 )
753764 context. add ( viewOnceButton
754- . position ( CGPoint ( x: availableSize. width - viewOnceButton. size. width / 2.0 - 8.0 , y: availableSize. height - viewOnceButton. size. height / 2.0 - 8.0 - viewOnceOffset) )
765+ . position ( CGPoint ( x: availableSize. width - viewOnceButton. size. width / 2.0 - sideInset , y: availableSize. height - viewOnceButton. size. height / 2.0 - 8.0 - viewOnceOffset) )
755766 . appear ( . default( scale: true , alpha: true ) )
756767 . disappear ( . default( scale: true , alpha: true ) )
757768 )
@@ -791,7 +802,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
791802 transition: context. transition
792803 )
793804 context. add ( recordMoreButton
794- . position ( CGPoint ( x: availableSize. width - recordMoreButton. size. width / 2.0 - 8.0 , y: availableSize. height - recordMoreButton. size. height / 2.0 - 22.0 ) )
805+ . position ( CGPoint ( x: availableSize. width - recordMoreButton. size. width / 2.0 - sideInset , y: availableSize. height - recordMoreButton. size. height / 2.0 - 22.0 ) )
795806 . appear ( . default( scale: true , alpha: true ) )
796807 . disappear ( . default( scale: true , alpha: true ) )
797808 )
@@ -1546,6 +1557,7 @@ public class VideoMessageCameraScreen: ViewController {
15461557 cameraState: self . cameraState,
15471558 containerSize: backgroundFrame. size,
15481559 previewFrame: previewFrame,
1560+ safeInsets: layout. safeInsets,
15491561 isPreviewing: self . previewState != nil || self . transitioningToPreview,
15501562 isMuted: self . previewState? . isMuted ?? true ,
15511563 totalDuration: self . previewState? . composition. duration. seconds ?? 0.0 ,
0 commit comments