From 50ca2bb8a37df762ec9faea1188ad1dc41dbb7c5 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 4 May 2025 14:44:43 +0300 Subject: [PATCH] create request method improvement. --- .../create_request-type_bottomsheet.dart | 93 ++++++++----------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart b/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart index 14b00184..1662d04a 100644 --- a/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart +++ b/lib/new_views/pages/land_page/create_request-type_bottomsheet.dart @@ -15,6 +15,8 @@ class CreateRequestTypeBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { + List requestList = CreateRequestModel.requestsList(context, isEngineer); + return Container( padding: const EdgeInsets.all(16.0), width: double.infinity, @@ -23,61 +25,23 @@ class CreateRequestTypeBottomSheet extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ context.translation.selectWorkOrder.heading4(context), - 16.height, - isEngineer - ? SizedBox( - // width: double.infinity, - child: listCard( - context: context, - icon: 'add_icon', - label: context.translation.task, - onTap: () async { - Navigator.pushReplacementNamed(context, CreateTaskView.id); - }, - ), - ) - : GridView( - padding: EdgeInsets.all(0), - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1, crossAxisSpacing: 16, mainAxisSpacing: 16), - children: [ - listCard( - context: context, - icon: 'add_icon', - label: context.translation.correctiveMaintenance, - onTap: () { - Navigator.pushReplacementNamed(context, CreateNewRequest.id); - }, - ), - listCard( - context: context, - icon: 'add_icon', - label: context.translation.gasRefill, - onTap: () { - //NewGasRefillRequestPage.routeName) - Navigator.pushReplacementNamed(context, NewGasRefillRequestPage.routeName); - }, - ), - listCard( - context: context, - icon: 'add_icon', - label: context.translation.deviceTransfer, - onTap: () async { - Navigator.pushReplacementNamed(context, CreateDeviceTransferRequest.id); - }, - ), - listCard( - context: context, - icon: 'add_icon', - label: context.translation.task, - onTap: () async { - Navigator.pushReplacementNamed(context, CreateTaskView.id); - }, - ), - ], + GridView( + padding: const EdgeInsets.only(top: 16, bottom: 16), + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1, crossAxisSpacing: 16, mainAxisSpacing: 16), + children: [ + for (var request in requestList) + listCard( + context: context, + icon: request.icon, + label: request.title, + onTap: () { + Navigator.pushReplacementNamed(context, request.routeName); + }, ), - 16.height, + ], + ), ], ), ); @@ -109,3 +73,24 @@ class CreateRequestTypeBottomSheet extends StatelessWidget { ); } } + +class CreateRequestModel { + String title; + String icon; + String routeName; + + CreateRequestModel(this.title, this.icon, this.routeName); + + static List requestsList(BuildContext context, bool isEngineer) { + List list = []; + if (isEngineer) { + list.add(CreateRequestModel(context.translation.task, "add_icon", CreateTaskView.id)); + } else { + list.add(CreateRequestModel(context.translation.correctiveMaintenance, "add_icon", CreateNewRequest.id)); + list.add(CreateRequestModel(context.translation.gasRefill, "add_icon", NewGasRefillRequestPage.routeName)); + list.add(CreateRequestModel(context.translation.deviceTransfer, "add_icon", CreateDeviceTransferRequest.id)); + list.add(CreateRequestModel(context.translation.task, "add_icon", CreateTaskView.id)); + } + return list; + } +}