Chat video fixes

development_sikander
haroon amjad 2 years ago
parent d3358d578c
commit 55c096aa7e

@ -4,7 +4,6 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" /> <uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.NFC" /> <uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
@ -18,7 +17,7 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" /> <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
<!-- Chat Web RTC Calling --> <!-- Chat Web RTC Calling -->
<uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.autofocus" />

@ -376,7 +376,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 3.7.8; MARKETING_VERSION = 3.7.9;
PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -514,7 +514,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 3.7.8; MARKETING_VERSION = 3.7.9;
PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -544,7 +544,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 3.7.8; MARKETING_VERSION = 3.7.9;
PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm; PRODUCT_BUNDLE_IDENTIFIER = com.cloudsolutions.mohemm;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";

@ -39,7 +39,7 @@ class ChatApiClient {
"platform": Platform.isIOS ? "ios" : "android", "platform": Platform.isIOS ? "ios" : "android",
"deviceToken": AppState().getIsHuawei ? AppState().getHuaweiPushToken : AppState().getDeviceToken, "deviceToken": AppState().getIsHuawei ? AppState().getHuaweiPushToken : AppState().getDeviceToken,
"isHuaweiDevice": AppState().getIsHuawei, "isHuaweiDevice": AppState().getIsHuawei,
"voipToken": "80a3b01fc1ef2453eb4f1daa4fc31d8142d9cb67baf848e91350b607971fe2ba", "voipToken": Platform.isIOS ? "80a3b01fc1ef2453eb4f1daa4fc31d8142d9cb67baf848e91350b607971fe2ba" : "",
}, },
); );
@ -145,14 +145,14 @@ class ChatApiClient {
} }
// Upload Chat Media // Upload Chat Media
Future<Object?> uploadMedia(String userId, File file) async { Future<Object?> uploadMedia(String userId, File file, String fileSource) async {
if (kDebugMode) { if (kDebugMode) {
print("${ApiConsts.chatMediaImageUploadUrl}upload"); print("${ApiConsts.chatMediaImageUploadUrl}upload");
print(AppState().chatDetails!.response!.token); print(AppState().chatDetails!.response!.token);
} }
dynamic request = MultipartRequest('POST', Uri.parse('${ApiConsts.chatMediaImageUploadUrl}upload')); dynamic request = MultipartRequest('POST', Uri.parse('${ApiConsts.chatMediaImageUploadUrl}upload'));
request.fields.addAll({'userId': userId, 'fileSource': '1'}); request.fields.addAll({'userId': userId, 'fileSource': fileSource});
request.files.add(await MultipartFile.fromPath('files', file.path)); request.files.add(await MultipartFile.fromPath('files', file.path));
request.headers.addAll({'Authorization': 'Bearer ${AppState().chatDetails!.response!.token}'}); request.headers.addAll({'Authorization': 'Bearer ${AppState().chatDetails!.response!.token}'});
StreamedResponse response = await request.send(); StreamedResponse response = await request.send();
@ -164,10 +164,10 @@ class ChatApiClient {
} }
// Download File For Chat // Download File For Chat
Future<Uint8List> downloadURL({required String fileName, required String fileTypeDescription}) async { Future<Uint8List> downloadURL({required String fileName, required String fileTypeDescription, required int fileSource}) async {
Response response = await ApiClient().postJsonForResponse( Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatMediaImageUploadUrl}download", "${ApiConsts.chatMediaImageUploadUrl}download",
{"fileType": fileTypeDescription, "fileName": fileName, "fileSource": 1}, {"fileType": fileTypeDescription, "fileName": fileName, "fileSource": fileSource},
token: AppState().chatDetails!.response!.token, token: AppState().chatDetails!.response!.token,
); );
Uint8List data = Uint8List.fromList(response.bodyBytes); Uint8List data = Uint8List.fromList(response.bodyBytes);

File diff suppressed because it is too large Load Diff

@ -1,5 +1,4 @@
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -18,9 +17,9 @@ import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.da
import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart'; import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart';
import 'package:mohem_flutter_app/ui/chat/common.dart'; import 'package:mohem_flutter_app/ui/chat/common.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
import 'package:video_player/video_player.dart';
class ChatBubble extends StatelessWidget { class ChatBubble extends StatelessWidget {
ChatBubble({Key? key, required this.dateTime, required this.cItem}) : super(key: key); ChatBubble({Key? key, required this.dateTime, required this.cItem}) : super(key: key);
@ -82,7 +81,8 @@ class ChatBubble extends StatelessWidget {
} }
} else { } else {
Utils.showLoading(context); Utils.showLoading(context);
Uint8List encodedString = await ChatApiClient().downloadURL(fileName: data.contant!, fileTypeDescription: provider.getFileTypeDescription(data.fileTypeResponse!.fileTypeName ?? "")); Uint8List encodedString =
await ChatApiClient().downloadURL(fileName: data.contant!, fileTypeDescription: provider.getFileTypeDescription(data.fileTypeResponse!.fileTypeName ?? ""), fileSource: 1);
// try { // try {
File sFile = await provider.downChatVoice(encodedString, data.fileTypeResponse!.fileTypeName ?? "", data); File sFile = await provider.downChatVoice(encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
if (sFile.path.isEmpty) { if (sFile.path.isEmpty) {
@ -195,20 +195,26 @@ class ChatBubble extends StatelessWidget {
}), }),
), ),
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13 && cItem.voiceController != null) if (fileTypeID == 13 && cItem.voiceController != null) currentWaveBubble(context, cItem),
currentWaveBubble(context, cItem) if (fileTypeID == 16)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
showVideoThumb(context, cItem),
Row(
children: [
Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12().expanded),
],
),
],
)
else else
Row( Row(
children: [ children: [
if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8)
// || fileTypeID == 2
)
SvgPicture.asset(provider.getType(fileTypeName ?? ""), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 0, right: 10), SvgPicture.asset(provider.getType(fileTypeName ?? ""), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 0, right: 10),
Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12().expanded), Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12().expanded),
if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8) const Icon(Icons.remove_red_eye, size: 16)
//|| fileTypeID == 2
)
const Icon(Icons.remove_red_eye, size: 16)
], ],
), ),
Align( Align(
@ -276,7 +282,12 @@ class ChatBubble extends StatelessWidget {
child: showImage( child: showImage(
isReplyPreview: true, isReplyPreview: true,
fileName: cItem.userChatReplyResponse!.contant!, fileName: cItem.userChatReplyResponse!.contant!,
fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg"), fileTypeDescription: cItem.fileTypeResponse != null && cItem.fileTypeResponse!.fileTypeDescription != null
? cItem.fileTypeResponse!.fileTypeDescription
: cItem.fileTypeResponse!.fileTypeName
// fileTypeDescription: cItem.userChatReplyResponse!.fileTypeResponse!.fileTypeDescription ?? "image/jpg"
),
), ),
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16) ).paddingOnly(left: 10, right: 10, bottom: 16, top: 16)
], ],
@ -300,20 +311,26 @@ class ChatBubble extends StatelessWidget {
}), }),
), ),
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13 && cItem.voiceController != null) if (fileTypeID == 13 && cItem.voiceController != null) recipetWaveBubble(context, cItem),
recipetWaveBubble(context, cItem) if (fileTypeID == 16)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
showVideoThumb(context, cItem),
Row(
children: [
Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12(color: Colors.white).expanded),
],
),
],
)
else else
Row( Row(
children: [ children: [
if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8)
// || fileTypeID == 2
)
SvgPicture.asset(provider.getType(fileTypeName ?? ""), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 0, right: 10), SvgPicture.asset(provider.getType(fileTypeName ?? ""), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 0, right: 10),
Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12(color: Colors.white).expanded), Directionality(textDirection: provider.getTextDirection(cItem.contant ?? ""), child: (cItem.contant ?? "").toText12(color: Colors.white).expanded),
if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8) const Icon(Icons.remove_red_eye, color: Colors.white, size: 16)
//|| fileTypeID == 2
)
const Icon(Icons.remove_red_eye, color: Colors.white, size: 16)
], ],
), ),
Align( Align(
@ -324,11 +341,7 @@ class ChatBubble extends StatelessWidget {
), ),
], ],
), ),
).paddingOnly(right: MediaQuery.of(context).size.width * 0.3); ).paddingOnly(right: MediaQuery.of(context).size.width * 0.33);
}
Widget voiceMsg(BuildContext context) {
return Container();
} }
Widget showImage({required bool isReplyPreview, required String fileName, required String fileTypeDescription}) { Widget showImage({required bool isReplyPreview, required String fileName, required String fileTypeDescription}) {
@ -342,7 +355,7 @@ class ChatBubble extends StatelessWidget {
); );
} else { } else {
return FutureBuilder<Uint8List>( return FutureBuilder<Uint8List>(
future: ChatApiClient().downloadURL(fileName: fileName, fileTypeDescription: fileTypeDescription), future: ChatApiClient().downloadURL(fileName: fileName, fileTypeDescription: fileTypeDescription, fileSource: 1),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) { builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState != ConnectionState.waiting) { if (snapshot.connectionState != ConnectionState.waiting) {
if (snapshot.data == null) { if (snapshot.data == null) {
@ -470,4 +483,50 @@ class ChatBubble extends StatelessWidget {
}, },
); );
} }
Widget showVideoThumb(BuildContext context, SingleUserChatModel data) {
return LoadVideo(data: data);
}
}
class LoadVideo extends StatefulWidget {
final SingleUserChatModel data;
const LoadVideo({Key? key, required this.data}) : super(key: key);
@override
State<LoadVideo> createState() => _LoadVideoState();
}
class _LoadVideoState extends State<LoadVideo> {
late VideoPlayerController videoController;
@override
void initState() {
videoController = VideoPlayerController.networkUrl(Uri.parse('https://apiderichat.hmg.com/attachments/${widget.data.fileTypeResponse?.fileName}'))..initialize().then((_) {});
super.initState();
}
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(5.0),
child: AspectRatio(
aspectRatio: videoController.value.aspectRatio,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
VideoPlayer(videoController),
Align(
alignment: Alignment.center,
child: Icon(
Icons.play_arrow,
color: Colors.white.withOpacity(.7),
size: 56,
),
)
],
),
));
}
} }

@ -152,14 +152,13 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
logger.w(m.userChatHistory[i].toJson()); logger.w(m.userChatHistory[i].toJson());
if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) { if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) {
if (m.userChatHistory[i].fileTypeId! == 1 || if (m.userChatHistory[i].fileTypeId! == 1 ||
m.userChatHistory[i].fileTypeId! == 5 || m.userChatHistory[i].fileTypeId! == 5 ||
m.userChatHistory[i].fileTypeId! == 7 || m.userChatHistory[i].fileTypeId! == 7 ||
m.userChatHistory[i].fileTypeId! == 6 || m.userChatHistory[i].fileTypeId! == 6 ||
m.userChatHistory[i].fileTypeId! == 8 m.userChatHistory[i].fileTypeId! == 8 ||
// || m.userChatHistory[i].fileTypeId! == 2 m.userChatHistory[i].fileTypeId! == 16) {
) {
m.getChatMedia(context, m.getChatMedia(context,
fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!); fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!, fileSource: 1);
} }
} }
}); });

@ -22,6 +22,7 @@ import 'package:mohem_flutter_app/ui/chat/common.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
import 'package:video_player/video_player.dart';
class GroupChatBubble extends StatelessWidget { class GroupChatBubble extends StatelessWidget {
GroupChatBubble({Key? key, required this.dateTime, required this.cItem}) GroupChatBubble({Key? key, required this.dateTime, required this.cItem})
@ -66,19 +67,19 @@ class GroupChatBubble extends StatelessWidget {
? cItem.fileTypeResponse!.fileTypeDescription ? cItem.fileTypeResponse!.fileTypeDescription
: ""; : "";
isDelivered = cItem.currentUserId == AppState().chatDetails!.response!.id && isDelivered = cItem.currentUserId == AppState().chatDetails!.response!.id &&
cItem.isDelivered == true cItem.isDelivered == true
? true ? true
: false; : false;
userName = AppState().chatDetails!.response!.userName == userName = AppState().chatDetails!.response!.userName ==
cItem.currentUserName.toString() cItem.currentUserName.toString()
? "You" ? "You"
: cItem.currentUserName.toString(); : cItem.currentUserName.toString();
} }
void playVoice( void playVoice(
BuildContext context, { BuildContext context, {
required SingleUserChatModel data, required SingleUserChatModel data,
}) async { }) async {
if (data.voice != null && data.voice!.existsSync()) { if (data.voice != null && data.voice!.existsSync()) {
if (Platform.isIOS) { if (Platform.isIOS) {
Duration? duration = await data.voiceController! Duration? duration = await data.voiceController!
@ -100,7 +101,7 @@ class GroupChatBubble extends StatelessWidget {
Uint8List encodedString = await ChatApiClient().downloadURL( Uint8List encodedString = await ChatApiClient().downloadURL(
fileName: data.contant!, fileName: data.contant!,
fileTypeDescription: provider.getFileTypeDescription( fileTypeDescription: provider.getFileTypeDescription(
data.fileTypeResponse!.fileTypeName ?? "")); data.fileTypeResponse!.fileTypeName ?? ""), fileSource: 2);
// try { // try {
File sFile = await provider.downChatVoice( File sFile = await provider.downChatVoice(
encodedString, data.fileTypeResponse!.fileTypeName ?? "", data); encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
@ -122,7 +123,7 @@ class GroupChatBubble extends StatelessWidget {
data.voiceController!.play(); data.voiceController!.play();
} else { } else {
Duration? duration = Duration? duration =
await data.voiceController!.setFilePath(sFile.path); await data.voiceController!.setFilePath(sFile.path);
await data.voiceController!.setLoopMode(LoopMode.off); await data.voiceController!.setLoopMode(LoopMode.off);
await data.voiceController!.seek(duration); await data.voiceController!.seek(duration);
Utils.hideLoading(context); Utils.hideLoading(context);
@ -148,7 +149,7 @@ class GroupChatBubble extends StatelessWidget {
cItem.voiceController!.positionStream, cItem.voiceController!.positionStream,
cItem.voiceController!.bufferedPositionStream, cItem.voiceController!.bufferedPositionStream,
cItem.voiceController!.durationStream, cItem.voiceController!.durationStream,
(Duration position, Duration bufferedPosition, Duration? duration) => (Duration position, Duration bufferedPosition, Duration? duration) =>
PositionData( PositionData(
position, bufferedPosition, duration ?? Duration.zero)); position, bufferedPosition, duration ?? Duration.zero));
@ -189,24 +190,24 @@ class GroupChatBubble extends StatelessWidget {
children: <Widget>[ children: <Widget>[
(userName) (userName)
.toText12( .toText12(
color: MyColors.gradiantStartColor, isBold: false) color: MyColors.gradiantStartColor, isBold: false)
.paddingOnly(right: 5, top: 5, bottom: 0, left: 5), .paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
Directionality( Directionality(
textDirection: provider.getTextDirection( textDirection: provider.getTextDirection(
cItem.groupChatReplyResponse != null cItem.groupChatReplyResponse != null
? cItem.groupChatReplyResponse!.contant ? cItem.groupChatReplyResponse!.contant
.toString() .toString()
: ""), : ""),
child: (cItem.groupChatReplyResponse != null child: (cItem.groupChatReplyResponse != null
? cItem.groupChatReplyResponse!.contant ? cItem.groupChatReplyResponse!.contant
.toString() .toString()
: "") : "")
.toText10( .toText10(
color: isCurrentUser color: isCurrentUser
? MyColors.grey71Color ? MyColors.grey71Color
: MyColors.white.withOpacity(0.5), : MyColors.white.withOpacity(0.5),
isBold: false, isBold: false,
maxlines: 4) maxlines: 4)
.paddingOnly(right: 5, top: 5, bottom: 8, left: 5), .paddingOnly(right: 5, top: 5, bottom: 8, left: 5),
), ),
], ],
@ -223,11 +224,11 @@ class GroupChatBubble extends StatelessWidget {
child: showImage( child: showImage(
isReplyPreview: false, isReplyPreview: false,
fileName: fileName:
cItem.groupChatReplyResponse!.contant!, cItem.groupChatReplyResponse!.contant!,
fileTypeDescription: cItem fileTypeDescription: cItem
.groupChatReplyResponse! .groupChatReplyResponse!
.fileTypeResponse! .fileTypeResponse!
.fileTypeDescription ?? .fileTypeDescription ??
"image/jpg")), "image/jpg")),
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16), ).paddingOnly(left: 10, right: 10, bottom: 16, top: 16),
], ],
@ -243,10 +244,13 @@ class GroupChatBubble extends StatelessWidget {
height: 140, height: 140,
width: 227, width: 227,
child: showImage( child: showImage(
isReplyPreview: false, isReplyPreview: false,
fileName: cItem.contant!, fileName: cItem.contant!,
fileTypeDescription: fileTypeDescription: cItem.fileTypeResponse != null &&
cItem.fileTypeResponse!.fileTypeDescription) cItem.fileTypeResponse!.fileTypeDescription !=
null
? cItem.fileTypeResponse!.fileTypeDescription
: cItem.fileTypeResponse!.fileTypeName)
.onPress(() { .onPress(() {
showDialog( showDialog(
context: context, context: context,
@ -258,7 +262,9 @@ class GroupChatBubble extends StatelessWidget {
), ),
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13 && cItem.voiceController != null) if (fileTypeID == 13 && cItem.voiceController != null)
currentWaveBubble(context, cItem) currentWaveBubble(context, cItem),
if (fileTypeID == 16)
showVideoThumb(context, cItem)
else else
Row( Row(
children: [ children: [
@ -270,10 +276,10 @@ class GroupChatBubble extends StatelessWidget {
// || fileTypeID == 2 // || fileTypeID == 2
) )
SvgPicture.asset(provider.getType(fileTypeName ?? ""), SvgPicture.asset(provider.getType(fileTypeName ?? ""),
height: 30, height: 30,
width: 22, width: 22,
alignment: Alignment.center, alignment: Alignment.center,
fit: BoxFit.cover) fit: BoxFit.cover)
.paddingOnly(left: 0, right: 10), .paddingOnly(left: 0, right: 10),
Directionality( Directionality(
textDirection: provider.getTextDirection(cItem.contant ?? ""), textDirection: provider.getTextDirection(cItem.contant ?? ""),
@ -349,27 +355,27 @@ class GroupChatBubble extends StatelessWidget {
children: <Widget>[ children: <Widget>[
(userName) (userName)
.toText12( .toText12(
color: MyColors.gradiantStartColor, color: MyColors.gradiantStartColor,
isBold: false) isBold: false)
.paddingOnly(right: 5, top: 5, bottom: 0, left: 5), .paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
Directionality( Directionality(
textDirection: provider.getTextDirection( textDirection: provider.getTextDirection(
cItem.groupChatReplyResponse != null cItem.groupChatReplyResponse != null
? cItem.groupChatReplyResponse!.contant ? cItem.groupChatReplyResponse!.contant
.toString() .toString()
: ""), : ""),
child: (cItem.groupChatReplyResponse != null child: (cItem.groupChatReplyResponse != null
? cItem.groupChatReplyResponse!.contant ? cItem.groupChatReplyResponse!.contant
.toString() .toString()
: "") : "")
.toText10( .toText10(
color: isCurrentUser color: isCurrentUser
? MyColors.grey71Color ? MyColors.grey71Color
: MyColors.white.withOpacity(0.5), : MyColors.white.withOpacity(0.5),
isBold: false, isBold: false,
maxlines: 4) maxlines: 4)
.paddingOnly( .paddingOnly(
right: 5, top: 5, bottom: 8, left: 5), right: 5, top: 5, bottom: 8, left: 5),
), ),
], ],
).expanded, ).expanded,
@ -385,11 +391,11 @@ class GroupChatBubble extends StatelessWidget {
child: showImage( child: showImage(
isReplyPreview: true, isReplyPreview: true,
fileName: fileName:
cItem.groupChatReplyResponse!.contant!, cItem.groupChatReplyResponse!.contant!,
fileTypeDescription: cItem fileTypeDescription: cItem
.groupChatReplyResponse! .groupChatReplyResponse!
.fileTypeResponse! .fileTypeResponse!
.fileTypeDescription ?? .fileTypeDescription ??
"image/jpg"), "image/jpg"),
), ),
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16) ).paddingOnly(left: 10, right: 10, bottom: 16, top: 16)
@ -406,11 +412,11 @@ class GroupChatBubble extends StatelessWidget {
height: 140, height: 140,
width: 227, width: 227,
child: showImage( child: showImage(
isReplyPreview: false, isReplyPreview: false,
fileName: cItem.contant ?? "", fileName: cItem.contant ?? "",
fileTypeDescription: fileTypeDescription:
cItem.fileTypeResponse!.fileTypeDescription ?? cItem.fileTypeResponse!.fileTypeDescription ??
"image/jpg") "image/jpg")
.onPress(() { .onPress(() {
showDialog( showDialog(
context: context, context: context,
@ -422,14 +428,18 @@ class GroupChatBubble extends StatelessWidget {
), ),
).paddingOnly(bottom: 4), ).paddingOnly(bottom: 4),
if (fileTypeID == 13 && cItem.voiceController != null) if (fileTypeID == 13 && cItem.voiceController != null)
recipetWaveBubble(context, cItem) recipetWaveBubble(context, cItem),
if (fileTypeID == 16)
showVideoThumb(context, cItem)
else else
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
cItem.currentUserName!.toText10( cItem.currentUserName!
.toText10(
color: Colors.black, color: Colors.black,
).paddingOnly(bottom: 5), )
.paddingOnly(bottom: 5),
Row( Row(
children: [ children: [
if (fileTypeID == 1 || if (fileTypeID == 1 ||
@ -440,14 +450,14 @@ class GroupChatBubble extends StatelessWidget {
// || fileTypeID == 2 // || fileTypeID == 2
) )
SvgPicture.asset(provider.getType(fileTypeName ?? ""), SvgPicture.asset(provider.getType(fileTypeName ?? ""),
height: 30, height: 30,
width: 22, width: 22,
alignment: Alignment.center, alignment: Alignment.center,
fit: BoxFit.cover) fit: BoxFit.cover)
.paddingOnly(left: 0, right: 10), .paddingOnly(left: 0, right: 10),
Directionality( Directionality(
textDirection: textDirection:
provider.getTextDirection(cItem.contant ?? ""), provider.getTextDirection(cItem.contant ?? ""),
child: (cItem.contant ?? "") child: (cItem.contant ?? "")
.toText12(color: Colors.white) .toText12(color: Colors.white)
.expanded), .expanded),
@ -464,9 +474,11 @@ class GroupChatBubble extends StatelessWidget {
), ),
Align( Align(
alignment: Alignment.topRight, alignment: Alignment.topRight,
child: dateTime.toText10( child: dateTime
.toText10(
color: Colors.white.withOpacity(.71), color: Colors.white.withOpacity(.71),
).paddingOnly(top:5), )
.paddingOnly(top: 5),
), ),
], ],
), ),
@ -479,8 +491,8 @@ class GroupChatBubble extends StatelessWidget {
Widget showImage( Widget showImage(
{required bool isReplyPreview, {required bool isReplyPreview,
required String fileName, required String fileName,
required String fileTypeDescription}) { required String fileTypeDescription}) {
if (cItem.isImageLoaded != null && cItem.image != null) { if (cItem.isImageLoaded != null && cItem.image != null) {
return Image.memory( return Image.memory(
cItem.image!, cItem.image!,
@ -492,7 +504,7 @@ class GroupChatBubble extends StatelessWidget {
} else { } else {
return FutureBuilder<Uint8List>( return FutureBuilder<Uint8List>(
future: ChatApiClient().downloadURL( future: ChatApiClient().downloadURL(
fileName: fileName, fileTypeDescription: fileTypeDescription), fileName: fileName, fileTypeDescription: fileTypeDescription, fileSource:2),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) { builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState != ConnectionState.waiting) { if (snapshot.connectionState != ConnectionState.waiting) {
if (snapshot.data == null) { if (snapshot.data == null) {
@ -528,7 +540,7 @@ class GroupChatBubble extends StatelessWidget {
left: BorderSide( left: BorderSide(
width: 6, width: 6,
color: color:
isCurrentUser ? MyColors.gradiantStartColor : MyColors.white), isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
), ),
color: isCurrentUser color: isCurrentUser
? MyColors.black.withOpacity(0.10) ? MyColors.black.withOpacity(0.10)
@ -547,7 +559,7 @@ class GroupChatBubble extends StatelessWidget {
duration: positionData?.duration ?? Duration.zero, duration: positionData?.duration ?? Duration.zero,
position: positionData?.position ?? Duration.zero, position: positionData?.position ?? Duration.zero,
bufferedPosition: bufferedPosition:
positionData?.bufferedPosition ?? Duration.zero, positionData?.bufferedPosition ?? Duration.zero,
onChangeEnd: data.voiceController!.seek, onChangeEnd: data.voiceController!.seek,
).expanded; ).expanded;
}, },
@ -557,6 +569,11 @@ class GroupChatBubble extends StatelessWidget {
).circle(5); ).circle(5);
} }
Widget showVideoThumb(BuildContext context, GetGroupChatHistoryAsync data) {
return LoadVideo(data: data);
}
Widget recipetWaveBubble( Widget recipetWaveBubble(
BuildContext context, GetGroupChatHistoryAsync data) { BuildContext context, GetGroupChatHistoryAsync data) {
return Container( return Container(
@ -566,7 +583,7 @@ class GroupChatBubble extends StatelessWidget {
left: BorderSide( left: BorderSide(
width: 6, width: 6,
color: color:
isCurrentUser ? MyColors.gradiantStartColor : MyColors.white), isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
), ),
color: isCurrentUser color: isCurrentUser
? MyColors.black.withOpacity(0.10) ? MyColors.black.withOpacity(0.10)
@ -586,7 +603,7 @@ class GroupChatBubble extends StatelessWidget {
duration: positionData?.duration ?? Duration.zero, duration: positionData?.duration ?? Duration.zero,
position: positionData?.position ?? Duration.zero, position: positionData?.position ?? Duration.zero,
bufferedPosition: bufferedPosition:
positionData?.bufferedPosition ?? Duration.zero, positionData?.bufferedPosition ?? Duration.zero,
onChangeEnd: data.voiceController!.seek, onChangeEnd: data.voiceController!.seek,
).expanded; ).expanded;
}, },
@ -641,3 +658,51 @@ class GroupChatBubble extends StatelessWidget {
); );
} }
} }
class LoadVideo extends StatefulWidget {
final GetGroupChatHistoryAsync data;
const LoadVideo({Key? key, required this.data}) : super(key: key);
@override
State<LoadVideo> createState() => _LoadVideoState();
}
class _LoadVideoState extends State<LoadVideo> {
late VideoPlayerController videoController;
@override
void initState() {
videoController = VideoPlayerController.networkUrl(Uri.parse(
'https://apiderichat.hmg.com/groupattachments/${widget.data.fileTypeResponse?.fileName}'))
..initialize().then((_) {
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
),
child: AspectRatio(
aspectRatio: videoController.value.aspectRatio,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
VideoPlayer(videoController),
Align(
alignment: Alignment.center,
child: Icon(
Icons.play_arrow,
color: Colors.white.withOpacity(.7),
size: 56,
),
)
],
),
));
}
}

@ -58,11 +58,11 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
data.paginationVal = data.paginationVal + 10; data.paginationVal = data.paginationVal + 10;
if (params != null) { if (params != null) {
data.getGroupChatHistory(params!.groupChatDetails! data.getGroupChatHistory(params!.groupChatDetails!
// senderUID: AppState().chatDetails!.response!.id!.toInt(), // senderUID: AppState().chatDetails!.response!.id!.toInt(),
// receiverUID: params!.groupChatDetails!.groupId!, // receiverUID: params!.groupChatDetails!.groupId!,
// loadMore: true, // loadMore: true,
// isNewChat: false, // isNewChat: false,
); );
} }
} }
await Future.delayed( await Future.delayed(
@ -83,13 +83,12 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
data = Provider.of<ChatProviderModel>(context, listen: false); data = Provider.of<ChatProviderModel>(context, listen: false);
// callPro = Provider.of<ChatCallProvider>(context, listen: false); // callPro = Provider.of<ChatCallProvider>(context, listen: false);
if (params != null) { if (params != null) {
data.getGroupChatHistory( data.getGroupChatHistory(params!.groupChatDetails!
params!.groupChatDetails! // senderUID: AppState().chatDetails!.response!.id!.toInt(),
// senderUID: AppState().chatDetails!.response!.id!.toInt(), // receiverUID: params!.groupChatHistory!.groupId!,
// receiverUID: params!.groupChatHistory!.groupId!, // loadMore: false,
// loadMore: false, // isNewChat: params!.isNewChat!,
// isNewChat: params!.isNewChat!, );
);
data.initAudio(receiverId: params!.groupChatDetails!.groupId!); data.initAudio(receiverId: params!.groupChatDetails!.groupId!);
} }
@ -99,8 +98,8 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
context, context,
title: params!.groupChatDetails!.groupName.toString().replaceAll(".", " ").capitalizeFirstofEach, title: params!.groupChatDetails!.groupName.toString().replaceAll(".", " ").capitalizeFirstofEach,
showHomeButton: false, showHomeButton: false,
// showTyping: true, // showTyping: true,
// chatUser: params!.groupChatHistory!.groupChatHistoryTargetUserList as ChatUser, // chatUser: params!.groupChatHistory!.groupChatHistoryTargetUserList as ChatUser,
actions: [ actions: [
// SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() { // SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() {
// makeCall(callType: "AUDIO"); // makeCall(callType: "AUDIO");
@ -117,224 +116,219 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
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.groupChatHistory.length,
padding: const EdgeInsets.all(21),
separatorBuilder: (BuildContext cxt, int index) => 8.height,
itemBuilder: (BuildContext context, int i) {
return SwipeTo(
iconColor: MyColors.lightGreenColor,
child: GroupChatBubble(
dateTime: m.groupChatHistory[i].createdDate!,
cItem: m.groupChatHistory[i],
),
onRightSwipe: (val) {
m.groupChatReply(
m.groupChatHistory[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.groupChatHistory.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: GroupChatBubble(
).expanded, dateTime: m.groupChatHistory[i].createdDate!,
if (m.isReplyMsg) cItem: m.groupChatHistory[i],
SizedBox( ),
height: 82, onRightSwipe: (val) {
child: Row( m.groupChatReply(
children: <Widget>[ m.groupChatHistory[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! == 16) {
m.getChatMedia(context,
fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!, fileSource: 2);
}
}
});
},
),
).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.groupChatReplyData.first.currentUserName.toString() padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21),
? "You" child: Row(
: m.groupChatReplyData.first.currentUserName.toString().replaceAll(".", " ")) children: [
.toText14(color: MyColors.lightGreenColor), Column(
(m.groupChatReplyData.isNotEmpty ? m.groupChatReplyData.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2) crossAxisAlignment: CrossAxisAlignment.start,
], children: [
(AppState().chatDetails!.response!.userName == m.groupChatReplyData.first.currentUserName.toString()
? "You"
: m.groupChatReplyData.first.currentUserName.toString().replaceAll(".", " "))
.toText14(color: MyColors.lightGreenColor),
(m.groupChatReplyData.isNotEmpty ? m.groupChatReplyData.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2)
],
).expanded,
12.width,
if (m.isReplyMsg && m.groupChatReplyData.isNotEmpty) showReplyImage(m.groupChatReplyData, m),
12.width,
const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe),
],
),
).expanded, ).expanded,
12.width,
if (m.isReplyMsg && m.groupChatReplyData.isNotEmpty) showReplyImage(m.groupChatReplyData, 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),
if (m.isRecoding)
Column(
children: <Widget>[
Row(
children: [
Text(m.buildTimer()).paddingAll(10),
if (m.isRecoding && m.isPlaying)
WaveBubble(
playerController: m.playerController,
isPlaying: m.playerController.playerState == PlayerState.playing,
onTap: () {},
).expanded
else
AudioWaveforms(
waveStyle: const WaveStyle(
waveColor: MyColors.lightGreenColor,
middleLineColor: Colors.transparent,
extendWaveform: true,
showBottom: true,
showTop: true,
waveThickness: 2,
showMiddleLine: false,
middleLineThickness: 0,
),
padding: const EdgeInsets.all(5),
shouldCalculateScrolledPosition: false,
margin: EdgeInsets.zero,
size: const Size(double.infinity, 30.0),
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.sendGroupChatMessage(context,
targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0,
userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!
),
)
.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(),
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.groupTypingInvoke(groupDetails: params!.groupChatDetails!, groupId: params!.groupChatDetails!.groupId!);
},
).expanded,
),
if (m.sFileType.isNotEmpty)
Row(
children: <Widget>[ children: <Widget>[
const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5), Row(
("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0), children: [
Text(m.buildTimer()).paddingAll(10),
if (m.isRecoding && m.isPlaying)
WaveBubble(
playerController: m.playerController,
isPlaying: m.playerController.playerState == PlayerState.playing,
onTap: () {},
).expanded
else
AudioWaveforms(
waveStyle: const WaveStyle(
waveColor: MyColors.lightGreenColor,
middleLineColor: Colors.transparent,
extendWaveform: true,
showBottom: true,
showTop: true,
waveThickness: 2,
showMiddleLine: false,
middleLineThickness: 0,
),
padding: const EdgeInsets.all(5),
shouldCalculateScrolledPosition: false,
margin: EdgeInsets.zero,
size: const Size(double.infinity, 30.0),
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.sendGroupChatMessage(context,
targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0,
userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!),
)
.paddingOnly(right: 21),
],
),
], ],
).onPress(() => m.removeAttachment()).paddingOnly(right: 15), ).objectContainerView(disablePadding: true, radius: 0),
if (m.sFileType.isEmpty) if (!m.isRecoding)
RotationTransition( Row(
turns: const AlwaysStoppedAnimation(45 / 360), children: [
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress( CustomAutoDirection(
() => { onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL),
m.selectImageToUpload(context) 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.groupTypingInvoke(groupDetails: params!.groupChatDetails!, groupId: params!.groupChatDetails!.groupId!);
}, },
), ).expanded,
).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.sendGroupChatMessage(context,
targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0,
userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!
), ),
) if (m.sFileType.isNotEmpty)
.paddingOnly(right: 21), 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.sendGroupChatMessage(context,
targetUserId: params!.groupChatDetails!.groupId!,
userStatus: 0,
userEmail: "",
targetUserName: params!.groupChatDetails!.groupName!,
userList: params!.groupChatDetails!.groupUserList!),
)
.paddingOnly(right: 21),
],
).objectContainerView(disablePadding: true, radius: 0),
], ],
).objectContainerView(disablePadding: true, radius: 0), ));
],
));
}, },
), ),
), ),
@ -352,11 +346,11 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
} 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();
} }
} }
@ -373,22 +367,22 @@ class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
// "calltype": callType == "VIDEO" ? "Video" : "Audio", // "calltype": callType == "VIDEO" ? "Video" : "Audio",
// }; // };
logger.w(json); logger.w(json);
// CallDataModel callData = CallDataModel.fromJson(json); // CallDataModel callData = CallDataModel.fromJson(json);
// await Navigator.push( // await Navigator.push(
// context, // context,
// MaterialPageRoute( // MaterialPageRoute(
// builder: (BuildContext context) => OutGoingCall( // builder: (BuildContext context) => OutGoingCall(
// isVideoCall: callType == "VIDEO" ? true : false, // isVideoCall: callType == "VIDEO" ? true : false,
// outGoingCallData: callData, // outGoingCallData: callData,
// ), // ),
// ), // ),
// ).then((value) { // ).then((value) {
// print("then"); // print("then");
// callPro.stopListeners(); // callPro.stopListeners();
// }); // });
} }
GroupUserList getCurrentUser(int id, GroupResponse groupChatDetails) { GroupUserList getCurrentUser(int id, GroupResponse groupChatDetails) {
return groupChatDetails.groupUserList!.firstWhere((GroupUserList item) => item.id ==id); return groupChatDetails.groupUserList!.firstWhere((GroupUserList item) => item.id == id);
} }
} }

@ -184,7 +184,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
handleErmChannel(list); handleErmChannel(list);
} catch (ex) { } catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, context, null); // Utils.handleException(ex, context, null);
return; return;
} }
} }

@ -8,23 +8,25 @@ import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/widgets/bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheet.dart';
import 'package:mohem_flutter_app/widgets/bottom_sheets/attachment_options.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/attachment_options.dart';
import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; final ImagePicker picker = ImagePicker();
import 'package:permission_handler/permission_handler.dart';
class ImageOptions { class ImageOptions {
static void showImageOptionsNew(BuildContext context, bool showFilesOption, Function(String, File) image) { static void showImageOptionsNew(BuildContext context, bool showFilesOption, Function(String, File) image) {
showMyBottomSheet( showMyBottomSheet(
context, context,
callBackFunc: () {}, callBackFunc: () {},
child: AttachmentOptions( child: AttachmentOptions(
showFilesOption: showFilesOption, showFilesOption: showFilesOption,
onCameraTap: () async { onCameraTap: () async {
if (Platform.isAndroid) { if (Platform.isAndroid) {
cameraImageAndroid(image); cameraImageAndroid(image);
} else { } else {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? ""); File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? "");
String fileName = _image.path; // XFile? media = await picker.pickMedia();
var bytes = File(fileName).readAsBytesSync(); String? fileName = _image?.path;
var bytes = File(fileName!).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);
if (base64Encode != null) { if (base64Encode != null) {
image(base64Encode, _image); image(base64Encode, _image);
@ -35,7 +37,7 @@ class ImageOptions {
if (Platform.isAndroid) { if (Platform.isAndroid) {
galleryImageAndroid(image); galleryImageAndroid(image);
} else { } else {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? ""); File _image = File((await picker.pickMedia())?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);
@ -45,61 +47,24 @@ class ImageOptions {
} }
}, },
onFilesTap: () async { onFilesTap: () async {
Permission.storage.isGranted.then((isGranted) async { FilePickerResult? result = await FilePicker.platform.pickFiles(
if (!isGranted) { type: FileType.custom,
Permission.storage.request().then((granted) async { allowedExtensions: [
if (granted == PermissionStatus.granted) { 'jpg',
FilePickerResult? result = await FilePicker.platform.pickFiles( 'jpeg ',
type: FileType.custom, 'pdf',
allowedExtensions: [ 'txt',
'jpg', 'docx',
'jpeg ', 'doc',
'pdf', 'pptx',
'txt', 'xlsx',
'docx', 'png',
'doc', 'rar',
'pptx', 'zip',
'xlsx', ],
'png', );
'rar', List<File> files = result!.paths.map((path) => File(path!)).toList();
'zip', image(result.files.first.path.toString(), files.first);
],
);
List<File> files = result!.paths.map((path) => File(path!)).toList();
image(result.files.first.path.toString(), files.first);
} else {
showDialog(
context: context,
builder: (BuildContext cxt) => ConfirmDialog(
message: "You need to give storage permission to upload files.",
onTap: () {
Navigator.pop(context);
},
),
);
}
});
} else {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: [
'jpg',
'jpeg ',
'pdf',
'txt',
'docx',
'doc',
'pptx',
'xlsx',
'png',
'rar',
'zip',
],
);
List<File> files = result!.paths.map((path) => File(path!)).toList();
image(result.files.first.path.toString(), files.first);
}
});
}, },
), ),
); );
@ -165,7 +130,7 @@ class ImageOptions {
} }
void galleryImageAndroid(Function(String, File) image) async { void galleryImageAndroid(Function(String, File) image) async {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))?.path ?? ""); File _image = File((await picker.pickMedia())?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
@ -176,7 +141,7 @@ void galleryImageAndroid(Function(String, File) image) async {
} }
void cameraImageAndroid(Function(String, File) image) async { void cameraImageAndroid(Function(String, File) image) async {
File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))?.path ?? ""); File _image = File(( await picker.pickMedia())?.path ?? "");
String fileName = _image.path; String fileName = _image.path;
var bytes = File(fileName).readAsBytesSync(); var bytes = File(fileName).readAsBytesSync();
String base64Encode = base64.encode(bytes); String base64Encode = base64.encode(bytes);

Loading…
Cancel
Save