diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift index fb8ed57d3e..08902fc539 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift @@ -786,7 +786,7 @@ public final class _MediaStreamComponent: CombinedComponent { } let background = background.update( - component: Rectangle(color: .black.withAlphaComponent(0.12)), + component: Rectangle(color: .black.withAlphaComponent(0.0)), availableSize: context.availableSize, transition: context.transition ) @@ -809,7 +809,15 @@ public final class _MediaStreamComponent: CombinedComponent { state.updated(transition: .easeInOut(duration: 3)) deactivatePictureInPicture.invoke(Void()) } - let isFullscreen = state.isFullscreen + var isFullscreen = state.isFullscreen + let isLandscape = context.availableSize.width > context.availableSize.height + if let videoSize = context.state.videoSize { + if videoSize.width > videoSize.height && isLandscape && !isFullscreen { + state.isFullscreen = true + isFullscreen = true + } + } + let video = video.update( component: MediaStreamVideoComponent( call: context.component.call, @@ -1118,7 +1126,6 @@ public final class _MediaStreamComponent: CombinedComponent { // transition: context.transition // ) - let isLandscape = context.availableSize.width > context.availableSize.height if context.state.storedIsLandscape != isLandscape { context.state.storedIsLandscape = isLandscape if isLandscape { @@ -1160,7 +1167,7 @@ public final class _MediaStreamComponent: CombinedComponent { // TODO: disable button instead of hiding rightItem: state.hasVideo ? AnyComponent(Button( content: AnyComponent(BundleIconComponent( - name: isLandscape ? "Media Gallery/Minimize" : "Media Gallery/Fullscreen", + name: isFullscreen ? "Media Gallery/Minimize" : "Media Gallery/Fullscreen", tintColor: .white )), action: { @@ -1220,7 +1227,7 @@ public final class _MediaStreamComponent: CombinedComponent { }) ) let videoHeight: CGFloat = context.availableSize.width / 16 * 9 - let sheetHeight: CGFloat = (50 + 70 + 20 + 80 + videoHeight) + let sheetHeight: CGFloat = isFullscreen ? context.availableSize.height : (50 + 70 + 20 + 80 + videoHeight) let isFullyDragged = context.availableSize.height - sheetHeight + state.dismissOffset < 30 let sheet = sheet.update( diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift index ace32beefd..1707793c82 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift @@ -68,6 +68,10 @@ final class _MediaStreamVideoComponent: Component { return false } + if lhs.isFullscreen != rhs.isFullscreen { + return false + } + return true } diff --git a/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift b/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift index 4e369283c7..1859932ba3 100644 --- a/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/StreamSheetComponent.swift @@ -50,7 +50,9 @@ final class StreamSheetComponent: CombinedComponent { if lhs.sheetHeight != rhs.sheetHeight { return false } - + if !lhs.backgroundColor.isEqual(rhs.backgroundColor) { + return false + } return true } // @@ -251,7 +253,29 @@ final class ViewerCountComponent: Component { final class SheetBackgroundComponent: Component { private let color: UIColor - private let backgroundView = UIView() + + class View: UIView { + private let backgroundView = UIView() + + func update(availableSize: CGSize, color: UIColor) { + if backgroundView.superview == nil { + self.addSubview(backgroundView) + } + // To fix release animation + let extraBottom: CGFloat = 500 + backgroundView.frame = .init(origin: .zero, size: .init(width: availableSize.width, height: availableSize.height + extraBottom)) + backgroundView.backgroundColor = color// .withAlphaComponent(0.4) + backgroundView.isUserInteractionEnabled = false + backgroundView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + backgroundView.layer.cornerRadius = 16 + backgroundView.clipsToBounds = true + backgroundView.layer.masksToBounds = true + } + } + + func makeView() -> View { + View() + } static func ==(lhs: SheetBackgroundComponent, rhs: SheetBackgroundComponent) -> Bool { if !lhs.color.isEqual(rhs.color) { @@ -270,17 +294,8 @@ final class SheetBackgroundComponent: Component { self.color = color } - public func update(view: UIView, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { - if backgroundView.superview == nil { - view.addSubview(backgroundView) - } - backgroundView.frame = .init(origin: .zero, size: availableSize) - backgroundView.backgroundColor = self.color// .withAlphaComponent(0.4) - backgroundView.isUserInteractionEnabled = false - backgroundView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] - backgroundView.layer.cornerRadius = 16 - backgroundView.clipsToBounds = true - backgroundView.layer.masksToBounds = true + public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: Transition) -> CGSize { + view.update(availableSize: availableSize, color: color) return availableSize } }