Fix iPad rotation related issue when in PiP

This commit is contained in:
Daniel Ornelas 2018-03-22 11:22:33 -05:00 committed by Lyubo Marinov
parent 15e1633d86
commit 7822155e5e
5 changed files with 45 additions and 16 deletions

View File

@ -32,8 +32,8 @@ class ViewController: UIViewController {
@IBAction func openJitsiMeet(sender: Any?) {
let jitsiMeetCoordinator = JitsiMeetPresentationCoordinator()
self.jitsiMeetCoordinator = jitsiMeetCoordinator
jitsiMeetCoordinator.jitsiMeetView().welcomePageEnabled = true
jitsiMeetCoordinator.jitsiMeetView().load(nil)
jitsiMeetCoordinator.jitsiMeetView.welcomePageEnabled = true
jitsiMeetCoordinator.jitsiMeetView.load(nil)
jitsiMeetCoordinator.show()
}
}

View File

@ -20,8 +20,20 @@ import Foundation
/// an external window that can be resized and dragged with custom PiP mode
open class JitsiMeetPresentationCoordinator: NSObject {
fileprivate let meetViewController: JitsiMeetViewController
fileprivate let meetWindow: PiPWindow
public let meetViewController: JitsiMeetViewController
public let meetWindow: PiPWindow
public var isInPiP: Bool {
get {
return meetWindow.isInPiP
}
}
public var jitsiMeetView: JitsiMeetView {
get {
return meetViewController.jitsiMeetView
}
}
public init(meetViewController: JitsiMeetViewController? = nil,
meetWindow: PiPWindow? = nil) {
@ -34,14 +46,12 @@ open class JitsiMeetPresentationCoordinator: NSObject {
configureMeetViewController()
}
public func jitsiMeetView() -> JitsiMeetView {
return meetViewController.jitsiMeetView
}
/// Show window with jitsi meet and perform a completion closure
open func show(completion: CompletionAction? = nil) {
meetWindow.show(completion: completion)
}
/// Hide window with jitsi meet and perform a completion closure
open func hide(completion: CompletionAction? = nil) {
meetWindow.hide(completion: completion)
}
@ -77,7 +87,7 @@ extension JitsiMeetPresentationCoordinator: JitsiMeetViewControllerDelegate {
switch to {
case .enterPictureInPicture:
meetWindow.enterPictureInPicture()
case .traitChange:
case .sizeChange:
// resize to full screen if rotation happens
if meetWindow.isInPiP {
meetWindow.exitPictureInPicture()

View File

@ -19,8 +19,8 @@ public enum JitsiMeetPresentationUpdate {
/// The conference wants to enter Picture-in-Picture
case enterPictureInPicture
/// A system traitCollectionChange (usually screen rotation)
case traitChange
/// A screen size change (usually screen rotation)
case sizeChange
}
public protocol JitsiMeetViewControllerDelegate: class {
@ -60,8 +60,9 @@ open class JitsiMeetViewController: UIViewController {
jitsiMeetView.delegate = self
}
open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
delegate?.performPresentationUpdate(to: .traitChange)
open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
delegate?.performPresentationUpdate(to: .sizeChange)
}
}

View File

@ -32,7 +32,17 @@ open class PiPWindow: UIWindow {
}
/// The size ratio for root view controller view when in PiP mode
public var pipSizeRatio: CGFloat = 0.333
public var pipSizeRatio: CGFloat = {
let deviceIdiom = UIScreen.main.traitCollection.userInterfaceIdiom
switch (deviceIdiom) {
case .pad:
return 0.25
case .phone:
return 0.33
default:
return 0.25
}
}()
/// The PiP state of this contents of the window
private(set) var isInPiP: Bool = false

View File

@ -7,8 +7,16 @@ import type { Dispatch } from 'redux';
/**
* Size threshold for determining if we are in reduced UI mode or not.
*
* FIXME The logic to base {@code reducedUI} on a hardcoded width or height is
* very brittle because it's completely disconnected from the UI which wants to
* be rendered and, naturally, it broke on iPad where even the secondary Toolbar
* didn't fit in the height. We do need to measure the actual UI at runtime and
* determine whether and how to render it. I'm bumping from 240 to 300 because I
* don't have the time now to refactor {@code ReducedUIDetector} or rip it out
* completely.
*/
const REDUCED_UI_THRESHOLD = 240;
const REDUCED_UI_THRESHOLD = 300;
/**
* Sets the aspect ratio of the app's user interface based on specific width and