gas refill

main_design2.0
nextwo 2 years ago
parent e21bde0153
commit cef6b1a77c

@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
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/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
@ -34,43 +32,12 @@ class GasRefillDetailsPage extends StatefulWidget {
class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
GasRefillModel _model = GasRefillModel(gazRefillDetails: []);
bool _enableEdit = false;
bool _validate = false;
UserProvider _userProvider;
SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider;
bool _isLoading = false;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
_isLoading = true;
setState(() {});
int status = await _gasRefillProvider.updateModel(user: _userProvider.user, host: _settingProvider.host, newModel: _model, oldModel: widget.model);
_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: context.translation.successfulRequestMessage,
);
_enableEdit = false;
_validate = false;
//Navigator.of(context).pop();
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
@override
void initState() {
_model.fromGasRefillModel(widget.model);
@ -81,8 +48,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
_gasRefillProvider = Provider.of<GasRefillProvider>(context);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillDetails),
key: _scaffoldKey,
@ -126,6 +92,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// TBD
//StatusLabel(
//label: item.priority.name,
//id: serviceRequest.priority.id,
@ -155,11 +122,11 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
),
),
).onPress(
// (widget.model.status?.value ?? 0) == 2
// ? null
// :
(widget.model.status?.value ?? 0) == 2
? null
:
() async {
// _enableEdit = !_enableEdit;
_enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model);
// setState(() {});
Navigator.push(
@ -217,6 +184,7 @@ class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
8.height,
],
).paddingAll(16),
/// TBD
(_userProvider.user.type == UsersTypes.normal_user
? Container(
height: 50,

@ -35,8 +35,7 @@ import '../../../../new_views/common_widgets/app_text_form_field.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../../providers/gas_request_providers/gas_status_provider.dart';
import '../../../widgets/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart';
class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill";
@ -171,7 +170,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (_firstTime) {
String _clientName;
if (widget.gasRefillModel != null) {
_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
//_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = DateTime.tryParse(_formModel.expectedDate??"");
_gasRefillProvider.timer = TimerModel(startAt: DateTime.tryParse(widget.gasRefillModel?.startDate??""), endAt: DateTime.tryParse(widget.gasRefillModel?.endDate??""));
_clientName = _formModel.site.custName;
@ -287,381 +286,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
],
),
)
// SingleChildScrollView(
// padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Center(
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text(
// "${widget.gasRefillModel == null ? "Request" : "Update"} Gas Refill",
// style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
// ),
// ),
// ),
// // const SizedBox(height: 4,),
// // ASubTitle(context.translation.title),
// // if(_validate && _formModel.title == null)
// // ASubTitle(context.translation.requiredWord,color: Colors.red,),
// // SizedBox(height: 4,),
// // ATextFormField(
// // initialValue: _formModel?.title,
// // textAlign: TextAlign.center,
// // style: Theme.of(context).textTheme.subtitle1,
// // textInputType: TextInputType.text,
// // onSaved: (value){
// // _formModel.title = value;
// // },
// // ),
// // const SizedBox(height: 8,),
// ASubTitle(context.translation.status),
// if (_validate && _formModel.status == null)
// ASubTitle(
// context.translation.requiredWord,
// color: Colors.red,
// ),
// const SizedBox(
// height: 4,
// ),
// GasStatusMenu(
// initialValue: _formModel.status ?? Lookup(value: 0),
// enabled: widget.gasRefillModel != null,
// onSelect: (status) {
// _formModel.status = status;
// },
// ),
// const SizedBox(
// height: 8,
// ),
// Divider(
// color: Theme.of(context).colorScheme.primary,
// ),
// const SizedBox(
// height: 4,
// ),
// HospitalAutoCompleteField(
// enabled: false,
// initialValue: _gasRefillProvider.hospital?.name,
// // onSave: (value){
// // _search.hospital = value;
// // },
// onSearch: (value) {
// _gasRefillProvider.hospital = value;
// _gasRefillProvider.building = null;
// _gasRefillProvider.floor = null;
// _gasRefillProvider.department = null;
// setState(() {});
// },
// ),
// const SizedBox(
// height: 8,
// ),
// BuildingTypeMenu(
// initialValue: _gasRefillProvider?.building,
// building: _gasRefillProvider?.hospital?.buildings,
// loading: _firstTime,
// enabled: widget.gasRefillModel == null,
// onSelect: (status) {
// _gasRefillProvider.building = status;
// setState(() {});
// },
// ),
// const SizedBox(height: 8),
// FloorTypeMenu(
// initialValue: _gasRefillProvider?.floor,
// floors: _gasRefillProvider?.building?.floors,
// enabled: widget.gasRefillModel == null,
// loading: _firstTime,
// onSelect: (status) {
// _gasRefillProvider.floor = status;
// setState(() {});
// },
// ),
// const SizedBox(height: 8),
// DepartmentTypeMenu(
// initialValue: _gasRefillProvider?.department,
// departments: _gasRefillProvider?.floor?.departments,
// loading: _firstTime,
// enabled: widget.gasRefillModel == null,
// onSelect: (status) {
// _gasRefillProvider.department = status;
// setState(() {});
// },
// ),
// const SizedBox(height: 8),
// if (widget.gasRefillModel != null) ASubTitle(context.translation.workingHours),
// if (widget.gasRefillModel != null) const SizedBox(height: 8),
// if (widget.gasRefillModel != null)
// Row(
// children: [
// Expanded(
// child: AppTimer(
// timer: _gasRefillProvider.timer,
// onChange: (timer) async {
// _gasRefillProvider.timer = timer;
// _formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
// _formModel.startDate = timer.startAt.toString();
// _formModel.endDate = timer.endAt.toString();
// return true;
// },
// ),
// ),
// ],
// ),
// //const SizedBox(height: 8),
// // if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
// // Column(
// // crossAxisAlignment: CrossAxisAlignment.stretch,
// // children: [
// // const ASubTitle("Expected Date"),
// // SizedBox(
// // height: 8 * AppStyle.getScaleFactor(context),
// // ),
// // ADateTimePicker(
// // date: _gasRefillProvider.expectedDateTime,
// // from: DateTime.now().subtract(const Duration(days: 365)),
// // to: DateTime.now().add(const Duration(days: 365)),
// // onDateTimePicker: (date) {
// // _gasRefillProvider.expectedDateTime = date;
// // _formModel.expectedDate = _gasRefillProvider.expectedDateTime;
// // setState(() {});
// // },
// // ),
// // ],
// // ),
// // if (_userProvider.user?.type == UsersTypes.engineer)
// // Column(
// // children: [
// // Row(
// // children: [
// // Expanded(
// // child: Column(
// // crossAxisAlignment: CrossAxisAlignment.stretch,
// // children: [
// // const ASubTitle("Start of Work"),
// // SizedBox(
// // height: 8 * AppStyle.getScaleFactor(context),
// // ),
// // ADateTimePicker(
// // date: _gasRefillProvider.startDate,
// // from: DateTime.now().subtract(const Duration(days: 365)),
// // to: DateTime.now().add(const Duration(days: 365)),
// // onDateTimePicker: (date) {
// // _gasRefillProvider.startDate = date;
// // setState(() {});
// // },
// // ),
// // ],
// // ),
// // ),
// // const SizedBox(width: 8),
// // Expanded(
// // child: Column(
// // crossAxisAlignment: CrossAxisAlignment.stretch,
// // children: [
// // const ASubTitle("End of Work"),
// // SizedBox(
// // height: 8 * AppStyle.getScaleFactor(context),
// // ),
// // ADateTimePicker(
// // date: _gasRefillProvider.endDate,
// // from: DateTime.now().subtract(const Duration(days: 365)),
// // to: DateTime.now().add(const Duration(days: 365)),
// // onDateTimePicker: (date) {
// // _gasRefillProvider.endDate = date;
// // setState(() {});
// // },
// // ),
// // ],
// // ),
// // ),
// // ],
// // ),
// // const SizedBox(height: 8),
// // ASubTitle(context.translation.workingHours),
// // const SizedBox(height: 4),
// // ATextFormField(
// // initialValue: null,
// // textAlign: TextAlign.center,
// // hintText: _gasRefillProvider.startDate == null
// // ? "0"
// // : ((_gasRefillProvider.endDate?.difference(_gasRefillProvider.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0",
// // enable: false,
// // style: Theme.of(context).textTheme.subtitle1,
// // validator: (value) => Validator.isNumeric(value) ? null : context.translation.requiredWord,
// // textInputType: TextInputType.number,
// // onSaved: (value) {
// // // _serviceReport.workHours = value;
// // },
// // ),
// // ],
// // ),
// if (widget.gasRefillModel == null)
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// const SizedBox(height: 8),
// Divider(color: Theme.of(context).colorScheme.primary),
// const SizedBox(height: 4),
// const ASubTitle("Gas Type"),
// if (_validate && _currentDetails.gasType == null) ASubTitle(context.translation.requiredWord, color: Colors.red),
// const SizedBox(height: 4),
// GasTypeMenu(
// initialValue: _currentDetails.gasType,
// onSelect: (status) {
// _currentDetails.gasType = status;
// },
// ),
// const SizedBox(height: 8),
// const ASubTitle("Cylinder Size"),
// if (_validate && _currentDetails.cylinderSize == null)
// ASubTitle(
// context.translation.requiredWord,
// color: Colors.red,
// ),
// const SizedBox(
// height: 4,
// ),
// GasCylinderSizeMenu(
// initialValue: _currentDetails.cylinderSize,
// onSelect: (status) {
// _currentDetails.cylinderSize = status;
// },
// ),
// const SizedBox(
// height: 8,
// ),
// const ASubTitle("Cylinder Type"),
// if (_validate && _currentDetails.cylinderSize == null)
// ASubTitle(
// context.translation.requiredWord,
// color: Colors.red,
// ),
// const SizedBox(
// height: 4,
// ),
// GasCylinderTypesMenu(
// initialValue: _currentDetails.cylinderType,
// onSelect: (status) {
// _currentDetails.cylinderType = status;
// },
// ),
// const SizedBox(
// height: 8,
// ),
// ASubTitle(context.translation.requestedQuantity),
// if (_validate && _currentDetails?.requestedQty == null)
// ASubTitle(
// context.translation.requiredWord,
// color: Colors.red,
// ),
// SizedBox(
// height: 4,
// ),
// ATextFormField(
// initialValue: (_currentDetails?.requestedQty ?? "").toString(),
// textAlign: TextAlign.center,
// controller: _requestedQuantityController,
// style: Theme.of(context).textTheme.subtitle1,
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
// textInputType: TextInputType.number,
// onChange: (value) {
// _currentDetails?.requestedQty = double.tryParse(value);
// },
// ),
// if (widget.gasRefillModel != null) const SizedBox(height: 16),
// if (widget.gasRefillModel != null) ASubTitle(context.translation.deliveredQuantity),
// if (widget.gasRefillModel != null && _validate && _currentDetails?.deliverdQty == null)
// ASubTitle(
// context.translation.requiredWord,
// color: Colors.red,
// ),
// if (widget.gasRefillModel != null) const SizedBox(height: 4),
// if (widget.gasRefillModel != null)
// ATextFormField(
// initialValue: (_currentDetails?.deliverdQty ?? "").toString(),
// textAlign: TextAlign.center,
// controller: _deliveredQuantityController,
// style: Theme.of(context).textTheme.subtitle1,
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
// textInputType: TextInputType.number,
// onChange: (value) {
// _currentDetails?.deliverdQty = double.tryParse(value);
// },
// ),
// const SizedBox(height: 16),
// AButton(
// text: context.translation.add,
// onPressed: ()async{await _addNewModel.call(context);},
// ),
// ],
// ),
// const SizedBox(height: 16),
// if (_formModel.gazRefillDetails.isNotEmpty) const ASubTitle("Gas Requests"),
// ListView.builder(
// key: _DetailsKey,
// shrinkWrap: true,
// physics: const ClampingScrollPhysics(),
// itemCount: _formModel.gazRefillDetails.length,
// itemBuilder: (context, index) {
// final model = _formModel.gazRefillDetails[index];
// return GasRefillCreateDetailsItem(
// isUpdate: widget.gasRefillModel != null,
// model: model,
// onPressed: () {
// if (widget.gasRefillModel != null) {
// model.selectedForEditing = !(model.selectedForEditing ?? false);
// }
// if (widget.gasRefillModel == null) {
// _formModel.gazRefillDetails.remove(model);
// }
// setState(() {});
// },
// );
// }),
// if (widget.gasRefillModel != null) const SizedBox(height: 16),
// if (widget.gasRefillModel != null) const ASubTitle("Nurse Signature"),
// if (widget.gasRefillModel != null)
// ESignature(
// oldSignature: _formModel.nurseSignature,
// newSignature: _formModel.localNurseSignature,
// onChange: (signature) {
// if (signature == null || signature.isEmpty) {
// return;
// }
// _formModel.localNurseSignature = signature;
// _formModel.nurseSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// },
// ),
// if (widget.gasRefillModel != null)
// const SizedBox(
// height: 8,
// ),
// if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"),
// if (widget.gasRefillModel != null)
// ESignature(
// oldSignature: _formModel.engSignature,
// newSignature: _formModel.localEngineerSignature,
// onChange: (signature) {
// if (signature == null || signature.isEmpty) {
// return;
// }
// _formModel.localEngineerSignature = signature;
// _formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// },
// ),
// const SizedBox(height: 16),
// AButton(
// text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
// onPressed:()async{_onSubmit.call(context);},
// ),
// const SizedBox(height: 100)
// ],
// ),
// ),
),
),
),
),
);

@ -4,13 +4,11 @@ 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/settings/setting_provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_list.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/app_search_field.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
class TrackGasRefillPage extends StatefulWidget {
@ -56,65 +54,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
children: [
Column(
children: [
// Container(
// color: Colors.white,
// padding: EdgeInsets.symmetric(horizontal: 10.toScreenWidth, vertical: 15.toScreenWidth),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Expanded(
// child: SizedBox(
// height: 40.toScreenHeight,
// child: const AppSearchField())),
// SizedBox(width: 20.toScreenWidth,),
// Text(context.translation.filter, style: TextStyle(
// color: AppColor.primary50,
// fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
// fontWeight: FontWeight.w500
// ),)
// ],
// ),
// ),
// Container(
// color: AColors.white,
// padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
// child: Column(
// children: [
// Row(
// children: [
// const ABackButton(),
// Expanded(
// child: Center(
// child: Text(
// "Gas Refill Requests",
// style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic),
// ),
// ),
// ),
// const SizedBox(
// width: 48,
// )
// ],
// ),
// ],
// ),
// ),
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16.0),
// child: ASwitchButton(
// title: "Most Recent",
// value: mostRecent,
// onChange: (value) async {
// mostRecent = value;
// _gasRefillProvider.reset();
// await _gasRefillProvider.getRequests(
// user: _userProvider.user,
// host: _settingProvider.host,
// mostRecent: mostRecent,
// );
// },
// ),
// ),
Expanded(
child: GasRefillList(
nextPage: _gasRefillProvider.nextPage,

@ -39,11 +39,12 @@ class GasRefillItem extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
StatusLabel(
label: "COMPLETE",
id: 0,
textColor: AColors.getPriorityStatusTextColor(0),
backgroundColor: AColors.getPriorityStatusColor(0)),
/// TBD
// StatusLabel(
// label: ,
// id: ,
// textColor: AColors.getPriorityStatusTextColor(),
// backgroundColor: AColors.getPriorityStatusColor()),
8.width,
StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)),
1.width.expanded,

Loading…
Cancel
Save