Chat Fixes & Chat Media Preview Api Implementation / On Msg Received Image

merge-requests/75/head
Aamir Muhammad 3 years ago
parent 5430fd2d32
commit 3309541142

@ -292,16 +292,21 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
data.first.currentUserId = temp.first.targetUserId;
data.first.currentUserName = temp.first.targetUserName;
if (data.first.fileTypeId == 12 || data.first.fileTypeId == 4 || data.first.fileTypeId == 3) {
data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription);
data.first.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg");
}
if (data.first.userChatReplyResponse != null) {
if (data.first.userChatReplyResponse!.fileTypeId == 12 || data.first.userChatReplyResponse!.fileTypeId == 4 || data.first.userChatReplyResponse!.fileTypeId == 3) {
data.first.userChatReplyResponse!.image = await ChatApiClient().downloadURL(fileName: data.first.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription);
data.first.userChatReplyResponse!.isImageLoaded = true;
if (data.first.fileTypeResponse != null) {
if (data.first.userChatReplyResponse!.fileTypeId == 12 || data.first.userChatReplyResponse!.fileTypeId == 4 || data.first.userChatReplyResponse!.fileTypeId == 3) {
data.first.userChatReplyResponse!.image =
await ChatApiClient().downloadURL(fileName: data.first.userChatReplyResponse!.contant!, fileTypeDescription: data.first.fileTypeResponse!.fileTypeDescription ?? "image/jpg");
data.first.userChatReplyResponse!.isImageLoaded = true;
}
}
}
}
userChatHistory.insert(0, data.first);
var list = [
{
"userChatHistoryId": data.first.userChatHistoryId,
@ -310,7 +315,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
"isSeen": isChatScreenActive ? true : false,
}
];
updateUserChatHistoryStatusAsync(list);
notifyListeners();
}
@ -666,22 +673,22 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
sFileType = "";
}
// void scrollListener() {
// _firstAutoscrollExecuted = true;
// if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) {
// _shouldAutoscroll = true;
// } else {
// _shouldAutoscroll = false;
// }
// }
//
// void scrollToBottom() {
// scrollController.animateTo(
// scrollController.position.maxScrollExtent + 100,
// duration: const Duration(milliseconds: 500),
// curve: Curves.easeIn,
// );
// }
// void scrollListener() {
// _firstAutoscrollExecuted = true;
// if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) {
// _shouldAutoscroll = true;
// } else {
// _shouldAutoscroll = false;
// }
// }
//
// void scrollToBottom() {
// scrollController.animateTo(
// scrollController.position.maxScrollExtent + 100,
// duration: const Duration(milliseconds: 500),
// curve: Curves.easeIn,
// );
// }
void msgScroll() {
scrollController.animateTo(

@ -10,6 +10,8 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart';
import 'package:mohem_flutter_app/widgets/bottom_sheet.dart';
// todo: @aamir use extension methods, and use correct widgets.
@ -87,7 +89,9 @@ class ChatBubble extends StatelessWidget {
),
).paddingOnly(right: 5, bottom: 7),
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription).paddingOnly(right: 5),
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription).paddingOnly(right: 5).onPress(() {
showDialog(context: context, builder: (index) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
}),
cItem.contant!.toText12(),
Align(
alignment: Alignment.centerRight,
@ -160,7 +164,9 @@ class ChatBubble extends StatelessWidget {
),
).paddingOnly(right: 5, bottom: 7),
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription).paddingOnly(right: 5)
showImage(isReplyPreview: false, fileName: cItem.contant!, fileTypeDescription: cItem.fileTypeResponse!.fileTypeDescription ?? "image/jpg").paddingOnly(right: 5).onPress(() {
showDialog(context: context, builder: (index) => ChatImagePreviewScreen(imgTitle: cItem.contant!, img: cItem.image!));
})
else
(cItem.contant! ?? "").toText12(color: Colors.white),
Align(
@ -188,7 +194,7 @@ class ChatBubble extends StatelessWidget {
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState != ConnectionState.waiting) {
if (snapshot.data == null) {
return (cItem.contant.toString()).toText12();
return SizedBox();
} else {
//data = image;
cItem.image = snapshot.data;

@ -0,0 +1,40 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
class ChatImagePreviewScreen extends StatelessWidget {
const ChatImagePreviewScreen({Key? key, required this.imgTitle, required this.img}) : super(key: key);
final String imgTitle;
final Uint8List img;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Dialog(
backgroundColor: Colors.transparent,
insetPadding: const EdgeInsets.all(10),
child: Stack(
alignment: Alignment.center,
children: [
Image.memory(
img,
fit: BoxFit.cover,
).paddingAll(10),
const Positioned(
right: 0,
top: 0,
child: Icon(Icons.cancel, color: MyColors.redA3Color, size: 35),
)
],
),
),
);
}
}
Loading…
Cancel
Save