@ -9,6 +9,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
import ' package:test_sa/extensions/string_extensions.dart ' ;
import ' package:test_sa/extensions/text_extensions.dart ' ;
import ' package:test_sa/extensions/widget_extensions.dart ' ;
import ' package:test_sa/helper/utils.dart ' ;
import ' package:test_sa/models/lookup.dart ' ;
import ' package:test_sa/modules/asset_delivery_module/helper_function.dart ' ;
import ' package:test_sa/modules/asset_delivery_module/models/asset_delivery_data_model.dart ' ;
@ -28,6 +29,7 @@ import 'package:test_sa/new_views/app_style/app_color.dart';
import ' package:test_sa/new_views/common_widgets/app_lazy_loading.dart ' ;
import ' package:test_sa/new_views/common_widgets/default_app_bar.dart ' ;
import ' package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart ' ;
import ' package:test_sa/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart ' ;
import ' package:test_sa/views/widgets/date_and_time/date_picker.dart ' ;
import ' package:test_sa/views/widgets/loaders/no_data_found.dart ' ;
import ' ../../../../new_views/common_widgets/app_filled_button.dart ' ;
@ -77,9 +79,11 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
) ,
] ) ;
model = results [ 0 ] as DeliveryInspectionFormModel ;
setState ( ( ) {
isLoading = false ;
} ) ;
if ( mounted ) {
setState ( ( ) {
isLoading = false ;
} ) ;
}
}
@ override
@ -91,12 +95,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
Widget build ( BuildContext context ) {
return Scaffold (
backgroundColor: Theme . of ( context ) . scaffoldBackgroundColor ,
/ / appBar: DefaultAppBar (
/ / title: ' Delivery Inspection ' . addTranslation ,
/ / onBackPress: ( ) {
/ / Navigator . pop ( context ) ;
/ / } ,
/ / ) ,
body: isLoading
? const CircularProgressIndicator ( color: AppColor . primary10 ) . center
: Form (
@ -104,52 +102,39 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
child: Column (
children: [
SingleChildScrollView (
padding: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 12 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
if ( ! viewOnly ) . . . [ inspectionDetailsForm ( ) ] else . . . [ inspectionDetails ( ) ] ,
8. height ,
Text (
' Total Time ' . addTranslation ,
style: AppTextStyles . bodyText . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . black10 ) ,
) ,
8. height ,
Text (
formatInspectionDuration ( model . totalTime ) ,
style: AppTextStyles . bodyText2 . copyWith (
color: context . isDark ? AppColor . neutral30 : AppColor . neutral120 ,
) ,
) ,
/ / Text (
/ / model . totalTime ! = null ? ' ${ model . totalTime . toString ( ) } hours ' : ' - ' ,
/ / style: AppTextStyles . bodyText2 . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . neutral120 ) ,
/ / ) ,
8. height ,
const Divider ( ) . defaultStyle ( context ) ,
Text (
" Lines " ,
style: AppTextStyles . heading6 . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . black10 ) ,
) ,
8. height ,
linesList ( context ) ,
] ,
) . toShadowContainer ( context , borderRadius: 20 , padding: 12 ) )
. expanded ,
padding: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 12 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
if ( ! viewOnly ) . . . [ inspectionDetailsForm ( ) ] else . . . [ inspectionDetails ( ) ] ,
20. height ,
Text (
" Lines " ,
style: AppTextStyles . heading6 . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . black10 ) ,
) ,
8. height ,
linesList ( context ) ,
] ,
) ) . expanded ,
FooterActionButton . footerContainer (
context: context ,
child: ! viewOnly
? Column (
children: [
AppFilledButton (
buttonColor: AppColor . primary10 ,
label: ' Attachments ' . addTranslation ,
maxWidth: true ,
onPressed: ( ) {
HelperFunction . attachmentTap ( context: context , assetDeliveryProvider: assetDeliveryProvider ! , deliveryTableItemId: widget . deliveryTableModel . id ) ;
} ) ,
16. height ,
Row (
children: [
AppFilledButton (
buttonColor: AppColor . primary10 ,
label: ' Attachments ' . addTranslation ,
maxWidth: true ,
onPressed: ( ) {
HelperFunction . attachmentTap ( context: context , assetDeliveryProvider: assetDeliveryProvider ! , deliveryTableItemId: widget . deliveryTableModel . id ) ;
} ) . expanded ,
12. width ,
AppFilledButton ( buttonColor: AppColor . primary10 , label: ' Save ' . addTranslation , maxWidth: true , onPressed: _saveTap ) . expanded ,
] ,
) ,
12. height ,
Row (
children: [
AppFilledButton (
@ -247,6 +232,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
Widget inspectionDetailsForm ( ) {
return Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
_inspectionTile (
title: ' Inspected by ' . addTranslation ,
@ -264,7 +250,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
}
} ,
) ,
8. height ,
_inspectionTile (
title: ' Approved by ' . addTranslation ,
@ -285,13 +270,13 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
if ( widget . requestModel ? . paymentTerm ? . value = = 2 ) . . . [
8. height ,
_inspectionTile (
title: ' Third Approved by ' . addTranslation ,
title: ' Third Approver ' . addTranslation ,
model: model . thirdApprovalModel ,
isHmg: widget . requestModel ? . isHMG = = true ,
onTap: ( ) async {
final result = await showInspectionBottomSheet (
context ,
title: ' Third Approved by ' . addTranslation ,
title: ' Third Approver ' . addTranslation ,
isHmg: widget . requestModel ? . isHMG = = true ,
initialModel: model . thirdApprovalModel ? ? InspectionPersonModel ( ) ,
) ;
@ -301,57 +286,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
} ,
) ,
] ,
/ / if ( widget . requestModel ? . isHMG = = true ) . . . [
/ / OracleUserAutoCompleteField (
/ / clearAfterPick: false ,
/ / initialValue: model . deliveryInspectionInspectedBy ? ? ' ' ,
/ / label: ' Inspected by ' . addTranslation ,
/ / onPick: ( value ) {
/ / model . deliveryInspectionInspectedBy = value . fullName ;
/ / setState ( ( ) { } ) ;
/ / } ,
/ / onChanged: ( value ) { } ,
/ / ) ,
/ / 8. height ,
/ / OracleUserAutoCompleteField (
/ / clearAfterPick: false ,
/ / initialValue: model . deliveryInspectionApprovedBy ? ? ' ' ,
/ / label: ' Approved by ' . addTranslation ,
/ / onChanged: ( value ) { } ,
/ / onPick: ( value ) {
/ / model . deliveryInspectionApprovedBy = value . fullName ;
/ / setState ( ( ) { } ) ;
/ / } ,
/ / ) ,
/ / ] / / No HMG user free text insted of dropdown . . .
/ / else . . . [
/ / AppTextFormField (
/ / labelText: ' Inspected by ' . addTranslation ,
/ / backgroundColor: AppColor . fieldBgColor ( context ) ,
/ / initialValue: model . deliveryInspectionInspectedBy ? ? ' ' ,
/ / textAlign: TextAlign . center ,
/ / labelStyle: AppTextStyles . textFieldLabelStyle ,
/ / showShadow: false ,
/ / onChange: ( value ) {
/ / model . deliveryInspectionInspectedBy = value ;
/ / } ,
/ / style: Theme . of ( context ) . textTheme . titleMedium ,
/ / ) ,
/ / 8. height ,
/ / AppTextFormField (
/ / labelText: ' Approved by ' . addTranslation ,
/ / backgroundColor: AppColor . fieldBgColor ( context ) ,
/ / initialValue: model . deliveryInspectionApprovedBy ? ? ' ' ,
/ / textAlign: TextAlign . center ,
/ / labelStyle: AppTextStyles . textFieldLabelStyle ,
/ / showShadow: false ,
/ / onChange: ( value ) {
/ / model . deliveryInspectionApprovedBy = value ;
/ / } ,
/ / style: Theme . of ( context ) . textTheme . titleMedium ,
/ / ) ,
/ / ] ,
8. height ,
ADatePicker (
label: ' Inspected Date/Time From ' . addTranslation ,
@ -385,7 +319,6 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
setState ( ( ) { } ) ;
} ,
) ,
8. height ,
ADatePicker (
label: ' Inspected Date/Time To ' . addTranslation ,
@ -424,8 +357,20 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
setState ( ( ) { } ) ;
} ,
) ,
8. height ,
Text (
' Total Time ' . addTranslation ,
style: AppTextStyles . bodyText . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . black10 ) ,
) ,
8. height ,
Text (
formatInspectionDuration ( model . totalTime ) ,
style: AppTextStyles . bodyText2 . copyWith (
color: context . isDark ? AppColor . neutral30 : AppColor . neutral120 ,
) ,
) ,
] ,
) ;
) .toShadowContainer ( context , borderRadius: 20 , padding: 12 ) ;
}
bool _validateInspectionDates ( { DateTime ? from , DateTime ? to } ) {
@ -552,8 +497,20 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
model . deliveryInspectionInspectedDateTo ! = null ? model . deliveryInspectionInspectedDateTo ! . toString ( ) . toServiceRequestDetailsFormat : ' - ' ,
style: AppTextStyles . bodyText2 . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . neutral120 ) ,
) ,
8. height ,
Text (
' Total Time ' . addTranslation ,
style: AppTextStyles . bodyText . copyWith ( color: context . isDark ? AppColor . neutral30 : AppColor . black10 ) ,
) ,
8. height ,
Text (
formatInspectionDuration ( model . totalTime ) ,
style: AppTextStyles . bodyText2 . copyWith (
color: context . isDark ? AppColor . neutral30 : AppColor . neutral120 ,
) ,
) ,
] ,
) ;
) .toShadowContainer ( context , borderRadius: 20 , padding: 12 ) ;
}
Widget _inspectionTile ( {
@ -566,7 +523,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
onTap: onTap ,
borderRadius: BorderRadius . circular ( 12 ) ,
child: Container (
padding: const EdgeInsets . all ( 1 4 ) ,
padding: const EdgeInsets . all ( 1 2 ) ,
decoration: BoxDecoration (
color: AppColor . fieldBgColor ( context ) ,
borderRadius: BorderRadius . circular ( 12 ) ,
@ -575,6 +532,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
children: [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisSize: MainAxisSize . min ,
children: [
Text ( title , style: AppTextStyles . textFieldLabelStyle ) ,
6. height ,
@ -603,27 +561,34 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
) ;
}
Future < Lookup ? > showAttachmentTypePicker ( ) {
return showDialog < Lookup > (
context: context ,
builder: ( _ ) {
return AlertDialog (
content: SingleItemDropDownMenu < Lookup , AttachmentTypeLookupProvider > (
context: context ,
title: context . translation . reason ,
showAsFullScreenDialog: false ,
onSelect: ( value ) {
Navigator . pop ( context , value ) ;
} ,
) ,
) ;
} ,
) ;
void _cancelTap ( ) async {
HelperFunction . cancelRequest ( context: context , itemId: widget . deliveryTableModel . id ! , requestId: widget . requestModel ? . id ) ;
/ / showDialog (
/ / context: context ,
/ / builder: ( BuildContext cxt ) = > AcknowledgeWorkDialog (
/ / message: " Are you sure you want to mark this request as cancel " ,
/ / confirmButtonText: ' Ok ' ,
/ / cancelButtonText: ' Cancel ' ,
/ / onSave: ( ) async {
/ / showDialog ( context: context , barrierDismissible: false , builder: ( context ) = > const AppLazyLoading ( ) ) ;
/ / await assetDeliveryProvider ! . changeDeliveryStatusToCancel ( itemId: widget . deliveryTableModel . id ) . then ( ( status ) async {
/ / Navigator . pop ( context ) ;
/ / if ( status ) {
/ / Navigator . pop ( context ) ;
/ / await assetDeliveryProvider ! . getAssetDeliveryTableListById ( requestId: widget . requestModel ? . id ) ;
/ / }
/ / } ) ;
/ / } ,
/ / onDiscard: ( ) { } ,
/ / ) ,
/ / ) ;
}
void _cancelTap ( ) async {
void _saveTap ( ) async {
_formKey . currentState ! . save ( ) ;
showDialog ( context: context , barrierDismissible: false , builder: ( context ) = > const AppLazyLoading ( ) ) ;
await assetDeliveryProvider ! . changeDeliveryStatusToCancel ( itemId: widget . deliveryTableModel . id ) . then ( ( status ) async {
model . assetDeliveryExternalDeliveryId = widget . deliveryTableModel . id ;
await assetDeliveryProvider ! . saveMasterInfoDeliveryInspection ( requestPayload: model . toJson ( ) ) . then ( ( status ) async {
Navigator . pop ( context ) ;
if ( status ) {
Navigator . pop ( context ) ;
@ -678,8 +643,8 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
void _changeStatusTap ( ) async {
_formKey . currentState ! . save ( ) ;
showDialog ( context: context , barrierDismissible: false , builder: ( context ) = > const AppLazyLoading ( ) ) ;
model . assetDeliveryExternalDeliveryId = widget . deliveryTableModel . id ;
await assetDeliveryProvider ! . changeDeliveryStatus ( requestPayload: model . toJson ( ) ) . then ( ( status ) async {
/ / await assetDeliveryProvider ! . changeDeliveryStatus ( requestPayload: model . toJson ( ) ) . then ( ( status ) async {
await assetDeliveryProvider ! . changeDeliveryStatus ( itemId: widget . deliveryTableModel . id ) . then ( ( status ) async {
Navigator . pop ( context ) ;
if ( status ) {
Navigator . pop ( context ) ;
@ -707,6 +672,7 @@ class _DeliveryInspectionFormViewState extends State<DeliveryInspectionFormView>
return InspectionPersonBottomSheet (
title: title ,
isHmg: isHmg ,
tableId: widget . deliveryTableModel . id ,
model: InspectionPersonModel (
name: initialModel . name ,
email: initialModel . email ,