|
|
|
|
@ -202,75 +202,95 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
appBar: DefaultAppBar(
|
|
|
|
|
title: widget.title,
|
|
|
|
|
actions: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: "calling/audio_call_icon".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
tooltip: "Audio",
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
bool audioPermission = await Provider.of<ChatProvider>(context, listen: false).checkAudioPermissions();
|
|
|
|
|
if (!audioPermission) {
|
|
|
|
|
context.showConfirmDialog("To perform audio call, we need permission to access microphone.", title: "Permission Required", onTap: () async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
audioPermission = await Provider.of<ChatProvider>(context, listen: false).requestAudioPermissions();
|
|
|
|
|
if (!audioPermission) {
|
|
|
|
|
bool openSetting = await showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (_) => const AAlertDialog(
|
|
|
|
|
title: "Permission denied",
|
|
|
|
|
content: "Permission is denied. Please go to application Setting to enable it.",
|
|
|
|
|
button1Text: "Cancel",
|
|
|
|
|
button2Text: "Open Setting",
|
|
|
|
|
Selector<ChatProvider, _ChatConnectionState>(
|
|
|
|
|
selector: (_, provider) => _ChatConnectionState(
|
|
|
|
|
isLoading: provider.chatLoginTokenLoading,
|
|
|
|
|
loginResponse: provider.chatLoginResponse,
|
|
|
|
|
),
|
|
|
|
|
builder: (context, connectionState, child) {
|
|
|
|
|
if (!connectionState.isLoading && connectionState.loginResponse == null) {
|
|
|
|
|
return SizedBox();
|
|
|
|
|
} else {
|
|
|
|
|
return Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: "calling/audio_call_icon".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
tooltip: "Audio",
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
bool audioPermission = await Provider.of<ChatProvider>(context, listen: false).checkAudioPermissions();
|
|
|
|
|
if (!audioPermission) {
|
|
|
|
|
context.showConfirmDialog("To perform audio call, we need permission to access microphone.", title: "Permission Required", onTap: () async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
audioPermission = await Provider.of<ChatProvider>(context, listen: false).requestAudioPermissions();
|
|
|
|
|
if (!audioPermission) {
|
|
|
|
|
bool openSetting = await showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (_) => const AAlertDialog(
|
|
|
|
|
title: "Permission denied",
|
|
|
|
|
content: "Permission is denied. Please go to application Setting to enable it.",
|
|
|
|
|
button1Text: "Cancel",
|
|
|
|
|
button2Text: "Open Setting",
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (!openSetting) PermissionHandler.openAppSettings();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => AudioCallPage(
|
|
|
|
|
sender: Provider.of<ChatProvider>(context, listen: false).sender!,
|
|
|
|
|
recipient: Provider.of<ChatProvider>(context, listen: false).recipient!,
|
|
|
|
|
moduleId: widget.moduleId,
|
|
|
|
|
referenceID: widget.requestId,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => AudioCallPage(
|
|
|
|
|
sender: Provider.of<ChatProvider>(context, listen: false).sender!,
|
|
|
|
|
recipient: Provider.of<ChatProvider>(context, listen: false).recipient!,
|
|
|
|
|
moduleId: widget.moduleId,
|
|
|
|
|
referenceID: widget.requestId,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (!openSetting) PermissionHandler.openAppSettings();
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => AudioCallPage(
|
|
|
|
|
sender: Provider.of<ChatProvider>(context, listen: false).sender!,
|
|
|
|
|
recipient: Provider.of<ChatProvider>(context, listen: false).recipient!,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => AudioCallPage(
|
|
|
|
|
sender: Provider.of<ChatProvider>(context, listen: false).sender!,
|
|
|
|
|
recipient: Provider.of<ChatProvider>(context, listen: false).recipient!,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: "calling/video_call_icon".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
tooltip: "Video",
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
bool videoPermission = await Provider.of<ChatProvider>(context, listen: false).checkVideoPermissions();
|
|
|
|
|
if (!videoPermission) {
|
|
|
|
|
context.showConfirmDialog("To perform Video call, we need permission to access microphone & Camera.", title: "Permission Required", onTap: () async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
videoPermission = await Provider.of<ChatProvider>(context, listen: false).requestVideoPermissions();
|
|
|
|
|
if (videoPermission) {
|
|
|
|
|
bool openSetting = await showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (_) => const AAlertDialog(
|
|
|
|
|
title: "Permission denied",
|
|
|
|
|
content: "Permission is denied. Please go to application Setting to enable it.",
|
|
|
|
|
button1Text: "Cancel",
|
|
|
|
|
button2Text: "Open Setting",
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: "calling/video_call_icon".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
tooltip: "Video",
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
bool videoPermission = await Provider.of<ChatProvider>(context, listen: false).checkVideoPermissions();
|
|
|
|
|
if (!videoPermission) {
|
|
|
|
|
context.showConfirmDialog("To perform Video call, we need permission to access microphone & Camera.", title: "Permission Required", onTap: () async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
videoPermission = await Provider.of<ChatProvider>(context, listen: false).requestVideoPermissions();
|
|
|
|
|
if (videoPermission) {
|
|
|
|
|
bool openSetting = await showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (_) => const AAlertDialog(
|
|
|
|
|
title: "Permission denied",
|
|
|
|
|
content: "Permission is denied. Please go to application Setting to enable it.",
|
|
|
|
|
button1Text: "Cancel",
|
|
|
|
|
button2Text: "Open Setting",
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (!openSetting) PermissionHandler.openAppSettings();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CallPage(isAudio: false)));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
if (!openSetting) PermissionHandler.openAppSettings();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CallPage(isAudio: false)));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: Selector<ChatProvider, _ChatConnectionState>(
|
|
|
|
|
|