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

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

@ -254,6 +254,8 @@
"serialNo" : "Serial No", "serialNo" : "Serial No",
"device" : "Device", "device" : "Device",
"pickAsset" : "Pick Asset", "pickAsset" : "Pick Asset",
"filter" : "Filter",
"pickAsset" : "Pick Asset",
"firstAction" : "First Action", "firstAction" : "First Action",
"workOrder" : "Work Orders", "workOrder" : "Work Orders",
"viewWorkOrder" : "View All Work Order", "viewWorkOrder" : "View All Work Order",
@ -266,5 +268,9 @@
"callComments" : "Call Comments", "callComments" : "Call Comments",
"comments": "Comments", "comments": "Comments",
"recordVoice" : "Record Voice", "recordVoice" : "Record Voice",
"gasRefillDetails" : "Gas Refill Details",
"updateRequest" : "Update Request",
"gasRefill" : "Gas Refill",
"recordVoice" : "Record Voice",
"assetDetails" : "Asset Details" "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/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_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_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_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_task_status_provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_visit_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/department_provider.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_size_provider.dart'; import 'package:test_sa/providers/gas_request_providers/cylinder_size_provider.dart';
import 'package:test_sa/providers/gas_request_providers/cylinder_type_provider.dart'; import 'package:test_sa/providers/gas_request_providers/cylinder_type_provider.dart';
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/gas_types_provider.dart';
import 'package:test_sa/providers/gas_request_providers/site_provider.dart'; import 'package:test_sa/providers/gas_request_providers/site_provider.dart';
import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/loading_list_notifier.dart';

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

@ -26,6 +26,7 @@ class AppTextFormField extends StatefulWidget {
final TextInputAction textInputAction; final TextInputAction textInputAction;
final VoidCallback onAction; final VoidCallback onAction;
final Color backgroundColor; final Color backgroundColor;
final bool alignLabelWithHint;
const AppTextFormField({ const AppTextFormField({
Key key, Key key,
@ -50,6 +51,7 @@ class AppTextFormField extends StatefulWidget {
this.textInputAction, this.textInputAction,
this.onAction, this.onAction,
this.backgroundColor, this.backgroundColor,
this.alignLabelWithHint
}) : super(key: key); }) : super(key: key);
@override @override
@ -80,13 +82,14 @@ class _AppTextFormFieldState extends State<AppTextFormField> {
onChanged: widget.onChange, onChanged: widget.onChange,
obscureText: widget.obscureText ?? false, obscureText: widget.obscureText ?? false,
keyboardType: widget.textInputType, keyboardType: widget.textInputType,
maxLines: widget.textInputType == TextInputType.multiline ? null : 1, maxLines: widget.textInputType == TextInputType.multiline ? 4 : 1,
obscuringCharacter: "*", obscuringCharacter: "*",
controller: widget.controller, controller: widget.controller,
textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next, textInputAction: widget.textInputType == TextInputType.multiline ? null : widget.textInputAction ?? TextInputAction.next,
onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(), onEditingComplete: widget.onAction ?? () => FocusScope.of(context).nextFocus(),
style: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500), style: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500),
decoration: InputDecoration( decoration: InputDecoration(
alignLabelWithHint: widget.alignLabelWithHint,
border: border, border: border,
disabledBorder: border, disabledBorder: border,
focusedBorder: 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) { final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue; return element == widget.initialValue;
}); });
if (result.isNotEmpty) _selectedItem = result.first; if (result?.isNotEmpty??false) _selectedItem = result.first;
if ((widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) { if ((widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) {
widget.onSelect(_selectedItem); 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) { final result = (X == NullableLoadingProvider ? widget.staticData : provider.items)?.where((element) {
return element == widget.initialValue; return element == widget.initialValue;
}); });
if (result.isNotEmpty) { if (result?.isNotEmpty??false) {
_selectedItem = result.first; _selectedItem = result.first;
} else { } else {
_selectedItem = null; _selectedItem = null;

@ -24,7 +24,7 @@ class MyRequestsPage extends StatelessWidget {
height: 50, height: 50,
child: AppSearchField())), child: AppSearchField())),
SizedBox(width: 20,), SizedBox(width: 20,),
Text("Filter", style: TextStyle( Text(context.translation.filter, style: TextStyle(
color: AppColor.primary50, color: AppColor.primary50,
fontSize: Theme.of(context).textTheme.bodySmall.fontSize, fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
fontWeight: FontWeight.w500 fontWeight: FontWeight.w500
@ -37,13 +37,13 @@ class MyRequestsPage extends StatelessWidget {
body: TabBarView( body: TabBarView(
children: const <Widget>[ children: const <Widget>[
Center( Center(
child: Text("It's cloudy here"), child: Text(""),
), ),
Center( Center(
child: Text("It's rainy here"), child: Text(""),
), ),
Center( 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/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/http_status_manger.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/gas_refill_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/models/subtitle.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/app_style/sizing.dart';
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.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/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/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/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'; import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget { class GasRefillDetailsPage extends StatefulWidget {
GasRefillModel model; GasRefillModel model;
GasRefillDetails({Key key, this.model}) : super(key: key); GasRefillDetailsPage({Key key, this.model}) : super(key: key);
@override @override
State<GasRefillDetails> createState() => _GasRefillDetailsState(); State<GasRefillDetailsPage> createState() => _GasRefillDetailsPageState();
} }
class _GasRefillDetailsState extends State<GasRefillDetails> { class _GasRefillDetailsPageState extends State<GasRefillDetailsPage> {
GasRefillModel _model = GasRefillModel(); GasRefillModel _model = GasRefillModel(gazRefillDetails: []);
bool _enableEdit = false; bool _enableEdit = false;
bool _validate = false; bool _validate = false;
UserProvider _userProvider; UserProvider _userProvider;
@ -76,7 +73,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
@override @override
void initState() { void initState() {
_model?.fromGasRefillModel(widget.model); _model.fromGasRefillModel(widget.model);
super.initState(); super.initState();
} }
@ -87,6 +84,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
_gasRefillProvider = Provider.of<GasRefillProvider>(context); _gasRefillProvider = Provider.of<GasRefillProvider>(context);
return Scaffold( return Scaffold(
appBar: DefaultAppBar(title: context.translation.gasRefillDetails),
key: _scaffoldKey, key: _scaffoldKey,
body: SafeArea( body: SafeArea(
child: Form( child: Form(
@ -98,167 +96,181 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
onRefresh: () async {}, onRefresh: () async {},
child: Column( child: Column(
children: [ children: [
Container( informationCard()
color: Theme.of(context).colorScheme.primary, ],
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), ),
child: Row( ),
),
),
);
}
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: [ children: [
ABackButton( //StatusLabel(
onPressed: () { //label: item.priority.name,
Navigator.of(context).pop(_model); //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)
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'),
),
), ),
Expanded( ).onPress(
child: Center( // (widget.model.status?.value ?? 0) == 2
child: Text( // ? null
"Gas Refill Request", // :
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), () async {
// _enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model);
// setState(() {});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RequestGasRefill(
gasRefillModel: widget.model,
), ),
), ),
).then((value) {
if (value != null) {
_model = value;
}
});
setState(() {});
},),
],
),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
Text(
'Cylinder Size: ${widget.model.gazRefillDetails[0].cylinderSize.value}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
Text(
'Site: ${widget.model.site.name}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
), ),
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 {
// _enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model);
// setState(() {});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RequestGasRefill(
gasRefillModel: widget.model,
),
),
).then((value) {
if (value != null) {
_model = value;
}
});
setState(() {});
},
),
const SizedBox(
width: 16,
)
], ],
), ),
Text(widget.model.startDate?.toServiceRequestCardFormat??"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
],
),
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)),
),
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),
), ),
Expanded( ),
child: SingleChildScrollView( ),
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)), child: Row(
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, Text(
children: [ 'Comment here...',
RequestInfoRow( style: AppTextStyles.heading6.copyWith(
title: "Gas Refill No", color: AppColor.neutral50.withOpacity(.6),
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(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8,
),
ASubTitle(context.translation.status),
if (_validate && _model.status == null)
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
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)),
],
),
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,
),
AButton(
text: context.translation.update,
onPressed: _update,
),
],
),
],
),
), ),
), ).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/providers/settings/setting_provider.dart';
import 'package:test_sa/controllers/validator/validator.dart'; import 'package:test_sa/controllers/validator/validator.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/gas_refill/gas_refill_details.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/timer_model.dart'; import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.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/status/gas_refill/gas_type.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.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 '../../../../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/e_signature/e_signature.dart';
import '../../../widgets/timer/app_timer.dart'; import '../../../widgets/timer/app_timer.dart';
@ -52,9 +56,11 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
SettingProvider _settingProvider; SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider; GasRefillProvider _gasRefillProvider;
GasRefillDetails _currentDetails = GasRefillDetails(); GasRefillDetails _currentDetails = GasRefillDetails();
final TextEditingController _requestedQuantityController = TextEditingController();
final TextEditingController _deliveredQuantityController = 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<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey _DetailsKey = GlobalKey<FormState>(); final GlobalKey _DetailsKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@ -73,26 +79,27 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (mounted) super.setState(() {}); if (mounted) super.setState(() {});
} }
_onSubmit() async { _onSubmit(BuildContext context) async {
if (_formModel.details.isEmpty) { if (_formModel.gazRefillDetails.isEmpty) {
if (!_addNewModel()) return; if (!(await _addNewModel(context))) return;
} }
_isLoading = true; //_isLoading = true;
setState(() {}); setState(() {});
if (widget.gasRefillModel != null) { // if (widget.gasRefillModel != null) {
if (!_formModel.validate()) { // if (!(await _formModel.validate(context))) {
_isLoading = false; // _isLoading = false;
setState(() {}); // setState(() {});
return; // return;
} // }
} // }
if (_gasRefillProvider.department?.name == null) { //if(!(_formKey.currentState.validate())) return;
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department"))); // if (_gasRefillProvider.department?.name == null) {
_isLoading = false; // ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text("Select department")));
setState(() {}); // _isLoading = false;
return; // setState(() {});
} // return;
// }
int status = widget.gasRefillModel == null int status = widget.gasRefillModel == null
? null /*await _gasRefillProvider.createModel( ? null /*await _gasRefillProvider.createModel(
@ -105,7 +112,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
oldModel: widget.gasRefillModel, oldModel: widget.gasRefillModel,
newModel: _formModel, newModel: _formModel,
); );
_isLoading = false; //_isLoading = false;
setState(() {}); setState(() {});
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
Fluttertoast.showToast( Fluttertoast.showToast(
@ -121,23 +128,24 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
} }
} }
bool _addNewModel() { Future<bool> _addNewModel(BuildContext context) async {
_validate = true; _validate = true;
if (!_formKey.currentState.validate()) { if (!_formKey.currentState.validate()) {
setState(() {}); setState(() {});
return false; return false;
} }
_formKey.currentState.save(); _formKey.currentState.save();
if (!_currentDetails.validate()) { if (!(await _currentDetails.validate(context))) {
setState(() {}); setState(() {});
return false; return false;
} }
_formModel.details.insert(0, _currentDetails); _formModel.gazRefillDetails.insert(0, _currentDetails);
_validate = false; _validate = false;
Scrollable.ensureVisible(_DetailsKey.currentContext); Scrollable.ensureVisible(_DetailsKey.currentContext);
_requestedQuantityController.clear();
_deliveredQuantityController.clear(); _deliveredQuantityController.clear();
_workingHoursController.clear();
_commentController.clear();
_currentDetails = GasRefillDetails(); _currentDetails = GasRefillDetails();
setState(() {}); setState(() {});
return true; return true;
@ -145,8 +153,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
@override @override
void dispose() { void dispose() {
_requestedQuantityController.dispose();
_deliveredQuantityController.dispose(); _deliveredQuantityController.dispose();
_commentController.dispose();
_workingHoursController.dispose();
super.dispose(); super.dispose();
} }
@ -163,9 +172,9 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
String _clientName; String _clientName;
if (widget.gasRefillModel != null) { if (widget.gasRefillModel != null) {
_formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0); _formModel.status = widget.gasRefillModel?.status ?? Lookup(value: 0);
_gasRefillProvider.expectedDateTime = _formModel.expectedDate; _gasRefillProvider.expectedDateTime = DateTime.tryParse(_formModel.expectedDate??"");
_gasRefillProvider.timer = TimerModel(startAt: widget.gasRefillModel?.startDate, endAt: widget.gasRefillModel?.endDate); _gasRefillProvider.timer = TimerModel(startAt: DateTime.tryParse(widget.gasRefillModel?.startDate??""), endAt: DateTime.tryParse(widget.gasRefillModel?.endDate??""));
_clientName = _formModel.clientName; _clientName = _formModel.site.custName;
} else { } else {
_gasRefillProvider.timer = null; _gasRefillProvider.timer = null;
_clientName = _userProvider.user?.clientName; _clientName = _userProvider.user?.clientName;
@ -181,6 +190,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
}); });
} }
return Scaffold( return Scaffold(
appBar: DefaultAppBar(title: context.translation.updateRequest),
key: _scaffoldKey, key: _scaffoldKey,
body: Form( body: Form(
key: _formKey, key: _formKey,
@ -191,379 +201,466 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
stateCode: 200, stateCode: 200,
onRefresh: () async {}, onRefresh: () async {},
child: SingleChildScrollView( child: SingleChildScrollView(
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Center( Column(
child: Padding( children: [
padding: const EdgeInsets.all(8.0), Container(
child: Text( width: MediaQuery.of(context).size.width,
"${widget.gasRefillModel == null ? "Request" : "Update"} Gas Refill", decoration: ShapeDecoration(
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold), color: Colors.white,
), shape: RoundedRectangleBorder(
), borderRadius: BorderRadius.circular(20),
),
// 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;
_formModel.endDate = timer.endAt;
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.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), shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
AButton(
text: context.translation.add,
onPressed: _addNewModel,
), ),
], child: Column(
), crossAxisAlignment: CrossAxisAlignment.start,
const SizedBox(height: 16), children: [
if (_formModel.details.isNotEmpty) const ASubTitle("Gas Requests"), Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
ListView.builder( 8.height,
key: _DetailsKey, Text(
shrinkWrap: true, 'Gas Request:',
physics: const ClampingScrollPhysics(), style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
itemCount: _formModel.details.length, ),
itemBuilder: (context, index) { Text(
final model = _formModel.details[index]; 'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}',
return GasRefillCreateDetailsItem( style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
isUpdate: widget.gasRefillModel != null, ),
model: model, Text(
onPressed: () { 'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}',
if (widget.gasRefillModel != null) { style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
model.selectedForEditing = !(model.selectedForEditing ?? false); ),
} Text(
if (widget.gasRefillModel == null) { 'Site: ${widget.gasRefillModel.site.name}',
_formModel.details.remove(model); style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
} ),
setState(() {}); ],
}, ).paddingAll(16),
); ),
}), 12.height,
if (widget.gasRefillModel != null) const SizedBox(height: 16), AppTextFormField(
if (widget.gasRefillModel != null) const ASubTitle("Nurse Signature"), labelText: context.translation.workingHours,
if (widget.gasRefillModel != null) onSaved:(value){
ESignature( _formModel?.workingHours = double.tryParse(value);
oldSignature: _formModel.signatureNurse, },
newSignature: _formModel.localNurseSignature, textInputType: TextInputType.number,
onChange: (signature) { controller: _workingHoursController,
if (signature == null || signature.isEmpty) { validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
return; ),
} 12.height,
_formModel.localNurseSignature = signature; SingleItemDropDownMenu<Lookup,GasStatusProvider >(
_formModel.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; context: context,
}, title: context.translation.reportStatus,
), initialValue: _formModel.status,
if (widget.gasRefillModel != null) onSelect: (value) {
const SizedBox( _formModel.status=value;
height: 8, },
), ),
if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"), 12.height,
if (widget.gasRefillModel != null) AppTextFormField(
ESignature( labelText: context.translation.deliveredQuantity,
oldSignature: _formModel.signatureEngineer, onSaved:(value){
newSignature: _formModel.localEngineerSignature, _currentDetails?.deliverdQty = double.tryParse(value);
onChange: (signature) { },
if (signature == null || signature.isEmpty) { textInputType: TextInputType.number,
return; controller: _deliveredQuantityController,
} validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
_formModel.localEngineerSignature = signature; ),
_formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; 12.height,
}, /// TBD
), AppTextFormField(
const SizedBox(height: 16), labelText: context.translation.comments,
textInputType: TextInputType.multiline,
alignLabelWithHint: true,
controller: _commentController,
onSaved: (value){
},
),
],
).paddingAll(16),
AButton( AButton(
text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update, text: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed: _onSubmit, onPressed:()async{_onSubmit.call(context);},
), ).paddingAll(16),
const SizedBox(height: 100)
], ],
), ),
), )
// 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)
// ],
// ),
// ),
), ),
), ),
), ),

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

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

@ -1,7 +1,14 @@
import 'package:flutter/material.dart'; 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 '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 { class GasRefillItem extends StatelessWidget {
final int index; final int index;
@ -30,12 +37,45 @@ class GasRefillItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("priority"), StatusLabel(
Text("process"), 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( // Row(
// children: [ // children: [
// Expanded( // Expanded(

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

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

@ -97,14 +97,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" 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: cached_network_image:
dependency: "direct main" dependency: "direct main"
description: description:

Loading…
Cancel
Save