End Call Android Native

development_aamir_testing23
Aamir Muhammad 2 years ago
parent 7bc36188c4
commit bce79efdd2

@ -1,16 +1,15 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:ui'; import 'dart:ui';
import 'package:camera/camera.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_webrtc/flutter_webrtc.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/models/chat/call.dart'; import 'package:mohem_flutter_app/models/chat/call.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:provider/provider.dart'; import 'package:provider/provider.dart';
class OutGoingCall extends StatefulWidget { class OutGoingCall extends StatefulWidget {
@ -23,407 +22,169 @@ class OutGoingCall extends StatefulWidget {
_OutGoingCallState createState() => _OutGoingCallState(); _OutGoingCallState createState() => _OutGoingCallState();
} }
class _OutGoingCallState extends State<OutGoingCall> with SingleTickerProviderStateMixin { class _OutGoingCallState extends State<OutGoingCall> {
AnimationController? _animationController; late ChatCallProvider callProvider;
late CameraController controller; late ChatProviderModel chatProvider;
late List<CameraDescription> _cameras;
Future<void>? _initializeControllerFuture;
bool isCameraReady = false;
bool isMicOff = false;
bool isLoudSpeaker = false;
bool isCamOff = false;
late ChatCallProvider callProviderd;
@override @override
void initState() { void initState() {
callProviderd = Provider.of<ChatCallProvider>(context, listen: false);
_animationController = AnimationController(
vsync: this,
duration: const Duration(
milliseconds: 500,
),
);
// _runAnimation();
// connectSignaling();
WidgetsBinding.instance.addPostFrameCallback(
(_) => _runAnimation(),
);
super.initState(); super.initState();
} }
void init() {
widget.isVideoCall ? callProvider.isVideoCall = true : callProvider.isVideoCall = false;
callProvider.isOutGoingCall = true;
callProvider.initLocalCamera(chatProvmodel: chatProvider, callData: widget.outGoingCallData, context: context);
}
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
chatProvider = Provider.of<ChatProviderModel>(context, listen: false);
callProvider = Provider.of<ChatCallProvider>(context, listen: false);
init();
return Scaffold( return Scaffold(
body: FutureBuilder<void>( body: Consumer<ChatCallProvider>(builder: (BuildContext context, ChatCallProvider chatcp, Widget? child) {
future: _initializeControllerFuture, if (chatcp.isCallEnded) {
builder: (BuildContext context, AsyncSnapshot<void> snapshot) { Navigator.pop(context);
if (snapshot.connectionState == ConnectionState.done) { }
return Stack( return Stack(
alignment: FractionalOffset.center, alignment: FractionalOffset.center,
children: <Widget>[ children: <Widget>[
if (widget.isVideoCall) if (chatcp.isVideoCall)
Positioned.fill( Positioned.fill(
child: CameraPreview( child: RTCVideoView(
controller, chatcp.localVideoRenderer!,
objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,
),
),
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(
Positioned.fill( crossAxisAlignment: CrossAxisAlignment.start,
child: ClipRect( mainAxisSize: MainAxisSize.max,
child: BackdropFilter( children: <Widget>[
filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), 40.height,
child: Container( Row(
decoration: BoxDecoration( crossAxisAlignment: CrossAxisAlignment.center,
color: MyColors.grey57Color.withOpacity( mainAxisAlignment: MainAxisAlignment.center,
0.3,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[ 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(
widget.outGoingCallData.title!,
style: const TextStyle(
fontSize: 21,
fontWeight: FontWeight.bold,
color: MyColors.white,
letterSpacing: -1.26,
height: 23 / 12,
),
),
const Text(
"Ringing...",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(
0xffC6C6C6,
),
letterSpacing: -0.48,
height: 23 / 24,
),
),
const SizedBox(
height: 2,
),
],
),
),
),
],
),
// Container(
// margin: const EdgeInsets.all(21.0),
// width: MediaQuery.of(context).size.width,
// decoration: cardRadius(15.0, color: MyColors.black, elevation: null),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// Container(
// padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 6.0),
// child: Text(
// "TranslationBase.of(context).appoInfo",
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.white, letterSpacing: -0.64, height: 23 / 12),
// ),
// ),
// Container(
// padding: const EdgeInsets.only(left: 16.0, right: 16.0),
// child: Text(
// "widget.OutGoingCallData.appointmentdate + widget.OutGoingCallData.appointmenttime",
// style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600),
// ),
// ),
// Container(
// padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 21.0),
// child: Text(
// "widget.OutGoingCallData.clinicname",
// style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600),
// ),
// ),
// ],
// ),
// ),
const Spacer(),
Container( Container(
margin: const EdgeInsets.only( margin: const EdgeInsets.all(21.0),
bottom: 70.0, child: Container(
left: 49, margin: const EdgeInsets.only(
right: 49, left: 10.0,
), right: 10.0,
child: Row( ),
mainAxisSize: MainAxisSize.max, child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ mainAxisSize: MainAxisSize.min,
if (widget.isVideoCall) mainAxisAlignment: MainAxisAlignment.spaceAround,
RawMaterialButton( children: <Widget>[
onPressed: () { SvgPicture.asset(
_camOff(); "assets/images/user.svg",
}, height: 70,
elevation: 2.0, width: 70,
fillColor: isCamOff ? MyColors.green2DColor : Colors.grey, fit: BoxFit.cover,
padding: const EdgeInsets.all( ),
15.0, 10.height,
), Text(
shape: const CircleBorder(), widget.outGoingCallData.receiverName.toString().replaceAll(".", " "),
child: Icon( style: const TextStyle(
isCamOff ? Icons.videocam_off : Icons.videocam, fontSize: 21,
color: MyColors.white, fontWeight: FontWeight.bold,
size: 35.0,
),
)
else
RawMaterialButton(
onPressed: () {
_loudOn();
},
elevation: 2.0,
fillColor: isLoudSpeaker ? MyColors.green2DColor : Colors.grey,
padding: const EdgeInsets.all(
15.0,
),
shape: const CircleBorder(),
child: const Icon(
Icons.volume_up,
color: MyColors.white, color: MyColors.white,
size: 35.0, letterSpacing: -1.26,
height: 23 / 12,
), ),
), ),
RawMaterialButton( const Text(
onPressed: () { "Ringing...",
_micOff(); style: TextStyle(
}, fontSize: 16,
elevation: 2.0, fontWeight: FontWeight.w600,
fillColor: isMicOff ? MyColors.green2DColor : Colors.grey, color: Color(
padding: const EdgeInsets.all( 0xffC6C6C6,
15.0, ),
), letterSpacing: -0.48,
shape: const CircleBorder(), height: 23 / 24,
child: Icon( ),
isMicOff ? Icons.mic_off : Icons.mic,
color: MyColors.white,
size: 35.0,
),
),
RawMaterialButton(
onPressed: () {
backToHome();
},
elevation: 2.0,
fillColor: MyColors.redA3Color,
padding: const EdgeInsets.all(
15.0,
), ),
shape: const CircleBorder(), const SizedBox(
child: const Icon( height: 2,
Icons.call_end,
color: MyColors.white,
size: 35.0,
), ),
), ],
], ),
), ),
), ),
], ],
), ),
), const Spacer(),
Container(
margin: const EdgeInsets.only(
bottom: 70.0,
left: 49,
right: 49,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RawMaterialButton(
onPressed: () {
chatcp.endCall(isUserOnline: chatProvider.isUserOnline).then((bool value) {
if (value) {
Navigator.of(context).pop();
// print("Reintiiiiiiitttzzzz");
// chatcp.initStreams();
}
});
},
elevation: 2.0,
fillColor: MyColors.redA3Color,
padding: const EdgeInsets.all(
15.0,
),
shape: const CircleBorder(),
child: const Icon(
Icons.call_end,
color: MyColors.white,
size: 35.0,
),
),
],
),
),
],
), ),
), ),
), ),
], ),
); ),
} else { ],
return const Center( );
child: CircularProgressIndicator(), }),
);
}
},
),
); );
} }
void _runAnimation() async {
_cameras = await availableCameras();
CameraDescription firstCamera = _cameras[1];
controller = CameraController(firstCamera, ResolutionPreset.medium);
_initializeControllerFuture = controller.initialize();
setState(() {});
// setAudioFile();
for (int i = 0; i < 100; i++) {
await _animationController!.forward();
await _animationController!.reverse();
}
}
void _micOff() {
setState(() {
isMicOff = !isMicOff;
});
}
void _camOff() {
setState(() {
isCamOff = !isCamOff;
});
}
void _loudOn() {
setState(() {
isLoudSpeaker = !isLoudSpeaker;
});
}
Future<void> _submit() async {
try {
// backToHome();
// final roomModel = RoomModel(name: widget.OutGoingCallData.name, token: widget.OutGoingCallData.sessionId, identity: widget.OutGoingCallData.identity);
await controller?.dispose();
// changeCallStatusAPI(4);
// if (_session != null && _signaling != null) {
// await Navigator.of(context).pushReplacement(
// MaterialPageRoute(
// // fullscreenDialog: true,
// builder: (BuildContext context) {
// // if (widget.OutGoingCallData.isWebRTC == "true") {
// return StartVideoCall(signaling: _signaling, session: _session);
//
// // else {
// // return OpenTokConnectCallPage(apiKey: OPENTOK_API_KEY, sessionId: widget.OutGoingCallData.sessionId, token: widget.OutGoingCallData.token);
// // }
//
// // return VideoCallWebPage(receiverId: widget.OutGoingCallData.receiverID, callerId: widget.OutGoingCallData.callerID); // Web WebRTC VideoCall
//
// // return CallHomePage(receiverId: widget.OutGoingCallData.receiverID, callerId: widget.OutGoingCallData.callerID); // App WebRTC VideoCall
// },
// ),
// );
// } else {
// // Invalid Params/Data
// Utils.showToast("Failed to establish connection with server");
// }
} catch (err) {
print(err);
// await PlatformExceptionAlertDialog(
// exception: err,
// ).show(context);
Utils.showToast(err.toString());
}
}
// void changeCallStatusAPI(int sessionStatus) {
// LiveCareService service = new LiveCareService();
// service.endCallAPI(widget.OutGoingCallData.sessionId, sessionStatus, context).then((res) {}).catchError((err) {
// print(err);
// });
// }
void backToHome() async {
// final connected = await signaling.declineCall(widget.OutGoingCallData.callerID, widget.OutGoingCallData.receiverID);
// LandingPage.isOpenCallPage = false;
// _signaling
_animationController!.dispose();
// player.stop();
// changeCallStatusAPI(3);
// _signaling.bye(_session, callRejected: true);
// _signaling.callDisconnected(_session, callRejected: true);
Navigator.of(context).pop();
}
//
// void disposeAudioResources() async {
// await player.dispose();
// }
//
// void setAudioFile() async {
// player.stop();
// await player.setVolume(1.0); // full volume
// try {
// await player.setAsset('assets/sounds/ring_60Sec.mp3').then((value) {
// player.setLoopMode(LoopMode.one); // loop ring sound
// player.play();
// }).catchError((err) {
// print("Error: $err");
// });
// } catch (e) {
// print("Error: $e");
// }
// }
//
// void connectSignaling({@required bool iAmCaller = false}) async {
// print("----------------- + Signaling Connection Started ---------------------------");
// var caller = widget.OutGoingCallData.callerID;
// var receiver = widget.OutGoingCallData.receiverID;
// var host = widget.OutGoingCallData.server;
//
// var selfRole = iAmCaller ? "Caller" : "Receiver";
// var selfId = iAmCaller ? caller : receiver;
// var selfUser = SocketUser(id: selfId, name: "$selfRole-$selfId", userAgent: DeviceInfo.userAgent, moreInfo: {});
//
// var remoteRole = !iAmCaller ? "Caller" : "Receiver";
// var remoteId = !iAmCaller ? caller : receiver;
// var remoteUser = SocketUser(id: remoteId, name: "$remoteRole-$remoteId", userAgent: DeviceInfo.userAgent, moreInfo: {});
//
// var sessionId = "$caller-$receiver";
// _session = SessionOneToOne(id: sessionId, local_user: selfUser, remote_user: remoteUser);
//
// _signaling = Signaling(host, session: _session);
// await _signaling.connect();
//
// if (_signaling.state == SignalingState.Open) {
// return;
// }
// }
BoxDecoration cardRadius(double radius, {required Color color, double? elevation}) { BoxDecoration cardRadius(double radius, {required Color color, double? elevation}) {
return BoxDecoration( return BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
color: color ?? Colors.white, color: color ?? Colors.white,
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(Radius.circular(radius)),
Radius.circular(radius), boxShadow: <BoxShadow>[BoxShadow(color: const Color(0xff000000).withOpacity(.05), blurRadius: elevation ?? 27, offset: const Offset(-2, 3))],
),
boxShadow: <BoxShadow>[
BoxShadow(
color: const Color(
0xff000000,
).withOpacity(
.05,
),
//spreadRadius: 5,
blurRadius: elevation ?? 27,
offset: const Offset(
-2,
3,
),
),
],
); );
} }
} }

@ -120,7 +120,7 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
}); });
} }
}), }),
// if (Platform.isAndroid) // if (Platform.isAndroid)
21.width, 21.width,
], ],
), ),
@ -129,218 +129,218 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
builder: (BuildContext context, ChatProviderModel m, Widget? child) { builder: (BuildContext context, ChatProviderModel m, Widget? child) {
return (m.isLoading return (m.isLoading
? ChatHomeShimmer( ? ChatHomeShimmer(
isDetailedScreen: true, isDetailedScreen: true,
) )
: Column( : Column(
children: <Widget>[ children: <Widget>[
SmartRefresher( SmartRefresher(
enablePullDown: false, enablePullDown: false,
enablePullUp: true, enablePullUp: true,
onLoading: () { onLoading: () {
getMoreChat(); getMoreChat();
},
header: const MaterialClassicHeader(
color: MyColors.gradiantEndColor,
),
controller: _rc,
reverse: true,
child: ListView.separated(
controller: m.scrollController,
shrinkWrap: true,
physics: const BouncingScrollPhysics(),
reverse: true,
itemCount: m.userChatHistory.length,
padding: const EdgeInsets.all(21),
separatorBuilder: (BuildContext cxt, int index) => 8.height,
itemBuilder: (BuildContext context, int i) {
return SwipeTo(
iconColor: MyColors.lightGreenColor,
child: ChatBubble(
dateTime: m.dateFormte(m.userChatHistory[i].createdDate!),
cItem: m.userChatHistory[i],
),
onRightSwipe: () {
m.chatReply(
m.userChatHistory[i],
);
}, },
).onPress(() async { header: const MaterialClassicHeader(
// logger.w(m.userChatHistory[i].toJson()); color: MyColors.gradiantEndColor,
if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) { ),
if (m.userChatHistory[i].fileTypeId! == 1 || controller: _rc,
m.userChatHistory[i].fileTypeId! == 5 || reverse: true,
m.userChatHistory[i].fileTypeId! == 7 || child: ListView.separated(
m.userChatHistory[i].fileTypeId! == 6 || controller: m.scrollController,
m.userChatHistory[i].fileTypeId! == 8 shrinkWrap: true,
// || m.userChatHistory[i].fileTypeId! == 2 physics: const BouncingScrollPhysics(),
) { reverse: true,
m.getChatMedia(context, itemCount: m.userChatHistory.length,
fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!); padding: const EdgeInsets.all(21),
} separatorBuilder: (BuildContext cxt, int index) => 8.height,
} itemBuilder: (BuildContext context, int i) {
}); return SwipeTo(
}, iconColor: MyColors.lightGreenColor,
), child: ChatBubble(
).expanded, dateTime: m.dateFormte(m.userChatHistory[i].createdDate!),
if (m.isReplyMsg) cItem: m.userChatHistory[i],
SizedBox( ),
height: 82, onRightSwipe: () {
child: Row( m.chatReply(
children: <Widget>[ m.userChatHistory[i],
Container(height: 82, color: MyColors.textMixColor, width: 6), );
Container( },
color: MyColors.darkTextColor.withOpacity(0.10), ).onPress(() async {
padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21), // logger.w(m.userChatHistory[i].toJson());
if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) {
if (m.userChatHistory[i].fileTypeId! == 1 ||
m.userChatHistory[i].fileTypeId! == 5 ||
m.userChatHistory[i].fileTypeId! == 7 ||
m.userChatHistory[i].fileTypeId! == 6 ||
m.userChatHistory[i].fileTypeId! == 8
// || m.userChatHistory[i].fileTypeId! == 2
) {
m.getChatMedia(context,
fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!);
}
}
});
},
),
).expanded,
if (m.isReplyMsg)
SizedBox(
height: 82,
child: Row( child: Row(
children: [ children: <Widget>[
Column( Container(height: 82, color: MyColors.textMixColor, width: 6),
crossAxisAlignment: CrossAxisAlignment.start, Container(
children: [ color: MyColors.darkTextColor.withOpacity(0.10),
(AppState().chatDetails!.response!.userName == m.repliedMsg.first.currentUserName.toString() padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21),
? "You" child: Row(
: m.repliedMsg.first.currentUserName.toString().replaceAll(".", " ")) children: [
.toText14(color: MyColors.lightGreenColor), Column(
(m.repliedMsg.isNotEmpty ? m.repliedMsg.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2) crossAxisAlignment: CrossAxisAlignment.start,
], children: [
(AppState().chatDetails!.response!.userName == m.repliedMsg.first.currentUserName.toString()
? "You"
: m.repliedMsg.first.currentUserName.toString().replaceAll(".", " "))
.toText14(color: MyColors.lightGreenColor),
(m.repliedMsg.isNotEmpty ? m.repliedMsg.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2)
],
).expanded,
12.width,
if (m.isReplyMsg && m.repliedMsg.isNotEmpty) showReplyImage(m.repliedMsg, m),
12.width,
const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe),
],
),
).expanded, ).expanded,
12.width,
if (m.isReplyMsg && m.repliedMsg.isNotEmpty) showReplyImage(m.repliedMsg, m),
12.width,
const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe),
], ],
), ),
).expanded, ),
], if (m.isAttachmentMsg && m.sFileType == ".png" || m.sFileType == ".jpeg" || m.sFileType == ".jpg")
), SizedBox(height: 200, width: double.infinity, child: Image.file(m.selectedFile, fit: BoxFit.cover)).paddingOnly(left: 21, right: 21, top: 21),
), const Divider(height: 1, color: MyColors.lightGreyEFColor),
if (m.isAttachmentMsg && m.sFileType == ".png" || m.sFileType == ".jpeg" || m.sFileType == ".jpg") if (m.isRecoding)
SizedBox(height: 200, width: double.infinity, child: Image.file(m.selectedFile, fit: BoxFit.cover)).paddingOnly(left: 21, right: 21, top: 21), Column(
const Divider(height: 1, color: MyColors.lightGreyEFColor), children: <Widget>[
if (m.isRecoding) Row(
Column( children: [
children: <Widget>[ Text(m.buildTimer()).paddingAll(10),
Row( if (m.isRecoding && m.isPlaying)
children: [ WaveBubble(
Text(m.buildTimer()).paddingAll(10), playerController: m.playerController,
if (m.isRecoding && m.isPlaying) isPlaying: m.playerController.playerState == PlayerState.playing,
WaveBubble( onTap: () {},
playerController: m.playerController, ).expanded
isPlaying: m.playerController.playerState == PlayerState.playing, else
onTap: () {}, AudioWaveforms(
).expanded waveStyle: const WaveStyle(
else waveColor: MyColors.lightGreenColor,
AudioWaveforms( middleLineColor: Colors.transparent,
waveStyle: const WaveStyle( extendWaveform: true,
waveColor: MyColors.lightGreenColor, showBottom: true,
middleLineColor: Colors.transparent, showTop: true,
extendWaveform: true, waveThickness: 2,
showBottom: true, showMiddleLine: false,
showTop: true, middleLineThickness: 0,
waveThickness: 2, ),
showMiddleLine: false, padding: const EdgeInsets.all(5),
middleLineThickness: 0, shouldCalculateScrolledPosition: false,
), margin: EdgeInsets.zero,
padding: const EdgeInsets.all(5), size: const Size(double.infinity, 30.0),
shouldCalculateScrolledPosition: false, recorderController: m.recorderController,
margin: EdgeInsets.zero, backgroundColor: Colors.white,
size: const Size(double.infinity, 30.0), ).expanded,
recorderController: m.recorderController, ],
backgroundColor: Colors.white,
).expanded,
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(
Icons.delete_outlined,
size: 26,
color: MyColors.lightGreenColor,
).paddingAll(10).onPress(() {
m.deleteRecoding();
}),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
.onPress(
() => m.sendChatMessage(context,
targetUserId: params!.chatUser!.id!,
userStatus: params!.chatUser!.userStatus ?? 0,
userEmail: params!.chatUser!.email!,
targetUserName: params!.chatUser!.userName!),
)
.paddingOnly(right: 21),
],
),
],
).objectContainerView(disablePadding: true, radius: 0),
if (!m.isRecoding)
Row(
children: [
CustomAutoDirection(
onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL),
text: m.msgText,
child: TextField(
// textDirection: m.textDirection,
controller: m.message,
decoration: InputDecoration(
hintTextDirection: m.textDirection,
hintText: m.isAttachmentMsg ? m.selectedFile.path.split("/").last : LocaleKeys.typeheretoreply.tr(),
hintStyle: TextStyle(color: m.isAttachmentMsg ? MyColors.darkTextColor : MyColors.grey98Color, fontSize: 14),
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
filled: true,
fillColor: MyColors.white,
contentPadding: const EdgeInsets.only(
left: 21,
top: 20,
bottom: 20,
), ),
prefixIconConstraints: const BoxConstraints(), Row(
prefixIcon: m.sFileType.isNotEmpty mainAxisAlignment: MainAxisAlignment.spaceBetween,
? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15) children: [
: null, const Icon(
), Icons.delete_outlined,
onChanged: (String val) { size: 26,
m.inputBoxDirection(val); color: MyColors.lightGreenColor,
m.userTypingInvoke(currentUser: AppState().chatDetails!.response!.id!, reciptUser: params!.chatUser!.id!); ).paddingAll(10).onPress(() {
}, m.deleteRecoding();
).expanded, }),
), SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
if (m.sFileType.isNotEmpty) .onPress(
() => m.sendChatMessage(context,
targetUserId: params!.chatUser!.id!,
userStatus: params!.chatUser!.userStatus ?? 0,
userEmail: params!.chatUser!.email!,
targetUserName: params!.chatUser!.userName!),
)
.paddingOnly(right: 21),
],
),
],
).objectContainerView(disablePadding: true, radius: 0),
if (!m.isRecoding)
Row( Row(
children: <Widget>[ children: [
const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5), CustomAutoDirection(
("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0), onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL),
text: m.msgText,
child: TextField(
// textDirection: m.textDirection,
controller: m.message,
decoration: InputDecoration(
hintTextDirection: m.textDirection,
hintText: m.isAttachmentMsg ? m.selectedFile.path.split("/").last : LocaleKeys.typeheretoreply.tr(),
hintStyle: TextStyle(color: m.isAttachmentMsg ? MyColors.darkTextColor : MyColors.grey98Color, fontSize: 14),
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
filled: true,
fillColor: MyColors.white,
contentPadding: const EdgeInsets.only(
left: 21,
top: 20,
bottom: 20,
),
prefixIconConstraints: const BoxConstraints(),
prefixIcon: m.sFileType.isNotEmpty
? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15)
: null,
),
onChanged: (String val) {
m.inputBoxDirection(val);
m.userTypingInvoke(currentUser: AppState().chatDetails!.response!.id!, reciptUser: params!.chatUser!.id!);
},
).expanded,
),
if (m.sFileType.isNotEmpty)
Row(
children: <Widget>[
const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5),
("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0),
],
).onPress(() => m.removeAttachment()).paddingOnly(right: 15),
if (m.sFileType.isEmpty)
RotationTransition(
turns: const AlwaysStoppedAnimation(45 / 360),
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
() => m.selectImageToUpload(context),
),
).paddingOnly(right: 15),
const Icon(
Icons.mic,
color: MyColors.lightGreenColor,
).paddingOnly(right: 15).onPress(() {
m.startRecoding(context);
}),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
.onPress(
() => m.sendChatMessage(context,
targetUserId: params!.chatUser!.id!,
userStatus: params!.chatUser!.userStatus ?? 0,
userEmail: params!.chatUser!.email!,
targetUserName: params!.chatUser!.userName!),
)
.paddingOnly(right: 21),
], ],
).onPress(() => m.removeAttachment()).paddingOnly(right: 15), ).objectContainerView(disablePadding: true, radius: 0),
if (m.sFileType.isEmpty)
RotationTransition(
turns: const AlwaysStoppedAnimation(45 / 360),
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
() => m.selectImageToUpload(context),
),
).paddingOnly(right: 15),
const Icon(
Icons.mic,
color: MyColors.lightGreenColor,
).paddingOnly(right: 15).onPress(() {
m.startRecoding(context);
}),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
.onPress(
() => m.sendChatMessage(context,
targetUserId: params!.chatUser!.id!,
userStatus: params!.chatUser!.userStatus ?? 0,
userEmail: params!.chatUser!.email!,
targetUserName: params!.chatUser!.userName!),
)
.paddingOnly(right: 21),
], ],
).objectContainerView(disablePadding: true, radius: 0), ));
],
));
}, },
), ),
), ),
@ -358,11 +358,11 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
} else { } else {
return data.first.fileTypeResponse != null && data.first.fileTypeResponse!.fileTypeName != null return data.first.fileTypeResponse != null && data.first.fileTypeResponse!.fileTypeName != null
? Container( ? Container(
width: 43, width: 43,
height: 43, height: 43,
constraints: const BoxConstraints(), constraints: const BoxConstraints(),
decoration: BoxDecoration(border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), color: Colors.white), decoration: BoxDecoration(border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), color: Colors.white),
child: SvgPicture.asset(m.getType(data.first.fileTypeResponse!.fileTypeName ?? ""), alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 5, right: 5, top: 5, bottom: 5)) child: SvgPicture.asset(m.getType(data.first.fileTypeResponse!.fileTypeName ?? ""), alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 5, right: 5, top: 5, bottom: 5))
: const SizedBox(); : const SizedBox();
} }
} }

Loading…
Cancel
Save