@ -2,15 +2,14 @@ import 'dart:convert';
import ' dart:io ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/rendering.dart ' ;
import ' package:fluttertoast/fluttertoast.dart ' ;
import ' package:provider/provider.dart ' ;
import ' ../../../../../api/login_api_client.dart ' ;
import ' ../../../../../controllers/http_status_manger/http_status_manger.dart ' ;
import ' ../../../../../controllers/localization/localization.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/user_provider.dart ' ;
import ' ../../../../../controllers/providers/settings/setting_provider.dart ' ;
import ' ../../../../../controllers/validator/validator.dart ' ;
import ' ../../../../../models/device/device.dart ' ;
@ -37,19 +36,18 @@ import '../../../../widgets/status/report/service_report_status.dart';
import ' ../../../../widgets/status/report/service_status.dart ' ;
import ' ../../../../widgets/timer/app_timer.dart ' ;
import ' ../../../../widgets/titles/app_sub_title.dart ' ;
class CreateServiceReport extends StatefulWidget {
static final String id = " /create-service-report " ;
final ServiceRequest ? request ;
static const String id = " /create-service-report " ;
final ServiceRequest ? request ;
const CreateServiceReport ( { Key ? key , this . request } ) : super ( key: key ) ;
@ override
_ CreateServiceReportState createState ( ) = > _ CreateServiceReportState( ) ;
CreateServiceReportState createState ( ) = > CreateServiceReportState( ) ;
}
class _CreateServiceReportState extends State < CreateServiceReport > with TickerProviderStateMixin {
UserProvider ? _userProvider ;
class CreateServiceReportState extends State < CreateServiceReport > with TickerProviderStateMixin {
SettingProvider ? _settingProvider ;
ServiceRequestsProvider ? _serviceRequestsProvider ;
@ -61,20 +59,19 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
File ? _image ;
final GlobalKey < FormState > _formKey = GlobalKey < FormState > ( ) ;
final GlobalKey < ScaffoldState > _scaffoldKey = GlobalKey < ScaffoldState > ( ) ;
TextEditingController _faultController = TextEditingController ( ) ;
TextEditingController _workPreformedController = TextEditingController ( ) ;
final TextEditingController _faultController = TextEditingController ( ) ;
final TextEditingController _workPreformedController = TextEditingController ( ) ;
@ override
void initState ( ) {
_serviceReport = ServiceReport (
visitDate: DateTime . now ( ) ,
type: const Lookup ( id: 2 ) ,
device: Device (
id: widget . request ? . deviceId ,
serialNumber: widget . request ? . deviceSerialNumber ,
) ,
parts: [ ]
) ;
visitDate: DateTime . now ( ) ,
type: const Lookup ( id: 2 ) ,
device: Device (
id: widget . request ? . deviceId ,
serialNumber: widget . request ? . deviceSerialNumber ,
) ,
parts: [ ] ) ;
super . initState ( ) ;
}
@ -84,9 +81,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_workPreformedController . dispose ( ) ;
super . dispose ( ) ;
}
@ override
Widget build ( BuildContext context ) {
_userProvider = Provider . of < UserProvider > ( context ) ;
_settingProvider = Provider . of < SettingProvider > ( context ) ;
_serviceRequestsProvider = Provider . of < ServiceRequestsProvider > ( context ) ;
_subtitle = AppLocalization . of ( context ) ? . subtitle ;
@ -105,52 +102,54 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
ListView (
children: [
/ / AppNameBar ( ) ,
const SizedBox ( height: 16 , ) ,
const SizedBox (
height: 16 ,
) ,
Center (
child: Padding (
padding: const EdgeInsets . all ( 8.0 ) ,
child: Text (
_subtitle ? . newServiceReport ? ? " " ,
style: Theme . of ( context ) . textTheme . headline5 ? . copyWith (
color: AColors . cyan ,
fontSize: 28 ,
fontWeight: FontWeight . bold
) ,
_subtitle ? . newServiceReport ? ? " " ,
style: Theme . of ( context ) . textTheme . headline5 ? . copyWith ( color: AColors . cyan , fontSize: 28 , fontWeight: FontWeight . bold ) ,
) ,
) ,
) ,
Container (
padding: const EdgeInsets . symmetric ( horizontal: 16 ) ,
margin: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 16 ) ,
decoration: BoxDecoration (
margin: const EdgeInsets . symmetric ( horizontal: 16 , vertical: 16 ) ,
decoration: BoxDecoration ( color: AColors . grey , borderRadius: BorderRadius . circular ( AppStyle . getBorderRadius ( context ) ) , boxShadow: [
const BoxShadow (
color: AColors . grey ,
borderRadius: BorderRadius . circular ( AppStyle . getBorderRadius ( context ) ) ,
boxShadow: [
const BoxShadow (
color: AColors . grey ,
offset: Offset ( 0 , - 1 ) ,
)
]
) ,
offset: Offset ( 0 , - 1 ) ,
)
] ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Wrap (
spacing: 10 ,
children: [
ASubTitle ( " ${ _subtitle ? . callId } : ${ widget . request ? . requestCode } " , font: 14 , ) ,
widget . request ? . deviceSerialNumber = = null ? const SizedBox ( ) :
ASubTitle ( " ${ _subtitle ? . deviceSN } : ${ widget . request ? . deviceSerialNumber } " , font: 14 , ) ,
ASubTitle (
" ${ _subtitle ? . callId } : ${ widget . request ? . requestCode } " ,
font: 14 ,
) ,
widget . request ? . deviceSerialNumber = = null
? const SizedBox ( )
: ASubTitle (
" ${ _subtitle ? . deviceSN } : ${ widget . request ? . deviceSerialNumber } " ,
font: 14 ,
) ,
Text (
" ${ _subtitle ? . customer } : ${ widget . request ? . hospitalName } " ,
style: Theme . of ( context ) . textTheme . subtitle1 ? . copyWith (
fontWeight: FontWeight . bold ,
fontSize: 12 ,
) ,
fontWeight: FontWeight . bold ,
fontSize: 12 ,
) ,
textScaleFactor: AppStyle . getScaleFactor ( context ) ,
)
] ,
) ,
const Divider ( ) ,
@ -183,18 +182,21 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . visitDate ? ? " " ) ,
_validate & & _serviceReport ? . visitDate = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
ASubTitle ( _subtitle ? . visitDate ? ? " " ) ,
_validate & & _serviceReport ? . visitDate = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
Row (
children: [
Expanded (
child: ADatePicker (
date: _serviceReport ? . visitDate ? ? DateTime . now ( ) ,
date: _serviceReport ? . visitDate ? ? DateTime . now ( ) ,
from: DateTime . now ( ) . subtract ( const Duration ( days: 365 ) ) ,
to: DateTime . now ( ) . add ( const Duration ( days: 365 ) ) ,
onDatePicker: ( date ) {
onDatePicker: ( date ) {
_serviceReport ? . visitDate = date ;
setState ( ( ) { } ) ;
} ,
@ -205,44 +207,59 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
] ,
) ,
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / device sn
Visibility (
visible: widget . request ? . deviceSerialNumber = = null ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . deviceSN ? ? " " ) ,
_validate & & _serviceReport ? . device ? . id = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
ASubTitle ( _subtitle ? . deviceSN ? ? " " ) ,
_validate & & _serviceReport ? . device ? . id = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
AutoCompleteDeviceField (
hospitalId: widget . request ? . hospitalId ? ? " " ,
hospitalId: widget . request ? . hospitalId ? ? " " ,
initialValue: _serviceReport ! . device ! ,
onPick: ( id ) {
onPick: ( id ) {
_serviceReport ? . device ? . id = id ;
} ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
] ,
) ,
) ,
const SizedBox ( height: 8 , ) ,
ASubTitle ( _subtitle ? . serviceType ? ? " " ) ,
_validate & & _serviceReport ? . serviceType = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 8 ,
) ,
ASubTitle ( _subtitle ? . serviceType ? ? " " ) ,
_validate & & _serviceReport ? . serviceType = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceStatusMenu (
initialValue: _serviceReport ? . serviceType ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport ? . serviceType = status ;
} ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Report status and Service Type
Row (
children: [
@ -251,106 +268,124 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . reportStatus ? ? " " ) ,
_validate & & _serviceReport ? . status = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
const SizedBox ( height: 4 , ) ,
ASubTitle ( _subtitle ? . reportStatus ? ? " " ) ,
_validate & & _serviceReport ? . status = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportStatusMenu (
report: _serviceReport ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport ? . status = status ;
} ,
) ,
] ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Provider . of < ServiceReportLastCallsProvider > ( context ) . isLoading = = null
? const SizedBox . shrink ( ) :
/ / Call ' s last Situation
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . callLastSituation ? ? " " ) ,
_validate & & _serviceReport ? . callLastSituation = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
const SizedBox ( height: 4 , ) ,
ServiceReportLastCallsMenu (
report: _serviceReport ,
onSelect: ( status ) {
if ( status ? . id = = 12
| | _serviceReport ? . callLastSituation ? . id = = 12 ) {
_serviceReport ? . callLastSituation = status ;
setState ( ( ) { } ) ;
} else {
_serviceReport ? . callLastSituation = status ;
}
} ,
? const SizedBox . shrink ( )
:
/ / Call ' s last Situation
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . callLastSituation ? ? " " ) ,
_validate & & _serviceReport ? . callLastSituation = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportLastCallsMenu (
report: _serviceReport ,
onSelect: ( status ) {
if ( status ? . id = = 12 | | _serviceReport ? . callLastSituation ? . id = = 12 ) {
_serviceReport ? . callLastSituation = status ;
setState ( ( ) { } ) ;
} else {
_serviceReport ? . callLastSituation = status ;
}
} ,
) ,
] ,
) ,
) ,
] ,
) ,
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / invoice number & code
_serviceReport ? . callLastSituation ? . id ! = 12 ? const SizedBox . shrink ( ) :
Row (
children: [
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
_serviceReport ? . callLastSituation ? . id ! = 12
? const SizedBox . shrink ( )
: Row (
children: [
ASubTitle ( _subtitle ? . invoiceNumber ? ? " " ) ,
const SizedBox ( height: 8 , ) ,
ATextFormField (
initialValue: _serviceReport ? . invoiceNumber ? ? " " ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
Validator . hasValue ( value ! )
? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
_serviceReport ? . invoiceNumber = value ;
} ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . invoiceNumber ? ? " " ) ,
const SizedBox (
height: 8 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . invoiceNumber ? ? " " ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
_serviceReport ? . invoiceNumber = value ;
} ,
) ,
] ,
) ,
) ,
] ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . invoiceCode ? ? " " ) ,
const SizedBox ( height: 4 , ) ,
ATextFormField (
initialValue: _serviceReport ? . invoiceCode ? ? " " ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
Validator . hasValue ( value ! )
? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . text ,
onSaved: ( value ) {
_serviceReport ? . invoiceCode = value ;
} ,
const SizedBox (
width: 8 ,
) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . invoiceCode ? ? " " ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . invoiceCode ? ? " " ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . text ,
onSaved: ( value ) {
_serviceReport ? . invoiceCode = value ;
} ,
) ,
] ,
) ,
) ,
] ,
) ,
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
children: [
ASubTitle ( _subtitle ? . faultDescription ? ? " " ) ,
ASubTitle ( _subtitle ? . faultDescription ? ? " " ) ,
Expanded (
child: SizedBox (
height: 32 * AppStyle . getScaleFactor ( context ) ,
@ -362,24 +397,26 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
) ,
] ,
) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . faultDescription ? ? " " ,
initialValue: _serviceReport ? . faultDescription ? ? " " ,
textAlign: TextAlign . center ,
controller: _faultController ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
Validator . hasValue ( value ! )
? ' ' : _subtitle ? . requiredWord ? ? " " ,
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . multiline ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport ? . faultDescription = value ;
} ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
children: [
ASubTitle ( _subtitle ? . workPreformed ? ? " " ) ,
ASubTitle ( _subtitle ? . workPreformed ? ? " " ) ,
Expanded (
child: SizedBox (
height: 32 * AppStyle . getScaleFactor ( context ) ,
@ -391,23 +428,27 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
) ,
] ,
) ,
const SizedBox ( height: 4 , ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . workPreformed ? ? " " ,
initialValue: _serviceReport ? . workPreformed ? ? " " ,
textAlign: TextAlign . center ,
controller: _workPreformedController ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
validator: ( value ) = >
Validator . hasValue ( value ! )
? ' ' : _subtitle ? . requiredWord ? ? " " ,
validator: ( value ) = > Validator . hasValue ( value ! ) ? ' ' : _subtitle ? . requiredWord ? ? " " ,
textInputType: TextInputType . multiline ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport ? . workPreformed = value ;
} ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
Row (
children: [
/ / reasons
@ -415,28 +456,32 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . reasons ? ? " " ) ,
const SizedBox ( height: 4 , ) ,
ASubTitle ( _subtitle ? . reasons ? ? " " ) ,
const SizedBox (
height: 4 ,
) ,
ServiceReportReasonsMenu (
initialValue: _serviceReport ? . reason ,
onSelect: ( status ) {
onSelect: ( status ) {
_serviceReport ? . reason = status ;
} ,
) ,
] ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . attachImage ? ? " " ) ,
ASubTitle ( _subtitle ? . attachImage ? ? " " ) ,
AMiniOneImagePicker (
/ / error: _validate & & _serviceReport . image = = null ,
image: _image ,
onPick: ( image ) {
_image = image ;
onPick: ( image ) {
_image = image ;
_serviceReport ? . image = base64Encode ( image . readAsBytesSync ( ) ) ;
} ,
) ,
@ -445,7 +490,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Traveling Hours & Working Hours
Row (
children: [
@ -453,11 +500,13 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . workingHours ? ? " " ) ,
const SizedBox ( height: 8 , ) ,
ASubTitle ( _subtitle ? . workingHours ? ? " " ) ,
const SizedBox (
height: 8 ,
) ,
AppTimer (
timer: _serviceReport ? . timer ,
onChange: ( timer ) async {
onChange: ( timer ) async {
_serviceReport ? . timer = timer ;
return true ;
} ,
@ -478,13 +527,17 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
] ,
) ,
) ,
const SizedBox ( width: 8 , ) ,
const SizedBox (
width: 8 ,
) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . travelingHours ? ? " " ) ,
const SizedBox ( height: 4 , ) ,
ASubTitle ( _subtitle ? . travelingHours ? ? " " ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . travelingHours ,
textAlign: TextAlign . center ,
@ -494,7 +547,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
/ / Validator . isNumeric ( value )
/ / ? null : _subtitle . requiredWord ,
textInputType: TextInputType . number ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport ? . travelingHours = value ;
} ,
) ,
@ -503,7 +556,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Operating Hours and Job Sheet Number
Row (
children: [
@ -534,14 +589,16 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . jobSheetNumber ? ? " " ) ,
const SizedBox ( height: 4 , ) ,
ASubTitle ( _subtitle ? . jobSheetNumber ? ? " " ) ,
const SizedBox (
height: 4 ,
) ,
ATextFormField (
initialValue: _serviceReport ? . jobSheetNumber ,
textAlign: TextAlign . center ,
style: Theme . of ( context ) . textTheme . subtitle1 ,
textInputType: TextInputType . name ,
onSaved: ( value ) {
onSaved: ( value ) {
_serviceReport ? . jobSheetNumber = value ;
} ,
) ,
@ -550,7 +607,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
) ,
] ,
) ,
const SizedBox ( height: 8 , ) ,
const SizedBox (
height: 8 ,
) ,
/ / Part Number and Quantity
Row (
children: [
@ -559,95 +618,92 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
ASubTitle ( _subtitle ? . partNumber ? ? " " ) ,
_validate & & _serviceReport ? . parts = = null ?
ASubTitle ( _subtitle ? . requiredWord ? ? " " , color: Colors . red , ) :
const SizedBox . shrink ( ) ,
const SizedBox ( height: 4 , ) ,
ASubTitle ( _subtitle ? . partNumber ? ? " " ) ,
_validate & & _serviceReport ? . parts = = null
? ASubTitle (
_subtitle ? . requiredWord ? ? " " ,
color: Colors . red ,
)
: const SizedBox . shrink ( ) ,
const SizedBox (
height: 4 ,
) ,
AutoCompletePartsField (
onPick: ( part ) {
onPick: ( part ) {
_serviceReport ? . parts ? . add ( part ) ;
} ,
) ,
] ,
) ,
) ,
] ,
) ,
SizedBox ( height: 8 * AppStyle . getScaleFactor ( context ) , ) ,
SizedBox (
height: 8 * AppStyle . getScaleFactor ( context ) ,
) ,
Row (
children: [
Expanded ( flex: 3 , child: Text ( _subtitle ? . number ? ? " " ) ) ,
Expanded ( flex: 1 , child: Text ( _subtitle ? . quantity ? ? " " ) ) ,
Expanded ( flex: 3 , child: Text ( _subtitle ? . number ? ? " " ) ) ,
Expanded ( flex: 1 , child: Text ( _subtitle ? . quantity ? ? " " ) ) ,
] ,
) ,
Column (
children: List . generate (
_serviceReport ! . parts ! . length ,
( index ) {
Part _part = _serviceReport ! . parts ! [ index ] ;
return PartItem (
part : _part ,
onDelete: ( part ) {
_serviceReport ! . parts ! . remove ( part ) ;
setState ( ( ) { } ) ;
} ,
) ;
}
) ,
children: List . generate ( _serviceReport ! . parts ! . length , ( index ) {
Part _part = _serviceReport ! . parts ! [ index ] ;
return PartItem (
part : _part ,
onDelete: ( part ) {
_serviceReport ! . parts ! . remove ( part ) ;
setState ( ( ) { } ) ;
} ,
) ;
} ) ,
) ,
const SizedBox ( height: 16 , ) ,
const SizedBox (
height: 16 ,
) ,
] ,
) ,
) ,
Padding (
padding: const EdgeInsets . all ( 16.0 ) ,
child: AButton (
text: _subtitle ? . submit ? ? " " ,
text: _subtitle ? . submit ? ? " " ,
onPressed: ( ) async {
_validate = true ;
if ( ! ( _formKey . currentState ? . validate ( ) ? ? false ) ) {
if ( ! ( _formKey . currentState ? . validate ( ) ? ? false ) ) {
setState ( ( ) { } ) ;
return ;
}
if ( ! ( _serviceReport ? . validate ( ) ? ? false ) ) return ;
if ( ! ( _serviceReport ? . validate ( ) ? ? false ) ) return ;
_formKey . currentState ? . save ( ) ;
_isLoading = true ;
_isLoading = true ;
setState ( ( ) { } ) ;
int ? status = await _serviceRequestsProvider ? . createServiceReport (
user: _userProvider ! . user ! ,
host: _settingProvider ? . host ? ? " " ,
report: _serviceReport ! ,
request: widget . request !
) ;
_isLoading = false ;
int ? status =
await _serviceRequestsProvider ? . createServiceReport ( user: UserApiClient ( ) . user ! , host: _settingProvider ? . host ? ? " " , report: _serviceReport ! , request: widget . request ! ) ;
_isLoading = false ;
setState ( ( ) { } ) ;
if ( status ! = null & & status > = 200 & & status < 300 ) {
if ( status ! = null & & status > = 200 & & status < 300 ) {
Fluttertoast . showToast (
msg: _subtitle ? . requestCompleteSuccessfully ? ? " " ,
msg: _subtitle ? . requestCompleteSuccessfully ? ? " " ,
) ;
Navigator . of ( context ) . pop ( ) ;
Navigator . of ( context ) . pop ( ) ;
} else {
String errorMessage = HttpStatusManger . getStatusMessage (
status: status , subtitle: _subtitle ) ;
ScaffoldMessenger . of ( context ) . showSnackBar (
SnackBar (
content: Text (
errorMessage
) ,
)
) ;
} else {
String errorMessage = HttpStatusManger . getStatusMessage ( status: status , subtitle: _subtitle ) ;
ScaffoldMessenger . of ( context ) . showSnackBar ( SnackBar (
content: Text ( errorMessage ) ,
) ) ;
}
} ,
) ,
) ,
const SizedBox ( height: 300 , )
const SizedBox (
height: 300 ,
)
] ,
) ,
const ABackButton ( ) ,