|
|
|
@ -24,6 +24,7 @@ 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:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class SearchEmployeeBottomSheet extends StatefulWidget {
|
|
|
|
class SearchEmployeeBottomSheet extends StatefulWidget {
|
|
|
|
int? notificationID;
|
|
|
|
int? notificationID;
|
|
|
|
@ -47,6 +48,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 = [
|
|
|
|
@ -62,6 +65,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
|
|
|
|
|
|
|
|
// Chat Items
|
|
|
|
// Chat Items
|
|
|
|
List<ChatUser>? chatUsersList = [];
|
|
|
|
List<ChatUser>? chatUsersList = [];
|
|
|
|
|
|
|
|
int pageNo = 1;
|
|
|
|
|
|
|
|
|
|
|
|
int _selectedSearchIndex = 0;
|
|
|
|
int _selectedSearchIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
@ -88,12 +92,16 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fetchChatUser({bool isNeedLoading = true}) async {
|
|
|
|
void fetchChatUser({bool isNeedLoading = true}) async {
|
|
|
|
|
|
|
|
if (pageNo == 1)
|
|
|
|
|
|
|
|
chatUsersList = [];
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
chatUsersList = await ChatApiClient().getChatMemberFromSearch(
|
|
|
|
await ChatApiClient().getChatMemberFromSearch(searchText, AppState().chatDetails!.response!.id!, pageNo).then((ChatUserModel value) {
|
|
|
|
searchText,
|
|
|
|
print(value.response!.length);
|
|
|
|
int.parse(AppState().chatDetails!.response!.id.toString()),
|
|
|
|
if (value.response != null) {
|
|
|
|
);
|
|
|
|
chatUsersList = value.response;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
chatUsersList!.removeWhere((ChatUser element) => element.id == AppState().chatDetails!.response!.id);
|
|
|
|
chatUsersList!.removeWhere((ChatUser element) => element.id == AppState().chatDetails!.response!.id);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
@ -107,11 +115,41 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void loadMoreChatUsers() async {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await ChatApiClient().getChatMemberFromSearch(searchText, AppState().chatDetails!.response!.id!, pageNo).then((ChatUserModel value) {
|
|
|
|
|
|
|
|
if (value.response != null) {
|
|
|
|
|
|
|
|
chatUsersList!.addAll(value.response!);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
chatUsersList!.removeWhere((ChatUser element) => element.id == AppState().chatDetails!.response!.id);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
Utils.handleException(e, context, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void scrollListener() async {
|
|
|
|
|
|
|
|
if (sc.position.pixels ==
|
|
|
|
|
|
|
|
sc.position.maxScrollExtent) {
|
|
|
|
|
|
|
|
pageNo++;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
sc.addListener(scrollListener);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SizedBox(
|
|
|
|
return SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
width: double.infinity,
|
|
|
|
height: MediaQuery.of(context).size.height - 100,
|
|
|
|
height: MediaQuery
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.size
|
|
|
|
|
|
|
|
.height - 100,
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
@ -153,7 +191,9 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
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),
|
|
|
|
@ -165,7 +205,8 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -179,7 +220,8 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -196,14 +238,10 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
Utils.getNoDataWidget(context),
|
|
|
|
Utils.getNoDataWidget(context),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: ListView(
|
|
|
|
: ListView
|
|
|
|
physics: const BouncingScrollPhysics(),
|
|
|
|
.separated(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
|
|
top: 15,
|
|
|
|
controller: sc,
|
|
|
|
),
|
|
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
|
|
ListView.separated(
|
|
|
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
shrinkWrap: true,
|
|
|
|
itemBuilder: (BuildContext cxt, int index) {
|
|
|
|
itemBuilder: (BuildContext cxt, int index) {
|
|
|
|
return SizedBox(
|
|
|
|
return SizedBox(
|
|
|
|
@ -245,19 +283,20 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
separatorBuilder: (BuildContext context, int index) => const Padding(
|
|
|
|
separatorBuilder: (BuildContext context, int index) =>
|
|
|
|
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.only(right: 10, left: 70, bottom: 0, top: 0),
|
|
|
|
padding: EdgeInsets.only(right: 10, left: 70, bottom: 0, top: 0),
|
|
|
|
child: Divider(
|
|
|
|
child: Divider(
|
|
|
|
color: Color(0xFFE5E5E5),
|
|
|
|
color: Color(0xFFE5E5E5),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
itemCount: chatUsersList?.length ?? 0,
|
|
|
|
itemCount: chatUsersList?.length ?? 0,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
12.height,
|
|
|
|
.expanded,
|
|
|
|
],
|
|
|
|
|
|
|
|
).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(),
|
|
|
|
@ -335,4 +374,4 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
}).expanded;
|
|
|
|
}).expanded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|