From 54493e56efc09318cc2c96c738135cdf1a9db4b6 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Wed, 9 Feb 2022 15:42:36 +1100 Subject: [PATCH] minor fix on top & bottom margin --- Session/Calls/Views & Modals/MiniCallView.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Session/Calls/Views & Modals/MiniCallView.swift b/Session/Calls/Views & Modals/MiniCallView.swift index a8a9dda9e..4296c0f81 100644 --- a/Session/Calls/Views & Modals/MiniCallView.swift +++ b/Session/Calls/Views & Modals/MiniCallView.swift @@ -6,6 +6,8 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { // MARK: UI private static let defaultSize: CGFloat = 100 + private let topMargin = UIApplication.shared.keyWindow!.safeAreaInsets.top + Values.veryLargeSpacing + private let bottomMargin = UIApplication.shared.keyWindow!.safeAreaInsets.bottom private var width: NSLayoutConstraint? private var height: NSLayoutConstraint? @@ -105,9 +107,8 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { left = self.autoPinEdge(toSuperviewEdge: .left) left?.isActive = false right = self.autoPinEdge(toSuperviewEdge: .right) - let topMargin = UIApplication.shared.keyWindow!.safeAreaInsets.top + Values.veryLargeSpacing top = self.autoPinEdge(toSuperviewEdge: .top, withInset: topMargin) - bottom = self.autoPinEdge(toSuperviewEdge: .bottom) + bottom = self.autoPinEdge(toSuperviewEdge: .bottom, withInset: bottomMargin) bottom?.isActive = false UIView.animate(withDuration: 0.5, delay: 0, options: [], animations: { self.alpha = 1.0 @@ -144,13 +145,13 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { right?.isActive = true } - let willTouchTop = currentCenter.y < newSize.height / 2 + let willTouchTop = currentCenter.y < newSize.height / 2 + topMargin let willTouchBottom = currentCenter.y + newSize.height / 2 >= self.superview!.height() if willTouchBottom { top?.isActive = false bottom?.isActive = true } else { - let constant = willTouchTop ? 0 : currentCenter.y - newSize.height / 2 + let constant = willTouchTop ? topMargin : currentCenter.y - newSize.height / 2 top?.constant = constant top?.isActive = true bottom?.isActive = false