improvements

design_3.0_asset_delivery_module
Sikander Saleem 3 weeks ago
parent 9f670d4a0b
commit ab6b143763

@ -29,11 +29,9 @@ extension BuildContextExtension on BuildContext {
return isTablet; return isTablet;
} }
void showConfirmDialog(String message, {String? title, VoidCallback? onTap, String? okTitle}) => showDialog( void showConfirmDialog(String message, {String? title, VoidCallback? onTap, String? okTitle}) => showDialog(
context: this, context: this,
builder: (BuildContext cxt) => ConfirmDialog(message: message, onTap: onTap, title: title,okTitle: okTitle), builder: (BuildContext cxt) => ConfirmDialog(message: message, onTap: onTap, title: title, okTitle: okTitle),
); );
Future showBottomSheet(Widget childWidget, {bool? isDismissible, String? title}) => showModalBottomSheet( Future showBottomSheet(Widget childWidget, {bool? isDismissible, String? title}) => showModalBottomSheet(

@ -74,60 +74,58 @@ class _AssetDeliveryPageState extends State<AssetDeliveryPage> {
if (dataModel == null) { if (dataModel == null) {
return const NoDataFound().center; return const NoDataFound().center;
} }
return ListView( return SingleChildScrollView(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(16),
children: [ child: Column(
requestDetailCard(context), crossAxisAlignment: CrossAxisAlignment.start,
const Divider().defaultStyle(context), children: [
Row( requestDetailCard(context),
mainAxisAlignment: MainAxisAlignment.spaceBetween, const Divider().defaultStyle(context),
children: [ Row(
Text( mainAxisAlignment: MainAxisAlignment.spaceBetween,
"Asset Delivery Table", children: [
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10), Text(
), "Asset Delivery Table",
Row( style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
children: [ ),
Container( Row(
height: 24, children: [
width: 24, Container(
decoration: const BoxDecoration( height: 24,
shape: BoxShape.circle, width: 24,
color: AppColor.primary10, // or AppColor.blueStatus(context) decoration: const BoxDecoration(
), shape: BoxShape.circle,
alignment: Alignment.center, color: AppColor.primary10, // or AppColor.blueStatus(context)
child: const Icon( ),
Icons.add, alignment: Alignment.center,
color: Colors.white, child: const Icon(
size: 16, Icons.add,
color: Colors.white,
size: 16,
),
), ),
), 4.width,
4.width, Text(
Text( "Add more",
"Add more", style: AppTextStyles.bodyText.copyWith(
style: AppTextStyles.bodyText.copyWith( color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, decoration: TextDecoration.underline,
decoration: TextDecoration.underline, ),
), ),
), ],
], ).onPress(() async {
).onPress(() async { await assetDeliveryProvider?.addNewDelivery(requestId: widget.requestId).then((status) async {
await assetDeliveryProvider?.addNewDelivery(requestId: widget.requestId).then((status) async { if (status) {
if (status) { await assetDeliveryProvider?.getAssetDeliveryTableListById(requestId: widget.requestId);
await assetDeliveryProvider?.getAssetDeliveryTableListById(requestId: widget.requestId); }
} });
}); }),
}), ],
], ),
), 8.height,
8.height, assetDeliveryTableList(context: context, assetDeliveryProvider: provider),
assetDeliveryTableList(context: context, assetDeliveryProvider: provider), ],
], ).toShadowContainer(context, borderRadius: 20),
).toShadowContainer(
context,
borderRadius: 20,
padding: 0,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
); );
}, },
), ),

@ -78,6 +78,7 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
attachment: _attachments, attachment: _attachments,
buttonColor: AppColor.primary10, buttonColor: AppColor.primary10,
onlyImages: false, onlyImages: false,
showAsListView: true,
// showAsGrid: true, // showAsGrid: true,
buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10), buttonIcon: 'quotation_icon'.toSvgAsset(color: AppColor.primary10),
onChange: (attachment) {}, onChange: (attachment) {},
@ -99,15 +100,15 @@ class _AssetDeliveryAttachmentViewState extends State<AssetDeliveryAttachmentVie
List<GenericAttachmentModel> attachement = []; List<GenericAttachmentModel> attachement = [];
for (var item in _attachments) { for (var item in _attachments) {
String fileName = String fileName =
CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? ''; CMRequestUtils.isLocalUrl(item.name ?? '') ? ("${item.name ?? ''.split("/").last}|${base64Encode(File(item.name ?? '').readAsBytesSync())}") : item.name ?? '';
attachement.add(GenericAttachmentModel(id: item.id ?? 0, name: fileName)); attachement.add(GenericAttachmentModel(id: item.id ?? 0, name: fileName));
} }
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
Map<String,dynamic> payLoad ={ Map<String, dynamic> payLoad = {
'assetDeliveryExternalDeliveryId': widget.tableItemId, 'assetDeliveryExternalDeliveryId': widget.tableItemId,
'attachments':attachement, 'attachments': attachement,
}; };
await assetDeliveryProvider.saveAttachment(payload:payLoad).then((status) async { await assetDeliveryProvider.saveAttachment(payload: payLoad).then((status) async {
Navigator.pop(context); Navigator.pop(context);
if (status) { if (status) {
///Need to verify need to stay on this page and refresh or go back.. ///Need to verify need to stay on this page and refresh or go back..

@ -1,5 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart';
@ -21,7 +19,7 @@ class AssetDeliveryBottomSheet {
); );
} }
static Future changeStatusBottomSheet({required BuildContext context,required VoidCallback cancelStatusTap,required VoidCallback statusChangeTap}) { static Future changeStatusBottomSheet({required BuildContext context, required VoidCallback cancelStatusTap, required VoidCallback statusChangeTap}) {
return buildBottomSheetParent( return buildBottomSheetParent(
context: context, context: context,
childWidget: Column( childWidget: Column(
@ -31,14 +29,17 @@ class AssetDeliveryBottomSheet {
8.height, 8.height,
Align( Align(
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: Text('Change Status'.addTranslation,style: TextStyle( child: Text(
fontSize: 21.toScreenWidth, 'Change Status'.addTranslation,
fontWeight: FontWeight.w500, style: TextStyle(
fontStyle: FontStyle.normal, fontSize: 21.toScreenWidth,
decoration: TextDecoration.none, fontWeight: FontWeight.w500,
),), fontStyle: FontStyle.normal,
decoration: TextDecoration.none,
),
),
), ),
10.height, 16.height,
Row( Row(
children: [ children: [
AppFilledButton( AppFilledButton(
@ -50,14 +51,16 @@ class AssetDeliveryBottomSheet {
showBorder: true, showBorder: true,
onPressed: () async { onPressed: () async {
cancelStatusTap(); cancelStatusTap();
}, },
).expanded, ).expanded,
12.width, 12.width,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: () { AppFilledButton(
statusChangeTap(); buttonColor: AppColor.green70,
label: 'Change Status'.addTranslation,
}).expanded, maxWidth: true,
onPressed: () {
statusChangeTap();
}).expanded,
], ],
), ),
], ],

@ -1,4 +1,3 @@
import 'dart:developer'; import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -103,32 +102,30 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
appBar: DefaultAppBar( appBar: DefaultAppBar(
title: 'Cost Center for Item'.addTranslation, title: 'Cost Center for Item'.addTranslation,
onBackPress: () { // onBackPress: () {
Navigator.pop(context); // Navigator.pop(context);
}, // },
), ),
body: Consumer<AssetDeliveryProvider>(builder: (context, provider, child) { body: Consumer<AssetDeliveryProvider>(builder: (context, provider, child) {
return Column( return provider.isLoading
children: [ ? const CircularProgressIndicator(color: AppColor.primary10).center
itemDetails(context: context, itemNo: widget.itemNo, itemDescription: widget.itemDescription), : Column(
provider.isLoading children: [
? const CircularProgressIndicator(color: AppColor.primary10).center itemDetails(context: context, itemNo: widget.itemNo, itemDescription: widget.itemDescription),
: ListView.builder( ListView.builder(
itemCount: _list.length + 1, itemCount: _list.length + 1,
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.all(widget.cardPadding ?? 16), padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index == _list.length) { if (index == _list.length) {
return Visibility( return AppFilledButton(
child: AppFilledButton( label: "Add Cost Center".addTranslation,
label: "Add Cost Center".addTranslation, maxWidth: true,
maxWidth: true, textColor: AppColor.textColor(context),
textColor: AppColor.textColor(context), buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.white10, icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)),
icon: Icon(Icons.add_circle, color: AppColor.blueStatus(context)), showIcon: true,
showIcon: true, onPressed: _addNewEntry,
onPressed: _addNewEntry,
),
); );
} }
return CostCenterItemCard( return CostCenterItemCard(
@ -142,28 +139,27 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
); );
}, },
).expanded, ).expanded,
8.height, FooterActionButton.footerContainer(
FooterActionButton.footerContainer( context: context,
context: context, child: AppFilledButton(
child: AppFilledButton( buttonColor: AppColor.primary10,
buttonColor: AppColor.primary10, label: 'Save'.addTranslation,
label: 'Save'.addTranslation, maxWidth: true,
maxWidth: true, onPressed: () async {
onPressed: () async { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); await assetDeliveryProvider.saveCostCenterToLineDeliveryInspection(tableItemId: widget.tableItemId, lineId: widget.lineId, list: _list).then((status) async {
await assetDeliveryProvider.saveCostCenterToLineDeliveryInspection(tableItemId: widget.tableItemId, lineId: widget.lineId, list: _list).then((status) async { Navigator.pop(context);
Navigator.pop(context); if (status) {
if (status) { Navigator.pop(context);
Navigator.pop(context); assetDeliveryProvider.getDeliveryLinesListById(
assetDeliveryProvider.getDeliveryLinesListById( itemId: widget.tableItemId,
itemId: widget.tableItemId, );
); }
} });
}); }),
}), ),
), ],
], );
);
}), }),
); );
} }
@ -172,6 +168,7 @@ class _CostCenterFormViewState extends State<CostCenterFormView> {
Widget itemDetails({required BuildContext context, String? itemNo, String? itemDescription}) { Widget itemDetails({required BuildContext context, String? itemNo, String? itemDescription}) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
'Item No'.addTranslation, 'Item No'.addTranslation,
@ -197,7 +194,8 @@ Widget itemDetails({required BuildContext context, String? itemNo, String? itemD
context, context,
borderRadius: 20, borderRadius: 20,
padding: 12, padding: 12,
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), showShadow: false,
margin: const EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
); );
} }
@ -293,6 +291,6 @@ class CostCenterItemCard extends StatelessWidget {
], ],
) )
], ],
).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 16, vertical: 12)).paddingOnly(bottom: 12); ).toShadowContainer(context, paddingObject: const EdgeInsets.symmetric(horizontal: 12, vertical: 12)).paddingOnly(bottom: 12);
} }
} }

@ -124,29 +124,28 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
], ],
).toShadowContainer(context, borderRadius: 20, padding: 12)) ).toShadowContainer(context, borderRadius: 20, padding: 12))
.expanded, .expanded,
if (!viewOnly) ...[
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
),
8.height,
],
FooterActionButton.footerContainer( FooterActionButton.footerContainer(
context: context, context: context,
child: !viewOnly child: !viewOnly
? Row( ? Column(
children: [ children: [
AppFilledButton( AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
label: 'Cancel'.addTranslation, 16.height,
maxWidth: true, Row(
buttonColor: AppColor.background(context), children: [
// textColor: context.isDark ? AppColor.neutral30 : Colors.white, AppFilledButton(
textColor: AppColor.red30, label: 'Cancel'.addTranslation,
showBorder: true, maxWidth: true,
onPressed: _cancelTap, buttonColor: AppColor.background(context),
).expanded, // textColor: context.isDark ? AppColor.neutral30 : Colors.white,
12.width, textColor: AppColor.red30,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded, showBorder: true,
onPressed: _cancelTap,
).expanded,
12.width,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded,
],
),
], ],
) )
: AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap), : AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap),

@ -83,28 +83,28 @@ class _EndUserCostCenterLIstViewState extends State<EndUserCostCenterLIstView> {
children: [ children: [
//Refactor this //Refactor this
SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context).toShadowContainer(context, borderRadius: 20, padding: 12)).expanded, SingleChildScrollView(padding: const EdgeInsets.all(16), child: linesList(context).toShadowContainer(context, borderRadius: 20, padding: 12)).expanded,
if (!viewOnly) ...[
FooterActionButton.footerContainer(
context: context,
child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
),
8.height,
],
!viewOnly !viewOnly
? FooterActionButton.footerContainer( ? FooterActionButton.footerContainer(
context: context, context: context,
child: Row( child: Column(
children: [ children: [
AppFilledButton( AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
label: 'Cancel'.addTranslation, 16.height,
maxWidth: true, Row(
buttonColor: AppColor.background(context), children: [
textColor: AppColor.red30, AppFilledButton(
showBorder: true, label: 'Cancel'.addTranslation,
onPressed: _cancelTap, maxWidth: true,
).expanded, buttonColor: AppColor.background(context),
12.width, textColor: AppColor.red30,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded, showBorder: true,
onPressed: _cancelTap,
).expanded,
12.width,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded,
],
),
], ],
)) ))
: const SizedBox(), : const SizedBox(),

@ -84,89 +84,86 @@ class _TechnicalInspectionLinesListViewState extends State<TechnicalInspectionLi
), ),
body: Form( body: Form(
key: _formKey, key: _formKey,
child: Column( child: (isLoading)
children: [ ? const CircularProgressIndicator(color: AppColor.primary10).center
Expanded( : (technicalInspectionLinesList.isEmpty)
child: linesList(context).toShadowContainer(context, borderRadius: 20, padding: 12), ? const NoDataFound().center
), : Column(
if (!viewOnly) ...[ children: [
FooterActionButton.footerContainer( SingleChildScrollView(
context: context, padding: const EdgeInsets.all(16),
child: AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap), child: Column(
), children: [
8.height, ListView.separated(
], padding: const EdgeInsets.all(0),
FooterActionButton.footerContainer( shrinkWrap: true,
context: context, physics: const NeverScrollableScrollPhysics(),
child: !viewOnly itemCount: technicalInspectionLinesList.length + 1,
? Row( // +1 for the header
children: [ separatorBuilder: (_, __) => 8.height,
AppFilledButton( itemBuilder: (context, index) {
label: 'Cancel'.addTranslation, if (index == 0) {
maxWidth: true, return Text(
buttonColor: AppColor.background(context), "Lines",
// textColor: context.isDark ? AppColor.neutral30 : Colors.white, style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
textColor: AppColor.red30, );
showBorder: true, }
onPressed: _cancelTap,
).expanded, final DeliveryLineModel model = technicalInspectionLinesList[index - 1];
12.width, return AssetDeliveryLineCard(
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded, deliveryLineModel: model,
], isViewOnly: viewOnly,
) isTechnical: true,
: AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap), editPress: () {
), Navigator.push(
], context,
), MaterialPageRoute(
builder: (context) => UpdateTechnicalInspectionLinesView(
requestModel: widget.requestModel,
deliveryTableModel: widget.deliveryTableModel,
deliveryLineModel: model,
),
),
);
},
);
},
).toShadowContainer(context, borderRadius: 20, padding: 12),
],
),
).expanded,
FooterActionButton.footerContainer(
context: context,
child: !viewOnly
? Column(
children: [
AppFilledButton(buttonColor: AppColor.primary10, label: 'Attachments'.addTranslation, maxWidth: true, onPressed: _attachmentTap),
16.height,
Row(
children: [
AppFilledButton(
label: 'Cancel'.addTranslation,
maxWidth: true,
buttonColor: AppColor.background(context),
// textColor: context.isDark ? AppColor.neutral30 : Colors.white,
textColor: AppColor.red30,
showBorder: true,
onPressed: _cancelTap,
).expanded,
12.width,
AppFilledButton(buttonColor: AppColor.green70, label: 'Change Status'.addTranslation, maxWidth: true, onPressed: _changeStatusTap).expanded,
],
),
],
)
: AppFilledButton(buttonColor: AppColor.primary10, label: 'Next'.addTranslation, maxWidth: true, onPressed: _nextTap),
),
],
),
), ),
); );
} }
Widget linesList(BuildContext context) {
if (isLoading) {
return SizedBox.expand(
child: const CircularProgressIndicator(color: AppColor.primary10).center,
);
}
if (technicalInspectionLinesList.isEmpty) {
return const NoDataFound().center;
}
return ListView.separated(
padding: const EdgeInsets.all(16),
itemCount: technicalInspectionLinesList.length + 1, // +1 for the header
separatorBuilder: (_, __) => 8.height,
itemBuilder: (context, index) {
if (index == 0) {
return Text(
"Lines",
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
);
}
final DeliveryLineModel model = technicalInspectionLinesList[index - 1];
return AssetDeliveryLineCard(
deliveryLineModel: model,
isViewOnly: viewOnly,
isTechnical: true,
editPress: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => UpdateTechnicalInspectionLinesView(
requestModel: widget.requestModel,
deliveryTableModel: widget.deliveryTableModel,
deliveryLineModel: model,
),
),
);
},
);
},
).toShadowContainer(context, borderRadius: 20, padding: 12);
}
//May be need to show data. //May be need to show data.
Widget inspectionDetails() { Widget inspectionDetails() {
return Column( return Column(

Loading…
Cancel
Save