|
|
|
|
@ -38,21 +38,25 @@ class NewGasRefillRequestPage extends StatefulWidget {
|
|
|
|
|
class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
|
|
|
|
|
late GasRefillDetails _currentDetails;
|
|
|
|
|
late GasRefillModel _gasModel;
|
|
|
|
|
late GlobalKey<FormState> _formKey;
|
|
|
|
|
late TextEditingController _quantityController;
|
|
|
|
|
Lookup? _requestedQuantity;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_formKey = GlobalKey<FormState>();
|
|
|
|
|
_currentDetails = GasRefillDetails();
|
|
|
|
|
_gasModel = GasRefillModel(gazRefillDetails: []);
|
|
|
|
|
_quantityController = TextEditingController();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_quantityController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -63,175 +67,162 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
child: Form(
|
|
|
|
|
key: _formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
16.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, GasTypesProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.gasType,
|
|
|
|
|
initialValue: _currentDetails.gasType,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.gasType = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
controller: _quantityController,
|
|
|
|
|
labelText: context.translation.quantity,
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
validator: (value) => Validator.hasValue(value!)
|
|
|
|
|
? Validator.isNumeric(value)
|
|
|
|
|
? null
|
|
|
|
|
: context.translation.onlyNumbers
|
|
|
|
|
: context.translation.requiredField,
|
|
|
|
|
onSaved: (text) {
|
|
|
|
|
_currentDetails.requestedQty = double.tryParse(text ?? "") ?? 0;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.cylinderType,
|
|
|
|
|
initialValue: _currentDetails.cylinderType,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.cylinderType = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.cylinderSize,
|
|
|
|
|
initialValue: _currentDetails.cylinderSize,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.cylinderSize = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.site,
|
|
|
|
|
initialValue: _gasModel.site,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_gasModel.site = value;
|
|
|
|
|
_gasModel.building = null;
|
|
|
|
|
_gasModel.floor = null;
|
|
|
|
|
_gasModel.department = null;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
16.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, GasTypesProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.gasType,
|
|
|
|
|
initialValue: _currentDetails.gasType,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.gasType = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.quantity,
|
|
|
|
|
initialValue: _requestedQuantity,
|
|
|
|
|
staticData: gasQuantity,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_requestedQuantity = value;
|
|
|
|
|
_currentDetails.requestedQty = value?.value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.cylinderType,
|
|
|
|
|
initialValue: _currentDetails.cylinderType,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.cylinderType = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.cylinderSize,
|
|
|
|
|
initialValue: _currentDetails.cylinderSize,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
_currentDetails.cylinderSize = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
SingleItemDropDownMenu<Site, SiteProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.site,
|
|
|
|
|
initialValue: _gasModel.site,
|
|
|
|
|
showAsBottomSheet: true,
|
|
|
|
|
onSelect: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_gasModel.site = value;
|
|
|
|
|
_gasModel.building = 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,
|
|
|
|
|
SingleItemDropDownMenu<Building, NullableLoadingProvider>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: context.translation.building,
|
|
|
|
|
initialValue: _gasModel.building,
|
|
|
|
|
enabled: _gasModel.site?.buildings?.isNotEmpty ?? false,
|
|
|
|
|
staticData: _gasModel.site?.buildings ?? [],
|
|
|
|
|
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 ?? [],
|
|
|
|
|
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 ?? [],
|
|
|
|
|
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),
|
|
|
|
|
],
|
|
|
|
|
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(
|
|
|
|
|
height: 48.toScreenWidth,
|
|
|
|
|
width: 48.toScreenWidth,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
|
border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
height: 48.toScreenWidth,
|
|
|
|
|
width: 48.toScreenWidth,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
|
border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
|
|
|
|
|
),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight),
|
|
|
|
|
child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
_delete(index);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight),
|
|
|
|
|
child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
_delete(index);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
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);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
16.height,
|
|
|
|
|
@ -242,11 +233,10 @@ class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _add() async {
|
|
|
|
|
if (_formKey.currentState!.validate() && await _currentDetails.validate(context) && await _gasModel.validate(context)) {
|
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
|
if (_currentDetails.validate(context) && _gasModel.validate(context)) {
|
|
|
|
|
_gasModel.gazRefillDetails!.add(_currentDetails);
|
|
|
|
|
_quantityController.clear();
|
|
|
|
|
_currentDetails = GasRefillDetails();
|
|
|
|
|
_requestedQuantity = null;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|