@ -2,16 +2,16 @@ import 'dart:convert';
import ' dart:io ' ;
import ' dart:io ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/rendering.dart ' ;
import ' package:fluttertoast/fluttertoast.dart ' ;
import ' package:fluttertoast/fluttertoast.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:provider/provider.dart ' ;
import ' ../../../../../api/user_api_client.dart ' ;
import ' ../../../../../controllers/http_status_manger/http_status_manger.dart ' ;
import ' ../../../../../controllers/http_status_manger/http_status_manger.dart ' ;
import ' ../../../../../controllers/localization/localization.dart ' ;
import ' ../../../../../controllers/localization/localization.dart ' ;
import ' ../../../../../controllers/providers/api/service_requests_provider.dart ' ;
import ' ../../../../../controllers/providers/api/service_requests_provider.dart ' ;
import ' ../../../../../controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart ' ;
import ' ../../../../../controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart ' ;
import ' ../../../../../controllers/providers/api/user_provider.dart ' ;
import ' ../../../../../controllers/providers/settings/setting_provider.dart ' ;
import ' ../../../../../controllers/providers/settings/setting_provider.dart ' ;
import ' ../../../../../controllers/providers/user_provider.dart ' ;
import ' ../../../../../controllers/validator/validator.dart ' ;
import ' ../../../../../controllers/validator/validator.dart ' ;
import ' ../../../../../models/part.dart ' ;
import ' ../../../../../models/part.dart ' ;
import ' ../../../../../models/service_report.dart ' ;
import ' ../../../../../models/service_report.dart ' ;
@ -39,7 +39,7 @@ import '../../../../widgets/titles/app_sub_title.dart';
class EditServiceReport extends StatefulWidget {
class EditServiceReport extends StatefulWidget {
static final String id = " /edit-service-report " ;
static final String id = " /edit-service-report " ;
final ServiceRequest request ;
final ServiceRequest request ;
final ServiceReport report ;
final ServiceReport report ;
const EditServiceReport ( { Key ? key , required this . request , required this . report } ) : super ( key: key ) ;
const EditServiceReport ( { Key ? key , required this . request , required this . report } ) : super ( key: key ) ;
@ -47,9 +47,7 @@ class EditServiceReport extends StatefulWidget {
_EditServiceReportState createState ( ) = > _EditServiceReportState ( ) ;
_EditServiceReportState createState ( ) = > _EditServiceReportState ( ) ;
}
}
class _EditServiceReportState extends State < EditServiceReport > with TickerProviderStateMixin {
class _EditServiceReportState extends State < EditServiceReport > with TickerProviderStateMixin {
late UserProvider _userProvider ;
late UserProvider _userProvider ;
late SettingProvider _settingProvider ;
late SettingProvider _settingProvider ;
late ServiceRequestsProvider _serviceRequestsProvider ;
late ServiceRequestsProvider _serviceRequestsProvider ;
@ -77,6 +75,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_workPreformedController . dispose ( ) ;
_workPreformedController . dispose ( ) ;
super . dispose ( ) ;
super . dispose ( ) ;
}
}
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
_userProvider = Provider . of < UserProvider > ( context ) ;
_userProvider = Provider . of < UserProvider > ( context ) ;
@ -98,43 +97,46 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ListView (
ListView (
children: [
children: [
/ / AppNameBar ( ) ,
/ / AppNameBar ( ) ,
const SizedBox ( height: 16 , ) ,
const SizedBox (
height: 16 ,
) ,
Center (
Center (
child: Padding (
child: Padding (
padding: const EdgeInsets . all ( 8.0 ) ,
padding: const EdgeInsets . all ( 8.0 ) ,
child: Text (
child: Text (
_subtitle . editServiceReport ,
_subtitle . editServiceReport ,
style: Theme . of ( context ) . textTheme . headline5 ? . copyWith (
style: Theme . of ( context ) . textTheme . headline5 ? . copyWith ( color: AColors . cyan , fontSize: 28 , fontWeight: FontWeight . bold ) ,
color: AColors . cyan ,
fontSize: 28 ,
fontWeight: FontWeight . bold
) ,
) ,
) ,
) ,
) ,
) ,
) ,
Container (
Container (
padding: const EdgeInsets . symmetric ( horizontal: 16 ) ,
padding: const EdgeInsets . symmetric ( horizontal: 16 ) ,
margin: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 16 ) ,
margin: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 16 ) ,
decoration: BoxDecoration (
decoration: BoxDecoration ( color: AColors . grey , borderRadius: BorderRadius . circular ( AppStyle . getBorderRadius ( context ) ) , boxShadow: [
color: AColors . grey ,
borderRadius: BorderRadius . circular ( AppStyle . getBorderRadius ( context ) ) ,
boxShadow: [
BoxShadow (
BoxShadow (
color: AColors . grey ,
color: AColors . grey ,
offset: Offset ( 0 , - 1 ) ,
offset: Offset ( 0 , - 1 ) ,
)
)
]
] ) ,
) ,
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Wrap (
Wrap (
spacing: 10 ,
spacing: 10 ,
children: [
children: [
ASubTitle ( " ${ _subtitle . callId } : ${ widget . request . requestCode } " , font: 14 , ) ,
ASubTitle (
widget . request . deviceSerialNumber = = null ? const SizedBox ( ) :
" ${ _subtitle . callId } : ${ widget . request . requestCode } " ,
ASubTitle ( " ${ _subtitle . deviceSN } : ${ widget . request . deviceSerialNumber } " , font: 14 , ) ,
font: 14 ,
) ,
widget . request . deviceSerialNumber = = null
? const SizedBox ( )
: ASubTitle (
" ${ _subtitle . deviceSN } : ${ widget . request . deviceSerialNumber } " ,
font: 14 ,
) ,
Text (
Text (
" ${ _subtitle . customer } : ${ widget . request . hospitalName } " ,
" ${ _subtitle . customer } : ${ widget . request . hospitalName } " ,
style: Theme . of ( context ) . textTheme . subtitle1 ? . copyWith (
style: Theme . of ( context ) . textTheme . subtitle1 ? . copyWith (
@ -143,7 +145,6 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
textScaleFactor: AppStyle . getScaleFactor ( context ) ,
textScaleFactor: AppStyle . getScaleFactor ( context ) ,
)
)
] ,
] ,
) ,
) ,
const Divider ( ) ,
const Divider ( ) ,
@ -157,29 +158,39 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . reportType ) ,
ASubTitle ( _subtitle . reportType ) ,
_validate & & _serviceReport . type = = null ?
_validate & & _serviceReport . type = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
const SizedBox ( height: 4 , ) ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportTypeMenu (
ServiceReportTypeMenu (
initialValue: _serviceReport . type ,
initialValue: _serviceReport . type ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport . type = status ;
_serviceReport . type = status ;
} ,
} ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
/ / visit date
/ / visit date
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . visitDate ) ,
ASubTitle ( _subtitle . visitDate ) ,
_validate & & _serviceReport . visitDate = = null ?
_validate & & _serviceReport . visitDate = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
Row (
Row (
children: [
children: [
Expanded (
Expanded (
@ -187,7 +198,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
date: _serviceReport . visitDate ,
date: _serviceReport . visitDate ,
from: DateTime . now ( ) . subtract ( const Duration ( days: 365 ) ) ,
from: DateTime . now ( ) . subtract ( const Duration ( days: 365 ) ) ,
to: DateTime . now ( ) . add ( const Duration ( days: 365 ) ) ,
to: DateTime . now ( ) . add ( const Duration ( days: 365 ) ) ,
onDatePicker: ( date ) {
onDatePicker: ( date ) {
_serviceReport . visitDate = date ;
_serviceReport . visitDate = date ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} ,
} ,
@ -198,44 +209,59 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
] ,
] ,
) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / device sn
/ / device sn
Visibility (
Visibility (
visible: true , / / widget . report . device = = null ,
visible: true , / / widget . report . device = = null ,
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . deviceSN ) ,
ASubTitle ( _subtitle . deviceSN ) ,
_validate & & _serviceReport . device ? . id = = null ?
_validate & & _serviceReport . device ? . id = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
AutoCompleteDeviceField (
AutoCompleteDeviceField (
hospitalId: widget . request . hospitalId ,
hospitalId: widget . request . hospitalId ,
initialValue: _serviceReport . device ! ,
initialValue: _serviceReport . device ! ,
onPick: ( id ) {
onPick: ( id ) {
_serviceReport . device ? . id = id ;
_serviceReport . device ? . id = id ;
} ,
} ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
ASubTitle ( _subtitle . serviceType ) ,
ASubTitle ( _subtitle . serviceType ) ,
_validate & & _serviceReport . serviceType = = null ?
_validate & & _serviceReport . serviceType = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
const SizedBox ( height: 4 , ) ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceStatusMenu (
ServiceStatusMenu (
initialValue: _serviceReport . serviceType ,
initialValue: _serviceReport . serviceType ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport . serviceType = status ;
_serviceReport . serviceType = status ;
} ,
} ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Report status and Service Type
/ / Report status and Service Type
Row (
Row (
children: [
children: [
@ -245,38 +271,49 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . reportStatus ) ,
ASubTitle ( _subtitle . reportStatus ) ,
_validate & & _serviceReport . status = = null ?
_validate & & _serviceReport . status = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
const SizedBox ( height: 4 , ) ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportStatusMenu (
ServiceReportStatusMenu (
report: _serviceReport ,
report: _serviceReport ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport . status = status ;
_serviceReport . status = status ;
} ,
} ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Provider . of < ServiceReportLastCallsProvider > ( context ) . isLoading = = null
Provider . of < ServiceReportLastCallsProvider > ( context ) . isLoading = = null
? const SizedBox . shrink ( ) :
? const SizedBox . shrink ( )
:
/ / Call ' s last Situation
/ / Call ' s last Situation
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . callLastSituation ) ,
ASubTitle ( _subtitle . callLastSituation ) ,
_validate & & _serviceReport . callLastSituation = = null ?
_validate & & _serviceReport . callLastSituation = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
const SizedBox ( height: 4 , ) ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportLastCallsMenu (
ServiceReportLastCallsMenu (
report: _serviceReport ,
report: _serviceReport ,
onSelect: ( status ) {
onSelect: ( status ) {
if ( status ? . id = = 12
if ( status ? . id = = 12 | | _serviceReport . callLastSituation ? . id = = 12 ) {
| | _serviceReport . callLastSituation ? . id = = 12 ) {
_serviceReport . callLastSituation = status ;
_serviceReport . callLastSituation = status ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} else {
} else {
@ -289,48 +326,53 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / invoice number & code
/ / invoice number & code
_serviceReport . callLastSituation ? . id ! = 12 ? const SizedBox . shrink ( ) :
_serviceReport . callLastSituation ? . id ! = 12
Row (
? const SizedBox . shrink ( )
: Row (
children: [
children: [
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . invoiceNumber ) ,
ASubTitle ( _subtitle . invoiceNumber ) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . invoiceNumber ,
initialValue: _serviceReport ? . invoiceNumber ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . hasValue ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . number ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . invoiceNumber = value ;
_serviceReport . invoiceNumber = value ;
} ,
} ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . invoiceCode ) ,
ASubTitle ( _subtitle . invoiceCode ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . invoiceCode ,
initialValue: _serviceReport ? . invoiceCode ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . hasValue ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . text ,
textInputType: TextInputType . text ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . invoiceCode = value ;
_serviceReport . invoiceCode = value ;
} ,
} ,
) ,
) ,
@ -340,7 +382,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
Row (
children: [
children: [
ASubTitle ( _subtitle . faultDescription ) ,
ASubTitle ( _subtitle . faultDescription ) ,
@ -355,21 +399,23 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . faultDescription ,
initialValue: _serviceReport ? . faultDescription ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
controller: _faultController ,
controller: _faultController ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . hasValue ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . multiline ,
textInputType: TextInputType . multiline ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . faultDescription = value ;
_serviceReport . faultDescription = value ;
} ,
} ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
Row (
children: [
children: [
ASubTitle ( _subtitle . workPreformed ) ,
ASubTitle ( _subtitle . workPreformed ) ,
@ -384,23 +430,27 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . workPreformed ,
initialValue: _serviceReport ? . workPreformed ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
controller: _workPreformedController ,
controller: _workPreformedController ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . hasValue ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . multiline ,
textInputType: TextInputType . multiline ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . workPreformed = value ;
_serviceReport . workPreformed = value ;
} ,
} ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
Row (
children: [
children: [
/ / reasons
/ / reasons
@ -409,17 +459,21 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . reasons ) ,
ASubTitle ( _subtitle . reasons ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportReasonsMenu (
ServiceReportReasonsMenu (
initialValue: _serviceReport . reason ,
initialValue: _serviceReport . reason ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport . reason = status ;
_serviceReport . reason = status ;
} ,
} ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
@ -428,8 +482,8 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
AMiniOneImagePicker (
AMiniOneImagePicker (
/ / error: _validate & & _serviceReport . image = = null ,
/ / error: _validate & & _serviceReport . image = = null ,
image: _image ,
image: _image ,
onPick: ( image ) {
onPick: ( image ) {
_image = image ;
_image = image ;
_serviceReport . image = base64Encode ( image . readAsBytesSync ( ) ) ;
_serviceReport . image = base64Encode ( image . readAsBytesSync ( ) ) ;
} ,
} ,
) ,
) ,
@ -438,7 +492,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Traveling Hours & Working Hours
/ / Traveling Hours & Working Hours
Row (
Row (
children: [
children: [
@ -447,10 +503,12 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . workingHours ) ,
ASubTitle ( _subtitle . workingHours ) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
AppTimer (
AppTimer (
timer: _serviceReport . timer ,
timer: _serviceReport . timer ,
onChange: ( timer ) async {
onChange: ( timer ) async {
_serviceReport . timer = timer ;
_serviceReport . timer = timer ;
return true ;
return true ;
} ,
} ,
@ -471,23 +529,25 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . travelingHours ) ,
ASubTitle ( _subtitle . travelingHours ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . travelingHours ,
initialValue: _serviceReport ? . travelingHours ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
hintText: " i.e 3, 3.5, 4 " ,
hintText: " i.e 3, 3.5, 4 " ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . isNumeric ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . isNumeric ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . number ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . travelingHours = value ;
_serviceReport . travelingHours = value ;
} ,
} ,
) ,
) ,
@ -496,7 +556,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Operating Hours and Job Sheet Number
/ / Operating Hours and Job Sheet Number
Row (
Row (
children: [
children: [
@ -505,36 +567,40 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . operatingHours ) ,
ASubTitle ( _subtitle . operatingHours ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . operatingHours ,
initialValue: _serviceReport ? . operatingHours ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
hintText: " i.e 3, 3.5, 4 " ,
hintText: " i.e 3, 3.5, 4 " ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
validator: ( value ) = > Validator . isNumeric ( value ! ) ? ' ' : _subtitle . requiredWord ,
Validator . isNumeric ( value ! )
? ' ' : _subtitle . requiredWord ,
textInputType: TextInputType . number ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . operatingHours = value ;
_serviceReport . operatingHours = value ;
} ,
} ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
Expanded (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . jobSheetNumber ) ,
ASubTitle ( _subtitle . jobSheetNumber ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
ATextFormField (
initialValue: _serviceReport ? . jobSheetNumber ,
initialValue: _serviceReport ? . jobSheetNumber ,
textAlign: TextAlign . center ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
textInputType: TextInputType . name ,
textInputType: TextInputType . name ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport . jobSheetNumber = value ;
_serviceReport . jobSheetNumber = value ;
} ,
} ,
) ,
) ,
@ -543,7 +609,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
) ,
) ,
] ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Part Number and Quantity
/ / Part Number and Quantity
Row (
Row (
children: [
children: [
@ -553,12 +621,17 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
ASubTitle ( _subtitle . partNumber ) ,
ASubTitle ( _subtitle . partNumber ) ,
_validate & & _serviceReport . parts = = null ?
_validate & & _serviceReport . parts = = null
ASubTitle ( _subtitle . requiredWord , color: Colors . red , ) :
? ASubTitle (
const SizedBox . shrink ( ) ,
_subtitle . requiredWord ,
const SizedBox ( height: 4 , ) ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
AutoCompletePartsField (
AutoCompletePartsField (
onPick: ( part ) {
onPick: ( part ) {
_serviceReport . parts ? . add ( part ) ;
_serviceReport . parts ? . add ( part ) ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} ,
} ,
@ -566,34 +639,33 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
] ,
] ,
) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
SizedBox ( height: 8 * AppStyle . getScaleFactor ( context ) , ) ,
SizedBox (
height: 8 * AppStyle . getScaleFactor ( context ) ,
) ,
Row (
Row (
children: [
children: [
Expanded ( flex: 3 , child: Text ( _subtitle . number ) ) ,
Expanded ( flex: 3 , child: Text ( _subtitle . number ) ) ,
Expanded ( flex: 1 , child: Text ( _subtitle . quantity ) ) ,
Expanded ( flex: 1 , child: Text ( _subtitle . quantity ) ) ,
] ,
] ,
) ,
) ,
Column (
Column (
children: List . generate (
children: List . generate ( _serviceReport . parts ! . length , ( index ) {
_serviceReport . parts ! . length ,
( index ) {
Part _part = _serviceReport . parts ! [ index ] ;
Part _part = _serviceReport . parts ! [ index ] ;
return PartItem (
return PartItem (
part : _part ,
part : _part ,
onDelete: ( part ) {
onDelete: ( part ) {
_serviceReport . parts ? . remove ( part ) ;
_serviceReport . parts ? . remove ( part ) ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} ,
} ,
) ;
) ;
}
} ) ,
) ,
) ,
) ,
const SizedBox ( height: 16 , ) ,
const SizedBox (
height: 16 ,
) ,
] ,
] ,
) ,
) ,
) ,
) ,
@ -603,48 +675,41 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
text: _subtitle . update ,
text: _subtitle . update ,
onPressed: ( ) async {
onPressed: ( ) async {
_validate = true ;
_validate = true ;
if ( ! ( _formKey . currentState ? . validate ( ) ? ? false ) ) {
if ( ! ( _formKey . currentState ? . validate ( ) ? ? false ) ) {
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
return ;
return ;
}
}
if ( ! _serviceReport . validate ( ) ) {
if ( ! _serviceReport . validate ( ) ) {
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
return ;
return ;
}
}
_formKey . currentState ? . save ( ) ;
_formKey . currentState ? . save ( ) ;
_isLoading = true ;
_isLoading = true ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
int status = await _serviceRequestsProvider . updateServiceReport (
int status =
user: _userProvider . user ! ,
await _serviceRequestsProvider . updateServiceReport ( user: UserApiClient ( ) . user ! , host: _settingProvider . host ? ? " " , report: _serviceReport , request: widget . request ) ;
host: _settingProvider . host ? ? " " ,
_isLoading = false ;
report: _serviceReport ,
request: widget . request
) ;
_isLoading = false ;
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
if ( status > = 200 & & status < 300 ) {
if ( status > = 200 & & status < 300 ) {
Fluttertoast . showToast (
Fluttertoast . showToast (
msg: _subtitle . requestCompleteSuccessfully ,
msg: _subtitle . requestCompleteSuccessfully ,
) ;
) ;
Navigator . of ( context ) . pop ( ) ;
Navigator . of ( context ) . pop ( ) ;
Navigator . of ( context ) . pop ( ) ;
Navigator . of ( context ) . pop ( ) ;
} else {
} else {
String errorMessage = HttpStatusManger . getStatusMessage (
String errorMessage = HttpStatusManger . getStatusMessage ( status: status , subtitle: _subtitle ) ;
status: status , subtitle: _subtitle ) ;
ScaffoldMessenger . of ( context ) . showSnackBar ( SnackBar (
ScaffoldMessenger . of ( context ) . showSnackBar (
content: Text ( errorMessage ) ,
SnackBar (
) ) ;
content: Text (
errorMessage
) ,
)
) ;
}
}
} ,
} ,
) ,
) ,
) ,
) ,
const SizedBox ( height: 300 , )
const SizedBox (
height: 300 ,
)
] ,
] ,
) ,
) ,
const ABackButton ( ) ,
const ABackButton ( ) ,