Merge branch 'main_latest_merged' into zaid_development_new

# Conflicts:
#	assets/subtitles/en_subtitle.json
#	lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart
#	lib/models/subtitle.dart
#	lib/views/pages/user/requests/report/create_service_report.dart
#	lib/views/pages/user/requests/report/edit_service_report.dart
#	lib/views/widgets/status/report/service_report_status.dart
merge-requests/30/head
Sikander Saleem 1 year ago
commit 29181aa965

@ -137,7 +137,6 @@
"workPerformed": "العمل انجز",
"actualDate": "تاريخ الفعلي",
"done": "تم الانتهاء",
"expectDate": "التاريخ المتوقع",
"images": "الصور",
"imagesRequired": "الصور مطلوبة",
@ -189,6 +188,13 @@
"duplicateAlert": "تنبيه التكرار",
"duplicateAlertMessage": "هل أنت متأكد أنك تريد تكرار الطلب؟",
"duplicateRequest": "تكرار الطلب",
"orderWorkNumber": "رقم طلب العمل",
"assignedEmployee": "الموظف المعين",
"assetSN": "رقم تسلسلي للاصل ",
"assetName": "اسم الاصل",
"site": "الموقع",
"maintenanceSituation": "موقع الصيانه",
"currentSituation": "الموقع الحالي",
"comment" : "تعليق",
"updateServiceRequest" : "تعديل طلب الخدمة",
"repairLocation" : "موقع الإصلاح",

@ -136,7 +136,6 @@
"workPerformed": "Work Performed",
"actualDate": "Actual Date",
"done": "Done",
"expectDate": "Expect Date",
"images": "Images",
"imagesRequired": "Images Required",
@ -184,6 +183,13 @@
"requiredWord": "required",
"serviceType": "Service Type",
"workPreformed": "Work Preformed",
"orderWorkNumber": "Order Work Number",
"assignedEmployee": "Assigned Employee",
"assetSN": "Asset S.N",
"assetName": "Asset Name",
"site": "Site",
"maintenanceSituation": "Maintenance Situation",
"currentSituation": "Current Situation",
"alert": "Alert",
"duplicateAlert": "Duplicate Alert",

@ -8,35 +8,33 @@ import 'package:http/http.dart';
import 'package:test_sa/models/user.dart';
class ApiManager {
ApiManager._();
Map<String,String> get _headers => {
'Content-Type': 'application/json',
if(user != null) 'Authorization': 'Bearer ${user.token}',
};
Map<String, String> get _headers => {
'Content-Type': 'application/json',
if (user != null) 'Authorization': 'Bearer ${user.token}',
};
static ApiManager instance = ApiManager._();
User user;
Future<http.Response> get(
String url,
{Map<String,String> headers,}
) async{
String url, {
Map<String, String> headers,
}) async {
headers ??= {};
headers.addAll(_headers);
Uri _url = Uri.parse(url);
// print(_url);
// print(headers);
http.Response response = await http.get(_url,headers: headers);
if(jsonDecode(response.body) is Map<String,dynamic>){
// print(_url);
// print(headers);
http.Response response = await http.get(_url, headers: headers);
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if(message != null && message.toString().isNotEmpty){
Fluttertoast.showToast(msg: message ?? "",toastLength: Toast.LENGTH_LONG);
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}
@ -44,12 +42,10 @@ class ApiManager {
}
Future<http.Response> post(
String url, {
Map<String,String> headers,
@required Map<String,dynamic> body,
}
) async{
String url, {
Map<String, String> headers,
@required Map<String, dynamic> body,
}) async {
headers ??= {};
headers.addAll(_headers);
@ -67,10 +63,10 @@ class ApiManager {
// print(response.statusCode);
// log(response.body);
if(jsonDecode(response.body) is Map<String,dynamic>){
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if(message != null && message.toString().isNotEmpty){
Fluttertoast.showToast(msg: message ?? "",toastLength: Toast.LENGTH_LONG);
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}
@ -78,12 +74,10 @@ class ApiManager {
}
Future<http.Response> put(
String url, {
Map<String,String> headers,
@required Map<String,dynamic> body,
}
) async{
String url, {
Map<String, String> headers,
@required Map<String, dynamic> body,
}) async {
headers ??= {};
headers.addAll(_headers);
@ -100,22 +94,24 @@ class ApiManager {
http.Response response = await http.Response.fromStream(streamedResponse);
// print(response.statusCode);
// log(response.body);
if(jsonDecode(response.body) is Map<String,dynamic>){
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if(message != null && message.toString().isNotEmpty){
Fluttertoast.showToast(msg: message ?? "",toastLength: Toast.LENGTH_LONG);
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}
return response;
}
Future<http.Response> multiPart(
String url, {
Map<String,String> headers,
@required Map<String,String> body,
@required List<Future<MultipartFile>> files,
}) async{
Map<String,String> _headers = const {'Content-Type': 'multipart/form-data',};
String url, {
Map<String, String> headers,
@required Map<String, String> body,
@required List<Future<MultipartFile>> files,
}) async {
Map<String, String> _headers = const {
'Content-Type': 'multipart/form-data',
};
headers ??= {};
@ -139,10 +135,10 @@ class ApiManager {
http.Response response = await http.Response.fromStream(streamedResponse);
// print(response.statusCode);
// log(response.body);
if(jsonDecode(response.body) is Map<String,dynamic>){
if (jsonDecode(response.body) is Map<String, dynamic>) {
final message = jsonDecode(response.body)["message"];
if(message != null && message.toString().isNotEmpty){
Fluttertoast.showToast(msg: message ?? "",toastLength: Toast.LENGTH_LONG);
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}
return response;

@ -1,40 +1,39 @@
import 'package:meta/meta.dart';
import 'package:test_sa/models/subtitle.dart';
class HttpStatusManger{
class HttpStatusManger {
static String getStatusMessage({
@required int status,
@required Subtitle subtitle,
String messageFor400,
String messageFor200,
}){
if(status == null)
}) {
if (status == null)
// no status code - code error no need for subtitle
return "careful null status";
if(status == -1)
if (status == -1)
// client's request in process
return subtitle.currentlyServiceNotAvailable;
if(status == -2){
if (status == -2) {
// client's request in process
return subtitle.waitUntilYourRequestComplete;
}else if(status >= 200 && status < 300){
} else if (status >= 200 && status < 300) {
// client's request was successfully received
return messageFor200 ?? subtitle.requestCompleteSuccessfully;
} else if(status >= 400 && status < 500){
} else if (status >= 400 && status < 500) {
// client's request have error
switch(status){
switch (status) {
case 400:
return messageFor400 ?? subtitle.failedToCompleteRequest;
default:
return subtitle.failedToCompleteRequest;
}
} else if(status >= 500){
} else if (status >= 500) {
// server error
return subtitle.currentlyServiceNotAvailable;
} else {
// no error match so return default error
return subtitle.failedToCompleteRequest;
}
}
}

@ -49,6 +49,7 @@ class URLs {
static get updateServiceReport => "$_baseUrl/WorkOrder/UpdateWorkOrder"; // get
static get getServiceReport => "$_baseUrl/WorkOrder/GetWorkOrderById"; // get
static get createDuplicatedReport => "$_baseUrl/handle/duplicate/request"; // get
static get searchWorkOrders => "$_baseUrl/WorkOrder/SearchWorkOrders";
static get getServiceReportReasons => "$_baseUrl/Lookups/GetLookup?lookupEnum=522"; // get
static get getServiceReportTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=501"; // get

@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:test_sa/models/subtitle.dart';
class AppLocalization {
AppLocalization(this.locale);
@ -17,23 +16,20 @@ class AppLocalization {
Subtitle get subtitle => _subtitle;
Future<void> load() async {
String jsonStringValues =
await rootBundle.loadString('assets/subtitles/${locale.languageCode}_subtitle.json');
String jsonStringValues = await rootBundle.loadString('assets/subtitles/${locale.languageCode}_subtitle.json');
_subtitle = Subtitle.fromJson(json.decode(jsonStringValues));
}
// static member to have simple access to the delegate from Material App
static const LocalizationsDelegate<AppLocalization> delegate =
_DemoLocalizationsDelegate();
static const LocalizationsDelegate<AppLocalization> delegate = _DemoLocalizationsDelegate();
}
class _DemoLocalizationsDelegate
extends LocalizationsDelegate<AppLocalization> {
class _DemoLocalizationsDelegate extends LocalizationsDelegate<AppLocalization> {
const _DemoLocalizationsDelegate();
@override
bool isSupported(Locale locale) {
return ['en','ar'].contains(locale.languageCode);
return ['en', 'ar'].contains(locale.languageCode);
}
@override

@ -7,8 +7,7 @@ import 'package:test_sa/models/app_notification.dart';
import 'notification_manger.dart';
class FirebaseNotificationManger{
class FirebaseNotificationManger {
static FirebaseMessaging messaging = FirebaseMessaging.instance;
static String token;
@ -23,7 +22,7 @@ class FirebaseNotificationManger{
sound: true,
);
if(settings.authorizationStatus == AuthorizationStatus.authorized){
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
token = await messaging.getToken();
}
return token;
@ -32,7 +31,7 @@ class FirebaseNotificationManger{
static initialized(BuildContext context) async {
await Firebase.initializeApp();
NotificationSettings settings;
try{
try {
settings = await messaging.requestPermission(
alert: true,
announcement: false,
@ -42,11 +41,11 @@ class FirebaseNotificationManger{
provisional: false,
sound: true,
);
}catch(error){
} catch (error) {
return;
}
if(settings.authorizationStatus != AuthorizationStatus.authorized){
if (settings.authorizationStatus != AuthorizationStatus.authorized) {
return;
}
@ -56,28 +55,17 @@ class FirebaseNotificationManger{
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
AppNotification notification = AppNotification.fromJson(message.data);
if(notification.path == null
|| notification.path.isEmpty)
return;
Navigator.pushNamed(
context,
notification.path,
arguments: notification.requestId
);
if (notification.path == null || notification.path.isEmpty) return;
Navigator.pushNamed(context, notification.path, arguments: notification.requestId);
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
AppNotification notification = AppNotification.fromJson(message.data);
NotificationManger.showNotification(
title: message.notification.title,
subtext: message.notification.body,
hashcode: int.tryParse(notification.requestId ?? "") ?? 1,
payload: json.encode(message.data)
);
title: message.notification.title, subtext: message.notification.body, hashcode: int.tryParse(notification.requestId ?? "") ?? 1, payload: json.encode(message.data));
return;
});
}
}
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
}
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {}

@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:test_sa/views/app_style/colors.dart';
class NotificationManger{
class NotificationManger {
// private constructor to avoid create object
NotificationManger._();
@ -12,43 +12,26 @@ class NotificationManger{
/// onNotificationPressed action when notification pressed to open tap
/// onIOSNotificationPressed action when notification pressed
/// to open tap in iOS versions older than 10
static initialisation(
Function(NotificationResponse) onNotificationPressed,
DidReceiveLocalNotificationCallback onIOSNotificationPressed
) async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
static initialisation(Function(NotificationResponse) onNotificationPressed, DidReceiveLocalNotificationCallback onIOSNotificationPressed) async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon',);
const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings(
'app_icon',
);
final DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings(
onDidReceiveLocalNotification: onIOSNotificationPressed);
final DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings(onDidReceiveLocalNotification: onIOSNotificationPressed);
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
macOS: initializationSettingsDarwin);
final InitializationSettings initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsDarwin, macOS: initializationSettingsDarwin);
await flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onDidReceiveNotificationResponse: onNotificationPressed);
await flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: onNotificationPressed);
}
// push new notification
static Future showNotification(
{
@required String title,
@required String subtext,
@required int hashcode,
String payload
}) async {
static Future showNotification({@required String title, @required String subtext, @required int hashcode, String payload}) async {
const AndroidNotificationDetails androidChannel = AndroidNotificationDetails(
'com.newtrack.testsa',
'Test SA',
channelDescription:'Push notification service for Test SA',
channelDescription: 'Push notification service for Test SA',
importance: Importance.max,
priority: Priority.max,
playSound: true,
@ -62,8 +45,7 @@ class NotificationManger{
groupKey: 'com.newtrack.testsa',
);
const DarwinNotificationDetails iosNotificationDetails =
DarwinNotificationDetails(
const DarwinNotificationDetails iosNotificationDetails = DarwinNotificationDetails(
categoryIdentifier: "testSA",
);
@ -81,5 +63,4 @@ class NotificationManger{
payload: payload,
);
}
}

@ -6,10 +6,9 @@ import 'package:test_sa/controllers/api_routes/api_manager.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/department.dart';
class DepartmentsProvider extends ChangeNotifier{
class DepartmentsProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
departments = null;
stateCode = null;
}
@ -19,7 +18,6 @@ class DepartmentsProvider extends ChangeNotifier{
// 500 service not available
int stateCode;
// contain user data
// when user not login or register _user = null
List<Department> departments;
@ -29,34 +27,29 @@ class DepartmentsProvider extends ChangeNotifier{
// failed _loading = false
bool isLoading;
/// return -2 if request in progress
/// return -1 if error happen when sending request
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getDepartment (String host) async {
if(isLoading == true)
return -2;
Future<int> getDepartment(String host) async {
if (isLoading == true) return -2;
isLoading = true;
notifyListeners();
Response response;
try{
response = await ApiManager.instance.post(
URLs.getDepartments,
body: {
"pageSize":50,
// if(title != null && title.isNotEmpty) "name":title,
}
);
} catch(error) {
try {
response = await ApiManager.instance.post(URLs.getDepartments, body: {
"pageSize": 50,
// if(title != null && title.isNotEmpty) "name":title,
});
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return -1;
}
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"];
departments = listJson.map((department) => Department.fromJson(department)).toList();
@ -65,5 +58,4 @@ class DepartmentsProvider extends ChangeNotifier{
notifyListeners();
return response.statusCode;
}
}

@ -143,61 +143,53 @@ class DeviceTransferProvider extends ChangeNotifier {
"destDepartmentId": oldModel.receiver.department.id,
};
if(isSender){
body.addAll(
{
"senderSiteId": newModel.client.id,
"senderDepartmentId": newModel.department.id,
"senderAssignedEmployeeId": newModel.userId,
"senderMachineStatusId": newModel.status.id,
"senderComment": newModel.comment,
"senderWorkingHours": newModel.workingHours,
"senderTravelingHours": newModel.travelingHours,
"senderAttachmentName": "${newModel.signature}.png",
"destSiteId": oldModel.receiver.client.id,
"destDepartmentId": oldModel.receiver.department.id,
"receiverAssignedEmployeeId": oldModel.receiver.userId,
"receiverMachineStatusId": oldModel.receiver.status.id??"",
"receiverComment": oldModel.receiver.comment,
"receiverWorkingHours": oldModel.receiver.workingHours,
"receiverTravelingHours": oldModel.receiver.travelingHours,
"receiverAttachmentName": "${oldModel.receiver.signature}.png",
}
);
}else{
body.addAll(
{
"senderSiteId": oldModel.sender.client.id,
"senderDepartmentId": oldModel.sender.department.id,
"senderAssignedEmployeeId": oldModel.sender.userId,
"senderMachineStatusId": oldModel.sender.status.id,
"senderComment": oldModel.sender.comment,
"senderWorkingHours": oldModel.sender.workingHours,
"senderTravelingHours": oldModel.sender.travelingHours,
"senderAttachmentName": "${oldModel.sender.signature}.png",
"destSiteId": newModel.client.id,
"destDepartmentId": newModel.department.id,
"receiverAssignedEmployeeId": newModel.userId,
"receiverMachineStatusId": newModel.status?.id??"",
"receiverComment": newModel.comment,
"receiverWorkingHours": newModel.workingHours,
"receiverTravelingHours": newModel.travelingHours,
"receiverAttachmentName": "${newModel.signature}.png",
}
);
if (isSender) {
body.addAll({
"senderSiteId": newModel.client.id,
"senderDepartmentId": newModel.department.id,
"senderAssignedEmployeeId": newModel.userId,
"senderMachineStatusId": newModel.status.id,
"senderComment": newModel.comment,
"senderWorkingHours": newModel.workingHours,
"senderTravelingHours": newModel.travelingHours,
"senderAttachmentName": "${newModel.signature}.png",
"destSiteId": oldModel.receiver.client.id,
"destDepartmentId": oldModel.receiver.department.id,
"receiverAssignedEmployeeId": oldModel.receiver.userId,
"receiverMachineStatusId": oldModel.receiver.status.id ?? "",
"receiverComment": oldModel.receiver.comment,
"receiverWorkingHours": oldModel.receiver.workingHours,
"receiverTravelingHours": oldModel.receiver.travelingHours,
"receiverAttachmentName": "${oldModel.receiver.signature}.png",
});
} else {
body.addAll({
"senderSiteId": oldModel.sender.client.id,
"senderDepartmentId": oldModel.sender.department.id,
"senderAssignedEmployeeId": oldModel.sender.userId,
"senderMachineStatusId": oldModel.sender.status.id,
"senderComment": oldModel.sender.comment,
"senderWorkingHours": oldModel.sender.workingHours,
"senderTravelingHours": oldModel.sender.travelingHours,
"senderAttachmentName": "${oldModel.sender.signature}.png",
"destSiteId": newModel.client.id,
"destDepartmentId": newModel.department.id,
"receiverAssignedEmployeeId": newModel.userId,
"receiverMachineStatusId": newModel.status?.id ?? "",
"receiverComment": newModel.comment,
"receiverWorkingHours": newModel.workingHours,
"receiverTravelingHours": newModel.travelingHours,
"receiverAttachmentName": "${newModel.signature}.png",
});
}
print(body["senderWorkingHours"]);
body.addAll(newModel.toJson(isSender));
print(body);
Response response;
try{
response = await ApiManager.instance.put(
URLs.updateDeviceTransfer,
body: body
);
try {
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: body);
print(response.body);
print("${newModel.signature}.png");

@ -23,7 +23,7 @@ class DevicesProvider extends ChangeNotifier {
int _stateCode;
int get stateCode => _stateCode;
List<Device> _devices=[];
List<Device> _devices = [];
List<Device> get devices => _devices;
// when categories in-process _loading = true
@ -54,8 +54,8 @@ class DevicesProvider extends ChangeNotifier {
Response response;
try {
response = await ApiManager.instance.post(URLs.getEquipment, body: {
"pageSize": pageItemNumber ,
"pageNumber":devices.length ~/ pageItemNumber + 1,
"pageSize": pageItemNumber,
"pageNumber": devices.length ~/ pageItemNumber + 1,
"siteId": hospitalId,
if (serialNumber?.isEmpty == false) "assetSerialNumber": serialNumber,
if (number?.isEmpty == false) "assetNo": number,
@ -72,10 +72,9 @@ class DevicesProvider extends ChangeNotifier {
List equipmentListJson = json.decode(response.body)["data"];
_devices.addAll(equipmentListJson.map<Device>((device) => Device.fromJson(device)).toList());
nextPage = true;
}else
{
nextPage = false;
}
} else {
nextPage = false;
}
_loading = false;
notifyListeners();
return response.statusCode;
@ -97,7 +96,7 @@ class DevicesProvider extends ChangeNotifier {
try {
response = await ApiManager.instance.post(URLs.getEquipment, body: {
"pageSize": pageItemNumber,
"pageNumber":devices.length ~/ pageItemNumber + 1,
"pageNumber": devices.length ~/ pageItemNumber + 1,
"siteId": devices.length ~/ pageItemNumber + 1,
if (serialNumber?.isEmpty == false) "assetSerialNumber": serialNumber,
if (number?.isEmpty == false) "assetNo": number,

@ -7,13 +7,12 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/user.dart';
class GasRefillProvider extends ChangeNotifier{
class GasRefillProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 50;
//reset provider data
void reset(){
void reset() {
items = null;
nextPage = true;
stateCode = null;
@ -40,132 +39,122 @@ class GasRefillProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getRequests ({
Future<int> getRequests({
@required String host,
@required User user,
}) async {
if(isLoading == true)
return -2;
if (isLoading == true) return -2;
isLoading = true;
Response response;
Map<String,dynamic> body = {};
body["pageNumber"] = (items?.length ?? 0) ~/pageItemNumber + 1;
body["pageSize"] = pageItemNumber;
response = await ApiManager.instance.post(
URLs.getGasRefill,
body: body,
);
stateCode = response.statusCode;
if(stateCode >= 200 && stateCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(response.body)["data"];
List<GasRefillModel> itemsPage = requestsListJson.map(
(request) => GasRefillModel.fromJson(request)).toList();
items ??= [];
items.addAll(itemsPage);
if(itemsPage.length == pageItemNumber){
nextPage = true;
}else{
nextPage = false;
}
Map<String, dynamic> body = {};
body["pageNumber"] = (items?.length ?? 0) ~/ pageItemNumber + 1;
body["pageSize"] = pageItemNumber;
response = await ApiManager.instance.post(
URLs.getGasRefill,
body: body,
);
stateCode = response.statusCode;
if (stateCode >= 200 && stateCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(response.body)["data"];
List<GasRefillModel> itemsPage = requestsListJson.map((request) => GasRefillModel.fromJson(request)).toList();
items ??= [];
items.addAll(itemsPage);
if (itemsPage.length == pageItemNumber) {
nextPage = true;
} else {
nextPage = false;
}
try{
}
try {
isLoading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
Future<int> createModel ({
Future<int> createModel({
@required String host,
@required User user,
@required GasRefillModel model,
}) async {
Map<String,dynamic> body = {
Map<String, dynamic> body = {
"uid": user.id.toString(),
"token": user.token ?? "",
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status.toMap(),
};
body["gazRefillDetails"] = model.details.map((model) => {
"gasType": model.type.toMap(),
"cylinderSize": model.cylinderSize.toMap(),
"cylinderType": model.cylinderType.toMap(),
"requestedQty": model.requestedQuantity,
}).toList();
body["gazRefillDetails"] = model.details
.map((model) => {
"gasType": model.type.toMap(),
"cylinderSize": model.cylinderSize.toMap(),
"cylinderType": model.cylinderType.toMap(),
"requestedQty": model.requestedQuantity,
})
.toList();
Response response;
try{
response = await ApiManager.instance.post(
URLs.requestGasRefill,
body: body
);
try {
response = await ApiManager.instance.post(URLs.requestGasRefill, body: body);
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if(items != null) {
reset();
if (response.statusCode >= 200 && response.statusCode < 300) {
if (items != null) {
reset();
notifyListeners();
}
}
return response.statusCode;
} catch(error) {
} catch (error) {
return -1;
}
}
Future<int> updateModel ({
Future<int> updateModel({
@required String host,
@required User user,
@required GasRefillModel oldModel,
@required GasRefillModel newModel,
}) async {
Map<String,dynamic> body = {
"id":newModel.id,
Map<String, dynamic> body = {
"id": newModel.id,
"gazRefillNo": newModel.title ?? "",
"status": newModel.status.toMap(),
};
body["gazRefillDetails"] = newModel.details.map((model) => {
"gasType": model.type.toMap(),
"cylinderSize": model.cylinderSize.toMap(),
"cylinderType": model.cylinderType.toMap(),
"requestedQty": model.requestedQuantity,
"deliverdQty": model.deliveredQuantity,
}).toList();
body["gazRefillDetails"] = newModel.details
.map((model) => {
"gasType": model.type.toMap(),
"cylinderSize": model.cylinderSize.toMap(),
"cylinderType": model.cylinderType.toMap(),
"requestedQty": model.requestedQuantity,
"deliverdQty": model.deliveredQuantity,
})
.toList();
Response response;
try{
response = await ApiManager.instance.put(
URLs.updateGasRefill,
body: body
);
try {
response = await ApiManager.instance.put(URLs.updateGasRefill, body: body);
// response = await post(
// Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"),
// body: body,
// );
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
oldModel.fromGasRefillModel(newModel);
notifyListeners();
}
return response.statusCode;
} catch(error) {
} catch (error) {
return -1;
}
}
}

@ -8,13 +8,12 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/user.dart';
class HospitalsProvider extends ChangeNotifier{
class HospitalsProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 50;
//reset provider data
void reset(){
void reset() {
_hospitals = null;
_stateCode = null;
}
@ -39,7 +38,7 @@ class HospitalsProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -49,58 +48,49 @@ class HospitalsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getHospitals ({String host,User user,String title}) async {
if(_loading == true)
return -2;
Future<int> getHospitals({String host, User user, String title}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
response = await ApiManager.instance.post(
URLs.getHospitals,
body: {
"pageNumber":(hospitals?.length ?? 0) ~/pageItemNumber + 1,
"pageSize":50,
if(title != null && title.isNotEmpty) "name":title,
}
);
try {
response = await ApiManager.instance.post(URLs.getHospitals, body: {
"pageNumber": (hospitals?.length ?? 0) ~/ pageItemNumber + 1,
"pageSize": 50,
if (title != null && title.isNotEmpty) "name": title,
});
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
List<Hospital> _page = categoriesListJson.map((category) => Hospital.fromJson(category)).toList();
if(hospitals == null)
_hospitals = [];
List<Hospital> _page = categoriesListJson.map((category) => Hospital.fromJson(category)).toList();
if (hospitals == null) _hospitals = [];
_hospitals.addAll(_page);
if(_page.length >= pageItemNumber){
if (_page.length >= pageItemNumber) {
_nextPage = true;
}else{
} else {
_nextPage = false;
}
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
Future<List<Hospital>> getHospitalsList ({String host,User user,String title}) async {
Future<List<Hospital>> getHospitalsList({String host, User user, String title}) async {
Response response;
try{
response = await ApiManager.instance.post(
URLs.getHospitals,
body: {
"pageSize":50,
if(title != null && title.isNotEmpty) "name":title,
}
);
try {
response = await ApiManager.instance.post(URLs.getHospitals, body: {
"pageSize": 50,
if (title != null && title.isNotEmpty) "name": title,
});
// response = await get(
// Uri.parse(host + URLs.getHospitals
// + ( title == null || title.isEmpty ? "" : "?name=$title" )),
@ -110,20 +100,18 @@ class HospitalsProvider extends ChangeNotifier{
// );
_stateCode = response.statusCode;
List<Hospital> _page = [];
if(response.statusCode >= 200 && response.statusCode < 300) {
List<Hospital> _page = [];
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_page = categoriesListJson.map((category) => Hospital.fromJson(category)).toList();
}
return _page;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return [];
}
}
}

@ -6,13 +6,12 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/app_notification.dart';
import 'package:test_sa/models/user.dart';
class NotificationsProvider extends ChangeNotifier{
class NotificationsProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 20;
//reset provider data
void reset(){
void reset() {
notifications = null;
nextPage = true;
stateCode = null;
@ -34,58 +33,50 @@ class NotificationsProvider extends ChangeNotifier{
// failed _loading = false
bool isLoading;
/// return -2 if request in progress
/// return -1 if error happen when sending request
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getNotifications ({
Future<int> getNotifications({
@required String host,
@required User user,
@required int hospitalId,
}) async {
if(isLoading == true)
return -2;
if (isLoading == true) return -2;
isLoading = true;
notifyListeners();
Response response;
// userId = 397.toString(); // testing id to view data
try{
// userId = 397.toString(); // testing id to view data
try {
response = await get(
Uri.parse(URLs.getNotifications
+"?uid=${user.id}"
"&token=${user.token}"
"&page=${(notifications?.length ?? 0) ~/pageItemNumber}"),
headers: {
"Content-Type":"application/json; charset=utf-8"
}
);
Uri.parse(URLs.getNotifications +
"?uid=${user.id}"
"&token=${user.token}"
"&page=${(notifications?.length ?? 0) ~/ pageItemNumber}"),
headers: {"Content-Type": "application/json; charset=utf-8"});
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(utf8.decode(response.bodyBytes));
List<AppNotification> _serviceRequestsPage = requestsListJson.map(
(request) => AppNotification.fromJson(request)).toList();
if(notifications == null)
notifications = [];
List<AppNotification> _serviceRequestsPage = requestsListJson.map((request) => AppNotification.fromJson(request)).toList();
if (notifications == null) notifications = [];
notifications.addAll(_serviceRequestsPage);
if(_serviceRequestsPage.length == pageItemNumber){
if (_serviceRequestsPage.length == pageItemNumber) {
nextPage = true;
}else{
} else {
nextPage = false;
}
}
isLoading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return -1;
}
}
/// return -2 if request in progress
@ -93,35 +84,26 @@ class NotificationsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<List<AppNotification>> getRecentNotifications ({
Future<List<AppNotification>> getRecentNotifications({
@required String host,
@required User user,
}) async {
Response response;
//userId = 397.toString(); // testing id to view data
try{
response = await get(
Uri.parse(host+URLs.getNotifications
+"?uid=${user.id}&token=${user.token}"),
headers: {
"Content-Type":"application/json; charset=utf-8"
}
);
try {
response = await get(Uri.parse(host + URLs.getNotifications + "?uid=${user.id}&token=${user.token}"), headers: {"Content-Type": "application/json; charset=utf-8"});
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List requestsListJson = json.decode(utf8.decode(response.bodyBytes));
List<AppNotification> _recentNotifications = requestsListJson.map(
(request) => AppNotification.fromJson(request)).toList();
List<AppNotification> _recentNotifications = requestsListJson.map((request) => AppNotification.fromJson(request)).toList();
return _recentNotifications;
}
return null;
} catch(error) {
} catch (error) {
return null;
}
}
}

@ -8,13 +8,12 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/part.dart';
import 'package:test_sa/models/user.dart';
class PartsProvider extends ChangeNotifier{
class PartsProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 50;
//reset provider data
void reset(){
void reset() {
_parts = null;
_stateCode = null;
}
@ -39,7 +38,7 @@ class PartsProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -49,44 +48,36 @@ class PartsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getParts ({String host,User user,String title}) async {
if(_loading == true)
return -2;
Future<int> getParts({String host, User user, String title}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
response = await ApiManager.instance.post(
URLs.getPartNumber,
body: {
if(title != null && title.isNotEmpty)
"partName":title
});
try {
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partName": title});
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
List<Part> _page = categoriesListJson.map((part) => Part.fromJson(part)).toList();
if(parts == null)
_parts = [];
List<Part> _page = categoriesListJson.map((part) => Part.fromJson(part)).toList();
if (parts == null) _parts = [];
_parts.addAll(_page);
if(_page.length >= pageItemNumber){
if (_page.length >= pageItemNumber) {
_nextPage = true;
}else{
} else {
_nextPage = false;
}
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
/// return -2 if request in progress
@ -94,26 +85,19 @@ class PartsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<List<Part>> getPartsList ({String host,User user,String title}) async {
Future<List<Part>> getPartsList({String host, User user, String title}) async {
Response response;
try{
response = await ApiManager.instance.post(
URLs.getPartNumber,
body: {
if(title != null && title.isNotEmpty)
"partName":title
});
List<Part> _page = [];
if(response.statusCode >= 200 && response.statusCode < 300) {
try {
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partName": title});
List<Part> _page = [];
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_page = categoriesListJson.map((part) => Part.fromJson(part)).toList();
}
return _page;
} catch(error) {
} catch (error) {
return [];
}
}
}

@ -11,13 +11,12 @@ import 'package:test_sa/models/visits/visit.dart';
import 'package:test_sa/models/visits/visits_group.dart';
import 'package:test_sa/models/visits/visits_search.dart';
class RegularVisitsProvider extends ChangeNotifier{
class RegularVisitsProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 20;
//reset provider data
void reset(){
void reset() {
visits = null;
nextPage = true;
stateCode = null;
@ -46,50 +45,47 @@ class RegularVisitsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getVisits ({
Future<int> getVisits({
@required String host,
@required User user,
// VisitsSearch visitsSearch,
// VisitsSearch visitsSearch,
}) async {
if(isLoading == true)
return -2;
if (isLoading == true) return -2;
isLoading = true;
if(visits == null) notifyListeners();
if (visits == null) notifyListeners();
Response response;
//userId = 397.toString(); // testing id to view data
try{
Map<String,dynamic> body = {};
try {
Map<String, dynamic> body = {};
body.addAll(visitsSearch.toMap());
body["pageNumber"] = (visits?.length ?? 0) ~/pageItemNumber +1;
body["pageNumber"] = (visits?.length ?? 0) ~/ pageItemNumber + 1;
body["pageSize"] = pageItemNumber;
response = await ApiManager.instance.post(
URLs.getRegularVisits,
body: body,
);
} catch(error) {
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
return -1;
}
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
try{
try {
List requestsListJson = json.decode(response.body)["data"];
List<Visit> _visits = requestsListJson.map(
(request) => Visit.fromJson(request)
).toList();
List<Visit> _visits = requestsListJson.map((request) => Visit.fromJson(request)).toList();
visits ??= [];
visits.addAll(_visits);
if(_visits.length == pageItemNumber){
if (_visits.length == pageItemNumber) {
nextPage = true;
}else{
} else {
nextPage = false;
}
}catch(error){
} catch (error) {
Logger().e(error);
isLoading = false;
stateCode = -1;
@ -107,29 +103,29 @@ class RegularVisitsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> updateGroupOfVisits ({
Future<int> updateGroupOfVisits({
@required String host,
@required User user,
VisitsGroup group,
}) async {
Response response;
try{
Map<String,dynamic> body = group.toJson();
try {
Map<String, dynamic> body = group.toJson();
response = await ApiManager.instance.post(
URLs.getRegularVisits,
body: body,
);
stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
reset();
notifyListeners();
}
return response.statusCode;
} catch(error) {
} catch (error) {
isLoading = false;
stateCode = -1;
notifyListeners();
@ -137,31 +133,26 @@ class RegularVisitsProvider extends ChangeNotifier{
}
}
Future<Pentry> getPently({String host,User user,int id}) async {
Future<Pentry> getPently({String host, User user, int id}) async {
Response response;
response = await get(
Uri.parse("$host${URLs.getPentry}/$id"),
headers: {
"Content-Type":"application/json; charset=utf-8"
}
);
response = await get(Uri.parse("$host${URLs.getPentry}/$id"), headers: {"Content-Type": "application/json; charset=utf-8"});
Pentry pantry;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
pantry = Pentry.fromMap(json.decode(utf8.decode(response.bodyBytes)));
}
return pantry;
}
Future<int> updatePentry ({
Future<int> updatePentry({
@required String host,
@required User user,
@required Pentry pentry,
@required Visit visit,
}) async {
try{
try {
Response response;
Map<String,dynamic> body = pentry.toMap(visit.id);
Map<String, dynamic> body = pentry.toMap(visit.id);
body["id"] = visit.id;
body["assetId"] = visit.deviceId;
body["ppmScheduleId"] = visit.ppmScheduleId;
@ -169,23 +160,19 @@ class RegularVisitsProvider extends ChangeNotifier{
// body["vChecklists"]?.addAll({});
// body["vCalibrationTools"]?.addAll({"visitId": visit.id,});
// body["vKits"]?.add({"visitId": visit.id,});
response = await ApiManager.instance.put(
URLs.updatePentry, body: body
);
response = await ApiManager.instance.put(URLs.updatePentry, body: body);
// response = await post(
// Uri.parse(host+URLs.updatePentry + "/${visit.id}"),
// body: body,
// );
if(response.statusCode >= 200 && response.statusCode < 300) {
reset();//visit.status = pentry.ppmVisitStatus;
if (response.statusCode >= 200 && response.statusCode < 300) {
reset(); //visit.status = pentry.ppmVisitStatus;
notifyListeners();
}
return response.statusCode;
} catch(error) {
} catch (error) {
return -1;
}
}
}

@ -13,6 +13,8 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/models/user.dart';
import '../../../models/service_request/search_work_order.dart';
class ServiceRequestsProvider extends ChangeNotifier {
// number of items call in each request
final pageItemNumber = 10;
@ -34,6 +36,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
// list of user requests
List<ServiceRequest> serviceRequests;
List<SearchWorkOrders> workOrders = [];
// when requests in-process _loading = true
// done _loading = true
@ -365,6 +368,34 @@ class ServiceRequestsProvider extends ChangeNotifier {
}
}
Future<List<SearchWorkOrders>> searchWorkOrders({@required String callId}) async {
Response response;
try {
var body = {
"pageSize": pageItemNumber,
"pageNumber": ((workOrders?.length ?? 0) ~/ pageItemNumber) + 1,
"callId": callId,
};
response = await ApiManager.instance.post(URLs.searchWorkOrders, body: body);
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List workOrdersJson = json.decode(response.body)["data"];
print(workOrdersJson);
workOrders = workOrdersJson.map<SearchWorkOrders>((request) => SearchWorkOrders.fromJson(request)).toList();
if (workOrders.length == pageItemNumber) {
nextPage = true;
} else {
nextPage = false;
}
}
return workOrders;
} catch (e) {
return [];
}
}
Future<int> createDuplicatedReport({
@required String host,
@required User user,

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class AssignedToProvider extends ChangeNotifier{
class AssignedToProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class AssignedToProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,18 +41,17 @@ class AssignedToProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getEmployees,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -61,13 +59,11 @@ class AssignedToProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -9,10 +9,9 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
class EngineersProvider extends ChangeNotifier{
class EngineersProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -33,7 +32,7 @@ class EngineersProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -43,17 +42,17 @@ class EngineersProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true) return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getEngineers,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body);
_items = categoriesListJson.map((type) => Engineer.fromJson(type)).toList();
@ -61,13 +60,11 @@ class EngineersProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class GasCylinderSizesProvider extends ChangeNotifier{
class GasCylinderSizesProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_loading = null;
_stateCode = null;
@ -33,7 +32,7 @@ class GasCylinderSizesProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -43,18 +42,20 @@ class GasCylinderSizesProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user,}) async {
if(_loading == true)
return -2;
Future<int> getData({
String host,
User user,
}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getGasCylinderSize,
URLs.getGasCylinderSize,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
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();
@ -62,13 +63,11 @@ class GasCylinderSizesProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class GasCylinderTypesProvider extends ChangeNotifier{
class GasCylinderTypesProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_loading = null;
_stateCode = null;
@ -33,7 +32,7 @@ class GasCylinderTypesProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -43,18 +42,20 @@ class GasCylinderTypesProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user,}) async {
if(_loading == true)
return -2;
Future<int> getData({
String host,
User user,
}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getGasCylinderType,
URLs.getGasCylinderType,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
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();
@ -62,13 +63,11 @@ class GasCylinderTypesProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -11,10 +11,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class GasStatusProvider extends ChangeNotifier{
class GasStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_loading = null;
_stateCode = null;
@ -36,7 +35,7 @@ class GasStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -46,17 +45,20 @@ class GasStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user,}) async {
if(_loading == true) return -2;
Future<int> getData({
String host,
User user,
}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getGasStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
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();
@ -64,13 +66,11 @@ class GasStatusProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -11,10 +11,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class GasTypesProvider extends ChangeNotifier{
class GasTypesProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_loading = null;
_stateCode = null;
@ -36,7 +35,7 @@ class GasTypesProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -46,17 +45,20 @@ class GasTypesProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user,}) async {
if(_loading == true) return -2;
Future<int> getData({
String host,
User user,
}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getGasTypes,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
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();
@ -64,13 +66,11 @@ class GasTypesProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class PentryStatusProvider extends ChangeNotifier{
class PentryStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class PentryStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,19 +41,18 @@ class PentryStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getPentryStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"];
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
@ -62,14 +60,11 @@ class PentryStatusProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class PentryTaskStatusProvider extends ChangeNotifier{
class PentryTaskStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class PentryTaskStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,19 +41,18 @@ class PentryTaskStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getPentryTaskStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -62,14 +60,11 @@ class PentryTaskStatusProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class PentryVisitStatusProvider extends ChangeNotifier{
class PentryVisitStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class PentryVisitStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,19 +41,18 @@ class PentryVisitStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getPentryVisitStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"];
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
@ -62,13 +60,11 @@ class PentryVisitStatusProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceRequestDefectTypesProvider extends ChangeNotifier{
class ServiceRequestDefectTypesProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceRequestDefectTypesProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,18 +41,17 @@ class ServiceRequestDefectTypesProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceReportDefectTypes,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"];
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
@ -61,14 +59,11 @@ class ServiceRequestDefectTypesProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceRequestPriorityProvider extends ChangeNotifier{
class ServiceRequestPriorityProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_items = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceRequestPriorityProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,19 +41,18 @@ class ServiceRequestPriorityProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceReportPriority,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List listJson = json.decode(response.body)["data"];
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
@ -62,13 +60,11 @@ class ServiceRequestPriorityProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceReportReasonsProvider extends ChangeNotifier{
class ServiceReportReasonsProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_reasons = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceReportReasonsProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,18 +41,17 @@ class ServiceReportReasonsProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getTypes ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getTypes({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceReportReasons,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_reasons = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -61,13 +59,11 @@ class ServiceReportReasonsProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -11,10 +11,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceReportStatusProvider extends ChangeNotifier{
class ServiceReportStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_status = null;
_stateCode = null;
}
@ -35,7 +34,7 @@ class ServiceReportStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -45,19 +44,18 @@ class ServiceReportStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getTypes ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getTypes({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceReportStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -65,14 +63,11 @@ class ServiceReportStatusProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceReportTypesProvider extends ChangeNotifier{
class ServiceReportTypesProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_types = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceReportTypesProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,18 +41,17 @@ class ServiceReportTypesProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getTypes ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getTypes({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceReportTypes,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_types = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -61,13 +59,11 @@ class ServiceReportTypesProvider extends ChangeNotifier{
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceStatusProvider extends ChangeNotifier{
class ServiceStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_statuses = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,33 +41,29 @@ class ServiceStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getTypes ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getTypes({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getAssetTypes,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceRequestStatusProvider extends ChangeNotifier{
class ServiceRequestStatusProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_statuses = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceRequestStatusProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,33 +41,29 @@ class ServiceRequestStatusProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceRequestStatus,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceRequestedThroughProvider extends ChangeNotifier{
class ServiceRequestedThroughProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_statuses = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceRequestedThroughProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,33 +41,29 @@ class ServiceRequestedThroughProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceRequestThrough,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -8,10 +8,9 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/user.dart';
class ServiceRequestTypeProvider extends ChangeNotifier{
class ServiceRequestTypeProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_statuses = null;
_stateCode = null;
}
@ -32,7 +31,7 @@ class ServiceRequestTypeProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -42,33 +41,29 @@ class ServiceRequestTypeProvider extends ChangeNotifier{
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<int> getData ({String host,User user}) async {
if(_loading == true)
return -2;
Future<int> getData({String host, User user}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
response = await ApiManager.instance.get(
URLs.getServiceRequestTypes,
);
_stateCode = response.statusCode;
if(response.statusCode >= 200 && response.statusCode < 300) {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List categoriesListJson = json.decode(response.body)["data"];
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
}
_loading = false;
notifyListeners();
return response.statusCode;
} catch(error) {
} catch (error) {
_loading = false;
_stateCode = -1;
notifyListeners();
return -1;
}
}
}

@ -7,9 +7,7 @@ import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../settings/app_settings.dart';
class SettingProvider extends ChangeNotifier{
class SettingProvider extends ChangeNotifier {
resetSettings() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
user = null;
@ -58,40 +56,38 @@ class SettingProvider extends ChangeNotifier{
}
// call loadSharedPreferences when provider initialise
SettingProvider(){
SettingProvider() {
loadSharedPreferences();
}
// get app setting
Future<void> loadSharedPreferences() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
if(prefs.containsKey(ASettings.language)){
if (prefs.containsKey(ASettings.language)) {
_language = prefs.getString(ASettings.language);
}else{
_language = 'en';
} else {
_language = 'en';
}
if(prefs.containsKey(ASettings.speechToText)){
if (prefs.containsKey(ASettings.speechToText)) {
_speechToText = prefs.getString(ASettings.speechToText);
}else{
_speechToText = 'ar';
} else {
_speechToText = 'ar';
}
if(prefs.containsKey(ASettings.user)){
if (prefs.containsKey(ASettings.user)) {
String userJson = prefs.getString(ASettings.user);
user = User.fromJson(json.decode(userJson));
}
if(prefs.containsKey(ASettings.host)){
if (prefs.containsKey(ASettings.host)) {
_host = prefs.getString(ASettings.host);
} else{
} else {
_host = URLs.host1;
}
isLoaded = true;
notifyListeners();
}
}

@ -1,24 +1,22 @@
class Validator{
class Validator {
// private constructor to avoid create class object
Validator._();
// check if string not empty and has value
static bool hasValue(String string){
if (string == null || string.isEmpty)
return false;
static bool hasValue(String string) {
if (string == null || string.isEmpty) return false;
return true;
}
// Return true if email is valid. Otherwise, return false
static bool isEmail(String email){
static bool isEmail(String email) {
RegExp exp = new RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
if(exp.hasMatch(email))
return true;
if (exp.hasMatch(email)) return true;
return false;
}
// Return true if phone number is valid. Otherwise, return false
static bool isPhoneNumber(String phoneNumber){
static bool isPhoneNumber(String phoneNumber) {
if (phoneNumber == null || phoneNumber.isEmpty) {
return false;
}
@ -26,17 +24,14 @@ class Validator{
final pattern = r'^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$';
final regExp = RegExp(pattern);
if (regExp.hasMatch(phoneNumber))
return true;
if (regExp.hasMatch(phoneNumber)) return true;
return false;
}
// Return true if password is valid. Otherwise, return false
static bool isValidPassword(String password){
if(password == null)
return false;
if(password.length <6)
return false;
static bool isValidPassword(String password) {
if (password == null) return false;
if (password.length < 6) return false;
return true;
}

@ -1,6 +1,6 @@
import 'package:test_sa/views/pages/user/requests/future_request_service_details.dart';
class AppNotification{
class AppNotification {
String requestId;
String title;
String description;
@ -15,13 +15,12 @@ class AppNotification{
this.path,
});
factory AppNotification.fromJson(Map<String,dynamic> parsedJson){
factory AppNotification.fromJson(Map<String, dynamic> parsedJson) {
return AppNotification(
requestId: parsedJson["nid"],
title: parsedJson["call_client"] ?? parsedJson["title"],
description: parsedJson["task_description"],
date: parsedJson["creation_date"],
path: FutureRequestServiceDetails.id
);
requestId: parsedJson["nid"],
title: parsedJson["call_client"] ?? parsedJson["title"],
description: parsedJson["task_description"],
date: parsedJson["creation_date"],
path: FutureRequestServiceDetails.id);
}
}

@ -1,4 +1,4 @@
class Department{
class Department {
int id;
String name;
@ -7,13 +7,13 @@ class Department{
this.name,
});
factory Department.fromJson(Map<String,dynamic> parsedJson){
factory Department.fromJson(Map<String, dynamic> parsedJson) {
return Department(
id: parsedJson["id"],
name: parsedJson["name"],
);
}
factory Department.fromDepartment(Department department){
factory Department.fromDepartment(Department department) {
return Department(
id: department?.id,
name: department?.name,

@ -5,7 +5,7 @@ import 'package:test_sa/models/device/device_transfer_info.dart';
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
class DeviceTransfer{
class DeviceTransfer {
int id;
String userId;
String title;
@ -22,12 +22,12 @@ class DeviceTransfer{
this.receiver,
});
bool validate(){
if(device == null) return false;
bool validate() {
if (device == null) return false;
return receiver.validate();
}
fromDeviceTransfer(DeviceTransfer old){
fromDeviceTransfer(DeviceTransfer old) {
id = old.id;
title = old.title;
userId = old.userId;
@ -40,7 +40,7 @@ class DeviceTransfer{
this.receiver = receiver;
}
factory DeviceTransfer.fromJson(Map<String,dynamic> parsedJson){
factory DeviceTransfer.fromJson(Map<String, dynamic> parsedJson) {
return DeviceTransfer(
id: parsedJson["id"],
title: parsedJson["transferCode"],
@ -56,16 +56,13 @@ class DeviceTransfer{
workingHours: parsedJson["senderWorkingHours"],
userId: parsedJson["senderAssignedEmployeeId"],
userName: parsedJson["senderAssignedEmployeeName"],
client: Hospital(
id: parsedJson["senderSiteId"],
name: parsedJson["senderSiteName"]
),
client: Hospital(id: parsedJson["senderSiteId"], name: parsedJson["senderSiteName"]),
department: Department(
id: parsedJson["senderDepartmentId"],
name: parsedJson["senderDepartmentName"],
),
// todo add segnature
signature: URLs.getFileUrl(parsedJson["senderAttachmentName"]),
signature: URLs.getFileUrl(parsedJson["senderAttachmentName"]),
status: Lookup(
id: parsedJson["senderMachineStatusId"],
name: parsedJson["senderMachineStatusName"],
@ -77,10 +74,7 @@ class DeviceTransfer{
workingHours: parsedJson["receiverWorkingHours"],
userId: parsedJson["receiverAssignedEmployeeId"],
userName: parsedJson["receiverAssignedEmployeeName"],
client: Hospital(
id: parsedJson["destSiteId"],
name: parsedJson["destSiteName"]
),
client: Hospital(id: parsedJson["destSiteId"], name: parsedJson["destSiteName"]),
department: Department(
id: parsedJson["destDepartmentId"],
name: parsedJson["destDepartmentName"],
@ -95,4 +89,3 @@ class DeviceTransfer{
);
}
}

@ -2,7 +2,7 @@ import 'package:test_sa/models/department.dart';
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
class DeviceTransferInfo{
class DeviceTransferInfo {
String userId;
String comment;
Hospital client;
@ -25,25 +25,25 @@ class DeviceTransferInfo{
this.status,
});
Map<String,String>toJson(bool isSender){
Map<String,String> body = {};
Map<String, String> toJson(bool isSender) {
Map<String, String> body = {};
final baseKey = isSender ? "sender_" : "receiver_";
if(comment != null && comment.isNotEmpty) body["${baseKey}comment"] = comment;
if(workingHours != null && workingHours.isNotEmpty) body["${baseKey}working_hours"] = workingHours;
if(travelingHours != null && travelingHours.isNotEmpty) body["${baseKey}travel_hours"] = travelingHours;
if(status != null) body["${baseKey}status"] = status.id.toString();
if(signature != null && signature.isNotEmpty) body["${baseKey}image"] = signature;
if (comment != null && comment.isNotEmpty) body["${baseKey}comment"] = comment;
if (workingHours != null && workingHours.isNotEmpty) body["${baseKey}working_hours"] = workingHours;
if (travelingHours != null && travelingHours.isNotEmpty) body["${baseKey}travel_hours"] = travelingHours;
if (status != null) body["${baseKey}status"] = status.id.toString();
if (signature != null && signature.isNotEmpty) body["${baseKey}image"] = signature;
return body;
}
bool validate(){
if(client == null) return false;
if(department == null) return false;
bool validate() {
if (client == null) return false;
if (department == null) return false;
return true;
}
fromDetails(DeviceTransferInfo old,{bool withSignature = true}){
fromDetails(DeviceTransferInfo old, {bool withSignature = true}) {
userId = old.userId;
userName = old.userName;
client = Hospital.fromHospital(old.client);
@ -51,11 +51,11 @@ class DeviceTransferInfo{
workingHours = old.workingHours;
travelingHours = old.travelingHours;
comment = old.comment;
if(withSignature) signature = old.signature;
if (withSignature) signature = old.signature;
status = old.status;
}
factory DeviceTransferInfo.fromJson(Map<String,dynamic> parsedJson,String key){
factory DeviceTransferInfo.fromJson(Map<String, dynamic> parsedJson, String key) {
return DeviceTransferInfo(
workingHours: parsedJson["${key}working_hours"],
travelingHours: parsedJson["${key}travel_hours"],
@ -63,19 +63,15 @@ class DeviceTransferInfo{
signature: parsedJson["${key}image"],
userId: parsedJson["${key}id"],
comment: parsedJson["${key}comment"],
client: Hospital(
id: parsedJson["${key}SiteId"],
name: parsedJson["${key}SiteName"]
),
client: Hospital(id: parsedJson["${key}SiteId"], name: parsedJson["${key}SiteName"]),
department: Department(
id: parsedJson["${key}DepartmentId"],
name: parsedJson["${key}DepartmentName"],
),
status: Lookup(
id: parsedJson["${key}status"],
name: parsedJson["${key}status"],
id: parsedJson["${key}status"],
name: parsedJson["${key}status"],
),
);
}
}

@ -8,15 +8,16 @@ class ModelDefinition {
String replacementDate;
int lifeSpan;
ModelDefinition(
{this.id,
this.assetName,
this.modelDefCode,
this.modelName,
this.manufacturerName,
this.supplierName,
this.replacementDate,
this.lifeSpan,});
ModelDefinition({
this.id,
this.assetName,
this.modelDefCode,
this.modelName,
this.manufacturerName,
this.supplierName,
this.replacementDate,
this.lifeSpan,
});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
@ -32,7 +33,7 @@ class ModelDefinition {
}
factory ModelDefinition.fromJson(Map<String, dynamic> map) {
if(map == null) return null;
if (map == null) return null;
return ModelDefinition(
id: map['id'] as int,
assetName: map['assetName'] as String,

@ -1,4 +1,4 @@
class Engineer{
class Engineer {
String id;
String name;
@ -7,15 +7,13 @@ class Engineer{
this.name,
});
factory Engineer.fromJson(Map<String,dynamic> parsedJson){
factory Engineer.fromJson(Map<String, dynamic> parsedJson) {
return Engineer(
id: parsedJson["userId"] ?? parsedJson["id"],
name: parsedJson["userName"] ?? parsedJson["name"],
);
}
factory Engineer.fromEngineer(Engineer department){
factory Engineer.fromEngineer(Engineer department) {
return Engineer(
id: department?.id,
name: department?.name,
@ -23,10 +21,7 @@ class Engineer{
}
@override
bool operator == (Object other) =>
identical(this, other) || other is Engineer &&
id == other.id;
bool operator ==(Object other) => identical(this, other) || other is Engineer && id == other.id;
@override
int get hashCode => id.hashCode;
@ -37,5 +32,4 @@ class Engineer{
'name': name,
};
}
}

@ -1,4 +1,4 @@
enum UsersTypes{
enum UsersTypes {
engineer, // 0
normal_user, // 1
}

@ -1,6 +1,6 @@
import 'package:test_sa/models/lookup.dart';
class GasRefillDetails{
class GasRefillDetails {
Lookup type;
Lookup cylinderSize;
Lookup cylinderType;
@ -15,13 +15,14 @@ class GasRefillDetails{
this.deliveredQuantity,
});
bool validate(){
bool validate() {
//if(cylinderSize == null) return false;
if(type == null) return false;
if(requestedQuantity == null) return false;
if (type == null) return false;
if (requestedQuantity == null) return false;
return true;
}
factory GasRefillDetails.fromJson(Map<String,dynamic> parsedJson){
factory GasRefillDetails.fromJson(Map<String, dynamic> parsedJson) {
return GasRefillDetails(
type: Lookup.fromJson(parsedJson["gasType"]),
cylinderSize: Lookup.fromJson(parsedJson["cylinderSize"]),
@ -31,14 +32,13 @@ class GasRefillDetails{
);
}
factory GasRefillDetails.fromDetails(GasRefillDetails details){
factory GasRefillDetails.fromDetails(GasRefillDetails details) {
return GasRefillDetails(
type: Lookup.fromStatus(details.type),
cylinderSize:Lookup.fromStatus(details.cylinderSize),
cylinderType:Lookup.fromStatus(details.cylinderType),
cylinderSize: Lookup.fromStatus(details.cylinderSize),
cylinderType: Lookup.fromStatus(details.cylinderType),
requestedQuantity: details.requestedQuantity,
deliveredQuantity: details.deliveredQuantity,
);
}
}

@ -1,7 +1,7 @@
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
import 'package:test_sa/models/lookup.dart';
class GasRefillModel{
class GasRefillModel {
int id;
//String userId;
String clientName;
@ -18,14 +18,14 @@ class GasRefillModel{
this.details,
});
bool validate(){
if(title == null) return false;
if(status == null) return false;
if(details == null && details.isEmpty) return false;
bool validate() {
if (title == null) return false;
if (status == null) return false;
if (details == null && details.isEmpty) return false;
return true;
}
fromGasRefillModel(GasRefillModel model){
fromGasRefillModel(GasRefillModel model) {
id = model.id;
//userId = model.userId;
clientName = model.clientName;
@ -34,9 +34,9 @@ class GasRefillModel{
details = model.details.map((e) => GasRefillDetails.fromDetails(e)).toList();
}
factory GasRefillModel.fromJson(Map<String,dynamic> parsedJson){
factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) {
List<GasRefillDetails> details = [];
if(parsedJson["gazRefillDetails"] != null){
if (parsedJson["gazRefillDetails"] != null) {
List list = parsedJson["gazRefillDetails"];
details = list.map((e) => GasRefillDetails.fromJson(e)).toList();
}
@ -44,11 +44,9 @@ class GasRefillModel{
id: parsedJson["id"],
//userId: parsedJson["uid"],
title: parsedJson["gazRefillNo"],
clientName: parsedJson["site"] == null ? null:
parsedJson["site"]["custName"],
clientName: parsedJson["site"] == null ? null : parsedJson["site"]["custName"],
status: Lookup.fromJson(parsedJson["status"]),
details: details,
);
}
}

@ -1,4 +1,4 @@
class Hospital{
class Hospital {
int id;
int customerCode;
String name;
@ -11,31 +11,15 @@ class Hospital{
this.buildings,
});
factory Hospital.fromJson(Map<String,dynamic> parsedJson){
return Hospital(
id: parsedJson["id"],
name: parsedJson["custName"],
customerCode: parsedJson["customerCode"],
buildings: parsedJson["buildings"]
);
factory Hospital.fromJson(Map<String, dynamic> parsedJson) {
return Hospital(id: parsedJson["id"], name: parsedJson["custName"], customerCode: parsedJson["customerCode"], buildings: parsedJson["buildings"]);
}
factory Hospital.fromHospital(Hospital hospital){
return Hospital(
id: hospital?.id,
name: hospital?.name,
customerCode: hospital?.customerCode,
buildings:hospital?.buildings
);
factory Hospital.fromHospital(Hospital hospital) {
return Hospital(id: hospital?.id, name: hospital?.name, customerCode: hospital?.customerCode, buildings: hospital?.buildings);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'customerCode': customerCode,
'custName': name,
"buildings":buildings
};
return {'id': id, 'customerCode': customerCode, 'custName': name, "buildings": buildings};
}
}

@ -1,4 +1,4 @@
class Issue{
class Issue {
String title;
String userId;
List<int> reports;
@ -15,13 +15,13 @@ class Issue{
this.serviceRequestId,
});
Map<String,String> toMap(){
Map<String,String> map ={};
if(title != null) map["title"] = title;
if(reports != null) map["issue_report"] = reports.toString();
if(userId != null) map["uid"] = userId;
if(description != null) map["desc"] = description;
if(serviceRequestId != null) map["call_id"] = serviceRequestId;
Map<String, String> toMap() {
Map<String, String> map = {};
if (title != null) map["title"] = title;
if (reports != null) map["issue_report"] = reports.toString();
if (userId != null) map["uid"] = userId;
if (description != null) map["desc"] = description;
if (serviceRequestId != null) map["call_id"] = serviceRequestId;
return map;
}
}

@ -1,5 +1,4 @@
class Lookup{
class Lookup {
//old name label
final String name;
// old name key
@ -13,25 +12,17 @@ class Lookup{
});
@override
bool operator == (Object other) =>
identical(this, other) || other is Lookup &&
((value != null && value == other.value)
|| ( id != null && id == other.id )) ;
bool operator ==(Object other) => identical(this, other) || other is Lookup && ((value != null && value == other.value) || (id != null && id == other.id));
@override
int get hashCode => id?.hashCode ?? value?.hashCode;
toMap(){
return {
"id": id,
"name": name,
"value": value
};
toMap() {
return {"id": id, "name": name, "value": value};
}
factory Lookup.fromStatus(Lookup old){
if(old == null) return null;
factory Lookup.fromStatus(Lookup old) {
if (old == null) return null;
return Lookup(
name: old.name,
id: old.id,
@ -39,8 +30,8 @@ class Lookup{
);
}
factory Lookup.fromJson(Map<String,dynamic> parsedJson){
if(parsedJson == null) return null;
factory Lookup.fromJson(Map<String, dynamic> parsedJson) {
if (parsedJson == null) return null;
return Lookup(
name: parsedJson["name"],
id: parsedJson["id"],

@ -1,6 +1,6 @@
import 'package:test_sa/models/lookup.dart';
class CalibrationTool{
class CalibrationTool {
int id;
Lookup assetsNumber;
DateTime dataOfTesting;
@ -13,16 +13,16 @@ class CalibrationTool{
Map<String, dynamic> toMap(int visitId) {
return {
"id":id ?? 0,
"id": id ?? 0,
"visitId": visitId,
if(assetsNumber != null) 'assetId': (assetsNumber?.id).toString(),
if(dataOfTesting != null) 'calibrationDateOfTesters': dataOfTesting.toIso8601String(),
if (assetsNumber != null) 'assetId': (assetsNumber?.id).toString(),
if (dataOfTesting != null) 'calibrationDateOfTesters': dataOfTesting.toIso8601String(),
};
}
factory CalibrationTool.fromMap(Map<String, dynamic> map) {
return CalibrationTool(
assetsNumber: Lookup(id: map["assetId"],name: map['assetSerialNo']),
assetsNumber: Lookup(id: map["assetId"], name: map['assetSerialNo']),
dataOfTesting: DateTime.tryParse(map['calibrationDateOfTesters'] ?? ""),
);
}

@ -1,6 +1,6 @@
import 'package:test_sa/models/lookup.dart';
class Contact{
class Contact {
Lookup title;
Lookup contactPerson;
String job;
@ -8,14 +8,7 @@ class Contact{
String telephone;
String landLine;
Contact({
this.title,
this.contactPerson,
this.job,
this.email,
this.telephone,
this.landLine
});
Contact({this.title, this.contactPerson, this.job, this.email, this.telephone, this.landLine});
Map<String, String> toMap() {
return {

@ -1,12 +1,9 @@
import 'package:test_sa/models/lookup.dart';
class ContactTitle extends Lookup {
ContactTitle({
int id,
String label
}):super(id: id,name: label);
ContactTitle({int id, String label}) : super(id: id, name: label);
factory ContactTitle.fromMap(Map<String,dynamic> parsedJson){
factory ContactTitle.fromMap(Map<String, dynamic> parsedJson) {
return ContactTitle(
label: parsedJson["value"],
id: parsedJson["id"],

@ -1,12 +1,9 @@
import 'package:test_sa/models/lookup.dart';
class ContactTitle extends Lookup {
ContactTitle({
int id,
String label
}):super(id: id,name: label);
ContactTitle({int id, String label}) : super(id: id, name: label);
factory ContactTitle.fromMap(Map<String,dynamic> parsedJson){
factory ContactTitle.fromMap(Map<String, dynamic> parsedJson) {
return ContactTitle(
label: parsedJson["value"],
id: parsedJson["id"],

@ -1,6 +1,6 @@
import 'package:test_sa/models/lookup.dart';
class PMKit{
class PMKit {
int id;
Lookup itemCode;
String itemName;
@ -10,22 +10,13 @@ class PMKit{
String quantityNeeded;
String quantityReserved;
PMKit({
this.id,
this.itemCode,
this.itemName,
this.preparationTimeFrame,
this.kitFrequencyDemand,
this.availability,
this.quantityNeeded,
this.quantityReserved
});
PMKit({this.id, this.itemCode, this.itemName, this.preparationTimeFrame, this.kitFrequencyDemand, this.availability, this.quantityNeeded, this.quantityReserved});
Map<String, dynamic> toMap(int visitId) {
return {
"id":id ?? 0,
"id": id ?? 0,
"visitId": visitId,
if(itemCode != null) 'partCatalogItemId': (itemCode?.id).toString(),
if (itemCode != null) 'partCatalogItemId': (itemCode?.id).toString(),
// if(itemName != null) 'itemName': itemName,
// if(preparationTimeFrame != null) 'preparationTimeFrame': preparationTimeFrame,
// if(kitFrequencyDemand != null) 'kitFrequencyDemand': kitFrequencyDemand,
@ -38,7 +29,7 @@ class PMKit{
factory PMKit.fromMap(Map<String, dynamic> map) {
return PMKit(
id: map['id'],
itemCode: Lookup(id:map['partCatalogItemId'],name:map["partNumber"]),
itemCode: Lookup(id: map['partCatalogItemId'], name: map["partNumber"]),
itemName: map['itemName'] as String,
preparationTimeFrame: map['preparationTimeFrame'] as String,
kitFrequencyDemand: map['kitFrequencyDemand'] as String,

@ -1,4 +1,4 @@
class Part{
class Part {
int id;
int reportPartID;
String code;
@ -13,21 +13,17 @@ class Part{
this.quantity = 1,
});
Map<String,dynamic> toJson(){
Map<String, dynamic> toJson() {
return {
"id": reportPartID ?? 0,
"sparePart":{
"id":id,
"partNo": code,
"partName":name
},
"qty":quantity
"sparePart": {"id": id, "partNo": code, "partName": name},
"qty": quantity
};
}
factory Part.fromJson(Map<String,dynamic> parsedJson,{Map<String,dynamic> reportJson}){
factory Part.fromJson(Map<String, dynamic> parsedJson, {Map<String, dynamic> reportJson}) {
return Part(
id: parsedJson["id"],
id: parsedJson["id"],
reportPartID: reportJson != null ? reportJson["id"] : null,
code: parsedJson["partNo"],
name: parsedJson["partName"],

@ -0,0 +1,548 @@
import 'package:test_sa/models/lookup.dart';
class SearchWorkOrders {
int id;
String parentWOId;
String workOrderNo;
int workOrderYear;
int workOrderSequennce;
CallRequest callRequest;
String assetType;
AssignedEmployee assignedEmployee;
String visitDate;
List assistantEmployees;
String supplier;
String vendorTicketNumber;
List contactPersonWorkOrders;
Lookup calllastSituation;
Lookup currentSituation;
String repairLocation;
String reason;
String startofWorkTime;
String endofWorkTime;
double workingHours;
num travelingHours;
num travelingExpenses;
ModelDefRelatedDefects faultDescription;
List sparePartsWorkOrders;
String reviewComment;
String comment;
String attachmentsWorkOrder;
String equipmentStatus;
List suppEngineerWorkOrders;
String engSignature;
String nurseSignature;
String woParentDto;
SearchWorkOrders(
{this.id,
this.parentWOId,
this.workOrderNo,
this.workOrderYear,
this.workOrderSequennce,
this.callRequest,
this.assetType,
this.assignedEmployee,
this.visitDate,
this.assistantEmployees,
this.supplier,
this.vendorTicketNumber,
this.contactPersonWorkOrders,
this.calllastSituation,
this.currentSituation,
this.repairLocation,
this.reason,
this.startofWorkTime,
this.endofWorkTime,
this.workingHours,
this.travelingHours,
this.travelingExpenses,
this.faultDescription,
this.sparePartsWorkOrders,
this.reviewComment,
this.comment,
this.attachmentsWorkOrder,
this.equipmentStatus,
this.suppEngineerWorkOrders,
this.engSignature,
this.nurseSignature,
this.woParentDto});
SearchWorkOrders.fromJson(Map<String, dynamic> json) {
print(json['callRequest']);
id = json['id'];
parentWOId = json['parentWOId'];
workOrderNo = json['workOrderNo'];
workOrderYear = json['workOrderYear'];
workOrderSequennce = json['workOrderSequennce'];
callRequest = json['callRequest'] != null ? new CallRequest.fromJson(json['callRequest']) : CallRequest();
assetType = json['assetType'];
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee();
visitDate = json['visitDate'];
if (json['assistantEmployees'] != null) {
assistantEmployees = json['assistantEmployees'];
}
supplier = json['supplier'];
vendorTicketNumber = json['vendorTicketNumber'];
if (json['contactPersonWorkOrders'] != null) {
contactPersonWorkOrders = json['contactPersonWorkOrders'];
}
calllastSituation = json['calllastSituation'] != null ? new Lookup.fromJson(json['calllastSituation']) : Lookup();
currentSituation = json['currentSituation'] != null ? new Lookup.fromJson(json['currentSituation']) : Lookup();
repairLocation = json['repairLocation'];
reason = json['reason'];
startofWorkTime = json['startofWorkTime'];
endofWorkTime = json['endofWorkTime'];
workingHours = json['workingHours'];
travelingHours = json['travelingHours'];
travelingExpenses = json['travelingExpenses'];
faultDescription = json['faultDescription'] != null ? new ModelDefRelatedDefects.fromJson(json['faultDescription']) : ModelDefRelatedDefects();
if (json['sparePartsWorkOrders'] != null) {
sparePartsWorkOrders = json['sparePartsWorkOrders'];
}
reviewComment = json['reviewComment'];
comment = json['comment'];
attachmentsWorkOrder = json['attachmentsWorkOrder'];
equipmentStatus = json['equipmentStatus'];
if (json['suppEngineerWorkOrders'] != null) {
suppEngineerWorkOrders = json['suppEngineerWorkOrders'];
}
engSignature = json['engSignature'];
nurseSignature = json['nurseSignature'];
woParentDto = json['woParentDto'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['parentWOId'] = this.parentWOId;
data['workOrderNo'] = this.workOrderNo;
data['workOrderYear'] = this.workOrderYear;
data['workOrderSequennce'] = this.workOrderSequennce;
if (this.callRequest != null) {
data['callRequest'] = this.callRequest.toJson();
}
data['assetType'] = this.assetType;
if (this.assignedEmployee != null) {
data['assignedEmployee'] = this.assignedEmployee.toJson();
}
data['visitDate'] = this.visitDate;
if (this.assistantEmployees != null) {
data['assistantEmployees'] = this.assistantEmployees.map((v) => v.toJson()).toList();
}
data['supplier'] = this.supplier;
data['vendorTicketNumber'] = this.vendorTicketNumber;
if (this.contactPersonWorkOrders != null) {
data['contactPersonWorkOrders'] = this.contactPersonWorkOrders.map((v) => v.toJson()).toList();
}
if (this.calllastSituation != null) {
data['calllastSituation'] = this.calllastSituation.toMap();
}
if (this.currentSituation != null) {
data['currentSituation'] = this.currentSituation.toMap();
}
data['repairLocation'] = this.repairLocation;
data['reason'] = this.reason;
data['startofWorkTime'] = this.startofWorkTime;
data['endofWorkTime'] = this.endofWorkTime;
data['workingHours'] = this.workingHours;
data['travelingHours'] = this.travelingHours;
data['travelingExpenses'] = this.travelingExpenses;
if (this.faultDescription != null) {
data['faultDescription'] = this.faultDescription.toJson();
}
if (this.sparePartsWorkOrders != null) {
data['sparePartsWorkOrders'] = this.sparePartsWorkOrders.map((v) => v.toJson()).toList();
}
data['reviewComment'] = this.reviewComment;
data['comment'] = this.comment;
data['attachmentsWorkOrder'] = this.attachmentsWorkOrder;
data['equipmentStatus'] = this.equipmentStatus;
if (this.suppEngineerWorkOrders != null) {
data['suppEngineerWorkOrders'] = this.suppEngineerWorkOrders.map((v) => v.toJson()).toList();
}
data['engSignature'] = this.engSignature;
data['nurseSignature'] = this.nurseSignature;
data['woParentDto'] = this.woParentDto;
return data;
}
}
class CallRequest {
int id;
String callNo;
Asset asset;
AssignedEmployee assignedEmployee;
List callSiteContactPerson;
Lookup status;
Lookup callLastSituation;
String defectType;
String firstAction;
String assetType;
CallRequest({this.id, this.callNo, this.asset, this.assignedEmployee, this.callSiteContactPerson, this.status, this.callLastSituation, this.defectType, this.firstAction, this.assetType});
CallRequest.fromJson(Map<String, dynamic> json) {
id = json['id'];
callNo = json['callNo'];
asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : Asset();
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee();
if (json['callSiteContactPerson'] != null) {
callSiteContactPerson = json['callSiteContactPerson'];
}
status = json['status'] != null ? new Lookup.fromJson(json['status']) : Lookup();
callLastSituation = json['callLastSituation'] != null ? new Lookup.fromJson(json['callLastSituation']) : Lookup();
defectType = json['defectType'];
firstAction = json['firstAction'];
assetType = json['assetType'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['callNo'] = this.callNo;
if (this.asset != null) {
data['asset'] = this.asset.toJson();
}
if (this.assignedEmployee != null) {
data['assignedEmployee'] = this.assignedEmployee.toJson();
}
if (this.callSiteContactPerson != null) {
data['callSiteContactPerson'] = this.callSiteContactPerson.map((v) => v.toJson()).toList();
}
if (this.status != null) {
data['status'] = this.status.toMap();
}
if (this.callLastSituation != null) {
data['callLastSituation'] = this.callLastSituation.toMap();
}
data['defectType'] = this.defectType;
data['firstAction'] = this.firstAction;
data['assetType'] = this.assetType;
return data;
}
}
class Asset {
int id;
String assetSerialNo;
String systemID;
String assetNumber;
ModelDefinition modelDefinition;
String supplier;
String ipAddress;
String macAddress;
String portNumber;
String assetReplace;
String oldAsset;
String isParent;
String parentAsset;
String assetType;
Site site;
String building;
String floor;
String department;
String room;
String testsDay;
String purchasingPrice;
String nbv;
String currency;
String poNo;
String invoiceNumber;
String invoiceDate;
String replacementDate;
String originDepartment;
Site originSite;
String budgetYear;
String lastPOPrice;
String commissioningStatus;
String productionDate;
String edd;
String technicalInspectionDate;
String deliveryInspectionDate;
String endUserAcceptanceDate;
String receivingCommittee;
String siteWarrantyMonths;
String extendedWarrantyMonths;
String remainderWarrantyMonths;
String eomWarrantyMonthsNo;
String warrantyValue;
String warrantyEndDate;
String warrantyContractConditions;
List technicalGuidanceBooks;
String comment;
String tagCode;
Asset(
{this.id,
this.assetSerialNo,
this.systemID,
this.assetNumber,
this.modelDefinition,
this.supplier,
this.ipAddress,
this.macAddress,
this.portNumber,
this.assetReplace,
this.oldAsset,
this.isParent,
this.parentAsset,
this.assetType,
this.site,
this.building,
this.floor,
this.department,
this.room,
this.testsDay,
this.purchasingPrice,
this.nbv,
this.currency,
this.poNo,
this.invoiceNumber,
this.invoiceDate,
this.replacementDate,
this.originDepartment,
this.originSite,
this.budgetYear,
this.lastPOPrice,
this.commissioningStatus,
this.productionDate,
this.edd,
this.technicalInspectionDate,
this.deliveryInspectionDate,
this.endUserAcceptanceDate,
this.receivingCommittee,
this.siteWarrantyMonths,
this.extendedWarrantyMonths,
this.remainderWarrantyMonths,
this.eomWarrantyMonthsNo,
this.warrantyValue,
this.warrantyEndDate,
this.warrantyContractConditions,
this.technicalGuidanceBooks,
this.comment,
this.tagCode});
Asset.fromJson(Map<String, dynamic> json) {
id = json['id'];
assetSerialNo = json['assetSerialNo'];
systemID = json['systemID'];
assetNumber = json['assetNumber'];
modelDefinition = json['modelDefinition'] != null ? new ModelDefinition.fromJson(json['modelDefinition']) : ModelDefinition();
supplier = json['supplier'];
ipAddress = json['ipAddress'];
macAddress = json['macAddress'];
portNumber = json['portNumber'];
assetReplace = json['assetReplace'];
oldAsset = json['oldAsset'];
isParent = json['isParent'];
parentAsset = json['parentAsset'];
assetType = json['assetType'];
site = json['site'] != null ? new Site.fromJson(json['site']) : Site();
building = json['building'];
floor = json['floor'];
department = json['department'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['assetSerialNo'] = this.assetSerialNo;
data['systemID'] = this.systemID;
data['assetNumber'] = this.assetNumber;
if (this.modelDefinition != null) {
data['modelDefinition'] = this.modelDefinition.toJson();
}
data['supplier'] = this.supplier;
data['ipAddress'] = this.ipAddress;
data['macAddress'] = this.macAddress;
data['portNumber'] = this.portNumber;
data['assetReplace'] = this.assetReplace;
data['oldAsset'] = this.oldAsset;
data['isParent'] = this.isParent;
data['parentAsset'] = this.parentAsset;
data['assetType'] = this.assetType;
if (this.site != null) {
data['site'] = this.site.toJson();
}
data['building'] = this.building;
data['floor'] = this.floor;
data['department'] = this.department;
data['room'] = this.room;
data['testsDay'] = this.testsDay;
data['purchasingPrice'] = this.purchasingPrice;
data['nbv'] = this.nbv;
data['currency'] = this.currency;
data['poNo'] = this.poNo;
data['invoiceNumber'] = this.invoiceNumber;
data['invoiceDate'] = this.invoiceDate;
data['replacementDate'] = this.replacementDate;
data['originDepartment'] = this.originDepartment;
if (this.originSite != null) {
data['originSite'] = this.originSite.toJson();
}
data['budgetYear'] = this.budgetYear;
data['lastPOPrice'] = this.lastPOPrice;
data['commissioningStatus'] = this.commissioningStatus;
data['productionDate'] = this.productionDate;
data['edd'] = this.edd;
data['technicalInspectionDate'] = this.technicalInspectionDate;
data['deliveryInspectionDate'] = this.deliveryInspectionDate;
data['endUserAcceptanceDate'] = this.endUserAcceptanceDate;
data['receivingCommittee'] = this.receivingCommittee;
data['siteWarrantyMonths'] = this.siteWarrantyMonths;
data['extendedWarrantyMonths'] = this.extendedWarrantyMonths;
data['remainderWarrantyMonths'] = this.remainderWarrantyMonths;
data['eomWarrantyMonthsNo'] = this.eomWarrantyMonthsNo;
data['warrantyValue'] = this.warrantyValue;
data['warrantyEndDate'] = this.warrantyEndDate;
data['warrantyContractConditions'] = this.warrantyContractConditions;
if (this.technicalGuidanceBooks != null) {
data['technicalGuidanceBooks'] = this.technicalGuidanceBooks.map((v) => v.toJson()).toList();
}
data['comment'] = this.comment;
data['tagCode'] = this.tagCode;
return data;
}
}
class ModelDefinition {
int id;
String assetName;
String modelDefCode;
String modelName;
int manufacturerId;
String manufacturerName;
String supplierName;
String replacementDate;
int lifeSpan;
List<ModelDefRelatedDefects> modelDefRelatedDefects;
List suppliers;
ModelDefinition(
{this.id,
this.assetName,
this.modelDefCode,
this.modelName,
this.manufacturerId,
this.manufacturerName,
this.supplierName,
this.replacementDate,
this.lifeSpan,
this.modelDefRelatedDefects,
this.suppliers});
ModelDefinition.fromJson(Map<String, dynamic> json) {
id = json['id'];
assetName = json['assetName'];
modelDefCode = json['modelDefCode'];
modelName = json['modelName'];
manufacturerId = json['manufacturerId'];
manufacturerName = json['manufacturerName'];
supplierName = json['supplierName'];
replacementDate = json['replacementDate'];
lifeSpan = json['lifeSpan'];
if (json['modelDefRelatedDefects'] != null) {
modelDefRelatedDefects = <ModelDefRelatedDefects>[];
json['modelDefRelatedDefects'].forEach((v) {
modelDefRelatedDefects.add(new ModelDefRelatedDefects.fromJson(v));
});
}
if (json['suppliers'] != null) {
suppliers = json['suppliers'];
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['assetName'] = this.assetName;
data['modelDefCode'] = this.modelDefCode;
data['modelName'] = this.modelName;
data['manufacturerId'] = this.manufacturerId;
data['manufacturerName'] = this.manufacturerName;
data['supplierName'] = this.supplierName;
data['replacementDate'] = this.replacementDate;
data['lifeSpan'] = this.lifeSpan;
if (this.modelDefRelatedDefects != null) {
data['modelDefRelatedDefects'] = this.modelDefRelatedDefects.map((v) => v.toJson()).toList();
}
if (this.suppliers != null) {
data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList();
}
return data;
}
}
class ModelDefRelatedDefects {
int id;
String defectName;
String workPerformed;
String estimatedTime;
ModelDefRelatedDefects({this.id, this.defectName, this.workPerformed, this.estimatedTime});
ModelDefRelatedDefects.fromJson(Map<String, dynamic> json) {
id = json['id'];
defectName = json['defectName'];
workPerformed = json['workPerformed'];
estimatedTime = json['estimatedTime'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['defectName'] = this.defectName;
data['workPerformed'] = this.workPerformed;
data['estimatedTime'] = this.estimatedTime;
return data;
}
}
class Site {
int id;
int customerCode;
String custName;
List buildings;
Site({this.id, this.customerCode, this.custName, this.buildings});
Site.fromJson(Map<String, dynamic> json) {
id = json['id'];
customerCode = json['customerCode'];
custName = json['custName'];
if (json['buildings'] != null) {
buildings = json['buildings'];
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['customerCode'] = this.customerCode;
data['custName'] = this.custName;
if (this.buildings != null) {
data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
}
return data;
}
}
class AssignedEmployee {
String id;
String name;
AssignedEmployee({this.id, this.name});
AssignedEmployee.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}

@ -1,7 +1,7 @@
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
class ServiceRequestSearch{
class ServiceRequestSearch {
String deviceSerialNumber;
String deviceNumber;
String deviceName;
@ -9,7 +9,6 @@ class ServiceRequestSearch{
String model;
Lookup statusValue;
ServiceRequestSearch({
this.deviceSerialNumber,
this.deviceNumber,
@ -19,7 +18,7 @@ class ServiceRequestSearch{
this.hospital,
});
fromSearch(ServiceRequestSearch newSearch){
fromSearch(ServiceRequestSearch newSearch) {
deviceSerialNumber = newSearch.deviceSerialNumber;
deviceNumber = newSearch.deviceNumber;
statusValue = newSearch.statusValue;
@ -27,30 +26,29 @@ class ServiceRequestSearch{
model = newSearch.model;
}
Map<String,dynamic> toMap(){
Map<String,dynamic> search = {};
if(deviceSerialNumber != null && deviceSerialNumber.isNotEmpty){
Map<String, dynamic> toMap() {
Map<String, dynamic> search = {};
if (deviceSerialNumber != null && deviceSerialNumber.isNotEmpty) {
search["assetSerialNumber"] = deviceSerialNumber;
}
if(deviceNumber != null && deviceNumber.isNotEmpty){
if (deviceNumber != null && deviceNumber.isNotEmpty) {
search["assetNo"] = deviceNumber;
}
if(statusValue != null){
if (statusValue != null) {
search["status"] = statusValue.toMap();
}
if(deviceName != null && deviceName.isNotEmpty){
if (deviceName != null && deviceName.isNotEmpty) {
search["assetName"] = deviceName;
}
if(hospital != null){
if (hospital != null) {
search["site"] = hospital.name;
}
if(model != null){
if (model != null) {
search["modelDefinition"] = model;
}
return search;

@ -209,6 +209,13 @@ class Subtitle {
String partNumber;
String number;
String quantity;
String orderWorkNumber;
String assignedEmployee;
String assetSN;
String assetName;
String site;
String maintenanceSituation;
String currentSituation;
// all
String duplicateRequest;
@ -413,6 +420,13 @@ class Subtitle {
@required this.duplicateAlert,
@required this.duplicateAlertMessage,
@required this.duplicateRequest,
@required this.orderWorkNumber,
@required this.assignedEmployee,
@required this.assetSN,
@required this.assetName,
@required this.site,
@required this.maintenanceSituation,
@required this.currentSituation,
@required this.repairLocation,
@required this.travelingExpense,
@required this.startDate,
@ -602,6 +616,13 @@ class Subtitle {
duplicateAlert: parsedJson["duplicateAlert"],
duplicateAlertMessage: parsedJson["duplicateAlertMessage"],
duplicateRequest: parsedJson["duplicateRequest"],
orderWorkNumber: parsedJson["orderWorkNumber"],
assignedEmployee: parsedJson["assignedEmployee"],
assetSN: parsedJson["assetSN"],
assetName: parsedJson["assetName"],
site: parsedJson["site"],
maintenanceSituation: parsedJson["maintenanceSituation"],
currentSituation: parsedJson["currentSituation"],
repairLocation: parsedJson["repairLocation"],
travelingExpense: parsedJson["travelingExpense"],
startDate: parsedJson["startDate"],

@ -3,5 +3,5 @@ class TimerModel {
DateTime endAt;
int durationInSecond;
TimerModel({this.startAt,this.endAt,this.durationInSecond});
TimerModel({this.startAt, this.endAt, this.durationInSecond});
}

@ -76,7 +76,7 @@ class User {
}
UsersTypes get type {
switch (userRoles.first.name) {
switch (userRoles?.first?.name) {
case "Engineer":
return UsersTypes.engineer;
case "Hospital":

@ -1,7 +1,7 @@
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/pantry/pentry.dart';
class Visit{
class Visit {
int id;
String serialNumber;
String expectDate;
@ -44,36 +44,35 @@ class Visit{
this.deviceNumber,
});
factory Visit.fromJson(Map<String,dynamic> parsedJson){
factory Visit.fromJson(Map<String, dynamic> parsedJson) {
List<String> images = [];
if(parsedJson["vAttachments"] is List){
if (parsedJson["vAttachments"] is List) {
List list = parsedJson["vAttachments"];
images = list.map((e) => e["attachmentURL"].toString()).toList();
}
return Visit(
id: parsedJson["id"],
serialNumber: parsedJson["visitCode"],
ppmScheduleId: parsedJson["ppmScheduleId"],
hospitalId: parsedJson["siteId"],
deviceNumber: parsedJson["assetNumber"],
hospitalName: parsedJson["siteName"],
deviceId: parsedJson["assetId"],
deviceSerialNumber: parsedJson["assetSerialNo"],
deviceEnglishName: parsedJson["assetName"],
deviceArabicName: parsedJson["assetName"],
employId: parsedJson["assignedToId"].toString(),
employName: parsedJson["assignedToName"],
expectDate: parsedJson["expectedDate"].toString().split("T").first,
actualDate: parsedJson["actualDate"].toString().split("T").first,
modelAndBrand: "${parsedJson["modelName"]} / ${parsedJson["manufacturerName"]}",
// contactStatus: parsedJson["contactStatus"],
images: images,
status: Lookup(
id: parsedJson["visitStatusId"], // actual value (0,1,2)
name: parsedJson["visitStatusName"] // text value
),
assignTo: parsedJson["assignedToName"],
pentry: Pentry.fromMap(parsedJson)
);
id: parsedJson["id"],
serialNumber: parsedJson["visitCode"],
ppmScheduleId: parsedJson["ppmScheduleId"],
hospitalId: parsedJson["siteId"],
deviceNumber: parsedJson["assetNumber"],
hospitalName: parsedJson["siteName"],
deviceId: parsedJson["assetId"],
deviceSerialNumber: parsedJson["assetSerialNo"],
deviceEnglishName: parsedJson["assetName"],
deviceArabicName: parsedJson["assetName"],
employId: parsedJson["assignedToId"].toString(),
employName: parsedJson["assignedToName"],
expectDate: parsedJson["expectedDate"].toString().split("T").first,
actualDate: parsedJson["actualDate"].toString().split("T").first,
modelAndBrand: "${parsedJson["modelName"]} / ${parsedJson["manufacturerName"]}",
// contactStatus: parsedJson["contactStatus"],
images: images,
status: Lookup(
id: parsedJson["visitStatusId"], // actual value (0,1,2)
name: parsedJson["visitStatusName"] // text value
),
assignTo: parsedJson["assignedToName"],
pentry: Pentry.fromMap(parsedJson));
}
}

@ -1,8 +1,7 @@
import 'package:test_sa/models/engineer.dart';
import 'package:test_sa/models/visits/visit.dart';
class VisitsGroup{
class VisitsGroup {
// String userId;
// String workingHours;
// String travelingHours;
@ -21,14 +20,14 @@ class VisitsGroup{
// this.jobSheetNumber,
// this.travelingHours,
// this.workingHours,
this.visits,
this.engineer,
this.visits,
this.engineer,
// this.image,
// this.taskStatus,
});
Map<String,dynamic> toJson(){
Map<String,dynamic> jsonObject = {};
Map<String, dynamic> toJson() {
Map<String, dynamic> jsonObject = {};
jsonObject["ids"] = visits.map((e) => e.id).toList();
jsonObject["assignedEmployeeId"] = engineer?.id;
// if(status != null) jsonObject["taskStatusId"] = status.id.toString();
@ -43,6 +42,4 @@ class VisitsGroup{
// if(taskStatus != null) jsonObject["task_status"] = taskStatus.id.toString();
return jsonObject;
}
}

@ -1,7 +1,7 @@
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
class VisitsSearch{
class VisitsSearch {
String deviceSerialNumber;
Hospital hospital;
String brand;
@ -26,7 +26,7 @@ class VisitsSearch{
this.expectedDateTo,
});
fromSearch(VisitsSearch newSearch){
fromSearch(VisitsSearch newSearch) {
deviceSerialNumber = newSearch.deviceSerialNumber;
brand = newSearch.brand;
hospital = newSearch.hospital;
@ -39,49 +39,48 @@ class VisitsSearch{
statusValue = newSearch.statusValue;
}
Map<String,dynamic> toMap(){
Map<String,dynamic> _search = {};
if(deviceSerialNumber != null && deviceSerialNumber.isNotEmpty){
_search["assetId"]= deviceSerialNumber;
Map<String, dynamic> toMap() {
Map<String, dynamic> _search = {};
if (deviceSerialNumber != null && deviceSerialNumber.isNotEmpty) {
_search["assetId"] = deviceSerialNumber;
}
if(hospital != null){
_search["siteId"]= hospital.id;
if (hospital != null) {
_search["siteId"] = hospital.id;
}
if(brand != null && brand.isNotEmpty){
if (brand != null && brand.isNotEmpty) {
// todo get new key
_search[""]= brand;
_search[""] = brand;
}
if(model != null){
_search["modelId"]= model.id;
if (model != null) {
_search["modelId"] = model.id;
}
if(expectedDateFrom != null){
_search["expectedDateFrom"]= expectedDateFrom.toIso8601String();
if (expectedDateFrom != null) {
_search["expectedDateFrom"] = expectedDateFrom.toIso8601String();
}
if(expectedDateTo != null){
_search["expectedDateTo"]= expectedDateTo.toIso8601String();
if (expectedDateTo != null) {
_search["expectedDateTo"] = expectedDateTo.toIso8601String();
}
if(actualDateFrom != null){
_search["actualDateFrom"]= actualDateFrom.toIso8601String();
if (actualDateFrom != null) {
_search["actualDateFrom"] = actualDateFrom.toIso8601String();
}
if(actualDateTo != null){
_search["actualDateTo"]= actualDateTo.toIso8601String();
if (actualDateTo != null) {
_search["actualDateTo"] = actualDateTo.toIso8601String();
}
if(statusValue != null){
_search["visitStatusId"]= statusValue.id;
if (statusValue != null) {
_search["visitStatusId"] = statusValue.id;
}
if(contactStatus != null){
_search["assignedToId"]= contactStatus.id;
if (contactStatus != null) {
_search["assignedToId"] = contactStatus.id;
}
return _search;
}
}

@ -1,40 +1,49 @@
import 'package:flutter/material.dart';
class AColors {
AColors._();
static const Color white = Color(0xffffffff);
static const Color black = Color(0xff000000);
static const Color grey3A = Color(0xff2e303a);
static const Color grey = Color(0xffe1e7e7);
static const green = Colors.green;
static const Color orange = Colors.orange;
static const Color deepOrange = Colors.deepOrangeAccent;
static const Color red = Colors.red;
static const Color deepRed = Color(0xFFD32F2F);
static const Color white = Color(0xffffffff);
static const Color black = Color(0xff000000);
static const Color grey3A = Color(0xff2e303a);
static const Color grey = Color(0xffe1e7e7);
static const green = Colors.green;
static const Color orange = Colors.orange;
static const Color deepOrange = Colors.deepOrangeAccent;
static const Color red = Colors.red;
static const Color deepRed = Color(0xFFD32F2F);
static const Color scaffoldBackgroundColor = Color(0xffffffff);
static const Color secondaryColor = Color(0xff111427);
static const Color primaryColor = Color(0xff5bb0da);
static const Color cyan = Color(0xff4A8DB7);
static const Color onPrimaryColor = Color(0xffffffff);
static const Color secondaryColor = Color(0xff111427);
static const Color primaryColor = Color(0xff5bb0da);
static const Color cyan = Color(0xff4A8DB7);
static const Color onPrimaryColor = Color(0xffffffff);
static Color inputFieldBackgroundColor = Color(0xfff5f5f5);
static Color greyEF = Color(0xffEFEFEF);
static Color getRequestStatusColor(int id){
switch(id){
case 4: return AColors.deepRed;
case 6: return AColors.green;
case 5: return AColors.orange;
case 8: return AColors.green;
case 9: return AColors.orange;
default : return AColors.grey;
static Color getRequestStatusColor(int id) {
switch (id) {
case 4:
return AColors.deepRed;
case 6:
return AColors.green;
case 5:
return AColors.orange;
case 8:
return AColors.green;
case 9:
return AColors.orange;
default:
return AColors.grey;
}
}
static Color getGasStatusColor(int id){
switch(id){
case 0: return AColors.orange;
case 1: return AColors.green;
default : return AColors.grey;
static Color getGasStatusColor(int id) {
switch (id) {
case 0:
return AColors.orange;
case 1:
return AColors.green;
default:
return AColors.grey;
}
}
}

@ -1,39 +1,31 @@
import 'package:flutter/material.dart';
class AppStyle {
AppStyle._();
static const double borderRadius = 10;
static const BoxShadow boxShadow = BoxShadow(
color: Colors.black26,
blurRadius: 3,
offset: Offset(0,2)
);
static const BoxShadow boxShadow = BoxShadow(color: Colors.black26, blurRadius: 3, offset: Offset(0, 2));
static double getBorderRadius(BuildContext context){
static double getBorderRadius(BuildContext context) {
return borderRadius * getScaleFactor(context);
}
static double getScaleFactor(BuildContext context){
static double getScaleFactor(BuildContext context) {
return MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.width/(360) > 1.5
? 1.5 : MediaQuery.of(context).size.width/(360)
: MediaQuery.of(context).size.height/(360) > 1.5
? 1.5 : MediaQuery.of(context).size.height/(360);
? MediaQuery.of(context).size.width / (360) > 1.5
? 1.5
: MediaQuery.of(context).size.width / (360)
: MediaQuery.of(context).size.height / (360) > 1.5
? 1.5
: MediaQuery.of(context).size.height / (360);
}
static BorderRadius getCardBorder(BuildContext context){
static BorderRadius getCardBorder(BuildContext context) {
return BorderRadius.only(
topRight: Radius.circular(
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
),
topLeft: Radius.circular(
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
),
bottomRight: Radius.circular(
AppStyle.borderRadius * AppStyle.getScaleFactor(context)
),
topRight: Radius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
topLeft: Radius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
bottomRight: Radius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
);
}
}

@ -25,7 +25,6 @@ class DeviceTransferDetails extends StatefulWidget {
}
class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
final DeviceTransferInfo _model = DeviceTransferInfo();
bool _isSender = false;
bool _isReceiver = false;
@ -39,8 +38,6 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
@override
void initState() {
super.initState();
}
@ -66,7 +63,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
children: [
Container(
color: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row(
children: [
const ABackButton(),
@ -74,10 +71,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
child: Center(
child: Text(
_subtitle.details,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
@ -87,7 +81,7 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.all(16*AppStyle.getScaleFactor(context)),
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -99,59 +93,52 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
title: _subtitle.device,
info: widget.model.device.serialNumber,
),
const SizedBox(height:8),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: Text(
"Sender",
style: Theme.of(context).textTheme.headline6
),
child: Text("Sender", style: Theme.of(context).textTheme.headline6),
),
if(_isSender || true)
if (_isSender || true)
ASmallButton(
text: _subtitle.edit,
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (_)=> UpdateDeviceTransfer(model: widget.model,isSender: true,)
)
);
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: widget.model,
isSender: true,
)));
},
),
],
),
const SizedBox(height:12),
const SizedBox(height: 12),
DeviceTransferInfoSection(
info: widget.model.sender,
),
const SizedBox(height:8),
const SizedBox(height: 8),
Row(
children: [
Expanded(
child: Text(
"Receiver",
style: Theme.of(context).textTheme.headline6
),
),
if(_isReceiver || true)
ASmallButton(
text: _subtitle.edit,
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (_)=> UpdateDeviceTransfer(model: widget.model,isSender: false,)
)
);
},
child: Text("Receiver", style: Theme.of(context).textTheme.headline6),
),
if (_isReceiver || true)
ASmallButton(
text: _subtitle.edit,
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: widget.model,
isSender: false,
)));
},
),
],
),
const SizedBox(height:12),
const SizedBox(height: 12),
DeviceTransferInfoSection(
info: widget.model.receiver,
),
],
),
),

@ -9,6 +9,7 @@ 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/device_trancfer/device_transfer_list.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class TrackDeviceTransferPage extends StatefulWidget {
static const String id = "/track-device-transfer";
@ -18,8 +19,7 @@ class TrackDeviceTransferPage extends StatefulWidget {
State<TrackDeviceTransferPage> createState() => _TrackDeviceTransferPageState();
}
class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage>
with TickerProviderStateMixin{
class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage> with TickerProviderStateMixin {
DeviceTransferProvider _deviceTransferProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -48,8 +48,8 @@ class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage>
Column(
children: [
Container(
color:AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
@ -59,17 +59,15 @@ class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage>
child: Center(
child: Text(
"Device Transfer",
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
const SizedBox(width: 48,)
const SizedBox(
width: 48,
)
],
),
],
),
),

@ -21,6 +21,7 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget {
final GasRefillModel model;
const GasRefillDetails({Key key, this.model}) : super(key: key);
@ -30,7 +31,6 @@ class GasRefillDetails extends StatefulWidget {
}
class _GasRefillDetailsState extends State<GasRefillDetails> {
final GasRefillModel _model = GasRefillModel();
bool _enableEdit = false;
bool _validate = false;
@ -43,39 +43,29 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async {
_validate = true;
if(!_formKey.currentState.validate()){
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _gasRefillProvider.updateModel(
user: _userProvider.user,
host: _settingProvider.host,
newModel: _model,
oldModel: widget.model
);
_isLoading =false;
int status = await _gasRefillProvider.updateModel(user: _userProvider.user, host: _settingProvider.host, newModel: _model, oldModel: widget.model);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
);
_enableEdit = false;
_validate = false;
//Navigator.of(context).pop();
}else{
String errorMessage = HttpStatusManger.getStatusMessage(
status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
errorMessage
),
)
);
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
@ -105,7 +95,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
children: [
Container(
color: Theme.of(context).colorScheme.primary,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row(
children: [
const ABackButton(),
@ -113,32 +103,31 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
child: Center(
child: Text(
_subtitle.details,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
if(_userProvider.user.type == UsersTypes.engineer)
AIconButton(
iconData: _enableEdit ? Icons.cancel : Icons.edit,
color: Theme.of(context).colorScheme.onPrimary,
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: () async {
_enableEdit = !_enableEdit;
_model.fromGasRefillModel(widget.model);
setState(() {});
},
),
const SizedBox(width: 16,)
if (_userProvider.user.type == UsersTypes.engineer)
AIconButton(
iconData: _enableEdit ? Icons.cancel : Icons.edit,
color: Theme.of(context).colorScheme.onPrimary,
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: () async {
_enableEdit = !_enableEdit;
_model.fromGasRefillModel(widget.model);
setState(() {});
},
),
const SizedBox(
width: 16,
)
],
),
),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.all(16*AppStyle.getScaleFactor(context)),
padding: EdgeInsets.all(16 * AppStyle.getScaleFactor(context)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -150,64 +139,73 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
title: _subtitle.hospital,
info: _model.clientName,
),
_enableEdit ?
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8,),
ASubTitle(_subtitle.status),
if(_validate && _model.status == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
const SizedBox(height: 4,),
GasStatusMenu(
initialValue: _model.status,
onSelect: (status){
_model.status = status;
},
)
],
):
Row(
children: [
Expanded(
child: Text(
"${_subtitle.status} : ",
style: Theme.of(context).textTheme.subtitle2,
textScaleFactor: AppStyle.getScaleFactor(context),
_enableEdit
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.status),
if (_validate && _model.status == null)
ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
GasStatusMenu(
initialValue: _model.status,
onSelect: (status) {
_model.status = status;
},
)
],
)
: Row(
children: [
Expanded(
child: Text(
"${_subtitle.status} : ",
style: Theme.of(context).textTheme.subtitle2,
textScaleFactor: AppStyle.getScaleFactor(context),
),
),
if (_model.status?.id != null) StatusLabel(label: _model.status.name, color: AColors.getGasStatusColor(_model.status.id)),
],
),
),
if(_model.status?.id != null)
StatusLabel(label: _model.status.name,
color: AColors.getGasStatusColor(_model.status.id)
),
],
const SizedBox(
height: 8,
),
const SizedBox(height: 8,),
const ASubTitle("Gas Requests"),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _model.details.length,
itemBuilder: (context,index){
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: _subtitle.update,
onPressed: _update,
),
],
),
}),
if (_enableEdit)
Column(
children: [
const SizedBox(
height: 16,
),
AButton(
text: _subtitle.update,
onPressed: _update,
),
],
),
],
),
),

@ -22,6 +22,7 @@ import 'package:test_sa/views/widgets/status/gas_refill/gas_type.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill";
const RequestGasRefill({Key key}) : super(key: key);
@ -45,16 +46,16 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
void setState(VoidCallback fn){
if(mounted) super.setState(() {});
void setState(VoidCallback fn) {
if (mounted) super.setState(() {});
}
_onSubmit() async {
if(_formModel.details.isEmpty){
if(!_addNewModel()) return;
if (_formModel.details.isEmpty) {
if (!_addNewModel()) return;
}
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _gasRefillProvider.createModel(
@ -62,40 +63,34 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
host: _settingProvider.host,
model: _formModel,
);
_isLoading =false;
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop();
}else{
String errorMessage = HttpStatusManger.getStatusMessage(
status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
errorMessage
),
)
);
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
}
bool _addNewModel(){
bool _addNewModel() {
_validate = true;
if(!_formKey.currentState.validate()){
if (!_formKey.currentState.validate()) {
setState(() {});
return false;
}
_formKey.currentState.save();
if(!_currentDetails.validate()) {
setState(() { });
if (!_currentDetails.validate()) {
setState(() {});
return false;
}
_formModel.details.insert(0,_currentDetails);
_formModel.details.insert(0, _currentDetails);
_validate = false;
Scrollable.ensureVisible(_DetailsKey.currentContext);
_requestedQuantityController.clear();
@ -109,12 +104,13 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
_requestedQuantityController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
_subtitle = AppLocalization.of(context).subtitle;
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
_gasRefillProvider = Provider.of<GasRefillProvider>(context,listen: false);
_gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false);
return Scaffold(
key: _scaffoldKey,
body: Form(
@ -135,11 +131,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
padding: const EdgeInsets.all(8.0),
child: Text(
"Request Gas Refill",
style: Theme.of(context).textTheme.headline5.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 28,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
@ -159,68 +151,101 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
// ),
// const SizedBox(height: 8,),
ASubTitle(_subtitle.status),
if(_validate && _formModel.status == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
const SizedBox(height: 4,),
GasStatusMenu(
initialValue: _formModel.status ?? const Lookup(
value: 1
if (_validate && _formModel.status == null)
ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
),
onSelect: (status){
const SizedBox(
height: 4,
),
GasStatusMenu(
initialValue: _formModel.status ?? const Lookup(value: 1),
onSelect: (status) {
_formModel.status = status;
},
),
const SizedBox(height: 8,),
Divider(color: Theme.of(context).colorScheme.primary,),
const SizedBox(height: 4,),
const SizedBox(
height: 8,
),
Divider(
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(
height: 4,
),
const ASubTitle("Type"),
if(_validate && _currentDetails.type == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
const SizedBox(height: 4,),
if (_validate && _currentDetails.type == null)
ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
GasTypeMenu(
initialValue: _currentDetails.type,
onSelect: (status){
onSelect: (status) {
_currentDetails.type = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Cylinder Size"),
if(_validate && _currentDetails.cylinderSize == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
const SizedBox(height: 4,),
if (_validate && _currentDetails.cylinderSize == null)
ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
GasCylinderSizeMenu(
initialValue: _currentDetails.cylinderSize,
onSelect: (status){
onSelect: (status) {
_currentDetails.cylinderSize = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Cylinder Type"),
if(_validate && _currentDetails.cylinderSize == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
const SizedBox(height: 4,),
if (_validate && _currentDetails.cylinderSize == null)
ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
),
const SizedBox(
height: 4,
),
GasCylinderTypesMenu(
initialValue: _currentDetails.cylinderType,
onSelect: (status){
onSelect: (status) {
_currentDetails.cylinderType = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.quantity),
if(_validate && _currentDetails.requestedQuantity == null)
ASubTitle(_subtitle.requiredWord,color: Colors.red,),
SizedBox(height: 4,),
if (_validate && _currentDetails.requestedQuantity == null)
ASubTitle(
_subtitle.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",
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
textInputType: TextInputType.number,
onSaved: (value){
onSaved: (value) {
_currentDetails.requestedQuantity = double.tryParse(value);
},
),
@ -229,30 +254,30 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
text: _subtitle.add,
onPressed: _addNewModel,
),
if(_formModel.details.isNotEmpty)
const ASubTitle("Gas Requests"),
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(
model: model,
onDelete: (){
_formModel.details.remove(model);
setState(() {});
},
);
}
),
key: _DetailsKey,
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: _formModel.details.length,
itemBuilder: (context, index) {
final model = _formModel.details[index];
return GasRefillCreateDetailsItem(
model: model,
onDelete: () {
_formModel.details.remove(model);
setState(() {});
},
);
}),
const SizedBox(height: 16),
AButton(
text: _subtitle.submit,
onPressed: _onSubmit,
),
const SizedBox(height: 100,)
const SizedBox(
height: 100,
)
],
),
),
@ -262,4 +287,3 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
);
}
}

@ -9,6 +9,7 @@ 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/loaders/loading_manager.dart';
class TrackGasRefillPage extends StatefulWidget {
static const String id = "/track-gas-refill";
@ -18,8 +19,7 @@ class TrackGasRefillPage extends StatefulWidget {
State<TrackGasRefillPage> createState() => _TrackGasRefillPageState();
}
class _TrackGasRefillPageState extends State<TrackGasRefillPage>
with TickerProviderStateMixin{
class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProviderStateMixin {
GasRefillProvider _gasRefillProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -48,8 +48,8 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage>
Column(
children: [
Container(
color:AColors.white,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
color: AColors.white,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
@ -59,17 +59,15 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage>
child: Center(
child: Text(
_subtitle.serviceRequests,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.grey3A,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic),
),
),
),
const SizedBox(width: 48,)
const SizedBox(
width: 48,
)
],
),
],
),
),
@ -87,7 +85,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage>
),
],
),
],
),
),

@ -6,6 +6,7 @@ import 'package:test_sa/views/pages/user/requests/future_request_service_details
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/notifications/notification_item.dart';
class NotificationsList extends StatelessWidget {
final List<AppNotification> notifications;
final bool nextPage;
@ -16,28 +17,26 @@ class NotificationsList extends StatelessWidget {
@override
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;
if(notifications.length == 0){
return NoItemFound(message: _subtitle.notificationsNotFound,);
if (notifications.length == 0) {
return NoItemFound(
message: _subtitle.notificationsNotFound,
);
}
return LazyLoading(
nextPage: nextPage,
onLazyLoad: onLazyLoad,
child: ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: notifications.length,
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 8),
itemBuilder: (context,itemIndex){
physics: BouncingScrollPhysics(),
itemCount: notifications.length,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
itemBuilder: (context, itemIndex) {
return NotificationItem(
notification: notifications[itemIndex],
onPressed: (notification){
Navigator.of(context).pushNamed(
FutureRequestServiceDetails.id,
arguments: notification.requestId
);
onPressed: (notification) {
Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId);
},
);
}
),
}),
);
}
}

@ -16,6 +16,7 @@ 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/issues/report_issue_item.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class ReportIssuesPage extends StatefulWidget {
static final String id = "/report-issue";
final ServiceRequest serviceRequest;
@ -64,22 +65,18 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
),
child: Text(
_subtitle.reportIssue,
style: Theme.of(context).textTheme.headline5.copyWith(
color: AColors.cyan,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontWeight: FontWeight.bold),
),
),
),
Image(
height: _height/8,
height: _height / 8,
image: AssetImage("assets/images/logo.png"),
),
Container(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
horizontal: 16,
vertical: 16,
),
decoration: BoxDecoration(
color: AColors.grey,
@ -90,10 +87,9 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
boxShadow: [
BoxShadow(
color: AColors.grey,
offset: Offset(0,-1),
offset: Offset(0, -1),
)
]
),
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -102,32 +98,30 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
hintText: _subtitle.title,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
validator: (value) =>
Validator.hasValue(value)
? null : _subtitle.titleValidateMessage,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.titleValidateMessage,
textInputType: TextInputType.name,
onSaved: (value){
onSaved: (value) {
_issue.title = value;
},
),
SizedBox(height: 8,),
Column(
children: List.generate(
_issues.length,
(index) => ReportIssueItem(
isSelected: _issue.reports.contains(index),
issueInfo: _issues[index],
onChange: (info,value){
if(value){
_issue.reports.add(index);
} else {
_issue.reports.remove(index);
}
setState(() {});
},
)
)
SizedBox(
height: 8,
),
Column(
children: List.generate(
_issues.length,
(index) => ReportIssueItem(
isSelected: _issue.reports.contains(index),
issueInfo: _issues[index],
onChange: (info, value) {
if (value) {
_issue.reports.add(index);
} else {
_issue.reports.remove(index);
}
setState(() {});
},
))),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
@ -139,7 +133,7 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
hintText: _subtitle.description,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.multiline,
onSaved: (value){
onSaved: (value) {
_issue.description = value;
},
),
@ -148,20 +142,19 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
child: AButton(
text: _subtitle.submit,
onPressed: () async {
if(!_formKey.currentState.validate())
return;
if (!_formKey.currentState.validate()) return;
_formKey.currentState.save();
_issue.serviceRequestId = widget.serviceRequest.id;
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _serviceRequestsProvider.createIssueReport(
user: _userProvider.user,
host: _settingProvider.host,
issue: _issue,
);
_isLoading =false;
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
);

@ -9,6 +9,7 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/pages/user/requests/request_details.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
class FutureRequestServiceDetails extends StatefulWidget {
static final String id = "/service-request-details";
@ -17,7 +18,6 @@ class FutureRequestServiceDetails extends StatefulWidget {
}
class _FutureRequestServiceDetailsState extends State<FutureRequestServiceDetails> {
UserProvider _userProvider;
SettingProvider _settingProvider;
@override
@ -28,19 +28,16 @@ class _FutureRequestServiceDetailsState extends State<FutureRequestServiceDetail
Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Scaffold(
body: FutureBuilder<ServiceRequest>(
future: ServiceRequestsProvider().getSingleServiceRequest(
requestId: requestId,
user: _userProvider.user,
host: _settingProvider.host,
subtitle: _subtitle
),
builder: (BuildContext context, AsyncSnapshot<ServiceRequest> snapshot){
if(snapshot.hasError)
future: ServiceRequestsProvider().getSingleServiceRequest(requestId: requestId, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle),
builder: (BuildContext context, AsyncSnapshot<ServiceRequest> snapshot) {
if (snapshot.hasError)
return FailedLoading(
message: snapshot.error.toString(),
onReload: (){setState(() {});},
onReload: () {
setState(() {});
},
);
if(snapshot.hasData){
if (snapshot.hasData) {
return RequestDetailsPage(
serviceRequest: snapshot.data,
);

@ -718,9 +718,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ),
// ],
// ),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
const ASubTitle("Nurse Signature"),
ESignature(
oldSignature: _serviceReport.signatureNurse,
@ -812,17 +810,13 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
text: _subtitle.submit,
onPressed: () async {
_validate = true;
print(1);
if (!_formKey.currentState.validate()) {
print(2);
setState(() {});
return;
}
print(3);
if (!_serviceReport.validate()) return;
print(4);
_formKey.currentState.save();
print(5);
_isLoading = true;
setState(() {});

@ -5,23 +5,25 @@ import 'package:test_sa/controllers/providers/api/service_requests_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/models/service_report.dart';
import 'package:test_sa/models/service_request/search_work_order.dart';
import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
import 'edit_service_report.dart';
class FutureServiceReport extends StatefulWidget {
final ServiceRequest request;
final SearchWorkOrders workOrder;
const FutureServiceReport({Key key, this.request}) : super(key: key);
const FutureServiceReport({Key key, this.request, this.workOrder}) : super(key: key);
@override
_FutureServiceReportState createState() => _FutureServiceReportState();
}
class _FutureServiceReportState extends State<FutureServiceReport> {
UserProvider _userProvider;
SettingProvider _settingProvider;
@override
@ -31,19 +33,16 @@ class _FutureServiceReportState extends State<FutureServiceReport> {
Subtitle _subtitle = AppLocalization.of(context).subtitle;
return Scaffold(
body: FutureBuilder<ServiceReport>(
future: ServiceRequestsProvider().getSingleServiceReport(
reportId: widget.request.reportID,
user: _userProvider.user,
host: _settingProvider.host,
subtitle: _subtitle
),
builder: (BuildContext context, AsyncSnapshot<ServiceReport> snapshot){
if(snapshot.hasError)
future: ServiceRequestsProvider().getSingleServiceReport(reportId: widget.workOrder.id, user: _userProvider.user, host: _settingProvider.host, subtitle: _subtitle),
builder: (BuildContext context, AsyncSnapshot<ServiceReport> snapshot) {
if (snapshot.hasError)
return FailedLoading(
message: snapshot.error.toString(),
onReload: (){setState(() {});},
onReload: () {
setState(() {});
},
);
if(snapshot.hasData){
if (snapshot.hasData) {
return EditServiceReport(
report: snapshot.data,
request: widget.request,

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
@ -5,12 +6,12 @@ import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/models/service_request/service_request.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/pages/user/requests/create_request.dart';
import 'package:test_sa/views/pages/user/requests/report/create_service_report.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
@ -19,9 +20,11 @@ import 'package:test_sa/views/widgets/images/images_list.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.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/service_request_update_dialog.dart';
import 'package:test_sa/views/widgets/sound/sound_player.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../models/service_request/search_work_order.dart';
import 'report/future_service_report.dart';
class RequestDetailsPage extends StatelessWidget {
@ -29,11 +32,13 @@ class RequestDetailsPage extends StatelessWidget {
final ServiceRequest serviceRequest;
const RequestDetailsPage({Key key, this.serviceRequest}) : super(key: key);
@override
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;
UserProvider _userProvider = Provider.of<UserProvider>(context);
SettingProvider _settingProvider = Provider.of<SettingProvider>(context);
List<SearchWorkOrders> workOrders = [];
ServiceRequestsProvider _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
return DefaultTabController(
length: 2,
@ -79,15 +84,13 @@ class RequestDetailsPage extends StatelessWidget {
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: () async {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => CreateRequestPage(serviceRequest: serviceRequest)),
);
// showModalBottomSheet(
// context: context,
// builder: (context) {
//
// // return ServiceRequestsUpdateDialog(request: serviceRequest,);
// });
showModalBottomSheet(
context: context,
builder: (context) {
return ServiceRequestsUpdateDialog(
request: serviceRequest,
);
});
// DateTime picked = await showDatePicker(
// context: context,
// initialDate: DateTime.now(),
@ -154,9 +157,7 @@ class RequestDetailsPage extends StatelessWidget {
),
),
),
SizedBox(
height: 8,
),
SizedBox(height: 8),
SizedBox(
height: 60 * AppStyle.getScaleFactor(context),
child: ImagesList(
@ -296,64 +297,117 @@ class RequestDetailsPage extends StatelessWidget {
// )
],
),
serviceRequest.viewReport
? ListView(
padding: EdgeInsets.symmetric(horizontal: 16),
children: [
RequestInfoRow(
title: _subtitle.faultDescription,
content: serviceRequest.faultDescription,
),
RequestInfoRow(
title: _subtitle.workPerformed,
content: serviceRequest.workPerformed,
),
RequestInfoRow(
title: _subtitle.visitDate,
info: serviceRequest.visitDate,
),
RequestInfoRow(
title: _subtitle.jobSheetNumber,
info: serviceRequest.jobSheetNumber,
),
_userProvider.user.type == UsersTypes.engineer && serviceRequest.reportID != null
? Padding(
padding: EdgeInsets.all(32),
child: AButton(
text: _subtitle.editServiceReport,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => FutureServiceReport(
request: serviceRequest,
)),
);
},
),
)
: SizedBox.shrink(),
],
)
: _userProvider.user.type == UsersTypes.engineer
? Center(
child: Padding(
padding: EdgeInsets.all(32),
child: AButton(
text: "Create Report",
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => CreateServiceReport(
request: serviceRequest,
)),
);
},
// workOrders.isEmpty ?
FutureBuilder(
future: _serviceRequestsProvider.searchWorkOrders(callId: serviceRequest.requestCode),
builder: (context, snap) {
workOrders = snap.data as List<SearchWorkOrders>;
if (snap.connectionState == ConnectionState.done && (snap.data?.length ?? 0) != 0) {
return ListView.separated(
padding: EdgeInsets.all(21),
itemCount: workOrders.length,
separatorBuilder: (czt, index) => 21.height,
itemBuilder: (context, index) {
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 ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
primary: itemColor.withOpacity(.7),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
),
),
)
: Center(
child: ASubTitle(_subtitle.noDateFound),
),
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
onPressed: () {
// onPressed(request);
},
child: Column(
children: [
RequestInfoRow(
title: _subtitle.callId,
content: serviceRequest.requestCode,
),
RequestInfoRow(
title: _subtitle.orderWorkNumber,
info: workOrders[index].workOrderNo.toString(),
),
RequestInfoRow(
title: _subtitle.visitDate,
info: workOrders[index].visitDate,
),
RequestInfoRow(title: _subtitle.assignedEmployee, info: workOrders[index].assignedEmployee.name),
RequestInfoRow(
title: _subtitle.assetSN,
info: workOrders[index].callRequest.asset.assetSerialNo,
),
RequestInfoRow(
title: _subtitle.assetName,
info: workOrders[index].callRequest.asset.modelDefinition.assetName,
),
RequestInfoRow(
title: _subtitle.model,
info: workOrders[index].callRequest.asset.modelDefinition.modelName,
),
RequestInfoRow(
title: _subtitle.site,
info: workOrders[index].callRequest.asset.site.custName,
),
RequestInfoRow(
title: _subtitle.maintenanceSituation,
info: workOrders[index].calllastSituation.name ?? '',
),
RequestInfoRow(
title: _subtitle.currentSituation,
info: workOrders[index].currentSituation.name ?? '',
),
_userProvider.user.type == UsersTypes.engineer && workOrders[index].workOrderNo != null
? Padding(
padding: EdgeInsets.all(32),
child: AButton(
text: _subtitle.editServiceReport,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => FutureServiceReport(
request: serviceRequest,
workOrder: workOrders[index],
)),
);
},
),
)
: SizedBox.shrink(),
],
),
);
},
);
} else {
return _userProvider.user.type == UsersTypes.engineer
? Center(
child: Padding(
padding: EdgeInsets.all(32),
child: AButton(
text: "Create Report",
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => CreateServiceReport(
request: serviceRequest,
)),
);
},
),
),
)
: Center(
child: ASubTitle(_subtitle.noDateFound),
);
}
},
)
],
),
),

@ -21,13 +21,13 @@ import 'package:test_sa/views/widgets/pentry/pentry_ppm_check_list_form.dart';
class EditPentry extends StatefulWidget {
final Pentry pentry;
final Visit visit;
const EditPentry({Key key,this.pentry, this.visit}) : super(key: key);
const EditPentry({Key key, this.pentry, this.visit}) : super(key: key);
@override
State<EditPentry> createState() => _EditPentryState();
}
class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateMixin{
class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateMixin {
bool _isLoading = false;
bool _validate = false;
Subtitle _subtitle;
@ -41,29 +41,24 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
_onSubmit() async {
_validate = true;
if(!_pentry.validate()) {
setState(() { });
if (!_pentry.validate()) {
setState(() {});
return;
}
_isLoading = true;
setState(() {});
int status = await _regularVisitsProvider.updatePentry(
user: _userProvider.user,
host: _settingProvider.host,
pentry: _pentry,
visit: widget.visit
);
_isLoading =false;
int status = await _regularVisitsProvider.updatePentry(user: _userProvider.user, host: _settingProvider.host, pentry: _pentry, visit: widget.visit);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop();
Navigator.of(context).pop();
}else{
} else {
// String errorMessage = HttpStatusManger.getStatusMessage(
// status: status, subtitle: _subtitle);
// Fluttertoast.showToast(
@ -75,9 +70,9 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
@override
void initState() {
_pentry = widget.pentry.copyWith();
if(_pentry.pmKits.isEmpty) _pentry.pmKits.add(PMKit());
if(_pentry.calibrationTools.isEmpty) _pentry.calibrationTools.add(CalibrationTool());
if(_pentry.ppmCheckLists.isEmpty) _pentry.ppmCheckLists.add(PPMCheckList());
if (_pentry.pmKits.isEmpty) _pentry.pmKits.add(PMKit());
if (_pentry.calibrationTools.isEmpty) _pentry.calibrationTools.add(CalibrationTool());
if (_pentry.ppmCheckLists.isEmpty) _pentry.ppmCheckLists.add(PPMCheckList());
_tabController = TabController(length: 4, vsync: this);
super.initState();
}
@ -98,96 +93,105 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
key: _scaffoldKey,
body: SafeArea(
child: LoadingManager(
isLoading: _isLoading,
isFailedLoading: false,
stateCode: 200,
onRefresh: () async {},
child: Column(
children: [
Material(
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index){
setState(() {});
},
tabs: const [
Tab(text: "PPM Check List",),
Tab(text: "Calibration Tools",),
Tab(text: "PK Kits",),
Tab(text: "Pentry",),
]),
),
),
Expanded(
child: Stack(
children: [
TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
PentryPPMCheckListForm(
models: _pentry.ppmCheckLists,
enableValidate: _validate,
),
PentryCalibrationToolForm(
models: _pentry.calibrationTools,
enableValidate: _validate,
),
PentryPMKitForm(
models: _pentry.pmKits,
enableValidate: _validate,
),
PentryInfoForm(
model: _pentry,
enableValidate: _validate,
)
isLoading: _isLoading,
isFailedLoading: false,
stateCode: 200,
onRefresh: () async {},
child: Column(
children: [
Material(
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index) {
setState(() {});
},
tabs: const [
Tab(
text: "PPM Check List",
),
Tab(
text: "Calibration Tools",
),
Tab(
text: "PK Kits",
),
Tab(
text: "Pentry",
),
]),
),
),
Expanded(
child: Stack(
children: [
TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
PentryPPMCheckListForm(
models: _pentry.ppmCheckLists,
enableValidate: _validate,
),
PentryCalibrationToolForm(
models: _pentry.calibrationTools,
enableValidate: _validate,
),
PentryPMKitForm(
models: _pentry.pmKits,
enableValidate: _validate,
),
PentryInfoForm(
model: _pentry,
enableValidate: _validate,
)
],
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
if (_tabController.index != 0)
ASmallButton(
text: _subtitle.back,
onPressed: () {
_tabController.animateTo(
_tabController.index - 1,
);
setState(() {});
},
),
const Spacer(),
if (_tabController.index != _tabController.length - 1)
ASmallButton(
text: _subtitle.next,
onPressed: () {
_tabController.animateTo(
_tabController.index + 1,
);
setState(() {});
},
),
if (_tabController.index == _tabController.length - 1)
ASmallButton(
text: _subtitle.update,
onPressed: _onSubmit,
),
],
),
),
)
],
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
if(_tabController.index != 0)
ASmallButton(
text: _subtitle.back,
onPressed: (){
_tabController.animateTo(_tabController.index - 1,);
setState(() {});
},
),
const Spacer(),
if(_tabController.index != _tabController.length -1)
ASmallButton(
text: _subtitle.next,
onPressed: (){
_tabController.animateTo(_tabController.index + 1,);
setState(() {});
},
),
if(_tabController.index == _tabController.length -1)
ASmallButton(
text: _subtitle.update,
onPressed: _onSubmit,
),
],
),
),
)
],
),
),
],
)
),
),
),
],
)),
),
);
}
}

@ -10,8 +10,8 @@ import 'package:test_sa/models/visits/visit.dart';
import 'package:test_sa/views/pages/user/visits/pantry/edit_pentry.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
class FutureEditPentry extends StatefulWidget {
class FutureEditPentry extends StatefulWidget {
final Visit visit;
const FutureEditPentry({Key key, this.visit}) : super(key: key);
@ -21,7 +21,6 @@ class FutureEditPentry extends StatefulWidget {
}
class _FutureEditPentryState extends State<FutureEditPentry> {
UserProvider _userProvider;
SettingProvider _settingProvider;
@override
@ -32,20 +31,17 @@ class _FutureEditPentryState extends State<FutureEditPentry> {
Subtitle subtitle = AppLocalization.of(context).subtitle;
return Scaffold(
body: FutureBuilder<Pentry>(
future: RegularVisitsProvider().getPently(
user: _userProvider.user,
host: _settingProvider.host,
id: widget.visit.id
),
builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot){
if(snapshot.hasError) {
future: RegularVisitsProvider().getPently(user: _userProvider.user, host: _settingProvider.host, id: widget.visit.id),
builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot) {
if (snapshot.hasError) {
return FailedLoading(
message: subtitle.failedToCompleteRequest,
onReload: (){setState(() {});},
onReload: () {
setState(() {});
},
);
}
if(snapshot.hasData){
if (snapshot.hasData) {
return EditPentry(
pentry: snapshot.data,
visit: widget.visit,

@ -18,14 +18,14 @@ import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/search/visits_search_bar.dart';
import 'package:test_sa/views/widgets/visits/visits_list.dart';
class PreventiveMaintenanceVisitsPage extends StatefulWidget {
static final String id = "/preventive-maintenance-visits";
@override
_PreventiveMaintenanceVisitsPageState createState() => _PreventiveMaintenanceVisitsPageState();
}
class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceVisitsPage>
with TickerProviderStateMixin{
class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceVisitsPage> with TickerProviderStateMixin {
PreventiveMaintenanceVisitsProvider _visitsProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -57,8 +57,8 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
Column(
children: [
Container(
color:AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
@ -68,10 +68,7 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
child: Center(
child: Text(
_subtitle.preventiveMaintenance,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
@ -84,27 +81,28 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
VisitsSearch _temp = await showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context){
builder: (context) {
return VisitsSearchDialog(
initialSearchValue: _visitsProvider.visitsSearch,
);
});
if(_temp != null){
if (_temp != null) {
_visitsProvider.visitsSearch = _temp;
_visitsProvider.reset();
setState(() {});
await _visitsProvider.getVisits(
user: _userProvider.user,
host: _settingProvider.host,
//visitsSearch: _visitsSearch
user: _userProvider.user,
host: _settingProvider.host,
//visitsSearch: _visitsSearch
);
}
},
),
SizedBox(width: 16,)
SizedBox(
width: 16,
)
],
),
],
),
),
@ -114,7 +112,7 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
padding: const EdgeInsets.all(8.0),
child: AButton(
text: _subtitle.clearSearch,
onPressed: (){
onPressed: () {
_visitsProvider.visitsSearch = VisitsSearch();
_visitsProvider.reset();
setState(() {});
@ -127,9 +125,9 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
nextPage: _visitsProvider.nextPage,
onLazyLoad: () async {
await _visitsProvider.getVisits(
user: _userProvider.user,
host: _settingProvider.host,
//visitsSearch: _visitsSearch
user: _userProvider.user,
host: _settingProvider.host,
//visitsSearch: _visitsSearch
);
},
onEditGroup: (visits) async {
@ -137,10 +135,13 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
isScrollControlled: true,
context: context,
builder: (context) {
return UpdateVisitsGroupSheet(visits: visits,title:_subtitle.updatePreventiveMaintenance,);
return UpdateVisitsGroupSheet(
visits: visits,
title: _subtitle.updatePreventiveMaintenance,
);
},
)as VisitsGroup;
if(_group != null){
) as VisitsGroup;
if (_group != null) {
showDialog<void>(
context: context,
barrierDismissible: false,
@ -151,24 +152,17 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
);
},
);
int status = await _visitsProvider.updateGroupOfVisits(
user: _userProvider.user,
host: _settingProvider.host,
group: _group
);
int status = await _visitsProvider.updateGroupOfVisits(user: _userProvider.user, host: _settingProvider.host, group: _group);
Navigator.of(context).pop();
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.preventiveMaintenanceUpdatedSuccessfully,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
}else{
} else {
Fluttertoast.showToast(
msg: HttpStatusManger.getStatusMessage(
status: status,
subtitle: _subtitle
),
msg: HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
@ -180,7 +174,6 @@ class _PreventiveMaintenanceVisitsPageState extends State<PreventiveMaintenanceV
),
],
),
],
),
),

@ -18,14 +18,14 @@ import 'package:test_sa/views/widgets/buttons/app_icon_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/search/visits_search_bar.dart';
import 'package:test_sa/views/widgets/visits/visits_list.dart';
class RegularVisitsPage extends StatefulWidget {
static final String id = "/Regular-visits";
@override
_RegularVisitsPageState createState() => _RegularVisitsPageState();
}
class _RegularVisitsPageState extends State<RegularVisitsPage>
with TickerProviderStateMixin{
class _RegularVisitsPageState extends State<RegularVisitsPage> with TickerProviderStateMixin {
RegularVisitsProvider _visitsProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -47,8 +47,8 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
_visitsProvider.reset();
//_visitsProvider.visitsSearch = VisitsSearch();
await _visitsProvider.getVisits(
user: _userProvider.user,
host: _settingProvider.host,
user: _userProvider.user,
host: _settingProvider.host,
);
},
child: Stack(
@ -56,8 +56,8 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
Column(
children: [
Container(
color:AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Column(
children: [
Row(
@ -67,10 +67,7 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
child: Center(
child: Text(
_subtitle.preventiveMaintenance,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
@ -78,7 +75,7 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
duration: Duration(milliseconds: 400),
child: AIconButton(
key: ValueKey(_expandedSearch),
iconData: _expandedSearch ? Icons.keyboard_arrow_up :Icons.search,
iconData: _expandedSearch ? Icons.keyboard_arrow_up : Icons.search,
color: AColors.secondaryColor,
buttonSize: 42,
backgroundColor: AColors.white,
@ -86,23 +83,24 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
VisitsSearch _temp = await showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context){
builder: (context) {
return VisitsSearchDialog(
initialSearchValue: _visitsProvider.visitsSearch,
);
});
if(_temp != null){
_visitsProvider.visitsSearch.fromSearch(_temp) ;
if (_temp != null) {
_visitsProvider.visitsSearch.fromSearch(_temp);
_visitsProvider.reset();
setState(() {});
}
},
),
),
SizedBox(width: 16,)
SizedBox(
width: 16,
)
],
),
],
),
),
@ -112,7 +110,7 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
padding: const EdgeInsets.all(8.0),
child: AButton(
text: _subtitle.clearSearch,
onPressed: (){
onPressed: () {
_visitsProvider.visitsSearch = VisitsSearch();
_visitsProvider.reset();
setState(() {});
@ -125,8 +123,8 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
nextPage: _visitsProvider.nextPage,
onLazyLoad: () async {
await _visitsProvider.getVisits(
user: _userProvider.user,
host: _settingProvider.host,
user: _userProvider.user,
host: _settingProvider.host,
);
},
onEditGroup: (visits) async {
@ -134,10 +132,13 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
isScrollControlled: true,
context: context,
builder: (context) {
return UpdateVisitsGroupSheet(visits: visits,title: _subtitle.updateRegularVisits,);
return UpdateVisitsGroupSheet(
visits: visits,
title: _subtitle.updateRegularVisits,
);
},
)as VisitsGroup;
if(_group != null){
) as VisitsGroup;
if (_group != null) {
showDialog<void>(
context: context,
barrierDismissible: false,
@ -148,24 +149,17 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
);
},
);
int status = await _visitsProvider.updateGroupOfVisits(
user: _userProvider.user,
host: _settingProvider.host,
group: _group
);
int status = await _visitsProvider.updateGroupOfVisits(user: _userProvider.user, host: _settingProvider.host, group: _group);
Navigator.of(context).pop();
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.preventiveMaintenanceUpdatedSuccessfully,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
msg: _subtitle.preventiveMaintenanceUpdatedSuccessfully,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
}else{
} else {
Fluttertoast.showToast(
msg: HttpStatusManger.getStatusMessage(
status: status,
subtitle: _subtitle
),
msg: HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
@ -177,7 +171,6 @@ class _RegularVisitsPageState extends State<RegularVisitsPage>
),
],
),
],
),
),

@ -14,6 +14,7 @@ import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
import 'package:test_sa/views/widgets/status/employee/engineers_mune.dart';
import 'package:test_sa/views/widgets/visits/visit_status.dart';
class UpdateVisitsGroupSheet extends StatefulWidget {
final List<Visit> visits;
final String title;
@ -70,20 +71,24 @@ class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
),
ASmallButton(
text: _subtitle.cancel,
onPressed: (){
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
EngineersMenu(
initialValue: _group.engineer,
onSelect: (engineer){
onSelect: (engineer) {
_group.engineer = engineer;
},
),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
// AOneImagePicker(
// image: _image,
// onPick: (image){
@ -91,146 +96,138 @@ class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
// _group.image = base64Encode(image.readAsBytesSync());
// },
// ),
// SizedBox(height: 12 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.jobSheetNumber,
// hintText: _subtitle.jobSheetNumber,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.jobSheetNumber = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.workingHours,
// hintText: _subtitle.workingHours,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.workingHours = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.travelingHours,
// hintText: _subtitle.travelingHours,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.travelingHours = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Row(
// children: [
// Expanded(
// child: Text(
// "${_subtitle.date} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// ),
// ADatePicker(
// date: _group.date ?? DateTime.now(),
// onDatePicker: (date){
// _group.date = date;
// setState(() {});
// },
// ),
// ],
// ),
// // SizedBox(height: 8 * AStyling.getScaleFactor(context),),
// Text(
// "${_subtitle.status} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Center(
// child: Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// status.length,
// (index) {
// bool isSelected = _group.status == status[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected)
// _group.status = null;
// else
// _group.status = status[index];
//
// setState(() {});
// },
// status: status[index],
// );
// }
//
// ),
// ),
// ),
// Text(
// "${_subtitle.taskStatus} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Center(
// child: Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// taskStatus.length,
// (index) {
// bool isSelected = _group.taskStatus == taskStatus[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected)
// _group.taskStatus = null;
// else
// _group.taskStatus = taskStatus[index];
//
// setState(() {});
// },
// status: taskStatus[index],
// );
// }
//
// ),
// ),
// ),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// SizedBox(height: 12 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.jobSheetNumber,
// hintText: _subtitle.jobSheetNumber,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.jobSheetNumber = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.workingHours,
// hintText: _subtitle.workingHours,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.workingHours = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// ATextFormField(
// initialValue: _group.travelingHours,
// hintText: _subtitle.travelingHours,
// style: Theme.of(context).textTheme.headline6,
// onSaved: (value){
// _group.travelingHours = value;
// },
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Row(
// children: [
// Expanded(
// child: Text(
// "${_subtitle.date} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// ),
// ADatePicker(
// date: _group.date ?? DateTime.now(),
// onDatePicker: (date){
// _group.date = date;
// setState(() {});
// },
// ),
// ],
// ),
// // SizedBox(height: 8 * AStyling.getScaleFactor(context),),
// Text(
// "${_subtitle.status} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Center(
// child: Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// status.length,
// (index) {
// bool isSelected = _group.status == status[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected)
// _group.status = null;
// else
// _group.status = status[index];
//
// setState(() {});
// },
// status: status[index],
// );
// }
//
// ),
// ),
// ),
// Text(
// "${_subtitle.taskStatus} :",
// style: Theme.of(context).textTheme.subtitle1,
// textScaleFactor: AppStyle.getScaleFactor(context),
// ),
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
// Center(
// child: Wrap(
// spacing: 10,
// runSpacing: 10,
// children: List.generate(
// taskStatus.length,
// (index) {
// bool isSelected = _group.taskStatus == taskStatus[index];
// return FilterItem(
// isSelected: isSelected,
// onSelected: (){
// if(isSelected)
// _group.taskStatus = null;
// else
// _group.taskStatus = taskStatus[index];
//
// setState(() {});
// },
// status: taskStatus[index],
// );
// }
//
// ),
// ),
// ),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
Expanded(
child: ListView.builder(
itemCount: widget.visits.length,
itemBuilder: (context,index){
itemBuilder: (context, index) {
Visit visit = widget.visits[index];
return Container(
padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
margin: EdgeInsets.symmetric(vertical: 4),
decoration: BoxDecoration(
color: AColors.primaryColor,
borderRadius: BorderRadius.circular(
AppStyle.getBorderRadius(context)
),
boxShadow: [
AppStyle.boxShadow
]
),
decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [AppStyle.boxShadow]),
child: Row(
children: [
Expanded(
child: Text(
"${_subtitle.sn}: "+visit.deviceSerialNumber ?? _subtitle.noSerialNumberFound,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontSize: 16,
fontWeight: FontWeight.bold
),
"${_subtitle.sn}: " + visit.deviceSerialNumber ?? _subtitle.noSerialNumberFound,
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontSize: 16, fontWeight: FontWeight.bold),
),
),
VisitStatusLabel(visit: visit,)
VisitStatusLabel(
visit: visit,
)
],
),
);
@ -239,13 +236,12 @@ class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
),
AButton(
text: _subtitle.update,
onPressed: (){
Navigator.of(context).pop(_group);
onPressed: () {
Navigator.of(context).pop(_group);
},
),
],
),
],
),
);

@ -29,8 +29,8 @@ class VisitDetailsPage extends StatelessWidget {
child: Column(
children: [
Container(
color:AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0,vertical: 4),
color: AColors.primaryColor,
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row(
children: [
ABackButton(),
@ -38,10 +38,7 @@ class VisitDetailsPage extends StatelessWidget {
child: Center(
child: Text(
_subtitle.visitInformation,
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
),
@ -51,9 +48,11 @@ class VisitDetailsPage extends StatelessWidget {
buttonSize: 42,
backgroundColor: AColors.green,
onPressed: () async {
Navigator.of(context).push(
MaterialPageRoute(builder: (_)=> EditPentry(visit: visit,pentry: visit.pentry,))
);
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => EditPentry(
visit: visit,
pentry: visit.pentry,
)));
},
),
SizedBox(width: 42)
@ -64,13 +63,14 @@ class VisitDetailsPage extends StatelessWidget {
child: ListView(
padding: EdgeInsets.symmetric(horizontal: 16),
children: [
SizedBox(height: 8,),
SizedBox(
height: 8,
),
MaterialButton(
padding: EdgeInsets.zero,
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => Scaffold(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => Scaffold(
body: InteractiveViewer(
child: Center(
child: ImageLoader(
@ -79,27 +79,29 @@ class VisitDetailsPage extends StatelessWidget {
),
),
),
)
)
);
)));
},
child: SizedBox(
height: 140 * AppStyle.getScaleFactor(context),
width: MediaQuery.of(context).size.width,
child: ImageLoader(
url: visit.images.isEmpty ? " ":visit.images.first,
url: visit.images.isEmpty ? " " : visit.images.first,
boxFit: BoxFit.cover,
),
),
),
SizedBox(height: 8,),
SizedBox(
height: 60* AppStyle.getScaleFactor(context),
height: 8,
),
SizedBox(
height: 60 * AppStyle.getScaleFactor(context),
child: ImagesList(
images: visit.images,
),
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
RequestInfoRow(
title: _subtitle.code,
info: visit.serialNumber,
@ -112,7 +114,6 @@ class VisitDetailsPage extends StatelessWidget {
title: _subtitle.deviceSN,
info: visit.deviceSerialNumber,
),
RequestInfoRow(
title: _subtitle.expectDate,
info: visit.expectDate,
@ -126,17 +127,18 @@ class VisitDetailsPage extends StatelessWidget {
Expanded(
child: Text(
"${_subtitle.status} : ",
style: Theme.of(context).textTheme.subtitle1.copyWith(
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold),
textScaleFactor: AppStyle.getScaleFactor(context),
),
),
VisitStatusLabel(visit: visit,),
VisitStatusLabel(
visit: visit,
),
],
),
Divider(color: Theme.of(context).primaryColor,),
Divider(
color: Theme.of(context).primaryColor,
),
RequestInfoRow(
title: _subtitle.contactStatus,
info: visit.assignTo,

@ -1,20 +1,18 @@
import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class AppNameBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 50 * AppStyle.getScaleFactor(context),
color:AColors.primaryColor,
color: AColors.primaryColor,
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(
"Test SA",
style: Theme.of(context).textTheme.headline6.copyWith(
color: AColors.white,
fontStyle: FontStyle.italic
),
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
),
),
);

@ -7,7 +7,7 @@ class ABackButton extends StatelessWidget {
final VoidCallback onPressed;
final IconData icon;
const ABackButton({Key key, this.onPressed,this.icon}) : super(key: key);
const ABackButton({Key key, this.onPressed, this.icon}) : super(key: key);
@override
Widget build(BuildContext context) {

@ -27,7 +27,7 @@ class AButton extends StatelessWidget {
onPressed: onPressed,
child: Text(
text ?? "",
style: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.white, fontSize: 14,fontWeight: FontWeight.w600),
style: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.white, fontSize: 14, fontWeight: FontWeight.w600),
textScaleFactor: AppStyle.getScaleFactor(context),
),
),

@ -8,19 +8,19 @@ class AFlatButton extends StatelessWidget {
final EdgeInsets padding;
final VoidCallback onPressed;
const AFlatButton({Key key, this.text, this.textColor,this.style ,this.onPressed,this.padding}) : super(key: key);
const AFlatButton({Key key, this.text, this.textColor, this.style, this.onPressed, this.padding}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(
style: TextButton.styleFrom(
foregroundColor: this.textColor ?? Colors.black, padding: padding,
),
onPressed: onPressed,
child: Text(
text??"",
style: style ?? Theme.of(context).textTheme.bodyText1,
textScaleFactor: AppStyle.getScaleFactor(context),
)
);
style: TextButton.styleFrom(
foregroundColor: this.textColor ?? Colors.black,
padding: padding,
),
onPressed: onPressed,
child: Text(
text ?? "",
style: style ?? Theme.of(context).textTheme.bodyText1,
textScaleFactor: AppStyle.getScaleFactor(context),
));
}
}

@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class AIconButton extends StatelessWidget {
class AIconButton extends StatelessWidget {
final IconData iconData;
final Color color;
final Color backgroundColor;
@ -11,16 +11,7 @@ class AIconButton extends StatelessWidget {
final double iconSize;
final double buttonSize;
const AIconButton({
Key key,
this.iconData,
this.onPressed,
this.color,
this.iconSize,
this.buttonSize = 54,
this.backgroundColor
}) : super(key: key);
const AIconButton({Key key, this.iconData, this.onPressed, this.color, this.iconSize, this.buttonSize = 54, this.backgroundColor}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -30,12 +21,8 @@ class AIconButton extends StatelessWidget {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
(AppStyle.borderRadius - 4) * AppStyle.getScaleFactor(context)
)
),
backgroundColor: backgroundColor ?? AColors.onPrimaryColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular((AppStyle.borderRadius - 4) * AppStyle.getScaleFactor(context))),
backgroundColor: backgroundColor ?? AColors.onPrimaryColor,
),
onPressed: onPressed,
child: FaIcon(

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class AIconButton2 extends StatelessWidget {
class AIconButton2 extends StatelessWidget {
final IconData iconData;
final Color color;
final VoidCallback onPressed;

@ -16,11 +16,7 @@ class AOutLinedButton extends StatelessWidget {
return OutlinedButton(
style: ElevatedButton.styleFrom(
padding: padding ?? EdgeInsets.symmetric(vertical: 12),
textStyle: textStyle ?? Theme
.of(context)
.textTheme
.subtitle2
.copyWith(fontSize: 18),
textStyle: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(fontSize: 18),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
),
onPressed: onPressed,
@ -29,11 +25,7 @@ class AOutLinedButton extends StatelessWidget {
Expanded(
child: Text(
text ?? "",
style: Theme
.of(context)
.textTheme
.subtitle2
.copyWith(color: AColors.primaryColor, fontSize: 14, fontWeight: FontWeight.w600),
style: Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.primaryColor, fontSize: 14, fontWeight: FontWeight.w600),
textAlign: TextAlign.center,
textScaleFactor: AppStyle.getScaleFactor(context),
),

@ -8,26 +8,20 @@ class ASmallButton extends StatelessWidget {
final EdgeInsets padding;
final VoidCallback onPressed;
const ASmallButton({Key key, this.text, this.style ,this.onPressed,this.padding, this.color}) : super(key: key);
const ASmallButton({Key key, this.text, this.style, this.onPressed, this.padding, this.color}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
padding: padding,
primary: color ?? Theme.of(context).primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)
style: ElevatedButton.styleFrom(
padding: padding,
primary: color ?? Theme.of(context).primaryColor,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
),
child: Text(
text??"",
style: style ?? Theme.of(context).textTheme.bodyText1.copyWith(
color: color == Colors.white
? Theme.of(context).primaryColor : Colors.white
child: Text(
text ?? "",
style: style ?? Theme.of(context).textTheme.bodyText1.copyWith(color: color == Colors.white ? Theme.of(context).primaryColor : Colors.white),
textScaleFactor: AppStyle.getScaleFactor(context),
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
onPressed: onPressed
);
onPressed: onPressed);
}
}

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
class CarveInImage extends CustomClipper<Path> {
final double gab;
var radius=10.0;
var radius = 10.0;
CarveInImage(this.gab);
@ -10,14 +10,14 @@ class CarveInImage extends CustomClipper<Path> {
Path getClip(Size size) {
Path path = Path();
path.lineTo(0, size.height);
path.lineTo(size.width/2 - gab / 2, size.height);
path.arcToPoint(Offset(size.width/2 + gab / 2, size.height),
radius: Radius.circular(gab/2));
path.lineTo(size.width / 2 - gab / 2, size.height);
path.arcToPoint(Offset(size.width / 2 + gab / 2, size.height), radius: Radius.circular(gab / 2));
path.lineTo(size.width, size.height);
path.lineTo(size.width, 0);
path.lineTo(0, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
}

@ -16,23 +16,15 @@ class ADatePicker extends StatelessWidget {
foregroundColor: Colors.white,
textStyle: Theme.of(context).textTheme.subtitle2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
12 * AppStyle.getScaleFactor(context)
),
borderRadius: BorderRadius.circular(12 * AppStyle.getScaleFactor(context)),
),
),
child: Text(
date == null ? "Pick Date" :
date.toString().split(" ").first,
date == null ? "Pick Date" : date.toString().split(" ").first,
textScaleFactor: AppStyle.getScaleFactor(context),
),
onPressed: () async {
DateTime picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: from ?? DateTime.now(),
lastDate: to ?? DateTime.now().add(Duration(days: 365))
);
DateTime picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: from ?? DateTime.now(), lastDate: to ?? DateTime.now().add(Duration(days: 365)));
onDatePicker(picked);
},
);

@ -4,6 +4,7 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'date_picker.dart';
class FromToDateBar extends StatefulWidget {
final DateTime from;
final DateTime to;
@ -32,22 +33,18 @@ class _FromToDateBarState extends State<FromToDateBar> {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_subtitle.from,
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 12,
fontWeight: FontWeight.normal
),
style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
textScaleFactor: AppStyle.getScaleFactor(context),
),
ADatePicker(
date: _from,
from: DateTime(1950),
onDatePicker: (date){
onDatePicker: (date) {
_from = date;
setState(() {});
widget.onPickFrom(date);
@ -60,16 +57,13 @@ class _FromToDateBarState extends State<FromToDateBar> {
children: [
Text(
_subtitle.to,
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 12,
fontWeight: FontWeight.normal
),
style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
textScaleFactor: AppStyle.getScaleFactor(context),
),
ADatePicker(
date: _to,
from: DateTime(1950),
onDatePicker: (date){
onDatePicker: (date) {
_to = date;
setState(() {});
widget.onPickTo(date);

@ -6,6 +6,7 @@ import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/departments/single_department_picker.dart';
class DepartmentButton extends StatelessWidget {
final Function(Department) onDepartmentPick;
final Department department;

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:test_sa/models/department.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class DepartmentItem extends StatelessWidget {
final Department department;
final Function(Department) onPressed;
@ -10,28 +11,23 @@ class DepartmentItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 6),
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AColors.primaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
AppStyle.getBorderRadius(context)
),
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
),
),
onPressed: (){
onPressed: () {
onPressed(department);
},
child: ListTile(
title: Text(
department.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: AColors.white
),
department.name ?? "",
style: Theme.of(context).textTheme.subtitle1.copyWith(color: AColors.white),
textDirection: TextDirection.rtl,
),
),
),
);

@ -10,6 +10,7 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
import '../app_text_form_field.dart';
class SingleDepartmentPicker extends StatefulWidget {
static final String id = "/single-Department-Picker";
@override
@ -26,7 +27,7 @@ class _SingleDepartmentPickerState extends State<SingleDepartmentPicker> {
_departmentsProvider = Provider.of<DepartmentsProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
Subtitle _subtitle = AppLocalization.of(context).subtitle;
if(_firstTime && _departmentsProvider.departments != null){
if (_firstTime && _departmentsProvider.departments != null) {
_searchableList.addAll(_departmentsProvider.departments);
_firstTime = false;
}
@ -45,40 +46,40 @@ class _SingleDepartmentPickerState extends State<SingleDepartmentPicker> {
},
child: Column(
children: [
SizedBox(height: 48,),
SizedBox(
height: 48,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: ATextFormField(
hintText: _subtitle.searchByName,
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.headline6,
suffixIcon: Icon(Icons.search_rounded),
onChange: (value){
onChange: (value) {
_searchableList.clear();
_searchableList.addAll(_departmentsProvider.departments.where(
(element) => element.name.toLowerCase().contains(
value.toLowerCase()
)
).toList());
_searchableList.addAll(_departmentsProvider.departments.where((element) => element.name.toLowerCase().contains(value.toLowerCase())).toList());
setState(() {});
},
),
),
Expanded(
child: _searchableList.isEmpty ?
NoItemFound(message: _subtitle.noUniteFound,):
ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: _searchableList.length,
itemBuilder: (listContext,itemIndex){
return DepartmentItem(
department: _searchableList[itemIndex],
onPressed: (hospital){
Navigator.of(context).pop(hospital);
},
);
},
),
child: _searchableList.isEmpty
? NoItemFound(
message: _subtitle.noUniteFound,
)
: ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
itemCount: _searchableList.length,
itemBuilder: (listContext, itemIndex) {
return DepartmentItem(
department: _searchableList[itemIndex],
onPressed: (hospital) {
Navigator.of(context).pop(hospital);
},
);
},
),
),
],
),

@ -5,6 +5,7 @@ import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
class DeviceTransferInfoSection extends StatelessWidget {
final DeviceTransferInfo info;
final VoidCallback onEdit;
@ -41,19 +42,16 @@ class DeviceTransferInfoSection extends StatelessWidget {
),
RequestInfoRow(
title: "Signature",
info: info.signature?.isEmpty != false
? subtitle.noDateFound : null,
contentWidget: info.signature?.isEmpty != false ? null :
ImageLoader(
url: info.signature,
),
info: info.signature?.isEmpty != false ? subtitle.noDateFound : null,
contentWidget: info.signature?.isEmpty != false
? null
: ImageLoader(
url: info.signature,
),
),
RequestInfoRow(
title: subtitle.status,
infoWidget: StatusLabel(
label: info.status?.name,
color: AColors.getGasStatusColor(info.status?.id)
),
infoWidget: StatusLabel(label: info.status?.name, color: AColors.getGasStatusColor(info.status?.id)),
),
],
);

@ -9,6 +9,7 @@ import 'package:test_sa/models/user.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
class DeviceTransferItem extends StatelessWidget {
final int index;
final DeviceTransfer item;
@ -18,28 +19,22 @@ class DeviceTransferItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;
User _user = Provider.of<UserProvider>(context,listen: false).user;
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;
User _user = Provider.of<UserProvider>(context, listen: false).user;
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(
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
backgroundColor: itemColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
AppStyle.getBorderRadius(context)
),
),
),
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
backgroundColor: itemColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
),
),
//padding: EdgeInsets.symmetric(vertical: 8,horizontal: 8),
onPressed: (){
onPressed: () {
onPressed(item);
},
child: Column(
@ -53,28 +48,25 @@ class DeviceTransferItem extends StatelessWidget {
children: [
Text(
item.title ?? "-----",
style: Theme.of(context).textTheme.headline6.copyWith(
color: onItemColor,
fontSize: 16,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
),
Divider(
color: onItemColor,
),
Divider(color: onItemColor,),
Row(
children: [
Expanded(
child: Text(
_subtitle.from,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
color: onItemColor,
),
),
),
StatusLabel(
color: AColors.getRequestStatusColor(item.sender.status?.id),
label: item.sender.status?.name,
)
StatusLabel(
color: AColors.getRequestStatusColor(item.sender.status?.id),
label: item.sender.status?.name,
)
],
),
//const SizedBox(height: 8,),
@ -84,37 +76,36 @@ class DeviceTransferItem extends StatelessWidget {
child: Text(
item.sender.client.name,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
color: onItemColor,
),
),
),
],
),
if(item.sender.department.id != null)
Text(
item.sender.department.name,
style: Theme.of(context).textTheme.bodySmall.copyWith(
color: onItemColor,
if (item.sender.department.id != null)
Text(
item.sender.department.name,
style: Theme.of(context).textTheme.bodySmall.copyWith(
color: onItemColor,
),
),
Divider(
color: onItemColor,
),
Divider(color: onItemColor,),
Row(
children: [
Expanded(
child: Text(
_subtitle.to,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
color: onItemColor,
),
),
),
StatusLabel(
color: AColors.getRequestStatusColor(item.receiver.status?.id),
label: item.receiver.status?.name,
)
],
),
//const SizedBox(height: 8,),
@ -124,26 +115,23 @@ class DeviceTransferItem extends StatelessWidget {
child: Text(
item.receiver.client.name,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
color: onItemColor,
),
),
),
],
),
if(item.receiver.department.id != null)
Text(
item.receiver.department.name,
style: Theme.of(context).textTheme.bodySmall.copyWith(
color: onItemColor,
if (item.receiver.department.id != null)
Text(
item.receiver.department.name,
style: Theme.of(context).textTheme.bodySmall.copyWith(
color: onItemColor,
),
),
),
//Divider(color: onItemColor,),
],
),
),
],
),
],

@ -6,6 +6,7 @@ import 'package:test_sa/views/pages/device_transfer/device_transfer_details.dart
import 'package:test_sa/views/widgets/device_trancfer/device_transfer_item.dart';
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
class DeviceTransferList extends StatelessWidget {
final List<DeviceTransfer> items;
final bool nextPage;
@ -15,32 +16,31 @@ class DeviceTransferList extends StatelessWidget {
@override
Widget build(BuildContext context) {
if(items.length == 0){
if (items.length == 0) {
Subtitle subtitle = AppLocalization.of(context).subtitle;
return NoItemFound(message: subtitle.noServiceRequestFound,);
return NoItemFound(
message: subtitle.noServiceRequestFound,
);
}
return LazyLoading(
nextPage: nextPage,
onLazyLoad: onLazyLoad,
child: ListView.builder(
//physics: const BouncingScrollPhysics(),
itemCount: items.length,
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 8),
itemBuilder: (context,itemIndex){
//physics: const BouncingScrollPhysics(),
itemCount: items.length,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
itemBuilder: (context, itemIndex) {
return DeviceTransferItem(
index: itemIndex,
item: items[itemIndex],
onPressed: (model){
Navigator.of(context).push(
MaterialPageRoute(
builder: (_)=> DeviceTransferDetails(model: model,)
)
);
onPressed: (model) {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => DeviceTransferDetails(
model: model,
)));
},
);
}
),
}),
);
}
}

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/models/subtitle.dart';
class AAlertDialog extends StatelessWidget {
final String title;
final String content;
@ -12,12 +13,8 @@ class AAlertDialog extends StatelessWidget {
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;
return CupertinoAlertDialog(
title: title != null
? Text(title)
: null,
content: content != null
? Text(content)
: null,
title: title != null ? Text(title) : null,
content: content != null ? Text(content) : null,
actions: <Widget>[
TextButton(
child: Text(_subtitle.confirm),

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save