diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index dc938e36..8ebd4235 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -49,7 +49,6 @@ import OpenTok
navVC.modalPresentationStyle = .fullScreen
window.rootViewController?.present(navVC, animated: true, completion: nil)
-
}
}
diff --git a/ios/Runner/Assets.xcassets/hide_video_icon.imageset/hide_video_icon.png b/ios/Runner/Assets.xcassets/hide_video_icon.imageset/hide_video_icon.png
index 8dea84b1..40889f77 100644
Binary files a/ios/Runner/Assets.xcassets/hide_video_icon.imageset/hide_video_icon.png and b/ios/Runner/Assets.xcassets/hide_video_icon.imageset/hide_video_icon.png differ
diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard
index 6443a057..cecbd930 100755
--- a/ios/Runner/Base.lproj/Main.storyboard
+++ b/ios/Runner/Base.lproj/Main.storyboard
@@ -41,13 +41,6 @@
-
-
-
-
-
-
-
@@ -114,6 +107,13 @@
+
+
+
+
+
+
+
@@ -333,7 +333,7 @@
-
+
diff --git a/ios/Runner/MainAppViewController.swift b/ios/Runner/MainAppViewController.swift
index 3849635e..87610042 100644
--- a/ios/Runner/MainAppViewController.swift
+++ b/ios/Runner/MainAppViewController.swift
@@ -35,8 +35,6 @@ class MainAppViewController: FlutterViewController{
switch call.method {
case "openVideoCall":
self.startVideoCall(result: result, call: call)
- case "showVideo":
- self.showVideo()
default:
result(FlutterMethodNotImplemented)
}
@@ -72,8 +70,10 @@ extension MainAppViewController : ICallProtocol{
}
}
- private func showVideo(){
- videoCallContainer.isHidden = false
+ private func showVideo(show:Bool){
+ UIView.transition(with: view, duration: 0.5, options: .transitionCrossDissolve, animations: {
+ self.videoCallContainer.isHidden = !show
+ })
}
private func startVideoCall(result: @escaping FlutterResult, call:FlutterMethodCall) {
@@ -82,17 +82,16 @@ extension MainAppViewController : ICallProtocol{
if let arguments = call.arguments as? NSDictionary{
showVideoCallView(true)
- videoCallViewController.onMinimize = { min in
- self.minimizeVideoCall(min)
+ videoCallViewController.onFloat = { min in
+ self.floatVideoCallView(min)
}
- videoCallViewController.onHide = {
- self.videoCallContainer.isHidden = true
- self.videoCallChannel?.invokeMethod("onHide", arguments: nil)
+ videoCallViewController.onCallConnect = {
+ self.videoCallChannel?.invokeMethod("onCallConnected",arguments: nil)
}
- videoCallViewController.onVideoDuration = { duration in
- self.videoCallChannel?.invokeMethod("onVideoDuration", arguments: duration)
+ videoCallViewController.onCallDisconnect = {
+ self.showVideoCallView(false)
+ self.videoCallChannel?.invokeMethod("onCallDisconnected",arguments: nil)
}
- videoCallViewController.onClose = videoCallClosed
videoCallViewController.callBack = self
videoCallViewController.start(params: VideoCallRequestParameters(dictionary: arguments))
}
@@ -100,7 +99,7 @@ extension MainAppViewController : ICallProtocol{
}
- private func minimizeVideoCall(_ value:Bool){
+ private func floatVideoCallView(_ value:Bool){
videoCallContainer.enable(value)
UIView.animate(withDuration: 0.5) {
@@ -119,20 +118,11 @@ extension MainAppViewController : ICallProtocol{
}
private func showVideoCallView(_ value:Bool){
- videoCallContainer.alpha = value ? 0.0 : 1
- self.videoCallContainer.isHidden = !value
-
UIView.animate(withDuration: 0.5) {
- self.videoCallContainer.alpha = value ? 1.0 : 0.0
- } completion: { complete in
self.videoCallContainer.isHidden = !value
}
}
- private func videoCallClosed(){
- showVideoCallView(false)
- }
-
func sessionDone(res: Any) {
videoCallFlutterResult?(res)
}
@@ -144,7 +134,6 @@ extension MainAppViewController : ICallProtocol{
func setVideoViewConstrints(){
let screen = UIScreen.main.bounds
-
videoCallContainer.translatesAutoresizingMaskIntoConstraints = false
diff --git a/ios/Runner/VCEmbeder.swift b/ios/Runner/VCEmbeder.swift
index 7e2ea0fd..9617a247 100644
--- a/ios/Runner/VCEmbeder.swift
+++ b/ios/Runner/VCEmbeder.swift
@@ -54,6 +54,7 @@ class ViewEmbedder {
let w = container.frame.size.width;
let h = container.frame.size.height;
child.view.frame = CGRect(x: 0, y: 0, width: w, height: h)
+ child.view.backgroundColor = UIColor.black
child.view.fill(to: container)
}
diff --git a/ios/Runner/VideoCallViewController.swift b/ios/Runner/VideoCallViewController.swift
index fd25541b..27268128 100644
--- a/ios/Runner/VideoCallViewController.swift
+++ b/ios/Runner/VideoCallViewController.swift
@@ -34,11 +34,11 @@ class VideoCallViewController: UIViewController {
var seconds = 30
var isUserConnect : Bool = false
- var onMinimize:((Bool)->Void)? = nil
- var onHide:(()->Void)? = nil
- var onVideoDuration:((String)->Void)? = nil
- var onClose:(()->Void)? = nil
-
+ var onFloat:((Bool)->Void)? = nil
+ var onMinimize:(()->Void)? = nil
+ var onCallConnect:(()->Void)? = nil
+ var onCallDisconnect:(()->Void)? = nil
+
@IBOutlet weak var lblRemoteUsername: UILabel!
@@ -61,6 +61,7 @@ class VideoCallViewController: UIViewController {
@IBOutlet weak var remoteVideo: UIView!
@IBOutlet weak var localVideo: UIView!{
didSet{
+ localVideo.layer.borderColor = UIColor.white.cgColor
localVideoDraggable = localVideo?.superview as? AADraggableView
localVideoDraggable?.reposition = .edgesOnly
}
@@ -74,7 +75,6 @@ class VideoCallViewController: UIViewController {
@IBAction func didClickMuteButton(_ sender: UIButton) {
sender.isSelected = !sender.isSelected
publisher!.publishAudio = !sender.isSelected
-
}
@IBAction func didClickSpeakerButton(_ sender: UIButton) {
@@ -113,24 +113,24 @@ class VideoCallViewController: UIViewController {
}
@IBAction func hideVideoBtnTapped(_ sender: Any) {
- onHide?()
+ onMinimize?()
}
- var minimized = false
+ var floated = false
@IBAction func onMinimize(_ sender: UIButton) {
- minimized = !minimized
- onMinimize?(minimized)
- sender.isSelected = minimized
+ floated = !floated
+ onFloat?(floated)
+ sender.isSelected = floated
- NSLayoutConstraint.activate(minimized ? minimizeConstraint : maximisedConstraint)
- NSLayoutConstraint.deactivate(minimized ? maximisedConstraint : minimizeConstraint)
- localVideoDraggable?.enable(!minimized)
+ NSLayoutConstraint.activate(floated ? minimizeConstraint : maximisedConstraint)
+ NSLayoutConstraint.deactivate(floated ? maximisedConstraint : minimizeConstraint)
+ localVideoDraggable?.enable(!floated)
- lblRemoteUsername.isHidden = minimized
- hideVideoBtn.isHidden = !minimized
+ lblRemoteUsername.isHidden = floated
+ hideVideoBtn.isHidden = !floated
lblCallDuration.superview?.isHidden = !hideVideoBtn.isHidden
- let min_ = minimized
+ let min_ = floated
UIView.animate(withDuration: 0.5) {
self.videoMuteBtn.isHidden = min_
self.micMuteBtn.isHidden = min_
@@ -157,7 +157,6 @@ class VideoCallViewController: UIViewController {
let durationString = "\(mins):\(secs)"
self.lblCallDuration.text = durationString
- self.onVideoDuration?(durationString)
}
}
@@ -277,7 +276,8 @@ class VideoCallViewController: UIViewController {
dismiss(animated: true)
}
dismiss(animated: true)
- onClose?()
+ onCallDisconnect?()
+ durationTimer?.invalidate()
}
func requestCameraPermissionsIfNeeded() {
@@ -435,6 +435,7 @@ extension VideoCallViewController: OTSessionDelegate {
remoteVideo.addSubview(subscriberView)
startUpdateCallDuration()
+ onCallConnect?()
}
func setupSubscribe(_ stream: OTStream?) {
diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart
index f2a52411..5212df0c 100644
--- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart
+++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart
@@ -22,6 +22,7 @@ import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dar
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
+import 'package:quiver/async.dart';
import '../../../../routes.dart';
@@ -95,6 +96,23 @@ class _PatientProfileScreenState extends State
_activeTab = 1;
}
+ StreamSubscription callTimer;
+ callConnected(){
+ callTimer = CountdownTimer(Duration(minutes: 1), Duration(seconds: 1)).listen(null)
+ ..onDone(() {
+ callTimer.cancel();
+ })
+ ..onData((data) {
+ var t = Helpers.timeFrom(duration: data.elapsed);
+ videoCallDurationStreamController.sink.add(t);
+ });
+ }
+
+ callDisconnected(){
+ callTimer.cancel();
+ videoCallDurationStreamController.sink.add(null);
+ }
+
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
@@ -112,9 +130,6 @@ class _PatientProfileScreenState extends State
PatientProfileHeaderNewDesignAppBar(
patient, arrivalType ?? '0', patientType,
videoCallDurationStream: videoCallDurationStream,
- onVideoDurationTap: (){
- VideoChannel.show();
- },
isInpatient: isInpatient,
isFromLiveCare: isFromLiveCare,
height: (patient.patientStatusType != null &&
@@ -322,9 +337,7 @@ class _PatientProfileScreenState extends State
onFailure: (String error) {
DrAppToastMsg.showErrorToast(error);
},
- onVideoDuration: (duration){
- videoCallDurationStreamController.sink.add(duration);
- },
+ onCallConnected: callConnected,
onCallEnd: () {
var asd="";
// WidgetsBinding.instance.addPostFrameCallback((_) {
diff --git a/lib/util/VideoChannel.dart b/lib/util/VideoChannel.dart
index a9c2b5e2..94e79b7e 100644
--- a/lib/util/VideoChannel.dart
+++ b/lib/util/VideoChannel.dart
@@ -12,18 +12,19 @@ class VideoChannel{
static const _channel = const MethodChannel("Dr.cloudSolution/videoCall");
static openVideoCallScreen({kApiKey, kSessionId, kToken, callDuration, warningDuration,int vcId,String tokenID,
String generalId,int doctorId, Function() onCallEnd ,
- Function(SessionStatusModel sessionStatusModel) onCallNotRespond ,Function(String error) onFailure, VoidCallback onHide, Function(String) onVideoDuration}) async {
+ Function(SessionStatusModel sessionStatusModel) onCallNotRespond ,Function(String error) onFailure, VoidCallback onCallConnected, VoidCallback onCallDisconnected}) async {
- onHide = onHide ?? (){};
- onVideoDuration = onVideoDuration ?? (v){};
+ onCallConnected = onCallConnected ?? (){};
+ onCallDisconnected = onCallDisconnected ?? (){};
var result;
try {
_channel.setMethodCallHandler((call) {
- if(call.method == 'onHide'){
- onHide();
- }else if(call.method == 'onVideoDuration'){
- onVideoDuration(call.arguments);
+ if(call.method == 'onCallConnected'){
+ onCallConnected();
+ }
+ if(call.method == 'onCallDisconnected'){
+ onCallDisconnected();
}
return true as dynamic;
});
@@ -44,7 +45,6 @@ class VideoChannel{
);
if(result['callResponse'] == 'CallEnd') {
onCallEnd();
- onVideoDuration(null);
}
else {
SessionStatusModel sessionStatusModel = SessionStatusModel.fromJson(Platform.isIOS ?result['sessionStatus'] :json.decode(result['sessionStatus']));
@@ -56,10 +56,6 @@ class VideoChannel{
}
}
-
- static show(){
- _channel.invokeMethod("showVideo");
- }
}
\ No newline at end of file
diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart
index 634abd02..7232f0c9 100644
--- a/lib/util/helpers.dart
+++ b/lib/util/helpers.dart
@@ -270,4 +270,11 @@ class Helpers {
var htmlRegex = RegExp("<(“[^”]*”|'[^’]*’|[^'”>])*>");
return htmlRegex.hasMatch(text);
}
+
+ static String timeFrom({Duration duration}) {
+ String twoDigits(int n) => n.toString().padLeft(2, "0");
+ String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
+ String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
+ return "$twoDigitMinutes:$twoDigitSeconds";
+ }
}
diff --git a/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart b/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart
index 69bb9758..f2a32e63 100644
--- a/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart
+++ b/lib/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart
@@ -22,10 +22,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget
final bool isFromLiveCare;
final Stream videoCallDurationStream;
- final VoidCallback onVideoDurationTap;
PatientProfileHeaderNewDesignAppBar(
- this.patient, this.patientType, this.arrivalType, {this.height = 0.0, this.isInpatient=false, this.isDischargedPatient=false, this.isFromLiveCare = false, this.videoCallDurationStream, this.onVideoDurationTap});
+ this.patient, this.patientType, this.arrivalType, {this.height = 0.0, this.isInpatient=false, this.isDischargedPatient=false, this.isFromLiveCare = false, this.videoCallDurationStream});
@override
Widget build(BuildContext context) {
@@ -94,11 +93,9 @@ class PatientProfileHeaderNewDesignAppBar extends StatelessWidget
StreamBuilder(
stream: videoCallDurationStream,
builder: (BuildContext context, AsyncSnapshot snapshot) {
- if(snapshot.hasData)
+ if(snapshot.hasData && snapshot.data != null)
return InkWell(
onTap: (){
- if(onVideoDurationTap != null)
- onVideoDurationTap();
},
child: Container(
decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(20)),
diff --git a/pubspec.lock b/pubspec.lock
index 77df9848..cac3f27b 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -813,7 +813,7 @@ packages:
source: hosted
version: "0.1.8"
quiver:
- dependency: transitive
+ dependency: "direct main"
description:
name: quiver
url: "https://pub.dartlang.org"
diff --git a/pubspec.yaml b/pubspec.yaml
index 973e8800..1429bc3e 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -90,7 +90,7 @@ dependencies:
speech_to_text:
path: speech_to_text
-
+ quiver: ^2.1.5
# Html Editor Enhanced
html_editor_enhanced: ^1.3.0