Merge remote-tracking branch 'origin/majd_development_new' into zaid_development_new

# Conflicts:
#	lib/models/visits/visits_search.dart
#	lib/views/pages/device_transfer/device_transfer_details.dart
#	lib/views/pages/user/gas_refill/request_gas_refill.dart
#	lib/views/widgets/device_trancfer/device_transfer_info_section.dart
#	lib/views/widgets/search/service_request_search_bar.dart
#	lib/views/widgets/search/visits_search_bar.dart
main_design2.0
zaid_daoud 2 years ago
commit 984f46913a

@ -1,5 +1,7 @@
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http/http.dart' as http;
@ -21,7 +23,6 @@ class ApiManager {
Future<http.Response> get(
String url, {
Map<String, String> headers,
enableToastMessage = true,
}) async {
headers ??= {};
@ -33,7 +34,7 @@ class ApiManager {
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 && enableToastMessage) {
if (message != null && message.toString().isNotEmpty) {
Fluttertoast.showToast(msg: message ?? "", toastLength: Toast.LENGTH_LONG);
}
}

@ -87,7 +87,6 @@ class URLs {
static get requestDeviceTransfer => "$_baseUrl/AssetTransfer/AddAssetTransfer"; // get
static get updateDeviceTransfer => "$_baseUrl/AssetTransfer/UpdateAssetTransfer"; // get
static get getDeviceTransfer => "$_baseUrl/AssetTransfer/GetAssetTransfers"; // get
static get getAssetTransferById => "$_baseUrl/AssetTransfer/GetAssetTransferById"; // get
// employee
static get getEmployees => "$_baseUrl/Lookups/GetLookup?lookupEnum=33"; // get

@ -60,11 +60,9 @@ class DeviceTransferProvider extends ChangeNotifier {
Future<int> getRequests({
@required String host,
@required User user,
bool mostRecent,
}) async {
if (isLoading == true) return -2;
isLoading = true;
notifyListeners();
Response response;
try {
Map<String, dynamic> body = {};
@ -83,7 +81,6 @@ class DeviceTransferProvider extends ChangeNotifier {
List<DeviceTransfer> itemsPage = listJson.map((request) => DeviceTransfer.fromJson(request)).toList();
items ??= [];
items.addAll(itemsPage);
sortMostRecent(items, mostRecent);
print(listJson);
if (itemsPage.length == pageItemNumber) {
nextPage = true;
@ -102,30 +99,6 @@ class DeviceTransferProvider extends ChangeNotifier {
}
}
void sortMostRecent(List<DeviceTransfer> transfer, bool mostRecent) {
if (mostRecent != null) {
transfer.sort((prev, next) =>
(mostRecent ?? false) ? DateTime.tryParse(next.createdOn).compareTo(DateTime.tryParse(prev.createdOn)) : DateTime.tryParse(prev.createdOn).compareTo(DateTime.tryParse(next.createdOn)));
}
}
Future<DeviceTransfer> getRequestById({int assetTransferId}) async {
Response response;
try {
response = await ApiManager.instance.get(
URLs.getAssetTransferById + "?assetTransferId=$assetTransferId",
enableToastMessage: false,
);
if (response.statusCode >= 200 && response.statusCode < 300) {
return DeviceTransfer.fromJson(json.decode(response.body)["data"]);
}
return null;
} catch (error) {
print(error);
return null;
}
}
Future<int> createRequest({
@required String host,
@required User user,

@ -17,20 +17,25 @@ class DevicesProvider extends ChangeNotifier {
final pageItemNumber = 10;
bool nextPage = true;
// state code of current request to defied error message
// like 400 customer request failed
// 500 service not available
int _stateCode;
int get stateCode => _stateCode;
List<Device> _devices = [];
List<Device> get devices => _devices;
// when categories in-process _loading = true
// done _loading = true
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
@ -70,7 +75,7 @@ class DevicesProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List equipmentListJson = json.decode(response.body)["data"];
_devices.addAll(equipmentListJson.map<Device>((device) => Device.fromJson(device, startKeyWithDest: false)).toList());
_devices.addAll(equipmentListJson.map<Device>((device) => Device.fromJson(device)).toList());
nextPage = true;
} else {
nextPage = false;
@ -111,8 +116,8 @@ class DevicesProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
List equipmentListJson = json.decode(response.body)["data"];
page = equipmentListJson.map((device) => Device.fromJson(device, startKeyWithDest: false)).toList();
_devices.addAll(equipmentListJson.map<Device>((device) => Device.fromJson(device, startKeyWithDest: false)).toList());
page = equipmentListJson.map((device) => Device.fromJson(device)).toList();
_devices.addAll(equipmentListJson.map<Device>((device) => Device.fromJson(device)).toList());
notifyListeners();
}
return page;
@ -147,31 +152,31 @@ class DevicesProvider extends ChangeNotifier {
}
}
// /// 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<List<Device>> getDevicesListBySN({@required String host, @required User user, @required int hospitalId, @required String sn}) async {
// Response response;
// try {
// response = await get(
// Uri.parse(URLs.getEquipment + "?client=$hospitalId" + (sn == null || sn.isEmpty ? "" : "&serial_qr=$sn")),
// );
//
// _stateCode = response.statusCode;
// List<Device> _page = [];
// if (response.statusCode >= 200 && response.statusCode < 300) {
// // client's request was successfully received
// List categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
// _page = categoriesListJson.map((device) => Device.fromJson(device)).toList();
// }
// return _page;
// } catch (error) {
// _loading = false;
// _stateCode = -1;
// notifyListeners();
// return [];
// }
// }
// /// 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<List<Device>> getDevicesListBySN({@required String host, @required User user, @required int hospitalId, @required String sn}) async {
// Response response;
// try {
// response = await get(
// Uri.parse(URLs.getEquipment + "?client=$hospitalId" + (sn == null || sn.isEmpty ? "" : "&serial_qr=$sn")),
// );
//
// _stateCode = response.statusCode;
// List<Device> _page = [];
// if (response.statusCode >= 200 && response.statusCode < 300) {
// // client's request was successfully received
// List categoriesListJson = json.decode(utf8.decode(response.bodyBytes));
// _page = categoriesListJson.map((device) => Device.fromJson(device)).toList();
// }
// return _page;
// } catch (error) {
// _loading = false;
// _stateCode = -1;
// notifyListeners();
// return [];
// }
// }
}

@ -6,7 +6,6 @@ import 'package:test_sa/controllers/api_routes/api_manager.dart';
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/hospital.dart';
import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/models/user.dart';
class GasRefillProvider extends ChangeNotifier {
@ -48,11 +47,9 @@ class GasRefillProvider extends ChangeNotifier {
Future<int> getRequests({
@required String host,
@required User user,
bool mostRecent,
}) async {
if (isLoading == true) return -2;
isLoading = true;
notifyListeners();
Response response;
Map<String, dynamic> body = {};
@ -69,13 +66,8 @@ class GasRefillProvider extends ChangeNotifier {
// client's request was successfully received
List requestsListJson = json.decode(response.body)["data"];
List<GasRefillModel> itemsPage = requestsListJson.map((request) => GasRefillModel.fromJson(request)).toList();
if (mostRecent != null) {
items = [];
} else {
items ??= [];
}
items ??= [];
items.addAll(itemsPage);
sortMostRecent(items, mostRecent);
if (itemsPage.length == pageItemNumber) {
nextPage = true;
} else {
@ -94,17 +86,12 @@ class GasRefillProvider extends ChangeNotifier {
}
}
void sortMostRecent(List<GasRefillModel> models, bool mostRecent) {
if (mostRecent != null) {
models.sort((prev, next) => (mostRecent ?? false) ? next.title.compareTo(prev.title) : prev.title.compareTo(next.title));
}
}
Future<int> createModel({
@required String host,
@required User user,
@required GasRefillModel model,
}) async {
print("ss");
Map<String, dynamic> body = {
"uid": user.id.toString(),
"token": user.token ?? "",
@ -121,6 +108,7 @@ class GasRefillProvider extends ChangeNotifier {
"GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}",
"status": model.status.toMap(),
};
print("ss1");
body["gazRefillDetails"] = model.details
.map((model) => {
"gasType": model.type.toMap(),
@ -133,6 +121,7 @@ class GasRefillProvider extends ChangeNotifier {
Response response;
try {
response = await ApiManager.instance.post(URLs.requestGasRefill, body: body);
print("ss2");
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
if (items != null) {
@ -157,14 +146,13 @@ class GasRefillProvider extends ChangeNotifier {
"id": newModel.id,
"gazRefillNo": newModel.title ?? "",
"status": newModel.status.toMap(),
"expectedDate": newModel.expectedDate?.toIso8601String(),
"expectedTime": newModel.expectedDate?.toIso8601String(),
"startDate": newModel.startDate?.toIso8601String(),
"startTime": newModel.startDate?.toIso8601String(),
"endDate": newModel.endDate?.toIso8601String(),
"endTime": newModel.endDate?.toIso8601String(),
// "workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60),
'workingHours': newModel.workingHours,
"expectedDate": oldModel.expectedDate?.toIso8601String(),
"expectedTime": oldModel.expectedDate?.toIso8601String(),
"startDate": startDate?.toIso8601String(),
"startTime": startDate?.toIso8601String(),
"endDate": endDate?.toIso8601String(),
"endTime": endDate?.toIso8601String(),
"workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60),
"assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(),
"site": hospital?.toMap(),
"building": building?.toJson(includeFloors: false),
@ -210,5 +198,4 @@ class GasRefillProvider extends ChangeNotifier {
DateTime expectedDateTime;
DateTime startDate;
DateTime endDate;
TimerModel timer;
}

@ -22,22 +22,27 @@ class HospitalsProvider extends ChangeNotifier {
// like 400 customer request failed
// 500 service not available
int _stateCode;
int get stateCode => _stateCode;
// true if there is next page in product list and false if not
bool _nextPage = true;
bool get nextPage => _nextPage;
// contain user data
// when user not login or register _user = null
List<Hospital> _hospitals;
List<Hospital> get hospitals => _hospitals;
// when categories in-process _loading = true
// done _loading = true
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();

@ -22,22 +22,27 @@ class PartsProvider extends ChangeNotifier {
// like 400 customer request failed
// 500 service not available
int _stateCode;
int get stateCode => _stateCode;
// true if there is next page in product list and false if not
bool _nextPage = true;
bool get nextPage => _nextPage;
// contain user data
// when user not login or register _user = null
List<Part> _parts;
List<Part> get parts => _parts;
// when categories in-process _loading = true
// done _loading = true
// failed _loading = false
bool _loading;
bool get isLoading => _loading;
set isLoading(bool isLoading) {
_loading = isLoading;
notifyListeners();
@ -88,7 +93,10 @@ class PartsProvider extends ChangeNotifier {
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});
if (int.tryParse(title) != null)
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partNo": title});
else
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

@ -79,7 +79,6 @@ class RegularVisitsProvider extends ChangeNotifier {
List requestsListJson = json.decode(response.body)["data"];
List<Visit> _visits = requestsListJson.map((request) => Visit.fromJson(request)).toList();
visits ??= [];
sortMostRecent(_visits);
visits.addAll(_visits);
if (_visits.length == pageItemNumber) {
nextPage = true;
@ -99,12 +98,6 @@ class RegularVisitsProvider extends ChangeNotifier {
return response.statusCode;
}
void sortMostRecent(List<Visit> visits) {
visits.sort((prev, next) => (visitsSearch.mostRecent ?? false)
? DateTime.tryParse(next.createdOn).compareTo(DateTime.tryParse(prev.createdOn))
: DateTime.tryParse(prev.createdOn).compareTo(DateTime.tryParse(next.createdOn)));
}
/// 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

@ -76,7 +76,6 @@ class ServiceRequestsProvider extends ChangeNotifier {
List requestsListJson = json.decode(response.body)["data"];
List<ServiceRequest> serviceRequestsPage = requestsListJson.map((request) => ServiceRequest.fromJson(request)).toList();
serviceRequests ??= [];
sortMostRecent(serviceRequestsPage);
serviceRequests.addAll(serviceRequestsPage);
if (serviceRequestsPage.length == pageItemNumber) {
nextPage = true;
@ -95,12 +94,6 @@ class ServiceRequestsProvider extends ChangeNotifier {
}
}
void sortMostRecent(List<ServiceRequest> requests) {
requests.sort(
(prev, next) => (search.mostRecent ?? false) ? DateTime.tryParse(next.date).compareTo(DateTime.tryParse(prev.date)) : DateTime.tryParse(prev.date).compareTo(DateTime.tryParse(next.date)),
);
}
Future<ServiceRequest> getSingleServiceRequest({
@required String requestId,
@required String host,

@ -13,6 +13,7 @@ class Device {
String destRoom;
String destFloor;
String destSiteName;
// String brand;
// String model;
ModelDefinition modelDefinition;
@ -34,7 +35,7 @@ class Device {
this.modelDefinition,
});
factory Device.fromJson(Map<String, dynamic> parsedJson, {bool startKeyWithDest = true}) {
factory Device.fromJson(Map<String, dynamic> parsedJson) {
print("parsedJson:$parsedJson");
return Device(
id: parsedJson["id"],
@ -43,10 +44,10 @@ class Device {
assetName: parsedJson["assetName"],
modelDefinition: ModelDefinition.fromJson(parsedJson["modelDefinition"]),
hospital: Hospital.fromJson(parsedJson["site"]),
destBuildingName: startKeyWithDest ? parsedJson["destBuildingName"] : parsedJson['building']['name'],
destDepartmentName: startKeyWithDest ? parsedJson["destDepartmentName"] : parsedJson['department']['departmentName'],
destRoom: startKeyWithDest ? parsedJson["destRoom"] : parsedJson['room'],
destFloor: startKeyWithDest ? parsedJson["destFloor"] : parsedJson['floor']['name'],
destBuildingName: parsedJson["destBuildingName"],
destDepartmentName: parsedJson["destDepartmentName"],
destRoom: parsedJson["destRoom"],
destFloor: parsedJson["destFloor"],
destSiteName: parsedJson['destSiteName']
// parsedJson["modelDefinition"] == null ? "" :
// parsedJson["modelDefinition"]["manufacturerName"],

@ -14,7 +14,6 @@ class DeviceTransfer {
Device device;
DeviceTransferInfo sender;
DeviceTransferInfo receiver;
String createdOn;
DeviceTransfer({
this.id,
@ -23,7 +22,6 @@ class DeviceTransfer {
this.userId,
this.sender,
this.receiver,
this.createdOn,
});
bool validate() {
@ -42,7 +40,6 @@ class DeviceTransfer {
final receiver = DeviceTransferInfo();
receiver.fromDetails(old.receiver);
this.receiver = receiver;
createdOn = old.createdOn;
}
factory DeviceTransfer.fromJson(Map<String, dynamic> parsedJson) {
@ -50,7 +47,6 @@ class DeviceTransfer {
id: parsedJson["id"],
title: parsedJson["transferCode"],
userId: parsedJson["uid"],
createdOn: parsedJson['createdOn'],
device: Device(
id: parsedJson["assetId"],
number: parsedJson["assetNumber"],

@ -10,6 +10,7 @@ class DeviceTransferInfo {
Hospital client;
Department department;
String workingHours;
// DateTime startDate;
// DateTime endDate;
String travelingHours;

@ -8,6 +8,7 @@ import '../call_request_for_work_order_model.dart';
class GasRefillModel {
int id;
//String userId;
String clientName;
String title;
@ -21,7 +22,7 @@ class GasRefillModel {
String signatureEngineer;
Uint8List localNurseSignature;
Uint8List localEngineerSignature;
num workingHours;
DateTime startDate, endDate, expectedDate;
GasRefillModel({
@ -42,7 +43,6 @@ class GasRefillModel {
this.signatureEngineer,
this.localEngineerSignature,
this.localNurseSignature,
this.workingHours,
});
bool validate() {
@ -75,7 +75,6 @@ class GasRefillModel {
localNurseSignature = model.localNurseSignature;
signatureEngineer = model.signatureEngineer;
signatureNurse = model.signatureNurse;
workingHours = model.workingHours;
}
factory GasRefillModel.fromJson(Map<String, dynamic> parsedJson) {
@ -100,7 +99,6 @@ class GasRefillModel {
assignedEmployee: AssignedEmployee.fromJson(parsedJson['assignedEmployee'] ?? {}),
signatureEngineer: URLs.getFileUrl(parsedJson["engSignature"]),
signatureNurse: URLs.getFileUrl(parsedJson["nurseSignature"]),
workingHours: parsedJson["workingHours"],
);
}
}

@ -19,6 +19,7 @@ class Pentry {
String travelingHours;
String image;
File imageFile;
// List<Contact> contacts;
List<PPMCheckList> ppmCheckLists;
List<CalibrationTool> calibrationTools;

@ -14,6 +14,8 @@ class ServiceReport {
int id;
double operatingHours;
DateTime visitDate;
DateTime returnToService;
// DateTime endDate;
// DateTime startDate;
Lookup assetType;
@ -32,7 +34,7 @@ class ServiceReport {
String invoiceNumber;
String invoiceCode;
List<Part> parts;
String image;
List<String> image;
Device device;
String quantity;
String jobSheetNumber;
@ -80,12 +82,15 @@ class ServiceReport {
// this.startDate,
this.reviewComment,
this.faultDescription,
this.returnToService
});
Map<String, dynamic> toMap(ServiceRequest request) {
Map<String, dynamic> _map = {};
if (id != null) _map["id"] = id;
if (visitDate != null) _map["visitDate"] = visitDate.toIso8601String();
if (returnToService != null) _map["replacementDate"] = returnToService.toIso8601String();
//if(serviceType != null) _map["service_type"] = serviceType.id.toString();
if (equipmentStatus != null) _map["equipmentStatus"] = equipmentStatus?.toMap();
if (type != null) _map["typeOfWO"] = type?.toMap();
@ -133,9 +138,8 @@ class ServiceReport {
//if(invoiceCode != null) _map["invoice_no"] = invoiceCode;
//if(invoiceNumber != null) _map["invoice_code"] = invoiceNumber;
if (image != null) {
_map["attachmentsWorkOrder"] = [
{"name": image}
];
_map["attachmentsWorkOrder"] = image.map((e) => {"name": e}).toList();
print(_map["attachmentsWorkOrder"]);
}
_map["nurseSignature"] = signatureNurse;
_map["engSignature"] = signatureEngineer;
@ -161,6 +165,10 @@ class ServiceReport {
await Fluttertoast.showToast(msg: "Visit Date Required");
return false;
}
if (returnToService == null) {
await Fluttertoast.showToast(msg: "return To Service Date Required");
return false;
}
if (timer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
@ -220,6 +228,7 @@ class ServiceReport {
travelingHours: parsedJson["travelingHours"],
travelingExpense: parsedJson["travelingExpenses"],
visitDate: DateTime.tryParse(parsedJson["visitDate"]),
returnToService: DateTime.tryParse(parsedJson["replacementDate"]??""),
workingHours: parsedJson["workingHours"],
timer: TimerModel(
startAt: DateTime.tryParse(parsedJson["startofWorkTime"] ?? ""),

@ -163,6 +163,7 @@ class SearchWorkOrder {
Lookup currentSituation;
Lookup repairLocation;
Lookup reason;
// String startofWorkTime;
// String endofWorkTime;
num workingHours;
@ -250,6 +251,7 @@ class SearchWorkOrder {
woParentDto: woParentDto ?? this.woParentDto,
timer: timer ?? this.timer,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -352,6 +354,7 @@ class WoParentDto {
equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null;
}
Lookup callLastSituation;
SupplierModel supplier;
Lookup assetType;
@ -362,6 +365,7 @@ class WoParentDto {
List<SuppEngineerWorkOrders> suppEngineerWorkOrders;
Lookup equipmentStatus;
Lookup currentSituation;
WoParentDto copyWith({
Lookup callLastSituation,
SupplierModel supplier,
@ -386,6 +390,7 @@ class WoParentDto {
equipmentStatus: equipmentStatus ?? this.equipmentStatus,
currentSituation: currentSituation ?? this.currentSituation,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (callLastSituation != null) {
@ -436,6 +441,7 @@ class SuppEngineerWorkOrders {
externalEngCode = json['externalEngCode'];
email = json['email'];
}
num id;
num supplierContactId;
String personName;
@ -443,6 +449,7 @@ class SuppEngineerWorkOrders {
String contact;
String externalEngCode;
String email;
SuppEngineerWorkOrders copyWith({
num id,
num supplierContactId,
@ -461,6 +468,7 @@ class SuppEngineerWorkOrders {
externalEngCode: externalEngCode ?? this.externalEngCode,
email: email ?? this.email,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -496,6 +504,7 @@ class StepsWorkOrderDto {
parentWOId = json['parentWOId'];
callId = json['callId'];
}
num sequence;
num id;
String name;
@ -504,6 +513,7 @@ class StepsWorkOrderDto {
bool processed;
num parentWOId;
num callId;
StepsWorkOrderDto copyWith({
num sequence,
num id,
@ -524,6 +534,7 @@ class StepsWorkOrderDto {
parentWOId: parentWOId ?? this.parentWOId,
callId: callId ?? this.callId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['sequence'] = sequence;
@ -612,6 +623,7 @@ class SupplierModel {
});
}
}
num id;
String suppliername;
String name;
@ -631,6 +643,7 @@ class SupplierModel {
List<Attachments> attachments;
List<SuppPersons> suppPersons;
List<SuppTCodes> suppTCodes;
SupplierModel copyWith({
num id,
String suppliername,
@ -673,6 +686,7 @@ class SupplierModel {
suppPersons: suppPersons ?? this.suppPersons,
suppTCodes: suppTCodes ?? this.suppTCodes,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -724,10 +738,12 @@ class SuppTCodes {
codeTypeId = json['codeTypeId'];
codeValue = json['codeValue'];
}
num id;
num supplierId;
num codeTypeId;
String codeValue;
SuppTCodes copyWith({
num id,
num supplierId,
@ -740,6 +756,7 @@ class SuppTCodes {
codeTypeId: codeTypeId ?? this.codeTypeId,
codeValue: codeValue ?? this.codeValue,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -770,6 +787,7 @@ class SuppPersons {
externalEngCode = json['externalEngCode'];
email = json['email'];
}
num id;
num supplierId;
String personName;
@ -777,6 +795,7 @@ class SuppPersons {
String contact;
String externalEngCode;
String email;
SuppPersons copyWith({
num id,
num supplierId,
@ -795,6 +814,7 @@ class SuppPersons {
externalEngCode: externalEngCode ?? this.externalEngCode,
email: email ?? this.email,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -822,10 +842,12 @@ class Attachments {
attachmentName = json['attachmentName'];
attachmentURL = json['attachmentURL'];
}
num id;
num supplierId;
String attachmentName;
String attachmentURL;
Attachments copyWith({
num id,
num supplierId,
@ -838,6 +860,7 @@ class Attachments {
attachmentName: attachmentName ?? this.attachmentName,
attachmentURL: attachmentURL ?? this.attachmentURL,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -860,9 +883,11 @@ class Addresses {
supplierId = json['supplierId'];
address = json['address'];
}
num id;
num supplierId;
String address;
Addresses copyWith({
num id,
num supplierId,
@ -873,6 +898,7 @@ class Addresses {
supplierId: supplierId ?? this.supplierId,
address: address ?? this.address,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -894,9 +920,11 @@ class Faxes {
supplierId = json['supplierId'];
fax = json['fax'];
}
num id;
num supplierId;
String fax;
Faxes copyWith({
num id,
num supplierId,
@ -907,6 +935,7 @@ class Faxes {
supplierId: supplierId ?? this.supplierId,
fax: fax ?? this.fax,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -928,9 +957,11 @@ class Telephones {
supplierId = json['supplierId'];
telephone = json['telephone'];
}
num id;
num supplierId;
String telephone;
Telephones copyWith({
num id,
num supplierId,
@ -941,6 +972,7 @@ class Telephones {
supplierId: supplierId ?? this.supplierId,
telephone: telephone ?? this.telephone,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -960,8 +992,10 @@ class AttachmentsWorkOrder {
id = json['id'];
name = json['name'];
}
num id;
String name;
AttachmentsWorkOrder copyWith({
num id,
String name,
@ -970,6 +1004,7 @@ class AttachmentsWorkOrder {
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -994,11 +1029,13 @@ class SparePartsWorkOrders {
returnQty = json['returnQty'];
installQty = json['installQty'];
}
num id;
SparePart sparePart;
num qty;
num returnQty;
num installQty;
SparePartsWorkOrders copyWith({
num id,
SparePart sparePart,
@ -1013,6 +1050,7 @@ class SparePartsWorkOrders {
returnQty: returnQty ?? this.returnQty,
installQty: installQty ?? this.installQty,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1038,9 +1076,11 @@ class SparePart {
partNo = json['partNo'];
partName = json['partName'];
}
num id;
String partNo;
String partName;
SparePart copyWith({
num id,
String partNo,
@ -1051,6 +1091,7 @@ class SparePart {
partNo: partNo ?? this.partNo,
partName: partName ?? this.partName,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1082,6 +1123,7 @@ class ContactPersonWorkOrders {
land = json['land'];
contactUserId = json['contactUserId'];
}
num id;
String employeeCode;
String name;
@ -1090,6 +1132,7 @@ class ContactPersonWorkOrders {
String email;
String land;
String contactUserId;
ContactPersonWorkOrders copyWith({
num id,
String employeeCode,
@ -1110,6 +1153,7 @@ class ContactPersonWorkOrders {
land: land ?? this.land,
contactUserId: contactUserId ?? this.contactUserId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1134,8 +1178,10 @@ class AssistantEmployees {
id = json['id'];
user = json['user'] != null ? UserModel.fromJson(json['user']) : UserModel(name: json['userName'], id: json['userId']);
}
num id;
UserModel user;
AssistantEmployees copyWith({
num id,
UserModel user,
@ -1144,6 +1190,7 @@ class AssistantEmployees {
id: id ?? this.id,
user: user ?? this.user,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1164,8 +1211,10 @@ class UserModel {
id = json['id'];
name = json['name'];
}
String id;
String name;
UserModel copyWith({
String id,
String name,
@ -1174,6 +1223,7 @@ class UserModel {
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1192,8 +1242,10 @@ class AssignedEmployee {
id = json['id'];
name = json['name'];
}
String id;
String name;
AssignedEmployee copyWith({
String id,
String name,
@ -1202,6 +1254,7 @@ class AssignedEmployee {
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1243,6 +1296,7 @@ class CallRequest {
firstAction = json['firstAction'] != null ? FirstAction.fromJson(json['firstAction']) : null;
assetType = json['assetType'];
}
num id;
String callNo;
String callComments;
@ -1254,6 +1308,7 @@ class CallRequest {
DefectType defectType;
FirstAction firstAction;
num assetType;
CallRequest copyWith({
num id,
String callNo,
@ -1280,6 +1335,7 @@ class CallRequest {
firstAction: firstAction ?? this.firstAction,
assetType: assetType ?? this.assetType,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1323,9 +1379,11 @@ class FirstAction {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
FirstAction copyWith({
num id,
String name,
@ -1336,6 +1394,7 @@ class FirstAction {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1357,9 +1416,11 @@ class DefectType {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
DefectType copyWith({
num id,
String name,
@ -1370,6 +1431,7 @@ class DefectType {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1391,9 +1453,11 @@ class Status {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
Status copyWith({
num id,
String name,
@ -1404,6 +1468,7 @@ class Status {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1435,6 +1500,7 @@ class CallSiteContactPerson {
land = json['land'];
contactUserId = json['contactUserId'];
}
num id;
String employeeCode;
String name;
@ -1443,6 +1509,7 @@ class CallSiteContactPerson {
String email;
String land;
String contactUserId;
CallSiteContactPerson copyWith({
num id,
String employeeCode,
@ -1463,6 +1530,7 @@ class CallSiteContactPerson {
land: land ?? this.land,
contactUserId: contactUserId ?? this.contactUserId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1584,6 +1652,7 @@ class Asset {
comment = json['comment'];
tagCode = json['tagCode'];
}
num id;
String assetSerialNo;
String systemID;
@ -1632,6 +1701,7 @@ class Asset {
List<TechnicalGuidanceBooks> technicalGuidanceBooks;
String comment;
String tagCode;
Asset copyWith({
num id,
String assetSerialNo,
@ -1732,6 +1802,7 @@ class Asset {
comment: comment ?? this.comment,
tagCode: tagCode ?? this.tagCode,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1836,8 +1907,10 @@ class TechnicalGuidanceBooks {
id = json['id'];
guidanceBook = json['guidanceBook'] != null ? GuidanceBook.fromJson(json['guidanceBook']) : null;
}
num id;
GuidanceBook guidanceBook;
TechnicalGuidanceBooks copyWith({
num id,
GuidanceBook guidanceBook,
@ -1846,6 +1919,7 @@ class TechnicalGuidanceBooks {
id: id ?? this.id,
guidanceBook: guidanceBook ?? this.guidanceBook,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1868,9 +1942,11 @@ class GuidanceBook {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
GuidanceBook copyWith({
num id,
String name,
@ -1881,6 +1957,7 @@ class GuidanceBook {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1902,9 +1979,11 @@ class RemainderWarrantyMonths {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
RemainderWarrantyMonths copyWith({
num id,
String name,
@ -1915,6 +1994,7 @@ class RemainderWarrantyMonths {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1936,9 +2016,11 @@ class ExtendedWarrantyMonths {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
ExtendedWarrantyMonths copyWith({
num id,
String name,
@ -1949,6 +2031,7 @@ class ExtendedWarrantyMonths {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -1970,9 +2053,11 @@ class SiteWarrantyMonths {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
SiteWarrantyMonths copyWith({
num id,
String name,
@ -1983,6 +2068,7 @@ class SiteWarrantyMonths {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2004,9 +2090,11 @@ class CommissioningStatus {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
CommissioningStatus copyWith({
num id,
String name,
@ -2017,6 +2105,7 @@ class CommissioningStatus {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2045,10 +2134,12 @@ class OriginSite {
});
}
}
num id;
num customerCode;
String custName;
List<Buildings> buildings;
OriginSite copyWith({
num id,
num customerCode,
@ -2061,6 +2152,7 @@ class OriginSite {
custName: custName ?? this.custName,
buildings: buildings ?? this.buildings,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2092,10 +2184,12 @@ class Buildings {
});
}
}
num id;
String name;
num value;
List<Floors> floors;
Buildings copyWith({
num id,
String name,
@ -2108,6 +2202,7 @@ class Buildings {
value: value ?? this.value,
floors: floors ?? this.floors,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2139,10 +2234,12 @@ class Floors {
});
}
}
num id;
String name;
num value;
List<Departments> departments;
Floors copyWith({
num id,
String name,
@ -2155,6 +2252,7 @@ class Floors {
value: value ?? this.value,
departments: departments ?? this.departments,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2177,8 +2275,10 @@ class Departments {
id = json['id'];
name = json['name'];
}
num id;
String name;
Departments copyWith({
num id,
String name,
@ -2187,6 +2287,7 @@ class Departments {
id: id ?? this.id,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2209,10 +2310,12 @@ class OriginDepartment {
departmentCode = json['departmentCode'];
ntCode = json['ntCode'];
}
num id;
String departmentName;
String departmentCode;
String ntCode;
OriginDepartment copyWith({
num id,
String departmentName,
@ -2225,6 +2328,7 @@ class OriginDepartment {
departmentCode: departmentCode ?? this.departmentCode,
ntCode: ntCode ?? this.ntCode,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
@ -2247,9 +2351,11 @@ class Currency {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
Currency copyWith({
num id,
String name,
@ -2260,6 +2366,7 @@ class Currency {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2283,10 +2390,12 @@ class Department {
departmentCode = json['departmentCode'];
ntCode = json['ntCode'];
}
num id;
String departmentName;
String departmentCode;
String ntCode;
Department copyWith({
num id,
String departmentName,
@ -2299,6 +2408,7 @@ class Department {
departmentCode: departmentCode ?? this.departmentCode,
ntCode: ntCode ?? this.ntCode,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2321,9 +2431,11 @@ class Floor {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
Floor copyWith({
num id,
String name,
@ -2334,6 +2446,7 @@ class Floor {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2355,9 +2468,11 @@ class Building {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
Building copyWith({
num id,
String name,
@ -2368,6 +2483,7 @@ class Building {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2396,10 +2512,12 @@ class Site {
});
}
}
num id;
num customerCode;
String custName;
List<Buildings> buildings;
Site copyWith({
num id,
num customerCode,
@ -2412,6 +2530,7 @@ class Site {
custName: custName ?? this.custName,
buildings: buildings ?? this.buildings,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2440,11 +2559,13 @@ class ParentAsset {
tagCode = json['tagCode'];
systemId = json['systemId'];
}
num id;
String assetSerialNo;
String assetNumber;
String tagCode;
String systemId;
ParentAsset copyWith({
num id,
String assetSerialNo,
@ -2459,6 +2580,7 @@ class ParentAsset {
tagCode: tagCode ?? this.tagCode,
systemId: systemId ?? this.systemId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2482,9 +2604,11 @@ class IsParent {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
IsParent copyWith({
num id,
String name,
@ -2495,6 +2619,7 @@ class IsParent {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2520,11 +2645,13 @@ class OldAsset {
tagCode = json['tagCode'];
systemId = json['systemId'];
}
num id;
String assetSerialNo;
String assetNumber;
String tagCode;
String systemId;
OldAsset copyWith({
num id,
String assetSerialNo,
@ -2539,6 +2666,7 @@ class OldAsset {
tagCode: tagCode ?? this.tagCode,
systemId: systemId ?? this.systemId,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
@ -2562,9 +2690,11 @@ class AssetReplace {
name = json['name'];
value = json['value'];
}
num id;
String name;
num value;
AssetReplace copyWith({
num id,
String name,
@ -2575,6 +2705,7 @@ class AssetReplace {
name: name ?? this.name,
value: value ?? this.value,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2594,8 +2725,10 @@ class Supplier {
id = json['id'];
suppliername = json['suppliername'];
}
num id;
String suppliername;
SupplierModel copyWith({
num id,
String suppliername,
@ -2604,6 +2737,7 @@ class Supplier {
id: id ?? this.id,
suppliername: suppliername ?? this.suppliername,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2654,6 +2788,7 @@ class ModelDefinition {
});
}
}
num id;
String assetName;
String modelDefCode;
@ -2667,6 +2802,7 @@ class ModelDefinition {
num lifeSpan;
List<ModelDefRelatedDefects> modelDefRelatedDefects;
List<Suppliers> suppliers;
ModelDefinition copyWith({
num id,
String assetName,
@ -2697,6 +2833,7 @@ class ModelDefinition {
modelDefRelatedDefects: modelDefRelatedDefects ?? this.modelDefRelatedDefects,
suppliers: suppliers ?? this.suppliers,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2730,8 +2867,10 @@ class Suppliers {
id = json['id'];
suppliername = json['suppliername'];
}
num id;
String suppliername;
Suppliers copyWith({
num id,
String suppliername,
@ -2740,6 +2879,7 @@ class Suppliers {
id: id ?? this.id,
suppliername: suppliername ?? this.suppliername,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id ?? 0;
@ -2762,10 +2902,12 @@ class ModelDefRelatedDefects {
workPerformed = json['workPerformed'];
estimatedTime = json['estimatedTime'];
}
num id;
String defectName;
String workPerformed;
String estimatedTime;
ModelDefRelatedDefects copyWith({
num id,
String defectName,
@ -2778,6 +2920,7 @@ class ModelDefRelatedDefects {
workPerformed: workPerformed ?? this.workPerformed,
estimatedTime: estimatedTime ?? this.estimatedTime,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;

@ -2,6 +2,7 @@ class TimerModel {
DateTime startAt;
DateTime endAt;
int durationInSecond;
// bool stopped;
TimerModel({this.startAt, this.endAt, this.durationInSecond});

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

@ -145,12 +145,12 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
text: _subtitle.edit,
onPressed: (_isSender || _isReceiver || false)
? () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: true,
)));
}
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: true,
)));
}
: null,
),
],
@ -171,12 +171,12 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
text: _subtitle.edit,
onPressed: (_isReceiver || false)
? () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: false,
)));
}
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer(
model: _model,
isSender: false,
)));
}
: null,
),
],

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/api_routes/http_status_manger.dart';
import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
@ -10,13 +12,14 @@ import 'package:test_sa/models/device/device_transfer_info.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/sizing.dart';
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/equipment/device_button.dart';
import 'package:test_sa/views/widgets/hospitals/hospital_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../controllers/validator/validator.dart';
import '../../app_style/colors.dart';
import '../../widgets/app_text_form_field.dart';
import '../../widgets/gas_refill/building_type_menu.dart';
import '../../widgets/gas_refill/department_type_menu.dart';
@ -25,6 +28,7 @@ import '../../widgets/hospitals/hospital_auto_complete_field_new.dart';
class RequestDeviceTransfer extends StatefulWidget {
static const String id = "/request-device-transfer";
const RequestDeviceTransfer({Key key}) : super(key: key);
@override
@ -42,6 +46,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
final DeviceTransfer _formModel = DeviceTransfer(receiver: DeviceTransferInfo(), sender: DeviceTransferInfo());
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
void setState(VoidCallback fn) {
if (mounted) super.setState(() {});
@ -116,7 +121,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Transfer Asset",
"Transfer Device",
style: Theme.of(context).textTheme.headline5.copyWith(color: Theme.of(context).primaryColor, fontSize: 28, fontWeight: FontWeight.bold),
),
),
@ -136,7 +141,7 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
// },
// ),
12.height,
const ASubTitle("Asset"),
const ASubTitle("Device"),
if (_validate && _formModel.device == null)
ASubTitle(
_subtitle.requiredWord,
@ -150,45 +155,6 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
setState(() {});
},
),
if (_formModel.device != null) 8.height,
if (_formModel.device != null) const ASubTitle("Asset Site"),
if (_formModel.device != null)
Container(
width: double.infinity,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
decoration: BoxDecoration(
color: AColors.inputFieldBackgroundColor,
border: Border.all(
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
// boxShadow: const [
// AppStyle.boxShadow
// ]
),
child: ASubTitle(_formModel.device?.hospital?.name),
),
if (_formModel.device != null) 4.height,
if (_formModel.device != null && _formModel.device.destDepartmentName != null) const ASubTitle("Asset Department"),
if (_formModel.device != null && _formModel.device.destDepartmentName != null)
Container(
width: double.infinity,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
decoration: BoxDecoration(
color: AColors.inputFieldBackgroundColor,
border: Border.all(
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
// boxShadow: const [
// AppStyle.boxShadow
// ]
),
child: ASubTitle(_formModel.device.destDepartmentName.toString()),
),
if (_formModel.device != null) 8.height,
// const SizedBox(height: 8,),
// const ASubTitle("Sender Department"),
// if(_validate && _formModel.senderDepartment == null)
@ -237,8 +203,6 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
Divider(
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 8),
const ASubTitle("Destination"),
const SizedBox(
height: 4,
),
@ -287,8 +251,8 @@ class _RequestDeviceTransferState extends State<RequestDeviceTransfer> {
},
),
const SizedBox(height: 8),
const ASubTitle("Room"),
const SizedBox(
ASubTitle("Room"),
SizedBox(
height: 4,
),
ATextFormField(

@ -9,7 +9,6 @@ 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';
import 'package:test_sa/views/widgets/switch_button.dart';
class TrackDeviceTransferPage extends StatefulWidget {
static const String id = "/track-device-transfer";
@ -24,7 +23,7 @@ class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage> with
DeviceTransferProvider _deviceTransferProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
bool mostRecent = false;
@override
Widget build(BuildContext context) {
_deviceTransferProvider = Provider.of<DeviceTransferProvider>(context);
@ -73,21 +72,6 @@ class _TrackDeviceTransferPageState extends State<TrackDeviceTransferPage> with
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ASwitchButton(
title: "Most Recent",
value: mostRecent,
onChange: (value) async {
mostRecent = value;
await _deviceTransferProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
mostRecent: mostRecent,
);
},
),
),
Expanded(
child: DeviceTransferList(
nextPage: _deviceTransferProvider.nextPage,

@ -72,6 +72,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
);
_validate = false;
Navigator.of(context).pop();
Navigator.of(context).pop();
}
}

@ -23,6 +23,7 @@ import '../../widgets/titles/app_sub_title.dart';
class SearchSubWorkOrderPage extends StatefulWidget {
static String id = "/SubWorkOrderPage";
const SearchSubWorkOrderPage({Key key}) : super(key: key);
@override

@ -13,6 +13,7 @@ import '../../widgets/titles/app_sub_title.dart';
class SparePartsBottomSheet extends StatefulWidget {
final SearchWorkOrder subWorkOrder;
const SparePartsBottomSheet({this.subWorkOrder, Key key}) : super(key: key);
@override

@ -11,6 +11,7 @@ class WorkOrderItem extends StatelessWidget {
final int index;
final SearchWorkOrder item;
final Function(SearchWorkOrder) onPressed;
const WorkOrderItem({Key key, this.item, this.onPressed, this.index}) : super(key: key);
@override

@ -17,6 +17,7 @@ import 'create_sub_workorder_page.dart';
class WorkOrderList extends StatefulWidget {
List<SearchWorkOrder> items;
final Future<List<SearchWorkOrder>> Function() onLazyLoading;
WorkOrderList({Key key, this.items, this.onLazyLoading}) : super(key: key);
@override
@ -25,6 +26,7 @@ class WorkOrderList extends StatefulWidget {
class _WorkOrderListState extends State<WorkOrderList> {
List<SearchWorkOrder> _items;
@override
void initState() {
super.initState();

@ -26,6 +26,7 @@ import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget {
final GasRefillModel model;
const GasRefillDetails({Key key, this.model}) : super(key: key);
@override
@ -43,6 +44,7 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
Subtitle _subtitle;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async {
_validate = true;
if (!_formKey.currentState.validate()) {

@ -89,16 +89,16 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
int status = widget.gasRefillModel == null
? await _gasRefillProvider.createModel(
user: _userProvider.user,
host: _settingProvider.host,
model: _formModel,
)
user: _userProvider.user,
host: _settingProvider.host,
model: _formModel,
)
: await _gasRefillProvider.updateModel(
user: _userProvider.user,
host: _settingProvider.host,
oldModel: widget.gasRefillModel,
newModel: _formModel,
);
user: _userProvider.user,
host: _settingProvider.host,
oldModel: widget.gasRefillModel,
newModel: _formModel,
);
_isLoading = false;
setState(() {});
if (status >= 200 && status < 300) {

@ -10,8 +10,6 @@ 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';
import '../../../widgets/switch_button.dart';
class TrackGasRefillPage extends StatefulWidget {
static const String id = "/track-gas-refill";
@ -25,7 +23,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
GasRefillProvider _gasRefillProvider;
UserProvider _userProvider;
SettingProvider _settingProvider;
bool mostRecent = false;
@override
Widget build(BuildContext context) {
@ -62,11 +59,11 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
children: [
Row(
children: [
const ABackButton(),
ABackButton(),
Expanded(
child: Center(
child: Text(
"Gas Refill Requests",
_subtitle.serviceRequests,
style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.grey3A, fontStyle: FontStyle.italic),
),
),
@ -79,21 +76,6 @@ class _TrackGasRefillPageState extends State<TrackGasRefillPage> with TickerProv
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ASwitchButton(
title: "Most Recent",
value: mostRecent,
onChange: (value) async {
mostRecent = value;
await _gasRefillProvider.getRequests(
user: _userProvider.user,
host: _settingProvider.host,
mostRecent: mostRecent,
);
},
),
),
Expanded(
child: GasRefillList(
nextPage: _gasRefillProvider.nextPage,

@ -23,6 +23,7 @@ import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/pages/device_transfer/request_device_transfer.dart';
import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart';
import 'package:test_sa/views/pages/sub_workorder/search_sub_workorder_page.dart';
import 'package:test_sa/views/pages/user/gas_refill/request_gas_refill.dart';
import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart';
import 'package:test_sa/views/pages/user/requests/create_request.dart';
@ -198,7 +199,7 @@ class _LandPageState extends State<LandPage> {
},
),
LandPageItem(
text: "Transfer Asset",
text: "transfer Device",
icon: FontAwesomeIcons.rightLeft,
onPressed: () {
Navigator.of(context).pushNamed(RequestDeviceTransfer.id);
@ -211,14 +212,14 @@ class _LandPageState extends State<LandPage> {
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
},
),
// if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
// LandPageItem(
// text: "Search Work Order",
// svgPath: "assets/images/sub_workorder_icon.svg",
// onPressed: () {
// Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
// },
// ),
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
LandPageItem(
text: "Search Work Order",
svgPath: "assets/images/sub_workorder_icon.svg",
onPressed: () {
Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
},
),
],
),
],

@ -12,6 +12,7 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class NotificationsPage extends StatefulWidget {
static final String id = "/notifications";
@override
_NotificationsPageState createState() => _NotificationsPageState();
}
@ -21,6 +22,7 @@ class _NotificationsPageState extends State<NotificationsPage> with TickerProvid
UserProvider _userProvider;
SettingProvider _settingProvider;
Subtitle _subtitle;
@override
Widget build(BuildContext context) {
_notificationsProvider = Provider.of<NotificationsProvider>(context);

@ -20,6 +20,7 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
class ProfilePage extends StatefulWidget {
static final String id = "/user/profile";
@override
_ProfilePageState createState() => _ProfilePageState();
}
@ -33,6 +34,7 @@ class _ProfilePageState extends State<ProfilePage> {
bool _firstTime = true;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);

@ -22,6 +22,7 @@ class ReportIssuesPage extends StatefulWidget {
final ServiceRequest serviceRequest;
const ReportIssuesPage({Key key, this.serviceRequest}) : super(key: key);
@override
_ReportIssuesPageState createState() => _ReportIssuesPageState();
}
@ -35,6 +36,7 @@ class _ReportIssuesPageState extends State<ReportIssuesPage> {
UserProvider _userProvider;
SettingProvider _settingProvider;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;

@ -31,8 +31,6 @@ import 'package:test_sa/views/widgets/status/service_request/service_request_thr
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';
import '../../../../controllers/providers/api/status_drop_down/service_reqest/service_request_through_provider.dart';
import '../../../../controllers/providers/api/status_drop_down/service_reqest/service_request_type_provider.dart';
import '../../../widgets/date_and_time/date_picker.dart';
import '../../../widgets/status/service_request/service_request_first_action.dart';
import '../../../widgets/status/service_request/service_request_loan_availability.dart';
@ -40,6 +38,7 @@ import '../../../widgets/status/service_request/service_request_loan_availabilit
class CreateRequestPage extends StatefulWidget {
static const String id = "/create-request";
final ServiceRequest serviceRequest;
const CreateRequestPage({this.serviceRequest, Key key}) : super(key: key);
@override
@ -59,7 +58,7 @@ class CreateRequestPageState extends State<CreateRequestPage> {
Subtitle _subtitle;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
TextEditingController _maintenanceController, _commentController;
TextEditingController _maintenanceController, _commentController, _reviewCommentController;
DateTime _dateTime;
@override
@ -166,11 +165,12 @@ class CreateRequestPageState extends State<CreateRequestPage> {
onSelect: (status) {
_serviceRequest.priority = status;
},
enabled: widget.serviceRequest == null ? true : false,
),
const SizedBox(
height: 8,
),
const ASubTitle("Defect Type"),
const ASubTitle("Equipment Status"),
const SizedBox(
height: 4,
),
@ -179,21 +179,22 @@ class CreateRequestPageState extends State<CreateRequestPage> {
onSelect: (status) {
_serviceRequest.defectType = status;
},
enabled: widget.serviceRequest == null ? true : false,
),
12.height,
const SizedBox(
height: 8,
),
const ASubTitle("Type"),
const ASubTitle("Type of Request"),
const SizedBox(
height: 4,
),
ServiceRequestTypesMenu(
initialValue: _serviceRequest.type,
enabled: widget.serviceRequest != null,
onSelect: (status) {
_serviceRequest.type = status;
},
enabled: widget.serviceRequest == null ? true : false,
),
const SizedBox(
height: 8,
@ -204,7 +205,10 @@ class CreateRequestPageState extends State<CreateRequestPage> {
),
ServiceRequestedThroughMenu(
initialValue: _serviceRequest.requestedThrough,
enabled: false,
onSelect: (status) {
_serviceRequest.requestedThrough = status;
},
enabled: widget.serviceRequest == null ? true : false,
),
if (widget.serviceRequest != null) 12.height,
if (widget.serviceRequest != null) const ASubTitle("First Action"),
@ -250,7 +254,7 @@ class CreateRequestPageState extends State<CreateRequestPage> {
),
if (widget.serviceRequest != null)
ATextFormField(
controller: _commentController,
controller: _reviewCommentController,
initialValue: _serviceRequest.reviewComment,
hintText: _subtitle.comment,
style: Theme.of(context).textTheme.titleMedium,
@ -258,14 +262,19 @@ class CreateRequestPageState extends State<CreateRequestPage> {
onSaved: (value) {
_serviceRequest.reviewComment = value;
},
enable: widget.serviceRequest != null ? false : true,
),
12.height,
MultiImagesPicker(
label: _subtitle.deviceImages,
images: _deviceImages,
enabled: widget.serviceRequest == null ? true : false,
),
12.height,
SpeechToTextButton(controller: _maintenanceController),
SpeechToTextButton(
controller: _maintenanceController,
enabled: widget.serviceRequest == null ? true : false,
),
12.height,
ATextFormField(
controller: _maintenanceController,
@ -278,11 +287,15 @@ class CreateRequestPageState extends State<CreateRequestPage> {
onSaved: (value) {
_serviceRequest.callComments = value;
},
enable: widget.serviceRequest == null ? true : false,
),
12.height,
RecordSound(onRecord: (audio) {
_serviceRequest.audio = audio;
}),
RecordSound(
onRecord: (audio) {
_serviceRequest.audio = audio;
},
enabled: widget.serviceRequest == null ? true : false,
),
12.height,
if (widget.serviceRequest != null)
ATextFormField(
@ -317,10 +330,6 @@ class CreateRequestPageState extends State<CreateRequestPage> {
}
_formKey.currentState.save();
_serviceRequest.deviceId = _device?.id;
if (widget.serviceRequest == null) {
_serviceRequest.type = Provider.of<ServiceRequestTypeProvider>(context, listen: false).getDefaultItem();
}
_serviceRequest.requestedThrough = Provider.of<ServiceRequestedThroughProvider>(context, listen: false).getDefaultItem();
_isLoading = true;
setState(() {});
_serviceRequest.devicePhotos = _deviceImages.map((e) => "${e.path.split("/").last}|${base64Encode(e.readAsBytesSync())}").toList();

@ -20,6 +20,7 @@ class FutureRequestServiceDetails extends StatefulWidget {
class _FutureRequestServiceDetailsState extends State<FutureRequestServiceDetails> {
UserProvider _userProvider;
SettingProvider _settingProvider;
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);

@ -155,12 +155,17 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
)
]),
child: Wrap(
direction: Axis.vertical,
spacing: 10,
children: [
ASubTitle(
"${_subtitle.callId}: ${widget.request.requestCode}",
font: 14,
),
ASubTitle(
"${_subtitle.assetNumber}: ${widget.request.deviceNumber}",
font: 14,
),
widget.request.deviceSerialNumber == null
? const SizedBox()
: ASubTitle(
@ -632,7 +637,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
image: _image,
onPick: (image) {
_image = image;
_serviceReport.image = "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}";
_serviceReport.image[0] = "${image.path.split("/").last}|${base64Encode(image.readAsBytesSync())}";
},
),
],

@ -38,6 +38,8 @@ import 'package:test_sa/views/widgets/status/report/service_report_repair_locati
import 'package:test_sa/views/widgets/timer/app_timer.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../widgets/images/multi_image_picker.dart';
class EditServiceReport extends StatefulWidget {
static final String id = "/edit-service-report";
final ServiceRequest request;
@ -60,7 +62,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
bool _showCommentField = false;
Subtitle _subtitle;
File _image;
final List<File> _images = [];
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
TextEditingController _faultController = TextEditingController();
@ -149,12 +151,17 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
)
]),
child: Wrap(
direction: Axis.vertical,
spacing: 10,
children: [
ASubTitle(
"${_subtitle.callId}: ${widget.request.requestCode}",
font: 14,
),
ASubTitle(
"${_subtitle.assetNumber}: ${widget.request.deviceNumber}",
font: 14,
),
widget.request.deviceSerialNumber == null
? const SizedBox()
: ASubTitle(
@ -380,6 +387,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
setState(() {});
} else {
_serviceReport.callLastSituation = status;
setState(() {});
}
},
),
@ -390,6 +398,56 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
),
],
),
const SizedBox(
height: 8,
),
ASubTitle("Return to Service"),
Row(
children: [
Expanded(
child: ADatePicker(
date: _serviceReport.returnToService,
from: DateTime.now().subtract(const Duration(days: 365)),
to: DateTime.now().add(const Duration(days: 365)),
onDatePicker: (date) {
_serviceReport.returnToService = date;
setState(() {});
},
),
),
],
),
if (_serviceReport.callLastSituation.value == 2)
Column(
children: [
const SizedBox(
height: 8,
),
ATextFormField(
initialValue: _serviceReport?.reviewComment,
hintText: "Vendor Name",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.multiline,
onSaved: (value) {
_serviceReport.reviewComment = value;
},
),
const SizedBox(
height: 8,
),
ATextFormField(
initialValue: _serviceReport?.reviewComment,
hintText: "Vendor Engineer",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
textInputType: TextInputType.multiline,
onSaved: (value) {
_serviceReport.reviewComment = value;
},
),
],
),
if (_showCommentField)
const SizedBox(
height: 8,
@ -664,7 +722,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
},
),
const SizedBox(height: 8),
ASubTitle(_subtitle.workPreformed),
ASubTitle("Solutions"),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.workPreformed,
@ -680,50 +738,38 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
},
),
const SizedBox(height: 4),
Row(
children: [
// reasons
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.reasons),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status) {
_serviceReport.reason = status;
},
),
],
),
),
const SizedBox(
width: 8,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ASubTitle(_subtitle.attachImage),
AMiniOneImagePicker(
//error: _validate && _serviceReport.image == null,
image: _image,
onPick: (image) {
_image = image;
_serviceReport.image = base64Encode(image.readAsBytesSync());
},
),
],
),
),
],
ASubTitle("Failure Reason"),
const SizedBox(
height: 4,
),
ServiceReportReasonsMenu(
initialValue: _serviceReport.reason,
onSelect: (status) {
_serviceReport.reason = status;
},
),
const SizedBox(
height: 8,
),
ASubTitle(_subtitle.attachImage),
const SizedBox(
height: 4,
),
MultiImagesPicker(
label: "",
images: _images,
),
// AMiniOneImagePicker(
// //error: _validate && _serviceReport.image == null,
// image: _image,
// onPick: (image) {
// _image = image;
// _serviceReport.image = base64Encode(image.readAsBytesSync());
// },
// ),
const SizedBox(
height: 8,
),
const SizedBox(height: 8),
ASubTitle(_subtitle.repairLocation),
const SizedBox(height: 4),
@ -734,7 +780,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
},
),
const SizedBox(height: 16),
ASubTitle(_subtitle.travelingExpense),
ASubTitle("Travel Expenses"),
const SizedBox(
height: 4,
),
@ -885,7 +931,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
//const SizedBox(height: 8,),
const SizedBox(height: 8),
ASubTitle(_subtitle.comment),
ASubTitle("technical comment"),
const SizedBox(height: 4),
ATextFormField(
initialValue: _serviceReport?.comment,
@ -1026,7 +1072,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
_isLoading = true;
setState(() {});
_serviceReport.image = _images.map((e) => base64Encode(e.readAsBytesSync())).toList();
int status = await _serviceRequestsProvider.updateServiceReport(user: _userProvider.user, host: _settingProvider.host, report: _serviceReport, request: widget.request);
_isLoading = false;
setState(() {});

@ -26,6 +26,7 @@ class FutureServiceReport extends StatefulWidget {
class _FutureServiceReportState extends State<FutureServiceReport> {
UserProvider _userProvider;
SettingProvider _settingProvider;
@override
Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context);

@ -246,10 +246,10 @@ class RequestDetailsPage extends StatelessWidget {
// title: _subtitle.deviceArName,
// content: serviceRequest.deviceArName,
// ),
RequestInfoRow(
title: _subtitle.deviceName,
content: serviceRequest.deviceEnName,
),
// RequestInfoRow(
// title: _subtitle.deviceName,
// content: serviceRequest.deviceEnName,
// ),
RequestInfoRow(
title: _subtitle.maintenanceIssue,
content: serviceRequest.callComments,
@ -354,6 +354,10 @@ class RequestDetailsPage extends StatelessWidget {
title: _subtitle.assetName,
info: workOrders[index].callRequest.asset.modelDefinition.assetName,
),
RequestInfoRow(
title: _subtitle.assetNumber,
info: workOrders[index].callRequest.asset.assetNumber,
),
RequestInfoRow(
title: _subtitle.model,
info: workOrders[index].callRequest.asset.modelDefinition.modelName,
@ -363,11 +367,7 @@ class RequestDetailsPage extends StatelessWidget {
info: workOrders[index].callRequest.asset.site.custName,
),
RequestInfoRow(
title: _subtitle.maintenanceSituation,
info: workOrders[index].calllastSituation.name ?? '',
),
RequestInfoRow(
title: _subtitle.currentSituation,
title: "Call last Situation",
info: workOrders[index].currentSituation.name ?? '',
),
_userProvider.user.type == UsersTypes.engineer && workOrders[index].workOrderNo != null

@ -15,6 +15,7 @@ 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();
}
@ -25,6 +26,7 @@ class _ServiceRequestsPageState extends State<ServiceRequestsPage> with TickerPr
SettingProvider _settingProvider;
bool _expandedSearch = false;
bool _firstTime = true;
@override
Widget build(BuildContext context) {
_serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);

@ -22,6 +22,7 @@ import '../../../../widgets/pentry/pentry_info_form.dart';
class EditPentry extends StatefulWidget {
final Pentry pentry;
final Visit visit;
const EditPentry({Key key, this.pentry, this.visit}) : super(key: key);
@override
@ -39,6 +40,7 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
TabController _tabController;
_onSubmit() async {
_validate = true;

@ -21,6 +21,7 @@ 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();
}

@ -21,6 +21,7 @@ import 'package:test_sa/views/widgets/visits/visits_list.dart';
class RegularVisitsPage extends StatefulWidget {
static final String id = "/Regular-visits";
@override
_RegularVisitsPageState createState() => _RegularVisitsPageState();
}
@ -31,6 +32,7 @@ class _RegularVisitsPageState extends State<RegularVisitsPage> with TickerProvid
SettingProvider _settingProvider;
bool _expandedSearch = false;
Subtitle _subtitle;
@override
Widget build(BuildContext context) {
_visitsProvider = Provider.of<RegularVisitsProvider>(context);

@ -13,6 +13,7 @@ import 'package:test_sa/views/widgets/visits/visit_status.dart';
class UpdateVisitsGroupSheet extends StatefulWidget {
final List<Visit> visits;
final String title;
const UpdateVisitsGroupSheet({Key key, this.visits, this.title}) : super(key: key);
@override
@ -31,6 +32,7 @@ class _UpdateVisitsGroupSheetState extends State<UpdateVisitsGroupSheet> {
// Lookup(name: "Failed", id: 1),
// ];
VisitsGroup _group = VisitsGroup();
// File _image;
Subtitle _subtitle;

@ -9,6 +9,7 @@ class AFlatButton extends StatelessWidget {
final VoidCallback onPressed;
const AFlatButton({Key key, this.text, this.textColor, this.style, this.onPressed, this.padding}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextButton(

@ -9,6 +9,7 @@ class ASmallButton extends StatelessWidget {
final VoidCallback onPressed;
const ASmallButton({Key key, this.text, this.style, this.onPressed, this.padding, this.color}) : super(key: key);
@override
Widget build(BuildContext context) {
return ElevatedButton(

@ -12,6 +12,7 @@ class FromToDateBar extends StatefulWidget {
final Function(DateTime) onPickTo;
const FromToDateBar({Key key, this.from, this.to, this.onPickFrom, this.onPickTo}) : super(key: key);
@override
_FromToDateBarState createState() => _FromToDateBarState();
}

@ -8,6 +8,7 @@ class DepartmentItem extends StatelessWidget {
final Function(Department) onPressed;
const DepartmentItem({Key key, this.department, this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(

@ -13,6 +13,7 @@ import '../app_text_form_field.dart';
class SingleDepartmentPicker extends StatefulWidget {
static final String id = "/single-Department-Picker";
@override
_SingleDepartmentPickerState createState() => _SingleDepartmentPickerState();
}
@ -22,6 +23,7 @@ class _SingleDepartmentPickerState extends State<SingleDepartmentPicker> {
SettingProvider _settingProvider;
List<Department> _searchableList = [];
bool _firstTime = true;
@override
Widget build(BuildContext context) {
_departmentsProvider = Provider.of<DepartmentsProvider>(context);

@ -31,7 +31,7 @@ class DeviceTransferInfoSection extends StatelessWidget {
info: info.department.name,
),
// RequestInfoRow(
// title: subtitle.engineerName,
// title: isSender ? "Sender Name " : "Receiver Name",
// info: info.userName,
// ),
RequestInfoRow(

@ -56,20 +56,6 @@ class DeviceButton extends StatelessWidget {
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(
color: Theme.of(context).textTheme.subtitle1.color,
),
Text(
"${_subtitle.assetNumber} : ${device.number}",
style: Theme.of(context).textTheme.subtitle2,
),
Divider(
color: Theme.of(context).textTheme.subtitle1.color,
),
Text(
"${_subtitle.assetName} : ${device.modelDefinition.assetName}",
style: Theme.of(context).textTheme.subtitle2,
),
Divider(
color: Theme.of(context).textTheme.subtitle1.color,
),

@ -10,6 +10,7 @@ class DeviceItem extends StatelessWidget {
final Function(Device) onPressed;
const DeviceItem({Key key, this.device, this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
Subtitle _subtitle = AppLocalization.of(context).subtitle;

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/devices_provider.dart';
@ -17,6 +18,7 @@ import '../qr/scan_qr.dart';
class SingleDevicePicker extends StatefulWidget {
static final String id = "/single-device-Picker";
final bool sandraChoice = true;
@override
_SingleDevicePickerState createState() => _SingleDevicePickerState();
}
@ -32,6 +34,7 @@ class _SingleDevicePickerState extends State<SingleDevicePicker> {
TextEditingController numberController = TextEditingController();
TextEditingController snController = TextEditingController();
_getDevice(String result) async {
print(result);
if (result == null) return;

@ -80,7 +80,7 @@ class _BuildingTypeMenuState extends State<BuildingTypeMenu> {
return DropdownMenuItem<Buildings>(
value: value,
child: Text(
value.name ?? "",
value.name,
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,

@ -80,7 +80,7 @@ class _FloorTypeMenuState extends State<FloorTypeMenu> {
return DropdownMenuItem<Floors>(
value: value,
child: Text(
value.name ?? "",
value.name,
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: Theme.of(context).primaryColor,
fontSize: 11,

@ -1,7 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/localization/localization.dart';
import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/models/gas_refill/gas_refill_model.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/models/user.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
@ -10,11 +14,13 @@ class GasRefillItem extends StatelessWidget {
final int index;
final GasRefillModel item;
final Function(GasRefillModel) onPressed;
const GasRefillItem({Key key, this.item, this.onPressed, this.index}) : super(key: key);
@override
Widget build(BuildContext context) {
Subtitle subtitle = AppLocalization.of(context).subtitle;
Subtitle _subtitle = AppLocalization.of(context).subtitle;
User _user = Provider.of<UserProvider>(context, listen: false).user;
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
@ -22,7 +28,7 @@ class GasRefillItem extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 4),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
backgroundColor: itemColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
@ -43,14 +49,14 @@ class GasRefillItem extends StatelessWidget {
children: [
Text(
item.title ?? "-----",
style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
),
Row(
children: [
Expanded(
child: Text(
subtitle.hospital,
style: Theme.of(context).textTheme.titleSmall.copyWith(
_subtitle.hospital,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
),
@ -58,48 +64,29 @@ class GasRefillItem extends StatelessWidget {
if (item.clientName != null)
Text(
item.clientName,
style: Theme.of(context).textTheme.titleSmall.copyWith(
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
),
],
),
Divider(color: onItemColor),
Divider(
color: onItemColor,
),
Row(
children: [
Expanded(
child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
child: Text(
_subtitle.status,
style: Theme.of(context).textTheme.subtitle2.copyWith(
color: onItemColor,
),
),
),
if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
],
),
if (item?.expectedDate != null) Divider(color: onItemColor),
if (item?.expectedDate != null)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Visit Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
],
),
if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: item.details
.map(
(gas) => gas?.type?.name?.isNotEmpty ?? false
? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
: const SizedBox.shrink(),
)
.toList(),
)
],
),
//Divider(color: onItemColor,),
],
),
),

@ -12,6 +12,7 @@ import 'package:test_sa/views/app_style/sizing.dart';
class HospitalAutoCompleteField extends StatefulWidget {
final String initialValue;
final Function(Hospital) onSearch;
//final Function(Hospital) onSave;
const HospitalAutoCompleteField({

@ -8,12 +8,10 @@ import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
class HospitalAutoCompleteField extends StatefulWidget {
final String initialValue;
final Function(Hospital) onSearch;
final bool enabled;
//final Function(Hospital) onSave;
@ -21,7 +19,6 @@ class HospitalAutoCompleteField extends StatefulWidget {
Key key,
this.onSearch,
this.initialValue,
this.enabled = true,
}) : super(key: key);
@override
@ -69,41 +66,32 @@ class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
// AppStyle.boxShadow
// ]
),
child: widget.enabled
? TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6,
controller: _controller,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: _subtitle.hospital,
border: InputBorder.none,
disabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
textInputAction: TextInputAction.search,
),
suggestionsCallback: (vale) async {
return await HospitalsProvider().getHospitalsListByVal(searchVal: _controller.text);
},
itemBuilder: (context, hospital) {
return ListTile(
title: Text(hospital.name),
);
},
onSuggestionSelected: (hospital) {
widget.onSearch(hospital);
},
)
: widget.initialValue == null
? const Padding(
padding: EdgeInsets.all(8.0),
child: ALoading(),
)
: ListTile(
title: Center(child: Text(widget.initialValue)),
),
child: TypeAheadField<Hospital>(
textFieldConfiguration: TextFieldConfiguration(
style: Theme.of(context).textTheme.headline6,
controller: _controller,
textAlign: TextAlign.center,
decoration: InputDecoration(
hintText: _subtitle.hospital,
border: InputBorder.none,
disabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
textInputAction: TextInputAction.search,
),
suggestionsCallback: (vale) async {
return await HospitalsProvider().getHospitalsListByVal(searchVal: _controller.text);
},
itemBuilder: (context, hospital) {
return ListTile(
title: Text(hospital.name),
);
},
onSuggestionSelected: (hospital) {
widget.onSearch(hospital);
},
),
);
}
}

@ -8,6 +8,7 @@ class HospitalItem extends StatelessWidget {
final Function(Hospital) onPressed;
const HospitalItem({Key key, this.hospital, this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(

@ -14,6 +14,7 @@ import '../app_text_form_field.dart';
class SingleHospitalPicker extends StatefulWidget {
static final String id = "/single-Hospital-Picker";
final bool sandraChoice = true;
@override
_SingleHospitalPickerState createState() => _SingleHospitalPickerState();
}
@ -23,6 +24,7 @@ class _SingleHospitalPickerState extends State<SingleHospitalPicker> {
SettingProvider _settingProvider;
List<Hospital> _searchableList = [];
bool _firstTime = true;
@override
Widget build(BuildContext context) {
_hospitalsProvider = Provider.of<HospitalsProvider>(context);

@ -5,6 +5,7 @@ import 'package:test_sa/views/widgets/loaders/image_loader.dart';
class ImagesViewer extends StatelessWidget {
final List<String> images;
final int initialIndex;
const ImagesViewer({
Key key,
this.images,

@ -12,6 +12,7 @@ class AMiniOneImagePicker extends StatefulWidget {
final File image;
final String label;
final bool error;
const AMiniOneImagePicker({Key key, this.label, this.error, this.image, this.onPick}) : super(key: key);
@override
@ -21,6 +22,7 @@ class AMiniOneImagePicker extends StatefulWidget {
class _AMiniOneImagePickerState extends State<AMiniOneImagePicker> {
File _image;
Subtitle _subtitle;
@override
void initState() {
super.initState();

@ -17,8 +17,9 @@ class MultiImagesPicker extends StatefulWidget {
final String label;
final bool error;
final List<File> images;
final bool enabled;
const MultiImagesPicker({Key key, this.images, this.label, this.error = false}) : super(key: key);
const MultiImagesPicker({Key key, this.images, this.label, this.error = false, this.enabled = true}) : super(key: key);
@override
_MultiImagesPickerState createState() => _MultiImagesPickerState();
@ -57,9 +58,11 @@ class _MultiImagesPickerState extends State<MultiImagesPicker> with TickerProvid
),
AFlatButton(
text: _subtitle.add,
onPressed: () {
onImagePick(_subtitle);
},
onPressed: widget.enabled
? () {
onImagePick(_subtitle);
}
: null,
),
],
),
@ -101,9 +104,11 @@ class _MultiImagesPickerState extends State<MultiImagesPicker> with TickerProvid
),
child: widget.images.isEmpty
? MaterialButton(
onPressed: () {
onImagePick(_subtitle);
},
onPressed: widget.enabled
? () {
onImagePick(_subtitle);
}
: null,
child: Center(
child: Icon(
Icons.add_a_photo_outlined,

@ -12,6 +12,7 @@ class AOneImagePicker extends StatefulWidget {
final File image;
final String label;
final bool error;
const AOneImagePicker({Key key, this.label, this.error, this.image, this.onPick}) : super(key: key);
@override
@ -21,6 +22,7 @@ class AOneImagePicker extends StatefulWidget {
class _AOneImagePickerState extends State<AOneImagePicker> {
File _image;
Subtitle _subtitle;
@override
void initState() {
super.initState();

@ -6,6 +6,7 @@ class FailedLoading extends StatelessWidget {
final VoidCallback onReload;
const FailedLoading({Key key, this.message, this.onReload}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(

@ -6,6 +6,7 @@ import 'package:test_sa/views/app_style/sizing.dart';
class NotificationItem extends StatelessWidget {
final AppNotification notification;
final Function(AppNotification) onPressed;
const NotificationItem({Key key, this.notification, this.onPressed}) : super(key: key);
@override

@ -19,6 +19,7 @@ import '../status/pentry/pentry_status_mune.dart';
class PentryInfoForm extends StatefulWidget {
final Pentry model;
final bool enableValidate;
const PentryInfoForm({
Key key,
this.model,

@ -11,6 +11,7 @@ import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class PentryPPMCheckListForm extends StatefulWidget {
final List<PPMCheckList> models;
final bool enableValidate;
const PentryPPMCheckListForm({
Key key,
this.models,

@ -9,6 +9,7 @@ class RequestInfoRow extends StatelessWidget {
final Widget infoWidget;
const RequestInfoRow({Key key, this.title, this.info, this.content, this.contentWidget, this.infoWidget}) : super(key: key);
@override
Widget build(BuildContext context) {
if (info != null && info.isEmpty) {

@ -19,6 +19,7 @@ class ServiceRequestItem extends StatelessWidget {
final int index;
final ServiceRequest request;
final Function(ServiceRequest) onPressed;
const ServiceRequestItem({Key key, this.request, this.onPressed, this.index}) : super(key: key);
@override

@ -306,22 +306,21 @@ class _ServiceRequestsSearchDialogState extends State<ServiceRequestsSearchDialo
// ),
// ),
Visibility(
visible: widget.initialSearchValue.toMap().isNotEmpty,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton(
padding: EdgeInsets.zero,
text: _subtitle.clearSearch,
onPressed: () {
_search = ServiceRequestSearch();
Navigator.of(context).pop(_search);
},
),
Visibility(
visible: widget.initialSearchValue.toMap().isNotEmpty,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton(
padding: EdgeInsets.zero,
text: _subtitle.clearSearch,
onPressed: () {
_search = ServiceRequestSearch();
Navigator.of(context).pop(_search);
},
),
),
],
),
),
],
),
),
),

@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rive/rive.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
@ -12,8 +11,9 @@ import '../../app_style/sizing.dart';
class RecordSound extends StatefulWidget {
final Function(String) onRecord;
final bool enabled;
const RecordSound({Key key, @required this.onRecord}) : super(key: key);
const RecordSound({Key key, @required this.onRecord, this.enabled = true}) : super(key: key);
@override
State<RecordSound> createState() => _RecordSoundState();
@ -72,8 +72,6 @@ class _RecordSoundState extends State<RecordSound> {
// await Permission.camera
PermissionStatus status = await Permission.microphone.request();
if (!status.isGranted) {
PermissionStatus status = await Permission.microphone.request();
Fluttertoast.showToast(msg: "Permission Denied");
return;
}
_rive.addController(SimpleAnimation('recording'));
@ -117,11 +115,11 @@ class _RecordSoundState extends State<RecordSound> {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(left: 12, right: 0),
padding: EdgeInsets.only(left: 12, right: 0),
decoration: BoxDecoration(
color: const Color(0xfff5f5f5),
color: Color(0xfff5f5f5),
border: Border.all(
color: const Color(0xffefefef),
color: Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
@ -186,15 +184,21 @@ class _RecordSoundState extends State<RecordSound> {
child: Icon(Icons.mic),
),
onTapDown: (TapDownDetails details) async {
_startRecording();
},
onTapUp: (TapUpDetails details) async {
_stopRecording();
},
onTapCancel: () async {
_cancelRecording();
},
onTapDown: widget.enabled
? (TapDownDetails details) async {
_startRecording();
}
: null,
onTapUp: widget.enabled
? (TapUpDetails details) async {
_stopRecording();
}
: null,
onTapCancel: widget.enabled
? () async {
_cancelRecording();
}
: null,
),
),
],

@ -5,24 +5,25 @@ import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import 'package:test_sa/views/app_style/sizing.dart';
class SpeechToTextButton extends StatefulWidget {
final TextEditingController controller;
final bool mini;
final bool enabled;
const SpeechToTextButton({Key key, this.controller, this.mini = false}) : super(key: key);
const SpeechToTextButton({Key key, this.controller, this.mini = false, this.enabled = true}) : super(key: key);
@override
SpeechToTextButtonState createState() => SpeechToTextButtonState();
_SpeechToTextButtonState createState() => _SpeechToTextButtonState();
}
class SpeechToTextButtonState extends State<SpeechToTextButton> {
class _SpeechToTextButtonState extends State<SpeechToTextButton> {
bool _speechEnabled = false;
SettingProvider _settingProvider;
final SpeechToText _speechToText = SpeechToText();
SpeechToText _speechToText = SpeechToText();
/// This has to happen only once per app
void _initSpeech() async {
@ -63,15 +64,12 @@ class SpeechToTextButtonState extends State<SpeechToTextButton> {
@override
void initState() {
_initSpeech();
widget.controller.addListener(() {
setState(() {});
});
super.initState();
}
@override
void setState(VoidCallback fn) {
if (!mounted) return;
if (!this.mounted) return;
super.setState(fn);
}
@ -79,18 +77,18 @@ class SpeechToTextButtonState extends State<SpeechToTextButton> {
Widget build(BuildContext context) {
_settingProvider = Provider.of<SettingProvider>(context);
return Container(
padding: const EdgeInsets.only(left: 12, right: 12),
padding: EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
color: const Color(0xfff5f5f5),
color: Color(0xfff5f5f5),
border: Border.all(
color: const Color(0xffefefef),
color: Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
child: Row(
children: [
widget.mini ? const SizedBox.shrink() : const ASubTitle("Speech To Text"),
widget.controller.text.isNotEmpty
widget.mini ? SizedBox.shrink() : ASubTitle("Text To Speech"),
widget.controller.text.isNotEmpty && widget.enabled
? AIconButton2(
iconData: Icons.delete,
onPressed: () {
@ -98,22 +96,24 @@ class SpeechToTextButtonState extends State<SpeechToTextButton> {
setState(() {});
},
)
: const SizedBox.shrink(),
const Spacer(),
: SizedBox.shrink(),
Spacer(),
TextButton(
onPressed: () {
if (_speechToText.isListening) return;
onPressed: widget.enabled
? () {
if (_speechToText.isListening) return;
if (_settingProvider.speechToText == "ar") {
_settingProvider.setSpeechToText("en");
} else {
_settingProvider.setSpeechToText("ar");
}
},
if (_settingProvider.speechToText == "ar") {
_settingProvider.setSpeechToText("en");
} else {
_settingProvider.setSpeechToText("ar");
}
}
: null,
child: Text(_settingProvider.speechToText)),
GestureDetector(
child: _speechToText.isListening
? const Icon(
? Icon(
Icons.fiber_manual_record,
color: Colors.red,
)
@ -121,17 +121,15 @@ class SpeechToTextButtonState extends State<SpeechToTextButton> {
Icons.mic,
color: Theme.of(context).colorScheme.primary,
),
onTap: () async {
if (!_speechEnabled) {
Fluttertoast.showToast(msg: "microphone not available");
return;
}
if (_speechToText.isListening) {
_stopListening();
} else {
_startListening();
}
},
onTap: widget.enabled
? () async {
if (!_speechEnabled) {
Fluttertoast.showToast(msg: "microphone not available");
return;
}
_startListening();
}
: null,
),
],
),

@ -9,6 +9,7 @@ class SingleEngineerMenu extends StatefulWidget {
final Function(Engineer) onSelect;
const SingleEngineerMenu({Key key, this.engineers, this.onSelect, this.initialStatus}) : super(key: key);
@override
_SingleEngineerMenuState createState() => _SingleEngineerMenuState();
}

@ -10,6 +10,7 @@ class MultiStatusMenu extends StatefulWidget {
final Function(List<Lookup>) onSelect;
const MultiStatusMenu({Key key, this.statuses, this.onSelect, this.initialSelectedStatus}) : super(key: key);
@override
_MultiStatusMenuState createState() => _MultiStatusMenuState();
}

@ -11,6 +11,7 @@ class ServiceReportLastCallsMenu extends StatelessWidget {
final ServiceReport report;
const ServiceReportLastCallsMenu({Key key, @required this.onSelect, @required this.report}) : super(key: key);
@override
Widget build(BuildContext context) {
ServiceReportLastCallsProvider _menuProvider = Provider.of<ServiceReportLastCallsProvider>(context);

@ -12,6 +12,7 @@ class ServiceReportReasonsMenu extends StatelessWidget {
final Function(Lookup) onSelect;
const ServiceReportReasonsMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
@override
Widget build(BuildContext context) {
SettingProvider _settingProvider = Provider.of<SettingProvider>(context);

@ -12,6 +12,7 @@ class ServiceReportRepairLocation extends StatelessWidget {
final Function(Lookup) onSelect;
const ServiceReportRepairLocation({Key key, this.onSelect, this.initialValue}) : super(key: key);
@override
Widget build(BuildContext context) {
SettingProvider _settingProvider = Provider.of<SettingProvider>(context);

@ -12,6 +12,7 @@ class ServiceAssetTypeMenu extends StatelessWidget {
final Lookup initialValue;
const ServiceAssetTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
@override
Widget build(BuildContext context) {
SettingProvider _settingProvider = Provider.of<SettingProvider>(context);

@ -10,8 +10,10 @@ import 'package:test_sa/views/widgets/status/single_status_menu.dart';
class ServiceRequestDefectTypesMenu extends StatelessWidget {
final Function(Lookup) onSelect;
final Lookup initialValue;
final bool enabled;
const ServiceRequestDefectTypesMenu({Key key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key);
const ServiceRequestDefectTypesMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
@override
Widget build(BuildContext context) {
final settingProvider = Provider.of<SettingProvider>(context);
@ -29,6 +31,7 @@ class ServiceRequestDefectTypesMenu extends StatelessWidget {
initialStatus: initialValue,
statuses: menuProvider.items,
onSelect: onSelect,
enabled: enabled,
));
}
}

@ -10,8 +10,10 @@ import 'package:test_sa/views/widgets/status/single_status_menu.dart';
class ServiceRequestPriorityMenu extends StatelessWidget {
final Function(Lookup) onSelect;
final Lookup initialValue;
final bool enabled;
const ServiceRequestPriorityMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
const ServiceRequestPriorityMenu({Key key, this.onSelect, this.initialValue, this.enabled}) : super(key: key);
@override
Widget build(BuildContext context) {
final settingProvider = Provider.of<SettingProvider>(context);
@ -30,6 +32,7 @@ class ServiceRequestPriorityMenu extends StatelessWidget {
initialStatus: initialValue,
statuses: menuProvider.items,
onSelect: onSelect,
enabled: enabled,
));
}
}

@ -13,6 +13,7 @@ class ServiceRequestedThroughMenu extends StatelessWidget {
final bool enabled;
const ServiceRequestedThroughMenu({Key key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key);
@override
Widget build(BuildContext context) {
final settingProvider = Provider.of<SettingProvider>(context);
@ -27,7 +28,7 @@ class ServiceRequestedThroughMenu extends StatelessWidget {
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
},
child: SingleStatusMenu(
initialStatus: enabled ? initialValue : menuProvider.getDefaultItem(),
initialStatus: initialValue,
statuses: menuProvider.items,
onSelect: onSelect,
enabled: enabled,

@ -1,44 +0,0 @@
import 'package:flutter/material.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../app_style/colors.dart';
import '../app_style/sizing.dart';
class ASwitchButton extends StatelessWidget {
final String title;
final bool value;
final void Function(bool) onChange;
const ASwitchButton({
@required this.title,
@required this.value,
@required this.onChange,
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
margin: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: AColors.inputFieldBackgroundColor,
border: Border.all(
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ASubTitle(title),
Switch.adaptive(
value: value,
activeColor: AColors.primaryColor,
onChanged: onChange,
),
],
),
);
}
}

@ -10,6 +10,7 @@ class AppTimer extends StatefulWidget {
final Future<bool> Function(TimerModel) onChange;
final TextStyle style;
final bool enabled;
const AppTimer({
Key key,
this.timer,

@ -6,7 +6,9 @@ class ASubTitle extends StatelessWidget {
final EdgeInsets padding;
final Color color;
final double font;
const ASubTitle(this.text, {Key key, this.padding, this.color, this.font}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(

@ -5,7 +5,9 @@ class ATitle extends StatelessWidget {
final String text;
final EdgeInsets padding;
final bool center;
const ATitle(this.text, {Key key, this.padding, this.center = false}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(

@ -15,6 +15,7 @@ class ExpandableInfoRow extends StatefulWidget {
class _ExpandableInfoRowState extends State<ExpandableInfoRow> with TickerProviderStateMixin {
bool _isExpanded = false;
@override
Widget build(BuildContext context) {
return InkWell(

@ -22,6 +22,7 @@ class VisitsList extends StatefulWidget {
class _VisitsListState extends State<VisitsList> {
List<Visit> _selectedVisits = [];
@override
void initState() {
_selectedVisits.clear();

Loading…
Cancel
Save