From 59ca4277a9fc2b8290edcba9c6e6890c1b5a86ae Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Sun, 4 Jun 2023 14:13:49 +0300 Subject: [PATCH] Enhancements --- .../pages/user/requests/create_request.dart | 8 +++-- .../report/create_service_report.dart | 31 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/views/pages/user/requests/create_request.dart b/lib/views/pages/user/requests/create_request.dart index fb676de4..99ff8077 100644 --- a/lib/views/pages/user/requests/create_request.dart +++ b/lib/views/pages/user/requests/create_request.dart @@ -53,6 +53,7 @@ class CreateRequestPageState extends State { ServiceRequest _serviceRequest; final List _deviceImages = []; bool _isLoading = false; + bool _showDatePicker = false; Device _device; Subtitle _subtitle; final GlobalKey _formKey = GlobalKey(); @@ -215,11 +216,12 @@ class CreateRequestPageState extends State { onSelect: (status) { _dateTime = null; _serviceRequest.firstAction = status; + _showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit"; _serviceRequestsProvider.notifyListeners(); }, ), - if (_serviceRequest.firstAction != null) 12.height, - if (_serviceRequest.firstAction != null) + if (_showDatePicker) 12.height, + if (_showDatePicker) ADatePicker( date: _dateTime, from: DateTime.now(), @@ -288,7 +290,7 @@ class CreateRequestPageState extends State { Fluttertoast.showToast(msg: _subtitle.pickDevice); return; } - if (_serviceRequest.firstAction != null && _dateTime == null) { + if (_serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit" && _dateTime == null) { Fluttertoast.showToast(msg: _subtitle.noDateFound); return; } diff --git a/lib/views/pages/user/requests/report/create_service_report.dart b/lib/views/pages/user/requests/report/create_service_report.dart index b2c6cbc2..eeb512c7 100644 --- a/lib/views/pages/user/requests/report/create_service_report.dart +++ b/lib/views/pages/user/requests/report/create_service_report.dart @@ -55,6 +55,7 @@ class _CreateServiceReportState extends State with TickerPr bool _validate = false; ServiceReport _serviceReport; bool _isLoading = false; + bool _showCommentField = false; Subtitle _subtitle; File _image; @@ -282,6 +283,8 @@ class _CreateServiceReportState extends State with TickerPr request: widget.request, onSelect: (status) { _serviceReport.status = status; + _showCommentField = _serviceReport.status?.name == "Resolved"; + setState(() {}); }, ), ], @@ -328,6 +331,21 @@ class _CreateServiceReportState extends State with TickerPr ), ], ), + if (_showCommentField) + const SizedBox( + height: 8, + ), + if (_showCommentField) + ATextFormField( + initialValue: _serviceReport?.comment, + hintText: _subtitle.comment, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + textInputType: TextInputType.multiline, + onSaved: (value) { + _serviceReport.comment = value; + }, + ), SizedBox( height: 8 * AppStyle.getScaleFactor(context), ), @@ -587,19 +605,6 @@ class _CreateServiceReportState extends State with TickerPr _serviceReport.travelingExpense = int.tryParse(value) ?? 0; }, ), - const SizedBox( - height: 8, - ), - ATextFormField( - initialValue: _serviceReport?.comment, - hintText: _subtitle.comment, - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.titleMedium, - textInputType: TextInputType.multiline, - onSaved: (value) { - _serviceReport.comment = value; - }, - ), const SizedBox( height: 8,