diff --git a/lib/ui/work_list/itg_detail_screen.dart b/lib/ui/work_list/itg_detail_screen.dart index cf33648..e123d22 100644 --- a/lib/ui/work_list/itg_detail_screen.dart +++ b/lib/ui/work_list/itg_detail_screen.dart @@ -35,6 +35,7 @@ class ItgDetailScreen extends StatefulWidget { class _ItgDetailScreenState extends State { int tabIndex = 0; + int animationIndex = 0; PageController controller = PageController(); bool showFabOptions = false; @@ -82,6 +83,7 @@ class _ItgDetailScreenState extends State { void getDataFromState() { if (requestDetails == null) { + animationIndex = animationIndex + 1; requestDetails = AppState().requestAllList![AppState().itgWorkListIndex!]; // ModalRoute.of(context)!.settings.arguments as WorkListResponseModel; providerData.itgFormsModel!.totalCount = providerData.itgFormsModel!.totalCount! - 1; getItgData(); @@ -95,151 +97,170 @@ class _ItgDetailScreenState extends State { return Scaffold( appBar: AppBarWidget(context, title: LocaleKeys.details.tr()), backgroundColor: Colors.white, - body: Stack( - children: [ - Column( - children: [ - Container( - padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), - decoration: const BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(25), - bottomRight: Radius.circular(25), + body: AnimatedSwitcher( + duration: const Duration(milliseconds: 500), + switchInCurve: Curves.easeInToLinear, + transitionBuilder: (Widget child, Animation animation) { + Animation custom = Tween( + begin: const Offset(1.0, 0.0), + end: Offset.zero, + ).animate(animation); + return ClipRect( + child: SlideTransition( + position: custom, + child: child, + // textDirection: TextDirection.ltr, + ), + ); + }, + child: Stack( + key: ValueKey(animationIndex), + children: [ + Column( + children: [ + Container( + padding: const EdgeInsets.only(left: 21, right: 21, top: 16, bottom: 16), + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(25), + bottomRight: Radius.circular(25), + ), + gradient: LinearGradient( + transform: GradientRotation(.83), + begin: Alignment.topRight, + end: Alignment.bottomLeft, + colors: [ + MyColors.gradiantEndColor, + MyColors.gradiantStartColor, + ], + ), ), - gradient: LinearGradient( - transform: GradientRotation(.83), - begin: Alignment.topRight, - end: Alignment.bottomLeft, - colors: [ - MyColors.gradiantEndColor, - MyColors.gradiantStartColor, + child: Row( + children: [ + myTab(LocaleKeys.requestDetails.tr(), 0), + myTab(LocaleKeys.approvalLevel.tr(), 1), + myTab(LocaleKeys.requesterDetails.tr(), 2), ], ), ), - child: Row( + PageView( + controller: controller, + onPageChanged: (pageIndex) { + setState(() { + tabIndex = pageIndex; + }); + }, children: [ - myTab(LocaleKeys.requestDetails.tr(), 0), - myTab(LocaleKeys.approvalLevel.tr(), 1), - myTab(LocaleKeys.requesterDetails.tr(), 2), + RequestDetailFragment(fields: itgRequest?.fieldGoups?[1].fields ?? []), + ApprovalLevelfragment( + wFHistory: itgRequest?.wFHistory ?? [], + voidCallback: reloadITG, + ), + RequestDetailFragment(fields: itgRequest?.fieldGoups?[0].fields ?? []), ], - ), - ), - PageView( - controller: controller, - onPageChanged: (pageIndex) { - setState(() { - tabIndex = pageIndex; - }); - }, - children: [ - RequestDetailFragment(fields: itgRequest?.fieldGoups?[1].fields ?? []), - ApprovalLevelfragment( - wFHistory: itgRequest?.wFHistory ?? [], - voidCallback: reloadITG, - ), - RequestDetailFragment(fields: itgRequest?.fieldGoups?[0].fields ?? []), - ], - ).expanded, - if (isApproveAvailable || isRejectAvailable || isCloseAvailable) - Container( - padding: const EdgeInsets.only(top: 14, bottom: 14, left: 21, right: 21), - decoration: const BoxDecoration( - color: Colors.white, - border: Border( - top: BorderSide( - color: MyColors.lightGreyEFColor, - width: 1.0, + ).expanded, + if (isApproveAvailable || isRejectAvailable || isCloseAvailable) + Container( + padding: const EdgeInsets.only(top: 14, bottom: 14, left: 21, right: 21), + decoration: const BoxDecoration( + color: Colors.white, + border: Border( + top: BorderSide( + color: MyColors.lightGreyEFColor, + width: 1.0, + ), ), ), - ), - child: Row( + child: Row( + children: [ + if (isRejectAvailable) + DefaultButton( + LocaleKeys.reject.tr(), + () => performAction("REJECTED"), + colors: const [ + Color(0xffE47A7E), + Color(0xffDE6D71), + ], + ).expanded, + if (isApproveAvailable && isRejectAvailable) 8.width, + if (isApproveAvailable) + DefaultButton( + LocaleKeys.approve.tr(), + () => performAction("APPROVED"), + colors: const [ + Color(0xff28C884), + Color(0xff1BB271), + ], + ).expanded, + if (isCloseAvailable) + DefaultButton( + LocaleKeys.ok.tr(), + () => performAction("CLOSE"), + colors: const [ + Color(0xff32D892), + Color(0xff1AB170), + ], + ).expanded, + 8.width, + Container( + height: 43, + width: 43, + decoration: const BoxDecoration( + shape: BoxShape.circle, + color: MyColors.lightGreyE6Color, + ), + child: Icon(showFabOptions ? Icons.more_vert_rounded : Icons.more_horiz_rounded, color: MyColors.darkIconColor), + ).onPress(() { + setState(() { + showFabOptions = true; + }); + }) + ], + ), + ) + ], + ), + IgnorePointer( + ignoring: !showFabOptions, + child: AnimatedOpacity( + opacity: showFabOptions ? 1 : 0, + duration: const Duration(milliseconds: 250), + child: Container( + padding: const EdgeInsets.only(left: 21, right: 21, bottom: 75 - 12), + width: double.infinity, + height: double.infinity, + color: Colors.white.withOpacity(.67), + alignment: Alignment.bottomRight, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - if (isRejectAvailable) - DefaultButton( - LocaleKeys.reject.tr(), - () => performAction("REJECTED"), - colors: const [ - Color(0xffE47A7E), - Color(0xffDE6D71), - ], - ).expanded, - if (isApproveAvailable && isRejectAvailable) 8.width, - if (isApproveAvailable) - DefaultButton( - LocaleKeys.approve.tr(), - () => performAction("APPROVED"), - colors: const [ - Color(0xff28C884), - Color(0xff1BB271), - ], - ).expanded, - if (isCloseAvailable) - DefaultButton( - LocaleKeys.ok.tr(), - () => performAction("CLOSE"), - colors: const [ - Color(0xff32D892), - Color(0xff1AB170), - ], - ).expanded, - 8.width, - Container( - height: 43, - width: 43, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: MyColors.lightGreyE6Color, - ), - child: Icon(showFabOptions ? Icons.more_vert_rounded : Icons.more_horiz_rounded, color: MyColors.darkIconColor), - ).onPress(() { - setState(() { - showFabOptions = true; - }); - }) + myFab(LocaleKeys.skip.tr(), "assets/images/skip.svg").onPress(() { + if (AppState().requestAllList!.length - 1 > AppState().itgWorkListIndex!) { + animationIndex = animationIndex + 1; + AppState().itgWorkListIndex = AppState().itgWorkListIndex! + 1; + requestDetails = null; + itgRequest = null; + tabIndex = 0; + showFabOptions = false; + getDataFromState(); + } else if (AppState().requestAllList!.length - 1 == AppState().itgWorkListIndex!) { + Navigator.pop(context); + } + }), + 12.height, + ...viewApiButtonsList(allowedActionList), ], ), - ) - ], - ), - IgnorePointer( - ignoring: !showFabOptions, - child: AnimatedOpacity( - opacity: showFabOptions ? 1 : 0, - duration: const Duration(milliseconds: 250), - child: Container( - padding: const EdgeInsets.only(left: 21, right: 21, bottom: 75 - 12), - width: double.infinity, - height: double.infinity, - color: Colors.white.withOpacity(.67), - alignment: Alignment.bottomRight, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - myFab(LocaleKeys.skip.tr(), "assets/images/skip.svg").onPress(() { - if (AppState().requestAllList!.length - 1 > AppState().itgWorkListIndex!) { - AppState().itgWorkListIndex = AppState().itgWorkListIndex! + 1; - requestDetails = null; - itgRequest = null; - tabIndex = 0; - showFabOptions = false; - getDataFromState(); - } else if (AppState().requestAllList!.length - 1 == AppState().itgWorkListIndex!) { - Navigator.pop(context); - } - }), - 12.height, - ...viewApiButtonsList(allowedActionList), - ], ), - ), - ).onPress(() { - setState(() { - showFabOptions = false; - }); - }), - ), - ], + ).onPress(() { + setState(() { + showFabOptions = false; + }); + }), + ), + ], + ), ), floatingActionButton: (!isApproveAvailable && !isRejectAvailable && !isCloseAvailable) ? Container( @@ -514,6 +535,7 @@ class _ItgDetailScreenState extends State { Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); // Navigator.pop(context, "delegate_reload"); + animationIndex=animationIndex+1; AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!); if (AppState().requestAllList!.isEmpty) { Navigator.pop(context, "delegate_reload"); @@ -534,9 +556,11 @@ class _ItgDetailScreenState extends State { void performDataCorrectionORReportGeneratedAction(String requestType, int taskId, int itemId, String employeeNumber) async { try { Utils.showLoading(context); + animationIndex = animationIndex + 1; ITGRequest? itgRequest = await WorkListApiClient().grantITGRequest(requestType, taskId, itemId, employeeNumber, "", ""); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); + AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!); if (AppState().requestAllList!.isEmpty) { Navigator.pop(context, "delegate_reload"); @@ -555,6 +579,7 @@ class _ItgDetailScreenState extends State { } void reloadITG() { + animationIndex = animationIndex + 1; AppState().requestAllList!.removeAt(AppState().itgWorkListIndex!); if (AppState().requestAllList!.isEmpty) { Navigator.pop(context, "delegate_reload"); diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 5d6727c..9ae62fd 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -55,6 +55,7 @@ class WorkListDetailScreen extends StatefulWidget { class _WorkListDetailScreenState extends State { int tabIndex = 0; + int animationIndex = 0; PageController controller = PageController(); bool showFabOptions = false; @@ -187,7 +188,6 @@ class _WorkListDetailScreenState extends State { @override Widget build(BuildContext context) { getDataFromState(); - return Scaffold( appBar: AppBarWidget(context, title: LocaleKeys.details.tr()), backgroundColor: Colors.white, @@ -208,7 +208,7 @@ class _WorkListDetailScreenState extends State { ); }, child: Stack( - key: ValueKey(AppState().workListIndex ?? 0), + key: ValueKey(animationIndex), children: [ Column( children: [ @@ -350,6 +350,7 @@ class _WorkListDetailScreenState extends State { children: [ myFab(LocaleKeys.skip.tr(), "assets/images/skip.svg").onPress(() { if (AppState().workList!.length - 1 > AppState().workListIndex!) { + animationIndex = animationIndex + 1; AppState().setWorkListIndex = AppState().workListIndex! + 1; workListData = null; showFabOptions = false; @@ -685,6 +686,7 @@ class _WorkListDetailScreenState extends State { GenericResponseModel model = await WorkListApiClient().postNotificationActions(payload); Utils.hideLoading(context); Utils.showToast(LocaleKeys.yourChangeHasBeenSavedSuccessfully.tr()); + animationIndex=animationIndex+1; AppState().workList!.removeAt(AppState().workListIndex!); if (AppState().workList!.isEmpty) { Navigator.pop(context, "delegate_reload"); @@ -703,6 +705,7 @@ class _WorkListDetailScreenState extends State { } void reloadWorkList() { + animationIndex = animationIndex + 1; AppState().workList!.removeAt(AppState().workListIndex!); if (AppState().workList!.isEmpty) { Navigator.pop(context, "delegate_reload"); diff --git a/lib/widgets/app_bar_widget.dart b/lib/widgets/app_bar_widget.dart index 29c94d2..6f0d7fd 100644 --- a/lib/widgets/app_bar_widget.dart +++ b/lib/widgets/app_bar_widget.dart @@ -21,7 +21,7 @@ AppBar AppBarWidget(BuildContext context, children: [ GestureDetector( behavior: HitTestBehavior.opaque, - onTap: Feedback.wrapForTap(() => Navigator.maybePop(context, true), context), + onTap: Feedback.wrapForTap(() => Navigator.maybePop(context), context), child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor), ), 4.width,