瀏覽代碼

Some improvements for handling completion of transitions. Fixed a wrong conferenceEnded value when user left the conversation.

j8
Daniel Ornelas 7 年之前
父節點
當前提交
de0a7bfcd3

+ 11
- 11
ios/sdk/src/picture-in-picture/JitsiMeetPresentationCoordinator.swift 查看文件

@@ -38,27 +38,27 @@ open class JitsiMeetPresentationCoordinator: NSObject {
38 38
         return meetViewController.jitsiMeetView
39 39
     }
40 40
     
41
-    public func show() {
42
-        meetWindow.show()
41
+    open func show(completion: CompletionAction? = nil) {
42
+        meetWindow.show(completion: completion)
43 43
     }
44 44
     
45
-    public func hide() {
46
-        meetWindow.hide()
45
+    open func hide(completion: CompletionAction? = nil) {
46
+        meetWindow.hide(completion: completion)
47 47
     }
48 48
     
49
-    deinit {
50
-        cleanUp()
51
-    }
52
-    
53
-    // MARK: - helpers
54
-    
55
-    fileprivate func cleanUp() {
49
+    open func cleanUp() {
56 50
         // TODO: more clean up work on this
57 51
         
58 52
         meetWindow.isHidden = true
59 53
         meetWindow.stopDragGesture()
60 54
     }
61 55
     
56
+    deinit {
57
+        cleanUp()
58
+    }
59
+    
60
+    // MARK: - helpers
61
+    
62 62
     private func configureMeetViewController() {
63 63
         meetViewController.jitsiMeetView.pictureInPictureEnabled = true
64 64
         meetViewController.delegate = self

+ 4
- 2
ios/sdk/src/picture-in-picture/JitsiMeetViewController.swift 查看文件

@@ -83,7 +83,7 @@ extension JitsiMeetViewController: JitsiMeetViewDelegate {
83 83
     
84 84
     open func conferenceLeft(_ data: [AnyHashable : Any]!) {
85 85
         DispatchQueue.main.async {
86
-            self.delegate?.conferenceEnded(didFail: true)
86
+            self.delegate?.conferenceEnded(didFail: false)
87 87
         }
88 88
     }
89 89
     
@@ -94,7 +94,9 @@ extension JitsiMeetViewController: JitsiMeetViewDelegate {
94 94
     }
95 95
     
96 96
     open func loadConfigError(_ data: [AnyHashable : Any]!) {
97
-        // do something
97
+        DispatchQueue.main.async {
98
+            self.delegate?.conferenceEnded(didFail: true)
99
+        }
98 100
     }
99 101
     
100 102
     open func enterPicture(inPicture data: [AnyHashable : Any]!) {

+ 14
- 10
ios/sdk/src/picture-in-picture/PiPWindow.swift 查看文件

@@ -14,6 +14,9 @@
14 14
  * limitations under the License.
15 15
  */
16 16
 
17
+/// Alias defining a completion closure that returns a Bool
18
+public typealias CompletionAction = (Bool) -> Void
19
+
17 20
 /// A window that allows its root view controller to be presented
18 21
 /// in full screen or in a custom Picture in Picture mode
19 22
 open class PiPWindow: UIWindow {
@@ -50,23 +53,23 @@ open class PiPWindow: UIWindow {
50 53
     }
51 54
     
52 55
     /// animate in the window
53
-    open func show() {
56
+    open func show(completion: CompletionAction? = nil) {
54 57
         if self.isHidden || self.alpha < 1 {
55 58
             self.isHidden = false
56 59
             self.alpha = 0
57
-            animateTransition {
60
+            
61
+            animateTransition(animations: {
58 62
                 self.alpha = 1
59
-            }
63
+            }, completion: completion)
60 64
         }
61 65
     }
62 66
     
63 67
     /// animate out the window
64
-    open func hide() {
68
+    open func hide(completion: CompletionAction? = nil) {
65 69
         if !self.isHidden || self.alpha > 0 {
66
-            animateTransition {
67
-                self.alpha = 0
68
-                self.isHidden = true
69
-            }
70
+            animateTransition(animations: {
71
+                self.alpha = 1
72
+            }, completion: completion)
70 73
         }
71 74
     }
72 75
     
@@ -175,11 +178,12 @@ open class PiPWindow: UIWindow {
175 178
     
176 179
     // MARK: - Animation transition
177 180
     
178
-    private func animateTransition(animations: @escaping () -> Void) {
181
+    private func animateTransition(animations: @escaping () -> Void,
182
+                                   completion: CompletionAction?) {
179 183
         UIView.animate(withDuration: 0.1,
180 184
                        delay: 0,
181 185
                        options: .beginFromCurrentState,
182 186
                        animations: animations,
183
-                       completion: nil)
187
+                       completion: completion)
184 188
     }
185 189
 }

Loading…
取消
儲存