improvement

Sikander Saleem 1 year ago
parent a34580f51d
commit 06b6ff0e06

@ -55,7 +55,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []); GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []);
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
bool _firstTime = true; bool _firstTime = true;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Lookup _deliveredQuantity; Lookup _deliveredQuantity;
static List<Lookup> deliveredQuantity = [ static List<Lookup> deliveredQuantity = [
@ -137,7 +137,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
setState(() {}); setState(() {});
return false; return false;
} }
_formKey.currentState.save();
_currentDetails.gasType = _formModel.gazRefillDetails[0].gasType; _currentDetails.gasType = _formModel.gazRefillDetails[0].gasType;
_currentDetails.cylinderSize = _formModel.gazRefillDetails[0].cylinderSize; _currentDetails.cylinderSize = _formModel.gazRefillDetails[0].cylinderSize;
_currentDetails.cylinderType = _formModel.gazRefillDetails[0].cylinderType; _currentDetails.cylinderType = _formModel.gazRefillDetails[0].cylinderType;
@ -198,129 +198,132 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
return Scaffold( return Scaffold(
appBar: DefaultAppBar(title: context.translation.updateRequest), appBar: DefaultAppBar(title: context.translation.updateRequest),
key: _scaffoldKey, key: _scaffoldKey,
body: SafeArea( body: Form(
child: LoadingManager( key: _formKey,
isLoading: _isLoading, child: SafeArea(
isFailedLoading: false, child: LoadingManager(
stateCode: 200, isLoading: _isLoading,
onRefresh: () async {}, isFailedLoading: false,
child: Column( stateCode: 200,
crossAxisAlignment: CrossAxisAlignment.stretch, onRefresh: () async {},
children: [ child: Column(
SingleChildScrollView( crossAxisAlignment: CrossAxisAlignment.stretch,
padding: const EdgeInsets.all(16), children: [
child: Column( SingleChildScrollView(
crossAxisAlignment: CrossAxisAlignment.stretch, padding: const EdgeInsets.all(16),
children: [ child: Column(
Column( crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Column(
context.translation.gasRefill.heading5(context), crossAxisAlignment: CrossAxisAlignment.start,
8.height, children: [
'${context.translation.gasRequest}: ${widget.gasRefillModel.gazRefillDetails[0].gasType.name}'.bodyText(context), context.translation.gasRefill.heading5(context),
'${context.translation.cylinderType}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderType.name}'.bodyText(context), 8.height,
'${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.name}'.bodyText(context), '${context.translation.gasRequest}: ${widget.gasRefillModel.gazRefillDetails[0].gasType.name}'.bodyText(context),
'${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty ?? 0}'.bodyText(context), '${context.translation.cylinderType}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderType.name}'.bodyText(context),
'${context.translation.site}: ${widget.gasRefillModel.site?.name}'.bodyText(context), '${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.name}'.bodyText(context),
], '${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty ?? 0}'.bodyText(context),
).toShadowContainer(context), '${context.translation.site}: ${widget.gasRefillModel.site?.name}'.bodyText(context),
8.height, ],
AppTimer( ).toShadowContainer(context),
label: context.translation.workingHours, 8.height,
timer: _formModel.timer, AppTimer(
enabled: _formModel.endDate == null, label: context.translation.workingHours,
onChange: (timer) async { timer: _formModel.timer,
_formModel.timer = timer; enabled: _formModel.endDate == null,
return true; onChange: (timer) async {
}, _formModel.timer = timer;
), return true;
8.height, },
SingleItemDropDownMenu<Lookup, GasStatusProvider>( ),
context: context, 8.height,
title: context.translation.requestStatus, SingleItemDropDownMenu<Lookup, GasStatusProvider>(
initialValue: _formModel.status, context: context,
onSelect: (value) { title: context.translation.requestStatus,
if (value?.value == 0) { initialValue: _formModel.status,
"Status cannot be change to ${value.name}.".addTranslation.showToast; onSelect: (value) {
setState(() {}); if (value?.value == 0) {
return; "Status cannot be change to ${value.name}.".addTranslation.showToast;
} setState(() {});
if (value != null) { return;
_formModel.status = value; }
} if (value != null) {
}, _formModel.status = value;
), }
8.height, },
SingleItemDropDownMenu<Lookup, NullableLoadingProvider>( ),
context: context, 8.height,
title: context.translation.quantity, SingleItemDropDownMenu<Lookup, NullableLoadingProvider>(
initialValue: _deliveredQuantity, context: context,
staticData: deliveredQuantity, title: context.translation.quantity,
onSelect: (value) { initialValue: _deliveredQuantity,
_deliveredQuantity = value; staticData: deliveredQuantity,
_currentDetails.deliverdQty = value.value; onSelect: (value) {
}, _deliveredQuantity = value;
), _currentDetails.deliverdQty = value.value;
8.height, },
// AppTextFormField( ),
// initialValue: _formModel.gazRefillDetails[0]?.deliverdQty?.toString(), 8.height,
// labelText: context.translation.deliveredQuantity, // AppTextFormField(
// onSaved: (value) { // initialValue: _formModel.gazRefillDetails[0]?.deliverdQty?.toString(),
// _currentDetails?.deliverdQty = double.tryParse(value); // labelText: context.translation.deliveredQuantity,
// }, // onSaved: (value) {
// textInputType: TextInputType.number, // _currentDetails?.deliverdQty = double.tryParse(value);
// controller: _deliveredQuantityController, // },
// validator: (value) => value == null || value.isEmpty // textInputType: TextInputType.number,
// ? context.translation.requiredField // controller: _deliveredQuantityController,
// : Validator.isNumeric(value) // validator: (value) => value == null || value.isEmpty
// ? null // ? context.translation.requiredField
// : context.translation.onlyNumbers, // : Validator.isNumeric(value)
// ), // ? null
// 8.height, // : context.translation.onlyNumbers,
// ),
// 8.height,
/// TBD /// TBD
AppTextFormField( AppTextFormField(
labelText: context.translation.comments, labelText: context.translation.comments,
textInputType: TextInputType.multiline, textInputType: TextInputType.multiline,
alignLabelWithHint: true, alignLabelWithHint: true,
controller: _commentController, controller: _commentController,
onSaved: (value) {}, onSaved: (value) {},
), ),
8.height, 8.height,
ESignature( ESignature(
title: "Engineer Signature", title: "Engineer Signature",
oldSignature: widget.gasRefillModel.engSignature, oldSignature: widget.gasRefillModel.engSignature,
newSignature: _engineerSignature, newSignature: _engineerSignature,
onSaved: (signature) { onSaved: (signature) {
_engineerSignature = signature; _engineerSignature = signature;
if (signature == null || signature.isEmpty) return; if (signature == null || signature.isEmpty) return;
_formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; _formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
//base64Encode(signature); //base64Encode(signature);
}, },
), ),
8.height, 8.height,
ESignature( ESignature(
title: "Nurse Signature", title: "Nurse Signature",
oldSignature: widget.gasRefillModel.nurseSignature, oldSignature: widget.gasRefillModel.nurseSignature,
newSignature: _nurseSignature, newSignature: _nurseSignature,
onSaved: (signature) { onSaved: (signature) {
_nurseSignature = signature; _nurseSignature = signature;
if (signature == null || signature.isEmpty) return; if (signature == null || signature.isEmpty) return;
_formModel.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; _formModel.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
//base64Encode(signature); //base64Encode(signature);
}, },
), ),
], ],
), ),
).expanded, ).expanded,
AppFilledButton( AppFilledButton(
label: widget.gasRefillModel == null ? context.translation.submit : context.translation.update, label: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed: () async { onPressed: () async {
_onSubmit.call(context); _onSubmit.call(context);
}, },
).paddingAll(16), ).paddingAll(16),
], ],
)), )),
),
), ),
); );
} }

Loading…
Cancel
Save