Merge branch 'master' into development_haroon

merge-requests/24/head
haroon amjad 3 years ago
commit 27ac98539f

@ -35,17 +35,19 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
await buildHubConnection(); await buildHubConnection();
} }
void getChatMemberFromSearch(String sName, int cUserId) async { Future<List<ChatUser>?> getChatMemberFromSearch(String sName, int cUserId) async {
isLoading = true;
notifyListeners();
Response response = await ApiClient().getJsonForResponse( Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatSearchMember}$sName/$cUserId", "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSearchMember}$sName/$cUserId",
token: AppState().chatDetails!.response!.token, token: AppState().chatDetails!.response!.token,
); );
return searchUserJsonModel(response.body);
logger.d(response.body);
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
} }
List<ChatUser> searchUserJsonModel(String str) => List<ChatUser>.from(json.decode(str).map((x) => ChatUser.fromJson(x)));
void getUserRecentChats() async { void getUserRecentChats() async {
Response response = await ApiClient().getJsonForResponse( Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}", "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}",
@ -64,13 +66,18 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$pagination", "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$pagination",
token: AppState().chatDetails!.response!.token, token: AppState().chatDetails!.response!.token,
); );
logger.d(response.body); logger.d(response.statusCode);
userChatHistory = getSingleUserChatintoModel(response.body); print(response.body);
if (response.statusCode == 204) {
userChatHistory = [];
} else {
userChatHistory = getSingleUserChatModel(response.body);
}
isLoading = false; isLoading = false;
notifyListeners(); notifyListeners();
} }
List<SingleUserChatModel> getSingleUserChatintoModel(String str) => List<SingleUserChatModel>.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); List<SingleUserChatModel> getSingleUserChatModel(String str) => List<SingleUserChatModel>.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x)));
ChatUserModel userToList(String str) => ChatUserModel.fromJson(json.decode(str)); ChatUserModel userToList(String str) => ChatUserModel.fromJson(json.decode(str));
@ -79,7 +86,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
hubConnection = await HubConnectionBuilder() hubConnection = await HubConnectionBuilder()
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp)
.withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]) .withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000])
.configureLogging(Logger("Logs Enabled")) .configureLogging(
Logger("Logs Enabled"),
)
.build(); .build();
hubConnection.onclose( hubConnection.onclose(
({Exception? error}) { ({Exception? error}) {
@ -159,7 +168,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
// print("================= Status Online // Offline ===================="); // print("================= Status Online // Offline ====================");
List items = args!.toList(); List items = args!.toList();
logger.d(items); logger.d(items);
for (var user in searchedChats!) { for (ChatUser user in searchedChats!) {
if (user.id == items.first["id"]) { if (user.id == items.first["id"]) {
user.userStatus = items.first["userStatus"]; user.userStatus = items.first["userStatus"];
} }
@ -172,7 +181,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (value.isEmpty || value == "") { if (value.isEmpty || value == "") {
tmp = pChatHistory; tmp = pChatHistory;
} else { } else {
for (var element in pChatHistory!) { for (ChatUser element in pChatHistory!) {
if (element.userName!.toLowerCase().contains(value.toLowerCase())) { if (element.userName!.toLowerCase().contains(value.toLowerCase())) {
tmp.add(element); tmp.add(element);
} }
@ -185,7 +194,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
Future<void> onMsgReceived(List<Object?>? parameters) async { Future<void> onMsgReceived(List<Object?>? parameters) async {
List<SingleUserChatModel> data = []; List<SingleUserChatModel> data = [];
for (dynamic msg in parameters!) { for (dynamic msg in parameters!) {
data = getSingleUserChatintoModel(jsonEncode(msg)); data = getSingleUserChatModel(jsonEncode(msg));
logger.d(msg); logger.d(msg);
} }
userChatHistory.add(data.first); userChatHistory.add(data.first);

@ -433,6 +433,7 @@ class _AddVacationRuleScreenState extends State<AddVacationRuleScreen> {
child: SearchEmployeeBottomSheet( child: SearchEmployeeBottomSheet(
title: LocaleKeys.searchForEmployee.tr(), title: LocaleKeys.searchForEmployee.tr(),
apiMode: LocaleKeys.delegate.tr(), apiMode: LocaleKeys.delegate.tr(),
fromChat: false,
onSelectEmployee: (_selectedEmployee) { onSelectEmployee: (_selectedEmployee) {
// Navigator.pop(context); // Navigator.pop(context);
selectedReplacementEmployee = _selectedEmployee; selectedReplacementEmployee = _selectedEmployee;

@ -163,6 +163,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
child: SearchEmployeeBottomSheet( child: SearchEmployeeBottomSheet(
title: LocaleKeys.searchForEmployee.tr(), title: LocaleKeys.searchForEmployee.tr(),
apiMode: LocaleKeys.delegate.tr(), apiMode: LocaleKeys.delegate.tr(),
fromChat: true,
onSelectEmployee: (_selectedEmployee) { onSelectEmployee: (_selectedEmployee) {
// Navigator.pop(context); // Navigator.pop(context);
// selectedReplacementEmployee = _selectedEmployee; // selectedReplacementEmployee = _selectedEmployee;

@ -49,7 +49,6 @@ class ServicesWidget extends StatelessWidget {
padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemBuilder: (cxt, index) { itemBuilder: (cxt, index) {
return AspectRatio( return AspectRatio(
aspectRatio: 105 / 105, aspectRatio: 105 / 105,
child: data.isServicesMenusLoading child: data.isServicesMenusLoading
@ -77,11 +76,7 @@ class ServicesWidget extends StatelessWidget {
Expanded( Expanded(
child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText10(isBold: true), child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText10(isBold: true),
), ),
RotatedBox( RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)),
quarterTurns: AppState().isArabic(context) ? 2:4,
child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)
),
], ],
) )
], ],
@ -119,7 +114,7 @@ class ServicesWidget extends StatelessWidget {
Navigator.of(context).pushNamed(AppRoutes.profile); Navigator.of(context).pushNamed(AppRoutes.profile);
return; return;
} }
List<GetMenuEntriesList> menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; List<GetMenuEntriesList> menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION")).toList() ?? [];
menuEntry.icon = ""; menuEntry.icon = "";
if (menuList.isEmpty) { if (menuList.isEmpty) {
if (menuEntry.requestType == "EIT") { if (menuEntry.requestType == "EIT") {
@ -128,7 +123,9 @@ class ServicesWidget extends StatelessWidget {
Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); Navigator.pushNamed(context, AppRoutes.monthlyPaySlip);
} }
} else { } else {
Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, menuList)); List<GetMenuEntriesList> _menuList =
pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? [];
Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList));
} }
return; return;
} }

@ -224,6 +224,7 @@ class _AddLeaveBalanceScreenState extends State<AddLeaveBalanceScreen> {
child: SearchEmployeeBottomSheet( child: SearchEmployeeBottomSheet(
title: LocaleKeys.searchForEmployee.tr(), title: LocaleKeys.searchForEmployee.tr(),
apiMode: LocaleKeys.delegate.tr(), apiMode: LocaleKeys.delegate.tr(),
fromChat: false,
onSelectEmployee: (_selectedEmployee) { onSelectEmployee: (_selectedEmployee) {
// Navigator.pop(context); // Navigator.pop(context);
selectedReplacementEmployee = _selectedEmployee; selectedReplacementEmployee = _selectedEmployee;

@ -93,95 +93,77 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
} }
void getData() async { void getData() async {
try { // try {
Utils.showLoading(context); // Utils.showLoading(context);
if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") { if (workListData!.iTEMTYPE == "HRSSA" || workListData!.iTEMTYPE == "STAMP") {
memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); getUserInformation();
} }
if (workListData!.iTEMTYPE == "HRSSA") { if (workListData!.iTEMTYPE == "HRSSA") {
if (workListData!.rEQUESTTYPE == "EIT") { if (workListData!.rEQUESTTYPE == "EIT") {
getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); getEitNotificationBody();
} else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") { } else if (workListData!.rEQUESTTYPE == "PHONE_NUMBERS") {
getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID); getPhonesNotificationBody();
} else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") { } else if (workListData!.rEQUESTTYPE == "BASIC_DETAILS") {
getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID); getBasicDetNtfBody();
} else if (workListData!.rEQUESTTYPE == "ABSENCE") { } else if (workListData!.rEQUESTTYPE == "ABSENCE") {
getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); getAbsenceNotificationBody();
} else if (workListData!.rEQUESTTYPE == "CONTACT") { } else if (workListData!.rEQUESTTYPE == "CONTACT") {
getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID); getContactNotificationBody();
} }
// getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999); // getBasicNTFBody = await WorkListApiClient().getBasicDetNTFBody(workListData!.nOTIFICATIONID!, -999);
// getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999); // getAbsenceCollectionNotifications = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID!, -999);
// subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", ""); // subordinatesLeavesModel = await WorkListApiClient().getSubordinatesLeaves("", "");
} }
if (workListData!.iTEMTYPE == "STAMP") { if (workListData!.iTEMTYPE == "STAMP") {
if (workListData!.rEQUESTTYPE == "STAMP_MS") { getStampNotificationBody();
getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999);
} else {
getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999);
}
} }
if (workListData!.iTEMTYPE == "INVMOA") { if (workListData!.iTEMTYPE == "INVMOA") {
getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999); getMoNotificationBody();
} }
if (workListData!.iTEMTYPE == "INVITEM") { if (workListData!.iTEMTYPE == "INVITEM") {
getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999); getItemCreationNtf();
} }
if (workListData!.iTEMTYPE == "POAPPRV") { if (workListData!.iTEMTYPE == "POAPPRV") {
getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999); getPoNotification();
} }
if (workListData!.iTEMTYPE == "REQAPPRV") { if (workListData!.iTEMTYPE == "REQAPPRV") {
getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999); getPRNotification();
} }
getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!);
if (getNotificationRespondAttributes.isNotEmpty) {
notificationNoteInput = getNotificationRespondAttributes.first;
}
List dataToFetch = await Future.wait([
WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!),
WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!),
WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!),
]);
notificationButtonsList = dataToFetch[0]; notificationGetRespondAttributes();
actionHistoryList = dataToFetch[1];
getAttachmentList = dataToFetch[2];
// List<Future> futureRequest = []; // List dataToFetch = await Future.wait([
// List<Object> futureObject = []; //
// WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!),
// WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!),
// ]);
// //
// addRequestInFuture(notificationButtonsList, WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!)); // notificationButtonsList = dataToFetch[0];
// addRequestInFuture(actionHistoryList, WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!)); // actionHistoryList = dataToFetch[1];
// addRequestInFuture(getAttachmentList, WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!)); // getAttachmentList = dataToFetch[2];
// List dataToFetch = await Future.wait(futureRequest); getNotificationButtons();
// for(int i=0;i<dataToFetch.length;i++) { getActionHistory();
// futureObject[i] = dataToFetch[i]; getAttachments();
// }
if (notificationButtonsList.isNotEmpty) { // if (notificationButtonsList.isNotEmpty) {
isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE"); // isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE");
isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED"); // isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED");
isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED"); // isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED");
} // }
Utils.hideLoading(context); // Utils.hideLoading(context);
setState(() {}); // setState(() {});
} catch (ex) { // } catch (ex) {
Utils.hideLoading(context); // Utils.hideLoading(context);
Utils.handleException(ex, context, null); // Utils.handleException(ex, context, null);
setState(() {}); // setState(() {});
} // }
} }
List<Future> futureRequest = []; List<Future> futureRequest = [];
List<Object> futureObject = []; List<Object> futureObject = [];
void addRequestInFuture(data, request) { int apiCallCount = 0;
futureObject.add(data);
futureRequest.add(request);
}
void getDataFromState() { void getDataFromState() {
if (workListData == null) { if (workListData == null) {
@ -489,9 +471,7 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
child: isIconAsset child: isIconAsset
? SvgPicture.asset(icon) ? SvgPicture.asset(icon)
: Image.memory( : Image.memory(
Utils.dataFromBase64String( Utils.dataFromBase64String(icon),
icon,
),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
) )
@ -508,7 +488,7 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
notificationGetRespond: notificationNoteInput, notificationGetRespond: notificationNoteInput,
textEditingController: textEditingController, textEditingController: textEditingController,
onTap: (note) { onTap: (note) {
if(note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) { if (note.isNotEmpty && (actionMode == "APPROVED" || actionMode == "APPROVE")) {
Map<String, dynamic> payload = { Map<String, dynamic> payload = {
"P_ACTION_MODE": actionMode, "P_ACTION_MODE": actionMode,
"P_APPROVER_INDEX": null, "P_APPROVER_INDEX": null,
@ -544,4 +524,271 @@ class _WorkListDetailScreenState extends State<WorkListDetailScreen> {
Utils.handleException(ex, context, null); Utils.handleException(ex, context, null);
} }
} }
void getEitNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getUserInformation() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getPhonesNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getPhonesNotificationBodyList = await WorkListApiClient().getPhonesNotificationBodyList(workListData!.nOTIFICATIONID);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getBasicDetNtfBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getBasicDetNtfBodyList = await WorkListApiClient().getBasicDetNtfBodyList(workListData!.nOTIFICATIONID);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getAbsenceNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getContactNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getContactNotificationBodyList = await WorkListApiClient().getContactNotificationBodyList(workListData!.nOTIFICATIONID);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getStampNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
if (workListData!.rEQUESTTYPE == "STAMP_MS") {
getStampMsNotifications = await WorkListApiClient().getStampMsNotificationBody(workListData!.nOTIFICATIONID!, -999);
} else {
getStampNsNotifications = await WorkListApiClient().getStampNsNotificationBody(workListData!.nOTIFICATIONID!, -999);
}
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getMoNotificationBody() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getMoNotificationBodyList = await WorkListApiClient().getMoNotificationBody(workListData!.nOTIFICATIONID!, -999);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getItemCreationNtf() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getItemCreationNtfBody = await WorkListApiClient().getItemCreationNtfBody(workListData!.nOTIFICATIONID!, -999);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getPoNotification() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getPoNotificationBody = await WorkListApiClient().getPoNotificationBody(workListData!.nOTIFICATIONID!, -999);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getPRNotification() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getPrNotificationBody = await WorkListApiClient().getPRNotificationBody(workListData!.nOTIFICATIONID!, -999);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void notificationGetRespondAttributes() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!);
if (getNotificationRespondAttributes.isNotEmpty) {
notificationNoteInput = getNotificationRespondAttributes.first;
}
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getNotificationButtons() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
notificationButtonsList = await WorkListApiClient().getNotificationButtons(workListData!.nOTIFICATIONID!);
if (notificationButtonsList.isNotEmpty) {
isCloseAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "CLOSE");
isApproveAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "APPROVED");
isRejectAvailable = notificationButtonsList.any((element) => element.bUTTONACTION == "REJECTED");
}
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getActionHistory() async {
try {
if (apiCallCount == 0) Utils.showLoading(context);
apiCallCount++;
actionHistoryList = await WorkListApiClient().getActionHistory(workListData!.nOTIFICATIONID!);
apiCallCount--;
if (apiCallCount == 0) {
Utils.hideLoading(context);
setState(() {});
}
} catch (ex) {
apiCallCount--;
Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
void getAttachments() async {
try {
// if (apiCallCount == 0) Utils.showLoading(context);
// apiCallCount++;
getAttachmentList = await WorkListApiClient().getAttachments(workListData!.nOTIFICATIONID!);
// apiCallCount--;
// if (apiCallCount == 0) {
// Utils.hideLoading(context);
setState(() {});
// }
} catch (ex) {
// apiCallCount--;
// Utils.hideLoading(context);
Utils.handleException(ex, context, null);
}
}
} }

@ -1,14 +1,21 @@
import 'dart:convert';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mohem_flutter_app/api/chat/chat_provider_model.dart';
import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/classes/utils.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
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';
@ -21,17 +28,19 @@ class SearchEmployeeBottomSheet extends StatefulWidget {
String title, apiMode; String title, apiMode;
List<GetActionHistoryList>? actionHistoryList; List<GetActionHistoryList>? actionHistoryList;
Function(ReplacementList) onSelectEmployee; Function(ReplacementList) onSelectEmployee;
bool fromChat;
SearchEmployeeBottomSheet( SearchEmployeeBottomSheet({
{required this.title, required this.title,
required this.apiMode, required this.apiMode,
this.notificationID, this.notificationID,
this.actionHistoryList, this.actionHistoryList,
required this.onSelectEmployee}); required this.onSelectEmployee,
required this.fromChat,
});
@override @override
State<SearchEmployeeBottomSheet> createState() => State<SearchEmployeeBottomSheet> createState() => _SearchEmployeeBottomSheetState();
_SearchEmployeeBottomSheetState();
} }
class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> { class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
@ -49,6 +58,9 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
List<ReplacementList>? favouriteUserList; List<ReplacementList>? favouriteUserList;
List<ReplacementList>? nonFavouriteUserList; List<ReplacementList>? nonFavouriteUserList;
// Chat Items
List<ChatUser>? chatUsersList = [];
int _selectedSearchIndex = 0; int _selectedSearchIndex = 0;
void fetchUserByInput({bool isNeedLoading = true}) async { void fetchUserByInput({bool isNeedLoading = true}) async {
@ -59,12 +71,24 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
userId: _selectedSearchIndex == 1 ? searchText : "", userId: _selectedSearchIndex == 1 ? searchText : "",
email: _selectedSearchIndex == 2 ? searchText : "", email: _selectedSearchIndex == 2 ? searchText : "",
); );
favouriteUserList = replacementList favouriteUserList = replacementList?.where((element) => element.isFavorite ?? false).toList();
?.where((element) => element.isFavorite ?? false) nonFavouriteUserList = replacementList?.where((element) => !(element.isFavorite ?? false)).toList();
.toList(); Utils.hideLoading(context);
nonFavouriteUserList = replacementList setState(() {});
?.where((element) => !(element.isFavorite ?? false)) } catch (e) {
.toList(); Utils.hideLoading(context);
Utils.handleException(e, context, null);
}
if (isNeedLoading) Utils.hideLoading(context);
setState(() {});
return null;
}
void fetchChatUser({bool isNeedLoading = true}) async {
try {
Utils.showLoading(context);
chatUsersList = await ChatProviderModel().getChatMemberFromSearch(searchText, int.parse(AppState().chatDetails!.response!.id.toString()));
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (e) { } catch (e) {
@ -114,9 +138,8 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
IconButton( IconButton(
constraints: const BoxConstraints(), constraints: const BoxConstraints(),
onPressed: () async { onPressed: () async {
await SystemChannels.textInput await SystemChannels.textInput.invokeMethod('TextInput.hide');
.invokeMethod('TextInput.hide'); widget.fromChat ? fetchChatUser() : fetchUserByInput();
fetchUserByInput();
}, },
icon: Icon(Icons.search)) icon: Icon(Icons.search))
], ],
@ -134,8 +157,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (cxt, index) => itemBuilder: (cxt, index) => employeeItemView(favouriteUserList![index]),
employeeItemView(favouriteUserList![index]),
separatorBuilder: (cxt, index) => Container( separatorBuilder: (cxt, index) => Container(
height: 1, height: 1,
color: MyColors.borderE3Color, color: MyColors.borderE3Color,
@ -149,8 +171,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
ListView.separated( ListView.separated(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (cxt, index) => employeeItemView( itemBuilder: (cxt, index) => employeeItemView(nonFavouriteUserList![index]),
nonFavouriteUserList![index]),
separatorBuilder: (cxt, index) => Container( separatorBuilder: (cxt, index) => Container(
height: 1, height: 1,
color: MyColors.borderE3Color, color: MyColors.borderE3Color,
@ -158,13 +179,68 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
itemCount: nonFavouriteUserList?.length ?? 0), itemCount: nonFavouriteUserList?.length ?? 0),
] ]
], ],
).expanded ).expanded,
if (widget.fromChat)
if (chatUsersList != null && widget.fromChat)
chatUsersList!.isEmpty
? Utils.getNoDataWidget(context)
: ListView(
physics: const BouncingScrollPhysics(),
padding: EdgeInsets.only(top: 0, bottom: 8),
children: [
ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (cxt, index) {
return ListTile(
leading: Stack(
children: [
SvgPicture.asset(
"assets/images/user.svg",
height: 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),
),
),
),
)
],
),
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),
minVerticalPadding: 0,
onTap: () {
Navigator.pop(context);
Navigator.pushNamed(
context,
AppRoutes.chatDetailed,
arguments: {"targetUser": chatUsersList![index]},
);
},
);
},
separatorBuilder: (cxt, index) => Container(
height: 1,
color: MyColors.borderE3Color,
),
itemCount: chatUsersList?.length ?? 0),
12.height,
],
).expanded,
], ],
).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded, ).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded,
Container( Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor),
width: double.infinity,
height: 1,
color: MyColors.lightGreyEFColor),
DefaultButton( DefaultButton(
LocaleKeys.cancel.tr(), LocaleKeys.cancel.tr(),
() { () {
@ -201,11 +277,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
Expanded( Expanded(
child: (replacement.employeeDisplayName ?? "").toText12(), child: (replacement.employeeDisplayName ?? "").toText12(),
), ),
Icon(Icons.star, Icon(Icons.star, size: 16, color: replacement.isFavorite! ? MyColors.yellowFavColor : MyColors.borderCEColor),
size: 16,
color: replacement.isFavorite!
? MyColors.yellowFavColor
: MyColors.borderCEColor),
], ],
), ),
), ),
@ -228,9 +300,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: value == groupValue color: value == groupValue ? MyColors.grey3AColor : Colors.transparent,
? MyColors.grey3AColor
: Colors.transparent,
borderRadius: BorderRadius.all(const Radius.circular(100)), borderRadius: BorderRadius.all(const Radius.circular(100)),
), ),
), ),

Loading…
Cancel
Save