gas refill quantity, change to dropdown.

Sikander Saleem 1 year ago
parent 17545af7e1
commit c3b66e3a01

@ -186,18 +186,18 @@ class GasRefillModel {
return map; return map;
} }
Future<bool> validate(BuildContext context) async { bool validate(BuildContext context) {
if (site == null) { if (site == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.destinationSite}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.destinationSite}");
return false; return false;
} else if (building == null) { } else if (building == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.building}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.building}");
return false; return false;
} else if (floor == null) { } else if (floor == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.floor}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.floor}");
return false; return false;
} else if (department == null) { } else if (department == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.department}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.department}");
return false; return false;
} }
return true; return true;
@ -280,15 +280,18 @@ class GasRefillDetails {
return map; return map;
} }
Future<bool> validate(BuildContext context) async { bool validate(BuildContext context) {
if (gasType == null) { if (gasType == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.gasType}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.gasType}");
return false;
} else if (requestedQty == null) {
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.quantity}");
return false; return false;
} else if (cylinderType == null) { } else if (cylinderType == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.cylinderType}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.cylinderType}");
return false; return false;
} else if (cylinderSize == null) { } else if (cylinderSize == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.cylinderSize}"); Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.cylinderSize}");
return false; return false;
} }
return true; return true;

@ -173,6 +173,9 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
), ),
)) as T; )) as T;
if (_selectedT != null) { if (_selectedT != null) {
setState(() {
_selectedItem = _selectedT;
});
widget.onSelect(_selectedT); widget.onSelect(_selectedT);
} }
} }

@ -14,7 +14,6 @@ import 'package:test_sa/models/new_models/gas_refill_model.dart';
import 'package:test_sa/models/new_models/site.dart'; import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_size_provider.dart'; import 'package:test_sa/providers/gas_request_providers/cylinder_size_provider.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_type_provider.dart'; import 'package:test_sa/providers/gas_request_providers/cylinder_type_provider.dart';
@ -23,7 +22,6 @@ import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/loading_list_notifier.dart';
import '../../controllers/providers/api/gas_refill_provider.dart'; import '../../controllers/providers/api/gas_refill_provider.dart';
import '../../controllers/validator/validator.dart';
import '../common_widgets/default_app_bar.dart'; import '../common_widgets/default_app_bar.dart';
class NewGasRefillRequestPage extends StatefulWidget { class NewGasRefillRequestPage extends StatefulWidget {
@ -38,21 +36,25 @@ class NewGasRefillRequestPage extends StatefulWidget {
class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> { class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
GasRefillDetails _currentDetails; GasRefillDetails _currentDetails;
GasRefillModel _gasModel; GasRefillModel _gasModel;
GlobalKey<FormState> _formKey; Lookup _requestedQuantity;
TextEditingController _quantityController;
static List<Lookup> gasQuantity = [
Lookup(name: "1", id: 1, value: 1),
Lookup(name: "2", id: 2, value: 2),
Lookup(name: "3", id: 3, value: 3),
Lookup(name: "4", id: 4, value: 4),
Lookup(name: "5", id: 5, value: 5)
];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_formKey = GlobalKey<FormState>();
_currentDetails = GasRefillDetails(); _currentDetails = GasRefillDetails();
_gasModel = GasRefillModel(gazRefillDetails: []); _gasModel = GasRefillModel(gazRefillDetails: []);
_quantityController = TextEditingController();
} }
@override @override
void dispose() { void dispose() {
_quantityController.dispose();
super.dispose(); super.dispose();
} }
@ -63,174 +65,162 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
body: Column( body: Column(
children: [ children: [
SingleChildScrollView( SingleChildScrollView(
child: Form( child: Column(
key: _formKey, children: [
child: Column( 16.height,
children: [ SingleItemDropDownMenu<Lookup, GasTypesProvider>(
16.height, context: context,
SingleItemDropDownMenu<Lookup, GasTypesProvider>( title: context.translation.gasType,
context: context, initialValue: _currentDetails.gasType,
title: context.translation.gasType, showAsBottomSheet: true,
initialValue: _currentDetails.gasType, onSelect: (value) {
onSelect: (value) { _currentDetails.gasType = value;
_currentDetails.gasType = value; },
}, ),
), 8.height,
8.height, SingleItemDropDownMenu<Lookup, NullableLoadingProvider>(
AppTextFormField( context: context,
controller: _quantityController, title: context.translation.quantity,
labelText: context.translation.quantity, initialValue: _requestedQuantity,
textInputType: TextInputType.number, staticData: gasQuantity,
validator: (value) => Validator.hasValue(value) onSelect: (value) {
? Validator.isNumeric(value) _requestedQuantity = value;
? null _currentDetails.requestedQty = value.value;
: context.translation.onlyNumbers },
: context.translation.requiredField, ),
onSaved: (text) { 8.height,
_currentDetails.requestedQty = double.tryParse(text ?? "") ?? 0; SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
}, context: context,
), title: context.translation.cylinderType,
8.height, initialValue: _currentDetails.cylinderType,
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>( onSelect: (value) {
context: context, _currentDetails.cylinderType = value;
title: context.translation.cylinderType, },
initialValue: _currentDetails.cylinderType, ),
onSelect: (value) { 8.height,
_currentDetails.cylinderType = value; SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
}, context: context,
), title: context.translation.cylinderSize,
8.height, initialValue: _currentDetails.cylinderSize,
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>( showAsBottomSheet: true,
context: context, onSelect: (value) {
title: context.translation.cylinderSize, _currentDetails.cylinderSize = value;
initialValue: _currentDetails.cylinderSize, },
onSelect: (value) { ),
_currentDetails.cylinderSize = value; 8.height,
}, SingleItemDropDownMenu<Site, SiteProvider>(
), context: context,
8.height, title: context.translation.site,
SingleItemDropDownMenu<Site, SiteProvider>( initialValue: _gasModel.site,
context: context, showAsBottomSheet: true,
title: context.translation.site, onSelect: (value) {
initialValue: _gasModel.site, setState(() {
onSelect: (value) { _gasModel.site = value;
setState(() { _gasModel?.building = null;
_gasModel.site = value; _gasModel?.floor = null;
_gasModel?.building = null; _gasModel?.department = null;
_gasModel?.floor = null; });
_gasModel?.department = null; },
}); ),
}, 8.height,
SingleItemDropDownMenu<Building, NullableLoadingProvider>(
context: context,
title: context.translation.building,
initialValue: _gasModel.building,
enabled: _gasModel.site?.buildings?.isNotEmpty ?? false,
staticData: _gasModel.site?.buildings ?? [],
showAsBottomSheet: true,
onSelect: (value) {
setState(() {
_gasModel.building = value;
_gasModel?.floor = null;
_gasModel?.department = null;
});
},
),
8.height,
SingleItemDropDownMenu<Floor, NullableLoadingProvider>(
context: context,
title: context.translation.floor,
initialValue: _gasModel.floor,
enabled: _gasModel.building?.floors?.isNotEmpty ?? false,
staticData: _gasModel.building?.floors ?? [],
showAsBottomSheet: true,
onSelect: (value) {
setState(() {
_gasModel.floor = value;
_gasModel?.department = null;
});
},
),
8.height,
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
context: context,
title: context.translation.department,
initialValue: _gasModel.department,
enabled: _gasModel.floor?.departments?.isNotEmpty ?? false,
staticData: _gasModel.floor?.departments ?? [],
showAsBottomSheet: true,
onSelect: (value) {
_gasModel.department = value;
},
),
8.height,
if (_gasModel.gazRefillDetails?.isEmpty ?? true)
AppFilledButton(
label: context.translation.add,
maxWidth: true,
textColor: Colors.white,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.neutral50,
onPressed: _add,
), ),
8.height, ListView.builder(
SingleItemDropDownMenu<Building, NullableLoadingProvider>( shrinkWrap: true,
context: context, itemCount: _gasModel.gazRefillDetails?.length,
title: context.translation.building, padding: const EdgeInsets.only(top: 12, bottom: 24),
initialValue: _gasModel.building, physics: const NeverScrollableScrollPhysics(),
enabled: _gasModel.site?.buildings?.isNotEmpty ?? false, itemBuilder: (context, index) {
staticData: _gasModel.site?.buildings ?? [], return Column(
onSelect: (value) { crossAxisAlignment: CrossAxisAlignment.start,
setState(() { children: [
_gasModel.building = value; Row(
_gasModel?.floor = null; mainAxisAlignment: MainAxisAlignment.spaceBetween,
_gasModel?.department = null; crossAxisAlignment: CrossAxisAlignment.start,
}); children: [
}, Column(
), crossAxisAlignment: CrossAxisAlignment.start,
8.height, children: [
SingleItemDropDownMenu<Floor, NullableLoadingProvider>( _gasModel.gazRefillDetails[index].gasType?.name?.heading5(context),
context: context, 8.height,
title: context.translation.floor, ("${context.translation.quantity}: ${_gasModel.gazRefillDetails[index].requestedQty}").bodyText(context),
initialValue: _gasModel.floor, ("${context.translation.cylinderSize}: ${_gasModel.gazRefillDetails[index].cylinderSize?.name}").bodyText(context),
enabled: _gasModel.building?.floors?.isNotEmpty ?? false, ("${context.translation.cylinderType}: ${_gasModel.gazRefillDetails[index].cylinderType?.name}").bodyText(context),
staticData: _gasModel.building?.floors ?? [], ],
onSelect: (value) { ),
setState(() { Container(
_gasModel.floor = value; height: 48.toScreenWidth,
_gasModel?.department = null; width: 48.toScreenWidth,
}); decoration: BoxDecoration(
}, borderRadius: BorderRadius.circular(100),
), border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
8.height,
SingleItemDropDownMenu<Department, NullableLoadingProvider>(
context: context,
title: context.translation.department,
initialValue: _gasModel.department,
enabled: _gasModel.floor?.departments?.isNotEmpty ?? false,
staticData: _gasModel.floor?.departments ?? [],
onSelect: (value) {
_gasModel.department = value;
},
),
8.height,
if (_gasModel.gazRefillDetails?.isEmpty ?? true)
AppFilledButton(
label: context.translation.add,
maxWidth: true,
textColor: Colors.white,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.neutral50,
onPressed: _add,
),
ListView.builder(
shrinkWrap: true,
itemCount: _gasModel.gazRefillDetails?.length,
padding: const EdgeInsets.only(top: 12, bottom: 24),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_gasModel.gazRefillDetails[index].gasType?.name?.heading5(context),
8.height,
("${context.translation.quantity}: ${_gasModel.gazRefillDetails[index].requestedQty}").bodyText(context),
("${context.translation.cylinderSize}: ${_gasModel.gazRefillDetails[index].cylinderSize?.name}").bodyText(context),
("${context.translation.cylinderType}: ${_gasModel.gazRefillDetails[index].cylinderType?.name}").bodyText(context),
],
), ),
Container( padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight),
height: 48.toScreenWidth, child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50),
width: 48.toScreenWidth, ).onPress(() {
decoration: BoxDecoration( _delete(index);
borderRadius: BorderRadius.circular(100), }),
border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30), ],
), ),
padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight), const Divider().defaultStyle(context),
child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50), ("${context.translation.site}: ${_gasModel.site?.custName}").bodyText(context),
).onPress(() { ("${context.translation.building}: ${_gasModel.building?.name}").bodyText(context),
_delete(index); ("${context.translation.floor}: ${_gasModel.floor?.name}").bodyText(context),
}), ("${context.translation.department}: ${_gasModel.department?.departmentName}").bodyText(context),
], ],
), ).toShadowContainer(context);
const Divider().defaultStyle(context), },
("${context.translation.site}: ${_gasModel.site?.custName}").bodyText(context), ),
("${context.translation.building}: ${_gasModel.building?.name}").bodyText(context), ],
("${context.translation.floor}: ${_gasModel.floor?.name}").bodyText(context),
("${context.translation.department}: ${_gasModel.department?.departmentName}").bodyText(context),
],
).toShadowContainer(context);
},
),
// 8.height,
// // todo sikander, check it with FM
// AppTextFormField(
// labelText: context.translation.comments,
// textInputType: TextInputType.multiline,
// alignLabelWithHint: true,
// onChange: (text) {
// _gasModel.comment = text;
// },
// ),
//40.height,
],
),
), ),
).expanded, ).expanded,
16.height, 16.height,
@ -241,11 +231,10 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
} }
void _add() async { void _add() async {
if (_formKey.currentState.validate() && await _currentDetails.validate(context) && await _gasModel.validate(context)) { if (_currentDetails.validate(context) && _gasModel.validate(context)) {
_formKey.currentState.save();
_gasModel.gazRefillDetails.add(_currentDetails); _gasModel.gazRefillDetails.add(_currentDetails);
_quantityController.clear();
_currentDetails = GasRefillDetails(); _currentDetails = GasRefillDetails();
_requestedQuantity = null;
setState(() {}); setState(() {});
} }
} }

@ -8,7 +8,6 @@ import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart'; import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart';
@ -16,6 +15,7 @@ import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/timer_model.dart'; import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart'; import '../../../../controllers/providers/api/hospitals_provider.dart';
@ -53,17 +53,29 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
final TextEditingController _workingHoursController = TextEditingController(); final TextEditingController _workingHoursController = TextEditingController();
GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []); GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []);
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey _DetailsKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
bool _firstTime = true; bool _firstTime = true;
Lookup _deliveredQuantity;
static List<Lookup> deliveredQuantity = [
Lookup(name: "1", id: 1, value: 1),
Lookup(name: "2", id: 2, value: 2),
Lookup(name: "3", id: 3, value: 3),
Lookup(name: "4", id: 4, value: 4),
Lookup(name: "5", id: 5, value: 5)
];
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (widget.gasRefillModel != null) { if (widget.gasRefillModel != null) {
_formModel.fromGasRefillModel(widget.gasRefillModel); _formModel.fromGasRefillModel(widget.gasRefillModel);
_commentController.text = _formModel.comment ?? ""; _commentController.text = _formModel.comment ?? "";
try {
_deliveredQuantity = deliveredQuantity.singleWhere((element) => element.value == _formModel.gazRefillDetails[0].deliverdQty);
_currentDetails.deliverdQty = _deliveredQuantity.value;
} catch (ex) {}
} }
} }
@ -86,11 +98,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
return false; return false;
} }
if (_formModel.gazRefillDetails?.isNotEmpty ?? false) { if (_formModel.gazRefillDetails?.isNotEmpty ?? false) {
if (!(await _addNewModel(context))) return; if (!(_addNewModel(context))) return;
} }
setState(() {}); setState(() {});
_formKey.currentState.save();
_formModel.comment = _commentController.text; _formModel.comment = _commentController.text;
int status = widget.gasRefillModel == null int status = widget.gasRefillModel == null
? null /*await _gasRefillProvider.createModel( ? null /*await _gasRefillProvider.createModel(
@ -119,17 +130,20 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
} }
} }
Future<bool> _addNewModel(BuildContext context) async { bool _addNewModel(BuildContext context) {
_validate = true; _validate = true;
if (!_formKey.currentState.validate()) { if (_currentDetails.deliverdQty == null) {
Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.quantity}");
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;
if (!(await _currentDetails.validate(context))) { _currentDetails.requestedQty = _formModel.gazRefillDetails[0].requestedQty;
if (!(_currentDetails.validate(context))) {
setState(() {}); setState(() {});
return false; return false;
} }
@ -184,123 +198,129 @@ 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: Form( body: SafeArea(
key: _formKey, child: LoadingManager(
child: SafeArea( isLoading: _isLoading,
child: LoadingManager( isFailedLoading: false,
isLoading: _isLoading, stateCode: 200,
isFailedLoading: false, onRefresh: () async {},
stateCode: 200, child: Column(
onRefresh: () async {}, crossAxisAlignment: CrossAxisAlignment.stretch,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.stretch, SingleChildScrollView(
children: [ padding: const EdgeInsets.all(16),
SingleChildScrollView( child: Column(
padding: const EdgeInsets.all(16), crossAxisAlignment: CrossAxisAlignment.stretch,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.stretch, Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, context.translation.gasRefill.heading5(context),
children: [ 8.height,
context.translation.gasRefill.heading5(context), '${context.translation.gasRequest}: ${widget.gasRefillModel.gazRefillDetails[0].gasType.name}'.bodyText(context),
8.height, '${context.translation.cylinderType}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderType.name}'.bodyText(context),
'${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.name}'.bodyText(context),
/// TBD '${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty ?? 0}'.bodyText(context),
'${context.translation.gasRequest}: ${widget.gasRefillModel.gazRefillDetails[0].gasType.name}'.bodyText(context), '${context.translation.site}: ${widget.gasRefillModel.site?.name}'.bodyText(context),
'${context.translation.cylinderType}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderType.name}'.bodyText(context), ],
'${context.translation.cylinderSize}: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.name}'.bodyText(context), ).toShadowContainer(context),
'${context.translation.quantity}: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty ?? 0}'.bodyText(context), 8.height,
'${context.translation.site}: ${widget.gasRefillModel.site?.name}'.bodyText(context), AppTimer(
], label: context.translation.workingHours,
).toShadowContainer(context), timer: _formModel.timer,
8.height, enabled: _formModel.endDate == null,
AppTimer( onChange: (timer) async {
label: context.translation.workingHours, _formModel.timer = timer;
timer: _formModel.timer, return true;
enabled: _formModel.endDate == null, },
onChange: (timer) async { ),
_formModel.timer = timer; 8.height,
return true; SingleItemDropDownMenu<Lookup, GasStatusProvider>(
}, context: context,
), title: context.translation.requestStatus,
8.height, initialValue: _formModel.status,
SingleItemDropDownMenu<Lookup, GasStatusProvider>( onSelect: (value) {
context: context, if (value?.value == 0) {
title: context.translation.requestStatus, "Status cannot be change to ${value.name}.".addTranslation.showToast;
initialValue: _formModel.status, setState(() {});
onSelect: (value) { return;
if (value?.value == 0) { }
"Status cannot be change to ${value.name}.".addTranslation.showToast; if (value != null) {
setState(() {}); _formModel.status = value;
return; }
} },
if(value!=null) { ),
_formModel.status = value; 8.height,
} SingleItemDropDownMenu<Lookup, NullableLoadingProvider>(
}, context: context,
), title: context.translation.quantity,
8.height, initialValue: _deliveredQuantity,
AppTextFormField( staticData: deliveredQuantity,
initialValue: _formModel.gazRefillDetails[0]?.deliverdQty?.toString(), onSelect: (value) {
labelText: context.translation.deliveredQuantity, _deliveredQuantity = value;
onSaved: (value) { _currentDetails.deliverdQty = value.value;
_currentDetails?.deliverdQty = double.tryParse(value); },
}, ),
textInputType: TextInputType.number, 8.height,
controller: _deliveredQuantityController, // AppTextFormField(
validator: (value) => value == null || value.isEmpty // initialValue: _formModel.gazRefillDetails[0]?.deliverdQty?.toString(),
? context.translation.requiredField // labelText: context.translation.deliveredQuantity,
: Validator.isNumeric(value) // onSaved: (value) {
? null // _currentDetails?.deliverdQty = double.tryParse(value);
: context.translation.onlyNumbers, // },
), // textInputType: TextInputType.number,
8.height, // controller: _deliveredQuantityController,
// validator: (value) => value == null || value.isEmpty
// ? context.translation.requiredField
// : Validator.isNumeric(value)
// ? null
// : 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