Enhancements

merge-requests/31/head
zaid_daoud 3 years ago
parent 9346990626
commit 59ca4277a9

@ -53,6 +53,7 @@ class CreateRequestPageState extends State<CreateRequestPage> {
ServiceRequest _serviceRequest; ServiceRequest _serviceRequest;
final List<File> _deviceImages = []; final List<File> _deviceImages = [];
bool _isLoading = false; bool _isLoading = false;
bool _showDatePicker = false;
Device _device; Device _device;
Subtitle _subtitle; Subtitle _subtitle;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@ -215,11 +216,12 @@ class CreateRequestPageState extends State<CreateRequestPage> {
onSelect: (status) { onSelect: (status) {
_dateTime = null; _dateTime = null;
_serviceRequest.firstAction = status; _serviceRequest.firstAction = status;
_showDatePicker = _serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit";
_serviceRequestsProvider.notifyListeners(); _serviceRequestsProvider.notifyListeners();
}, },
), ),
if (_serviceRequest.firstAction != null) 12.height, if (_showDatePicker) 12.height,
if (_serviceRequest.firstAction != null) if (_showDatePicker)
ADatePicker( ADatePicker(
date: _dateTime, date: _dateTime,
from: DateTime.now(), from: DateTime.now(),
@ -288,7 +290,7 @@ class CreateRequestPageState extends State<CreateRequestPage> {
Fluttertoast.showToast(msg: _subtitle.pickDevice); Fluttertoast.showToast(msg: _subtitle.pickDevice);
return; return;
} }
if (_serviceRequest.firstAction != null && _dateTime == null) { if (_serviceRequest.firstAction != null && _serviceRequest.firstAction.name == "Need a visit" && _dateTime == null) {
Fluttertoast.showToast(msg: _subtitle.noDateFound); Fluttertoast.showToast(msg: _subtitle.noDateFound);
return; return;
} }

@ -55,6 +55,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
bool _validate = false; bool _validate = false;
ServiceReport _serviceReport; ServiceReport _serviceReport;
bool _isLoading = false; bool _isLoading = false;
bool _showCommentField = false;
Subtitle _subtitle; Subtitle _subtitle;
File _image; File _image;
@ -282,6 +283,8 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
request: widget.request, request: widget.request,
onSelect: (status) { onSelect: (status) {
_serviceReport.status = status; _serviceReport.status = status;
_showCommentField = _serviceReport.status?.name == "Resolved";
setState(() {});
}, },
), ),
], ],
@ -328,6 +331,21 @@ class _CreateServiceReportState extends State<CreateServiceReport> 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( SizedBox(
height: 8 * AppStyle.getScaleFactor(context), height: 8 * AppStyle.getScaleFactor(context),
), ),
@ -587,19 +605,6 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_serviceReport.travelingExpense = int.tryParse(value) ?? 0; _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( const SizedBox(
height: 8, height: 8,

Loading…
Cancel
Save