diff --git a/packages/inventory_management/lib/pages/acknowledgement.dart b/packages/inventory_management/lib/pages/acknowledgement.dart index ba8b1124d..875cf9485 100644 --- a/packages/inventory_management/lib/pages/acknowledgement.dart +++ b/packages/inventory_management/lib/pages/acknowledgement.dart @@ -1,5 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; +import 'package:digit_ui_components/widgets/molecules/panel_cards.dart'; import 'package:flutter/material.dart'; import '../utils/i18_key_constants.dart' as i18; import '../widgets/localized.dart'; @@ -31,26 +33,48 @@ class AcknowledgementPageState final theme = Theme.of(context); return Scaffold( - body: DigitAcknowledgement.success( - description: widget.description ?? + body: PanelCard( + title: widget.label ?? localizations.translate( - i18.acknowledgementSuccess.acknowledgementDescriptionText, + i18.acknowledgementSuccess.acknowledgementLabelText, ), - descriptionWidget: widget.isDataRecordSuccess - ? DigitTableCard( - element: widget.descriptionTableData ?? {}, - ) - : null, - label: widget.label ?? + type: PanelType.success, + description: widget.description ?? localizations.translate( - i18.acknowledgementSuccess.acknowledgementLabelText, + i18.acknowledgementSuccess.acknowledgementDescriptionText, ), - action: () { - context.router.maybePop(); - }, - enableBackToSearch: widget.isDataRecordSuccess ? false : true, - actionLabel: - localizations.translate(i18.acknowledgementSuccess.actionLabelText), + /// TODO: need to update this as listview card + // additionWidgets: widget.isDataRecordSuccess + // ? DigitTableCard( + // element: widget.descriptionTableData ?? {}, + // ) + // : null, + actions: [ + DigitButton( + label: localizations.translate(i18.acknowledgementSuccess.actionLabelText), + onPressed: () { + context.router.maybePop(); + }, + type: DigitButtonType.primary, + size: DigitButtonSize.large), + if(!widget.isDataRecordSuccess) + DigitButton( + label: localizations + .translate(i18.acknowledgementSuccess.actionLabelText), + onPressed: () { + final parent = context.router.parent() as StackRouter; + // Pop twice to navigate back to the previous screen + parent.popUntilRoot(); + }, + type: DigitButtonType.secondary, + size: DigitButtonSize.large), + ], + // action: () { + // context.router.maybePop(); + // }, + // enableBackToSearch: widget.isDataRecordSuccess ? false : true, + // actionLabel: + // localizations.translate(i18.acknowledgementSuccess.actionLabelText), ), bottomNavigationBar: Offstage( offstage: !widget.isDataRecordSuccess, @@ -58,13 +82,13 @@ class AcknowledgementPageState child: SizedBox( height: 150, child: DigitCard( - margin: const EdgeInsets.fromLTRB(0, kPadding, 0, 0), - padding: const EdgeInsets.fromLTRB(kPadding, 0, kPadding, 0), - child: Column( - children: [ - DigitElevatedButton( - child: Text(localizations - .translate(i18.acknowledgementSuccess.goToHome)), + margin: const EdgeInsets.fromLTRB(0, spacer2, 0, 0), + children: [ + DigitButton( + size: DigitButtonSize.large, + type: DigitButtonType.secondary, + label: localizations + .translate(i18.acknowledgementSuccess.goToHome), onPressed: () { context.router.popUntilRoot(); }, @@ -72,32 +96,19 @@ class AcknowledgementPageState const SizedBox( height: 12, ), - DigitOutLineButton( + DigitButton( + size: DigitButtonSize.large, + type: DigitButtonType.primary, onPressed: () { context.router.popUntilRoot(); }, label: localizations .translate(i18.acknowledgementSuccess.downloadmoredata), - buttonStyle: OutlinedButton.styleFrom( - backgroundColor: Colors.white, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, - ), - side: BorderSide( - width: 1.0, - color: theme.colorScheme.secondary, - ), - minimumSize: Size( - MediaQuery.of(context).size.width, - 50, - ), - ), ), ], ), ), ), - ), ); } } diff --git a/packages/inventory_management/lib/pages/facility_selection.dart b/packages/inventory_management/lib/pages/facility_selection.dart index 08b6d667f..ec46e9483 100644 --- a/packages/inventory_management/lib/pages/facility_selection.dart +++ b/packages/inventory_management/lib/pages/facility_selection.dart @@ -1,7 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:collection/collection.dart'; -import 'package:digit_components/digit_components.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/theme/digit_extended_theme.dart'; +import 'package:digit_ui_components/widgets/scrollable_content.dart'; import 'package:flutter/material.dart'; import 'package:inventory_management/utils/constants.dart'; import 'package:inventory_management/widgets/localized.dart'; @@ -67,11 +69,11 @@ class InventoryFacilitySelectionPageState color: Colors.white, child: Padding( padding: const EdgeInsets.symmetric( - horizontal: kPadding * 2), + horizontal: spacer4), child: Column( children: [ Padding( - padding: const EdgeInsets.all(kPadding), + padding: const EdgeInsets.all(spacer2), child: Align( alignment: Alignment.topLeft, child: Text( @@ -83,13 +85,15 @@ class InventoryFacilitySelectionPageState ), ), ), - const DigitTextFormField( - suffix: Padding( - padding: EdgeInsets.all(kPadding), - child: Icon(Icons.search), - ), - label: '', - formControlName: _facilityName, + ReactiveWrapperField( + formControlName: _facilityName, + builder: (field) { + return DigitSearchFormInput( + onChange: (value){ + field.control.value = value; + }, + ); + } ), ], ), @@ -104,13 +108,12 @@ class InventoryFacilitySelectionPageState return Container( color: Colors.white, padding: const EdgeInsets.symmetric( - horizontal: kPadding), + horizontal: spacer2), child: Container( margin: const EdgeInsets.symmetric( - horizontal: kPadding), + horizontal: spacer2), decoration: BoxDecoration( - color: - DigitTheme.instance.colors.alabasterWhite, + color:Theme.of(context).colorTheme.paper.secondary, border: Border( top: index == 0 ? borderSide : BorderSide.none, @@ -126,10 +129,9 @@ class InventoryFacilitySelectionPageState Navigator.of(context).pop(facility); }, child: Container( - margin: const EdgeInsets.all(kPadding), + margin: const EdgeInsets.all(spacer2), decoration: BoxDecoration( - color: DigitTheme - .instance.colors.alabasterWhite, + color: Theme.of(context).colorTheme.paper.secondary, border: Border( bottom: BorderSide( color: theme.colorScheme.outline, @@ -138,7 +140,7 @@ class InventoryFacilitySelectionPageState ), ), child: Padding( - padding: const EdgeInsets.all(kPadding * 2), + padding: const EdgeInsets.all(spacer4), child: Text( localizations.translate( '$facilityPrefix${facility.id}'), diff --git a/packages/inventory_management/lib/pages/manage_stocks.dart b/packages/inventory_management/lib/pages/manage_stocks.dart index 8730c8634..da1cf9b00 100644 --- a/packages/inventory_management/lib/pages/manage_stocks.dart +++ b/packages/inventory_management/lib/pages/manage_stocks.dart @@ -1,5 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/atoms/menu_card.dart'; +import 'package:digit_ui_components/widgets/scrollable_content.dart'; import 'package:flutter/material.dart'; import 'package:inventory_management/router/inventory_router.gm.dart'; @@ -39,7 +41,7 @@ class ManageStocksPageState extends LocalizedState { children: [ Padding( padding: const EdgeInsets.fromLTRB( - kPadding * 2, kPadding, kPadding * 2, kPadding), + spacer4, spacer2, spacer4, spacer2), child: Align( alignment: Alignment.topLeft, child: Text( @@ -50,14 +52,13 @@ class ManageStocksPageState extends LocalizedState { ), ), Column(children: [ - DigitListView( - title: localizations + MenuCard( + heading: localizations .translate(i18.manageStock.recordStockReceiptLabel), description: localizations .translate(i18.manageStock.recordStockReceiptDescription), - prefixIcon: Icons.file_download_outlined, - sufixIcon: Icons.arrow_circle_right, - onPressed: () { + icon: Icons.file_download_outlined, + onTap: () { context.router.push( RecordStockWrapperRoute( type: StockRecordEntryType.receipt, @@ -65,53 +66,49 @@ class ManageStocksPageState extends LocalizedState { ); }, ), - DigitListView( - title: localizations + MenuCard( + heading: localizations .translate(i18.manageStock.recordStockIssuedLabel), description: localizations.translate( i18.manageStock.recordStockIssuedDescription), - prefixIcon: Icons.file_upload_outlined, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.file_upload_outlined, + onTap: () => context.router.push( RecordStockWrapperRoute( type: StockRecordEntryType.dispatch, ), )), - DigitListView( - title: localizations + MenuCard( + heading: localizations .translate(i18.manageStock.recordStockReturnedLabel), description: localizations.translate( i18.manageStock.recordStockReturnedDescription, ), - prefixIcon: Icons.settings_backup_restore, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.settings_backup_restore, + onTap: () => context.router.push( RecordStockWrapperRoute( type: StockRecordEntryType.returned, ), )), - DigitListView( - title: localizations + MenuCard( + heading: localizations .translate(i18.manageStock.recordStockDamagedLabel), description: localizations.translate( i18.manageStock.recordStockDamagedDescription, ), - prefixIcon: Icons.store, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.store, + onTap: () => context.router.push( RecordStockWrapperRoute( type: StockRecordEntryType.damaged, ), )), - DigitListView( - title: localizations + MenuCard( + heading: localizations .translate(i18.manageStock.recordStockLossLabel), description: localizations.translate( i18.manageStock.recordStockDamagedDescription, ), - prefixIcon: Icons.store, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.store, + onTap: () => context.router.push( RecordStockWrapperRoute( type: StockRecordEntryType.loss, ), diff --git a/packages/inventory_management/lib/pages/record_stock/stock_details.dart b/packages/inventory_management/lib/pages/record_stock/stock_details.dart index d8aff70b6..dcfc4496e 100644 --- a/packages/inventory_management/lib/pages/record_stock/stock_details.dart +++ b/packages/inventory_management/lib/pages/record_stock/stock_details.dart @@ -1,10 +1,15 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; -import 'package:digit_components/widgets/atoms/digit_toaster.dart'; -import 'package:digit_components/widgets/digit_sync_dialog.dart'; import 'package:digit_data_model/data_model.dart'; import 'package:digit_scanner/blocs/scanner.dart'; import 'package:digit_scanner/pages/qr_scanner.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/services/location_bloc.dart'; +import 'package:digit_ui_components/utils/component_utils.dart'; +import 'package:digit_ui_components/widgets/atoms/input_wrapper.dart'; +import 'package:digit_ui_components/widgets/atoms/pop_up_card.dart'; +import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; +import 'package:digit_ui_components/widgets/molecules/show_pop_up.dart'; +import 'package:digit_ui_components/widgets/scrollable_content.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:gs1_barcode_parser/gs1_barcode_parser.dart'; @@ -46,6 +51,7 @@ class StockDetailsPageState extends LocalizedState { List transportTypes = []; List scannedResources = []; + TextEditingController controller1 = TextEditingController(); FormGroup _form(StockRecordEntryType stockType) { return fb.group({ @@ -199,87 +205,78 @@ class StockDetailsPageState extends LocalizedState { }, ), ]), - enableFixedButton: true, + enableFixedDigitButton: true, footer: DigitCard( - margin: const EdgeInsets.fromLTRB(0, kPadding, 0, 0), - padding: const EdgeInsets.fromLTRB( - kPadding, - 0, - kPadding, - 0, - ), - child: ReactiveFormConsumer( - builder: (context, form, child) { - if (form - .control(_deliveryTeamKey) - .value - .toString() - .isEmpty || - form.control(_deliveryTeamKey).value == null || - scannerState.qrCodes.isNotEmpty) { - form.control(_deliveryTeamKey).value = - scannerState.qrCodes.isNotEmpty - ? scannerState.qrCodes.last - : ''; - } - return DigitElevatedButton( - onPressed: !form.valid - ? null - : () async { + margin: const EdgeInsets.fromLTRB(0, spacer2, 0, 0), + children: [ + ReactiveFormConsumer( + builder: (context, form, child) { + if (form + .control(_deliveryTeamKey) + .value + .toString() + .isEmpty || + form.control(_deliveryTeamKey).value == null || + scannerState.qrCodes.isNotEmpty) { + form.control(_deliveryTeamKey).value = + scannerState.qrCodes.isNotEmpty + ? scannerState.qrCodes.last + : ''; + } + return DigitButton( + type: DigitButtonType.primary, + size: DigitButtonSize.large, + onPressed: !form.valid + ? (){} + : () async { form.markAllAsTouched(); if (!form.valid) { return; } final primaryId = BlocProvider.of( - context, - ).state.primaryId; + context, + ).state.primaryId; final secondaryParty = - selectedFacilityId != null - ? FacilityModel( - id: selectedFacilityId - .toString(), - ) - : null; + selectedFacilityId != null + ? FacilityModel( + id: selectedFacilityId + .toString(), + ) + : null; final deliveryTeamName = form .control(_deliveryTeamKey) .value as String?; if (deliveryTeamSelected && (form - .control( - _deliveryTeamKey, - ) - .value == - null || + .control( + _deliveryTeamKey, + ) + .value == + null || form .control(_deliveryTeamKey) .value .toString() .trim() .isEmpty)) { - DigitToast.show( + Toast.showToast( context, - options: DigitToastOptions( - localizations.translate( - i18.stockDetails.teamCodeRequired, - ), - true, - theme, + type: ToastType.error, + message: localizations.translate( + i18.stockDetails.teamCodeRequired, ), ); } else if ((primaryId == - secondaryParty?.id) || + secondaryParty?.id) || (primaryId == deliveryTeamName)) { - DigitToast.show( + Toast.showToast( context, - options: DigitToastOptions( - localizations.translate( - i18.stockDetails - .senderReceiverValidation, - ), - true, - theme, + type: ToastType.error, + message: localizations.translate( + i18.stockDetails + .senderReceiverValidation, ), ); } else { @@ -288,293 +285,295 @@ class StockDetailsPageState extends LocalizedState { context .read() .add(const LoadLocationEvent()); - DigitComponentsUtils() - .showLocationCapturingDialog( - context, - localizations.translate(i18 - .common.locationCapturing), - DigitSyncDialogType.inProgress); + DigitComponentsUtils + .showDialog( + context, + localizations.translate(i18 + .common.locationCapturing), + DialogType.inProgress); Future.delayed( const Duration(seconds: 2), - () async { - DigitComponentsUtils() - .hideDialog(context); - final bloc = + () async { + DigitComponentsUtils + .hideDialog(context); + final bloc = context.read(); - final productVariant = form - .control(_productVariantKey) - .value as ProductVariantModel; + final productVariant = form + .control(_productVariantKey) + .value as ProductVariantModel; - switch (entryType) { - case StockRecordEntryType.receipt: - transactionReason = - TransactionReason.received - .toValue(); - break; - case StockRecordEntryType.dispatch: - transactionReason = null; - break; - case StockRecordEntryType.returned: - transactionReason = - TransactionReason.returned - .toValue(); - break; - default: - transactionReason = form - .control( + switch (entryType) { + case StockRecordEntryType.receipt: + transactionReason = + TransactionReason.received + .toValue(); + break; + case StockRecordEntryType.dispatch: + transactionReason = null; + break; + case StockRecordEntryType.returned: + transactionReason = + TransactionReason.returned + .toValue(); + break; + default: + transactionReason = form + .control( _transactionReasonKey, ) - .value as String?; - break; - } + .value as String?; + break; + } - final quantity = form - .control(_transactionQuantityKey) - .value; + final quantity = form + .control(_transactionQuantityKey) + .value; - final waybillNumber = form - .control(_waybillNumberKey) - .value as String?; + final waybillNumber = form + .control(_waybillNumberKey) + .value as String?; - final waybillQuantity = form - .control(_waybillQuantityKey) - .value as String?; + final waybillQuantity = form + .control(_waybillQuantityKey) + .value as String?; - final vehicleNumber = form - .control(_vehicleNumberKey) - .value as String?; + final vehicleNumber = form + .control(_vehicleNumberKey) + .value as String?; - final lat = locationState.latitude; - final lng = locationState.longitude; + final lat = locationState.latitude; + final lng = locationState.longitude; - final hasLocationData = - lat != null && lng != null; + final hasLocationData = + lat != null && lng != null; - final comments = form - .control(_commentsKey) - .value as String?; + final comments = form + .control(_commentsKey) + .value as String?; - final deliveryTeamName = form - .control(_deliveryTeamKey) - .value as String?; + final deliveryTeamName = form + .control(_deliveryTeamKey) + .value as String?; - String? senderId; - String? senderType; - String? receiverId; - String? receiverType; + String? senderId; + String? senderType; + String? receiverId; + String? receiverType; - final primaryType = - BlocProvider.of( - context, - ).state.primaryType; + final primaryType = + BlocProvider.of( + context, + ).state.primaryType; - final primaryId = - BlocProvider.of( - context, - ).state.primaryId; + final primaryId = + BlocProvider.of( + context, + ).state.primaryId; - switch (entryType) { - case StockRecordEntryType.receipt: - case StockRecordEntryType.loss: - case StockRecordEntryType.damaged: - case StockRecordEntryType.returned: - if (deliveryTeamSelected) { - senderId = deliveryTeamName; - senderType = "STAFF"; - } else { - senderId = secondaryParty?.id; - senderType = "WAREHOUSE"; - } - receiverId = primaryId; - receiverType = primaryType; + switch (entryType) { + case StockRecordEntryType.receipt: + case StockRecordEntryType.loss: + case StockRecordEntryType.damaged: + case StockRecordEntryType.returned: + if (deliveryTeamSelected) { + senderId = deliveryTeamName; + senderType = "STAFF"; + } else { + senderId = secondaryParty?.id; + senderType = "WAREHOUSE"; + } + receiverId = primaryId; + receiverType = primaryType; - break; - case StockRecordEntryType.dispatch: - if (deliveryTeamSelected) { - receiverId = deliveryTeamName; - receiverType = "STAFF"; - } else { - receiverId = secondaryParty?.id; - receiverType = "WAREHOUSE"; + break; + case StockRecordEntryType.dispatch: + if (deliveryTeamSelected) { + receiverId = deliveryTeamName; + receiverType = "STAFF"; + } else { + receiverId = secondaryParty?.id; + receiverType = "WAREHOUSE"; + } + senderId = primaryId; + senderType = primaryType; + break; } - senderId = primaryId; - senderType = primaryType; - break; - } - final stockModel = StockModel( - clientReferenceId: + final stockModel = StockModel( + clientReferenceId: IdGen.i.identifier, - productVariantId: productVariant.id, - transactionReason: + productVariantId: productVariant.id, + transactionReason: transactionReason, - transactionType: transactionType, - referenceId: stockState.projectId, - referenceIdType: 'PROJECT', - quantity: quantity.toString(), - wayBillNumber: waybillNumber, - receiverId: receiverId, - receiverType: receiverType, - senderId: senderId, - senderType: senderType, - auditDetails: AuditDetails( - createdBy: InventorySingleton() - .loggedInUserUuid, - createdTime: context - .millisecondsSinceEpoch(), - ), - clientAuditDetails: + transactionType: transactionType, + referenceId: stockState.projectId, + referenceIdType: 'PROJECT', + quantity: quantity.toString(), + wayBillNumber: waybillNumber, + receiverId: receiverId, + receiverType: receiverType, + senderId: senderId, + senderType: senderType, + auditDetails: AuditDetails( + createdBy: InventorySingleton() + .loggedInUserUuid, + createdTime: context + .millisecondsSinceEpoch(), + ), + clientAuditDetails: ClientAuditDetails( - createdBy: InventorySingleton() - .loggedInUserUuid, - createdTime: context - .millisecondsSinceEpoch(), - lastModifiedBy: + createdBy: InventorySingleton() + .loggedInUserUuid, + createdTime: context + .millisecondsSinceEpoch(), + lastModifiedBy: InventorySingleton() .loggedInUserUuid, - lastModifiedTime: context - .millisecondsSinceEpoch(), - ), - additionalFields: [ - waybillQuantity, - vehicleNumber, - comments, - ].any((element) => - element != null) || + lastModifiedTime: context + .millisecondsSinceEpoch(), + ), + additionalFields: [ + waybillQuantity, + vehicleNumber, + comments, + ].any((element) => + element != null) || hasLocationData - ? StockAdditionalFields( - version: 1, - fields: [ + ? StockAdditionalFields( + version: 1, + fields: [ + AdditionalField( + InventoryManagementEnums + .name + .toValue(), + InventorySingleton() + .loggedInUser + ?.name, + ), + if (waybillQuantity != + null && + waybillQuantity + .trim() + .isNotEmpty) AdditionalField( - InventoryManagementEnums - .name - .toValue(), - InventorySingleton() - .loggedInUser - ?.name, + 'waybill_quantity', + waybillQuantity, + ), + if (vehicleNumber != + null && + vehicleNumber + .trim() + .isNotEmpty) + AdditionalField( + 'vehicle_number', + vehicleNumber, + ), + if (comments != null && + comments + .trim() + .isNotEmpty) + AdditionalField( + 'comments', + comments, + ), + if (deliveryTeamName != + null && + deliveryTeamName + .trim() + .isNotEmpty) + AdditionalField( + 'deliveryTeam', + deliveryTeamName, + ), + if (hasLocationData) ...[ + AdditionalField( + 'lat', + lat, + ), + AdditionalField( + 'lng', + lng, ), - if (waybillQuantity != - null && - waybillQuantity - .trim() - .isNotEmpty) - AdditionalField( - 'waybill_quantity', - waybillQuantity, - ), - if (vehicleNumber != - null && - vehicleNumber - .trim() - .isNotEmpty) - AdditionalField( - 'vehicle_number', - vehicleNumber, - ), - if (comments != null && - comments - .trim() - .isNotEmpty) - AdditionalField( - 'comments', - comments, - ), - if (deliveryTeamName != - null && - deliveryTeamName - .trim() - .isNotEmpty) - AdditionalField( - 'deliveryTeam', - deliveryTeamName, - ), - if (hasLocationData) ...[ - AdditionalField( - 'lat', - lat, - ), - AdditionalField( - 'lng', - lng, - ), - ], - if (scannerState - .barCodes.isNotEmpty) - addBarCodesToFields( - scannerState - .barCodes), ], - ) - : null, - ); - - bloc.add( - RecordStockSaveStockDetailsEvent( - stockModel: stockModel, - ), - ); + if (scannerState + .barCodes.isNotEmpty) + addBarCodesToFields( + scannerState + .barCodes), + ], + ) + : null, + ); - final submit = - await DigitDialog.show( - context, - options: DigitDialogOptions( - key: const Key('submitDialog'), - titleText: - localizations.translate( - i18.stockDetails.dialogTitle, - ), - contentText: - localizations.translate( - i18.stockDetails.dialogContent, - ), - primaryAction: DigitDialogActions( - label: localizations.translate( - i18.common.coreCommonSubmit, + bloc.add( + RecordStockSaveStockDetailsEvent( + stockModel: stockModel, ), - action: (context) { - Navigator.of( - context, - rootNavigator: true, - ).pop(true); - }, - ), - secondaryAction: - DigitDialogActions( - label: localizations.translate( - i18.common.coreCommonCancel, + ); + + final submit = + showCustomPopup( + context: context, + builder: (popupContext) => Popup( + title:localizations.translate( + i18.stockDetails.dialogTitle, + ), + onOutsideTap: () { + Navigator.of(popupContext).pop(false); + }, + description:localizations.translate( + i18.stockDetails.dialogContent, + ), + type: PopUpType.simple, + actions: [ + DigitButton( + label: localizations.translate( + i18.common.coreCommonSubmit, + ), + onPressed: () { + Navigator.of( + popupContext, + rootNavigator: true, + ).pop(true); + }, + type: DigitButtonType.primary, + size: DigitButtonSize.large, + ), + DigitButton( + label: localizations.translate( + i18.common.coreCommonCancel, + ), + onPressed: () { + Navigator.of( + popupContext, + rootNavigator: true, + ).pop(false); + }, + type: DigitButtonType.primary, + size: DigitButtonSize.large, + ), + ], ), - action: (context) => - Navigator.of( - context, - rootNavigator: true, - ).pop(false), - ), - ), - ); + ) as bool; - if (submit ?? false) { - bloc.add( - const RecordStockCreateStockEntryEvent(), - ); - } - }); + if (submit ?? false) { + bloc.add( + const RecordStockCreateStockEntryEvent(), + ); + } + }); } }, - child: Center( - child: Text( - localizations - .translate(i18.common.coreCommonSubmit), - ), - ), - ); - }), + isDisabled: !form.valid, + label: localizations + .translate(i18.common.coreCommonSubmit), + ); + }) + ], ), children: [ DigitCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, children: [ Text( localizations.translate(pageTitle), @@ -594,23 +593,50 @@ class StockDetailsPageState extends LocalizedState { )), ), fetched: (productVariants) { - return DigitReactiveDropdown< - ProductVariantModel>( - key: const Key(_productVariantKey), + return ReactiveWrapperField( formControlName: _productVariantKey, - label: localizations.translate( - module.selectProductLabel, - ), - isRequired: true, - valueMapper: (value) { - return localizations.translate( - value.sku ?? value.id, - ); - }, - menuItems: productVariants, validationMessages: { 'required': (object) => - '${module.selectProductLabel}_IS_REQUIRED', + '${module.selectProductLabel}_IS_REQUIRED', + }, + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return LabeledField( + label: localizations.translate( + module.selectProductLabel, + ), + isRequired: true, + child: DigitDropdown( + errorMessage: field.errorText, + emptyItemText: + localizations.translate( + i18.common.noMatchFound, + ), + items: productVariants + .map((variant) { + return DropdownItem( + name: + localizations.translate( + variant.sku ?? variant.id, + ), + code: variant.id, + ); + }).toList(), + onSelect: (value) { + /// Find the selected product variant model by matching the id + final selectedVariant = + productVariants + .firstWhere( + (variant) => + variant.id == + value.code, + ); + /// Update the form control with the selected product variant model + field.control.value = + selectedVariant; + }, + ), + ); }, ); }, @@ -621,16 +647,42 @@ class StockDetailsPageState extends LocalizedState { StockRecordEntryType.loss, StockRecordEntryType.damaged, ].contains(entryType)) - DigitReactiveDropdown( - key: const Key(_transactionReasonKey), - label: localizations.translate( - transactionReasonLabel ?? 'Reason', - ), - menuItems: reasons ?? [], + ReactiveWrapperField( formControlName: _transactionReasonKey, - valueMapper: (value) => - localizations.translate(value), - isRequired: true, + builder: (field) { + return LabeledField( + label: localizations.translate( + transactionReasonLabel ?? 'Reason', + ), + isRequired: true, + child: DigitDropdown( + emptyItemText: + localizations.translate( + i18.common.noMatchFound, + ), + items: + reasons!.map((reason) { + return + DropdownItem( + name: localizations + .translate(reason), + code: reason.toString(), + ); + }).toList(), + onSelect: (value) { + final selectedReason = + reasons + ?.firstWhere( + (reason) => + reason.toString() == + value.code, + ); + field.control.value = + selectedReason; + }, + ), + ); + }, ), BlocBuilder( builder: (context, state) { @@ -641,86 +693,34 @@ class StockDetailsPageState extends LocalizedState { CircularProgressIndicator(), ), fetched: (facilities, allFacilities) { - return InkWell( - onTap: () async { - clearQRCodes(); - form - .control(_deliveryTeamKey) - .value = ''; - - final facility = - await context.router.push( - InventoryFacilitySelectionRoute( - facilities: - allFacilities)) - as FacilityModel?; - - if (facility == null) return; - form - .control(_secondaryPartyKey) - .value = - localizations.translate( - 'FAC_${facility.id}', - ); - - setState(() { - selectedFacilityId = - facility.id; - }); - if (facility.id == - 'Delivery Team') { - setState(() { - deliveryTeamSelected = true; - }); - } else { - setState(() { - deliveryTeamSelected = false; - }); - } - }, - child: IgnorePointer( - child: DigitTextFormField( - key: const Key( - _secondaryPartyKey), - hideKeyboard: true, - label: localizations.translate( - '${pageTitle}_${i18.stockReconciliationDetails.stockLabel}', - ), - isRequired: true, - validationMessages: { - 'required': (object) => - localizations.translate( - '${i18.individualDetails.nameLabelText}_IS_REQUIRED', - ), - }, - suffix: const Padding( - padding: EdgeInsets.all(8.0), - child: Icon(Icons.search), - ), - formControlName: - _secondaryPartyKey, + return Column( + children: [ + const SizedBox(height: spacer4,), + InkWell( onTap: () async { clearQRCodes(); form .control(_deliveryTeamKey) .value = ''; - final facility = - await context.router.push( - InventoryFacilitySelectionRoute( - facilities: allFacilities, - ), - ) as FacilityModel?; + final facility = await context + .router + .push( + InventoryFacilitySelectionRoute( + facilities: + facilities)) + as FacilityModel?; if (facility == null) return; form - .control( - _secondaryPartyKey) - .value = + .control(_secondaryPartyKey) + .value = localizations.translate( - 'FAC_${facility.id}', - ); - + 'FAC_${facility.id}', + ); + controller1.text = + localizations.translate( + 'FAC_${facility.id}'); setState(() { selectedFacilityId = facility.id; @@ -728,208 +728,303 @@ class StockDetailsPageState extends LocalizedState { if (facility.id == 'Delivery Team') { setState(() { - deliveryTeamSelected = - true; + deliveryTeamSelected = true; }); } else { setState(() { - deliveryTeamSelected = - false; + deliveryTeamSelected = false; }); } }, + child: IgnorePointer( + child: ReactiveWrapperField( + formControlName: + _secondaryPartyKey, + validationMessages: { + 'required': (object) => + localizations + .translate( + '${i18.individualDetails.nameLabelText}_IS_REQUIRED', + ), + }, + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return InputField( + type: InputType.search, + isRequired: true, + label: localizations + .translate( + '${pageTitle}_${i18.stockReconciliationDetails.stockLabel}', + ), + onChange: (value) { + field.control.markAsTouched(); + }, + controller: controller1, + errorMessage: field.errorText, + ); + }), + ), ), - ), + ], ); }); }, ), + // TODO: as this case i need to set when occurring Visibility( visible: deliveryTeamSelected, - child: DigitTextFormField( - label: localizations.translate( - i18.stockReconciliationDetails - .teamCodeLabel, - ), - onChanged: (val) { - String? value = val.value as String?; - if (value != null && - value.trim().isNotEmpty) { - context.read().add( - DigitScannerEvent.handleScanner( - barCode: [], - qrCode: [value], - manualCode: value, + child: ReactiveWrapperField( + formControlName: _deliveryTeamKey, + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.stockReconciliationDetails + .teamCodeLabel, + ), + isRequired: deliveryTeamSelected, + suffixIcon: Icons.qr_code_2, + onSuffixTap: (value){ + //[TODO: Add route to auto_route] + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + const DigitScannerPage( + quantity: 5, + isGS1code: false, + singleValue: false, + ), + settings: const RouteSettings( + name: '/qr-scanner'), ), ); - } else { - clearQRCodes(); - } - }, - suffix: IconButton( - onPressed: () { - //[TODO: Add route to auto_route] - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - const DigitScannerPage( - quantity: 5, - isGS1code: false, - singleValue: false, - ), - settings: const RouteSettings( - name: '/qr-scanner'), - ), + }, + onChange: (val) { + String? value = val; + if (value != null && + value.trim().isNotEmpty) { + context.read().add( + DigitScannerEvent.handleScanner( + barCode: [], + qrCode: [value], + manualCode: value, + ), + ); + } else { + clearQRCodes(); + } + }, ); - }, - icon: Icon( - Icons.qr_code_2, - color: theme.colorScheme.secondary, - ), - ), - isRequired: deliveryTeamSelected, - maxLines: 3, - formControlName: _deliveryTeamKey, - ), + }), + // DigitTextFormField( + // label: localizations.translate( + // i18.stockReconciliationDetails + // .teamCodeLabel, + // ), + // onChanged: (val) { + // String? value = val.value as String?; + // if (value != null && + // value.trim().isNotEmpty) { + // context.read().add( + // DigitScannerEvent.handleScanner( + // barCode: [], + // qrCode: [value], + // manualCode: value, + // ), + // ); + // } else { + // clearQRCodes(); + // } + // }, + // suffix: IconButton( + // onPressed: () { + // //[TODO: Add route to auto_route] + // Navigator.of(context).push( + // MaterialPageRoute( + // builder: (context) => + // const DigitScannerPage( + // quantity: 5, + // isGS1code: false, + // singleValue: false, + // ), + // settings: const RouteSettings( + // name: '/qr-scanner'), + // ), + // ); + // }, + // icon: Icon( + // Icons.qr_code_2, + // color: theme.colorScheme.secondary, + // ), + // ), + // isRequired: deliveryTeamSelected, + // maxLines: 3, + // formControlName: _deliveryTeamKey, + // ), ), - DigitTextFormField( - key: const Key(_transactionQuantityKey), - formControlName: _transactionQuantityKey, - keyboardType: - const TextInputType.numberWithOptions( - decimal: true, - ), - isRequired: true, - validationMessages: { - "number": (object) => - localizations.translate( - '${quantityCountLabel}_ERROR', - ), - "max": (object) => localizations.translate( - '${quantityCountLabel}_MAX_ERROR', + ReactiveWrapperField( + formControlName: _transactionQuantityKey, + validationMessages: { + "number": (object) => + localizations.translate( + '${quantityCountLabel}_ERROR', + ), + "max": (object) => + localizations.translate( + '${quantityCountLabel}_MAX_ERROR', + ), + "min": (object) => + localizations.translate( + '${quantityCountLabel}_MIN_ERROR', + ), + }, + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return LabeledField( + label: localizations.translate( + quantityCountLabel, ), - "min": (object) => localizations.translate( - '${quantityCountLabel}_MIN_ERROR', + isRequired: true, + child: BaseDigitFormInput( + errorMessage: field.errorText, + keyboardType: const TextInputType + .numberWithOptions( + decimal: true, + ), + onChange: (val) { + field.control.markAsTouched(); + if (int.parse(val) > 10000000000) { + field.control.value = 10000; + } else { + if(val !=''){ + field.control.value = + int.parse(val); + }else{ + field.control.value = null; + } + } + }, ), - }, - onChanged: (val) { - if (val.value != null) { - if (val.value > 10000000000) { - form - .control(_transactionQuantityKey) - .value = 10000; - } - } - }, - label: localizations.translate( - quantityCountLabel, - ), - ), + ); + }), if (isWareHouseMgr) - DigitTextFormField( - key: const Key(_waybillNumberKey), - label: localizations.translate( - i18.stockDetails.waybillNumberLabel, - ), + ReactiveWrapperField( formControlName: _waybillNumberKey, - keyboardType: - const TextInputType.numberWithOptions( - decimal: true, - ), - validationMessages: { - 'maxLength': (object) => localizations - .translate( - i18.common.maxCharsRequired) - .replaceAll('{}', '200'), - 'minLength': (object) => localizations - .translate( - i18.common.min2CharsRequired) - .replaceAll('{}', ''), + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.stockDetails.waybillNumberLabel, + ), + onChange: (val) { + field.control.value = val; + }, + ); }), if (isWareHouseMgr) - DigitTextFormField( - label: localizations.translate( - i18.stockDetails - .quantityOfProductIndicatedOnWaybillLabel, - ), + ReactiveWrapperField( formControlName: _waybillQuantityKey, - onChanged: (val) { - if (val.toString().isEmpty || - val.value == null) { - form - .control(_waybillQuantityKey) - .value = '0'; - } + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.stockDetails + .quantityOfProductIndicatedOnWaybillLabel, + ), + initialValue: '0', + onChange: (val) { + if (val == '') { + field.control.value = '0'; + } else { + field.control.value = val; + } + }, + ); }), if (isWareHouseMgr) transportTypes.isNotEmpty - ? DigitReactiveDropdown( - key: const Key(_typeOfTransportKey), - isRequired: false, - label: localizations.translate( - i18.stockDetails.transportTypeLabel, + ? ReactiveWrapperField( + formControlName: _typeOfTransportKey, + builder: (field) { + return LabeledField( + label: localizations.translate( + i18.stockDetails + .transportTypeLabel, + ), + child: DigitDropdown( + emptyItemText: + localizations.translate( + i18.common.noMatchFound, ), - valueMapper: (e) => e, - onChanged: (value) { - setState(() { - form.control( - _typeOfTransportKey, - ); - }); + items: + transportTypes.map((type) { + return DropdownItem( + name: localizations + .translate(type.name), + code: type.code, + ); + }).toList(), + onSelect: (value) { + field.control.value = + value.name; }, - initialValue: - transportTypes.firstOrNull?.name, - menuItems: transportTypes.map( - (e) { - return localizations - .translate(e.name); - }, - ).toList(), - formControlName: _typeOfTransportKey, - ) + ), + ); + }, + ) : const Offstage(), if (isWareHouseMgr) - DigitTextFormField( - label: localizations.translate( - i18.stockDetails.vehicleNumberLabel, - ), - formControlName: _vehicleNumberKey, - ), - DigitTextFormField( - label: localizations.translate( - i18.stockDetails.commentsLabel, - ), - minLines: 2, - maxLines: 3, - formControlName: _commentsKey, - ), - scannerState.barCodes.isEmpty - ? DigitOutlineIconButton( - buttonStyle: OutlinedButton.styleFrom( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero, + ReactiveWrapperField( + formControlName: _vehicleNumberKey, + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.stockDetails.vehicleNumberLabel, ), + onChange: (val) { + field.control.value = val; + }, + ); + }), + ReactiveWrapperField( + formControlName: _commentsKey, + builder: (field) { + return InputField( + type: InputType.textArea, + label: localizations.translate( + i18.stockDetails.commentsLabel, ), - onPressed: () { - //[TODO: Add route to auto_route] - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - const DigitScannerPage( - quantity: 5, - isGS1code: true, - singleValue: false, - ), - settings: const RouteSettings( - name: '/qr-scanner'), - ), - ); + onChange: (val) { + field.control.value = val; }, - icon: Icons.qr_code, - label: localizations.translate( - i18.common.scanBales, + ); + }), + scannerState.barCodes.isEmpty + ? DigitButton( + mainAxisSize: MainAxisSize.max, + size: DigitButtonSize.large, + type: DigitButtonType.secondary, + onPressed: () { + //[TODO: Add route to auto_route] + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + const DigitScannerPage( + quantity: 5, + isGS1code: true, + singleValue: false, ), - ) + settings: const RouteSettings( + name: '/qr-scanner'), + ), + ); + }, + prefixIcon: Icons.qr_code, + label: localizations.translate( + i18.common.scanBales, + ), + ) : Column(children: [ Row( mainAxisAlignment: @@ -950,7 +1045,7 @@ class StockDetailsPageState extends LocalizedState { ), Padding( padding: const EdgeInsets.only( - bottom: kPadding * 2, + bottom: spacer4, ), child: IconButton( alignment: @@ -988,7 +1083,6 @@ class StockDetailsPageState extends LocalizedState { ]) ], ), - ), ], ); }); diff --git a/packages/inventory_management/lib/pages/record_stock/warehouse_details.dart b/packages/inventory_management/lib/pages/record_stock/warehouse_details.dart index de24d5850..d33ac0487 100644 --- a/packages/inventory_management/lib/pages/record_stock/warehouse_details.dart +++ b/packages/inventory_management/lib/pages/record_stock/warehouse_details.dart @@ -1,11 +1,14 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; -import 'package:digit_components/widgets/atoms/digit_toaster.dart'; import 'package:digit_data_model/data_model.dart'; import 'package:digit_scanner/blocs/scanner.dart'; import 'package:digit_scanner/pages/qr_scanner.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/atoms/input_wrapper.dart'; +import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; +import 'package:digit_ui_components/widgets/scrollable_content.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:intl/intl.dart'; import 'package:inventory_management/router/inventory_router.gm.dart'; import 'package:reactive_forms/reactive_forms.dart'; @@ -35,6 +38,7 @@ class WarehouseDetailsPageState extends LocalizedState { static const _teamCodeKey = 'teamCode'; bool deliveryTeamSelected = false; String? selectedFacilityId; + TextEditingController controller1 = TextEditingController(); @override void initState() { @@ -123,131 +127,116 @@ class WarehouseDetailsPageState extends LocalizedState { footer: SizedBox( child: DigitCard( margin: const EdgeInsets.fromLTRB( - 0, kPadding, 0, 0), - padding: const EdgeInsets.fromLTRB( - kPadding, - 0, - kPadding, - 0, - ), - child: ReactiveFormConsumer( - builder: (context, form, child) { - return DigitElevatedButton( - onPressed: !form.valid - ? null - : () { - form.markAllAsTouched(); - if (!form.valid) { - return; - } - final dateOfRecord = form - .control(_dateOfEntryKey) - .value as DateTime; + 0, spacer2, 0, 0), + children:[ + ReactiveFormConsumer( + builder: (context, form, child) { + return DigitButton( + type: DigitButtonType.primary, + size: DigitButtonSize.large, + isDisabled: !form.valid, + label: localizations.translate( + i18.householdDetails.actionLabel, + ), + onPressed: !form.valid + ? (){} + : () { + form.markAllAsTouched(); + if (!form.valid) { + return; + } + final dateOfRecord = form + .control(_dateOfEntryKey) + .value as DateTime; - final teamCode = form - .control(_teamCodeKey) - .value as String?; + final teamCode = form + .control(_teamCodeKey) + .value as String?; - final facility = - deliveryTeamSelected - ? FacilityModel( - id: teamCode ?? - 'Delivery Team', - ) - : selectedFacilityId != - null - ? FacilityModel( - id: selectedFacilityId - .toString(), - ) - : null; + final facility = + deliveryTeamSelected + ? FacilityModel( + id: teamCode ?? + 'Delivery Team', + ) + : selectedFacilityId != + null + ? FacilityModel( + id: selectedFacilityId + .toString(), + ) + : null; - context - .read() - .add( - const DigitScannerEvent - .handleScanner( - qrCode: [], - barCode: []), - ); - if (facility == null) { - DigitToast.show( - context, - options: DigitToastOptions( - localizations.translate( - i18.stockDetails - .facilityRequired, - ), - true, - theme, - ), - ); - } else if (deliveryTeamSelected && - (teamCode == null || - teamCode - .trim() - .isEmpty)) { - DigitToast.show( - context, - options: DigitToastOptions( - localizations.translate( - i18.stockDetails - .teamCodeRequired, - ), - true, - theme, - ), - ); - } else { - recordStockBloc.add( - RecordStockSaveTransactionDetailsEvent( - dateOfRecord: dateOfRecord, - facilityModel: InventorySingleton() - .isDistributor! && - !InventorySingleton() - .isWareHouseMgr! - ? FacilityModel( - id: teamCode - .toString(), - ) - : facility, - primaryId: facility.id == - "Delivery Team" - ? teamCode ?? '' - : facility.id, - primaryType: (InventorySingleton() - .isDistributor! && - !InventorySingleton() - .isWareHouseMgr! && - deliveryTeamSelected) || - deliveryTeamSelected - ? "STAFF" - : "WAREHOUSE", - ), - ); - context.router.push( - StockDetailsRoute(), - ); - } - }, - child: child!, - ); - }, - child: Center( - child: Text( - localizations.translate( - i18.householdDetails.actionLabel, - ), - ), + context + .read() + .add( + const DigitScannerEvent + .handleScanner( + qrCode: [], + barCode: []), + ); + if (facility == null) { + Toast.showToast( + type: ToastType.error, + context, + message: localizations.translate( + i18.stockDetails + .facilityRequired, + ), + ); + } else if (deliveryTeamSelected && + (teamCode == null || + teamCode + .trim() + .isEmpty)) { + Toast.showToast( + context, + type: ToastType.error, + message:localizations.translate( + i18.stockDetails + .teamCodeRequired, + ), + ); + } else { + recordStockBloc.add( + RecordStockSaveTransactionDetailsEvent( + dateOfRecord: dateOfRecord, + facilityModel: InventorySingleton() + .isDistributor! && + !InventorySingleton() + .isWareHouseMgr! + ? FacilityModel( + id: teamCode + .toString(), + ) + : facility, + primaryId: facility.id == + "Delivery Team" + ? teamCode ?? '' + : facility.id, + primaryType: (InventorySingleton() + .isDistributor! && + !InventorySingleton() + .isWareHouseMgr! && + deliveryTeamSelected) || + deliveryTeamSelected + ? "STAFF" + : "WAREHOUSE", + ), + ); + context.router.push( + StockDetailsRoute(), + ); + } + }, + ); + }, ), - ), + ] ), ), children: [ DigitCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, children: [ Text( InventorySingleton().isDistributor! && @@ -264,180 +253,154 @@ class WarehouseDetailsPageState extends LocalizedState { style: theme.textTheme.displayMedium, ), Column(children: [ - DigitDateFormPicker( - isEnabled: false, - formControlName: _dateOfEntryKey, - label: localizations.translate( - i18.warehouseDetails.dateOfReceipt, - ), - isRequired: false, - confirmText: localizations.translate( - i18.common.coreCommonOk, - ), - cancelText: localizations.translate( - i18.common.coreCommonCancel, - ), - ), - DigitTextFormField( - readOnly: true, - formControlName: _administrativeUnitKey, - label: localizations.translate( - i18.warehouseDetails - .administrativeUnit, - ), + ReactiveWrapperField( + formControlName: _dateOfEntryKey, + builder: (field) { + return InputField( + type: InputType.date, + label: localizations.translate( + i18.warehouseDetails + .dateOfReceipt, + ), + confirmText: localizations.translate( + i18.common.coreCommonOk, + ), + cancelText: localizations.translate( + i18.common.coreCommonCancel, + ), + initialValue: DateFormat( + 'dd/MM/yy') + .format( + field.control.value), + readOnly: true, + ); + }), + ReactiveWrapperField( + formControlName: _administrativeUnitKey, + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.warehouseDetails + .administrativeUnit, + ), + initialValue: field.control.value, + readOnly: true, + ); + } ), ]), + ]), InkWell( - onTap: () async { - clearQRCodes(); - form.control(_teamCodeKey).value = ''; + onTap: () async { + clearQRCodes(); + form.control(_teamCodeKey).value = ''; - final facility = - await Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - InventoryFacilitySelectionPage( - facilities: facilities, - ), + final facility = + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + InventoryFacilitySelectionPage( + facilities: facilities, ), - ); + ), + ); - if (facility == null) return; - form.control(_warehouseKey).value = - localizations.translate( - 'FAC_${facility.id}'); + if (facility == null) return; + form.control(_warehouseKey).value = + localizations.translate( + 'FAC_${facility.id}'); + controller1.text = localizations.translate( + 'FAC_${facility.id}'); - setState(() { - selectedFacilityId = facility.id; - }); - if (facility.id == 'Delivery Team') { - setState(() { - deliveryTeamSelected = true; - }); - } else { - setState(() { - deliveryTeamSelected = false; - }); - } + setState(() { + selectedFacilityId = facility.id; + }); + if (facility.id == 'Delivery Team') { + setState(() { + deliveryTeamSelected = true; + }); + } else { + setState(() { + deliveryTeamSelected = false; + }); + } + }, + child: IgnorePointer( + child: ReactiveWrapperField( + formControlName: _warehouseKey, + validationMessages: { + 'required': (object) => + localizations.translate( + '${i18.individualDetails + .nameLabelText}_IS_REQUIRED', + ), }, - child: IgnorePointer( - child: DigitTextFormField( - hideKeyboard: true, - padding: const EdgeInsets.only( - bottom: kPadding, - ), - isRequired: true, + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return InputField( + type: InputType.search, label: localizations.translate( i18.stockReconciliationDetails .facilityLabel, ), - validationMessages: { - 'required': (object) => - localizations.translate( - '${i18.individualDetails.nameLabelText}_IS_REQUIRED', - ), - }, - suffix: const Padding( - padding: EdgeInsets.all(8.0), - child: Icon(Icons.search), - ), - formControlName: _warehouseKey, - readOnly: true, - onTap: () async { - context - .read() - .add( - const DigitScannerEvent - .handleScanner( - barCode: [], - qrCode: [], - ), - ); - form.control(_teamCodeKey).value = - ''; - final facility = - await Navigator.of(context) - .push( - MaterialPageRoute( - builder: (context) => - InventoryFacilitySelectionPage( - facilities: facilities, - ), - ), - ); - - if (facility == null) return; - form.control(_warehouseKey).value = - localizations.translate( - 'FAC_${facility.id}'); - - setState(() { - selectedFacilityId = facility.id; - }); - if (facility.id == - 'Delivery Team') { - setState(() { - deliveryTeamSelected = true; - }); - } else { - setState(() { - deliveryTeamSelected = false; - }); - } + controller: controller1, + isRequired: true, + errorMessage: field.errorText, + onChange: (value) { + field.control.markAsTouched(); }, - ), - ), - ), + ); + } + ), + ), + ), if (deliveryTeamSelected) - DigitTextFormField( - label: localizations.translate( - i18.stockReconciliationDetails - .teamCodeLabel, - ), - formControlName: _teamCodeKey, - onChanged: (val) { - String? value = val as String?; - if (value != null && - value.trim().isNotEmpty) { - context - .read() - .add( - DigitScannerEvent - .handleScanner( - barCode: [], - qrCode: [value], + ReactiveWrapperField( + formControlName: _teamCodeKey, + builder: (field) { + return InputField( + type: InputType.text, + label: localizations.translate( + i18.stockReconciliationDetails + .teamCodeLabel, + ), + isRequired: deliveryTeamSelected, + suffixIcon: Icons.qr_code_2, + onSuffixTap: (value){ + //[TODO: Add route to auto_route] + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + const DigitScannerPage( + quantity: 5, + isGS1code: false, + singleValue: false, + ), + settings: const RouteSettings( + name: '/qr-scanner'), ), ); - } else { - clearQRCodes(); - } - }, - isRequired: true, - suffix: IconButton( - onPressed: () { - //[TODO: Add route to auto_route] - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - const DigitScannerPage( - quantity: 1, - isGS1code: false, - singleValue: false, - ), - settings: const RouteSettings( - name: '/qr-scanner'), - ), + }, + onChange: (val) { + String? value = val; + if (value != null && + value.trim().isNotEmpty) { + context + .read() + .add( + DigitScannerEvent + .handleScanner( + barCode: [], + qrCode: [value], + ), + ); + } else { + clearQRCodes(); + } + }, ); - }, - icon: Icon( - Icons.qr_code_2, - color: theme.colorScheme.secondary, - ), - ), - ), - ], - ), - ), + }) ], ); }, diff --git a/packages/inventory_management/lib/pages/reports/report_details.dart b/packages/inventory_management/lib/pages/reports/report_details.dart index 8b31c8cc2..183b6493d 100644 --- a/packages/inventory_management/lib/pages/reports/report_details.dart +++ b/packages/inventory_management/lib/pages/reports/report_details.dart @@ -1,7 +1,9 @@ import 'package:auto_route/auto_route.dart'; import 'package:collection/collection.dart'; -import 'package:digit_components/digit_components.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/atoms/input_wrapper.dart'; +import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:inventory_management/router/inventory_router.gm.dart'; @@ -117,17 +119,16 @@ class InventoryReportDetailsPageState ), child: Scaffold( bottomNavigationBar: DigitCard( - padding: const EdgeInsets.all(8.0), - child: DigitElevatedButton( - onPressed: () => context.router.popUntilRoot(), - child: Text( - localizations.translate( + children: [ + DigitButton( + size: DigitButtonSize.large, + type: DigitButtonType.secondary, + onPressed: () => context.router.popUntilRoot(), + label: localizations.translate( i18.inventoryReportDetails.backToHomeButtonLabel, ), - textAlign: TextAlign.center, - maxLines: 1, ), - ), + ], ), body: BlocBuilder( builder: (context, inventoryReportState) { @@ -146,7 +147,7 @@ class InventoryReportDetailsPageState children: [ const BackNavigationHelpHeaderWidget(), Container( - padding: const EdgeInsets.all(kPadding), + padding: const EdgeInsets.all(spacer2), child: Align( alignment: Alignment.centerLeft, child: Text( @@ -189,7 +190,6 @@ class InventoryReportDetailsPageState return Column( children: [ DigitCard( - child: Column( children: [ if (isWareHouseManager) BlocConsumer( - key: const Key( - _productVariantKey), - label: - localizations.translate( - i18.stockReconciliationDetails - .productLabel, - ), - form: form, - menuItems: productVariants, + return ReactiveWrapperField( formControlName: - _productVariantKey, - isRequired: true, - valueMapper: (value) { - return localizations - .translate( - value.sku ?? value.id, - ); - }, - onSelected: (value) { - handleSelection( - form, - context.read< - InventoryReportBloc>()); + _productVariantKey, + validationMessages: { + 'required': (object) => + localizations.translate( + i18.common + .corecommonRequired, + ), }, - validationMessage: - localizations.translate( - i18.common - .corecommonRequired, - ), - emptyText: + builder: (field) { + return LabeledField( + isRequired: true, + label: localizations.translate( - i18.common.noMatchFound, - ), + i18.stockReconciliationDetails + .productLabel, + ), + child: DigitDropdown( + emptyItemText: + localizations.translate( + i18.common.noMatchFound, + ), + items: productVariants.map(( + variant) { + return DropdownItem( + name: localizations + .translate( + variant.sku ?? + variant.id, + ), + code: variant.id, + ); + }).toList(), + onSelect: (value) { + /// Find the selected product variant model by matching the id + final selectedVariant = productVariants.firstWhere( + (variant) => variant.id == value.code, + ); + /// Update the form control with the selected product variant model + field.control.value = selectedVariant; + + handleSelection( + form, + context.read< + InventoryReportBloc>()); + }, + ), + ); + }, ); }, ); }, ), ], - ), ), Expanded( child: Align( @@ -323,7 +328,7 @@ class InventoryReportDetailsPageState if (data.isEmpty) { return Padding( padding: const EdgeInsets.all( - kPadding * 2, + spacer4 ), child: _NoReportContent( title: title, @@ -433,7 +438,7 @@ class InventoryReportDetailsPageState if (data.isEmpty) { return Padding( padding: const EdgeInsets.all( - kPadding * 2, + spacer4 ), child: _NoReportContent( title: title, @@ -766,12 +771,12 @@ class _ReportDetailsContent extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.all(kPadding), + padding: const EdgeInsets.all(spacer2), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - const SizedBox(height: kPadding * 2), + const SizedBox(height: spacer4), Flexible( child: ReadonlyDigitGrid( data: data, @@ -800,7 +805,7 @@ class _NoReportContent extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox( - height: kPadding * 2, + height: spacer4, width: double.maxFinite, ), Center( diff --git a/packages/inventory_management/lib/pages/reports/report_selection.dart b/packages/inventory_management/lib/pages/reports/report_selection.dart index 5f7cfd145..b8b22c442 100644 --- a/packages/inventory_management/lib/pages/reports/report_selection.dart +++ b/packages/inventory_management/lib/pages/reports/report_selection.dart @@ -1,5 +1,6 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/atoms/menu_card.dart'; import 'package:flutter/material.dart'; import 'package:inventory_management/router/inventory_router.gm.dart'; @@ -43,7 +44,7 @@ class InventoryReportSelectionPageState children: [ Padding( padding: const EdgeInsets.fromLTRB( - kPadding * 2, kPadding, kPadding * 2, kPadding), + spacer4, spacer2, spacer4, spacer2), child: Align( alignment: Alignment.topLeft, child: Text( @@ -54,84 +55,79 @@ class InventoryReportSelectionPageState ), ), Column(children: [ - DigitListView( - title: localizations.translate( + MenuCard( + heading: localizations.translate( i18.inventoryReportSelection.inventoryReportReceiptLabel, ), description: localizations.translate(i18 .inventoryReportSelection .inventoryReportReceiptDescription), - prefixIcon: Icons.login, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.login, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.receipt, ), ), ), - DigitListView( - title: localizations.translate( + MenuCard( + heading: localizations.translate( i18.inventoryReportSelection.inventoryReportIssuedLabel, ), description: localizations.translate(i18 .inventoryReportSelection .inventoryReportIssuedDescription), - prefixIcon: Icons.logout, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.logout, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.dispatch, ), ), ), - DigitListView( - title: localizations.translate(i18 + MenuCard( + heading: localizations.translate(i18 .inventoryReportSelection.inventoryReportReturnedLabel), description: localizations.translate( i18.inventoryReportSelection .inventoryReportReturnedDescription, ), - prefixIcon: Icons.settings_backup_restore, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.settings_backup_restore, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.returned, ), ), ), - DigitListView( - title: localizations.translate( + MenuCard( + heading: localizations.translate( i18.inventoryReportSelection.inventoryReportDamagedLabel, ), description: localizations.translate( i18.inventoryReportSelection .inventoryReportDamagedDescription, ), - prefixIcon: Icons.store, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.store, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.damage, ), ), ), - DigitListView( - title: localizations.translate( + MenuCard( + heading: localizations.translate( i18.inventoryReportSelection.inventoryReportLossLabel, ), description: localizations.translate( i18.inventoryReportSelection.inventoryReportLossDescription, ), - prefixIcon: Icons.store, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.store, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.loss, ), ), ), - DigitListView( - title: localizations.translate( + MenuCard( + heading: localizations.translate( i18.inventoryReportSelection .inventoryReportReconciliationLabel, ), @@ -139,9 +135,8 @@ class InventoryReportSelectionPageState i18.inventoryReportSelection .inventoryReportReconciliationDescription, ), - prefixIcon: Icons.store, - sufixIcon: Icons.arrow_circle_right, - onPressed: () => context.router.push( + icon: Icons.store, + onTap: () => context.router.push( InventoryReportDetailsRoute( reportType: InventoryReportType.reconciliation, ), diff --git a/packages/inventory_management/lib/pages/stock_reconciliation/stock_reconciliation.dart b/packages/inventory_management/lib/pages/stock_reconciliation/stock_reconciliation.dart index a52100f4b..f890f4a3d 100644 --- a/packages/inventory_management/lib/pages/stock_reconciliation/stock_reconciliation.dart +++ b/packages/inventory_management/lib/pages/stock_reconciliation/stock_reconciliation.dart @@ -1,7 +1,13 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; -import 'package:digit_components/widgets/atoms/digit_divider.dart'; import 'package:digit_data_model/data_model.dart'; +import 'package:digit_ui_components/digit_components.dart'; +import 'package:digit_ui_components/widgets/atoms/digit_divider.dart'; +import 'package:digit_ui_components/widgets/atoms/input_wrapper.dart'; +import 'package:digit_ui_components/widgets/atoms/label_value_list.dart'; +import 'package:digit_ui_components/widgets/atoms/pop_up_card.dart'; +import 'package:digit_ui_components/widgets/molecules/digit_card.dart'; +import 'package:digit_ui_components/widgets/molecules/show_pop_up.dart'; +import 'package:digit_ui_components/widgets/scrollable_content.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; @@ -38,6 +44,7 @@ class StockReconciliationPageState static const _manualCountKey = 'manualCountKey'; static const _reconciliationCommentsKey = 'reconciliationCommentsKey'; String? selectedFacilityId; + TextEditingController controller1 = TextEditingController(); FormGroup _form(bool isDistributor) { return fb.group({ @@ -103,24 +110,25 @@ class StockReconciliationPageState builder: (ctx, form, child) { return Scaffold( body: ScrollableContent( - enableFixedButton: true, + enableFixedDigitButton: true, header: const BackNavigationHelpHeaderWidget(), footer: SizedBox( child: DigitCard( margin: const EdgeInsets.fromLTRB( - 0, kPadding, 0, 0), - padding: const EdgeInsets.fromLTRB( - kPadding, 0, kPadding, 0), - child: ReactiveFormConsumer( - builder: (ctx, form, child) => - DigitElevatedButton( - onPressed: !form.valid || - (form - .control(_productVariantKey) - .value == - null) - ? null - : () async { + 0, spacer2, 0, 0), + children:[ + ReactiveFormConsumer( + builder: (ctx, form, child) => + DigitButton( + size: DigitButtonSize.large, + type: DigitButtonType.primary, + onPressed: !form.valid || + (form + .control(_productVariantKey) + .value == + null) + ? (){} + : () async { form.markAllAsTouched(); FocusManager.instance.primaryFocus ?.unfocus(); @@ -130,18 +138,18 @@ class StockReconciliationPageState StockReconciliationBloc>(); final facilityId = - InventorySingleton() - .isDistributor! && - !InventorySingleton() - .isWareHouseMgr! - ? FacilityModel( - id: InventorySingleton() - .loggedInUserUuid!, - ) - : FacilityModel( - id: selectedFacilityId - .toString(), - ); + InventorySingleton() + .isDistributor! && + !InventorySingleton() + .isWareHouseMgr! + ? FacilityModel( + id: InventorySingleton() + .loggedInUserUuid!, + ) + : FacilityModel( + id: selectedFacilityId + .toString(), + ); final productVariant = form .control(_productVariantKey) @@ -153,28 +161,28 @@ class StockReconciliationPageState final comments = form .control( - _reconciliationCommentsKey, - ) + _reconciliationCommentsKey, + ) .value as String?; final model = - StockReconciliationModel( + StockReconciliationModel( clientReferenceId: - IdGen.i.identifier, + IdGen.i.identifier, dateOfReconciliation: stockState .dateOfReconciliation .millisecondsSinceEpoch, facilityId: facilityId.id, productVariantId: - productVariant.id, + productVariant.id, calculatedCount: stockState .stockInHand .toInt(), commentsOnReconciliation: - comments, + comments, physicalCount: int.tryParse( - calculatedCount, - ) ?? + calculatedCount, + ) ?? 0, auditDetails: AuditDetails( createdBy: InventorySingleton() @@ -183,61 +191,68 @@ class StockReconciliationPageState .millisecondsSinceEpoch(), ), clientAuditDetails: - ClientAuditDetails( + ClientAuditDetails( createdBy: InventorySingleton() .loggedInUserUuid, createdTime: context .millisecondsSinceEpoch(), lastModifiedBy: - InventorySingleton() - .loggedInUserUuid, + InventorySingleton() + .loggedInUserUuid, lastModifiedTime: context .millisecondsSinceEpoch(), ), ); final submit = - await DigitDialog.show( - context, - options: DigitDialogOptions( - key: const Key('submitDialog'), - titleText: - localizations.translate( + showCustomPopup( + context: context, + builder: (popupContext) => Popup( + title: localizations.translate( i18.stockReconciliationDetails .dialogTitle, ), - contentText: - localizations.translate( + onOutsideTap: () { + Navigator.of( + popupContext, + rootNavigator: true, + ).pop(false); + }, + description: localizations.translate( i18.stockReconciliationDetails .dialogContent, ), - primaryAction: - DigitDialogActions( - label: - localizations.translate( - i18.common.coreCommonSubmit, - ), - action: (context) { - Navigator.of( - context, - rootNavigator: true, - ).pop(true); - }, - ), - secondaryAction: - DigitDialogActions( - label: - localizations.translate( - i18.common.coreCommonCancel, + type: PopUpType.simple, + actions: [ + DigitButton( + label: localizations.translate( + i18.common.coreCommonSubmit, + ), + onPressed: () { + Navigator.of( + popupContext, + rootNavigator: true, + ).pop(true); + }, + type: DigitButtonType.primary, + size: DigitButtonSize.large, ), - action: (context) => + DigitButton( + label: localizations.translate( + i18.common.coreCommonCancel, + ), + onPressed: () { Navigator.of( - context, - rootNavigator: true, - ).pop(false), - ), + popupContext, + rootNavigator: true, + ).pop(false); + }, + type: DigitButtonType.secondary, + size: DigitButtonSize.large, + ), + ], ), - ); + ) as bool; if (submit ?? false) { bloc.add( @@ -247,22 +262,16 @@ class StockReconciliationPageState ); } }, - child: Center( - child: Text( - localizations.translate( - i18.common.coreCommonSubmit, + label: localizations.translate( + i18.common.coreCommonSubmit, + ), ), - ), - ), ), - ), + ] ), ), children: [ DigitCard( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, children: [ Text( localizations.translate( @@ -292,93 +301,62 @@ class StockReconciliationPageState ), fetched: (facilities, allFacilities) { - return InkWell( - onTap: () async { - final stockReconciliationBloc = - context.read< - StockReconciliationBloc>(); - final facility = await context - .router - .push(InventoryFacilitySelectionRoute( - facilities: - facilities)) - as FacilityModel?; - - if (facility == null) { - return; - } - form - .control(_facilityKey) - .value = - localizations.translate( - 'FAC_${facility.id}', - ); - setState(() { - selectedFacilityId = - facility.id; - }); - stockReconciliationBloc.add( - StockReconciliationSelectFacilityEvent( - facility, - ), - ); - }, - child: IgnorePointer( - child: DigitTextFormField( - key: const Key( - _facilityKey), - hideKeyboard: true, - label: localizations - .translate( - i18.stockReconciliationDetails - .facilityLabel, - ), - suffix: const Padding( - padding: - EdgeInsets.all(8.0), - child: - Icon(Icons.search), - ), - formControlName: - _facilityKey, - readOnly: true, - isRequired: true, - onTap: () async { - final stockReconciliationBloc = - context.read< - StockReconciliationBloc>(); + return Column( + children: [ + const SizedBox(height: 16,), + InkWell( + onTap: () async { + final stockReconciliationBloc = + context.read< + StockReconciliationBloc>(); + final facility = await context + .router + .push(InventoryFacilitySelectionRoute( + facilities: + facilities)) + as FacilityModel?; - final facility = await context - .router - .push(InventoryFacilitySelectionRoute( - facilities: - facilities)) - as FacilityModel?; - - if (facility == null) { - return; - } - form - .control( - _facilityKey) - .value = - localizations - .translate( - 'FAC_${facility.id}', - ); - setState(() { - selectedFacilityId = - facility.id; - }); - stockReconciliationBloc - .add( - StockReconciliationSelectFacilityEvent( - facility, + if (facility == null) + return; + form + .control(_facilityKey) + .value = + localizations.translate( + 'FAC_${facility.id}', + ); + controller1.text = localizations.translate( + 'FAC_${facility.id}', + ); + setState(() { + selectedFacilityId = + facility.id; + }); + stockReconciliationBloc.add( + StockReconciliationSelectFacilityEvent( + facility, + ), + ); + }, + child: IgnorePointer( + child: ReactiveWrapperField( + formControlName: _facilityKey, + builder: (field){ + return InputField( + type: InputType.search, + isRequired: true, + controller: controller1, + label: localizations + .translate( + i18.stockReconciliationDetails + .facilityLabel, + ), + ); + }, ), - ); - }, - ), - ), + ), + ), + const SizedBox(height: 16,), + ], ); }); }, @@ -397,147 +375,109 @@ class StockReconciliationPageState ), ), fetched: (productVariants) { - return DigitReactiveSearchDropdown< - ProductVariantModel>( - key: - const Key(_productVariantKey), - label: localizations.translate( - i18.stockReconciliationDetails - .productLabel, - ), - form: form, - menuItems: productVariants, - formControlName: - _productVariantKey, - isRequired: true, - valueMapper: (value) { - return localizations.translate( - value.sku ?? value.id, - ); + return ReactiveWrapperField( + formControlName: _productVariantKey, + validationMessages: { + 'required': (error) => localizations.translate(i18 + .common + .corecommonRequired), }, - onSelected: (value) { - ctx - .read< - StockReconciliationBloc>() - .add( - StockReconciliationSelectProductEvent( - value.id, - isDistributor: InventorySingleton() - .isDistributor! && - !InventorySingleton() - .isWareHouseMgr!, - ), - ); + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return LabeledField( + isRequired: true, + label: localizations + .translate( + i18 + .stockReconciliationDetails + .productLabel, + ), + child: DigitDropdown( + emptyItemText: localizations.translate( + i18.common.noMatchFound, + ), + items: productVariants.map(( + variant) { + return DropdownItem( + name: localizations + .translate( + variant.sku ?? + variant.id, + ), + code: variant.id, + ); + }).toList(), + onSelect: (value) { + field.control.markAsTouched(); + /// Find the selected product variant model by matching the id + final selectedVariant = productVariants.firstWhere( + (variant) => variant.id == value.code, + ); + /// Update the form control with the selected product variant model + field.control.value = selectedVariant; + + ctx + .read< + StockReconciliationBloc>() + .add( + StockReconciliationSelectProductEvent( + value.code, + isDistributor: InventorySingleton() + .isDistributor! && + !InventorySingleton() + .isWareHouseMgr!, + ), + ); + }, + ), + ); }, - validationMessage: - localizations.translate(i18 - .common - .corecommonRequired), - emptyText: - localizations.translate( - i18.common.noMatchFound, - ), ); }, ); }, ), - DigitTableCard( - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate(i18 - .stockReconciliationDetails - .dateOfReconciliation): - DateFormat('dd MMMM yyyy').format( - stockState.dateOfReconciliation, - ), - }, - ), + LabelValueItem(label: localizations.translate(i18 + .stockReconciliationDetails + .dateOfReconciliation), value: DateFormat('dd MMMM yyyy').format( + stockState.dateOfReconciliation)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockReceived'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockReceived, - ): stockState.stockReceived - .toStringAsFixed(0), - }, - ), + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockReceived, + ), value: stockState.stockReceived + .toStringAsFixed(0)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockIssued'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockIssued, - ): stockState.stockIssued - .toStringAsFixed(0), - }, - ), + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockIssued, + ), value: stockState.stockIssued + .toStringAsFixed(0)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockReturned'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockReturned, - ): stockState.stockReturned - .toStringAsFixed(0), - }, - ), + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockReturned, + ), value: stockState.stockReturned + .toStringAsFixed(0)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockLost'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockLost, - ): stockState.stockLost - .toStringAsFixed(0), - }, - ), + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockLost, + ), value: stockState.stockLost + .toStringAsFixed(0)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockDamaged'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockDamaged, - ): stockState.stockDamaged - .toStringAsFixed(0), - }, - ), + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockDamaged, + ), value: stockState.stockDamaged + .toStringAsFixed(0)), const DigitDivider(), - DigitTableCard( - key: const Key('stockReconStockOnHand'), - fraction: 2.5, - gap: kPadding, - element: { - localizations.translate( - i18.stockReconciliationDetails - .stockOnHand, - ): stockState.stockInHand - .toStringAsFixed(0), - }, - ), - DigitInfoCard( - margin: EdgeInsets.zero, - icon: Icons.info, - backgroundColor: - theme.colorScheme.tertiaryContainer, - iconColor: theme.colorScheme.surfaceTint, + LabelValueItem(label: localizations.translate( + i18.stockReconciliationDetails + .stockOnHand), value: stockState.stockInHand + .toStringAsFixed(0)), + InfoCard( + type: InfoType.info, description: localizations.translate( i18.stockReconciliationDetails .infoCardContent, @@ -548,56 +488,71 @@ class StockReconciliationPageState ), ), const SizedBox( - height: kPadding * 2, + height: spacer4, ), const DigitDivider(), const SizedBox( - height: kPadding, + height: spacer2, ), - DigitTextFormField( - key: const Key(_manualCountKey), - isRequired: true, - label: localizations.translate( - i18.stockReconciliationDetails - .manualCountLabel, - ), - formControlName: _manualCountKey, - keyboardType: - const TextInputType.numberWithOptions( - decimal: false, - ), - validationMessages: { - "required": (object) => - localizations.translate(i18 - .stockReconciliationDetails - .manualCountRequiredError), - "number": (object) => - localizations.translate(i18 - .stockReconciliationDetails - .manualCountInvalidType), - "min": (object) => - localizations.translate(i18 - .stockReconciliationDetails - .manualCountMinError), - "max": (object) => - localizations.translate(i18 - .stockReconciliationDetails - .manualCountMaxError), - }, + ReactiveWrapperField( + formControlName: _manualCountKey, + validationMessages: { + "required": (object) => i18 + .stockReconciliationDetails + .manualCountRequiredError, + "number": (object) => i18 + .stockReconciliationDetails + .manualCountInvalidType, + "min": (object) => i18 + .stockReconciliationDetails + .manualCountMinError, + "max": (object) => i18 + .stockReconciliationDetails + .manualCountMaxError, + }, + showErrors: (control) => control.invalid && control.touched, + builder: (field) { + return LabeledField( + label: localizations.translate( + i18.stockReconciliationDetails + .manualCountLabel, + ), + isRequired: true, + child: BaseDigitFormInput( + errorMessage: field.errorText, + keyboardType: + const TextInputType + .numberWithOptions( + decimal: false, + ), + initialValue: '0', + onChange: (value){ + field.control.markAsTouched(); + field.control.value = value; + }, + ), + ); + } ), - DigitTextFormField( - label: localizations.translate( - i18.stockReconciliationDetails - .commentsLabel, - ), - maxLines: 3, - minLines: 3, - formControlName: - _reconciliationCommentsKey, + ReactiveWrapperField( + formControlName: _reconciliationCommentsKey, + builder: (field){ + return InputField( + type: InputType.textArea, + label: localizations + .translate( + i18.stockReconciliationDetails + .commentsLabel, + ), + textAreaScroll: TextAreaScroll.smart, + onChange: (value){ + field.control.value= value; + }, + ); + }, ), ], ), - ), ], ), ); diff --git a/packages/inventory_management/lib/widgets/back_navigation_help_header.dart b/packages/inventory_management/lib/widgets/back_navigation_help_header.dart index 633e2c456..3fc512d89 100644 --- a/packages/inventory_management/lib/widgets/back_navigation_help_header.dart +++ b/packages/inventory_management/lib/widgets/back_navigation_help_header.dart @@ -1,5 +1,5 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; +import 'package:digit_ui_components/theme/spacers.dart'; import 'package:flutter/material.dart'; import 'package:inventory_management/blocs/app_localization.dart'; @@ -26,7 +26,7 @@ class BackNavigationHelpHeaderWidget extends StatelessWidget { final theme = Theme.of(context); return Padding( - padding: const EdgeInsets.all(kPadding / 2), + padding: const EdgeInsets.all(spacer1), child: Row( children: [ Expanded( @@ -55,7 +55,7 @@ class BackNavigationHelpHeaderWidget extends StatelessWidget { ], ), ), - SizedBox(width: showHelp ? kPadding * 2 : 0), + SizedBox(width: showHelp ? spacer2: 0), if (showHelp) TextButton( style: TextButton.styleFrom(padding: EdgeInsets.zero), diff --git a/packages/inventory_management/lib/widgets/inventory/no_facilities_assigned_dialog.dart b/packages/inventory_management/lib/widgets/inventory/no_facilities_assigned_dialog.dart index d7d0d9358..6388e73dd 100644 --- a/packages/inventory_management/lib/widgets/inventory/no_facilities_assigned_dialog.dart +++ b/packages/inventory_management/lib/widgets/inventory/no_facilities_assigned_dialog.dart @@ -1,5 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:digit_components/digit_components.dart'; +import 'package:digit_ui_components/enum/app_enums.dart'; +import 'package:digit_ui_components/widgets/atoms/digit_button.dart'; +import 'package:digit_ui_components/widgets/atoms/pop_up_card.dart'; +import 'package:digit_ui_components/widgets/molecules/show_pop_up.dart'; import 'package:flutter/material.dart'; import '../../../utils/i18_key_constants.dart' as i18; import '../../blocs/app_localization.dart'; @@ -7,29 +10,34 @@ import '../../blocs/app_localization.dart'; class NoFacilitiesAssignedDialog { static Future show( BuildContext context, InventoryLocalization localizations) { - return DigitDialog.show( - context, - options: DigitDialogOptions( - titleIcon: Icon( - Icons.warning, - color: Theme.of(context).colorScheme.error, - ), - titleText: localizations.translate( - i18.warehouseDetails.noFacilitiesAssigned, - ), - contentText: localizations.translate( - i18.warehouseDetails.noFacilitiesAssignedDescription, - ), - primaryAction: DigitDialogActions( - label: localizations.translate( - i18.common.corecommonclose, + return + showCustomPopup( + context: context, + builder: (popupContext) => Popup( + title: localizations.translate( + i18.warehouseDetails.noFacilitiesAssigned, ), - action: (dialogContext) { - Navigator.of(context, rootNavigator: true).pop(); - context.router.maybePop(); + onOutsideTap: () { + Navigator.of(popupContext).pop(); }, + description:localizations.translate( + i18.warehouseDetails.noFacilitiesAssignedDescription, + ), + type: PopUpType.alert, + actions: [ + DigitButton( + label: localizations.translate( + i18.common.corecommonclose, + ), + onPressed: () { + Navigator.of(popupContext, rootNavigator: true).pop(); + popupContext.router.maybePop(); + }, + type: DigitButtonType.primary, + size: DigitButtonSize.large, + ), + ], ), - ), - ); + ); } } diff --git a/packages/inventory_management/lib/widgets/reports/readonly_pluto_grid.dart b/packages/inventory_management/lib/widgets/reports/readonly_pluto_grid.dart index fd5d36d7d..e94fd8dbf 100644 --- a/packages/inventory_management/lib/widgets/reports/readonly_pluto_grid.dart +++ b/packages/inventory_management/lib/widgets/reports/readonly_pluto_grid.dart @@ -1,4 +1,4 @@ -import 'package:digit_components/theme/colors.dart'; +import 'package:digit_ui_components/theme/digit_extended_theme.dart'; import 'package:flutter/material.dart'; import 'package:pluto_grid/pluto_grid.dart'; import '../../../utils/i18_key_constants.dart' as i18; @@ -35,6 +35,7 @@ class ReadonlyDigitGrid extends LocalizedStatefulWidget { class ReadonlyDigitGridState extends LocalizedState { @override Widget build(BuildContext context) { + final theme = Theme.of(context); // Returns a PlutoGrid with the given configuration and data return PlutoGrid( mode: PlutoGridMode.readOnly, @@ -51,15 +52,15 @@ class ReadonlyDigitGridState extends LocalizedState { restoreAutoSizeAfterFrozenColumn: true, ), style: PlutoGridStyleConfig( - gridBorderColor: const DigitColors().seaShellGray, - oddRowColor: const DigitColors().seaShellGray, - borderColor: const DigitColors().seaShellGray, + gridBorderColor: theme.colorTheme.generic.background, + oddRowColor: theme.colorTheme.generic.background, + borderColor: theme.colorTheme.generic.background, iconColor: Colors.transparent, evenRowColor: Colors.transparent, - activatedColor: const DigitColors().burningOrange.withOpacity( + activatedColor: theme.colorTheme.primary.primary1.withOpacity( 0.2, ), - activatedBorderColor: const DigitColors().burningOrange.withOpacity( + activatedBorderColor: theme.colorTheme.primary.primary1.withOpacity( 0.8, ), enableRowColorAnimation: true, diff --git a/packages/inventory_management/pubspec.lock b/packages/inventory_management/pubspec.lock index bda7b1fa2..7d6603fd7 100644 --- a/packages/inventory_management/pubspec.lock +++ b/packages/inventory_management/pubspec.lock @@ -9,14 +9,6 @@ packages: url: "https://pub.dev" source: hosted version: "61.0.0" - _flutterfire_internals: - dependency: transitive - description: - name: _flutterfire_internals - sha256: "37a42d06068e2fe3deddb2da079a8c4d105f241225ba27b7122b37e9865fd8f7" - url: "https://pub.dev" - source: hosted - version: "1.3.35" analyzer: dependency: transitive description: @@ -380,9 +372,10 @@ packages: dart_mappable_builder: dependency: "direct dev" description: - path: "../dart_mappable_builder" - relative: true - source: path + name: dart_mappable_builder + sha256: ab5cf9086862d3fceb9773e945b5f95cc5471a28c782a4fc451bd400a4e0c64e + url: "https://pub.dev" + source: hosted version: "4.2.3" dart_style: dependency: transitive @@ -408,13 +401,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" - digit_components: - dependency: transitive - description: - path: "../digit_components" - relative: true - source: path - version: "1.0.2+1" digit_data_model: dependency: "direct main" description: @@ -422,13 +408,6 @@ packages: relative: true source: path version: "1.0.5-dev.1" - digit_firebase_services: - dependency: "direct overridden" - description: - path: "../digit_firebase_services" - relative: true - source: path - version: "0.0.1" digit_scanner: dependency: "direct main" description: @@ -485,14 +464,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.18.0" - easy_stepper: - dependency: transitive - description: - name: easy_stepper - sha256: "63f66314a509ec690c8152a41288961fd96ba9e92ef184299f068a5e78bd16ad" - url: "https://pub.dev" - source: hosted - version: "0.8.5+1" fake_async: dependency: transitive description: @@ -557,46 +528,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.3+3" - firebase_core: - dependency: transitive - description: - name: firebase_core - sha256: "26de145bb9688a90962faec6f838247377b0b0d32cc0abecd9a4e43525fc856c" - url: "https://pub.dev" - source: hosted - version: "2.32.0" - firebase_core_platform_interface: - dependency: transitive - description: - name: firebase_core_platform_interface - sha256: b94b217e3ad745e784960603d33d99471621ecca151c99c670869b76e50ad2a6 - url: "https://pub.dev" - source: hosted - version: "5.3.1" - firebase_core_web: - dependency: transitive - description: - name: firebase_core_web - sha256: "362e52457ed2b7b180964769c1e04d1e0ea0259fdf7025fdfedd019d4ae2bd88" - url: "https://pub.dev" - source: hosted - version: "2.17.5" - firebase_crashlytics: - dependency: transitive - description: - name: firebase_crashlytics - sha256: "9897c01efaa950d2f6da8317d12452749a74dc45f33b46390a14cfe28067f271" - url: "https://pub.dev" - source: hosted - version: "3.5.7" - firebase_crashlytics_platform_interface: - dependency: transitive - description: - name: firebase_crashlytics_platform_interface - sha256: "16a71e08fbf6e00382816e1b13397898c29a54fa0ad969c2c2a3b82a704877f0" - url: "https://pub.dev" - source: hosted - version: "3.6.35" fixnum: dependency: transitive description: @@ -642,62 +573,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.13" - flutter_focus_watcher: - dependency: transitive - description: - name: flutter_focus_watcher - sha256: a72ee539ae0237961308a25839887ca93a0b1cb6f87b0d492b139c8fccff8e79 - url: "https://pub.dev" - source: hosted - version: "2.0.0" - flutter_keyboard_visibility: - dependency: transitive - description: - name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" - url: "https://pub.dev" - source: hosted - version: "5.4.1" - flutter_keyboard_visibility_linux: - dependency: transitive - description: - name: flutter_keyboard_visibility_linux - sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08" - url: "https://pub.dev" - source: hosted - version: "1.0.0" - flutter_keyboard_visibility_macos: - dependency: transitive - description: - name: flutter_keyboard_visibility_macos - sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086 - url: "https://pub.dev" - source: hosted - version: "1.0.0" - flutter_keyboard_visibility_platform_interface: - dependency: transitive - description: - name: flutter_keyboard_visibility_platform_interface - sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4 - url: "https://pub.dev" - source: hosted - version: "2.0.0" - flutter_keyboard_visibility_web: - dependency: transitive - description: - name: flutter_keyboard_visibility_web - sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1 - url: "https://pub.dev" - source: hosted - version: "2.0.0" - flutter_keyboard_visibility_windows: - dependency: transitive - description: - name: flutter_keyboard_visibility_windows - sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73 - url: "https://pub.dev" - source: hosted - version: "1.0.0" flutter_lints: dependency: "direct dev" description: @@ -748,14 +623,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_typeahead: - dependency: transitive - description: - name: flutter_typeahead - sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818 - url: "https://pub.dev" - source: hosted - version: "4.8.0" flutter_web_plugins: dependency: transitive description: flutter @@ -1193,22 +1060,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" - package_info_plus: - dependency: transitive - description: - name: package_info_plus - sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918 - url: "https://pub.dev" - source: hosted - version: "8.0.2" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66 - url: "https://pub.dev" - source: hosted - version: "3.0.1" path: dependency: "direct main" description: @@ -1313,14 +1164,6 @@ packages: url: "https://pub.dev" source: hosted version: "8.0.0" - pointer_interceptor: - dependency: transitive - description: - name: pointer_interceptor - sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22 - url: "https://pub.dev" - source: hosted - version: "0.9.3+7" pool: dependency: transitive description: @@ -1353,14 +1196,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.3" - reactive_flutter_typeahead: - dependency: transitive - description: - name: reactive_flutter_typeahead - sha256: a5dbca4b537bd9dde245d4228e1a6ce937c05cd77c57ed45b9c05135540d5f1a - url: "https://pub.dev" - source: hosted - version: "2.1.1" reactive_forms: dependency: "direct main" description: @@ -1377,14 +1212,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" - remove_emoji_input_formatter: - dependency: transitive - description: - name: remove_emoji_input_formatter - sha256: "82d195984f890de7a8fea936c698848e78c1a67ccefe18db3baf9f7a3bc0177f" - url: "https://pub.dev" - source: hosted - version: "0.0.1+1" rxdart: dependency: transitive description: diff --git a/packages/inventory_management/pubspec.yaml b/packages/inventory_management/pubspec.yaml index d3678b9ee..63dd4aec3 100644 --- a/packages/inventory_management/pubspec.yaml +++ b/packages/inventory_management/pubspec.yaml @@ -24,7 +24,9 @@ dependencies: dart_mappable: ^4.2.2 drift: ^2.18.0 auto_route: ^8.1.3 - digit_data_model: ^1.0.5-dev.1 + digit_data_model: + path: + ../digit_data_model collection: ^1.18.0 dio: ^5.4.3+1 location: ^6.0.2 @@ -37,7 +39,9 @@ dependencies: path: ^1.8.2 drift_db_viewer: ^2.0.0 recase: ^4.1.0 - digit_scanner: ^1.0.3+1 + digit_scanner: + path: + ../digit_scanner pluto_grid: ^8.0.0 dev_dependencies: