From 9ce5ca2f09507d442f8ed9a88cc96425200549b1 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 9 Nov 2023 09:49:55 +0300 Subject: [PATCH] Improvements --- .../device_transfer_details.dart | 186 +++++++++--------- lib/views/pages/user/land_page.dart | 17 +- .../device_trancfer/device_transfer_item.dart | 67 +++---- .../widgets/gas_refill/gas_refill_item.dart | 2 +- 4 files changed, 126 insertions(+), 146 deletions(-) diff --git a/lib/views/pages/device_transfer/device_transfer_details.dart b/lib/views/pages/device_transfer/device_transfer_details.dart index b378496d..bc348879 100644 --- a/lib/views/pages/device_transfer/device_transfer_details.dart +++ b/lib/views/pages/device_transfer/device_transfer_details.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/providers/api/asset_transfer_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; @@ -12,11 +11,8 @@ import 'package:test_sa/models/device/asset_transfer.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/pages/device_transfer/update_device_transfer.dart'; -import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; -import 'package:test_sa/views/widgets/buttons/app_small_button.dart'; import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; -import 'package:test_sa/views/widgets/requests/info_row.dart'; import '../../../extensions/text_extensions.dart'; import '../../../models/enums/user_types.dart'; @@ -73,73 +69,87 @@ class _DeviceTransferDetailsState extends State { child: Column( children: [ _buildDetailsCard( - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - /// TBD - // StatusLabel( - // label: "", - // id: 0, - // textColor: AColors.getPriorityStatusTextColor(0), - // backgroundColor: AColors.getPriorityStatusColor(0)), - 8.width, - /// TBD - //StatusLabel(label: '', textColor: AColors.getRequestStatusTextColor(0), backgroundColor: AColors.getRequestStatusColor(0)), - ], - ), - 1.width.expanded, - Text(widget.model.createdOn != null ?widget.model.createdOn.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), - ], - ), - 8.height, - Text(context.translation.transferDetails, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), - 8.height, - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildTextWidget('${context.translation.assetName} : ${_model.assetName}'), - _buildTextWidget('${context.translation.assetNumber} : ${_model.assetNumber}'), - _buildTextWidget('${context.translation.model} : ${_model.modelName}'), - _buildTextWidget('${context.translation.sn} : ${_model.assetSerialNo}'), - ], - ), - 8.height, - ], - ).paddingAll(14) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text(context.translation.transferDetails, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), + 8.height, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildTextWidget('${context.translation.assetName} : ${_model.assetName}'), + _buildTextWidget('${context.translation.assetNumber} : ${_model.assetNumber}'), + _buildTextWidget('${context.translation.model} : ${_model.modelName}'), + _buildTextWidget('${context.translation.sn} : ${_model.assetSerialNo}'), + ], + ), + 8.height, + ], + ).expanded, + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + /// TBD + // Row( + // children: [ + // /// TBD + // // StatusLabel( + // // label: "", + // // id: 0, + // // textColor: AColors.getPriorityStatusTextColor(0), + // // backgroundColor: AColors.getPriorityStatusColor(0)), + // 8.width, + // + // /// TBD + // //StatusLabel(label: '', textColor: AColors.getRequestStatusTextColor(0), backgroundColor: AColors.getRequestStatusColor(0)), + // ], + // ), + 1.width, + Text(widget.model.createdOn != null ? widget.model.createdOn.toServiceRequestCardFormat : "", + textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), + ], + ), + ], + ).paddingAll(14), ), // sender card _buildCard( isSender: true, - site: _model.senderSiteName??"", + site: _model.senderSiteName ?? "", + /// TBD - unit: _model.senderDepartmentName??"", - comment: _model.senderComment??"", + unit: _model.senderDepartmentName ?? "", + comment: _model.senderComment ?? "", + /// TBD - statusLabel: _model.senderMachineStatusName != null? StatusLabel( - label: _model.senderMachineStatusName, - id: _model.senderMachineStatusId, - textColor: AColors.getRequestStatusTextColor(getIdstatus(_model.senderMachineStatusName)), - backgroundColor: AColors.getRequestStatusColor(getIdstatus(_model.senderMachineStatusName))):null, + statusLabel: _model.senderMachineStatusName != null + ? StatusLabel( + label: _model.senderMachineStatusName, + id: _model.senderMachineStatusId, + textColor: AColors.getRequestStatusTextColor(getIdstatus(_model.senderMachineStatusName)), + backgroundColor: AColors.getRequestStatusColor(getIdstatus(_model.senderMachineStatusName))) + : null, ), // receiver card _buildCard( - isSender: false, - site: _model.destSiteName??"", + isSender: false, + site: _model.destSiteName ?? "", + /// TBD - unit: _model.destDepartmentName??"", - comment: _model.receiverComment??"", + unit: _model.destDepartmentName ?? "", + comment: _model.receiverComment ?? "", + /// TBD - statusLabel: _model.receiverMachineStatusName != null ? StatusLabel( - label: _model.receiverMachineStatusName??"", - id: _model.receiverMachineStatusId, - textColor: AColors.getRequestStatusTextColor(getIdstatus(_model.receiverMachineStatusName)), - backgroundColor: AColors.getRequestStatusColor(getIdstatus(_model.receiverMachineStatusName))):null, + statusLabel: _model.receiverMachineStatusName != null + ? StatusLabel( + label: _model.receiverMachineStatusName ?? "", + id: _model.receiverMachineStatusId, + textColor: AColors.getRequestStatusTextColor(getIdstatus(_model.receiverMachineStatusName)), + backgroundColor: AColors.getRequestStatusColor(getIdstatus(_model.receiverMachineStatusName))) + : null, ), ], ), @@ -152,7 +162,7 @@ class _DeviceTransferDetailsState extends State { ); } - _buildDetailsCard(Widget widget){ + _buildDetailsCard(Widget widget) { return Container( decoration: BoxDecoration( color: Colors.white, @@ -162,13 +172,14 @@ class _DeviceTransferDetailsState extends State { ).paddingOnly(top: 14, start: 14, end: 14); } - _buildTextWidget(String text){ + _buildTextWidget(String text) { return Text( - text, style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + text, + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), ); } - _buildCard({@required String site, @required String unit, @required String comment, @required bool isSender, StatusLabel statusLabel}){ + _buildCard({@required String site, @required String unit, @required String comment, @required bool isSender, StatusLabel statusLabel}) { return Container( decoration: BoxDecoration( color: Colors.white, @@ -183,13 +194,12 @@ class _DeviceTransferDetailsState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - statusLabel??Container(), + statusLabel ?? Container(), 8.height, - Text(isSender?context.translation.senderDetails:context.translation.receiverDetails, - style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), + Text(isSender ? context.translation.senderDetails : context.translation.receiverDetails, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), ], ), - if (_userProvider.user?.type == UsersTypes.engineer) + if ((_userProvider.user?.type == UsersTypes.engineer) && (isSender ? _model.senderMachineStatusName != "Closed" : _model.receiverMachineStatusName != "Closed")) CircleAvatar( radius: 25, backgroundColor: AppColor.neutral30, @@ -201,26 +211,13 @@ class _DeviceTransferDetailsState extends State { child: SvgPicture.asset('assets/images/update.svg'), ), ), - ).onPress( - isSender ? _model.senderMachineStatusName == "Closed" - ? null - : () { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => UpdateDeviceTransfer( - model: _model, - isSender: isSender, - ))); - } - : _model.receiverMachineStatusName == "Closed" - ? null - : () { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => UpdateDeviceTransfer( - model: _model, - isSender: isSender, - ))); - }), - + ).onPress(isSender + ? () { + Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeviceTransfer(model: _model, isSender: isSender))); + } + : () { + Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateDeviceTransfer(model: _model, isSender: isSender))); + }), ], ), Column( @@ -239,19 +236,18 @@ class _DeviceTransferDetailsState extends State { ).paddingAll(14), ).paddingOnly(top: 14, start: 14, end: 14); } - - int getIdstatus(String status){ - switch(status){ + + int getIdstatus(String status) { + switch (status) { case "Closed": - return 3 ; + return 3; break; case "Open": - return 1 ; + return 1; break; case "In Progress": return 2; break; } -} - + } } diff --git a/lib/views/pages/user/land_page.dart b/lib/views/pages/user/land_page.dart index 3afdd1a5..d0fd2783 100644 --- a/lib/views/pages/user/land_page.dart +++ b/lib/views/pages/user/land_page.dart @@ -15,7 +15,6 @@ import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart'; -import 'package:test_sa/views/pages/sub_workorder/search_sub_workorder_page.dart'; import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart'; import 'package:test_sa/views/pages/user/requests/create_service_request_page.dart'; import 'package:test_sa/views/pages/user/visits/regular_visits_page.dart'; @@ -212,14 +211,14 @@ class _LandPageState extends State { Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); }, ), - if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) - LandPageItem( - text: "Create Sub Work Order", - svgPath: "assets/images/sub_workorder_icon.svg", - onPressed: () { - Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); - }, - ), + // if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user) + // LandPageItem( + // text: "Create Sub Work Order", + // svgPath: "assets/images/sub_workorder_icon.svg", + // onPressed: () { + // Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); + // }, + // ), ], ), ], diff --git a/lib/views/widgets/device_trancfer/device_transfer_item.dart b/lib/views/widgets/device_trancfer/device_transfer_item.dart index e928adce..3fd77498 100644 --- a/lib/views/widgets/device_trancfer/device_transfer_item.dart +++ b/lib/views/widgets/device_trancfer/device_transfer_item.dart @@ -4,11 +4,8 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/device/asset_transfer.dart'; -import 'package:test_sa/views/app_style/sizing.dart'; import '../../../extensions/text_extensions.dart'; -import '../../app_style/colors.dart'; -import '../requests/request_status.dart'; class DeviceTransferItem extends StatelessWidget { final int index; @@ -19,41 +16,12 @@ class DeviceTransferItem extends StatelessWidget { @override Widget build(BuildContext context) { - - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 0, - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), - ), - ), - onPressed: () { - onPressed(item); - }, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - /// TBD - // StatusLabel( - // label: '', - // id: 0, - // textColor: AColors.getPriorityStatusTextColor(0), - // backgroundColor: AColors.getPriorityStatusColor(0)), - 8.width, - /// TBD - //StatusLabel(label: '', textColor: AColors.getRequestStatusTextColor(0), backgroundColor: AColors.getRequestStatusColor(0)), - 1.width.expanded, - Text(item.createdOn != null ?item.createdOn.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), - ], - ), - 8.height, Text(context.translation.deviceTransferRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), Text( '${context.translation.from} : ${item.senderAssignedEmployeeName}', @@ -78,10 +46,27 @@ class DeviceTransferItem extends StatelessWidget { size: 14, ) ], - ), + ).onPress(() => onPressed(item)), + ], + ).expanded, + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + /// TBD + // StatusLabel( + // label: '', + // id: 0, + // textColor: AColors.getPriorityStatusTextColor(0), + // backgroundColor: AColors.getPriorityStatusColor(0)), + // 8.width, + + /// TBD + //StatusLabel(label: '', textColor: AColors.getRequestStatusTextColor(0), backgroundColor: AColors.getRequestStatusColor(0)), + 1.width, + Text(item.createdOn != null ? item.createdOn.toServiceRequestCardFormat : "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), ], - ) - ), - ); + ), + ], + ).toShadowContainer(context).paddingOnly(bottom: 8); } } diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 5ab6501e..f4392fc9 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -61,7 +61,7 @@ class GasRefillItem extends StatelessWidget { size: 14, ) ], - ), + ).onPress(() => onPressed(item)), // Row( // children: [ // Expanded(