Chat Search User Api Implementation

merge-requests/22/head
Aamir Muhammad 3 years ago
parent a623765510
commit 90b60ce55a

@ -88,13 +88,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
void fetchChatUser({bool isNeedLoading = true}) async { void fetchChatUser({bool isNeedLoading = true}) async {
try { try {
Utils.showLoading(context); Utils.showLoading(context);
chatUsersList = await ChatProviderModel().getChatMemberFromSearch(searchText, int.parse(AppState().chatDetails!.response!.id.toString())); chatUsersList = await ChatProviderModel().getChatMemberFromSearch(searchText, int.parse(AppState().chatDetails!.response!.id.toString()));
print("================================");
print(jsonEncode(chatUsersList));
//
// favouriteUserList = replacementList?.where((element) => element.isFavorite ?? false).toList();
// nonFavouriteUserList = replacementList?.where((element) => !(element.isFavorite ?? false)).toList();
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (e) { } catch (e) {
@ -150,106 +144,102 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
icon: Icon(Icons.search)) icon: Icon(Icons.search))
], ],
), ),
if (replacementList != null) if (replacementList != null)
replacementList!.isEmpty replacementList!.isEmpty
? Utils.getNoDataWidget(context).expanded ? Utils.getNoDataWidget(context).expanded
: ListView( : ListView(
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
padding: EdgeInsets.only(top: 21, bottom: 8), padding: EdgeInsets.only(top: 21, bottom: 8),
children: [ children: [
if (favouriteUserList?.isNotEmpty ?? false) ...[ if (favouriteUserList?.isNotEmpty ?? false) ...[
"Favorites".toText16(), "Favorites".toText16(),
12.height, 12.height,
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (cxt, index) => employeeItemView(favouriteUserList![index]), itemBuilder: (cxt, index) => employeeItemView(favouriteUserList![index]),
separatorBuilder: (cxt, index) => Container( separatorBuilder: (cxt, index) => Container(
height: 1, height: 1,
color: MyColors.borderE3Color, color: MyColors.borderE3Color,
), ),
itemCount: favouriteUserList?.length ?? 0), itemCount: favouriteUserList?.length ?? 0),
12.height, 12.height,
], ],
if (nonFavouriteUserList?.isNotEmpty ?? false) ...[ if (nonFavouriteUserList?.isNotEmpty ?? false) ...[
"Related".toText16(), "Related".toText16(),
12.height, 12.height,
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (cxt, index) => employeeItemView(nonFavouriteUserList![index]), itemBuilder: (cxt, index) => employeeItemView(nonFavouriteUserList![index]),
separatorBuilder: (cxt, index) => Container( separatorBuilder: (cxt, index) => Container(
height: 1, height: 1,
color: MyColors.borderE3Color, color: MyColors.borderE3Color,
), ),
itemCount: nonFavouriteUserList?.length ?? 0), itemCount: nonFavouriteUserList?.length ?? 0),
] ]
], ],
).expanded, ).expanded,
if (widget.fromChat)
if(widget.fromChat)
if (chatUsersList != null && widget.fromChat) if (chatUsersList != null && widget.fromChat)
chatUsersList!.isEmpty chatUsersList!.isEmpty
? Utils.getNoDataWidget(context) ? Utils.getNoDataWidget(context)
: ListView( : ListView(
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
padding: EdgeInsets.only(top: 0, bottom: 8), padding: EdgeInsets.only(top: 0, bottom: 8),
children: [ children: [
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (cxt, index) {
itemBuilder: (cxt, index) { return ListTile(
return ListTile( leading: Stack(
leading: Stack( children: [
children: [ SvgPicture.asset(
SvgPicture.asset( "assets/images/user.svg",
"assets/images/user.svg", height: 48,
height: 48, width: 48,
width: 48,
),
Positioned(
right: 5,
bottom: 1,
child: Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red,
borderRadius: const BorderRadius.all(
Radius.circular(10),
), ),
), Positioned(
right: 5,
bottom: 1,
child: Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: chatUsersList![index].userStatus == 1 ? MyColors.green2DColor : Colors.red,
borderRadius: const BorderRadius.all(
Radius.circular(10),
),
),
),
)
],
), ),
) title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor),
], subtitle: (chatUsersList![index].isTyping == true ? "Something is Typing" : "Last message text").toText11(color: MyColors.normalTextColor),
), trailing: ("Today").toText10(color: MyColors.lightTextColor),
title: (chatUsersList![index].userName ?? "").toText14(color: MyColors.darkTextColor), minVerticalPadding: 0,
subtitle: (chatUsersList![index].isTyping == true ? "Something is Typing" : "Last message text").toText11(color: MyColors.normalTextColor), onTap: () {
trailing: ("Today").toText10(color: MyColors.lightTextColor), Navigator.pop(context);
minVerticalPadding: 0, Navigator.pushNamed(
onTap: () { context,
Navigator.pop(context); AppRoutes.chatDetailed,
Navigator.pushNamed( arguments: {"targetUser": chatUsersList![index]},
context, );
AppRoutes.chatDetailed, },
arguments: {"targetUser": chatUsersList![index]}, );
); },
}, separatorBuilder: (cxt, index) => Container(
); height: 1,
}, color: MyColors.borderE3Color,
separatorBuilder: (cxt, index) => Container( ),
height: 1, itemCount: chatUsersList?.length ?? 0),
color: MyColors.borderE3Color, 12.height,
), ],
itemCount: chatUsersList?.length ?? 0), ).expanded,
12.height,
],
).expanded,
], ],
).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded,
Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor), Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor),
DefaultButton( DefaultButton(
LocaleKeys.cancel.tr(), LocaleKeys.cancel.tr(),

Loading…
Cancel
Save