From 322a32be21c6b3bbbd727e0caf920e68fd004c4e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 27 Sep 2021 12:16:18 +0300 Subject: [PATCH] WebRTC Implementing --- lib/pages/webRTC/call_page.dart | 67 +++++++++++ lib/widgets/drawer/app_drawer_widget.dart | 128 ++++++++-------------- 2 files changed, 115 insertions(+), 80 deletions(-) diff --git a/lib/pages/webRTC/call_page.dart b/lib/pages/webRTC/call_page.dart index e69de29b..bf0895c9 100644 --- a/lib/pages/webRTC/call_page.dart +++ b/lib/pages/webRTC/call_page.dart @@ -0,0 +1,67 @@ +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_webrtc/flutter_webrtc.dart'; + +class CallPage extends StatefulWidget { + @override + _CallPageState createState() => _CallPageState(); +} + +class _CallPageState extends State { + final _localRenderer = new RTCVideoRenderer(); + + @override + void initState() { + initializeRenderers(); + _getUserMedia(); + super.initState(); + } + + @override + void dispose() { + _localRenderer.dispose(); + super.dispose(); + } + + void _getUserMedia() async { + final Map constraints = { + 'audio': 'false', + 'video': {'facingMode': 'user'}, + }; + + MediaStream stream = await navigator.mediaDevices.getUserMedia(constraints); + setState(() { + _localRenderer.srcObject = stream; + }); + } + + void initializeRenderers() async { + _localRenderer.initialize(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + isShowDecPage: false, + appBarTitle: "WebRTC Calling", + body: Container( + child: Stack( + children: [ + Positioned( + top: 0.0, + left: 0.0, + right: 0.0, + bottom: 0.0, + child: Container( + child: new RTCVideoView(_localRenderer), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index f5e633ec..6d5c034d 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -16,6 +16,7 @@ import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStat import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notifications_page.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; +import 'package:diplomaticquarterapp/pages/webRTC/call_page.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; @@ -173,17 +174,14 @@ class _AppDrawerState extends State { children: [ (user.isFamily == null || user.isFamily == false) ? InkWell( - child: DrawerItem( - TranslationBase.of(context).family, - SvgPicture.asset("assets/images/new/family_files.svg"), - isImageIcon: true, - bottomLine: false, - textColor: Theme.of(context).textTheme.bodyText1.color, - iconColor: Theme.of(context).textTheme.bodyText1.color, - sideArrow: true, - letterSpacing: -0.84, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).family, SvgPicture.asset("assets/images/new/family_files.svg"), + isImageIcon: true, + bottomLine: false, + textColor: Theme.of(context).textTheme.bodyText1.color, + iconColor: Theme.of(context).textTheme.bodyText1.color, + sideArrow: true, + letterSpacing: -0.84, + projectProvider: projectProvider), onTap: () { Navigator.of(context).pop(); Navigator.of(context).pushNamed( @@ -306,16 +304,9 @@ class _AppDrawerState extends State { ), mHeight(20), InkWell( - child: DrawerItem( - TranslationBase.of(context).arabicChange, - Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider.isArabic ? 3 : 0)), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - fontHeight: projectProvider.isArabic ? 1 : 0.8, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).arabicChange, + Padding(child: Image.asset('assets/images/lang.png'), padding: EdgeInsets.only(left: 3, right: 3, top: 3, bottom: projectProvider.isArabic ? 3 : 0)), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, fontHeight: projectProvider.isArabic ? 1 : 0.8, projectProvider: projectProvider), onTap: () { sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); sharedPref.setBool(IS_ROBOT_INIT, null); @@ -371,15 +362,8 @@ class _AppDrawerState extends State { ), if (projectProvider.havePrivilege(3)) InkWell( - child: DrawerItem( - TranslationBase.of(context).appsetting, - SvgPicture.asset("assets/images/new/app_setting.svg"), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).appsetting, SvgPicture.asset("assets/images/new/app_setting.svg"), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { Navigator.of(context).pushNamed( SETTINGS, @@ -387,14 +371,7 @@ class _AppDrawerState extends State { }, ), InkWell( - child: DrawerItem( - TranslationBase.of(context).rateApp, - Icons.star, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).rateApp, Icons.star, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { if (Platform.isIOS) { launch("https://apps.apple.com/sa/app/dr-suliaman-alhabib/id733503978"); @@ -404,15 +381,8 @@ class _AppDrawerState extends State { }, ), InkWell( - child: DrawerItem( - TranslationBase.of(context).logout, - SvgPicture.asset("assets/images/new/logout.svg"), - isImageIcon: true, - bottomLine: false, - letterSpacing: -0.84, - fontSize: 14, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).logout, SvgPicture.asset("assets/images/new/logout.svg"), + isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { logout(); }, @@ -420,15 +390,8 @@ class _AppDrawerState extends State { ], ) : InkWell( - child: DrawerItem( - TranslationBase.of(context).loginregister, - SvgPicture.asset("assets/images/new/logout.svg"), - isImageIcon: true, - letterSpacing: -0.84, - fontSize: 14, - bottomLine: false, - projectProvider: projectProvider - ), + child: DrawerItem(TranslationBase.of(context).loginregister, SvgPicture.asset("assets/images/new/logout.svg"), + isImageIcon: true, letterSpacing: -0.84, fontSize: 14, bottomLine: false, projectProvider: projectProvider), onTap: () { login(); }, @@ -449,32 +412,37 @@ class _AppDrawerState extends State { ), ), mHeight(12), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - TranslationBase.of(context).poweredBy, - style: TextStyle( - color: Color(0xFF989898), - fontSize: 13, - letterSpacing: -0.54, - fontWeight: FontWeight.w600, + InkWell( + onTap: () { + Navigator.push(context, FadePage(page: CallPage())); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + TranslationBase.of(context).poweredBy, + style: TextStyle( + color: Color(0xFF989898), + fontSize: 13, + letterSpacing: -0.54, + fontWeight: FontWeight.w600, + ), ), - ), - mWidth(2), - Text( - "Cloud Solutions", - style: TextStyle( - color: Color(0xff2E303A), - fontSize: 13, - letterSpacing: -0.54, - fontWeight: FontWeight.w600, + mWidth(2), + Text( + "Cloud Solutions", + style: TextStyle( + color: Color(0xff2E303A), + fontSize: 13, + letterSpacing: -0.54, + fontWeight: FontWeight.w600, + ), ), - ), - mWidth(16), - SvgPicture.asset("assets/images/new/cloud_logo.svg"), - ], + mWidth(16), + SvgPicture.asset("assets/images/new/cloud_logo.svg"), + ], + ), ), mHeight(12), ],