capacitor-plugin-vonage 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
37
37
  var publisherLabel = UILabel()
38
38
  var subscriberLabel = UILabel()
39
39
  var timerLabel = UILabel()
40
+ var subscriberImg = UIImageView()
40
41
  var counter = 0
41
42
  var timer = Timer()
42
43
  override func viewDidLoad() {
@@ -123,7 +124,7 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
123
124
  remoteView = UIView(frame: CGRect(x: 0, y: 0, width: screenWidth, height:screenHeight))
124
125
  remoteView.backgroundColor = UIColor(red: 83/255, green: 83/255, blue: 83/255, alpha: 1.0)
125
126
 
126
- subscriberLabel = UILabel(frame: CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 140), height: 40))
127
+ subscriberLabel = UILabel(frame: CGRect(x: 20, y: Int(screenHeight) - 180, width: Int(remoteView.frame.size.width - 180), height: 40))
127
128
  subscriberLabel.text = subscriberName
128
129
  //subscriberLabel.backgroundColor = UIColor(red: 31/255, green: 33/255, blue: 36/255, alpha: 1.0)
129
130
  subscriberLabel.textColor = .white
@@ -138,11 +139,29 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
138
139
  timerLabel.textAlignment = .left
139
140
  timerLabel.font = subscriberLabel.font.withSize(dynamicFontSize(15))
140
141
  timerLabel.layer.zPosition = 1;
141
-
142
+ let url = URL(string: "https://www.gravatar.com/avatar/?d=mp")!
143
+
144
+ DispatchQueue.global().async {
145
+ // Fetch Image Data
146
+ if let data = try? Data(contentsOf: url) {
147
+ DispatchQueue.main.async {
148
+ // Create Image and Update Image View
149
+ self.subscriberImg.image = UIImage(data: data)
150
+ }
151
+ }
152
+ }
153
+ subscriberImg.layer.zPosition = 1
154
+ subscriberImg.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
155
+ subscriberImg.layer.cornerRadius = 100
156
+ subscriberImg.clipsToBounds = true
157
+ subscriberImg.center.x = remoteView.center.x
158
+ subscriberImg.center.y = remoteView.center.y - 100
159
+ // subscriberImg = UIImageView(image: <#T##UIImage?#>)
160
+ remoteView.addSubview(subscriberImg)
142
161
  remoteView.addSubview(timerLabel)
143
162
  remoteView.addSubview(subscriberLabel)
144
163
  self.view.addSubview(remoteView)
145
-
164
+ // someImageViewConstraints()
146
165
  let bottomView = UIView(frame: CGRect(x: 0, y: screenHeight - 90, width: 320, height: 90))
147
166
  bottomView.backgroundColor = UIColor.clear
148
167
  bottomView.center = CGPoint(x: self.view.frame.size.width / 2, y: self.view.frame.size.height - 50)
@@ -325,6 +344,9 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
325
344
  self.session?.disconnect(nil)
326
345
  self.dismiss(animated: true, completion: nil)
327
346
  }
347
+ subscriberImg.isHidden = false
348
+ showToast(message: "\(subscriberName) is left the call")
349
+ cleanupSubscriber()
328
350
 
329
351
  }
330
352
 
@@ -341,20 +363,30 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
341
363
  }
342
364
  }
343
365
 
366
+
344
367
  //Subscriber methods
345
368
  public func subscriberDidConnect(toStream subscriber: OTSubscriberKit) {
346
369
  print("The subscriber did connect to the stream.")
370
+ subscriberImg.isHidden = true
371
+ showToast(message: "\(subscriberName) is joined the call")
347
372
  }
348
373
 
349
374
  public func subscriber(_ subscriber: OTSubscriberKit, didFailWithError error: OTError) {
350
375
  print("The subscriber failed to connect to the stream.")
376
+ showToast(message: "\(subscriberName) failed to connect to the call")
351
377
  }
352
378
 
353
379
  func subscriberVideoDisabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
354
380
  // Display the video disabled indicator
381
+ showToast(message: "\(subscriberName) video disabled")
382
+ subscriberImg.isHidden = false
355
383
  }
356
384
 
357
385
  func subscriberVideoEnabled(_ subscriber: OTSubscriberKit, reason: OTSubscriberVideoEventReason) {
386
+ showToast(message: "\(subscriberName) video enabled")
387
+ subscriberImg.isHidden = true
388
+ // showToast(message: "is provider \(isProvider) video enabled")
389
+
358
390
  // Remove the video disabled indicator
359
391
  }
360
392
 
@@ -377,6 +409,12 @@ class VideoChatViewController: UIViewController,OTSessionDelegate,OTPublisherDel
377
409
  publisher?.view?.removeFromSuperview()
378
410
  publisher = nil
379
411
  }
412
+ func someImageViewConstraints() {
413
+ subscriberImg.widthAnchor.constraint(equalToConstant: 180).isActive = true
414
+ subscriberImg.heightAnchor.constraint(equalToConstant: 180).isActive = true
415
+ subscriberImg.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
416
+ subscriberImg.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 28).isActive = true
417
+ }
380
418
  }
381
419
 
382
420
  extension String {
@@ -385,3 +423,27 @@ extension String {
385
423
  return try? JSONSerialization.jsonObject(with: data, options: .mutableContainers)
386
424
  }
387
425
  }
426
+ extension UIViewController {
427
+
428
+ func showToast(message : String) {
429
+ DispatchQueue.main.async {
430
+ let toastLabel = UILabel(frame: CGRect(x: 0, y: self.view.frame.size.height-300, width: self.view.frame.size.width - 100, height: 50))
431
+ toastLabel.center.x = self.view.center.x
432
+ toastLabel.backgroundColor = UIColor.white.withAlphaComponent(0.6)
433
+ toastLabel.textColor = UIColor.black
434
+ toastLabel.font = .systemFont(ofSize: 12.0)
435
+ toastLabel.textAlignment = .center;
436
+ toastLabel.text = message
437
+ toastLabel.alpha = 1.0
438
+ toastLabel.layer.cornerRadius = 10;
439
+ toastLabel.clipsToBounds = true
440
+ self.view.addSubview(toastLabel)
441
+ UIView.animate(withDuration: 5.0, delay: 0.2, options: .curveEaseOut, animations: {
442
+ toastLabel.alpha = 0.0
443
+ }, completion: {(isCompleted) in
444
+ toastLabel.removeFromSuperview()
445
+ })
446
+ }
447
+ }
448
+
449
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-plugin-vonage",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "opentok sdk capacitor plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",