From ae559df29f07b036756db0d2953a715ba76223ed Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Mon, 12 Dec 2022 15:56:52 +0300 Subject: [PATCH] Chat Fixes & Counter Updated on Signal R --- lib/provider/chat_provider_model.dart | 7 +++++-- lib/ui/chat/chat_detailed_screen.dart | 6 ++---- lib/ui/chat/chat_home_screen.dart | 10 +++++++++- lib/widgets/chat_app_bar_widge.dart | 10 ++++++++-- pubspec.yaml | 1 + 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index 4263569..d3639c9 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -405,7 +405,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { if (user.id == parameters![1] && parameters[0] == true) { user.isTyping = parameters[0] as bool?; Future.delayed( - const Duration(seconds: 1), + const Duration(seconds: 2), () { user.isTyping = false; notifyListeners(); @@ -839,12 +839,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } - Future getChatMedia({required String fileName, required String fileTypeName, required int fileTypeID}) async { + Future getChatMedia(BuildContext context, {required String fileName, required String fileTypeName, required int fileTypeID}) async { + Utils.showLoading(context); if (fileTypeID == 1 || fileTypeID == 5 || fileTypeID == 7 || fileTypeID == 6 || fileTypeID == 8 || fileTypeID == 2) { Uint8List encodedString = await ChatApiClient().downloadURL(fileName: fileName, fileTypeDescription: getFileTypeDescription(fileTypeName)); try { String path = await downChatMedia(encodedString, fileTypeName ?? ""); + Utils.hideLoading(context); OpenFile.open(path); + } catch (e) { Utils.showToast("Cannot open file."); } diff --git a/lib/ui/chat/chat_detailed_screen.dart b/lib/ui/chat/chat_detailed_screen.dart index 619e850..15b2156 100644 --- a/lib/ui/chat/chat_detailed_screen.dart +++ b/lib/ui/chat/chat_detailed_screen.dart @@ -137,10 +137,8 @@ class _ChatDetailScreenState extends State { }, ).onPress(() async { if (m.userChatHistory[i].fileTypeResponse != null) { - m.getChatMedia( - fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", - fileTypeID: m.userChatHistory[i].fileTypeResponse!.fileTypeId!, - fileName: m.userChatHistory[i].contant!); + m.getChatMedia(context, + fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!); } }); }, diff --git a/lib/ui/chat/chat_home_screen.dart b/lib/ui/chat/chat_home_screen.dart index fe4291f..a9814ee 100644 --- a/lib/ui/chat/chat_home_screen.dart +++ b/lib/ui/chat/chat_home_screen.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -137,7 +138,14 @@ class _ChatHomeScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ (m.searchedChats![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), - (m.searchedChats![index].isTyping! ? "Typing ..." : "").toText10(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 0), + m.searchedChats![index].isTyping! + ? AnimatedTextKit( + animatedTexts: [ + ScaleAnimatedText('Typing...', textStyle: const TextStyle(color: MyColors.textMixColor, fontSize: 10, letterSpacing: -0.4, fontStyle: FontStyle.normal)), + ], + ).paddingOnly(left: 11) + : const SizedBox() + //(m.searchedChats![index].isTyping! ? "Typing ..." : "").toText10(color: MyColors.textMixColor).paddingOnly(left: 11, top: 0), ], ).expanded, SizedBox( diff --git a/lib/widgets/chat_app_bar_widge.dart b/lib/widgets/chat_app_bar_widge.dart index 3a9dee4..0feac6c 100644 --- a/lib/widgets/chat_app_bar_widge.dart +++ b/lib/widgets/chat_app_bar_widge.dart @@ -1,3 +1,4 @@ +import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; @@ -50,14 +51,19 @@ AppBar ChatAppBarWidget(BuildContext context, Consumer( builder: (BuildContext cxt, ChatProviderModel data, Widget? child) { if (chatUser!.isTyping!) { - return ("Typing ...").toText10(color: MyColors.darkTextColor); + // return ("Typing ...").toText10(color: MyColors.textMixColor); + return AnimatedTextKit( + animatedTexts: [ + ScaleAnimatedText('Typing...', textStyle: const TextStyle(color: MyColors.textMixColor, fontSize: 10, letterSpacing: -0.4, fontStyle: FontStyle.normal)), + ], + ); } else { return const SizedBox(); } }, ), ], - ).expanded, + ), ) ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 0d5cda5..2e3c4c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -92,6 +92,7 @@ dependencies: swipe_to: ^1.0.2 flutter_webrtc: ^0.9.16 camera: ^0.10.0+4 + animated_text_kit: ^4.2.2 #Encryption flutter_des: ^2.1.0