Changes On iOS
parent
02073faf9d
commit
9dcbdee156
@ -1,233 +1,589 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:core';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
import 'package:draggable_widget/draggable_widget.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
||||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
import 'package:mohem_flutter_app/main.dart';
|
import 'package:mohem_flutter_app/main.dart';
|
||||||
import 'package:mohem_flutter_app/models/chat/call.dart';
|
import 'package:mohem_flutter_app/models/chat/call.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart';
|
||||||
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
||||||
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class IncomingCall extends StatefulWidget {
|
class StartCallPage extends StatefulWidget {
|
||||||
CallDataModel outGoingCallData;
|
|
||||||
bool isVideoCall;
|
|
||||||
|
|
||||||
IncomingCall({Key? key, required this.outGoingCallData, required this.isVideoCall}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_IncomingCallState createState() => _IncomingCallState();
|
_StartCallPageState createState() => _StartCallPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IncomingCallState extends State<IncomingCall> with SingleTickerProviderStateMixin {
|
class _StartCallPageState extends State<StartCallPage> {
|
||||||
late ChatCallProvider callProvider;
|
DragController dragController = DragController();
|
||||||
late ChatProviderModel chatProvider;
|
bool isOutGoingCall = false;
|
||||||
|
bool isIncomingCall = false;
|
||||||
|
late ChatCallProvider cProv;
|
||||||
|
late ChatProviderModel provider;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
chatProvider = Provider.of<ChatProviderModel>(context, listen: false);
|
cProv = Provider.of<ChatCallProvider>(context, listen: false);
|
||||||
callProvider = Provider.of<ChatCallProvider>(context, listen: false);
|
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
init();
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
startCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
@override
|
||||||
widget.isVideoCall ? callProvider.isVideoCall = true : callProvider.isVideoCall = false;
|
void dispose() {
|
||||||
callProvider.initLocalCamera(chatProvmodel: chatProvider, callData: widget.outGoingCallData, context: context, isIncomingCall: true);
|
super.dispose();
|
||||||
callProvider.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startCall() async {
|
||||||
|
IncomingCallModel? sessionData;
|
||||||
|
dynamic calls = await FlutterCallkitIncoming.activeCalls();
|
||||||
|
if (calls.isNotEmpty) {
|
||||||
|
sessionData = IncomingCallModel.fromRawJson(jsonEncode(calls[0]));
|
||||||
|
isIncomingCall = sessionData.extra!.isIncomingCall!;
|
||||||
|
}
|
||||||
|
if (isIncomingCall) {
|
||||||
|
if (provider.isUserOnline) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("====== Processing Incoming Call in Online State =========");
|
||||||
|
}
|
||||||
|
await cProv.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson());
|
||||||
|
cProv.init();
|
||||||
|
} else {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("====== Processing Incoming Call =========");
|
||||||
|
}
|
||||||
|
await cProv.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson());
|
||||||
|
try {
|
||||||
|
AppState().setchatUserDetails = UserAutoLoginModel(response: Response.fromJson(sessionData.extra!.loginDetails!.toJson()), errorResponses: null);
|
||||||
|
await provider.buildHubConnection(context: context, ccProvider: cProv).whenComplete(() {
|
||||||
|
cProv.init();
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
logger.w(e);
|
||||||
|
}
|
||||||
|
if (kDebugMode) {
|
||||||
|
print('========== END ==============');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else if (isOutGoingCall) {
|
||||||
|
// if (kDebugMode) {
|
||||||
|
// print("====== Processing Outgoing Call =========");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
else {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("====== Something Wrong With Call =========");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// void connection({required data, required bool isUserOnline}) async {
|
||||||
|
// if (isUserOnline) {
|
||||||
|
// cProv.isUserOnline = isUserOnline;
|
||||||
|
// cProv.startIncomingCallViaKit(inCallData: data);
|
||||||
|
// } else {
|
||||||
|
// dynamic callData = await jsonDecode(data);
|
||||||
|
// AppState().setchatUserDetails = UserAutoLoginModel(
|
||||||
|
// response: Response.fromJson(callData[0]["loginDetails"]),
|
||||||
|
// errorResponses: null,
|
||||||
|
// );
|
||||||
|
// Utils.saveStringFromPrefs(
|
||||||
|
// "userLoginChatDetails",
|
||||||
|
// UserAutoLoginModel(
|
||||||
|
// response: Response.fromJson(callData[0]["loginDetails"]),
|
||||||
|
// errorResponses: null,
|
||||||
|
// ).toJson().toString());
|
||||||
|
// cProv.startIncomingCallViaKit(inCallData: data);
|
||||||
|
// try {
|
||||||
|
// await prov.buildHubConnection(context: AppRoutes.navigatorKey.currentContext!, ccProvider: cProv).whenComplete(() {
|
||||||
|
// cProv.init();
|
||||||
|
// });
|
||||||
|
// } catch (e) {
|
||||||
|
// logger.w(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Consumer<ChatCallProvider>(builder: (BuildContext context, ChatCallProvider chatcp, Widget? child) {
|
extendBody: true,
|
||||||
if (chatcp.isCallEnded) Navigator.pop(context);
|
body: Consumer2<ChatCallProvider, ChatProviderModel>(
|
||||||
return Stack(
|
builder: (BuildContext context, ChatCallProvider provider, ChatProviderModel cpm, Widget? child) {
|
||||||
alignment: FractionalOffset.center,
|
return provider.isIncomingCallLoader
|
||||||
children: <Widget>[
|
? const SizedBox(
|
||||||
if (widget.isVideoCall)
|
width: double.infinity,
|
||||||
Positioned.fill(
|
height: double.infinity,
|
||||||
child: RTCVideoView(
|
child: Center(child: CircularProgressIndicator()),
|
||||||
callProvider.localVideoRenderer,
|
)
|
||||||
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
: provider.isIncomingCall
|
||||||
),
|
? SizedBox(
|
||||||
),
|
width: double.infinity,
|
||||||
Positioned.fill(
|
height: double.infinity,
|
||||||
child: ClipRect(
|
child: Stack(
|
||||||
child: BackdropFilter(
|
alignment: FractionalOffset.center,
|
||||||
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
children: <Widget>[
|
||||||
child: Container(
|
if (!provider.isAudioCall && provider.isVideoCall)
|
||||||
decoration: BoxDecoration(
|
Positioned.fill(
|
||||||
color: MyColors.grey57Color.withOpacity(
|
child: RTCVideoView(
|
||||||
0.3,
|
provider.remoteRenderer,
|
||||||
),
|
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
||||||
),
|
key: const Key('remote'),
|
||||||
child: Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
mainAxisSize: MainAxisSize.max,
|
if (provider.isVideoCall)
|
||||||
children: <Widget>[
|
DraggableWidget(
|
||||||
40.height,
|
bottomMargin: 20,
|
||||||
Row(
|
topMargin: 40,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
intialVisibility: true,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
horizontalSpace: 20,
|
||||||
children: <Widget>[
|
shadowBorderRadius: 50,
|
||||||
Container(
|
initialPosition: AnchoringPosition.topLeft,
|
||||||
margin: const EdgeInsets.all(21.0),
|
dragController: dragController,
|
||||||
child: Container(
|
normalShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
||||||
margin: const EdgeInsets.only(
|
draggingShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
||||||
left: 10.0,
|
child: SizedBox(
|
||||||
right: 10.0,
|
height: 200,
|
||||||
|
width: 140,
|
||||||
|
child: RTCVideoView(
|
||||||
|
provider.localVideoRenderer,
|
||||||
|
mirror: true,
|
||||||
|
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
||||||
),
|
),
|
||||||
child: Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
),
|
||||||
mainAxisSize: MainAxisSize.min,
|
if (!provider.isVideoCall)
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
Positioned.fill(
|
||||||
children: <Widget>[
|
child: ClipRect(
|
||||||
SvgPicture.asset(
|
child: BackdropFilter(
|
||||||
"assets/images/user.svg",
|
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
||||||
height: 70,
|
child: Container(
|
||||||
width: 70,
|
decoration: BoxDecoration(
|
||||||
fit: BoxFit.cover,
|
color: MyColors.grey57Color.withOpacity(
|
||||||
),
|
0.3,
|
||||||
10.height,
|
|
||||||
Text(
|
|
||||||
widget.outGoingCallData.receiverName.toString().replaceAll(".", " "),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 21,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MyColors.white,
|
|
||||||
letterSpacing: -1.26,
|
|
||||||
height: 23 / 12,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Text(
|
child: Column(
|
||||||
"Ringing...",
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
style: TextStyle(
|
mainAxisSize: MainAxisSize.max,
|
||||||
fontSize: 16,
|
children: <Widget>[
|
||||||
fontWeight: FontWeight.w600,
|
40.height,
|
||||||
color: Color(
|
Row(
|
||||||
0xffC6C6C6,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.all(21.0),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(
|
||||||
|
left: 10.0,
|
||||||
|
right: 10.0,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: <Widget>[
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 70,
|
||||||
|
width: 70,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Text(
|
||||||
|
provider.outGoingCallData.receiverName!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 21,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MyColors.white,
|
||||||
|
letterSpacing: -1.26,
|
||||||
|
height: 23 / 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"On Call",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(
|
||||||
|
0xffC6C6C6,
|
||||||
|
),
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
height: 23 / 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
letterSpacing: -0.48,
|
],
|
||||||
height: 23 / 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 2,
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
Align(
|
||||||
),
|
alignment: Alignment.bottomCenter,
|
||||||
const Spacer(),
|
child: Container(
|
||||||
Container(
|
padding: const EdgeInsets.only(
|
||||||
margin: const EdgeInsets.only(
|
bottom: 20,
|
||||||
bottom: 70.0,
|
left: 40,
|
||||||
left: 49,
|
right: 40,
|
||||||
right: 49,
|
),
|
||||||
),
|
child: Row(
|
||||||
child: Row(
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: <Widget>[
|
||||||
children: <Widget>[
|
// if (provider.isVideoCall)
|
||||||
if (widget.isVideoCall)
|
RawMaterialButton(
|
||||||
RawMaterialButton(
|
constraints: const BoxConstraints(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
callProvider.camOff();
|
provider.loudOn();
|
||||||
},
|
},
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
fillColor: callProvider.isCamOff ? MyColors.green2DColor : Colors.grey,
|
fillColor: provider.isLoudSpeaker ? MyColors.textMixColor : Colors.grey,
|
||||||
padding: const EdgeInsets.all(
|
padding: const EdgeInsets.all(
|
||||||
15.0,
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.volume_up,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
shape: const CircleBorder(),
|
RawMaterialButton(
|
||||||
child: Icon(
|
constraints: const BoxConstraints(),
|
||||||
callProvider.isCamOff ? Icons.videocam_off : Icons.videocam,
|
onPressed: () {
|
||||||
color: MyColors.white,
|
provider.camOff();
|
||||||
size: 35.0,
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isCamOff ? MyColors.textMixColor : Colors.grey,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isCamOff ? Icons.videocam_off : Icons.videocam,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.switchCamera();
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isFrontCamera ? Colors.grey : MyColors.textMixColor,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isFrontCamera ? Icons.switch_camera_outlined : Icons.switch_camera,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
RawMaterialButton(
|
||||||
else
|
constraints: const BoxConstraints(),
|
||||||
RawMaterialButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
provider.micOff();
|
||||||
callProvider.loudOn();
|
},
|
||||||
},
|
elevation: 2.0,
|
||||||
elevation: 2.0,
|
fillColor: provider.isMicOff ? MyColors.textMixColor : Colors.grey,
|
||||||
fillColor: callProvider.isLoudSpeaker ? MyColors.green2DColor : Colors.grey,
|
padding: const EdgeInsets.all(
|
||||||
padding: const EdgeInsets.all(
|
10.0,
|
||||||
15.0,
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isMicOff ? Icons.mic_off : Icons.mic,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
shape: const CircleBorder(),
|
RawMaterialButton(
|
||||||
child: const Icon(
|
constraints: const BoxConstraints(),
|
||||||
Icons.volume_up,
|
onPressed: () {
|
||||||
color: MyColors.white,
|
provider.endCall(isUserOnline: cpm.isUserOnline).then((bool value) {
|
||||||
size: 35.0,
|
if (value) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
print("Reintiiiiiiitttiiiiiiii");
|
||||||
|
provider.initStreams();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: MyColors.redA3Color,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.call_end,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: provider.isOutGoingCall
|
||||||
|
? SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Stack(
|
||||||
|
alignment: FractionalOffset.center,
|
||||||
|
children: <Widget>[
|
||||||
|
if (!provider.isAudioCall && provider.isVideoCall)
|
||||||
|
Positioned.fill(
|
||||||
|
child: RTCVideoView(
|
||||||
|
provider.remoteRenderer,
|
||||||
|
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
||||||
|
key: const Key('remote'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
RawMaterialButton(
|
if (provider.isVideoCall)
|
||||||
onPressed: () {
|
DraggableWidget(
|
||||||
callProvider.micOff();
|
bottomMargin: 20,
|
||||||
},
|
topMargin: 40,
|
||||||
elevation: 2.0,
|
intialVisibility: true,
|
||||||
fillColor: callProvider.isMicOff ? MyColors.green2DColor : Colors.grey,
|
horizontalSpace: 20,
|
||||||
padding: const EdgeInsets.all(
|
shadowBorderRadius: 50,
|
||||||
15.0,
|
initialPosition: AnchoringPosition.topLeft,
|
||||||
),
|
dragController: dragController,
|
||||||
shape: const CircleBorder(),
|
normalShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
||||||
child: Icon(
|
draggingShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
||||||
callProvider.isMicOff ? Icons.mic_off : Icons.mic,
|
child: SizedBox(
|
||||||
color: MyColors.white,
|
height: 200,
|
||||||
size: 35.0,
|
width: 140,
|
||||||
|
child: RTCVideoView(
|
||||||
|
provider.localVideoRenderer,
|
||||||
|
mirror: true,
|
||||||
|
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
if (!provider.isVideoCall)
|
||||||
RawMaterialButton(
|
Positioned.fill(
|
||||||
onPressed: () {
|
child: ClipRect(
|
||||||
callProvider.endCall().then((value) {
|
child: BackdropFilter(
|
||||||
if (value) {
|
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
||||||
Navigator.of(context).pop();
|
child: Container(
|
||||||
}
|
decoration: BoxDecoration(
|
||||||
});
|
color: MyColors.grey57Color.withOpacity(
|
||||||
},
|
0.3,
|
||||||
elevation: 2.0,
|
),
|
||||||
fillColor: MyColors.redA3Color,
|
),
|
||||||
padding: const EdgeInsets.all(
|
child: Column(
|
||||||
15.0,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: <Widget>[
|
||||||
|
40.height,
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.all(21.0),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(
|
||||||
|
left: 10.0,
|
||||||
|
right: 10.0,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: <Widget>[
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 70,
|
||||||
|
width: 70,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
10.height,
|
||||||
|
Text(
|
||||||
|
provider.outGoingCallData.receiverName!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 21,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MyColors.white,
|
||||||
|
letterSpacing: -1.26,
|
||||||
|
height: 23 / 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"On Call",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
decoration: TextDecoration.none,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(
|
||||||
|
0xffC6C6C6,
|
||||||
|
),
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
height: 23 / 24,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
shape: const CircleBorder(),
|
Align(
|
||||||
child: const Icon(
|
alignment: Alignment.bottomCenter,
|
||||||
Icons.call_end,
|
child: Container(
|
||||||
color: MyColors.white,
|
padding: const EdgeInsets.only(
|
||||||
size: 35.0,
|
bottom: 20,
|
||||||
|
left: 40,
|
||||||
|
right: 40,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
// if (provider.isVideoCall)
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.loudOn();
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isLoudSpeaker ? MyColors.textMixColor : Colors.grey,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.volume_up,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.camOff();
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isCamOff ? MyColors.textMixColor : Colors.grey,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isCamOff ? Icons.videocam_off : Icons.videocam,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.switchCamera();
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isFrontCamera ? Colors.grey : MyColors.textMixColor,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isFrontCamera ? Icons.switch_camera_outlined : Icons.switch_camera,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.micOff();
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: provider.isMicOff ? MyColors.textMixColor : Colors.grey,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: Icon(
|
||||||
|
provider.isMicOff ? Icons.mic_off : Icons.mic,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RawMaterialButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () {
|
||||||
|
provider.endCall(isUserOnline: cpm.isUserOnline).then((bool value) {
|
||||||
|
if (value) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
elevation: 2.0,
|
||||||
|
fillColor: MyColors.redA3Color,
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
10.0,
|
||||||
|
),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.call_end,
|
||||||
|
color: MyColors.white,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
: const SizedBox();
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
BoxDecoration cardRadius(double radius, {required Color color, double? elevation}) {
|
|
||||||
return BoxDecoration(
|
|
||||||
shape: BoxShape.rectangle,
|
|
||||||
color: color ?? Colors.white,
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(radius)),
|
|
||||||
boxShadow: <BoxShadow>[BoxShadow(color: const Color(0xff000000).withOpacity(.05), blurRadius: elevation ?? 27, offset: const Offset(-2, 3))],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// if (Platform.isAndroid) {
|
||||||
|
// SystemNavigator.pop();
|
||||||
|
// } else if (Platform.isIOS) {
|
||||||
|
// exit(0);
|
||||||
|
// }
|
||||||
|
|||||||
@ -1,593 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:core';
|
|
||||||
import 'dart:ui';
|
|
||||||
import 'package:draggable_widget/draggable_widget.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
|
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
|
||||||
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
|
||||||
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
||||||
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
||||||
import 'package:mohem_flutter_app/main.dart';
|
|
||||||
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
|
|
||||||
import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart';
|
|
||||||
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
|
||||||
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
class StartCallPage extends StatefulWidget {
|
|
||||||
|
|
||||||
@override
|
|
||||||
_StartCallPageState createState() => _StartCallPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _StartCallPageState extends State<StartCallPage> {
|
|
||||||
DragController dragController = DragController();
|
|
||||||
bool isOutGoingCall = false;
|
|
||||||
bool isIncomingCall = false;
|
|
||||||
late ChatCallProvider cProv;
|
|
||||||
late ChatProviderModel provider;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
cProv = Provider.of<ChatCallProvider>(context, listen: false);
|
|
||||||
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
|
||||||
startCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void startCall() async {
|
|
||||||
IncomingCallModel? sessionData;
|
|
||||||
dynamic calls = await FlutterCallkitIncoming.activeCalls();
|
|
||||||
if (calls.isNotEmpty) {
|
|
||||||
sessionData = IncomingCallModel.fromRawJson(jsonEncode(calls[0]));
|
|
||||||
isIncomingCall = sessionData.extra!.isIncomingCall!;
|
|
||||||
}
|
|
||||||
if (isIncomingCall) {
|
|
||||||
if (provider.isUserOnline) {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print("====== Processing Incoming Call in Online State =========");
|
|
||||||
}
|
|
||||||
await cProv.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson());
|
|
||||||
cProv.init();
|
|
||||||
} else {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print("====== Processing Incoming Call =========");
|
|
||||||
}
|
|
||||||
await cProv.startIncomingCallViaKit(inCallData: sessionData!.extra!.callerDetails!.toJson());
|
|
||||||
try {
|
|
||||||
AppState().setchatUserDetails = UserAutoLoginModel(response: Response.fromJson(sessionData.extra!.loginDetails!.toJson()), errorResponses: null);
|
|
||||||
await provider.buildHubConnection(context: context, ccProvider: cProv).whenComplete(() {
|
|
||||||
cProv.init();
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
logger.w(e);
|
|
||||||
}
|
|
||||||
if (kDebugMode) {
|
|
||||||
print('========== END ==============');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (isOutGoingCall) {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print("====== Processing Outgoing Call =========");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print("====== Something Wrong With Call =========");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.d(sessionData!.extra!.isIncomingCall);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// void connection({required data, required bool isUserOnline}) async {
|
|
||||||
// if (isUserOnline) {
|
|
||||||
// cProv.isUserOnline = isUserOnline;
|
|
||||||
// cProv.startIncomingCallViaKit(inCallData: data);
|
|
||||||
// } else {
|
|
||||||
// dynamic callData = await jsonDecode(data);
|
|
||||||
// AppState().setchatUserDetails = UserAutoLoginModel(
|
|
||||||
// response: Response.fromJson(callData[0]["loginDetails"]),
|
|
||||||
// errorResponses: null,
|
|
||||||
// );
|
|
||||||
// Utils.saveStringFromPrefs(
|
|
||||||
// "userLoginChatDetails",
|
|
||||||
// UserAutoLoginModel(
|
|
||||||
// response: Response.fromJson(callData[0]["loginDetails"]),
|
|
||||||
// errorResponses: null,
|
|
||||||
// ).toJson().toString());
|
|
||||||
// cProv.startIncomingCallViaKit(inCallData: data);
|
|
||||||
// try {
|
|
||||||
// await prov.buildHubConnection(context: AppRoutes.navigatorKey.currentContext!, ccProvider: cProv).whenComplete(() {
|
|
||||||
// cProv.init();
|
|
||||||
// });
|
|
||||||
// } catch (e) {
|
|
||||||
// logger.w(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
extendBody: true,
|
|
||||||
body: Consumer2<ChatCallProvider, ChatProviderModel>(
|
|
||||||
builder: (BuildContext context, ChatCallProvider provider, ChatProviderModel cpm, Widget? child) {
|
|
||||||
return provider.isIncomingCallLoader
|
|
||||||
? const SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
)
|
|
||||||
: provider.isIncomingCall
|
|
||||||
? SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
child: Stack(
|
|
||||||
alignment: FractionalOffset.center,
|
|
||||||
children: <Widget>[
|
|
||||||
if (!provider.isAudioCall && provider.isVideoCall)
|
|
||||||
Positioned.fill(
|
|
||||||
child: RTCVideoView(
|
|
||||||
provider.remoteRenderer,
|
|
||||||
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
|
||||||
key: const Key('remote'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (provider.isVideoCall)
|
|
||||||
DraggableWidget(
|
|
||||||
bottomMargin: 20,
|
|
||||||
topMargin: 40,
|
|
||||||
intialVisibility: true,
|
|
||||||
horizontalSpace: 20,
|
|
||||||
shadowBorderRadius: 50,
|
|
||||||
initialPosition: AnchoringPosition.topLeft,
|
|
||||||
dragController: dragController,
|
|
||||||
normalShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
|
||||||
draggingShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 200,
|
|
||||||
width: 140,
|
|
||||||
child: RTCVideoView(
|
|
||||||
provider.localVideoRenderer,
|
|
||||||
mirror: true,
|
|
||||||
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!provider.isVideoCall)
|
|
||||||
Positioned.fill(
|
|
||||||
child: ClipRect(
|
|
||||||
child: BackdropFilter(
|
|
||||||
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: MyColors.grey57Color.withOpacity(
|
|
||||||
0.3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: <Widget>[
|
|
||||||
40.height,
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.all(21.0),
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.only(
|
|
||||||
left: 10.0,
|
|
||||||
right: 10.0,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: <Widget>[
|
|
||||||
SvgPicture.asset(
|
|
||||||
"assets/images/user.svg",
|
|
||||||
height: 70,
|
|
||||||
width: 70,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
10.height,
|
|
||||||
Text(
|
|
||||||
provider.outGoingCallData.receiverName!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 21,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MyColors.white,
|
|
||||||
letterSpacing: -1.26,
|
|
||||||
height: 23 / 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"On Call",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Color(
|
|
||||||
0xffC6C6C6,
|
|
||||||
),
|
|
||||||
letterSpacing: -0.48,
|
|
||||||
height: 23 / 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 2,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
bottom: 20,
|
|
||||||
left: 40,
|
|
||||||
right: 40,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: <Widget>[
|
|
||||||
// if (provider.isVideoCall)
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.loudOn();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isLoudSpeaker ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.volume_up,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.camOff();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isCamOff ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isCamOff ? Icons.videocam_off : Icons.videocam,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.switchCamera();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isFrontCamera ? Colors.grey : MyColors.textMixColor,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isFrontCamera ? Icons.switch_camera_outlined : Icons.switch_camera,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.micOff();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isMicOff ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isMicOff ? Icons.mic_off : Icons.mic,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.endCall().then((bool value) {
|
|
||||||
if (value) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: MyColors.redA3Color,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.call_end,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: provider.isOutGoingCall
|
|
||||||
? SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
child: Stack(
|
|
||||||
alignment: FractionalOffset.center,
|
|
||||||
children: <Widget>[
|
|
||||||
if (!provider.isAudioCall && provider.isVideoCall)
|
|
||||||
Positioned.fill(
|
|
||||||
child: RTCVideoView(
|
|
||||||
provider.remoteRenderer,
|
|
||||||
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
|
||||||
key: const Key('remote'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (provider.isVideoCall)
|
|
||||||
DraggableWidget(
|
|
||||||
bottomMargin: 20,
|
|
||||||
topMargin: 40,
|
|
||||||
intialVisibility: true,
|
|
||||||
horizontalSpace: 20,
|
|
||||||
shadowBorderRadius: 50,
|
|
||||||
initialPosition: AnchoringPosition.topLeft,
|
|
||||||
dragController: dragController,
|
|
||||||
normalShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
|
||||||
draggingShadow: const BoxShadow(spreadRadius: 0.0, blurRadius: 0.0),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 200,
|
|
||||||
width: 140,
|
|
||||||
child: RTCVideoView(
|
|
||||||
provider.localVideoRenderer,
|
|
||||||
mirror: true,
|
|
||||||
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!provider.isVideoCall)
|
|
||||||
Positioned.fill(
|
|
||||||
child: ClipRect(
|
|
||||||
child: BackdropFilter(
|
|
||||||
filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: MyColors.grey57Color.withOpacity(
|
|
||||||
0.3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: <Widget>[
|
|
||||||
40.height,
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.all(21.0),
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.only(
|
|
||||||
left: 10.0,
|
|
||||||
right: 10.0,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: <Widget>[
|
|
||||||
SvgPicture.asset(
|
|
||||||
"assets/images/user.svg",
|
|
||||||
height: 70,
|
|
||||||
width: 70,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
10.height,
|
|
||||||
Text(
|
|
||||||
provider.outGoingCallData.receiverName!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 21,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MyColors.white,
|
|
||||||
letterSpacing: -1.26,
|
|
||||||
height: 23 / 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"On Call",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
decoration: TextDecoration.none,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Color(
|
|
||||||
0xffC6C6C6,
|
|
||||||
),
|
|
||||||
letterSpacing: -0.48,
|
|
||||||
height: 23 / 24,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 2,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
bottom: 20,
|
|
||||||
left: 40,
|
|
||||||
right: 40,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: <Widget>[
|
|
||||||
// if (provider.isVideoCall)
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.loudOn();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isLoudSpeaker ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.volume_up,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.camOff();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isCamOff ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isCamOff ? Icons.videocam_off : Icons.videocam,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.switchCamera();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isFrontCamera ? Colors.grey : MyColors.textMixColor,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isFrontCamera ? Icons.switch_camera_outlined : Icons.switch_camera,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.micOff();
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: provider.isMicOff ? MyColors.textMixColor : Colors.grey,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: Icon(
|
|
||||||
provider.isMicOff ? Icons.mic_off : Icons.mic,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawMaterialButton(
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
onPressed: () {
|
|
||||||
provider.endCall().then((bool value) {
|
|
||||||
if (value) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
elevation: 2.0,
|
|
||||||
fillColor: MyColors.redA3Color,
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
10.0,
|
|
||||||
),
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.call_end,
|
|
||||||
color: MyColors.white,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: SizedBox(
|
|
||||||
child: Container(
|
|
||||||
color: Colors.red,
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// if (Platform.isAndroid) {
|
|
||||||
// SystemNavigator.pop();
|
|
||||||
// } else if (Platform.isIOS) {
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
Loading…
Reference in New Issue