From 1c9101d8abe10453664527002148e66ea8863324 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Wed, 6 Sep 2023 10:05:25 +0300 Subject: [PATCH] Fix pm entry empty values when scroll --- .../widgets/pentry/pentry_info_form.dart | 329 +++++++++--------- 1 file changed, 166 insertions(+), 163 deletions(-) diff --git a/lib/views/widgets/pentry/pentry_info_form.dart b/lib/views/widgets/pentry/pentry_info_form.dart index 78f4e09d..f5f1f6a5 100644 --- a/lib/views/widgets/pentry/pentry_info_form.dart +++ b/lib/views/widgets/pentry/pentry_info_form.dart @@ -36,171 +36,174 @@ class _PentryInfoFormState extends State { widget.model?.files ??= []; final subtitle = AppLocalization.of(context).subtitle; final userProvider = Provider.of(context); - return ListView( + return Padding( padding: EdgeInsets.only( top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)), - shrinkWrap: true, - physics: const ClampingScrollPhysics(), - children: [ - const SizedBox( - height: 8, - ), - const ASubTitle("PPM Visit Status"), - if (widget.enableValidate && widget.model.ppmVisitStatus == null) - ASubTitle( - subtitle.requiredWord, - color: Colors.red, - ), - const SizedBox( - height: 4, - ), - PentryVisitsStatusMenu( - initialValue: widget.model.ppmVisitStatus, - onSelect: (status) { - if (status != null) { - widget.model.ppmVisitStatus = status; - } - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Timer"), - if (widget.enableValidate && widget.model?.timer?.endAt == null) - ASubTitle( - subtitle.requiredWord, - color: Colors.red, - ), - const SizedBox( - height: 4, - ), - AppTimer( - timer: widget.model.timer, - enabled: widget.model.timer.endAt == null, - onChange: (timer) async { - widget.model.timer = timer; - return true; - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Status"), - if (widget.enableValidate && widget.model.status == null) - ASubTitle( - subtitle.requiredWord, - color: Colors.red, - ), - const SizedBox( - height: 4, - ), - PentryStatusMenu( - initialValue: widget.model.status, - onSelect: (status) { - widget.model.status = status; - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Actual Visit Date"), - if (widget.enableValidate && widget.model.actualVisitDate == null) - ASubTitle( - subtitle.requiredWord, - color: Colors.red, - ), - const SizedBox( - height: 4, - ), - ADatePicker( - date: widget.model.actualVisitDate, - from: DateTime.now().subtract(const Duration(days: 30)), - onDatePicker: (date) { - if (date == null) return; - widget.model.actualVisitDate = date; - setState(() {}); - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Expected Visit Date"), - if (widget.enableValidate && widget.model.expectedVisitDate == null) - ASubTitle( - subtitle.requiredWord, - color: Colors.red, - ), - const SizedBox( - height: 4, - ), - ADatePicker( - date: widget.model.expectedVisitDate, - from: DateTime.now().subtract(const Duration(days: 30)), - onDatePicker: (date) { - if (date == null) return; - widget.model.expectedVisitDate = date; - setState(() {}); - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Traveling Hours"), - const SizedBox( - height: 4, - ), - ATextFormField( - initialValue: (widget.model.travelingHours ?? "").toString(), - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.titleMedium, - textInputType: TextInputType.number, - onChange: (value) { - widget.model.travelingHours = value; - }, - ), - const SizedBox(height: 12), - MultiFilesPicker(label: "PPM Attachments", files: widget.model.files), - // AMiniOneFilePicker( - // //error: _validate && _serviceReport.image == null, - // file: widget.model.file, - // onPick: (file) { - // widget.model.file = file; - // }, - // ), - const SizedBox( - height: 8, - ), - const ASubTitle("Nurse Signature"), - ESignature( - oldSignature: widget.model.signatureNurse, - newSignature: widget.model.localNurseSignature, - onChange: (signature) { - if (signature == null || signature.isEmpty) { - return; - } - widget.model.localNurseSignature = signature; - widget.model.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }, - ), - const SizedBox( - height: 8, - ), - const ASubTitle("Engineer Signature"), - ESignature( - oldSignature: widget.model.signatureEngineer, - newSignature: widget.model.localNurseSignature, - onChange: (signature) { - if (signature == null || signature.isEmpty) { - return; - } - widget.model.localNurseSignature = signature; - widget.model.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; - }, - ), - const SizedBox( - height: 8, - ), - ], + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox( + height: 8, + ), + const ASubTitle("PPM Visit Status"), + if (widget.enableValidate && widget.model.ppmVisitStatus == null) + ASubTitle( + subtitle.requiredWord, + color: Colors.red, + ), + const SizedBox( + height: 4, + ), + PentryVisitsStatusMenu( + initialValue: widget.model.ppmVisitStatus, + onSelect: (status) { + if (status != null) { + widget.model.ppmVisitStatus = status; + } + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Timer"), + if (widget.enableValidate && widget.model?.timer?.endAt == null) + ASubTitle( + subtitle.requiredWord, + color: Colors.red, + ), + const SizedBox( + height: 4, + ), + AppTimer( + timer: widget.model.timer, + enabled: widget.model.timer.endAt == null, + onChange: (timer) async { + widget.model.timer = timer; + return true; + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Status"), + if (widget.enableValidate && widget.model.status == null) + ASubTitle( + subtitle.requiredWord, + color: Colors.red, + ), + const SizedBox( + height: 4, + ), + PentryStatusMenu( + initialValue: widget.model.status, + onSelect: (status) { + widget.model.status = status; + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Actual Visit Date"), + if (widget.enableValidate && widget.model.actualVisitDate == null) + ASubTitle( + subtitle.requiredWord, + color: Colors.red, + ), + const SizedBox( + height: 4, + ), + ADatePicker( + date: widget.model.actualVisitDate, + from: DateTime.now().subtract(const Duration(days: 30)), + onDatePicker: (date) { + if (date == null) return; + widget.model.actualVisitDate = date; + setState(() {}); + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Expected Visit Date"), + if (widget.enableValidate && widget.model.expectedVisitDate == null) + ASubTitle( + subtitle.requiredWord, + color: Colors.red, + ), + const SizedBox( + height: 4, + ), + ADatePicker( + date: widget.model.expectedVisitDate, + from: DateTime.now().subtract(const Duration(days: 30)), + onDatePicker: (date) { + if (date == null) return; + widget.model.expectedVisitDate = date; + setState(() {}); + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Traveling Hours"), + const SizedBox( + height: 4, + ), + ATextFormField( + initialValue: (widget.model.travelingHours ?? "").toString(), + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.number, + onChange: (value) { + widget.model.travelingHours = value; + }, + ), + const SizedBox(height: 12), + MultiFilesPicker(label: "PPM Attachments", files: widget.model.files), + // AMiniOneFilePicker( + // //error: _validate && _serviceReport.image == null, + // file: widget.model.file, + // onPick: (file) { + // widget.model.file = file; + // }, + // ), + const SizedBox( + height: 8, + ), + const ASubTitle("Nurse Signature"), + ESignature( + oldSignature: widget.model.signatureNurse, + newSignature: widget.model.localNurseSignature, + onChange: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + widget.model.localNurseSignature = signature; + widget.model.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), + const SizedBox( + height: 8, + ), + const ASubTitle("Engineer Signature"), + ESignature( + oldSignature: widget.model.signatureEngineer, + newSignature: widget.model.localEngineerSignature, + onChange: (signature) { + if (signature == null || signature.isEmpty) { + return; + } + widget.model.localEngineerSignature = signature; + widget.model.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; + }, + ), + const SizedBox( + height: 8, + ), + ], + ), + ), ); } }