Browse Source

Implement Exit PiP mode in PiPWindow

master
Daniel Ornelas 7 years ago
parent
commit
8428dd95c2

BIN
ios/sdk/image-resize@2x.png View File


BIN
ios/sdk/image-resize@3x.png View File


+ 10
- 2
ios/sdk/sdk.xcodeproj/project.pbxproj View File

@@ -27,6 +27,8 @@
27 27
 		0BCA496C1EC4BBF900B793EE /* jitsi.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0BCA496B1EC4BBF900B793EE /* jitsi.ttf */; };
28 28
 		0BD906EA1EC0C00300C8C18E /* JitsiMeet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BD906E81EC0C00300C8C18E /* JitsiMeet.h */; settings = {ATTRIBUTES = (Public, ); }; };
29 29
 		0F65EECE1D95DA94561BB47E /* libPods-JitsiMeet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 03F2ADC957FF109849B7FCA1 /* libPods-JitsiMeet.a */; };
30
+		C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5B2053091D0040BE68 /* image-resize@2x.png */; };
31
+		C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5C2053091D0040BE68 /* image-resize@3x.png */; };
30 32
 		C6A3425F204EF76800E062DD /* PiPWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425C204EF76800E062DD /* PiPWindow.swift */; };
31 33
 		C6A34260204EF76800E062DD /* JitsiMeetManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425D204EF76800E062DD /* JitsiMeetManager.swift */; };
32 34
 		C6A34261204EF76800E062DD /* DragGestureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425E204EF76800E062DD /* DragGestureController.swift */; };
@@ -60,6 +62,8 @@
60 62
 		0BD906E91EC0C00300C8C18E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
61 63
 		98E09B5C73D9036B4ED252FC /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = "<group>"; };
62 64
 		9C77CA3CC919B081F1A52982 /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = "<group>"; };
65
+		C6245F5B2053091D0040BE68 /* image-resize@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "image-resize@2x.png"; sourceTree = "<group>"; };
66
+		C6245F5C2053091D0040BE68 /* image-resize@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "image-resize@3x.png"; sourceTree = "<group>"; };
63 67
 		C6A3425C204EF76800E062DD /* PiPWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PiPWindow.swift; sourceTree = "<group>"; };
64 68
 		C6A3425D204EF76800E062DD /* JitsiMeetManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JitsiMeetManager.swift; sourceTree = "<group>"; };
65 69
 		C6A3425E204EF76800E062DD /* DragGestureController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragGestureController.swift; sourceTree = "<group>"; };
@@ -86,6 +90,8 @@
86 90
 			isa = PBXGroup;
87 91
 			children = (
88 92
 				0BC4B8681F8C01E100CE8B21 /* CallKitIcon.png */,
93
+				C6245F5B2053091D0040BE68 /* image-resize@2x.png */,
94
+				C6245F5C2053091D0040BE68 /* image-resize@3x.png */,
89 95
 				0BCA496B1EC4BBF900B793EE /* jitsi.ttf */,
90 96
 			);
91 97
 			name = Resources;
@@ -252,7 +258,9 @@
252 258
 			buildActionMask = 2147483647;
253 259
 			files = (
254 260
 				0BCA496C1EC4BBF900B793EE /* jitsi.ttf in Resources */,
261
+				C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */,
255 262
 				0BC4B8691F8C03A700CE8B21 /* CallKitIcon.png in Resources */,
263
+				C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */,
256 264
 			);
257 265
 			runOnlyForDeploymentPostprocessing = 0;
258 266
 		};
@@ -472,7 +480,7 @@
472 480
 			isa = XCBuildConfiguration;
473 481
 			baseConfigurationReference = 98E09B5C73D9036B4ED252FC /* Pods-JitsiMeet.debug.xcconfig */;
474 482
 			buildSettings = {
475
-				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
483
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
476 484
 				CLANG_ENABLE_MODULES = YES;
477 485
 				CODE_SIGN_IDENTITY = "";
478 486
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
@@ -499,7 +507,7 @@
499 507
 			isa = XCBuildConfiguration;
500 508
 			baseConfigurationReference = 9C77CA3CC919B081F1A52982 /* Pods-JitsiMeet.release.xcconfig */;
501 509
 			buildSettings = {
502
-				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
510
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
503 511
 				CLANG_ENABLE_MODULES = YES;
504 512
 				CODE_SIGN_IDENTITY = "";
505 513
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";

+ 56
- 0
ios/sdk/src/JitsiMeetManager/PiPWindow/PiPWindow.swift View File

@@ -19,6 +19,10 @@ open class PiPWindow: UIWindow {
19 19
     
20 20
     private let dragController: DragGestureController = DragGestureController()
21 21
     
22
+    /// Used when in PiP mode to enable/disable exit PiP UI
23
+    private var tapGestureRecognizer: UITapGestureRecognizer?
24
+    private var exitPiPButton: UIButton?
25
+    
22 26
     /// Help out to bubble up the gesture detection outside of the rootVC frame
23 27
     open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
24 28
         guard let vc = rootViewController else {
@@ -66,6 +70,11 @@ open class PiPWindow: UIWindow {
66 70
         animateRootViewChange()
67 71
         dragController.startDragListener(inView: view)
68 72
         dragController.insets = dragBoundInsets
73
+        
74
+        // add single tap gesture recognition for displaying exit PiP UI
75
+        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(toggleExitPiP))
76
+        self.tapGestureRecognizer = tapGestureRecognizer
77
+        view.addGestureRecognizer(tapGestureRecognizer)
69 78
     }
70 79
     
71 80
     /// Resize the root view to full screen
@@ -73,6 +82,14 @@ open class PiPWindow: UIWindow {
73 82
         isInPiP = false
74 83
         animateRootViewChange()
75 84
         dragController.stopDragListener()
85
+        
86
+        // hide PiP UI
87
+        exitPiPButton?.removeFromSuperview()
88
+        exitPiPButton = nil
89
+        
90
+        // remove gesture
91
+        tapGestureRecognizer?.removeTarget(self, action: #selector(toggleExitPiP))
92
+        tapGestureRecognizer = nil
76 93
     }
77 94
     
78 95
     /// Stop the dragging gesture of the root view
@@ -80,6 +97,22 @@ open class PiPWindow: UIWindow {
80 97
         dragController.stopDragListener()
81 98
     }
82 99
     
100
+    /// Customize the presentation of exit pip button
101
+    open func configureExitPiPButton(target: Any, action: Selector) -> UIButton {
102
+        let buttonImage = UIImage.init(named: "image-resize", in: Bundle(for: type(of: self)), compatibleWith: nil)
103
+        let button = UIButton(type: .custom)
104
+        let size: CGSize = CGSize(width: 44, height: 44)
105
+        button.setImage(buttonImage, for: .normal)
106
+        button.backgroundColor = .gray
107
+        button.layer.cornerRadius = size.width / 2
108
+        button.frame = CGRect(origin: CGPoint.zero, size: size)
109
+        if let view = rootViewController?.view {
110
+            button.center = view.convert(view.center, from:view.superview)
111
+        }
112
+        button.addTarget(target, action: action, for: .touchUpInside)
113
+        return button
114
+    }
115
+    
83 116
     // MARK: - Manage presentation switching
84 117
     
85 118
     private func animateRootViewChange() {
@@ -102,4 +135,27 @@ open class PiPWindow: UIWindow {
102 135
         let y: CGFloat = adjustedBounds.maxY - size.height
103 136
         return CGRect(x: x, y: y, width: size.width, height: size.height)
104 137
     }
138
+    
139
+    // MARK: - Exit PiP
140
+    
141
+    @objc private func toggleExitPiP() {
142
+        guard let view = rootViewController?.view else { return }
143
+        
144
+        if exitPiPButton == nil {
145
+            // show button
146
+            let button = configureExitPiPButton(target: self, action: #selector(exitPiP))
147
+            view.addSubview(button)
148
+            exitPiPButton = button
149
+            
150
+        } else {
151
+            // hide button
152
+            exitPiPButton?.removeFromSuperview()
153
+            exitPiPButton = nil
154
+        }
155
+        
156
+    }
157
+    
158
+    @objc private func exitPiP() {
159
+        goToFullScreen()
160
+    }
105 161
 }

Loading…
Cancel
Save