gas refill

main_design2.0
nextwo 2 years ago
parent d6de203ba0
commit 4cc12691ac

@ -0,0 +1,7 @@
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.5">
<path d="M12.5703 13.9869C12.3589 14.1982 12.0976 14.3596 11.8145 14.4541L9.07994 15.3655C8.88258 15.4314 8.67676 15.4648 8.46853 15.4648C7.95201 15.4648 7.46642 15.2637 7.10123 14.8984C6.57997 14.3771 6.40105 13.6189 6.63416 12.9197L7.54569 10.1852C7.64001 9.90203 7.80157 9.64061 8.01277 9.42942L13.919 3.52319H2.36328C1.06017 3.52319 0 4.58336 0 5.88647V19.6365C0 20.9396 1.06017 21.9997 2.36328 21.9997H16.1133C17.4164 21.9997 18.4766 20.9396 18.4766 19.6365V8.08071L12.5703 13.9869Z" fill="#163A51"/>
<path d="M8.92453 10.341C8.85376 10.4118 8.80048 10.498 8.76886 10.593L7.85732 13.3275C7.7801 13.5591 7.84039 13.8144 8.013 13.987C8.18564 14.1597 8.44096 14.22 8.67256 14.1427L11.4071 13.2312C11.5021 13.1996 11.5883 13.1463 11.659 13.0755L19.7107 5.02392L16.9762 2.28943L8.92453 10.341Z" fill="#163A51"/>
<path d="M20.4698 0.314384C20.0503 -0.10512 19.3701 -0.10512 18.9506 0.314384L17.8872 1.37782L20.6217 4.11235L21.6852 3.04891C22.1047 2.62941 22.1047 1.94926 21.6852 1.52975L20.4698 0.314384Z" fill="#163A51"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -35,7 +35,7 @@ class GasRefillProvider extends ChangeNotifier {
bool nextPage = true;
// list of user requests
List<GasRefillModel> items;
List<gasModel.GasRefillModel> items;
// when requests in-process _loading = true
// done _loading = true
@ -67,7 +67,7 @@ class GasRefillProvider extends ChangeNotifier {
if (stateCode >= 200 && stateCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(response.body)["data"];
List<GasRefillModel> itemsPage = requestsListJson.map((request) => GasRefillModel.fromJson(request)).toList();
List<gasModel.GasRefillModel> itemsPage = requestsListJson.map((request) => gasModel.GasRefillModel.fromJson(request)).toList();
items ??= [];
items.addAll(itemsPage);
notifyListeners();
@ -138,15 +138,15 @@ class GasRefillProvider extends ChangeNotifier {
Future<int> updateModel({
@required String host,
@required User user,
@required GasRefillModel oldModel,
@required GasRefillModel newModel,
@required gasModel.GasRefillModel oldModel,
@required gasModel.GasRefillModel newModel,
}) async {
Map<String, dynamic> body = {
"id": newModel.id,
"gazRefillNo": newModel.title ?? "",
"gazRefillNo": newModel.gazRefillNo ?? "",
"status": newModel.status.toJson(),
//"expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate,
if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(),
if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(),
if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(),
@ -158,17 +158,17 @@ class GasRefillProvider extends ChangeNotifier {
"building": building?.toJson(includeFloors: false),
"floor": floor?.toJson(includeDepartments: false),
"department": department?.toJson(),
"engSignature": newModel.signatureEngineer,
"nurseSignature": newModel.signatureNurse,
"engSignature": newModel.engSignature,
"nurseSignature": newModel.nurseSignature,
};
body["gazRefillDetails"] = newModel.details
body["gazRefillDetails"] = newModel.gazRefillDetails
.map((model) => {
"gasType": model.type.toJson(),
"gasType": model.gasType.toJson(),
"cylinderSize": model.cylinderSize.toJson(),
"cylinderType": model.cylinderType.toJson(),
"requestedQty": model.requestedQuantity,
"deliverdQty": model.deliveredQuantity,
"requestedQty": model.requestedQty,
"deliverdQty": model.deliverdQty,
})
.toList();
log(body.toString());

@ -253,11 +253,16 @@
"serialNumber" : "الرقم التسلسلي",
"device" : "الجهاز",
"pickAsset" : "إختر جهاز",
"filter" : "تصنيف",
"pickAsset" : "إختر جهاز",
"firstAction" : "First Action",
"priority" : "الأولوية",
"equipmentStatus" : "حالة المعدات",
"attachImage" : "إرفاق صورة",
"callComments" : "تعليقات الطلب",
"comments" : "تعليقات",
"recordVoice" : "تسجيل صوت"
"recordVoice" : "تسجيل صوت",
"gasRefillDetails" : "تفاصيل اعادة تعبئة غاز",
"updateRequest" : "تعديل الطلب",
"gasRefill" : "اعادة تعبئة غاز"
}

@ -254,6 +254,8 @@
"serialNo" : "Serial No",
"device" : "Device",
"pickAsset" : "Pick Asset",
"filter" : "Filter",
"pickAsset" : "Pick Asset",
"firstAction" : "First Action",
"workOrder" : "Work Orders",
"viewWorkOrder" : "View All Work Order",
@ -266,5 +268,9 @@
"callComments" : "Call Comments",
"comments": "Comments",
"recordVoice" : "Record Voice",
"gasRefillDetails" : "Gas Refill Details",
"updateRequest" : "Update Request",
"gasRefill" : "Gas Refill",
"recordVoice" : "Record Voice",
"assetDetails" : "Asset Details"
}

@ -20,7 +20,6 @@ import 'package:test_sa/controllers/providers/api/status_drop_down/employee/assi
import 'package:test_sa/controllers/providers/api/status_drop_down/employee/engineers_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_size_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_type_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_task_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_visit_status_provider.dart';
@ -51,6 +50,7 @@ import 'package:test_sa/new_views/pages/splash_page.dart';
import 'package:test_sa/providers/department_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/gas_status_provider.dart';
import 'package:test_sa/providers/gas_request_providers/gas_types_provider.dart';
import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';

@ -1,4 +1,5 @@
import 'dart:developer';
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -31,6 +32,8 @@ class GasRefillModel {
this.assignedEmployee,
this.status,
this.gazRefillDetails,
this.localEngineerSignature,
this.localNurseSignature
});
GasRefillModel.fromJson(dynamic json) {
@ -48,7 +51,6 @@ class GasRefillModel {
site = json['site'] != null ? Site.fromJson(json['site']) : null;
building = json['building'] != null ? Building.fromJson(json['building']) : null;
floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
log(json['department']);
department = json['department'] != null ? Department.fromJson(json['department']) : null;
assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
status = json['status'] != null ? Lookup.fromJson(json['status']) : null;
@ -78,6 +80,8 @@ class GasRefillModel {
AssignedEmployee assignedEmployee;
Lookup status;
List<GasRefillDetails> gazRefillDetails;
Uint8List localNurseSignature;
Uint8List localEngineerSignature;
GasRefillModel copyWith({
num id,
@ -173,6 +177,27 @@ class GasRefillModel {
}
return true;
}
fromGasRefillModel(GasRefillModel model) {
id = model.id;
//userId = model.userId;
site = model.site;
gazRefillNo = model.gazRefillNo;
status = Lookup.fromStatus(model.status);
gazRefillDetails = model.gazRefillDetails;
building = model.building;
floor = model.floor;
department = model.department;
startDate = model.startDate;
endDate = model.endDate;
expectedDate = model.expectedDate;
assignedEmployee = model.assignedEmployee;
localEngineerSignature = model.localEngineerSignature;
localNurseSignature = model.localNurseSignature;
engSignature = model.engSignature;
nurseSignature = model.nurseSignature;
workingHours = model.workingHours;
}
}
class GasRefillDetails {
@ -183,6 +208,7 @@ class GasRefillDetails {
this.cylinderSize,
this.requestedQty,
this.deliverdQty,
this.selectedForEditing
});
GasRefillDetails.fromJson(dynamic json) {
@ -200,6 +226,7 @@ class GasRefillDetails {
Lookup cylinderSize;
num requestedQty;
num deliverdQty;
bool selectedForEditing;
GasRefillDetails copyWith({
num id,

@ -26,6 +26,7 @@ class AppTextFormField extends StatefulWidget {
final TextInputAction textInputAction;
final VoidCallback onAction;
final Color backgroundColor;
final bool alignLabelWithHint;
const AppTextFormField({
Key key,
@ -50,6 +51,7 @@ class AppTextFormField extends StatefulWidget {
this.textInputAction,
this.onAction,
this.backgroundColor,
this.alignLabelWithHint
}) : super(key: key);
@override
@ -80,13 +82,14 @@ class _AppTextFormFieldState extends State<AppTextFormField> {
onChanged: widget.onChange,
obscureText: widget.obscureText ?? false,
keyboardType: widget.textInputType,
maxLines: widget.textInputType == TextInputType.multiline ? null : 1,
maxLines: widget.textInputType == TextInputType.multiline ? 4 : 1,
obscuringCharacter: "*",
controller: widget.controller,
textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next,
onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(),
style: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500),
decoration: InputDecoration(
alignLabelWithHint: widget.alignLabelWithHint,
border: border,
disabledBorder: border,
focusedBorder: border,

@ -46,7 +46,7 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue;
});
if (result.isNotEmpty) _selectedItem = result.first;
if (result?.isNotEmpty??false) _selectedItem = result.first;
if ((widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) {
widget.onSelect(_selectedItem);
}
@ -65,7 +65,7 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue;
});
if (result.isNotEmpty) {
if (result?.isNotEmpty??false) {
_selectedItem = result.first;
} else {
_selectedItem = null;

@ -24,7 +24,7 @@ class MyRequestsPage extends StatelessWidget {
height: 50,
child: AppSearchField())),
SizedBox(width: 20,),
Text("Filter", style: TextStyle(
Text(context.translation.filter, style: TextStyle(
color: AppColor.primary50,
fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
fontWeight: FontWeight.w500
@ -37,13 +37,13 @@ class MyRequestsPage extends StatelessWidget {
body: TabBarView(
children: const <Widget>[
Center(
child: Text("It's cloudy here"),
child: Text(""),
),
Center(
child: Text("It's rainy here"),
child: Text(""),
),
Center(
child: Text("It's sunny here"),
child: Text(""),
),
],
),

@ -0,0 +1,34 @@
import 'dart:convert';
import 'package:http/http.dart';
import '../../controllers/api_routes/api_manager.dart';
import '../../controllers/api_routes/urls.dart';
import '../../models/lookup.dart';
import '../loading_list_notifier.dart';
class GasStatusProvider extends LoadingListNotifier<Lookup> {
@override
Future getDate() async {
if (loading ?? false) return -2;
loading = true;
notifyListeners();
try {
Response response = await ApiManager.instance.get(URLs.getGasStatus);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
}
loading = false;
notifyListeners();
return response.statusCode;
} catch (error) {
loading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -1,41 +1,38 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
import 'package:test_sa/controllers/localization/localization.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';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_update_details_item.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../extensions/text_extensions.dart';
import '../../../../models/enums/user_types.dart';
import '../../../../models/new_models/gas_refill_model.dart';
import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget {
class GasRefillDetailsPage extends StatefulWidget {
GasRefillModel model;
GasRefillDetails({Key key, this.model}) : super(key: key);
GasRefillDetailsPage({Key key, this.model}) : super(key: key);
@override
State<GasRefillDetails> createState() => _GasRefillDetailsState();
State<GasRefillDetailsPage> createState() => _GasRefillDetailsPageState();
}
class _GasRefillDetailsState extends State<GasRefillDetails> {
GasRefillModel _model = GasRefillModel();
class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
GasRefillModel _model = GasRefillModel(gazRefillDetails: []);
bool _enableEdit = false;
bool _validate = false;
UserProvider _userProvider;
@ -76,7 +73,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
@override
void initState() {
_model?.fromGasRefillModel(widget.model);
_model.fromGasRefillModel(widget.model);
super.initState();
}
@ -87,6 +84,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
_settingProvider = Provider.of<SettingProvider>(context);
_gasRefillProvider = Provider.of<GasRefillProvider>(context);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillDetails),
key: _scaffoldKey,
body: SafeArea(
child: Form(
@ -98,33 +96,69 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
onRefresh: () async {},
child: Column(
children: [
Container(
color: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row(
children: [
ABackButton(
onPressed: () {
Navigator.of(context).pop(_model);
},
informationCard()
],
),
Expanded(
child: Center(
child: Text(
"Gas Refill Request",
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
);
}
Widget informationCard() {
return Container(
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
),
child: Column(
children: [
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//StatusLabel(
//label: item.priority.name,
//id: serviceRequest.priority.id,
//textColor: AColors.getPriorityStatusTextColor(serviceRequest.priority.id),
//backgroundColor: AColors.getPriorityStatusColor(serviceRequest.priority.id)
//),
8.width,
StatusLabel(
label: widget.model.status?.name??"",
textColor: AColors.getRequestStatusTextColor(widget.model.status?.value??0),
backgroundColor: AColors.getRequestStatusColor(widget.model.status?.value??0)),
8.height,
Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
],
),
1.width.expanded,
if (_userProvider.user.type == UsersTypes.engineer)
AIconButton(
iconData: /*_enableEdit ? Icons.cancel :*/ Icons.edit,
color: Theme.of(context).colorScheme.onPrimary,
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: (widget.model.status?.value ?? 0) == 2
? null
: () async {
CircleAvatar(
radius: 25,
backgroundColor: AppColor.neutral30,
child: CircleAvatar(
radius: 24,
backgroundColor: Colors.white,
child: Padding(
padding: const EdgeInsets.only(left: 3.0),
child: SvgPicture.asset('assets/images/update.svg'),
),
),
).onPress(
// (widget.model.status?.value ?? 0) == 2
// ? null
// :
() async {
// _enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model);
// setState(() {});
@ -141,124 +175,102 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
}
});
setState(() {});
},
),
const SizedBox(
width: 16,
)
},),
],
),
),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
child: Column(
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RequestInfoRow(
title: "Gas Refill No",
info: _model.title,
),
RequestInfoRow(
title: context.translation.hospital,
info: _model.clientName,
),
RequestInfoRow(
title: "Building",
info: _model.building?.name,
),
RequestInfoRow(
title: "Floor",
info: _model.floor?.name,
),
RequestInfoRow(
title: "Department",
info: _model.department?.departmentName,
),
RequestInfoRow(
title: context.translation.startDate,
info: _model.startDate == null ? null : "${DateFormat.yMd().format(_model.startDate)} ${DateFormat.Hms().format(_model.startDate)}",
),
RequestInfoRow(
title: context.translation.endDate,
info: _model.endDate == null ? null : "${DateFormat.yMd().format(_model.endDate)} ${DateFormat.Hms().format(_model.endDate)}",
),
_enableEdit
? Column(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8,
Text(
'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
ASubTitle(context.translation.status),
if (_validate && _model.status == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
Text(
'Cylinder Size: ${widget.model.gazRefillDetails[0].cylinderSize.value}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 4,
Text(
'Site: ${widget.model.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
GasStatusMenu(
initialValue: _model.status,
onSelect: (status) {
_model.status = status;
},
)
],
)
: Row(
children: [
Expanded(
child: Text(
"${context.translation.status} : ",
style: Theme.of(context).textTheme.subtitle2,
textScaleFactor: AppStyle.getScaleFactor(context),
),
),
if (_model.status?.id != null) StatusLabel(label: _model.status.name, backgroundColor: AColors.getGasStatusColor(_model.status.id)),
Text(widget.model.startDate?.toServiceRequestCardFormat??"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
],
),
const SizedBox(
height: 8,
),
const ASubTitle("Gas Requests"),
const SizedBox(
height: 8,
),
ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _model.details.length,
itemBuilder: (context, index) {
final details = _model.details[index];
return GasRefillUpdateDetailsItem(
details: details,
validate: _validate,
enableEdit: _enableEdit,
);
}),
if (_enableEdit)
Column(
children: [
const SizedBox(
height: 16,
8.height,
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
8.height,
Text(
'Request Quantity: ${widget.model.gazRefillDetails[0].requestedQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
AButton(
text: context.translation.update,
onPressed: _update,
Text(
'Delivered Quantity: ${widget.model.gazRefillDetails[0].deliverdQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
8.height,
],
).paddingAll(16),
(_userProvider.user.type == UsersTypes.normal_user
? Container(
height: 50,
padding: const EdgeInsets.only(left: 16, right: 16),
alignment: Alignment.center,
width: double.infinity,
decoration: const ShapeDecoration(
color: Color(0xFFEAF1F4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
],
),
),
child: Row(
children: [
Text(
'Comment here...',
style: AppTextStyles.heading6.copyWith(
color: AppColor.neutral50.withOpacity(.6),
),
).expanded,
SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70),
],
),
)
: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
16.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'View Comments',
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
),
4.width,
const Icon(
Icons.arrow_forward,
color: Color(0xFF4A8DB7),
size: 14,
)
],
),
],
).paddingOnly(bottom: 16, start: 16, end: 16))
.onPress(() {
}),
],
),
),
);
).paddingAll(16);
}
}

@ -9,10 +9,9 @@ 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/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
@ -29,8 +28,13 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/status/gas_refill/gas_type.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart';
import '../../../../extensions/text_extensions.dart';
import '../../../../models/new_models/gas_refill_model.dart';
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';
@ -52,9 +56,11 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider;
GasRefillDetails _currentDetails = GasRefillDetails();
final TextEditingController _requestedQuantityController = TextEditingController();
final TextEditingController _deliveredQuantityController = TextEditingController();
GasRefillModel _formModel = GasRefillModel(details: []);
final TextEditingController _commentController = TextEditingController();
final TextEditingController _workingHoursController = TextEditingController();
GasRefillModel _formModel = GasRefillModel(gazRefillDetails: []);
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey _DetailsKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@ -73,26 +79,27 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (mounted) super.setState(() {});
}
_onSubmit() async {
if (_formModel.details.isEmpty) {
if (!_addNewModel()) return;
_onSubmit(BuildContext context) async {
if (_formModel.gazRefillDetails.isEmpty) {
if (!(await _addNewModel(context))) return;
}
_isLoading = true;
setState(() {});
if (widget.gasRefillModel != null) {
if (!_formModel.validate()) {
_isLoading = false;
setState(() {});
return;
}
}
if (_gasRefillProvider.department?.name == null) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
_isLoading = false;
//_isLoading = true;
setState(() {});
return;
}
// if (widget.gasRefillModel != null) {
// if (!(await _formModel.validate(context))) {
// _isLoading = false;
// setState(() {});
// return;
// }
// }
//if(!(_formKey.currentState.validate())) return;
// if (_gasRefillProvider.department?.name == null) {
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
// _isLoading = false;
// setState(() {});
// return;
// }
int status = widget.gasRefillModel == null
? null /*await _gasRefillProvider.createModel(
@ -105,7 +112,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
oldModel: widget.gasRefillModel,
newModel: _formModel,
);
_isLoading = false;
//_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
@ -121,23 +128,24 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}
}
bool _addNewModel() {
Future<bool> _addNewModel(BuildContext context) async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
if (!_currentDetails.validate()) {
if (!(await _currentDetails.validate(context))) {
setState(() {});
return false;
}
_formModel.details.insert(0, _currentDetails);
_formModel.gazRefillDetails.insert(0, _currentDetails);
_validate = false;
Scrollable.ensureVisible(_DetailsKey.currentContext);
_requestedQuantityController.clear();
_deliveredQuantityController.clear();
_workingHoursController.clear();
_commentController.clear();
_currentDetails = GasRefillDetails();
setState(() {});
return true;
@ -145,8 +153,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
@override
void dispose() {
_requestedQuantityController.dispose();
_deliveredQuantityController.dispose();
_commentController.dispose();
_workingHoursController.dispose();
super.dispose();
}
@ -163,9 +172,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
String _clientName;
if (widget.gasRefillModel != null) {
_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = _formModel.expectedDate;
_gasRefillProvider.timer = TimerModel(startAt: widget.gasRefillModel?.startDate, endAt: widget.gasRefillModel?.endDate);
_clientName = _formModel.clientName;
_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;
} else {
_gasRefillProvider.timer = null;
_clientName = _userProvider.user?.clientName;
@ -181,6 +190,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
});
}
return Scaffold(
appBar: DefaultAppBar(title: context.translation.updateRequest),
key: _scaffoldKey,
body: Form(
key: _formKey,
@ -191,379 +201,466 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
stateCode: 200,
onRefresh: () async {},
child: SingleChildScrollView(
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
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,
Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: ShapeDecoration(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
GasStatusMenu(
initialValue: _formModel.status ?? Lookup(value: 0),
enabled: widget.gasRefillModel != null,
onSelect: (status) {
_formModel.status = status;
},
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
),
const SizedBox(
height: 8,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
8.height,
Text(
'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
Divider(
color: Theme.of(context).colorScheme.primary,
Text(
'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 4,
Text(
'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
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(() {});
},
Text(
'Site: ${widget.gasRefillModel.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
const SizedBox(
height: 8,
],
).paddingAll(16),
),
BuildingTypeMenu(
initialValue: _gasRefillProvider?.building,
building: _gasRefillProvider?.hospital?.buildings,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.building = status;
setState(() {});
12.height,
AppTextFormField(
labelText: context.translation.workingHours,
onSaved:(value){
_formModel?.workingHours = double.tryParse(value);
},
textInputType: TextInputType.number,
controller: _workingHoursController,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
),
const SizedBox(height: 8),
FloorTypeMenu(
initialValue: _gasRefillProvider?.floor,
floors: _gasRefillProvider?.building?.floors,
enabled: widget.gasRefillModel == null,
loading: _firstTime,
onSelect: (status) {
_gasRefillProvider.floor = status;
setState(() {});
12.height,
SingleItemDropDownMenu<Lookup,GasStatusProvider >(
context: context,
title: context.translation.reportStatus,
initialValue: _formModel.status,
onSelect: (value) {
_formModel.status=value;
},
),
const SizedBox(height: 8),
DepartmentTypeMenu(
initialValue: _gasRefillProvider?.department,
departments: _gasRefillProvider?.floor?.departments,
loading: _firstTime,
enabled: widget.gasRefillModel == null,
onSelect: (status) {
_gasRefillProvider.department = status;
setState(() {});
12.height,
AppTextFormField(
labelText: context.translation.deliveredQuantity,
onSaved:(value){
_currentDetails?.deliverdQty = double.tryParse(value);
},
textInputType: TextInputType.number,
controller: _deliveredQuantityController,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
),
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;
_formModel.endDate = timer.endAt;
return true;
12.height,
/// TBD
AppTextFormField(
labelText: context.translation.comments,
textInputType: TextInputType.multiline,
alignLabelWithHint: true,
controller: _commentController,
onSaved: (value){
},
),
),
],
).paddingAll(16),
AButton(
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed:()async{_onSubmit.call(context);},
).paddingAll(16),
],
),
//const SizedBox(height: 8),
// if (_userProvider.user?.type == UsersTypes.normal_user || widget.gasRefillModel != null)
// Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
)
// SingleChildScrollView(
// padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// 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(() {});
// 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,
// ),
// 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;
// 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(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;
// 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),
// ASubTitle(context.translation.workingHours),
// 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: null,
// initialValue: (_currentDetails?.deliverdQty ?? "").toString(),
// textAlign: TextAlign.center,
// hintText: _gasRefillProvider.startDate == null
// ? "0"
// : ((_gasRefillProvider.endDate?.difference(_gasRefillProvider.startDate)?.inMinutes ?? 0) / 60)?.toStringAsFixed(2)?.toString() ?? "0",
// enable: false,
// controller: _deliveredQuantityController,
// style: Theme.of(context).textTheme.subtitle1,
// validator: (value) => Validator.isNumeric(value) ? null : context.translation.requiredWord,
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
// textInputType: TextInputType.number,
// onSaved: (value) {
// // _serviceReport.workHours = value;
// onChange: (value) {
// _currentDetails?.deliverdQty = double.tryParse(value);
// },
// ),
// const SizedBox(height: 16),
// AButton(
// text: context.translation.add,
// onPressed: ()async{await _addNewModel.call(context);},
// ),
// ],
// ),
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.type == null) ASubTitle(context.translation.requiredWord, color: Colors.red),
const SizedBox(height: 4),
GasTypeMenu(
initialValue: _currentDetails.type,
onSelect: (status) {
_currentDetails.type = 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?.requestedQuantity == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
SizedBox(
height: 4,
),
ATextFormField(
initialValue: (_currentDetails?.requestedQuantity ?? "").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?.requestedQuantity = 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?.deliveredQuantity == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
if (widget.gasRefillModel != null) const SizedBox(height: 4),
if (widget.gasRefillModel != null)
ATextFormField(
initialValue: (_currentDetails?.deliveredQuantity ?? "").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?.deliveredQuantity = double.tryParse(value);
},
),
const SizedBox(height: 16),
AButton(
text: context.translation.add,
onPressed: _addNewModel,
),
],
),
const SizedBox(height: 16),
if (_formModel.details.isNotEmpty) const ASubTitle("Gas Requests"),
ListView.builder(
key: _DetailsKey,
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _formModel.details.length,
itemBuilder: (context, index) {
final model = _formModel.details[index];
return GasRefillCreateDetailsItem(
isUpdate: widget.gasRefillModel != null,
model: model,
onPressed: () {
if (widget.gasRefillModel != null) {
model.selectedForEditing = !(model.selectedForEditing ?? false);
}
if (widget.gasRefillModel == null) {
_formModel.details.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.signatureNurse,
newSignature: _formModel.localNurseSignature,
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_formModel.localNurseSignature = signature;
_formModel.signatureNurse = "${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.signatureEngineer,
newSignature: _formModel.localEngineerSignature,
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_formModel.localEngineerSignature = signature;
_formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 16),
AButton(
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed: _onSubmit,
),
const SizedBox(height: 100)
],
),
),
// 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)
// ],
// ),
// ),
),
),
),

@ -1,20 +1,17 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/localization/localization.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';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.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 '../../../../models/enums/translation_keys.dart';
import '../../../../new_views/app_style/app_color.dart';
import '../../../../new_views/common_widgets/app_search_field.dart';
import '../../../widgets/switch_button.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart';
class TrackGasRefillPage extends StatefulWidget {
static const String id = "/track-gas-refill";
@ -41,7 +38,7 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
_settingProvider = Provider.of<SettingProvider>(context);
return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillRequest),
body: SafeArea(
child: LoadingManager(
isLoading: _gasRefillProvider.isLoading,
@ -59,25 +56,25 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
children: [
Column(
children: [
Container(
color: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 15),
//margin: const EdgeInsets.all(10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: SizedBox(
height: 40,
child: AppSearchField())),
SizedBox(width: 20,),
Text("Filter", style: TextStyle(
color: AppColor.primary50,
fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
fontWeight: FontWeight.w500
),)
],
),
),
// 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),

@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import '../../../controllers/localization/localization.dart';
import '../../../models/new_models/gas_refill_model.dart';
import '../buttons/app_button.dart';
import '../titles/app_sub_title.dart';
@ -38,23 +37,23 @@ class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem>
children: [
Row(
children: [
Expanded(child: Text(widget.model.type.name)),
Expanded(child: Text(widget.model.gasType.name)),
IconButton(onPressed: widget.onPressed, color: widget.isUpdate ? AColors.cyan : AColors.red, icon: Icon(widget.isUpdate ? Icons.edit : Icons.delete))
],
),
Wrap(
spacing: 10,
children: [
Text("Quantity: ${widget.model.requestedQuantity.toStringAsFixed(0)}"),
Text("Quantity: ${widget.model.requestedQty.toStringAsFixed(0)}"),
Text("Cylinder Size: ${widget.model.cylinderSize.name}"),
Text("Cylinder Type: ${widget.model.cylinderType.name}"),
],
),
if (widget.model.deliveredQuantity != null)
if (widget.model.deliverdQty != null)
Row(
children: [
const Text("Delivered Quantity: "),
Text(widget.model.deliveredQuantity.toStringAsFixed(0)),
Text(widget.model.deliverdQty.toStringAsFixed(0)),
],
),
if (startEditing) const SizedBox(height: 16),
@ -62,16 +61,16 @@ class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem>
if (startEditing) const SizedBox(height: 4),
if (startEditing)
ATextFormField(
initialValue: widget.model.deliveredQuantity?.toString() ?? "0",
initialValue: widget.model.deliverdQty?.toString() ?? "0",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onSaved: (value) {
if (value.isNotEmpty) {
widget.model.deliveredQuantity = double.tryParse(value);
widget.model.deliverdQty = double.tryParse(value);
} else {
widget.model.deliveredQuantity = 0;
widget.model.deliverdQty = 0;
}
},
),

@ -1,7 +1,14 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import '../../../models/gas_refill/gas_refill_model.dart';
import '../../../extensions/text_extensions.dart';
import '../../../models/new_models/gas_refill_model.dart';
import '../../app_style/colors.dart';
import '../requests/request_status.dart';
class GasRefillItem extends StatelessWidget {
final int index;
@ -30,12 +37,45 @@ class GasRefillItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("priority"),
Text("process"),
StatusLabel(
label: "COMPLETE",
id: 0,
textColor: AColors.getPriorityStatusTextColor(0),
backgroundColor: AColors.getPriorityStatusColor(0)),
8.width,
StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)),
1.width.expanded,
Text(item.startDate != null ?item.startDate.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
],
),
8.height,
Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
Text(
'Gas Type: ${item.gazRefillDetails[0].gasType.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
Text(
'${context.translation.site}: ${item.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
8.height,
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'View Details',
style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
),
4.width,
const Icon(
Icons.arrow_forward,
color: Color(0xFF4A8DB7),
size: 14,
)
],
),
// Row(
// children: [
// Expanded(

@ -1,13 +1,12 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/pages/user/gas_refill/gas_refill_details.dart';
import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart';
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
import '../../../models/new_models/gas_refill_model.dart';
class GasRefillList extends StatefulWidget {
final List<GasRefillModel> items;
final bool nextPage;
@ -22,7 +21,7 @@ class GasRefillList extends StatefulWidget {
class _GasRefillListState extends State<GasRefillList> {
@override
Widget build(BuildContext context) {
if (widget.items.length == 0) {
if (widget.items.isEmpty) {
return NoItemFound(
message: context.translation.noServiceRequestFound,
);
@ -40,7 +39,7 @@ class _GasRefillListState extends State<GasRefillList> {
item: widget.items[itemIndex],
onPressed: (model) {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => GasRefillDetails(
builder: (_) => GasRefillDetailsPage(
model: model,
))).then((value) {
model=value;

@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import 'package:test_sa/views/widgets/titles/app_title.dart';
import '../../../models/new_models/gas_refill_model.dart';
class GasRefillUpdateDetailsItem extends StatelessWidget {
final GasRefillDetails details;
final bool enableEdit;
@ -22,21 +21,21 @@ class GasRefillUpdateDetailsItem extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ATitle(details.type.name),
ATitle(details.gasType.name),
RequestInfoRow(
title: "Cylinder Size",
info: details.cylinderSize.name,
),
RequestInfoRow(
title: "Requested Quantity",
info: details.requestedQuantity.toStringAsFixed(0),
info: details.deliverdQty?.toStringAsFixed(0)??"",
),
enableEdit
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(context.translation.quantity),
if (validate && details.deliveredQuantity == null)
if (validate && details.deliverdQty == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
@ -45,20 +44,20 @@ class GasRefillUpdateDetailsItem extends StatelessWidget {
height: 4,
),
ATextFormField(
initialValue: (details.deliveredQuantity ?? "").toString(),
initialValue: (details.deliverdQty ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onSaved: (value) {
details.deliveredQuantity = double.tryParse(value);
details.deliverdQty = double.tryParse(value);
},
),
],
)
: RequestInfoRow(
title: "Delivered Quantity",
info: details.deliveredQuantity?.toStringAsFixed(0),
info: details.deliverdQty?.toStringAsFixed(0),
),
//SizedBox(height: 16,)
],

@ -97,14 +97,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
buttons_tabbar:
dependency: "direct main"
description:
name: buttons_tabbar
sha256: "781128180f3e76cf93c093183f10395c664983dbee20bc4da2025be70085c2da"
url: "https://pub.dev"
source: hosted
version: "1.3.7+1"
cached_network_image:
dependency: "direct main"
description:

Loading…
Cancel
Save