Merge branch 'development_aamir' into 'master'

Chat Search Api Update/ Fav Unfav/ Fixes

See merge request Cloud_Solution/mohemm-flutter-app!126
merge-requests/127/head
haroon amjad 3 years ago
commit d24fa6b61b

@ -46,15 +46,15 @@ class ChatApiClient {
return userLoginResponse; return userLoginResponse;
} }
Future<List<ChatUser>?> getChatMemberFromSearch(String sName, int cUserId) async { Future<ChatUserModel> getChatMemberFromSearch(String searchParam, int cUserId, int pageNo) async {
Response response = await ApiClient().getJsonForResponse( ChatUserModel chatUserModel;
"${ApiConsts.chatLoginTokenUrl}getUserWithStatusAndFavAsync/$sName/$cUserId", Response response = await ApiClient().postJsonForResponse("${ApiConsts.chatLoginTokenUrl}getUserWithStatusAndFavAsync", {"employeeNumber": cUserId, "userName": searchParam, "pageNumber": pageNo},
token: AppState().chatDetails!.response!.token, token: AppState().chatDetails!.response!.token);
);
if (!kReleaseMode) { if (!kReleaseMode) {
logger.i("res: " + response.body); logger.i("res: " + response.body);
} }
return List<ChatUser>.from(json.decode(response.body).map((x) => ChatUser.fromJson(x))); chatUserModel = chatUserModelFromJson(response.body);
return chatUserModel;
} }
//Get User Recent Chats //Get User Recent Chats

@ -1,5 +1,10 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
ChatUserModel chatUserModelFromJson(String str) => ChatUserModel.fromJson(json.decode(str));
String chatUserModelToJson(ChatUserModel data) => json.encode(data.toJson());
class ChatUserModel { class ChatUserModel {
ChatUserModel({ ChatUserModel({
this.response, this.response,
@ -7,16 +12,40 @@ class ChatUserModel {
}); });
List<ChatUser>? response; List<ChatUser>? response;
dynamic errorResponses; List<ErrorResponse>? errorResponses;
factory ChatUserModel.fromJson(Map<String, dynamic> json) => ChatUserModel( factory ChatUserModel.fromJson(Map<String, dynamic> json) => ChatUserModel(
response: json["response"] == null ? null : List<ChatUser>.from(json["response"].map((x) => ChatUser.fromJson(x))), response: json["response"] == null ? null : List<ChatUser>.from(json["response"].map((x) => ChatUser.fromJson(x))),
errorResponses: json["errorResponses"], errorResponses: json["errorResponses"] == null ? null : List<ErrorResponse>.from(json["errorResponses"].map((x) => ErrorResponse.fromJson(x))),
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"response": response == null ? null : List<dynamic>.from(response!.map((x) => x.toJson())), "response": response == null ? null : List<dynamic>.from(response!.map((x) => x.toJson())),
"errorResponses": errorResponses, "errorResponses": errorResponses == null ? null : List<dynamic>.from(errorResponses!.map((x) => x.toJson())),
};
}
class ErrorResponse {
ErrorResponse({
this.fieldName,
this.message,
});
dynamic? fieldName;
String? message;
factory ErrorResponse.fromRawJson(String str) => ErrorResponse.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory ErrorResponse.fromJson(Map<String, dynamic> json) => ErrorResponse(
fieldName: json["fieldName"],
message: json["message"] == null ? null : json["message"],
);
Map<String, dynamic> toJson() => {
"fieldName": fieldName,
"message": message == null ? null : message,
}; };
} }
@ -34,6 +63,8 @@ class ChatUser {
this.isPin, this.isPin,
this.isFav, this.isFav,
this.isAdmin, this.isAdmin,
this.rKey,
this.totalCount,
this.isTyping, this.isTyping,
this.isImageLoaded, this.isImageLoaded,
this.isImageLoading, this.isImageLoading,
@ -44,7 +75,7 @@ class ChatUser {
String? userName; String? userName;
String? email; String? email;
dynamic? phone; dynamic? phone;
dynamic? title; String? title;
int? userStatus; int? userStatus;
dynamic? image; dynamic? image;
int? unreadMessageCount; int? unreadMessageCount;
@ -52,17 +83,23 @@ class ChatUser {
bool? isPin; bool? isPin;
bool? isFav; bool? isFav;
bool? isAdmin; bool? isAdmin;
dynamic? rKey;
int? totalCount;
bool? isTyping; bool? isTyping;
bool? isImageLoaded; bool? isImageLoaded;
bool? isImageLoading; bool? isImageLoading;
File? userLocalDownlaodedImage; File? userLocalDownlaodedImage;
factory ChatUser.fromRawJson(String str) => ChatUser.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory ChatUser.fromJson(Map<String, dynamic> json) => ChatUser( factory ChatUser.fromJson(Map<String, dynamic> json) => ChatUser(
id: json["id"] == null ? null : json["id"], id: json["id"] == null ? null : json["id"],
userName: json["userName"] == null ? null : json["userName"], userName: json["userName"] == null ? null : json["userName"],
email: json["email"] == null ? null : json["email"], email: json["email"] == null ? null : json["email"],
phone: json["phone"], phone: json["phone"],
title: json["title"], title: json["title"] == null ? null : json["title"],
userStatus: json["userStatus"] == null ? null : json["userStatus"], userStatus: json["userStatus"] == null ? null : json["userStatus"],
image: json["image"], image: json["image"],
unreadMessageCount: json["unreadMessageCount"] == null ? null : json["unreadMessageCount"], unreadMessageCount: json["unreadMessageCount"] == null ? null : json["unreadMessageCount"],
@ -70,6 +107,8 @@ class ChatUser {
isPin: json["isPin"] == null ? null : json["isPin"], isPin: json["isPin"] == null ? null : json["isPin"],
isFav: json["isFav"] == null ? null : json["isFav"], isFav: json["isFav"] == null ? null : json["isFav"],
isAdmin: json["isAdmin"] == null ? null : json["isAdmin"], isAdmin: json["isAdmin"] == null ? null : json["isAdmin"],
rKey: json["rKey"],
totalCount: json["totalCount"] == null ? null : json["totalCount"],
isTyping: false, isTyping: false,
isImageLoaded: false, isImageLoaded: false,
isImageLoading: true, isImageLoading: true,
@ -80,7 +119,7 @@ class ChatUser {
"userName": userName == null ? null : userName, "userName": userName == null ? null : userName,
"email": email == null ? null : email, "email": email == null ? null : email,
"phone": phone, "phone": phone,
"title": title, "title": title == null ? null : title,
"userStatus": userStatus == null ? null : userStatus, "userStatus": userStatus == null ? null : userStatus,
"image": image, "image": image,
"unreadMessageCount": unreadMessageCount == null ? null : unreadMessageCount, "unreadMessageCount": unreadMessageCount == null ? null : unreadMessageCount,
@ -88,5 +127,7 @@ class ChatUser {
"isPin": isPin == null ? null : isPin, "isPin": isPin == null ? null : isPin,
"isFav": isFav == null ? null : isFav, "isFav": isFav == null ? null : isFav,
"isAdmin": isAdmin == null ? null : isAdmin, "isAdmin": isAdmin == null ? null : isAdmin,
"rKey": rKey,
"totalCount": totalCount == null ? null : totalCount,
}; };
} }

@ -69,6 +69,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
//Chat Home Page Counter //Chat Home Page Counter
int chatUConvCounter = 0; int chatUConvCounter = 0;
/// Search Provider
List<ChatUser>? chatUsersList = [];
int pageNo = 1;
Future<void> getUserAutoLoginToken() async { Future<void> getUserAutoLoginToken() async {
userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken();
if (userLoginResponse.response != null) { if (userLoginResponse.response != null) {
@ -172,7 +176,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (isNewChat) { if (isNewChat) {
userChatHistory = []; userChatHistory = [];
} else if (loadMore) { } else if (loadMore) {
Utils.showToast("No More Data To Load");
} }
} else { } else {
if (loadMore) { if (loadMore) {
@ -329,6 +333,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
user.userStatus = items.first["userStatus"]; user.userStatus = items.first["userStatus"];
} }
} }
if (teamMembersList != null) {
if (teamMembersList.isNotEmpty) {
for (ChatUser user in teamMembersList!) {
if (user.id == items.first["id"]) {
user.userStatus = items.first["userStatus"];
}
}
}
}
notifyListeners(); notifyListeners();
} }
@ -931,8 +945,26 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
} }
for (ChatUser user in chatUsersList!) {
if (user.id == favoriteChatUser.response!.targetUserId!) {
user.isFav = favoriteChatUser.response!.isFav;
dynamic contain = favUsersList!.where((ChatUser element) => element.id == favoriteChatUser.response!.targetUserId!);
if (contain.isEmpty) {
favUsersList.add(user);
}
}
}
}
for (ChatUser user in favUsersList) {
if (user.id == targetUserID) {
user.userLocalDownlaodedImage = null;
user.isImageLoading = false;
user.isImageLoaded = false;
}
} }
notifyListeners(); notifyListeners();
} }
Future<void> unFavoriteUser({required int userID, required int targetUserID}) async { Future<void> unFavoriteUser({required int userID, required int targetUserID}) async {
@ -949,6 +981,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
); );
} }
for (ChatUser user in chatUsersList!) {
if (user.id == favoriteChatUser.response!.targetUserId!) {
user.isFav = favoriteChatUser.response!.isFav;
}
}
notifyListeners(); notifyListeners();
} }
@ -1264,7 +1302,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
await Directory(dirPath).create(); await Directory(dirPath).create();
await File('$dirPath/.nomedia').create(); await File('$dirPath/.nomedia').create();
} }
File file = File("$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}" + ext); File file = File("$dirPath/${data.currentUserId}-${data.targetUserId}-${DateTime.now().microsecondsSinceEpoch}." + ext);
await file.writeAsBytes(bytes); await file.writeAsBytes(bytes);
return file.path; return file.path;
} }
@ -1288,50 +1326,64 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
teamMembersList = []; teamMembersList = [];
isLoading = true; isLoading = true;
if (AppState().getemployeeSubordinatesList.isNotEmpty) { if (AppState().getemployeeSubordinatesList.isNotEmpty) {
print("=============== In App State =====================");
getEmployeeSubordinatesList = AppState().getemployeeSubordinatesList; getEmployeeSubordinatesList = AppState().getemployeeSubordinatesList;
for (GetEmployeeSubordinatesList element in getEmployeeSubordinatesList) { for (GetEmployeeSubordinatesList element in getEmployeeSubordinatesList) {
print(element.eMPLOYEEEMAILADDRESS); if (element.eMPLOYEEEMAILADDRESS != null) {
teamMembersList.add( if (element.eMPLOYEEEMAILADDRESS!.isNotEmpty) {
ChatUser( teamMembersList.add(
id: int.parse(element.eMPLOYEENUMBER!), ChatUser(
email: element.eMPLOYEEEMAILADDRESS, id: int.parse(element.eMPLOYEENUMBER!),
userName: element.eMPLOYEENAME, email: element.eMPLOYEEEMAILADDRESS,
phone: element.eMPLOYEEMOBILENUMBER, userName: element.eMPLOYEENAME,
userStatus: 0, phone: element.eMPLOYEEMOBILENUMBER,
unreadMessageCount: 0, userStatus: 0,
isFav: false, unreadMessageCount: 0,
isTyping: false, isFav: false,
isImageLoading: false, isTyping: false,
image: element.eMPLOYEEIMAGE ?? "", isImageLoading: false,
isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true, image: element.eMPLOYEEIMAGE ?? "",
userLocalDownlaodedImage:element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true,
), userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!),
); ),
);
}
}
} }
} else { } else {
getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates("", "", ""); getEmployeeSubordinatesList = await MyTeamApiClient().getEmployeeSubordinates("", "", "");
AppState().setemployeeSubordinatesList = getEmployeeSubordinatesList; AppState().setemployeeSubordinatesList = getEmployeeSubordinatesList;
for (GetEmployeeSubordinatesList element in getEmployeeSubordinatesList) { for (GetEmployeeSubordinatesList element in getEmployeeSubordinatesList) {
print(element.eMPLOYEEEMAILADDRESS); if (element.eMPLOYEEEMAILADDRESS != null) {
teamMembersList.add( if (element.eMPLOYEEEMAILADDRESS!.isNotEmpty) {
ChatUser( teamMembersList.add(
id: int.parse(element.eMPLOYEENUMBER!), ChatUser(
email: element.eMPLOYEEEMAILADDRESS, id: int.parse(element.eMPLOYEENUMBER!),
userName: element.eMPLOYEENAME, email: element.eMPLOYEEEMAILADDRESS,
phone: element.eMPLOYEEMOBILENUMBER, userName: element.eMPLOYEENAME,
userStatus: 0, phone: element.eMPLOYEEMOBILENUMBER,
unreadMessageCount: 0, userStatus: 0,
isFav: false, unreadMessageCount: 0,
isTyping: false, isFav: false,
isImageLoading: false, isTyping: false,
image: element.eMPLOYEEIMAGE ?? "", isImageLoading: false,
isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true, image: element.eMPLOYEEIMAGE ?? "",
userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!), isImageLoaded: element.eMPLOYEEIMAGE == null ? false : true,
), userLocalDownlaodedImage: element.eMPLOYEEIMAGE == null ? null : await downloadImageLocal(element.eMPLOYEEIMAGE ?? "", element.eMPLOYEENUMBER!),
); ),
);
}
}
} }
} }
for (ChatUser user in searchedChats!) {
for (ChatUser teamUser in teamMembersList!) {
if (user.id == teamUser.id) {
teamUser.userStatus = user.userStatus;
}
}
}
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
} }

@ -238,6 +238,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
), ),
), ),
onPressed: () async { onPressed: () async {
print(AppState().chatDetails!.response!.token);
showMyBottomSheet( showMyBottomSheet(
context, context,
callBackFunc: () {}, callBackFunc: () {},

@ -84,24 +84,24 @@ class _MyTeamScreenState extends State<MyTeamScreen> {
), ),
), ),
), ),
// Positioned( Positioned(
// right: 5, right: 5,
// bottom: 1, bottom: 1,
// child: Container( child: Container(
// width: 10, width: 10,
// height: 10, height: 10,
// decoration: BoxDecoration( decoration: BoxDecoration(
// color: m.teamMembersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, color: m.teamMembersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red,
// ), ),
// ).circle(10), ).circle(10),
// ) )
], ],
), ),
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
(m.teamMembersList![index].userName! ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), (m.teamMembersList![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13),
], ],
).expanded, ).expanded,
// SizedBox( // SizedBox(

@ -20,10 +20,13 @@ import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
import 'package:mohem_flutter_app/models/get_action_history_list_model.dart'; import 'package:mohem_flutter_app/models/get_action_history_list_model.dart';
import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart'; import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart';
import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart'; import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart';
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart'; import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/circular_avatar.dart'; import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart'; import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class SearchEmployeeBottomSheet extends StatefulWidget { class SearchEmployeeBottomSheet extends StatefulWidget {
int? notificationID; int? notificationID;
@ -47,6 +50,8 @@ class SearchEmployeeBottomSheet extends StatefulWidget {
class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> { class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
TextEditingController username = TextEditingController(); TextEditingController username = TextEditingController();
ScrollController sc = ScrollController();
String searchText = ""; String searchText = "";
List<String>? optionsList = [ List<String>? optionsList = [
@ -61,7 +66,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
List<ReplacementList>? nonFavouriteUserList; List<ReplacementList>? nonFavouriteUserList;
// Chat Items // Chat Items
List<ChatUser>? chatUsersList = []; late ChatProviderModel provider;
int _selectedSearchIndex = 0; int _selectedSearchIndex = 0;
@ -88,25 +93,55 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
} }
void fetchChatUser({bool isNeedLoading = true}) async { void fetchChatUser({bool isNeedLoading = true}) async {
if (provider.pageNo == 1) provider.chatUsersList!.clear();
try { try {
Utils.showLoading(context); Utils.showLoading(context);
chatUsersList = await ChatApiClient().getChatMemberFromSearch( await ChatApiClient().getChatMemberFromSearch(searchText, AppState().chatDetails!.response!.id!, provider.pageNo).then((ChatUserModel value) {
searchText, if (value.response != null) {
int.parse(AppState().chatDetails!.response!.id.toString()), if (provider.pageNo == 1) {
); provider.chatUsersList = value.response;
chatUsersList!.removeWhere((ChatUser element) => element.id == AppState().chatDetails!.response!.id); } else {
print("--------------------------Added More----------------------");
provider.chatUsersList!.addAll(value.response!);
}
}
});
provider.chatUsersList!.removeWhere((ChatUser element) => element.id == AppState().chatDetails!.response!.id);
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (e) { } catch (e) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(e, context, null); Utils.handleException(e, context, null);
} }
if (isNeedLoading) Utils.hideLoading(context); if (isNeedLoading) Utils.hideLoading(context);
setState(() {}); setState(() {});
return null; return null;
} }
void scrollListener() async {
if (sc.position.pixels == sc.position.maxScrollExtent) {
provider.pageNo++;
logger.w(provider.chatUsersList!.length);
logger.w(provider.pageNo);
fetchChatUser();
}
}
@override
void initState() {
super.initState();
sc.addListener(scrollListener);
provider = Provider.of<ChatProviderModel>(context, listen: false);
}
@override
void dispose() {
print("// TODO: implement dispose");
super.dispose();
provider.chatUsersList = [];
provider.pageNo = 1;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
@ -123,7 +158,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
11.height, 11.height,
Row( Row(
children: [ children: [
radioOption("Name", 0, _selectedSearchIndex), radioOption(widget.fromChat ? "UserId" : "Name", 0, _selectedSearchIndex),
radioOption("User Name", 1, _selectedSearchIndex), radioOption("User Name", 1, _selectedSearchIndex),
radioOption("Email", 2, _selectedSearchIndex), radioOption("Email", 2, _selectedSearchIndex),
], ],
@ -188,73 +223,135 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
], ],
).expanded, ).expanded,
if (widget.fromChat) if (widget.fromChat)
if (chatUsersList != null && widget.fromChat) if (provider.chatUsersList != null && widget.fromChat)
chatUsersList!.isEmpty provider.chatUsersList!.isEmpty
? Column( ? Column(
children: [ children: [
20.height, 20.height,
Utils.getNoDataWidget(context), Utils.getNoDataWidget(context),
], ],
) )
: ListView( : ListView.separated(
physics: const BouncingScrollPhysics(), itemCount: provider.chatUsersList!.length,
padding: const EdgeInsets.only( shrinkWrap: true,
top: 15, physics: const ClampingScrollPhysics(),
), controller: sc,
children: <Widget>[ padding: const EdgeInsets.only(bottom: 80.0, top: 20),
ListView.separated( itemBuilder: (BuildContext context, int index) {
physics: const NeverScrollableScrollPhysics(), return SizedBox(
shrinkWrap: true, height: 55,
itemBuilder: (BuildContext cxt, int index) { child: Row(
return SizedBox( children: [
height: 55, Stack(
child: ListTile( children: <Widget>[
leading: Stack( SvgPicture.asset(
children: [
SvgPicture.asset(
"assets/images/user.svg", "assets/images/user.svg",
height: 48, height: 48,
width: 48, width: 48,
), ),
Positioned( Positioned(
right: 5, right: 5,
bottom: 1, bottom: 1,
child: Container( child: Container(
width: 10, width: 10,
height: 10, height: 10,
decoration: BoxDecoration( decoration: BoxDecoration(
color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, color: provider.chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red,
borderRadius: const BorderRadius.all( ),
Radius.circular(10), ).circle(10),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(provider.chatUsersList![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "")
.toText14(color: MyColors.darkTextColor)
.paddingOnly(left: 11, top: 13),
provider.chatUsersList![index].isTyping!
? 'Typing...'
.toText10(
color: MyColors.textMixColor,
)
.paddingOnly(left: 11.0)
: const SizedBox()
],
).expanded,
SizedBox(
width: 60,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
if (provider.chatUsersList![index].unreadMessageCount! > 0)
Container(
alignment: Alignment.center,
width: 18,
height: 18,
decoration: const BoxDecoration(
color: MyColors.redColor,
borderRadius: BorderRadius.all(
Radius.circular(20),
), ),
), ),
), child: (provider.chatUsersList![index].unreadMessageCount!.toString())
) .toText10(
color: MyColors.white,
)
.center,
).paddingOnly(right: 10).center,
Icon(
provider.chatUsersList![index].isFav != null && provider.chatUsersList![index].isFav == false ? Icons.star_sharp : Icons.star_sharp,
color: provider.chatUsersList![index].isFav != null && provider.chatUsersList![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color,
).onPress(
() {
if (provider.chatUsersList![index].isFav == null || provider.chatUsersList![index].isFav == false) {
provider
.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: provider.chatUsersList![index].id!,
)
.then((value) {
setState(() {});
});
} else if (provider.chatUsersList![index].isFav == true) {
provider
.unFavoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: provider.chatUsersList![index].id!,
)
.then((value) {
setState(() {});
});
} else {
provider
.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: provider.chatUsersList![index].id!,
)
.then((value) {
setState(() {});
});
}
},
).center
], ],
), ),
title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor),
minVerticalPadding: 0,
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(
context,
AppRoutes.chatDetailed,
arguments: ChatDetailedScreenParams(chatUsersList![index], true),
);
},
), ),
); ],
},
separatorBuilder: (BuildContext context, int index) => const Padding(
padding: EdgeInsets.only(right: 10, left: 70, bottom: 0, top: 0),
child: Divider(
color: Color(0xFFE5E5E5),
),
), ),
itemCount: chatUsersList?.length ?? 0, ).onPress(() {
), Navigator.pop(context);
12.height, Navigator.pushNamed(
], context,
AppRoutes.chatDetailed,
arguments: ChatDetailedScreenParams(provider.chatUsersList![index], true),
);
});
},
separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59),
).expanded, ).expanded,
], ],
).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded,
@ -263,6 +360,8 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
LocaleKeys.cancel.tr(), LocaleKeys.cancel.tr(),
() { () {
Navigator.pop(context); Navigator.pop(context);
provider.chatUsersList = [];
provider.pageNo = 1;
}, },
textColor: MyColors.grey3AColor, textColor: MyColors.grey3AColor,
colors: const [ colors: const [

@ -273,7 +273,7 @@ class ChatHomeShimmer extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Container( Container(
width: double.infinity, width: double.infinity,
height: 8.0, height: 20.0,
color: Colors.white, color: Colors.white,
), ),
const Padding( const Padding(
@ -281,7 +281,7 @@ class ChatHomeShimmer extends StatelessWidget {
), ),
Container( Container(
width: double.infinity, width: double.infinity,
height: 8.0, height: 15.0,
color: Colors.white, color: Colors.white,
), ),
const Padding( const Padding(
@ -289,7 +289,7 @@ class ChatHomeShimmer extends StatelessWidget {
), ),
Container( Container(
width: 40.0, width: 40.0,
height: 8.0, height: 10.0,
color: Colors.white, color: Colors.white,
), ),
], ],

Loading…
Cancel
Save