Merge remote-tracking branch 'origin/main_design2.0' into main_design2.0

main_design2.0
zaid_daoud 1 year ago
commit ee16e35485

@ -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

@ -18,6 +18,8 @@
"transferRequest" : "طلب نقل", "transferRequest" : "طلب نقل",
"serviceRequest" : "طلب خدمة", "serviceRequest" : "طلب خدمة",
"newServiceRequest" : "طلب خدمة جديدة", "newServiceRequest" : "طلب خدمة جديدة",
"search": "بحث",
"filter" : "تصنيف",
"newGasRefillRequest" : "طلب إعادة تعبئة غاز جديد", "newGasRefillRequest" : "طلب إعادة تعبئة غاز جديد",
"newTransferRequest" : "طلب نقل جديد", "newTransferRequest" : "طلب نقل جديد",
"submitRequest" : "تأكيد الطلب", "submitRequest" : "تأكيد الطلب",

@ -18,6 +18,8 @@
"transferRequest" : "Transfer Request", "transferRequest" : "Transfer Request",
"serviceRequest" : "Service Request", "serviceRequest" : "Service Request",
"newServiceRequest" : "New Service Request", "newServiceRequest" : "New Service Request",
"search": "Search",
"filter": "Filter",
"newGasRefillRequest" : "New Gas Refill Request", "newGasRefillRequest" : "New Gas Refill Request",
"newTransferRequest" : "New Transfer Request", "newTransferRequest" : "New Transfer Request",
"submitRequest" : "Submit Request", "submitRequest" : "Submit Request",

@ -39,7 +39,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
@ -71,7 +71,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();
@ -128,15 +128,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(),
@ -148,17 +148,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,6 +253,8 @@
"Serial No" : "الرقم التسلسلي", "Serial No" : "الرقم التسلسلي",
"device" : "الجهاز", "device" : "الجهاز",
"pickAsset" : "إختر جهاز", "pickAsset" : "إختر جهاز",
"filter" : "تصنيف",
"pickAsset" : "إختر جهاز",
"firstAction" : "First Action", "firstAction" : "First Action",
"priority" : "الأولوية", "priority" : "الأولوية",
"equipmentStatus" : "حالة المعدات", "equipmentStatus" : "حالة المعدات",
@ -260,6 +262,10 @@
"callComments" : "تعليقات الطلب", "callComments" : "تعليقات الطلب",
"comments" : "تعليقات", "comments" : "تعليقات",
"recordVoice" : "تسجيل صوت", "recordVoice" : "تسجيل صوت",
"gasRefillDetails" : "تفاصيل اعادة تعبئة غاز",
"updateRequest" : "تعديل الطلب",
"gasRefill" : "اعادة تعبئة غاز",
"recordVoice" : "تسجيل صوت",
"receiverName" : "اسم المستلم", "receiverName" : "اسم المستلم",
"receiverDetails" : "تفاصيل المستلم", "receiverDetails" : "تفاصيل المستلم",
"requestedThrough" : "الطلب عبر", "requestedThrough" : "الطلب عبر",

@ -253,6 +253,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",
@ -265,6 +267,10 @@
"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",
"receiverName" : "Receiver Name", "receiverName" : "Receiver Name",
"receiverDetails" : "Receiver Details", "receiverDetails" : "Receiver 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';
@ -50,6 +49,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';

@ -18,6 +18,8 @@ enum TranslationKeys {
transferRequest, transferRequest,
serviceRequest, serviceRequest,
newServiceRequest, newServiceRequest,
search,
filter,
newGasRefillRequest, newGasRefillRequest,
newTransferRequest, newTransferRequest,
submitRequest, submitRequest,

@ -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';
@ -30,6 +31,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) {
@ -47,7 +50,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;
@ -77,6 +79,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,
@ -172,6 +176,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 {
@ -182,6 +207,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) {
@ -199,6 +225,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,

@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import '../../models/enums/translation_keys.dart';
class AppSearchField extends StatefulWidget {
final Function(String) onChanged;
final Function(String) onSubmitted;
const AppSearchField({Key key, this.onChanged, this.onSubmitted}) : super(key: key);
@override
State<AppSearchField> createState() => _AppSearchFieldState();
}
class _AppSearchFieldState extends State<AppSearchField> {
@override
Widget build(BuildContext context) {
return TextField(
onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search, color: AppColor.neutral20,),
hintText: context.translation.search,
hintStyle: TextStyle(
fontSize: Theme.of(context).textTheme.bodySmall.fontSize
),
filled: true,
fillColor: AppColor.neutral30,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide.none,
)),
);
}
}

@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
class AppTabBar extends StatelessWidget {
const AppTabBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return TabBar(
tabs:[
Tab(
icon: Icon(Icons.cloud_outlined),
),
Tab(
icon: Icon(Icons.beach_access_sharp),
),
Tab(
icon: Icon(Icons.brightness_5_sharp),
),
],
);
}
}

@ -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,

@ -45,7 +45,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.onSelect != null && (widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) { if (widget.onSelect != null && (widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) {
widget.onSelect(_selectedItem); widget.onSelect(_selectedItem);
} }
@ -64,7 +64,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;

@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/new_views/pages/land_page/home_app_bar.dart'; import 'package:test_sa/new_views/pages/land_page/home_app_bar.dart';
import 'package:test_sa/new_views/pages/land_page/my_assets_page.dart'; import 'package:test_sa/new_views/pages/land_page/my_assets_page.dart';
import 'package:test_sa/new_views/pages/land_page/my_requests_page.dart'; import 'package:test_sa/new_views/pages/land_page/my_request/my_requests_page.dart';
import '../../common_widgets/app_bottom_nav_bar.dart'; import '../../common_widgets/app_bottom_nav_bar.dart';
import '../../common_widgets/app_drawer.dart'; import '../../common_widgets/app_drawer.dart';
@ -24,6 +24,7 @@ class LandPage extends StatefulWidget {
class _LandPageState extends State<LandPage> { class _LandPageState extends State<LandPage> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int currentPageIndex = 0; int currentPageIndex = 0;
bool showAppbar =true;
final List<Widget> _pages = const <Widget>[ final List<Widget> _pages = const <Widget>[
DashboardPage(), DashboardPage(),
MyRequestsPage(), MyRequestsPage(),
@ -53,11 +54,8 @@ class _LandPageState extends State<LandPage> {
}, },
child: Scaffold( child: Scaffold(
key: _scaffoldKey, key: _scaffoldKey,
appBar: HomeAppBar(scaffoldKey: _scaffoldKey), appBar: showAppbar?HomeAppBar(scaffoldKey: _scaffoldKey): null,
body: Padding( body: _pages[currentPageIndex],
padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth, end: 11.toScreenHeight),
child: _pages[currentPageIndex],
),
drawer: const AppDrawer(), drawer: const AppDrawer(),
floatingActionButton: const AppFloatingActionButton(), floatingActionButton: const AppFloatingActionButton(),
bottomNavigationBar: AppBottomNavigationBar( bottomNavigationBar: AppBottomNavigationBar(
@ -74,6 +72,16 @@ class _LandPageState extends State<LandPage> {
setState(() { setState(() {
currentPageIndex = index; currentPageIndex = index;
}); });
if(index == 1){
setState(() {
showAppbar =false;
});
}else{
setState(() {
showAppbar =true;
});
}
} }
}, },
), ),

@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/enums/translation_keys.dart';
import '../../../app_style/app_color.dart';
import '../../../common_widgets/app_search_field.dart';
class MyRequestsPage extends StatelessWidget {
const MyRequestsPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leadingWidth: 0,
title: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: SizedBox(
height: 50,
child: AppSearchField())),
SizedBox(width: 20,),
Text(context.translation.filter, style: TextStyle(
color: AppColor.primary50,
fontSize: Theme.of(context).textTheme.bodySmall.fontSize,
fontWeight: FontWeight.w500
),)
],
),
),
),
body: TabBarView(
children: const <Widget>[
Center(
child: Text(""),
),
Center(
child: Text(""),
),
Center(
child: Text(""),
),
],
),
);
}
}

@ -1,14 +0,0 @@
import 'package:flutter/material.dart';
class MyRequestsPage extends StatelessWidget {
const MyRequestsPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text("My Requests"),
),
);
}
}

@ -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,82 +1,46 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:flutter_svg/svg.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/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;
UserProvider _userProvider; UserProvider _userProvider;
SettingProvider _settingProvider;
GasRefillProvider _gasRefillProvider;
bool _isLoading = false; bool _isLoading = false;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async {
_validate = true;
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
_isLoading = true;
setState(() {});
int status = await _gasRefillProvider.updateModel(user: _userProvider.user, host: _settingProvider.host, newModel: _model, oldModel: widget.model);
_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: context.translation.successfulRequestMessage,
);
_enableEdit = false;
_validate = false;
//Navigator.of(context).pop();
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
@override @override
void initState() { void initState() {
_model?.fromGasRefillModel(widget.model); _model.fromGasRefillModel(widget.model);
super.initState(); super.initState();
} }
@ -84,9 +48,9 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(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,34 +62,71 @@ 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( ),
children: [ ),
ABackButton(
onPressed: () {
Navigator.of(context).pop(_model);
},
), ),
Expanded( );
child: Center( }
child: Text(
"Gas Refill Request", Widget informationCard() {
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), 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: [
/// TBD
//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) if (_userProvider.user.type == UsersTypes.engineer)
AIconButton( CircleAvatar(
iconData: /*_enableEdit ? Icons.cancel :*/ Icons.edit, radius: 25,
color: Theme.of(context).colorScheme.onPrimary, backgroundColor: AppColor.neutral30,
buttonSize: 42, child: CircleAvatar(
backgroundColor: AColors.green, radius: 24,
onPressed: (widget.model.status?.value ?? 0) == 2 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 ? null
: () async { :
// _enableEdit = !_enableEdit; () async {
_enableEdit = !_enableEdit;
_model?.fromGasRefillModel(widget.model); _model?.fromGasRefillModel(widget.model);
// setState(() {}); // setState(() {});
Navigator.push( Navigator.push(
@ -141,124 +142,103 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
} }
}); });
setState(() {}); setState(() {});
}, },),
),
const SizedBox(
width: 16,
)
], ],
), ),
), 8.height,
Expanded( Row(
child: SingleChildScrollView( mainAxisAlignment: MainAxisAlignment.spaceBetween,
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
RequestInfoRow( Column(
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(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox( Text(
height: 8, 'Gas Request:',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
), ),
ASubTitle(context.translation.status), Text(
if (_validate && _model.status == null) 'Cylinder Size: ${widget.model.gazRefillDetails[0].cylinderSize.value}',
ASubTitle( style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
context.translation.requiredWord,
color: Colors.red,
), ),
const SizedBox( Text(
height: 4, '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( 8.height,
height: 8, 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)),
), ),
const ASubTitle("Gas Requests"), Text(
const SizedBox( 'Delivered Quantity: ${widget.model.gazRefillDetails[0].deliverdQty}',
height: 8, style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
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,
), ),
8.height,
], ],
).paddingAll(16),
/// TBD
(_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/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,10 +28,14 @@ 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 '../../../widgets/e_signature/e_signature.dart'; import '../../../../extensions/text_extensions.dart';
import '../../../widgets/timer/app_timer.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';
class RequestGasRefill extends StatefulWidget { class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill"; static const String id = "/request-gas-refill";
@ -52,9 +55,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 +78,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(() {});
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;
setState(() {}); 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 int status = widget.gasRefillModel == null
? null /*await _gasRefillProvider.createModel( ? null /*await _gasRefillProvider.createModel(
@ -105,7 +111,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 +127,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 +152,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();
} }
@ -162,10 +170,10 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
if (_firstTime) { if (_firstTime) {
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 +189,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 +200,92 @@ 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(
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: [ children: [
Expanded( Container(
child: AppTimer( width: MediaQuery.of(context).size.width,
timer: _gasRefillProvider.timer, decoration: ShapeDecoration(
onChange: (timer) async { color: Colors.white,
_gasRefillProvider.timer = timer; shape: RoundedRectangleBorder(
_formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0"); borderRadius: BorderRadius.circular(20),
_formModel.startDate = timer.startAt;
_formModel.endDate = timer.endAt;
return true;
},
), ),
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
), ),
], child: Column(
),
//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, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 8), Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
Divider(color: Theme.of(context).colorScheme.primary), 8.height,
const SizedBox(height: 4), Text(
const ASubTitle("Gas Type"), 'Gas Request:',
if (_validate && _currentDetails.type == null) ASubTitle(context.translation.requiredWord, color: Colors.red), style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
const SizedBox(height: 4),
GasTypeMenu(
initialValue: _currentDetails.type,
onSelect: (status) {
_currentDetails.type = status;
},
), ),
const SizedBox(height: 8), Text(
const ASubTitle("Cylinder Size"), 'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}',
if (_validate && _currentDetails.cylinderSize == null) style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
ASubTitle(
context.translation.requiredWord,
color: Colors.red,
), ),
const SizedBox( Text(
height: 4, 'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
), ),
GasCylinderSizeMenu( Text(
initialValue: _currentDetails.cylinderSize, 'Site: ${widget.gasRefillModel.site.name}',
onSelect: (status) { style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
_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, ).paddingAll(16),
), ),
GasCylinderTypesMenu( 12.height,
initialValue: _currentDetails.cylinderType, AppTextFormField(
onSelect: (status) { labelText: context.translation.workingHours,
_currentDetails.cylinderType = status; onSaved:(value){
_formModel?.workingHours = double.tryParse(value);
}, },
),
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, textInputType: TextInputType.number,
onChange: (value) { controller: _workingHoursController,
_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", validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onChange: (value) {
_currentDetails?.deliveredQuantity = double.tryParse(value);
},
), ),
const SizedBox(height: 16), 12.height,
AButton( SingleItemDropDownMenu<Lookup,GasStatusProvider >(
text: context.translation.add, context: context,
onPressed: _addNewModel, title: context.translation.reportStatus,
), initialValue: _formModel.status,
], onSelect: (value) {
), _formModel.status=value;
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) 12.height,
const SizedBox( AppTextFormField(
height: 8, 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",
), ),
if (widget.gasRefillModel != null) const ASubTitle("Engineer Signature"), 12.height,
if (widget.gasRefillModel != null) /// TBD
ESignature( AppTextFormField(
oldSignature: _formModel.signatureEngineer, labelText: context.translation.comments,
newSignature: _formModel.localEngineerSignature, textInputType: TextInputType.multiline,
onChange: (signature) { alignLabelWithHint: true,
if (signature == null || signature.isEmpty) { controller: _commentController,
return; onSaved: (value){
}
_formModel.localEngineerSignature = signature;
_formModel.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
}, },
), ),
const SizedBox(height: 16), ],
).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)
], ],
), ),
), )
), ),
), ),
), ),

@ -1,16 +1,15 @@
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/models/subtitle.dart'; import 'package:test_sa/extensions/context_extension.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 '../../../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";
@ -31,13 +30,13 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_gasRefillProvider == null) { if (_gasRefillProvider == null) {
_gasRefillProvider = Provider.of<GasRefillProvider>(context); _gasRefillProvider = Provider.of<GasRefillProvider>(context);
//_gasRefillProvider?.isLoading = false;
_gasRefillProvider.reset(); _gasRefillProvider.reset();
} }
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_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,
@ -55,46 +54,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
children: [ children: [
Column( Column(
children: [ children: [
Container(
color: AColors.white,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
children: [
const ABackButton(),
Expanded(
child: Center(
child: Text(
"Gas Refill Requests",
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic),
),
),
),
const SizedBox(
width: 48,
)
],
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ASwitchButton(
title: "Most Recent",
value: mostRecent,
onChange: (value) async {
mostRecent = value;
_gasRefillProvider.reset();
await _gasRefillProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
mostRecent: mostRecent,
);
},
),
),
Expanded( Expanded(
child: GasRefillList( child: GasRefillList(
nextPage: _gasRefillProvider.nextPage, nextPage: _gasRefillProvider.nextPage,

@ -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,10 +1,14 @@
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/extensions/int_extensions.dart';
import 'package:test_sa/views/app_style/colors.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/widgets/requests/request_status.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;
@ -15,20 +19,17 @@ class GasRefillItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 4), padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
backgroundColor: itemColor, backgroundColor: Colors.white,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
), ),
), ),
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
onPressed: () { onPressed: () {
onPressed(item); onPressed(item);
}, },
@ -36,75 +37,116 @@ class GasRefillItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( /// TBD
item.title ?? "-----", // StatusLabel(
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), // label: ,
), // id: ,
Row( // textColor: AColors.getPriorityStatusTextColor(),
children: [ // backgroundColor: AColors.getPriorityStatusColor()),
Expanded( 8.width,
child: Text( StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)),
context.translation.hospital, 1.width.expanded,
style: Theme.of(context).textTheme.titleSmall.copyWith( Text(item.startDate != null ?item.startDate.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))),
color: onItemColor,
),
),
),
if (item.clientName != null)
Text(
item.clientName,
style: Theme.of(context).textTheme.titleSmall.copyWith(
color: onItemColor,
),
),
], ],
), ),
Divider(color: onItemColor), 8.height,
Row( Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
children: [ Text(
Expanded( 'Gas Type: ${item.gazRefillDetails[0].gasType.name}',
child: Text(context.translation.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
),
if (item.status?.id != null) StatusLabel(label: item.status.name, backgroundColor: AColors.getGasStatusColor(item.status.id)),
],
), ),
if (item?.expectedDate != null) Divider(color: onItemColor), Text(
if (item?.expectedDate != null) '${context.translation.site}: ${item.site.name}',
Row( style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
],
), ),
if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor), 8.height,
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), Text(
Column( 'View Details',
crossAxisAlignment: CrossAxisAlignment.end, style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
children: item.details ),
.map( 4.width,
(gas) => gas?.type?.name?.isNotEmpty ?? false const Icon(
? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)) Icons.arrow_forward,
: const SizedBox.shrink(), color: Color(0xFF4A8DB7),
) size: 14,
.toList(),
) )
], ],
), ),
], // Row(
), // children: [
), // Expanded(
], // child: Column(
), // crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// item.title ?? "-----",
// style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
// ),
// Row(
// children: [
// Expanded(
// child: Text(
// subtitle.hospital,
// style: Theme.of(context).textTheme.titleSmall.copyWith(
// color: onItemColor,
// ),
// ),
// ),
// if (item.clientName != null)
// Text(
// item.clientName,
// style: Theme.of(context).textTheme.titleSmall.copyWith(
// color: onItemColor,
// ),
// ),
// ],
// ),
// Divider(color: onItemColor),
// Row(
// children: [
// Expanded(
// child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// ),
// if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
// ],
// ),
// if (item?.expectedDate != null) Divider(color: onItemColor),
// if (item?.expectedDate != null)
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// ],
// ),
// if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
// Column(
// crossAxisAlignment: CrossAxisAlignment.end,
// children: item.details
// .map(
// (gas) => gas?.type?.name?.isNotEmpty ?? false
// ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
// : const SizedBox.shrink(),
// )
// .toList(),
// )
// ],
// ),
// ],
// ),
// ),
// ],
// ),
], ],
), ),
), ),

@ -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,)
], ],

Loading…
Cancel
Save