Still working on gas refill request

main_design2.0
zaid_daoud 2 years ago
parent 085674ee18
commit ed759f5dcf

@ -0,0 +1,4 @@
<svg width="18" height="24" viewBox="0 0 18 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.3077 2.8125H12.4615V2.10938C12.4615 0.946219 11.5299 0 10.3846 0H7.61538C6.47012 0 5.53846 0.946219 5.53846 2.10938V2.8125H0.692308C0.309646 2.8125 0 3.12698 0 3.51562C0 3.90427 0.309646 4.21875 0.692308 4.21875H17.3077C17.6904 4.21875 18 3.90427 18 3.51562C18 3.12698 17.6904 2.8125 17.3077 2.8125ZM6.92308 2.10938C6.92308 1.72144 7.23342 1.40625 7.61538 1.40625H10.3846C10.7666 1.40625 11.0769 1.72144 11.0769 2.10938V2.8125H6.92308V2.10938Z" fill="#D02127"/>
<path d="M15.9231 5.625H2.07695C1.69429 5.625 1.38464 5.93948 1.38464 6.32812V23.2969C1.38464 23.6855 1.69429 24 2.07695 24H15.9231C16.3058 24 16.6154 23.6855 16.6154 23.2969V6.32812C16.6154 5.93948 16.3058 5.625 15.9231 5.625ZM5.53849 19.0312C5.53849 19.4199 5.22884 19.7344 4.84618 19.7344C4.46352 19.7344 4.15387 19.4199 4.15387 19.0312V10.5938C4.15387 10.2051 4.46352 9.89062 4.84618 9.89062C5.22884 9.89062 5.53849 10.2051 5.53849 10.5938V19.0312ZM9.69234 19.0312C9.69234 19.4199 9.38269 19.7344 9.00003 19.7344C8.61737 19.7344 8.30772 19.4199 8.30772 19.0312V10.5938C8.30772 10.2051 8.61737 9.89062 9.00003 9.89062C9.38269 9.89062 9.69234 10.2051 9.69234 10.5938V19.0312ZM13.8462 19.0312C13.8462 19.4199 13.5365 19.7344 13.1539 19.7344C12.7712 19.7344 12.4616 19.4199 12.4616 19.0312V10.5938C12.4616 10.2051 12.7712 9.89062 13.1539 9.89062C13.5365 9.89062 13.8462 10.2051 13.8462 10.5938V19.0312Z" fill="#D02127"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -29,5 +29,9 @@
"department" : "القسم", "department" : "القسم",
"httpError" : "خطأ فشل الطلب", "httpError" : "خطأ فشل الطلب",
"tryAgain" : "أعد المحاولة", "tryAgain" : "أعد المحاولة",
"destinationSite" : "موقع الوجهة" "destinationSite" : "موقع الوجهة",
"add": "أضف",
"site" : "الموقع",
"onlyNumbers": "يسمح بإدخال الأرقام فقط",
"youHaveToSelect" : "يجب عليك إختيار"
} }

@ -29,5 +29,9 @@
"department" : "Department", "department" : "Department",
"httpError" : "Error Request Failed", "httpError" : "Error Request Failed",
"tryAgain" : "Try Again", "tryAgain" : "Try Again",
"destinationSite" : "Destination Site" "destinationSite" : "Destination Site",
"add": "Add",
"site" : "Site",
"onlyNumbers": "Only Numbers Allowed",
"youHaveToSelect" : "You have to select"
} }

@ -24,8 +24,8 @@ class URLs {
static get login => "$_baseUrl/MobileAuth/LoginIntegration"; // post static get login => "$_baseUrl/MobileAuth/LoginIntegration"; // post
static get register => "$_baseUrl/handle/create/user"; // post static get register => "$_baseUrl/handle/create/user"; // post
static get updateProfile => "$_baseUrl/update/user/profile"; // post static get updateProfile => "$_baseUrl/update/user/profile"; // post
static get getHospitals => "$_baseUrl/Customer/GetCustomers"; // get static get getSites => "$_baseUrl/Customer/GetCustomers"; // get
static get getHospitalsAutoComplete => "$_baseUrl/Customer/GetCustomersAutoComplete"; // get static get getSitesAutoComplete => "$_baseUrl/Customer/GetCustomersAutoComplete"; // get
static get getDepartments => "$_baseUrl/Customer/GetDepartmentLookup"; // get static get getDepartments => "$_baseUrl/Customer/GetDepartmentLookup"; // get
static get getEquipment => "$_baseUrl/Asset/GetAssets"; // get ?client=208051 static get getEquipment => "$_baseUrl/Asset/GetAssets"; // get ?client=208051

@ -59,7 +59,7 @@ class HospitalsProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
Response response; Response response;
try { try {
response = await ApiManager.instance.post(URLs.getHospitals, body: { response = await ApiManager.instance.post(URLs.getSites, body: {
"pageNumber": (hospitals?.length ?? 0) ~/ pageItemNumber + 1, "pageNumber": (hospitals?.length ?? 0) ~/ pageItemNumber + 1,
"pageSize": 50, "pageSize": 50,
if (title != null && title.isNotEmpty) "name": title, if (title != null && title.isNotEmpty) "name": title,
@ -92,7 +92,7 @@ class HospitalsProvider extends ChangeNotifier {
Future<List<Hospital>> getHospitalsList({String host, User user, String title}) async { Future<List<Hospital>> getHospitalsList({String host, User user, String title}) async {
Response response; Response response;
try { try {
response = await ApiManager.instance.post(URLs.getHospitals, body: { response = await ApiManager.instance.post(URLs.getSites, body: {
"pageSize": 50, "pageSize": 50,
if (title != null && title.isNotEmpty) "name": title, if (title != null && title.isNotEmpty) "name": title,
}); });
@ -126,7 +126,7 @@ class HospitalsProvider extends ChangeNotifier {
if (searchVal.isNotEmpty) { if (searchVal.isNotEmpty) {
searchVal = "?searchText=$searchVal"; searchVal = "?searchText=$searchVal";
} }
response = await ApiManager.instance.get(URLs.getHospitalsAutoComplete + searchVal); response = await ApiManager.instance.get(URLs.getSitesAutoComplete + searchVal);
// response = await get( // response = await get(
// Uri.parse(host + URLs.getHospitals // Uri.parse(host + URLs.getHospitals
// + ( title == null || title.isEmpty ? "" : "?name=$title" )), // + ( title == null || title.isEmpty ? "" : "?name=$title" )),

@ -140,17 +140,17 @@ extension CapExtension on String {
extension FilesExtension on String { extension FilesExtension on String {
SvgPicture toSvgAsset({ SvgPicture toSvgAsset({
double width, int width,
double height, int height,
Color color, Color color,
BoxFit fit = BoxFit.contain, BoxFit fit = BoxFit.contain,
}) => }) =>
SvgPicture.asset("assets/images/$this.svg", width: width, height: height, color: color, fit: fit); SvgPicture.asset("assets/images/$this.svg", width: width?.toScreenWidth, height: height?.toScreenHeight, color: color, fit: fit);
Image toPngAsset({ Image toPngAsset({
double width, int width,
double height, int height,
Color color, Color color,
BoxFit fit = BoxFit.contain, BoxFit fit = BoxFit.contain,
}) => }) =>
Image.asset("assets/images/$this.png", width: width, height: height, color: color, fit: fit); Image.asset("assets/images/$this.png", width: width?.toScreenWidth, height: height?.toScreenHeight, color: color, fit: fit);
} }

@ -1,6 +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/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import '../new_views/app_style/app_color.dart';
extension WidgetExtensions on Widget { extension WidgetExtensions on Widget {
Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this); Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this);
@ -17,3 +20,7 @@ extension WidgetExtensions on Widget {
Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this); Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this);
} }
extension DividerExtension on Divider {
Divider defaultStyle(BuildContext context) => Divider(thickness: 1, color: context.isDark ? AppColor.neutral50 : AppColor.neutral30);
}

@ -16,6 +16,7 @@ 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_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/views/pages/user/land_page.dart' as old; import 'package:test_sa/views/pages/user/land_page.dart' as old;
import 'controllers/providers/api/user_provider.dart'; import 'controllers/providers/api/user_provider.dart';
@ -61,6 +62,7 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => CylinderTypesProvider()), ChangeNotifierProvider(create: (_) => CylinderTypesProvider()),
ChangeNotifierProvider(create: (_) => CylinderSizeProvider()), ChangeNotifierProvider(create: (_) => CylinderSizeProvider()),
ChangeNotifierProvider(create: (_) => DepartmentProvider()), ChangeNotifierProvider(create: (_) => DepartmentProvider()),
ChangeNotifierProvider(create: (_) => SiteProvider()),
], ],
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {

@ -1,3 +1,4 @@
import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
class CallRequestForWorkOrder { class CallRequestForWorkOrder {
@ -413,13 +414,13 @@ class Site {
} }
} }
class Department { class Department extends Base {
int id; int id;
String departmentName; String departmentName;
String departmentCode; String departmentCode;
String ntCode; String ntCode;
Department({this.id, this.departmentName, this.departmentCode, this.ntCode}); Department({this.id, this.departmentName, this.departmentCode, this.ntCode}) : super(identifier: id.toString(), name: departmentName);
Department.fromJson(Map<String, dynamic> json) { Department.fromJson(Map<String, dynamic> json) {
id = json['id']; id = json['id'];

@ -30,4 +30,8 @@ enum TranslationKeys {
httpError, httpError,
tryAgain, tryAgain,
destinationSite, destinationSite,
add,
site,
onlyNumbers,
youHaveToSelect,
} }

@ -1,5 +1,6 @@
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
@Deprecated("Use the model inside lib/models/new_models folder")
class GasRefillDetails { class GasRefillDetails {
Lookup type; Lookup type;
Lookup cylinderSize; Lookup cylinderSize;

@ -6,6 +6,7 @@ import 'package:test_sa/models/lookup.dart';
import '../../controllers/api_routes/urls.dart'; import '../../controllers/api_routes/urls.dart';
import '../call_request_for_work_order_model.dart'; import '../call_request_for_work_order_model.dart';
@Deprecated("Use the new model [lib/models/new_models/gas_refill_model.dart]")
class GasRefillModel { class GasRefillModel {
int id; int id;

@ -0,0 +1,27 @@
class AssignedEmployee {
AssignedEmployee({
this.id,
this.name,
});
AssignedEmployee.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
}
String id;
String name;
AssignedEmployee copyWith({
String id,
String name,
}) =>
AssignedEmployee(
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
return map;
}
}

@ -0,0 +1,48 @@
import 'package:test_sa/models/new_models/floor.dart';
class Building {
Building({
this.id,
this.name,
this.value,
this.floors,
});
Building.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
value = json['value'];
if (json['floors'] != null) {
floors = [];
json['floors'].forEach((v) {
floors.add(Floor.fromJson(v));
});
}
}
num id;
String name;
num value;
List<Floor> floors;
Building copyWith({
num id,
String name,
num value,
List<Floor> floors,
}) =>
Building(
id: id ?? this.id,
name: name ?? this.name,
value: value ?? this.value,
floors: floors ?? this.floors,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['value'] = value;
if (floors != null) {
map['floors'] = floors.map((v) => v.toJson()).toList();
}
return map;
}
}

@ -0,0 +1,39 @@
class Department {
Department({
this.id,
this.departmentName,
this.departmentCode,
this.ntCode,
});
Department.fromJson(dynamic json) {
id = json['id'];
departmentName = json['departmentName'];
departmentCode = json['departmentCode'];
ntCode = json['ntCode'];
}
num id;
String departmentName;
String departmentCode;
String ntCode;
Department copyWith({
num id,
String departmentName,
String departmentCode,
String ntCode,
}) =>
Department(
id: id ?? this.id,
departmentName: departmentName ?? this.departmentName,
departmentCode: departmentCode ?? this.departmentCode,
ntCode: ntCode ?? this.ntCode,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['departmentName'] = departmentName;
map['departmentCode'] = departmentCode;
map['ntCode'] = ntCode;
return map;
}
}

@ -0,0 +1,48 @@
import 'package:test_sa/models/new_models/department.dart';
class Floor {
Floor({
this.id,
this.name,
this.value,
this.departments,
});
Floor.fromJson(dynamic json) {
id = json['id'];
name = json['name'];
value = json['value'];
if (json['departments'] != null) {
departments = [];
json['departments'].forEach((v) {
departments.add(Department.fromJson(v));
});
}
}
num id;
String name;
num value;
List<Department> departments;
Floor copyWith({
num id,
String name,
num value,
List<Department> departments,
}) =>
Floor(
id: id ?? this.id,
name: name ?? this.name,
value: value ?? this.value,
departments: departments ?? this.departments,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['name'] = name;
map['value'] = value;
if (departments != null) {
map['departments'] = departments.map((v) => v.toJson()).toList();
}
return map;
}
}

@ -0,0 +1,225 @@
import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/enums/translation_keys.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assigned_employee.dart';
import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/department.dart';
import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/site.dart';
class GasRefillModel {
GasRefillModel({
this.id,
this.gazRefillNo,
this.expectedDate,
this.expectedTime,
this.startDate,
this.startTime,
this.endDate,
this.endTime,
this.engSignature,
this.nurseSignature,
this.workingHours,
this.site,
this.building,
this.floor,
this.department,
this.assignedEmployee,
this.status,
this.gazRefillDetails,
});
GasRefillModel.fromJson(dynamic json) {
id = json['id'];
gazRefillNo = json['gazRefillNo'];
expectedDate = json['expectedDate'];
expectedTime = json['expectedTime'];
startDate = json['startDate'];
startTime = json['startTime'];
endDate = json['endDate'];
endTime = json['endTime'];
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
workingHours = json['workingHours'];
site = json['site'] != null ? Site.fromJson(json['site']) : null;
building = json['building'] != null ? Building.fromJson(json['building']) : null;
floor = json['floor'] != null ? Floor.fromJson(json['floor']) : null;
department = json['department'] != null ? Department.fromJson(json['department']) : null;
assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
status = json['status'] != null ? Lookup.fromJson(json['status']) : null;
if (json['gazRefillDetails'] != null) {
gazRefillDetails = [];
json['gazRefillDetails'].forEach((v) {
gazRefillDetails.add(GasRefillDetails.fromJson(v));
});
}
}
num id;
String gazRefillNo;
String expectedDate;
String expectedTime;
String startDate;
String startTime;
String endDate;
String endTime;
String engSignature;
String nurseSignature;
num workingHours;
Site site;
Building building;
Floor floor;
Department department;
AssignedEmployee assignedEmployee;
Lookup status;
List<GasRefillDetails> gazRefillDetails;
GasRefillModel copyWith({
num id,
String gazRefillNo,
String expectedDate,
String expectedTime,
String startDate,
String startTime,
String endDate,
String endTime,
String engSignature,
String nurseSignature,
num workingHours,
Site site,
Building building,
Floor floor,
Department department,
AssignedEmployee assignedEmployee,
Lookup status,
List<GasRefillDetails> gazRefillDetails,
}) =>
GasRefillModel(
id: id ?? this.id,
gazRefillNo: gazRefillNo ?? this.gazRefillNo,
expectedDate: expectedDate ?? this.expectedDate,
expectedTime: expectedTime ?? this.expectedTime,
startDate: startDate ?? this.startDate,
startTime: startTime ?? this.startTime,
endDate: endDate ?? this.endDate,
endTime: endTime ?? this.endTime,
engSignature: engSignature ?? this.engSignature,
nurseSignature: nurseSignature ?? this.nurseSignature,
workingHours: workingHours ?? this.workingHours,
site: site ?? this.site,
building: building ?? this.building,
floor: floor ?? this.floor,
department: department ?? this.department,
assignedEmployee: assignedEmployee ?? this.assignedEmployee,
status: status ?? this.status,
gazRefillDetails: gazRefillDetails ?? this.gazRefillDetails,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['gazRefillNo'] = gazRefillNo;
map['expectedDate'] = expectedDate;
map['expectedTime'] = expectedTime;
map['startDate'] = startDate;
map['startTime'] = startTime;
map['endDate'] = endDate;
map['endTime'] = endTime;
map['engSignature'] = engSignature;
map['nurseSignature'] = nurseSignature;
map['workingHours'] = workingHours;
if (site != null) {
map['site'] = site.toJson();
}
if (building != null) {
map['building'] = building.toJson();
}
if (floor != null) {
map['floor'] = floor.toJson();
}
if (department != null) {
map['department'] = department.toJson();
}
if (assignedEmployee != null) {
map['assignedEmployee'] = assignedEmployee.toJson();
}
if (status != null) {
map['status'] = status.toMap();
}
if (gazRefillDetails != null) {
map['gazRefillDetails'] = gazRefillDetails.map((v) => v.toJson()).toList();
}
return map;
}
}
class GasRefillDetails {
GasRefillDetails({
this.id,
this.gasType,
this.cylinderType,
this.cylinderSize,
this.requestedQty,
this.deliverdQty,
});
GasRefillDetails.fromJson(dynamic json) {
id = json['id'];
gasType = json['gasType'] != null ? Lookup.fromJson(json['gasType']) : null;
cylinderType = json['cylinderType'] != null ? Lookup.fromJson(json['cylinderType']) : null;
cylinderSize = json['cylinderSize'] != null ? Lookup.fromJson(json['cylinderSize']) : null;
requestedQty = json['requestedQty'];
deliverdQty = json['deliverdQty'];
}
num id;
Lookup gasType;
Lookup cylinderType;
Lookup cylinderSize;
num requestedQty;
num deliverdQty;
GasRefillDetails copyWith({
num id,
Lookup gasType,
Lookup cylinderType,
Lookup cylinderSize,
num requestedQty,
num deliverdQty,
}) =>
GasRefillDetails(
id: id ?? this.id,
gasType: gasType ?? this.gasType,
cylinderType: cylinderType ?? this.cylinderType,
cylinderSize: cylinderSize ?? this.cylinderSize,
requestedQty: requestedQty ?? this.requestedQty,
deliverdQty: deliverdQty ?? this.deliverdQty,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
if (gasType != null) {
map['gasType'] = gasType.toMap();
}
if (cylinderType != null) {
map['cylinderType'] = cylinderType.toMap();
}
if (cylinderSize != null) {
map['cylinderSize'] = cylinderSize.toMap();
}
map['requestedQty'] = requestedQty;
map['deliverdQty'] = deliverdQty;
return map;
}
Future<bool> validate(BuildContext context) async {
if (gasType == null) {
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.gasType)}");
return false;
} else if (cylinderType == null) {
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.cylinderType)}");
return false;
} else if (cylinderSize == null) {
await Fluttertoast.showToast(msg: "${context.translate(TranslationKeys.youHaveToSelect)} ${context.translate(TranslationKeys.cylinderSize)}");
return false;
}
return true;
}
}

@ -0,0 +1,43 @@
import 'package:test_sa/models/base.dart';
import 'package:test_sa/models/new_models/building.dart';
class Site extends Base {
Site({
this.id,
this.custName,
this.buildings,
}) : super(identifier: id.toString(), name: custName);
Site.fromJson(dynamic json) {
id = json['id'];
custName = json['custName'];
if (json['buildings'] != null) {
buildings = [];
json['buildings'].forEach((v) {
buildings.add(Building.fromJson(v));
});
}
}
num id;
String custName;
List<Building> buildings;
Site copyWith({
num id,
String custName,
List<Building> buildings,
}) =>
Site(
id: id ?? this.id,
custName: custName ?? this.custName,
buildings: buildings ?? this.buildings,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['custName'] = custName;
if (buildings != null) {
map['buildings'] = buildings.map((v) => v.toJson()).toList();
}
return map;
}
}

@ -55,6 +55,7 @@ class AppThemes {
appBarTheme: AppBarTheme(elevation: 0, backgroundColor: AppColor.neutral60, iconTheme: ThemeData.dark().iconTheme.copyWith(color: AppColor.primary40)), appBarTheme: AppBarTheme(elevation: 0, backgroundColor: AppColor.neutral60, iconTheme: ThemeData.dark().iconTheme.copyWith(color: AppColor.primary40)),
cardTheme: ThemeData.dark().cardTheme.copyWith( cardTheme: ThemeData.dark().cardTheme.copyWith(
elevation: 3, elevation: 3,
color: AppColor.neutral60,
shadowColor: Colors.white.withOpacity(0.05), shadowColor: Colors.white.withOpacity(0.05),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
), ),

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart'; import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart';
import 'package:test_sa/new_views/pages/new_service_request_page.dart'; import 'package:test_sa/new_views/pages/new_service_request_page.dart';
import 'package:test_sa/new_views/pages/new_transfer_request_page.dart'; import 'package:test_sa/new_views/pages/new_transfer_request_page.dart';
@ -47,19 +48,16 @@ class _AppFloatingActionButtonState extends State<AppFloatingActionButton> {
child: Card( child: Card(
shape: Theme.of(context).cardTheme.copyWith().shape, shape: Theme.of(context).cardTheme.copyWith().shape,
margin: EdgeInsetsDirectional.only(start: 60.toScreenWidth), margin: EdgeInsetsDirectional.only(start: 60.toScreenWidth),
child: Padding( child: Column(
padding: EdgeInsets.symmetric(vertical: 8.toScreenHeight), mainAxisSize: MainAxisSize.min,
child: Column( children: [
mainAxisSize: MainAxisSize.min, const _FloatingButtonListTile(iconName: "gas_refill_request", label: TranslationKeys.gasRefillRequest, routeName: NewGasRefillRequestPage.routeName),
children: [ const Divider().defaultStyle(context).paddingOnly(left: 16, right: 16),
const _FloatingButtonListTile(iconName: "gas_refill_request", label: TranslationKeys.gasRefillRequest, routeName: NewGasRefillRequestPage.routeName), const _FloatingButtonListTile(iconName: "transfer_request", label: TranslationKeys.transferRequest, routeName: NewTransferRequestPage.routeName),
Padding(padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), child: const Divider()), const Divider().defaultStyle(context).paddingOnly(left: 16, right: 16),
const _FloatingButtonListTile(iconName: "transfer_request", label: TranslationKeys.transferRequest, routeName: NewTransferRequestPage.routeName), const _FloatingButtonListTile(iconName: "service_request", label: TranslationKeys.serviceRequest, routeName: NewServiceRequestPage.routeName),
Padding(padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), child: const Divider()), ],
const _FloatingButtonListTile(iconName: "service_request", label: TranslationKeys.serviceRequest, routeName: NewServiceRequestPage.routeName), ).paddingOnly(top: 8, bottom: 8),
],
),
),
), ),
), ),
), ),

@ -88,48 +88,46 @@ class _SingleItemDropDownMenuState<T extends Base, X extends LoadingListNotifier
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
const PositionedDirectional(end: 0, child: Icon(Icons.keyboard_arrow_down_rounded)), const PositionedDirectional(end: 0, child: Icon(Icons.keyboard_arrow_down_rounded)),
Expanded( Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(
Text( context.translate(widget.title),
context.translate(widget.title), style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), ),
DropdownButton<T>(
value: _selectedItem,
iconSize: 24,
isDense: true,
icon: const SizedBox.shrink(),
elevation: 0,
isExpanded: true,
hint: Text(
context.translate(TranslationKeys.select),
style: Theme.of(context).textTheme.bodyLarge,
), ),
DropdownButton<T>( style: TextStyle(color: Theme.of(context).primaryColor),
value: _selectedItem, underline: const SizedBox.shrink(),
iconSize: 24, onChanged: widget.enabled == false
isDense: true, ? null
icon: const SizedBox.shrink(), : (T newValue) {
elevation: 0, setState(() {
isExpanded: true, _selectedItem = newValue;
hint: Text( });
context.translate(TranslationKeys.select), widget.onSelect(newValue);
style: Theme.of(context).textTheme.bodyLarge, },
), items: provider.items?.map<DropdownMenuItem<T>>((value) {
style: TextStyle(color: Theme.of(context).primaryColor), return DropdownMenuItem<T>(
underline: const SizedBox.shrink(), value: value,
onChanged: widget.enabled == false child: Text(
? null value?.name ?? "",
: (T newValue) { style: Theme.of(context).textTheme.bodyLarge,
setState(() { ),
_selectedItem = newValue; );
}); })?.toList(),
widget.onSelect(newValue); ),
}, ],
items: provider.items?.map<DropdownMenuItem<T>>((value) {
return DropdownMenuItem<T>(
value: value,
child: Text(
value?.name ?? "",
style: Theme.of(context).textTheme.bodyLarge,
),
);
})?.toList(),
),
],
),
), ),
], ],
), ),

@ -47,7 +47,7 @@ class _LoginPageState extends State<LoginPage> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Hero(tag: "logo", child: "logo".toSvgAsset(height: 64.toScreenHeight)), Hero(tag: "logo", child: "logo".toSvgAsset(height: 64)),
64.height, 64.height,
context.translate(TranslationKeys.login).heading2(context).custom(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.primary50 : AppColor.neutral50), context.translate(TranslationKeys.login).heading2(context).custom(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.primary50 : AppColor.neutral50),
context.translate(TranslationKeys.enterCredsToLogin).heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), context.translate(TranslationKeys.enterCredsToLogin).heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),

@ -1,70 +1,199 @@
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/int_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/translation_keys.dart'; import 'package:test_sa/models/enums/translation_keys.dart';
import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/gas_refill_model.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.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_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 '../../controllers/validator/validator.dart';
import '../common_widgets/default_app_bar.dart'; import '../common_widgets/default_app_bar.dart';
class NewGasRefillRequestPage extends StatelessWidget { class NewGasRefillRequestPage extends StatefulWidget {
static const String routeName = "/new_gas_refill_request_page"; static const String routeName = "/new_gas_refill_request_page";
const NewGasRefillRequestPage({Key key}) : super(key: key); const NewGasRefillRequestPage({Key key}) : super(key: key);
@override
State<NewGasRefillRequestPage> createState() => _NewGasRefillRequestPageState();
}
class _NewGasRefillRequestPageState extends State<NewGasRefillRequestPage> {
GasRefillDetails _currentDetails;
GasRefillModel _gasModel;
GlobalKey<FormState> _formKey;
TextEditingController _quantityController;
@override
void initState() {
super.initState();
_formKey = GlobalKey<FormState>();
_currentDetails = GasRefillDetails();
_gasModel = GasRefillModel(gazRefillDetails: []);
_quantityController = TextEditingController();
}
@override
void dispose() {
_quantityController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: const DefaultAppBar(title: TranslationKeys.newGasRefillRequest), appBar: const DefaultAppBar(title: TranslationKeys.newGasRefillRequest),
body: Padding( body: Column(
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), children: [
child: SingleChildScrollView( SingleChildScrollView(
child: Column( child: Form(
children: [ key: _formKey,
16.height, child: Column(
SingleItemDropDownMenu<Lookup, GasTypesProvider>( children: [
context: context, 16.height,
title: TranslationKeys.gasType, SingleItemDropDownMenu<Lookup, GasTypesProvider>(
context: context,
title: TranslationKeys.gasType,
onSelect: (value) {
_currentDetails.gasType = value;
},
),
8.height,
AppTextFormField(
controller: _quantityController,
labelText: TranslationKeys.quantity,
textInputType: TextInputType.number,
validator: (value) => Validator.hasValue(value)
? Validator.isNumeric(value)
? null
: context.translate(TranslationKeys.onlyNumbers)
: context.translate(TranslationKeys.requiredField),
onSaved: (text) {
_currentDetails.requestedQty = double.tryParse(text ?? "") ?? 0;
},
),
8.height,
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
context: context,
title: TranslationKeys.cylinderType,
onSelect: (value) {
_currentDetails.cylinderType = value;
},
),
8.height,
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
context: context,
title: TranslationKeys.cylinderSize,
onSelect: (value) {
_currentDetails.cylinderSize = value;
},
),
8.height,
SingleItemDropDownMenu<Site, SiteProvider>(
context: context,
title: TranslationKeys.destinationSite,
onSelect: (value) {
_gasModel.site = value;
},
),
// 8.height,
// SingleItemDropDownMenu<Department, DepartmentProvider>(
// context: context,
// title: TranslationKeys.department,
// onSelect: (value) {
// _formModel.department = value;
// },
// ),
8.height,
AppFilledButton(
label: TranslationKeys.add,
maxWidth: true,
textColor: Colors.white,
buttonColor: context.isDark ? AppColor.neutral60 : AppColor.neutral50,
onPressed: _add,
),
24.height,
ListView.builder(
shrinkWrap: true,
itemCount: _gasModel.gazRefillDetails?.length,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
return Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_gasModel.gazRefillDetails[index].gasType?.name?.heading5(context),
8.height,
("${context.translate(TranslationKeys.quantity)}: ${_gasModel.gazRefillDetails[index].requestedQty}").bodyText(context),
("${context.translate(TranslationKeys.cylinderSize)}: ${_gasModel.gazRefillDetails[index].cylinderSize?.name}").bodyText(context),
("${context.translate(TranslationKeys.cylinderType)}: ${_gasModel.gazRefillDetails[index].cylinderType?.name}").bodyText(context),
],
),
Container(
height: 48.toScreenWidth,
width: 48.toScreenWidth,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
),
padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight),
child: "trash".toSvgAsset(fit: BoxFit.fitHeight, color: context.isDark ? AppColor.red40 : AppColor.red50),
).onPress(() {
_delete(index);
}),
],
),
const Divider().defaultStyle(context),
("${context.translate(TranslationKeys.department)}: ${_gasModel.department?.departmentCode}").bodyText(context),
("${context.translate(TranslationKeys.site)}: ${_gasModel.department?.departmentName}").bodyText(context),
],
).paddingAll(16),
);
},
),
40.height,
],
), ),
8.height, ),
const AppTextFormField( ).expanded,
labelText: TranslationKeys.quantity, AppFilledButton(label: TranslationKeys.submitRequest, maxWidth: true, onPressed: _submit),
textInputType: TextInputType.number, ],
), ).paddingOnly(left: 16, right: 16, bottom: 24),
8.height,
SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
context: context,
title: TranslationKeys.cylinderType,
),
8.height,
SingleItemDropDownMenu<Lookup, CylinderSizeProvider>(
context: context,
title: TranslationKeys.cylinderSize,
),
8.height,
// SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
// context: context,
// title: TranslationKeys.department,
// ),
// 8.height,
// SingleItemDropDownMenu<Lookup, CylinderTypesProvider>(
// context: context,
// title: TranslationKeys.destinationSite,
// ),
// 8.height,
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: AppFilledButton(
label: TranslationKeys.submitRequest,
maxWidth: true,
onPressed: () {},
),
); );
} }
void _add() async {
if (_formKey.currentState.validate() && await _currentDetails.validate(context)) {
_formKey.currentState.save();
_gasModel.gazRefillDetails.add(_currentDetails);
_quantityController.clear();
_currentDetails = GasRefillDetails();
setState(() {});
}
}
void _delete(index) {
_gasModel.gazRefillDetails.remove(_gasModel.gazRefillDetails[index]);
setState(() {});
}
void _submit() {
Navigator.pop(context);
}
} }

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/translation_keys.dart'; import 'package:test_sa/models/enums/translation_keys.dart';
import '../common_widgets/app_filled_button.dart'; import '../common_widgets/app_filled_button.dart';
@ -12,12 +13,14 @@ class NewServiceRequestPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: const DefaultAppBar(title: TranslationKeys.newServiceRequest), appBar: const DefaultAppBar(title: TranslationKeys.newServiceRequest),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, body: Column(
floatingActionButton: AppFilledButton( children: [
label: TranslationKeys.submitRequest, SingleChildScrollView(
maxWidth: true, child: Column(children: []),
onPressed: () {}, ).expanded,
), AppFilledButton(label: TranslationKeys.submitRequest, maxWidth: true, onPressed: () {})
],
).paddingOnly(left: 16, right: 16, bottom: 24),
); );
} }
} }

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/translation_keys.dart'; import 'package:test_sa/models/enums/translation_keys.dart';
import '../common_widgets/app_filled_button.dart'; import '../common_widgets/app_filled_button.dart';
@ -12,12 +13,14 @@ class NewTransferRequestPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: const DefaultAppBar(title: TranslationKeys.newTransferRequest), appBar: const DefaultAppBar(title: TranslationKeys.newTransferRequest),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, body: Column(
floatingActionButton: AppFilledButton( children: [
label: TranslationKeys.submitRequest, SingleChildScrollView(
maxWidth: true, child: Column(children: []),
onPressed: () {}, ).expanded,
), AppFilledButton(label: TranslationKeys.submitRequest, maxWidth: true, onPressed: () {})
],
).paddingOnly(left: 16, right: 16, bottom: 24),
); );
} }
} }

@ -0,0 +1,34 @@
import 'dart:convert';
import 'package:http/http.dart';
import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/providers/loading_list_notifier.dart';
import '../../controllers/api_routes/api_manager.dart';
import '../../controllers/api_routes/urls.dart';
class SiteProvider extends LoadingListNotifier<Site> {
@override
Future getDate() async {
if (loading ?? false) return -2;
loading = true;
notifyListeners();
try {
Response response = await ApiManager.instance.get(URLs.getSitesAutoComplete);
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) => Site.fromJson(item)).toList();
}
loading = false;
notifyListeners();
return response.statusCode;
} catch (error) {
loading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -11,7 +11,6 @@ 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/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart'; import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart';
import 'package:test_sa/new_views/pages/new_transfer_request_page.dart'; import 'package:test_sa/new_views/pages/new_transfer_request_page.dart';
import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/colors.dart';
@ -148,16 +147,17 @@ class _LandPageState extends State<LandPage> {
mainAxisSpacing: 12, mainAxisSpacing: 12,
childAspectRatio: 1, childAspectRatio: 1,
children: [ children: [
if (_userProvider.user != null && _userProvider.user.type == UsersTypes.normal_user) /// enable this condition when the nurse account works
LandPageItem( // if (_userProvider.user != null && _userProvider.user.type == UsersTypes.normal_user)
// text: _subtitle.newServiceRequest, LandPageItem(
text: "New Service Request", // text: _subtitle.newServiceRequest,
icon: FontAwesomeIcons.screwdriverWrench, text: "New Service Request",
onPressed: () { icon: FontAwesomeIcons.screwdriverWrench,
// Navigator.of(context).pushNamed(CreateRequestPage.id); onPressed: () {
Navigator.of(context).pushNamed(NewServiceRequestPage.routeName); // Navigator.of(context).pushNamed(CreateRequestPage.id);
}, Navigator.of(context).pushNamed(NewServiceRequestPage.routeName);
), },
),
LandPageItem( LandPageItem(
// text: _subtitle.trackServiceRequest, // text: _subtitle.trackServiceRequest,
text: "Track Service Request", text: "Track Service Request",
@ -183,15 +183,16 @@ class _LandPageState extends State<LandPage> {
// Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id); // Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id);
// }, // },
// ), // ),
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.engineer) /// enable this condition when the nurse account works
LandPageItem( // if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.engineer)
text: "Request Gas Refill", LandPageItem(
icon: FontAwesomeIcons.truckFast, text: "Request Gas Refill",
onPressed: () { icon: FontAwesomeIcons.truckFast,
// Navigator.of(context).pushNamed(RequestGasRefill.id); onPressed: () {
Navigator.of(context).pushNamed(NewGasRefillRequestPage.routeName); // Navigator.of(context).pushNamed(RequestGasRefill.id);
}, Navigator.of(context).pushNamed(NewGasRefillRequestPage.routeName);
), },
),
LandPageItem( LandPageItem(
text: "Track Gas Refill", text: "Track Gas Refill",
icon: Icons.content_paste_search, icon: Icons.content_paste_search,
@ -214,14 +215,16 @@ class _LandPageState extends State<LandPage> {
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id); Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
}, },
), ),
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
LandPageItem( /// enable this condition when the nurse account works
text: "Create Sub Work Order", // if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
svgPath: "assets/images/sub_workorder_icon.svg", LandPageItem(
onPressed: () { text: "Create Sub Work Order",
Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id); svgPath: "assets/images/sub_workorder_icon.svg",
}, onPressed: () {
), Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
},
),
], ],
), ),
], ],

Loading…
Cancel
Save