implement searchWorkOrders api and edit on ui

merge-requests/29/head
nextwo 2 years ago
parent f39b6f5d8e
commit 756e2a1881

@ -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,12 +135,12 @@ 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;
}
}
}
}

@ -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
@ -45,4 +41,4 @@ class _DemoLocalizationsDelegate
@override
bool shouldReload(LocalizationsDelegate<AppLocalization> old) => false;
}
}

@ -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");
@ -221,4 +213,4 @@ class DeviceTransferProvider extends ChangeNotifier {
return -1;
}
}
}
}

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

@ -37,7 +37,7 @@ class ServiceRequestsProvider extends ChangeNotifier {
// list of user requests
List<ServiceRequest> serviceRequests;
List<SearchWorkOrders> workOrders =[];
List<SearchWorkOrders> workOrders = [];
// when requests in-process _loading = true
// done _loading = true
@ -249,16 +249,15 @@ class ServiceRequestsProvider extends ChangeNotifier {
}
Future<List<SearchWorkOrders>> searchWorkOrders({@required String callId}) async {
Response response;
try{
try {
var body = {
"pageSize": pageItemNumber,
"pageNumber":( (workOrders?.length ?? 0) ~/ pageItemNumber) + 1,
"callId": callId,
};
response = await ApiManager.instance.post(URLs.searchWorkOrders, body: 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
@ -272,9 +271,8 @@ class ServiceRequestsProvider extends ChangeNotifier {
}
}
return workOrders;
}catch(e){
return [];
} catch (e) {
return [];
}
}

@ -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 ServiceReportLastCallsProvider extends ChangeNotifier{
class ServiceReportLastCallsProvider extends ChangeNotifier {
//reset provider data
void reset(){
void reset() {
_calls = null;
_loading = null;
_stateCode = null;
@ -33,7 +32,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading){
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
}
@ -43,13 +42,12 @@ class ServiceReportLastCallsProvider 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> getCalls ({String host,User user,int serviceStatus}) async {
if(_loading == true)
return -2;
Future<int> getCalls({String host, User user, int serviceStatus}) async {
if (_loading == true) return -2;
_loading = true;
notifyListeners();
Response response;
try{
try {
// todo request new api from backend to make filter work
response = await ApiManager.instance.get(
URLs.getServiceReportLastCalls,
@ -61,7 +59,7 @@ class ServiceReportLastCallsProvider extends ChangeNotifier{
// ),
// );
_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"];
_calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
@ -69,13 +67,11 @@ class ServiceReportLastCallsProvider 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;
}
}
}
}

@ -3,4 +3,4 @@ class ASettings {
static final String host = "host";
static final String language = "language";
static final String speechToText = "speech_to_text";
}
}

@ -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;
}
@ -55,4 +50,4 @@ class Validator{
}
return int.tryParse(value) != null;
}
}
}

@ -65,17 +65,16 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isIOS) {
await Firebase.initializeApp(
options: const FirebaseOptions(apiKey: "AIzaSyACQkSleNwU1jzEKR5ho1uSfZERokwwAbc", appId: "1:973582662416:ios:bc4a8061444c6a08fbc395", messagingSenderId: "973582662416", projectId: "atoms-fb912"),
options:
const FirebaseOptions(apiKey: "AIzaSyACQkSleNwU1jzEKR5ho1uSfZERokwwAbc", appId: "1:973582662416:ios:bc4a8061444c6a08fbc395", messagingSenderId: "973582662416", projectId: "atoms-fb912"),
);
} else {
await Firebase.initializeApp();
}
runApp(
ChangeNotifierProvider(
create: (_) => SettingProvider(),
child: MyApp(),
)
);
runApp(ChangeNotifierProvider(
create: (_) => SettingProvider(),
child: MyApp(),
));
}
class MyApp extends StatelessWidget {
@ -127,18 +126,12 @@ class MyApp extends StatelessWidget {
title: 'ATOMS',
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: "Poppins",
//canvasColor: AColors.primaryColor,
scaffoldBackgroundColor: AColors.scaffoldBackgroundColor,
primaryColor: AColors.primaryColor,
indicatorColor: AColors.primaryColor,
colorScheme: const ColorScheme.light(
primary: AColors.primaryColor,
onPrimary: Colors.white,
secondary: AColors.secondaryColor,
onSecondary: Colors.white
)
),
fontFamily: "Poppins",
//canvasColor: AColors.primaryColor,
scaffoldBackgroundColor: AColors.scaffoldBackgroundColor,
primaryColor: AColors.primaryColor,
indicatorColor: AColors.primaryColor,
colorScheme: const ColorScheme.light(primary: AColors.primaryColor, onPrimary: Colors.white, secondary: AColors.secondaryColor, onSecondary: Colors.white)),
localizationsDelegates: const [
// ... app-specific localization delegate[s] here
AppLocalization.delegate,
@ -153,31 +146,28 @@ class MyApp extends StatelessWidget {
locale: Locale(_settingProvider.language ?? 'en'),
initialRoute: SplashScreen.id,
routes: {
SplashScreen.id: (_)=> const SplashScreen(),
LandPage.id: (_)=> const LandPage(),
Login.id: (_)=> Login(),
Register.id: (_)=> Register(),
ProfilePage.id: (_)=> ProfilePage(),
ReportIssuesPage.id: (_)=> const ReportIssuesPage(),
RequestGasRefill.id: (_)=> const RequestGasRefill(),
CreateRequestPage.id: (_)=> CreateRequestPage(),
SingleHospitalPicker.id: (_)=> SingleHospitalPicker(),
SingleDevicePicker.id: (_)=> SingleDevicePicker(),
SingleDepartmentPicker.id: (_)=> SingleDepartmentPicker(),
ServiceRequestsPage.id: (_)=> ServiceRequestsPage(),
NotificationsPage.id: (_)=> NotificationsPage(),
FutureRequestServiceDetails.id: (_)=> FutureRequestServiceDetails(),
PreventiveMaintenanceVisitsPage.id: (_)=> PreventiveMaintenanceVisitsPage(),
RegularVisitsPage.id: (_)=> RegularVisitsPage(),
TrackGasRefillPage.id: (_)=> const TrackGasRefillPage(),
RequestDeviceTransfer.id: (_)=> const RequestDeviceTransfer(),
TrackDeviceTransferPage.id: (_)=> const TrackDeviceTransferPage(),
SplashScreen.id: (_) => const SplashScreen(),
LandPage.id: (_) => const LandPage(),
Login.id: (_) => Login(),
Register.id: (_) => Register(),
ProfilePage.id: (_) => ProfilePage(),
ReportIssuesPage.id: (_) => const ReportIssuesPage(),
RequestGasRefill.id: (_) => const RequestGasRefill(),
CreateRequestPage.id: (_) => CreateRequestPage(),
SingleHospitalPicker.id: (_) => SingleHospitalPicker(),
SingleDevicePicker.id: (_) => SingleDevicePicker(),
SingleDepartmentPicker.id: (_) => SingleDepartmentPicker(),
ServiceRequestsPage.id: (_) => ServiceRequestsPage(),
NotificationsPage.id: (_) => NotificationsPage(),
FutureRequestServiceDetails.id: (_) => FutureRequestServiceDetails(),
PreventiveMaintenanceVisitsPage.id: (_) => PreventiveMaintenanceVisitsPage(),
RegularVisitsPage.id: (_) => RegularVisitsPage(),
TrackGasRefillPage.id: (_) => const TrackGasRefillPage(),
RequestDeviceTransfer.id: (_) => const RequestDeviceTransfer(),
TrackDeviceTransferPage.id: (_) => const TrackDeviceTransferPage(),
},
),
),
);
}
}

@ -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,16 +7,16 @@ 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,
@ -44,4 +45,4 @@ class ModelDefinition {
lifeSpan: map['lifeSpan'] as int,
);
}
}
}

@ -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"],
@ -64,4 +55,4 @@ class Lookup{
// 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'] ?? ""),
);
}
@ -37,4 +37,4 @@ class CalibrationTool{
dataOfTesting: dataOfTesting ?? this.dataOfTesting,
);
}
}
}

@ -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 {
@ -38,4 +31,4 @@ class Contact{
landLine: map['landLine'] as String,
);
}
}
}

@ -1,15 +1,12 @@
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,15 +1,12 @@
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,
@ -69,4 +60,4 @@ class PMKit{
quantityReserved: quantityReserved ?? this.quantityReserved,
);
}
}
}

@ -1,4 +1,4 @@
class Part{
class Part {
int id;
int reportPartID;
String code;
@ -13,25 +13,21 @@ 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"],
quantity: reportJson != null ? (reportJson["qty"] ?? 1).toInt() : 1,
);
}
}
}

@ -36,37 +36,37 @@ class SearchWorkOrders {
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});
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']);
@ -75,13 +75,9 @@ class SearchWorkOrders {
workOrderNo = json['workOrderNo'];
workOrderYear = json['workOrderYear'];
workOrderSequennce = json['workOrderSequennce'];
callRequest = json['callRequest'] != null
? new CallRequest.fromJson(json['callRequest'])
: CallRequest();
callRequest = json['callRequest'] != null ? new CallRequest.fromJson(json['callRequest']) : CallRequest();
assetType = json['assetType'];
assignedEmployee = json['assignedEmployee'] != null
? new AssignedEmployee.fromJson(json['assignedEmployee'])
: AssignedEmployee();
assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : AssignedEmployee();
visitDate = json['visitDate'];
if (json['assistantEmployees'] != null) {
assistantEmployees = json['assistantEmployees'];
@ -91,12 +87,8 @@ class SearchWorkOrders {
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();
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'];
@ -104,9 +96,7 @@ class SearchWorkOrders {
workingHours = json['workingHours'];
travelingHours = json['travelingHours'];
travelingExpenses = json['travelingExpenses'];
faultDescription = json['faultDescription'] != null
? new ModelDefRelatedDefects.fromJson(json['faultDescription'])
: ModelDefRelatedDefects();
faultDescription = json['faultDescription'] != null ? new ModelDefRelatedDefects.fromJson(json['faultDescription']) : ModelDefRelatedDefects();
if (json['sparePartsWorkOrders'] != null) {
sparePartsWorkOrders = json['sparePartsWorkOrders'];
}
@ -138,14 +128,12 @@ class SearchWorkOrders {
}
data['visitDate'] = this.visitDate;
if (this.assistantEmployees != null) {
data['assistantEmployees'] =
this.assistantEmployees.map((v) => v.toJson()).toList();
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();
data['contactPersonWorkOrders'] = this.contactPersonWorkOrders.map((v) => v.toJson()).toList();
}
if (this.calllastSituation != null) {
data['calllastSituation'] = this.calllastSituation.toMap();
@ -164,16 +152,14 @@ class SearchWorkOrders {
data['faultDescription'] = this.faultDescription.toJson();
}
if (this.sparePartsWorkOrders != null) {
data['sparePartsWorkOrders'] =
this.sparePartsWorkOrders.map((v) => v.toJson()).toList();
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['suppEngineerWorkOrders'] = this.suppEngineerWorkOrders.map((v) => v.toJson()).toList();
}
data['engSignature'] = this.engSignature;
data['nurseSignature'] = this.nurseSignature;
@ -194,33 +180,18 @@ class CallRequest {
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({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();
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();
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'];
@ -237,8 +208,7 @@ class CallRequest {
data['assignedEmployee'] = this.assignedEmployee.toJson();
}
if (this.callSiteContactPerson != null) {
data['callSiteContactPerson'] =
this.callSiteContactPerson.map((v) => v.toJson()).toList();
data['callSiteContactPerson'] = this.callSiteContactPerson.map((v) => v.toJson()).toList();
}
if (this.status != null) {
data['status'] = this.status.toMap();
@ -305,62 +275,60 @@ class Asset {
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});
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();
modelDefinition = json['modelDefinition'] != null ? new ModelDefinition.fromJson(json['modelDefinition']) : ModelDefinition();
supplier = json['supplier'];
ipAddress = json['ipAddress'];
macAddress = json['macAddress'];
@ -430,8 +398,7 @@ class Asset {
data['warrantyEndDate'] = this.warrantyEndDate;
data['warrantyContractConditions'] = this.warrantyContractConditions;
if (this.technicalGuidanceBooks != null) {
data['technicalGuidanceBooks'] =
this.technicalGuidanceBooks.map((v) => v.toJson()).toList();
data['technicalGuidanceBooks'] = this.technicalGuidanceBooks.map((v) => v.toJson()).toList();
}
data['comment'] = this.comment;
data['tagCode'] = this.tagCode;
@ -454,16 +421,16 @@ class ModelDefinition {
ModelDefinition(
{this.id,
this.assetName,
this.modelDefCode,
this.modelName,
this.manufacturerId,
this.manufacturerName,
this.supplierName,
this.replacementDate,
this.lifeSpan,
this.modelDefRelatedDefects,
this.suppliers});
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'];
@ -498,8 +465,7 @@ class ModelDefinition {
data['replacementDate'] = this.replacementDate;
data['lifeSpan'] = this.lifeSpan;
if (this.modelDefRelatedDefects != null) {
data['modelDefRelatedDefects'] =
this.modelDefRelatedDefects.map((v) => v.toJson()).toList();
data['modelDefRelatedDefects'] = this.modelDefRelatedDefects.map((v) => v.toJson()).toList();
}
if (this.suppliers != null) {
data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList();
@ -514,8 +480,7 @@ class ModelDefRelatedDefects {
String workPerformed;
String estimatedTime;
ModelDefRelatedDefects(
{this.id, this.defectName, this.workPerformed, this.estimatedTime});
ModelDefRelatedDefects({this.id, this.defectName, this.workPerformed, this.estimatedTime});
ModelDefRelatedDefects.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -581,4 +546,3 @@ class AssignedEmployee {
return data;
}
}

@ -2,7 +2,7 @@ import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/device/device.dart';
import 'package:test_sa/models/lookup.dart';
class ServiceRequest{
class ServiceRequest {
String id;
String requestCode;
String deviceSerialNumber;
@ -53,7 +53,6 @@ class ServiceRequest{
this.deviceId,
this.audio,
this.engineerName,
this.viewReport = false,
this.deviceModel,
this.engineerMobile,
@ -71,49 +70,39 @@ class ServiceRequest{
this.device,
});
factory ServiceRequest.fromJson(Map<String,dynamic> parsedJson){
factory ServiceRequest.fromJson(Map<String, dynamic> parsedJson) {
List<String> images = [];
if(parsedJson["attachmentsCallRequest"] is List){
if (parsedJson["attachmentsCallRequest"] is List) {
List list = parsedJson["attachmentsCallRequest"];
images = list.map((e) => URLs.getFileUrl(e["attachmentsCallRequest"])).toList();
}
return ServiceRequest(
id: parsedJson["id"].toString(),
requestCode: parsedJson["callNo"].toString(),
hospitalName: parsedJson["asset"]["site"]["custName"],
deviceNumber: parsedJson["asset"]["assetNumber"].toString(),
deviceId: parsedJson["asset"]["id"],
audio: URLs.getFileUrl(parsedJson["voiceNote"] ?? ""),
deviceArName: parsedJson["asset"]["modelDefinition"]["assetName"] ?? "",
deviceEnName: parsedJson["asset"]["modelDefinition"]["assetName"] ?? "",
devicePhotos: images,
deviceSerialNumber: parsedJson["asset"]["assetSerialNo"],
date: DateTime.tryParse(parsedJson["requestedDate"] ?? "").toString().split(" ").first,
maintenanceIssue: parsedJson["comments"],
statusLabel: parsedJson["status"] == null ? null :
parsedJson["status"]["name"],
statusValue: parsedJson["status"] == null ? null :
parsedJson["status"]["value"],
departmentName: parsedJson["asset"]["department"] != null ?
parsedJson["asset"]["department"]["name"] : "",
engineerName: parsedJson["assignedEmployee"] == null ? null :
parsedJson["assignedEmployee"]["name"],
hospitalId: parsedJson["asset"]["site"]["id"],
reportID: parsedJson["workOrder"] != null ?
parsedJson["workOrder"]["workOrderId"] : null,
viewReport: parsedJson["workOrder"] != null,
deviceModel: parsedJson["asset"]["modelDefinition"]["modelName"],
engineerMobile: parsedJson["assignedEmployee"] == null ? null :
parsedJson["assignedEmployee"]["phone"],
faultDescription: parsedJson["workOrder"] != null ?
parsedJson["workOrder"]["faultDescription"] : null,
jobSheetNumber: parsedJson["workOrder"] != null ?
parsedJson["workOrder"]["jobSheetNumber"] :null,
visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first,
nextVisitDate: DateTime.tryParse(parsedJson["nextVisitDate"] ?? ""),
workPerformed: parsedJson["workOrder"] != null ?
parsedJson["workOrder"]["workPerformed"] : null,
device: Device.fromJson(parsedJson["asset"])
);
id: parsedJson["id"].toString(),
requestCode: parsedJson["callNo"].toString(),
hospitalName: parsedJson["asset"]["site"]["custName"],
deviceNumber: parsedJson["asset"]["assetNumber"].toString(),
deviceId: parsedJson["asset"]["id"],
audio: URLs.getFileUrl(parsedJson["voiceNote"] ?? ""),
deviceArName: parsedJson["asset"]["modelDefinition"]["assetName"] ?? "",
deviceEnName: parsedJson["asset"]["modelDefinition"]["assetName"] ?? "",
devicePhotos: images,
deviceSerialNumber: parsedJson["asset"]["assetSerialNo"],
date: DateTime.tryParse(parsedJson["requestedDate"] ?? "").toString().split(" ").first,
maintenanceIssue: parsedJson["comments"],
statusLabel: parsedJson["status"] == null ? null : parsedJson["status"]["name"],
statusValue: parsedJson["status"] == null ? null : parsedJson["status"]["value"],
departmentName: parsedJson["asset"]["department"] != null ? parsedJson["asset"]["department"]["name"] : "",
engineerName: parsedJson["assignedEmployee"] == null ? null : parsedJson["assignedEmployee"]["name"],
hospitalId: parsedJson["asset"]["site"]["id"],
reportID: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["workOrderId"] : null,
viewReport: parsedJson["workOrder"] != null,
deviceModel: parsedJson["asset"]["modelDefinition"]["modelName"],
engineerMobile: parsedJson["assignedEmployee"] == null ? null : parsedJson["assignedEmployee"]["phone"],
faultDescription: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["faultDescription"] : null,
jobSheetNumber: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["jobSheetNumber"] : null,
visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first,
nextVisitDate: DateTime.tryParse(parsedJson["nextVisitDate"] ?? ""),
workPerformed: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["workPerformed"] : null,
device: Device.fromJson(parsedJson["asset"]));
}
}
}

@ -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,32 +26,31 @@ 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;
}
}
}

@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
class Subtitle{
class Subtitle {
// http requests status messages
String currentlyServiceNotAvailable;
String waitUntilYourRequestComplete;
@ -223,7 +223,7 @@ class Subtitle{
String duplicateAlertMessage;
String alert;
void setIssues(List<String> issues){
void setIssues(List<String> issues) {
issues.clear();
issues.add(reason1);
issues.add(reason2);
@ -285,7 +285,6 @@ class Subtitle{
@required this.titleValidateMessage,
@required this.to,
@required this.urlNotFound,
@required this.nameExist,
@required this.unitRequired,
@required this.unite,
@ -391,7 +390,6 @@ class Subtitle{
@required this.pickImage,
@required this.requiredImage,
@required this.activationAlert,
@required this.callId,
@required this.requiredWord,
@required this.quantity,
@ -423,7 +421,7 @@ class Subtitle{
@required this.currentSituation,
});
factory Subtitle.fromJson(Map<String,dynamic> parsedJson){
factory Subtitle.fromJson(Map<String, dynamic> parsedJson) {
return Subtitle(
currentlyServiceNotAvailable: parsedJson["server_error_message"],
failedToCompleteRequest: parsedJson["failed_request_message"],
@ -437,7 +435,6 @@ class Subtitle{
signOut: parsedJson["sign_out"],
signOutAlert: parsedJson["logout_alert"],
language: parsedJson["language"],
name: parsedJson["name"],
email: parsedJson["email"],
phoneNumber: parsedJson["phone_number"],
@ -451,7 +448,6 @@ class Subtitle{
passwordValidateMessage: parsedJson["password_validate_message"],
confirmPasswordValidateMessage: parsedJson["confirm_password_validate_message"],
phoneNumberValidateMessage: parsedJson["phone_number_validate_message"],
forgetPasswordWithMark: parsedJson["forget_password_with_mark"],
showPassword: parsedJson["show_password"],
wrongEmailOrPassword: parsedJson["wrong_email_or_password"],
@ -461,7 +457,6 @@ class Subtitle{
back: parsedJson["back"],
search: parsedJson["search"],
searchByName: parsedJson["search_by_name"],
address: parsedJson["address"],
addressNotFound: parsedJson["address_not_found"],
addressValidateMessage: parsedJson["address_validate_message"],
@ -480,7 +475,6 @@ class Subtitle{
titleNotFound: parsedJson["title_not_found"],
titleValidateMessage: parsedJson["title_validate_message"],
urlNotFound: parsedJson["url_not_found"],
date: parsedJson["date"],
status: parsedJson["status"],
code: parsedJson["code"],
@ -556,7 +550,6 @@ class Subtitle{
visitDate: parsedJson["visitDate"],
whatsApp: parsedJson["whatsApp"],
workPerformed: parsedJson["workPerformed"],
actualDate: parsedJson["actualDate"],
done: parsedJson["done"],
expectDate: parsedJson["expectDate"],
@ -587,7 +580,6 @@ class Subtitle{
requiredImage: parsedJson["requiredImage"],
taskStatus: parsedJson["taskStatus"],
activationAlert: parsedJson["activationAlert"],
attachImage: parsedJson["attachImage"],
callLastSituation: parsedJson["callLastSituation"],
customer: parsedJson["customer"],
@ -606,19 +598,17 @@ class Subtitle{
requiredWord: parsedJson["requiredWord"],
serviceType: parsedJson["serviceType"],
workPreformed: parsedJson["workPreformed"],
alert: parsedJson["alert"],
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"],
orderWorkNumber: parsedJson["orderWorkNumber"],
assignedEmployee: parsedJson["assignedEmployee"],
assetSN: parsedJson["assetSN"],
assetName: parsedJson["assetName"],
site: parsedJson["site"],
maintenanceSituation: parsedJson["maintenanceSituation"],
currentSituation: parsedJson["currentSituation"],
);
}
}
}

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

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

@ -35,7 +35,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
SettingProvider _settingProvider;
DeviceTransferProvider _deviceTransferProvider;
final TextEditingController _requestedQuantityController = TextEditingController();
final DeviceTransfer _formModel = DeviceTransfer(receiver: DeviceTransferInfo(),sender: DeviceTransferInfo());
final DeviceTransfer _formModel = DeviceTransfer(receiver: DeviceTransferInfo(), sender: DeviceTransferInfo());
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

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

@ -22,12 +22,11 @@ class SplashScreen extends StatefulWidget {
}
class _SplashScreenState extends State<SplashScreen> {
SettingProvider _settingProvider;
UserProvider _userProvider;
_goToUserScreen(User user){
if(user.tokenLife != null && user.tokenLife.isAfter(DateTime.now())){
_goToUserScreen(User user) {
if (user.tokenLife != null && user.tokenLife.isAfter(DateTime.now())) {
_userProvider.user = user;
// Navigator.of(context).pushNamed(Login.id);
Navigator.of(context).pushNamed(LandPage.id);
@ -38,38 +37,30 @@ class _SplashScreenState extends State<SplashScreen> {
void initState() {
Firebase.initializeApp();
NotificationManger.initialisation(
(notificationDetails) {
AppNotification notification = AppNotification.fromJson(json.decode(notificationDetails.payload));
if(notification.path == null || notification.path.isEmpty)
return;
Navigator.pushNamed(
context,
notification.path,
arguments: notification.requestId
);
}
, (id, title, body, payload) async {
});
NotificationManger.initialisation((notificationDetails) {
AppNotification notification = AppNotification.fromJson(json.decode(notificationDetails.payload));
if (notification.path == null || notification.path.isEmpty) return;
Navigator.pushNamed(context, notification.path, arguments: notification.requestId);
}, (id, title, body, payload) async {});
super.initState();
}
@override
Widget build(BuildContext context) {
_settingProvider = Provider.of<SettingProvider>(context,listen: false);
_userProvider = Provider.of<UserProvider>(context,listen: false);
_settingProvider = Provider.of<SettingProvider>(context, listen: false);
_userProvider = Provider.of<UserProvider>(context, listen: false);
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: SizedBox(
width: MediaQuery.of(context).size.width/1.1,
child: FlareActor(
width: MediaQuery.of(context).size.width / 1.1,
child: FlareActor(
"assets/rives/atoms_splash.flr",
fit: BoxFit.contain,
animation: "splash",
callback: (animation) async {
Navigator.of(context).pushNamed(Login.id);
if(_settingProvider.isLoaded && _settingProvider.user != null){
if (_settingProvider.isLoaded && _settingProvider.user != null) {
_goToUserScreen(_settingProvider.user);
}
},

@ -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);
},
);
}
),
}),
);
}
}

@ -9,14 +9,14 @@ import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/pages/user/notifications/notifications_list.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class NotificationsPage extends StatefulWidget {
static final String id = "/notifications";
@override
_NotificationsPageState createState() => _NotificationsPageState();
}
class _NotificationsPageState extends State<NotificationsPage>
with TickerProviderStateMixin{
class _NotificationsPageState extends State<NotificationsPage> with TickerProviderStateMixin {
NotificationsProvider _notificationsProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -36,9 +36,9 @@ class _NotificationsPageState extends State<NotificationsPage>
onRefresh: () async {
_notificationsProvider.reset();
await _notificationsProvider.getNotifications(
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital.id,
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital.id,
);
},
child: Stack(
@ -46,8 +46,8 @@ class _NotificationsPageState extends State<NotificationsPage>
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(
@ -57,17 +57,15 @@ class _NotificationsPageState extends State<NotificationsPage>
child: Center(
child: Text(
_subtitle.notifications,
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),
),
),
),
SizedBox(width: 48,)
SizedBox(
width: 48,
)
],
),
],
),
),
@ -86,7 +84,6 @@ class _NotificationsPageState extends State<NotificationsPage>
),
],
),
],
),
),

@ -16,6 +16,7 @@ import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/departments/department_button.dart';
import 'package:test_sa/views/widgets/hospitals/hospital_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class ProfilePage extends StatefulWidget {
static final String id = "/user/profile";
@override
@ -38,13 +39,13 @@ class _ProfilePageState extends State<ProfilePage> {
_width = MediaQuery.of(context).size.width;
_height = MediaQuery.of(context).size.height;
Subtitle _subtitle = AppLocalization.of(context).subtitle;
if(_firstTime){
if (_firstTime) {
_user = User.fromJson(_userProvider.user.toJson());
_firstTime = false;
}
return Scaffold(
key: _scaffoldKey,
body:LoadingManager(
body: LoadingManager(
isLoading: _userProvider.isLoading,
isFailedLoading: false,
stateCode: 200,
@ -60,23 +61,19 @@ class _ProfilePageState extends State<ProfilePage> {
Hero(
tag: "logo",
child: Image(
height: _height/4,
height: _height / 4,
image: AssetImage("assets/images/logo.png"),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 16,vertical: 16),
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
margin: EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: AColors.primaryColor,
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
boxShadow: [
BoxShadow(
color: AColors.grey,
offset: Offset(0,-1),
)
]
),
decoration: BoxDecoration(color: AColors.primaryColor, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
BoxShadow(
color: AColors.grey,
offset: Offset(0, -1),
)
]),
child: Column(
children: [
ATextFormField(
@ -85,13 +82,14 @@ class _ProfilePageState extends State<ProfilePage> {
enable: false,
prefixIconData: Icons.account_circle,
style: Theme.of(context).textTheme.headline6,
validator: (value) => Validator.hasValue(value)
? null : _subtitle.nameValidateMessage,
onSaved: (value){
validator: (value) => Validator.hasValue(value) ? null : _subtitle.nameValidateMessage,
onSaved: (value) {
_user.userName = value;
},
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
ATextFormField(
initialValue: _user.email,
hintText: _subtitle.email,
@ -99,110 +97,105 @@ class _ProfilePageState extends State<ProfilePage> {
prefixIconData: Icons.email,
textInputType: TextInputType.emailAddress,
style: Theme.of(context).textTheme.headline6,
validator: (value) => Validator.isEmail(value)
? null : _subtitle.emailValidateMessage,
onSaved: (value){
validator: (value) => Validator.isEmail(value) ? null : _subtitle.emailValidateMessage,
onSaved: (value) {
_user.email = value;
},
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
AbsorbPointer(
child: HospitalButton(
hospital: _user.hospital,
onHospitalPick: (hospital){
onHospitalPick: (hospital) {
_user.hospital = hospital;
setState(() {});
},
),
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
DepartmentButton(
department: _user.department,
onDepartmentPick: (department){
onDepartmentPick: (department) {
_user.department = department;
setState(() {});
},
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
ATextFormField(
initialValue: _user.phoneNumber,
hintText: _subtitle.phoneNumber,
style: Theme.of(context).textTheme.headline6,
prefixIconData: Icons.phone_android,
validator: (value) =>
Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
validator: (value) => Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
textInputType: TextInputType.phone,
onSaved: (value){
onSaved: (value) {
_user.phoneNumber = value;
},
),
SizedBox(height: 8,),
SizedBox(
height: 8,
),
ATextFormField(
initialValue: _user.whatsApp,
hintText: _subtitle.whatsApp,
style: Theme.of(context).textTheme.headline6,
prefixIconData: FontAwesomeIcons.whatsapp,
prefixIconSize: 36,
validator: (value) =>
Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
validator: (value) => Validator.isPhoneNumber(value) ? null : _subtitle.phoneNumberValidateMessage,
textInputType: TextInputType.phone,
onSaved: (value){
onSaved: (value) {
_user.whatsApp = value;
},
),
],
),
),
SizedBox(height: 16,),
SizedBox(
height: 16,
),
Center(
child: SizedBox(
height: _width / 8,
width: _width/1.2,
width: _width / 1.2,
child: AButton(
text: _subtitle.update,
onPressed: () async {
if(!_formKey.currentState.validate())
return;
if (!_formKey.currentState.validate()) return;
_formKey.currentState.save();
if(_user.department?.id == null){
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
_subtitle.unitRequired
),
)
);
if (_user.department?.id == null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(_subtitle.unitRequired),
));
return;
}
int status = await _userProvider.updateProfile(
user: _user,
host: _settingProvider.host,
);
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
_settingProvider.setUser(_userProvider.user);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
_subtitle.requestCompleteSuccessfully
),
)
);
}else{
String errorMessage = HttpStatusManger.getStatusMessage(
status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
errorMessage
),
)
);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(_subtitle.requestCompleteSuccessfully),
));
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(errorMessage),
));
}
},
),
),
),
SizedBox(height: 32,),
SizedBox(
height: 32,
),
],
),
),

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

@ -31,6 +31,7 @@ import 'package:test_sa/views/widgets/status/service_request/service_request_pri
import 'package:test_sa/views/widgets/status/service_request/service_request_through_mune.dart';
import 'package:test_sa/views/widgets/status/service_request/service_request_types_mune.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class CreateRequestPage extends StatefulWidget {
static final String id = "/create-request";
@ -136,40 +137,56 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
setState(() {});
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Priority"),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceRequestPriorityMenu(
initialValue: _serviceRequest.priority,
onSelect: (status){
onSelect: (status) {
_serviceRequest.priority = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Defect Type"),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceRequestDefectTypesMenu(
initialValue: _serviceRequest.defectType,
onSelect: (status){
onSelect: (status) {
_serviceRequest.defectType = status;
},
),
12.height,
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Type"),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceRequestTypesMenu(
initialValue: _serviceRequest.type,
onSelect: (status){
onSelect: (status) {
_serviceRequest.type = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Through"),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceRequestedThroughMenu(
initialValue: const Lookup(name: "App",value: 3),
onSelect: (status){
initialValue: const Lookup(name: "App", value: 3),
onSelect: (status) {
_serviceRequest.requestedThrough = status;
},
),
@ -210,9 +227,8 @@ class _CreateRequestPageState extends State<CreateRequestPage> {
_serviceRequest.deviceId = _device?.id ?? "";
_isLoading = true;
setState(() {});
_serviceRequest.devicePhotos = _deviceImages.map(
(e) => "${e.path.split("/").last}|${base64Encode(e.readAsBytesSync())}").toList();
if(_serviceRequest.audio != null){
_serviceRequest.devicePhotos = _deviceImages.map((e) => "${e.path.split("/").last}|${base64Encode(e.readAsBytesSync())}").toList();
if (_serviceRequest.audio != null) {
final file = File(_serviceRequest.audio);
_serviceRequest.audio = "${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}";
}

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

@ -37,18 +37,17 @@ import 'package:test_sa/views/widgets/status/report/service_report_type.dart';
import 'package:test_sa/views/widgets/status/report/service_status.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class CreateServiceReport extends StatefulWidget {
static final String id = "/create-service-report";
final ServiceRequest request ;
final ServiceRequest request;
const CreateServiceReport({Key key, this.request}) : super(key: key);
@override
_CreateServiceReportState createState() => _CreateServiceReportState();
}
class _CreateServiceReportState extends State<CreateServiceReport> with TickerProviderStateMixin{
class _CreateServiceReportState extends State<CreateServiceReport> with TickerProviderStateMixin {
UserProvider _userProvider;
SettingProvider _settingProvider;
ServiceRequestsProvider _serviceRequestsProvider;
@ -67,11 +66,10 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
@override
void initState() {
_serviceReport = ServiceReport(
visitDate: DateTime.now(),
//type: const Lookup(value: 2),
device: widget.request.device,
parts: []
);
visitDate: DateTime.now(),
//type: const Lookup(value: 2),
device: widget.request.device,
parts: []);
super.initState();
}
@ -81,6 +79,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
_workPreformedController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);
@ -102,52 +101,54 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
ListView(
children: [
//AppNameBar(),
const SizedBox(height: 16,),
const SizedBox(
height: 16,
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_subtitle.newServiceReport,
style: Theme.of(context).textTheme.headline5.copyWith(
color: AColors.cyan,
fontSize: 28,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
margin: const EdgeInsets.symmetric(horizontal: 16,vertical: 16),
decoration: BoxDecoration(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
const BoxShadow(
color: AColors.grey,
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
boxShadow: [
const BoxShadow(
color: AColors.grey,
offset: Offset(0,-1),
)
]
),
offset: Offset(0, -1),
)
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Wrap(
spacing: 10,
children: [
ASubTitle("${_subtitle.callId}: ${widget.request.requestCode}",font: 14,),
widget.request.deviceSerialNumber == null ? const SizedBox():
ASubTitle("${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",font: 14,),
ASubTitle(
"${_subtitle.callId}: ${widget.request.requestCode}",
font: 14,
),
widget.request.deviceSerialNumber == null
? const SizedBox()
: ASubTitle(
"${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",
font: 14,
),
Text(
"${_subtitle.customer}: ${widget.request.hospitalName}",
style: Theme.of(context).textTheme.subtitle1.copyWith(
fontWeight: FontWeight.bold,
fontSize: 12,
),
fontWeight: FontWeight.bold,
fontSize: 12,
),
textScaleFactor: AppStyle.getScaleFactor(context),
)
],
),
const Divider(),
@ -181,9 +182,12 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.visitDate),
_validate && _serviceReport.visitDate == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.visitDate == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
Row(
children: [
Expanded(
@ -191,7 +195,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
date: _serviceReport.visitDate,
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
onDatePicker: (date){
onDatePicker: (date) {
_serviceReport.visitDate = date;
setState(() {});
},
@ -202,10 +206,11 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
],
),
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// device sn
Visibility(
visible: widget.request.deviceSerialNumber == null,
@ -213,33 +218,47 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.deviceSN),
_validate && _serviceReport.device?.id == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.device?.id == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
AutoCompleteDeviceField(
hospitalId: widget.request.hospitalId,
initialValue: _serviceReport.device,
onPick: (id){
onPick: (id) {
_serviceReport.device.id = id;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
],
),
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.serviceType),
_validate && _serviceReport.assetType == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.assetType == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceAssetTypeMenu(
initialValue: _serviceReport.assetType,
onSelect: (status){
onSelect: (status) {
_serviceReport.assetType = status;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Report status and Service Type
Row(
children: [
@ -249,40 +268,51 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reportStatus),
_validate && _serviceReport.status == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.status == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportStatusMenu(
report: _serviceReport,
onSelect: (status){
onSelect: (status) {
_serviceReport.status = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
// Provider.of<ServiceReportLastCallsProvider>(context).isLoading == null
// ? const SizedBox.shrink():
// Call's last Situation
Consumer<ServiceReportLastCallsProvider>(
builder: (_, provider, __) {
if(provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
if (provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.callLastSituation),
_validate && _serviceReport.callLastSituation == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.callLastSituation == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportLastCallsMenu(
report: _serviceReport,
onSelect: (status){
if(status?.value == 12
|| _serviceReport.callLastSituation?.value == 12){
onSelect: (status) {
if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) {
_serviceReport.callLastSituation = status;
setState(() {});
} else {
@ -297,69 +327,83 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
],
),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
const ASubTitle("Assign Employee"),
const SizedBox(height: 8,),
_validate && _serviceReport.engineer == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
const SizedBox(
height: 8,
),
_validate && _serviceReport.engineer == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
EngineersMenu(
initialValue: _serviceReport.engineer,
onSelect: (engineer){
onSelect: (engineer) {
_serviceReport.engineer = engineer;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// invoice number & code
_serviceReport.callLastSituation?.id != 12 ? const SizedBox.shrink():
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
_serviceReport.callLastSituation?.id != 12
? const SizedBox.shrink()
: Row(
children: [
ASubTitle(_subtitle.invoiceNumber),
const SizedBox(height: 8,),
ATextFormField(
initialValue: _serviceReport?.invoiceNumber,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) =>
Validator.hasValue(value)
? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value){
_serviceReport.invoiceNumber = value;
},
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceNumber),
const SizedBox(
height: 8,
),
ATextFormField(
initialValue: _serviceReport?.invoiceNumber,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value) {
_serviceReport.invoiceNumber = value;
},
),
],
),
),
],
),
),
const SizedBox(width: 8,),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox(height: 4,),
ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) =>
Validator.hasValue(value)
? null : _subtitle.requiredWord,
textInputType: TextInputType.text,
onSaved: (value){
_serviceReport.invoiceCode = value;
},
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox(
height: 4,
),
ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.text,
onSaved: (value) {
_serviceReport.invoiceCode = value;
},
),
],
),
),
],
),
),
],
),
// const SizedBox(height: 8,),
// Row(
@ -421,7 +465,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ),
// const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
// reasons
@ -430,17 +476,21 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reasons),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status){
onSelect: (status) {
_serviceReport.reason = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -449,8 +499,8 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
AMiniOneImagePicker(
//error: _validate && _serviceReport.image == null,
image: _image,
onPick: (image){
_image =image;
onPick: (image) {
_image = image;
_serviceReport.image = "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}";
},
),
@ -459,7 +509,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Traveling Hours & Working Hours
Row(
children: [
@ -468,13 +520,15 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.workingHours),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
Expanded(
child: AppTimer(
timer: _serviceReport.timer,
onChange: (timer) async{
onChange: (timer) async {
_serviceReport.timer = timer;
return true;
},
@ -523,7 +577,9 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Operating Hours and Job Sheet Number
// Row(
// children: [
@ -571,29 +627,39 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
// ],
// ),
//const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Nurse Signature"),
ESignature(
oldSignature: _serviceReport.signatureNurse,
newSignature: _serviceReport.localNurseSignature,
onSaved: (signature){
if(signature == null || signature.isEmpty) {return;}
onSaved: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Engineer Signature"),
ESignature(
oldSignature: _serviceReport.signatureEngineer,
newSignature: _serviceReport.localNurseSignature,
onSaved: (signature){
if(signature == null || signature.isEmpty) {return;}
onSaved: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Part Number and Quantity
Row(
children: [
@ -603,45 +669,49 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.partNumber),
_validate && _serviceReport.parts == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.parts == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
AutoCompletePartsField(
onPick: (part){
onPick: (part) {
_serviceReport.parts.add(part);
},
),
],
),
),
],
),
SizedBox(height: 8*AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
Row(
children: [
Expanded(flex:3,child: Text(_subtitle.number)),
Expanded(flex: 1,child: Text(_subtitle.quantity)),
Expanded(flex: 3, child: Text(_subtitle.number)),
Expanded(flex: 1, child: Text(_subtitle.quantity)),
],
),
Column(
children: List.generate(
_serviceReport.parts.length,
(index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part){
_serviceReport.parts.remove(part);
setState(() {});
},
);
}
),
children: List.generate(_serviceReport.parts.length, (index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part) {
_serviceReport.parts.remove(part);
setState(() {});
},
);
}),
),
const SizedBox(
height: 16,
),
const SizedBox(height: 16,),
],
),
),
@ -651,47 +721,37 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
text: _subtitle.submit,
onPressed: () async {
_validate = true;
if(!_formKey.currentState.validate()){
if (!_formKey.currentState.validate()) {
setState(() {});
return;
}
if(!_serviceReport.validate()) return;
if (!_serviceReport.validate()) return;
_formKey.currentState.save();
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _serviceRequestsProvider.createServiceReport(
user: _userProvider.user,
host: _settingProvider.host,
report: _serviceReport,
request: widget.request
);
_isLoading =false;
int status = await _serviceRequestsProvider.createServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop();
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),
));
}
},
),
),
const SizedBox(height: 300,)
const SizedBox(
height: 300,
)
],
),
const ABackButton(),

@ -36,9 +36,10 @@ import 'package:test_sa/views/widgets/status/report/service_report_type.dart';
import 'package:test_sa/views/widgets/status/report/service_status.dart';
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class EditServiceReport extends StatefulWidget {
static final String id = "/edit-service-report";
final ServiceRequest request ;
final ServiceRequest request;
final ServiceReport report;
const EditServiceReport({Key key, this.request, this.report}) : super(key: key);
@ -46,9 +47,7 @@ class EditServiceReport extends StatefulWidget {
_EditServiceReportState createState() => _EditServiceReportState();
}
class _EditServiceReportState extends State<EditServiceReport> with TickerProviderStateMixin{
class _EditServiceReportState extends State<EditServiceReport> with TickerProviderStateMixin {
UserProvider _userProvider;
SettingProvider _settingProvider;
ServiceRequestsProvider _serviceRequestsProvider;
@ -76,6 +75,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_workPreformedController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);
@ -97,52 +97,54 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
ListView(
children: [
//AppNameBar(),
const SizedBox(height: 16,),
const SizedBox(
height: 16,
),
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_subtitle.editServiceReport,
style: Theme.of(context).textTheme.headline5.copyWith(
color: AColors.cyan,
fontSize: 28,
fontWeight: FontWeight.bold
),
style: Theme.of(context).textTheme.headline5.copyWith(color: AColors.cyan, fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
margin: const EdgeInsets.symmetric(horizontal: 16,vertical: 16),
decoration: BoxDecoration(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: [
const BoxShadow(
color: AColors.grey,
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
boxShadow: [
const BoxShadow(
color: AColors.grey,
offset: Offset(0,-1),
)
]
),
offset: Offset(0, -1),
)
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Wrap(
spacing: 10,
children: [
ASubTitle("${_subtitle.callId}: ${widget.request.requestCode}",font: 14,),
widget.request.deviceSerialNumber == null ? const SizedBox():
ASubTitle("${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",font: 14,),
ASubTitle(
"${_subtitle.callId}: ${widget.request.requestCode}",
font: 14,
),
widget.request.deviceSerialNumber == null
? const SizedBox()
: ASubTitle(
"${_subtitle.deviceSN}: ${widget.request.deviceSerialNumber}",
font: 14,
),
Text(
"${_subtitle.customer}: ${widget.request.hospitalName}",
style: Theme.of(context).textTheme.subtitle1.copyWith(
fontWeight: FontWeight.bold,
fontSize: 12,
),
fontWeight: FontWeight.bold,
fontSize: 12,
),
textScaleFactor: AppStyle.getScaleFactor(context),
)
],
),
const Divider(),
@ -156,29 +158,39 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reportType),
_validate && _serviceReport.type == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.type == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportTypeMenu(
initialValue: _serviceReport.type,
onSelect: (status){
onSelect: (status) {
_serviceReport.type = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
// visit date
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.visitDate),
_validate && _serviceReport.visitDate == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.visitDate == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
Row(
children: [
Expanded(
@ -186,7 +198,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
date: _serviceReport.visitDate,
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
onDatePicker: (date){
onDatePicker: (date) {
_serviceReport.visitDate = date;
setState(() {});
},
@ -197,58 +209,84 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
],
),
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// device sn
Visibility(
visible: true,//widget.report.device == null,
visible: true, //widget.report.device == null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.deviceSN),
_validate && _serviceReport.device?.id == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
_validate && _serviceReport.device?.id == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
AutoCompleteDeviceField(
hospitalId: widget.request.hospitalId,
initialValue: _serviceReport.device,
onPick: (id){
onPick: (id) {
_serviceReport.device.id = id;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
],
),
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.serviceType),
_validate && _serviceReport.assetType == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.assetType == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceAssetTypeMenu(
initialValue: _serviceReport.assetType,
onSelect: (status){
onSelect: (status) {
_serviceReport.assetType = status;
},
),
const SizedBox(height: 8,),
SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
const SizedBox(
height: 8,
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
const ASubTitle("Assign Employee"),
const SizedBox(height: 8,),
_validate && _serviceReport.engineer == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
const SizedBox(
height: 8,
),
_validate && _serviceReport.engineer == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
EngineersMenu(
initialValue: _serviceReport.engineer,
onSelect: (engineer){
onSelect: (engineer) {
_serviceReport.engineer = engineer;
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Report status and Service Type
Row(
children: [
@ -258,37 +296,48 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reportStatus),
_validate && _serviceReport.status == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.status == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportStatusMenu(
report: _serviceReport,
onSelect: (status){
onSelect: (status) {
_serviceReport.status = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
Consumer<ServiceReportLastCallsProvider>(
builder: (_, provider, __) {
if(provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
if (provider.isLoading == null) return const SizedBox.shrink();
return Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.callLastSituation),
_validate && _serviceReport.callLastSituation == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.callLastSituation == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
ServiceReportLastCallsMenu(
report: _serviceReport,
onSelect: (status){
if(status?.value == 12
|| _serviceReport.callLastSituation?.value == 12){
onSelect: (status) {
if (status?.value == 12 || _serviceReport.callLastSituation?.value == 12) {
_serviceReport.callLastSituation = status;
setState(() {});
} else {
@ -303,56 +352,61 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// invoice number & code
_serviceReport.callLastSituation?.value != 12 ? const SizedBox.shrink():
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
_serviceReport.callLastSituation?.value != 12
? const SizedBox.shrink()
: Row(
children: [
ASubTitle(_subtitle.invoiceNumber),
const SizedBox(height: 8,),
ATextFormField(
initialValue: _serviceReport?.invoiceNumber,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) =>
Validator.hasValue(value)
? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value){
_serviceReport.invoiceNumber = value;
},
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceNumber),
const SizedBox(
height: 8,
),
ATextFormField(
initialValue: _serviceReport?.invoiceNumber,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.number,
onSaved: (value) {
_serviceReport.invoiceNumber = value;
},
),
],
),
),
],
),
),
const SizedBox(width: 8,),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox(height: 4,),
ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) =>
Validator.hasValue(value)
? null : _subtitle.requiredWord,
textInputType: TextInputType.text,
onSaved: (value){
_serviceReport.invoiceCode = value;
},
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.invoiceCode),
const SizedBox(
height: 4,
),
ATextFormField(
initialValue: _serviceReport?.invoiceCode,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
validator: (value) => Validator.hasValue(value) ? null : _subtitle.requiredWord,
textInputType: TextInputType.text,
onSaved: (value) {
_serviceReport.invoiceCode = value;
},
),
],
),
),
],
),
),
],
),
// const SizedBox(height: 8,),
// Row(
@ -414,7 +468,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ),
// const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
// reasons
@ -423,17 +479,21 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reasons),
const SizedBox(height: 4,),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status){
onSelect: (status) {
_serviceReport.reason = status;
},
),
],
),
),
const SizedBox(width: 8,),
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@ -442,8 +502,8 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
AMiniOneImagePicker(
//error: _validate && _serviceReport.image == null,
image: _image,
onPick: (image){
_image =image;
onPick: (image) {
_image = image;
_serviceReport.image = base64Encode(image.readAsBytesSync());
},
),
@ -452,7 +512,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Traveling Hours & Working Hours
Row(
children: [
@ -461,13 +523,15 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.workingHours),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
Row(
children: [
Expanded(
child: AppTimer(
timer: _serviceReport.timer,
onChange: (timer) async{
onChange: (timer) async {
_serviceReport.timer = timer;
return true;
},
@ -516,7 +580,9 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ),
],
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Operating Hours and Job Sheet Number
// Row(
// children: [
@ -564,29 +630,39 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
// ],
// ),
//const SizedBox(height: 8,),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Nurse Signature"),
ESignature(
oldSignature: _serviceReport.signatureNurse,
newSignature: _serviceReport.localNurseSignature,
onChange: (signature){
if(signature == null || signature.isEmpty) {return;}
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureNurse = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
const ASubTitle("Engineer Signature"),
ESignature(
oldSignature: _serviceReport.signatureEngineer,
newSignature: _serviceReport.localNurseSignature,
onChange: (signature){
if(signature == null || signature.isEmpty) {return;}
onChange: (signature) {
if (signature == null || signature.isEmpty) {
return;
}
_serviceReport.localNurseSignature = signature;
_serviceReport.signatureEngineer = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
},
),
const SizedBox(height: 8,),
const SizedBox(
height: 8,
),
// Part Number and Quantity
Row(
children: [
@ -596,12 +672,17 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.partNumber),
_validate && _serviceReport.parts == null ?
ASubTitle(_subtitle.requiredWord,color: Colors.red,):
const SizedBox.shrink(),
const SizedBox(height: 4,),
_validate && _serviceReport.parts == null
? ASubTitle(
_subtitle.requiredWord,
color: Colors.red,
)
: const SizedBox.shrink(),
const SizedBox(
height: 4,
),
AutoCompletePartsField(
onPick: (part){
onPick: (part) {
_serviceReport.parts.add(part);
setState(() {});
},
@ -609,34 +690,33 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
],
),
),
],
),
SizedBox(height: 8*AppStyle.getScaleFactor(context),),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
Row(
children: [
Expanded(flex:3,child: Text(_subtitle.number)),
Expanded(flex: 1,child: Text(_subtitle.quantity)),
Expanded(flex: 3, child: Text(_subtitle.number)),
Expanded(flex: 1, child: Text(_subtitle.quantity)),
],
),
Column(
children: List.generate(
_serviceReport.parts.length,
(index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part){
_serviceReport.parts.remove(part);
setState(() {});
},
);
}
),
children: List.generate(_serviceReport.parts.length, (index) {
Part _part = _serviceReport.parts[index];
return PartItem(
part: _part,
onDelete: (part) {
_serviceReport.parts.remove(part);
setState(() {});
},
);
}),
),
const SizedBox(height: 16,),
const SizedBox(
height: 16,
),
],
),
),
@ -646,48 +726,40 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
text: _subtitle.update,
onPressed: () async {
_validate = true;
if(!_formKey.currentState.validate()){
if (!_formKey.currentState.validate()) {
setState(() {});
return;
}
if(!_serviceReport.validate()) {
if (!_serviceReport.validate()) {
setState(() {});
return;
}
_formKey.currentState.save();
_isLoading =true;
_isLoading = true;
setState(() {});
int status = await _serviceRequestsProvider.updateServiceReport(
user: _userProvider.user,
host: _settingProvider.host,
report: _serviceReport,
request: widget.request
);
_isLoading =false;
int status = await _serviceRequestsProvider.updateServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
if (status >= 200 && status < 300) {
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
msg: _subtitle.requestCompleteSuccessfully,
);
Navigator.of(context).pop();
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),
));
}
},
),
),
const SizedBox(height: 300,)
const SizedBox(
height: 300,
)
],
),
const ABackButton(),

@ -12,14 +12,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/requests/service_request_list.dart';
import 'package:test_sa/views/widgets/search/service_request_search_bar.dart';
class ServiceRequestsPage extends StatefulWidget {
static final String id = "/service-requests";
@override
_ServiceRequestsPageState createState() => _ServiceRequestsPageState();
}
class _ServiceRequestsPageState extends State<ServiceRequestsPage>
with TickerProviderStateMixin{
class _ServiceRequestsPageState extends State<ServiceRequestsPage> with TickerProviderStateMixin {
ServiceRequestsProvider _serviceRequestsProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
@ -31,7 +31,7 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
Subtitle _subtitle = AppLocalization.of(context).subtitle;
if(_firstTime){
if (_firstTime) {
_serviceRequestsProvider.reset();
_firstTime = false;
}
@ -45,9 +45,9 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
onRefresh: () async {
_serviceRequestsProvider.reset();
await _serviceRequestsProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital?.id,
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital?.id,
);
},
child: Stack(
@ -55,8 +55,8 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
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(
@ -66,10 +66,7 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
child: Center(
child: Text(
_subtitle.serviceRequests,
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),
),
),
),
@ -83,22 +80,23 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
ServiceRequestSearch _temp = await showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context){
builder: (context) {
return ServiceRequestsSearchDialog(
initialSearchValue: _serviceRequestsProvider.search,
);
});
if(_temp != null){
if (_temp != null) {
_serviceRequestsProvider.search = _temp;
_serviceRequestsProvider.reset();
setState(() {});
}
},
),
SizedBox(width: 16,)
SizedBox(
width: 16,
)
],
),
],
),
),
@ -107,9 +105,9 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
nextPage: _serviceRequestsProvider.nextPage,
onLazyLoad: () async {
await _serviceRequestsProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital.id,
user: _userProvider.user,
host: _settingProvider.host,
hospitalId: _userProvider.user.hospital.id,
);
},
requests: _serviceRequestsProvider.serviceRequests,
@ -117,7 +115,6 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage>
),
],
),
],
),
),

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

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

Loading…
Cancel
Save