From ba8e272885673c0ac3503f92215c3132db3ce485 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 10 Oct 2022 11:17:16 +0300 Subject: [PATCH 1/4] pull to refresh added on worklist screen. --- lib/ui/work_list/work_list_screen.dart | 130 ++++++++++++++----------- 1 file changed, 72 insertions(+), 58 deletions(-) diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index dcdd580..8db019c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -19,6 +19,7 @@ import 'package:mohem_flutter_app/models/worklist_response_model.dart'; import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:provider/provider.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; class WorkListScreen extends StatefulWidget { WorkListScreen({Key? key}) : super(key: key); @@ -82,6 +83,8 @@ class _WorkListScreenState extends State { late DashboardProviderModel providerData; + final RefreshController _refreshController = RefreshController(initialRefresh: false); + @override void initState() { super.initState(); @@ -137,6 +140,11 @@ class _WorkListScreenState extends State { } } + void _onRefresh() async { + getWorkList(); + _refreshController.refreshCompleted(); + } + @override void dispose() { super.dispose(); @@ -177,6 +185,7 @@ class _WorkListScreenState extends State { workListItemIndex = index; if (workListItemTypes[index].value == 0) { workList = []; + itgRequestTypeIndex = null; } else { workList = null; } @@ -195,58 +204,70 @@ class _WorkListScreenState extends State { ), ).paddingOnly(top: 21, bottom: 21), workListItemTypes[workListItemIndex].fullName.toSectionHeading().paddingOnly(left: 21, right: 21), - if (itgRequestTypeIndex != null) - SizedBox( - height: 40, - child: ListView.separated( - itemBuilder: (context, index) { - RequestType type = itgFormsModel!.requestType![index]; - return Container( - padding: const EdgeInsets.only(left: 21, right: 21, top: 8, bottom: 8), - alignment: Alignment.center, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(30), color: itgRequestTypeIndex == index ? MyColors.darkIconColor : MyColors.lightGreyEAColor), - child: ("${type.requestTypeName}").toText12(color: itgRequestTypeIndex == index ? MyColors.white : MyColors.black), - ).onPress(() { - if (itgRequestTypeIndex != index) { - itgRequestTypeIndex = index; - setState(() {}); - } - }); - }, - separatorBuilder: (context, index) => 8.width, - shrinkWrap: true, - itemCount: itgFormsModel?.requestType?.length ?? 0, - scrollDirection: Axis.horizontal, - padding: const EdgeInsets.only(left: 21, right: 21), + SmartRefresher( + enablePullDown: true, + enablePullUp: false, + header: const MaterialClassicHeader( + color: MyColors.gradiantEndColor, ), - ).paddingOnly(top: 16, bottom: 16), - itgRequestTypeIndex != null - ? Expanded( - child: ListView.separated( - physics: BouncingScrollPhysics(), - itemBuilder: (context, index) { - return itgRowItem(workListItemTypes[workListItemIndex], itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails![index], index); - }, - separatorBuilder: (context, index) => 12.height, - itemCount: itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails?.length ?? 0, - padding: const EdgeInsets.all(21), - ), - ) - : Expanded( - child: workList != null - ? ((workList!).isEmpty - ? LocaleKeys.noHistoryAvailable.tr().toText16().center - : ListView.separated( - physics: const BouncingScrollPhysics(), + controller: _refreshController, + onRefresh: _onRefresh, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: itgRequestTypeIndex != null + ? Column( + children: [ + SizedBox( + height: 40, + child: ListView.separated( itemBuilder: (context, index) { - return rowItem(workListItemTypes[workListItemIndex], workList![index], index); + RequestType type = itgFormsModel!.requestType![index]; + return Container( + padding: const EdgeInsets.only(left: 21, right: 21, top: 8, bottom: 8), + alignment: Alignment.center, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(30), color: itgRequestTypeIndex == index ? MyColors.darkIconColor : MyColors.lightGreyEAColor), + child: ("${type.requestTypeName}").toText12(color: itgRequestTypeIndex == index ? MyColors.white : MyColors.black), + ).onPress(() { + if (itgRequestTypeIndex != index) { + itgRequestTypeIndex = index; + setState(() {}); + } + }); }, - separatorBuilder: (context, index) => 12.height, - itemCount: workList?.length ?? 0, - padding: const EdgeInsets.all(21), - )) - : const SizedBox(), - ), + separatorBuilder: (context, index) => 8.width, + shrinkWrap: true, + itemCount: itgFormsModel?.requestType?.length ?? 0, + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.only(left: 21, right: 21), + ), + ).paddingOnly(top: 16, bottom: 16), + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + return itgRowItem(workListItemTypes[workListItemIndex], itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails![index], index); + }, + separatorBuilder: (context, index) => 12.height, + itemCount: itgFormsModel!.requestType![itgRequestTypeIndex!].requestDetails?.length ?? 0, + padding: const EdgeInsets.all(21), + ), + ], + ) + : workList != null + ? ((workList!).isEmpty + ? Utils.getNoDataWidget(context).paddingOnly(top: 100) + : ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + return rowItem(workListItemTypes[workListItemIndex], workList![index], index); + }, + separatorBuilder: (context, index) => 12.height, + itemCount: workList?.length ?? 0, + padding: const EdgeInsets.all(21), + )) + : const SizedBox(), + )).expanded, ], ), ), @@ -321,10 +342,7 @@ class _WorkListScreenState extends State { Row( children: [ DateUtil.formatDateToDate(DateUtil.convertStringToDate(requestDetails.modifiedDate!), false).toText10(color: MyColors.lightTextColor).expanded, - RotatedBox( - quarterTurns: AppState().isArabic(context) ? 2:4, - child: SvgPicture.asset("assets/images/arrow_next.svg", color:MyColors.darkIconColor) - ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.darkIconColor)), ], ), ], @@ -403,11 +421,7 @@ class _WorkListScreenState extends State { Row( children: [ DateUtil.formatDateToDate(DateUtil.convertSimpleStringDateToDate(workData.bEGINDATE!), false).toText10(color: MyColors.lightTextColor).expanded, - RotatedBox( - quarterTurns: AppState().isArabic(context) ? 2:4, - child: SvgPicture.asset("assets/images/arrow_next.svg", color:MyColors.darkIconColor) - ), - + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: MyColors.darkIconColor)), ], ), ], From d6315b067423d8c220adec7867fbc277a65d238b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 10 Oct 2022 12:40:26 +0300 Subject: [PATCH 2/4] fixes. --- lib/ui/work_list/work_list_screen.dart | 6 +- .../attachments_fragment.dart | 10 +- lib/ui/work_list/worklist_settings.dart | 179 ++++++++---------- 3 files changed, 84 insertions(+), 111 deletions(-) diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 8db019c..2fa5156 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -165,11 +165,7 @@ class _WorkListScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: double.infinity, - height: 1, - color: MyColors.lightGreyEFColor, - ), + Container(width: double.infinity, height: 1, color: MyColors.lightGreyEFColor), SizedBox( height: 40, child: ListView.separated( diff --git a/lib/ui/work_list/worklist_fragments/attachments_fragment.dart b/lib/ui/work_list/worklist_fragments/attachments_fragment.dart index 0497823..ebc3db9 100644 --- a/lib/ui/work_list/worklist_fragments/attachments_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/attachments_fragment.dart @@ -28,9 +28,12 @@ class AttachmentsFragment extends StatelessWidget { (getAttachmentList[index].fILENAME?.capitalizeFirstofEach ?? "").toText16().expanded, ], ).objectContainerView().onPress(() async { - // print("calling"); - // String path = await _createFileFromString(getAttachmentList[index].fILEDATA ?? "", getAttachmentList[index].fILECONTENTTYPE ?? ""); - // OpenFile.open(path); + try { + String path = await _createFileFromString(getAttachmentList[index].fILEDATA ?? "", getAttachmentList[index].fILECONTENTTYPE ?? ""); + OpenFile.open(path); + } catch (ex) { + debugPrint("FileErorr:$ex"); + } }); }, separatorBuilder: (BuildContext context, int index) => 12.height, @@ -67,7 +70,6 @@ class AttachmentsFragment extends StatelessWidget { String dir = (await getApplicationDocumentsDirectory()).path; File file = File("$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + "." + ext); await file.writeAsBytes(bytes); - // print(file.path); return file.path; } } diff --git a/lib/ui/work_list/worklist_settings.dart b/lib/ui/work_list/worklist_settings.dart index 7bdec80..77c1d81 100644 --- a/lib/ui/work_list/worklist_settings.dart +++ b/lib/ui/work_list/worklist_settings.dart @@ -1,4 +1,3 @@ - import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -6,6 +5,7 @@ import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.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/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; @@ -15,7 +15,7 @@ import 'package:mohem_flutter_app/models/worklist/update_user_type_list.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; -class WorklistSettings extends StatefulWidget { +class WorklistSettings extends StatefulWidget { const WorklistSettings({Key? key}) : super(key: key); @override @@ -26,7 +26,6 @@ class _WorklistSettingsState extends State { List getUserItemTypesList = []; UpdateUserItemTypesList? updateUserItemTypesList; - void initState() { super.initState(); userItemTypesList(); @@ -47,10 +46,9 @@ class _WorklistSettingsState extends State { void updateUserItem() async { try { Utils.showLoading(context); - List> itemList=[]; + List> itemList = []; for (var element in getUserItemTypesList) { - itemList.add(UpdateUserTypesList(itemID: element.uSERITEMTYPEID, pITEMTYPE: element.iTEMTYPE,pFYAENABLEDFALG: element.fYAENABLEDFALG, pFYIENABLEDFALG: element.fYIENABLEDFLAG).toJson()); - + itemList.add(UpdateUserTypesList(itemID: element.uSERITEMTYPEID, pITEMTYPE: element.iTEMTYPE, pFYAENABLEDFALG: element.fYAENABLEDFALG, pFYIENABLEDFALG: element.fYIENABLEDFLAG).toJson()); } updateUserItemTypesList = await WorkListApiClient().updateUserItemTypes(itemList); Utils.hideLoading(context); @@ -64,115 +62,92 @@ class _WorklistSettingsState extends State { @override Widget build(BuildContext context) { - return Scaffold(backgroundColor: Colors.white, + return Scaffold( + backgroundColor: Colors.white, appBar: AppBarWidget( context, title: LocaleKeys.worklistSettings.tr(), ), - body:ListView( + body: Column( children: [ - Expanded( - child: Container( - margin: const EdgeInsets.only(top: 21, left: 21, right: 21), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + ListView( + padding: const EdgeInsets.only(top: 21, left: 21, right: 21), + children: [ + LocaleKeys.TurnNotificationsFor.tr().toText22(color: MyColors.blackColor), + 16.height, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - child: LocaleKeys.TurnNotificationsFor.tr().toText22(color: MyColors.blackColor), - ).paddingOnly(top: 10, bottom: 50), + LocaleKeys.itemType.tr().toText14(color: MyColors.blackColor), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - child: LocaleKeys.itemType.tr().toText14(color: MyColors.blackColor) , - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Container( - child: "FYA".tr().toText14(color: MyColors.blackColor) , - ), - Container( - child: "FYI".tr().toText14(color: MyColors.blackColor) , - ).paddingOnly(left: 30, right: 30), - ], - ) - ], - ), - Divider(color: MyColors.greyA5Color,), - SingleChildScrollView( - scrollDirection: Axis.vertical, - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: getUserItemTypesList == null ? 0 : getUserItemTypesList.length, - itemBuilder: (BuildContext context,int index) { - return Column( - children:[ - customSwitch(getUserItemTypesList[index]), - Divider( - color: MyColors.greyC4Color, - thickness: 0.5,), - ]); - } - ), - ), + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: ["FYA".tr().toText14(color: MyColors.blackColor), 30.width, "FYI".tr().toText14(color: MyColors.blackColor), 30.width], + ) ], ), - ), - ), - DefaultButton( - LocaleKeys.save.tr(), () async { + const Divider(color: MyColors.greyA5Color), + SingleChildScrollView( + scrollDirection: Axis.vertical, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: getUserItemTypesList == null ? 0 : getUserItemTypesList.length, + itemBuilder: (BuildContext context, int index) { + return Column(children: [ + customSwitch(getUserItemTypesList[index]), + Divider( + color: MyColors.greyC4Color, + thickness: 0.5, + ), + ]); + }), + ), + ], + ).expanded, + DefaultButton(LocaleKeys.save.tr(), () async { updateUserItem(); }).insideContainer, ], - ) - - ); + )); } - - Widget customSwitch(GetUserItemTypesList list){ - return Padding( - padding: const EdgeInsets.only(top: 21), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(list.iTEMTYPE.toString(), style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: MyColors.blackColor - ),), - const Spacer(), - Row( - children: [ - CupertinoSwitch( - trackColor: Colors.grey, - activeColor: MyColors.gradiantEndColor, - value: list?.fYAENABLEDFALG =='Y' ?true : false, - onChanged: (value){ - setState(() { - list?.fYAENABLEDFALG = value == true ? 'Y': 'N'; - }); - } - ), - CupertinoSwitch( - trackColor: Colors.grey, - activeColor: MyColors.gradiantEndColor, - value: list?.fYIENABLEDFLAG =='Y' ?true : false, - onChanged: (value){ - setState(() { - // list.isFYI = value; - list?.fYIENABLEDFLAG = value ==true ? 'Y': 'N'; - }); - } - ), - ], - ) - ], - ), - ); + Widget customSwitch(GetUserItemTypesList list) { + return Padding( + padding: const EdgeInsets.only(top: 21), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + list.iTEMTYPE.toString(), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: MyColors.blackColor), + ), + const Spacer(), + Row( + children: [ + CupertinoSwitch( + trackColor: MyColors.grey57Color, + activeColor: MyColors.textMixColor, + value: list?.fYAENABLEDFALG == 'Y' ? true : false, + onChanged: (value) { + setState(() { + list?.fYAENABLEDFALG = value == true ? 'Y' : 'N'; + }); + }), + CupertinoSwitch( + trackColor: MyColors.grey57Color, + activeColor: MyColors.textMixColor, + value: list?.fYIENABLEDFLAG == 'Y' ? true : false, + onChanged: (value) { + setState(() { + // list.isFYI = value; + list?.fYIENABLEDFLAG = value == true ? 'Y' : 'N'; + }); + }), + ], + ) + ], + ), + ); } - } From 06810486e32501ee46e0e3787d697c1c30931a0d Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 11 Oct 2022 12:32:22 +0300 Subject: [PATCH 3/4] dynamic list center issue fixed. --- .../leave_balance/calculate_absence_duration_model.dart | 4 ++-- lib/ui/leave_balance/add_leave_balance_screen.dart | 4 ++-- .../dynamic_screens/dynamic_listview_screen.dart | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/models/leave_balance/calculate_absence_duration_model.dart b/lib/models/leave_balance/calculate_absence_duration_model.dart index b16b4c3..0f0a48b 100644 --- a/lib/models/leave_balance/calculate_absence_duration_model.dart +++ b/lib/models/leave_balance/calculate_absence_duration_model.dart @@ -1,6 +1,6 @@ class CalculateAbsenceDuration { - int? pABSENCEDAYS; - int? pABSENCEHOURS; + num? pABSENCEDAYS; + num? pABSENCEHOURS; String? pRETURNMSG; String? pRETURNSTATUS; diff --git a/lib/ui/leave_balance/add_leave_balance_screen.dart b/lib/ui/leave_balance/add_leave_balance_screen.dart index dc44085..477f978 100644 --- a/lib/ui/leave_balance/add_leave_balance_screen.dart +++ b/lib/ui/leave_balance/add_leave_balance_screen.dart @@ -81,8 +81,8 @@ class _AddLeaveBalanceScreenState extends State { Utils.showLoading(context); CalculateAbsenceDuration duration = await LeaveBalanceApiClient() .calculateAbsenceDuration(selectedAbsenceType!.aBSENCEATTENDANCETYPEID!, Utils.getMonthNamedFormat(startDateTime!), Utils.getMonthNamedFormat(endDateTime!), -999); - print(duration.toJson()); - totalDays = duration.pABSENCEDAYS; + + totalDays = duration.pABSENCEDAYS?.toInt(); Utils.hideLoading(context); setState(() {}); } catch (ex) { diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart index 1f03683..57b61d9 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_listview_screen.dart @@ -69,10 +69,8 @@ class _DynamicListViewScreenState extends State { isTicketRequest = dynamicParams!.dynamicId == "HMG_TKT_NEW_EIT_SS"; getTransactions(); } - Widget dataWidget = ListView( physics: const BouncingScrollPhysics(), - shrinkWrap: true, padding: const EdgeInsets.all(21), children: [ // HMG_TKT_NEW_EIT_SS Id used for ticket balance dashboard From bf7a18b91cf334195fe3f2e856280082324972c1 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 11 Oct 2022 16:34:46 +0300 Subject: [PATCH 4/4] action colors added. contact details improvement --- lib/ui/profile/contact_details.dart | 64 ++---- lib/ui/profile/phone_numbers.dart | 193 ++++++------------ .../worklist_fragments/actions_fragment.dart | 8 +- 3 files changed, 82 insertions(+), 183 deletions(-) diff --git a/lib/ui/profile/contact_details.dart b/lib/ui/profile/contact_details.dart index eb23a93..d64eeb4 100644 --- a/lib/ui/profile/contact_details.dart +++ b/lib/ui/profile/contact_details.dart @@ -84,24 +84,8 @@ class _ContactDetailsState extends State { if (getEmployeePhonesList.isNotEmpty) Stack( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - menuEntriesPhone.updateButton == 'Y' - ? IconButton( - icon: Icon( - Icons.edit_location_alt_outlined, - size: 20, - ), - onPressed: () { - updatePhone(); - }, - ) - : Container() - ], - ), ListView.separated( - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (cxt, index) => Column( @@ -113,38 +97,20 @@ class _ContactDetailsState extends State { ), separatorBuilder: (cxt, index) => 12.height, itemCount: getEmployeePhonesList.length), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: getEmployeePhonesList - // .map((e) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - // "${e.pHONETYPEMEANING}".toText13(color: MyColors.lightGrayColor), - // "${e.pHONENUMBER}".toText16(isBold: true, color: MyColors.blackColor), - // ])) - // .toList()) + if (menuEntriesPhone.updateButton == 'Y') + Positioned( + top: 1, + right: 1, + child: const Icon(Icons.edit_location_alt_outlined, size: 20).onPress(updatePhone), + ), ], ).objectContainerView(), 12.height, if (getEmployeeAddressList.isNotEmpty) Stack( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - menuEntriesAddress.updateButton == 'Y' - ? IconButton( - icon: Icon( - Icons.edit_location_alt_outlined, - size: 20, - ), - onPressed: () { - addUpdateAddress(); - }, - ) - : Container() - ], - ), ListView.separated( - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, padding: EdgeInsets.zero, itemBuilder: (cxt, index) => Column( @@ -156,14 +122,12 @@ class _ContactDetailsState extends State { ), separatorBuilder: (cxt, index) => 12.height, itemCount: getEmployeeAddressList.length), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: getEmployeeAddressList - // .map((e) => Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - // "${e.sEGMENTPROMPT}".toText13(color: MyColors.lightGrayColor), - // "${e.sEGMENTVALUEDSP}".toText16(isBold: true, color: MyColors.blackColor), - // ])) - // .toList()) + if (menuEntriesAddress.updateButton == 'Y') + Positioned( + top: 1, + right: 1, + child: const Icon(Icons.edit_location_alt_outlined, size: 20).onPress(addUpdateAddress), + ), ], ).objectContainerView() ], diff --git a/lib/ui/profile/phone_numbers.dart b/lib/ui/profile/phone_numbers.dart index 4b27b19..f4be007 100644 --- a/lib/ui/profile/phone_numbers.dart +++ b/lib/ui/profile/phone_numbers.dart @@ -4,6 +4,8 @@ import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.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/string_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/models/get_employee_phones_model.dart'; @@ -26,6 +28,7 @@ class PhoneNumbers extends StatefulWidget { class _PhoneNumbersState extends State { List getPhoneNumberTypesList = []; SubmitPhonesTransactionList submitPhoneNumbers = SubmitPhonesTransactionList(); + @override void initState() { super.initState(); @@ -46,129 +49,66 @@ class _PhoneNumbersState extends State { title: LocaleKeys.profile_contactDetails.tr(), ), backgroundColor: MyColors.backgroundColor, - bottomSheet: footer(), - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - margin: EdgeInsets.only(left: 25, right: 25, top: 25), - padding: EdgeInsets.all(20), - // height: 400, - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10.0), border: Border.all(color: Color.fromARGB(255, 209, 207, 207))), - child: InkWell( - child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - Icon( - Icons.add, - color: Color(0xff259CB8), - ), - Text( - LocaleKeys.addRow.tr(), - style: TextStyle(color: Color(0xff259CB8), fontWeight: FontWeight.bold), - ) - ]), - onTap: () { - addNewRow(); - }, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: widget.getEmployeePhonesList - .map((e) => e.aCTION != 'DELETE_ROW' - ? Container( - width: double.infinity, - margin: EdgeInsets.only( - top: 20, - left: 26, - right: 26, - ), - padding: EdgeInsets.only(left: 14, right: 14, top: 15, bottom: 15), - // height: 400, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 5, - blurRadius: 26, - offset: Offset(0, 3), - ), - ], - color: Colors.white, - borderRadius: BorderRadius.circular(10.0), - ), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - PopupMenuButton( - child: DynamicTextFieldWidget( - LocaleKeys.pleaseSelect.tr(), - e.pHONETYPEMEANING ?? "", - isEnable: false, - isPopup: true, - ).paddingOnly(bottom: 12), - itemBuilder: (_) => >[ - for (int i = 0; i < getPhoneNumberTypesList.length; i++) PopupMenuItem(child: Text(getPhoneNumberTypesList![i].mEANING!), value: i), - ], - onSelected: (int index) { - e.pHONETYPEMEANING = getPhoneNumberTypesList[index].mEANING; - e.pHONETYPE = getPhoneNumberTypesList[index].cODE; - setState(() {}); - }), - DynamicTextFieldWidget( - "", - e.pHONENUMBER ?? "", - isReadOnly: false, - onChange: (text) { - e.pHONENUMBER = text; - }, - ).paddingOnly(bottom: 12), - InkWell( - child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [ - Icon( - Icons.delete, - color: Colors.red, - size: 18, - ), - Text( - LocaleKeys.delete.tr(), - style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold), - ) - ]), - onTap: () { - // widget.getEmployeePhonesList.removeWhere((item) => item.pHONEID == e.pHONEID); - setState(() { - deleteRow(e); - }); - }, - ), - SizedBox( - height: 10, - ), - ])) - : Container()) - .toList()), - SizedBox( - height: 80, - ) - ], - ), - ), - ); - } - - Widget footer() { - return Container( - decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(10), - color: MyColors.white, - boxShadow: [ - BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), + body: Column( + children: [ + ListView( + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.all(21), + children: [ + DefaultButton("+ ${LocaleKeys.addRow.tr()}", () { + widget.getEmployeePhonesList.add(GetEmployeePhonesList(aCTION: 'NEW_ROW')); + setState(() {}); + }), + 12.height, + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (cxt, index) { + var element = widget.getEmployeePhonesList[index]; + return element.aCTION != 'DELETE_ROW' + ? Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + PopupMenuButton( + child: DynamicTextFieldWidget( + LocaleKeys.selectTypeT.tr(), + element.pHONETYPEMEANING ?? LocaleKeys.pleaseSelect.tr(), + isEnable: false, + isPopup: true, + ).paddingOnly(bottom: 12), + itemBuilder: (_) => >[ + for (int i = 0; i < getPhoneNumberTypesList.length; i++) PopupMenuItem(child: Text(getPhoneNumberTypesList![i].mEANING!), value: i), + ], + onSelected: (int index) { + element.pHONETYPEMEANING = getPhoneNumberTypesList[index].mEANING; + element.pHONETYPE = getPhoneNumberTypesList[index].cODE; + setState(() {}); + }), + DynamicTextFieldWidget( + "Value", + element.pHONENUMBER ?? "", + isReadOnly: false, + onChange: (text) { + element.pHONENUMBER = text; + }, + ).paddingOnly(bottom: 12), + Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Icon(Icons.delete, color: MyColors.redColor, size: 18), + LocaleKeys.delete.tr().toText14(color: MyColors.redColor), + ]).onPress(() { + element.aCTION = 'DELETE_ROW'; + setState(() {}); + }), + ]).objectContainerView().paddingOnly(bottom: 12) + : Container(); + }, + separatorBuilder: (cxt, index) => 0.height, + itemCount: widget.getEmployeePhonesList.length) + ], + ).expanded, + DefaultButton(LocaleKeys.update.tr(), () async { + updatePhone(); + }).insideContainer ], ), - child: DefaultButton(LocaleKeys.update.tr(), () async { - updatePhone(); - // context.setLocale(const Locale("en", "US")); // to change Loacle - // Profile(); - }).insideContainer, ); } @@ -176,7 +116,6 @@ class _PhoneNumbersState extends State { Utils.showLoading(context); setUpdateStatus(); submitPhoneNumbers = await ProfileApiClient().submitPhoneNumbers(widget.getEmployeePhonesList); - Utils.hideLoading(context); Navigator.pushNamed(context, AppRoutes.requestSubmitScreen, arguments: RequestSubmitScreenParams(LocaleKeys.profile_contactDetails.tr(), submitPhoneNumbers.pTRANSACTIONID!, submitPhoneNumbers.pITEMKEY!, 'phone_numbers')); @@ -191,14 +130,4 @@ class _PhoneNumbersState extends State { } }); } - - void addNewRow() { - setState(() { - widget.getEmployeePhonesList.add(GetEmployeePhonesList(aCTION: 'NEW_ROW')); - }); - } - - void deleteRow(GetEmployeePhonesList row) { - row.aCTION = 'DELETE_ROW'; - } } diff --git a/lib/ui/work_list/worklist_fragments/actions_fragment.dart b/lib/ui/work_list/worklist_fragments/actions_fragment.dart index db40be1..bc97c79 100644 --- a/lib/ui/work_list/worklist_fragments/actions_fragment.dart +++ b/lib/ui/work_list/worklist_fragments/actions_fragment.dart @@ -115,9 +115,15 @@ class ActionsFragment extends StatelessWidget { if (code == "SUBMIT") { return const Color(0xff2E303A); } else if (code == "REJECTED") { - return const Color(0xffD02127); + return MyColors.redColor; + } else if (code == "REJECT") { + return MyColors.redColor; + } else if (code == "PENDING") { + return MyColors.orange; } else if (code == "APPROVED") { return const Color(0xff1FA269); + } else if (code != "SUBMIT" && code != "REJECT" && code != "PENDING") { + return const Color(0xff1FA269); } else if (code == "REQUEST_INFO") { return const Color(0xff2E303A); } else {