Merge remote-tracking branch 'origin/main_design2.0' into main_design2.0
commit
ad3549b9a4
@ -1,75 +1,76 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class AssetTransferStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({
|
||||
String host,
|
||||
User user,
|
||||
}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getAssetTransferStatus);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class AssetTransferStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({
|
||||
// String host,
|
||||
// User user,
|
||||
// }) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(URLs.getAssetTransferStatus);
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class AssignedToProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getEmployees,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class AssignedToProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getEmployees,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/employee.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class EngineersProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Employee> _items;
|
||||
|
||||
List<Employee> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getEngineers,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body);
|
||||
_items = categoriesListJson.map((type) => Employee.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/employee.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class EngineersProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Employee> _items;
|
||||
//
|
||||
// List<Employee> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getEngineers,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body);
|
||||
// _items = categoriesListJson.map((type) => Employee.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class GasCylinderSizesProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({
|
||||
String host,
|
||||
User user,
|
||||
}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getGasCylinderSize,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class GasCylinderSizesProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({
|
||||
// String host,
|
||||
// User user,
|
||||
// }) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getGasCylinderSize,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class GasCylinderTypesProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({
|
||||
String host,
|
||||
User user,
|
||||
}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getGasCylinderType,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class GasCylinderTypesProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({
|
||||
// String host,
|
||||
// User user,
|
||||
// }) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getGasCylinderType,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class GasStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({
|
||||
String host,
|
||||
User user,
|
||||
}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getGasStatus,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class GasStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({
|
||||
// String host,
|
||||
// User user,
|
||||
// }) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getGasStatus,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class GasTypesProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({
|
||||
String host,
|
||||
User user,
|
||||
}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getGasTypes,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class GasTypesProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({
|
||||
// String host,
|
||||
// User user,
|
||||
// }) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getGasTypes,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,74 +1,75 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class PentryStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getPentryStatus,
|
||||
);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class PentryStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getPentryStatus,
|
||||
// );
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List listJson = json.decode(response.body)["data"];
|
||||
// _items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,74 +1,75 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class PentryTaskStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getPentryTaskStatus,
|
||||
);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class PentryTaskStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getPentryTaskStatus,
|
||||
// );
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _items = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,74 +1,75 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class PentryVisitStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getPentryVisitStatus,
|
||||
);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class PentryVisitStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getPentryVisitStatus,
|
||||
// );
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List listJson = json.decode(response.body)["data"];
|
||||
// _items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceRequestDefectTypesProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceReportDefectTypes,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceRequestDefectTypesProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceReportDefectTypes,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List listJson = json.decode(response.body)["data"];
|
||||
// _items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,72 +1,73 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceReportEquipmentStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_status = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _status;
|
||||
|
||||
List<Lookup> get statuses => _status;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getTypes({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.equipmentStatus);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceReportEquipmentStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _status = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _status;
|
||||
//
|
||||
// List<Lookup> get statuses => _status;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getTypes({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(URLs.equipmentStatus);
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,79 +1,80 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class ServiceReportMaintenanceSituationProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_calls = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _calls;
|
||||
|
||||
List<Lookup> get operators => _calls;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getOperators(String woId) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
woId == null ? "${URLs.getMaintenanceSituation}" : "${URLs.getServiceReportLastCalls}?parentWOId=$woId&isAdd=true&id=${0}&typeTransaction='Nothing'",
|
||||
);
|
||||
// response = await get(
|
||||
// Uri.parse(
|
||||
// URLs.getServiceReportLastCalls
|
||||
// +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// ),
|
||||
// );
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// class ServiceReportMaintenanceSituationProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _calls = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _calls;
|
||||
//
|
||||
// List<Lookup> get operators => _calls;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getOperators(String woId) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// woId == null ? "${URLs.getMaintenanceSituation}" : "${URLs.getServiceReportLastCalls}?parentWOId=$woId&isAdd=true&id=${0}&typeTransaction='Nothing'",
|
||||
// );
|
||||
// // response = await get(
|
||||
// // Uri.parse(
|
||||
// // URLs.getServiceReportLastCalls
|
||||
// // +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// // ),
|
||||
// // );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,75 +1,76 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
@Deprecated("Use the one inside lib/providers folder")
|
||||
class ServiceRequestPriorityProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_items = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _items;
|
||||
|
||||
List<Lookup> get items => _items;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceReportPriority,
|
||||
);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
_items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// @Deprecated("Use the one inside lib/providers folder")
|
||||
// class ServiceRequestPriorityProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _items = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _items;
|
||||
//
|
||||
// List<Lookup> get items => _items;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceReportPriority,
|
||||
// );
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List listJson = json.decode(response.body)["data"];
|
||||
// _items = listJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceReportReasonsProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_reasons = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _reasons;
|
||||
|
||||
List<Lookup> get reasons => _reasons;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getTypes({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceReportReasons+"&serviceRequestId=72355",
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_reasons = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceReportReasonsProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _reasons = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _reasons;
|
||||
//
|
||||
// List<Lookup> get reasons => _reasons;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getTypes({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceReportReasons+"&serviceRequestId=72355",
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _reasons = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,74 +1,75 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceReportStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_status = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _status;
|
||||
|
||||
List<Lookup> get statuses => _status;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getTypes({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceReportStatus,
|
||||
);
|
||||
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceReportStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _status = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _status;
|
||||
//
|
||||
// List<Lookup> get statuses => _status;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getTypes({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceReportStatus,
|
||||
// );
|
||||
//
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _status = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceReportTypesProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_types = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _types;
|
||||
|
||||
List<Lookup> get types => _types;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getTypes({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceReportTypes,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_types = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceReportTypesProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _types = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _types;
|
||||
//
|
||||
// List<Lookup> get types => _types;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getTypes({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceReportTypes,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _types = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/employee.dart';
|
||||
|
||||
class ServiceReportUsersProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_engineers = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Employee> _engineers;
|
||||
|
||||
List<Employee> get engineers => _engineers;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getAllUsers() async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get("${URLs.getEngineers}");
|
||||
// response = await get(
|
||||
// Uri.parse(
|
||||
// URLs.getServiceReportLastCalls
|
||||
// +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// ),
|
||||
// );
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List usersListJson = json.decode(response.body);
|
||||
_engineers = usersListJson.map((type) => Employee.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/employee.dart';
|
||||
//
|
||||
// class ServiceReportUsersProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _engineers = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Employee> _engineers;
|
||||
//
|
||||
// List<Employee> get engineers => _engineers;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getAllUsers() async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get("${URLs.getEngineers}");
|
||||
// // response = await get(
|
||||
// // Uri.parse(
|
||||
// // URLs.getServiceReportLastCalls
|
||||
// // +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// // ),
|
||||
// // );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List usersListJson = json.decode(response.body);
|
||||
// _engineers = usersListJson.map((type) => Employee.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,79 +1,80 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
class ServiceReportVisitOperatorProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_calls = null;
|
||||
_loading = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _calls;
|
||||
|
||||
List<Lookup> get operators => _calls;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getOperators() async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
"${URLs.getDateOperators}",
|
||||
);
|
||||
// response = await get(
|
||||
// Uri.parse(
|
||||
// URLs.getServiceReportLastCalls
|
||||
// +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// ),
|
||||
// );
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// class ServiceReportVisitOperatorProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _calls = null;
|
||||
// _loading = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _calls;
|
||||
//
|
||||
// List<Lookup> get operators => _calls;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getOperators() async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// "${URLs.getDateOperators}",
|
||||
// );
|
||||
// // response = await get(
|
||||
// // Uri.parse(
|
||||
// // URLs.getServiceReportLastCalls
|
||||
// // +(serviceStatus == null ? "" : "?service_status=$serviceStatus")
|
||||
// // ),
|
||||
// // );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceFirstActionProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_statuses = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _statuses;
|
||||
|
||||
List<Lookup> get items => _statuses;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceFirstAction,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceFirstActionProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _statuses = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _statuses;
|
||||
//
|
||||
// List<Lookup> get items => _statuses;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceFirstAction,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,73 +1,74 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceRequestStatusProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_statuses = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _statuses;
|
||||
|
||||
List<Lookup> get items => _statuses;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceRequestStatus,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceRequestStatusProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _statuses = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _statuses;
|
||||
//
|
||||
// List<Lookup> get items => _statuses;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceRequestStatus,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceRequestedThroughProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_statuses = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _statuses;
|
||||
|
||||
List<Lookup> get items => _statuses;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceRequestThrough,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Lookup getDefaultItem() {
|
||||
return items?.firstWhere((element) => element.name.toLowerCase().contains("app"));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceRequestedThroughProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _statuses = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _statuses;
|
||||
//
|
||||
// List<Lookup> get items => _statuses;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceRequestThrough,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Lookup getDefaultItem() {
|
||||
// return items?.firstWhere((element) => element.name.toLowerCase().contains("app"));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,77 +1,78 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
|
||||
class ServiceRequestTypeProvider extends ChangeNotifier {
|
||||
//reset provider data
|
||||
void reset() {
|
||||
_statuses = null;
|
||||
_stateCode = null;
|
||||
}
|
||||
|
||||
// state code of current request to defied error message
|
||||
// like 400 customer request failed
|
||||
// 500 service not available
|
||||
int _stateCode;
|
||||
|
||||
int get stateCode => _stateCode;
|
||||
|
||||
// contain user data
|
||||
// when user not login or register _user = null
|
||||
List<Lookup> _statuses;
|
||||
|
||||
List<Lookup> get items => _statuses;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// return -2 if request in progress
|
||||
/// return -1 if error happen when sending request
|
||||
/// return state code if request complete may be 200, 404 or 403
|
||||
/// for more details check http state manager
|
||||
/// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
Future<int> getData({String host, User user}) async {
|
||||
if (_loading == true) return -2;
|
||||
_loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(
|
||||
URLs.getServiceRequestTypes,
|
||||
);
|
||||
_stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
_statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
}
|
||||
_loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
_loading = false;
|
||||
_stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Lookup getDefaultItem() {
|
||||
return items?.firstWhere((element) => element.name.toLowerCase().contains("maintenance"));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/api_manager.dart';
|
||||
// import 'package:test_sa/controllers/api_routes/urls.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
//
|
||||
// class ServiceRequestTypeProvider extends ChangeNotifier {
|
||||
// //reset provider data
|
||||
// void reset() {
|
||||
// _statuses = null;
|
||||
// _stateCode = null;
|
||||
// }
|
||||
//
|
||||
// // state code of current request to defied error message
|
||||
// // like 400 customer request failed
|
||||
// // 500 service not available
|
||||
// int _stateCode;
|
||||
//
|
||||
// int get stateCode => _stateCode;
|
||||
//
|
||||
// // contain user data
|
||||
// // when user not login or register _user = null
|
||||
// List<Lookup> _statuses;
|
||||
//
|
||||
// List<Lookup> get items => _statuses;
|
||||
//
|
||||
// // 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();
|
||||
// }
|
||||
//
|
||||
// /// return -2 if request in progress
|
||||
// /// return -1 if error happen when sending request
|
||||
// /// return state code if request complete may be 200, 404 or 403
|
||||
// /// for more details check http state manager
|
||||
// /// lib\controllers\http_status_manger\http_status_manger.dart
|
||||
// Future<int> getData({String host, User user}) async {
|
||||
// if (_loading == true) return -2;
|
||||
// _loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(
|
||||
// URLs.getServiceRequestTypes,
|
||||
// );
|
||||
// _stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// _statuses = categoriesListJson.map((e) => Lookup.fromJson(e)).toList();
|
||||
// }
|
||||
// _loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// _loading = false;
|
||||
// _stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Lookup getDefaultItem() {
|
||||
// return items?.firstWhere((element) => element.name.toLowerCase().contains("maintenance"));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,149 +1,150 @@
|
||||
class Customer {
|
||||
List<Data> data;
|
||||
String message;
|
||||
String innerMessage;
|
||||
int responseCode;
|
||||
bool isSuccess;
|
||||
|
||||
Customer({this.data, this.message, this.innerMessage, this.responseCode, this.isSuccess});
|
||||
|
||||
Customer.fromJson(Map<String, dynamic> json) {
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data.add(new Data.fromJson(v));
|
||||
});
|
||||
}
|
||||
message = json['message'];
|
||||
innerMessage = json['innerMessage'];
|
||||
responseCode = json['responseCode'];
|
||||
isSuccess = json['isSuccess'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['message'] = this.message;
|
||||
data['innerMessage'] = this.innerMessage;
|
||||
data['responseCode'] = this.responseCode;
|
||||
data['isSuccess'] = this.isSuccess;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int id;
|
||||
int customerCode;
|
||||
String custName;
|
||||
List<Buildings> buildings;
|
||||
|
||||
Data({this.id, this.customerCode, this.custName, this.buildings});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
customerCode = json['customerCode'];
|
||||
custName = json['custName'];
|
||||
if (json['buildings'] != null) {
|
||||
buildings = [];
|
||||
json['buildings'].forEach((v) {
|
||||
buildings.add(new Buildings.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['customerCode'] = this.customerCode;
|
||||
data['custName'] = this.custName;
|
||||
if (this.buildings != null) {
|
||||
data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Buildings {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
List<Floors> floors;
|
||||
|
||||
Buildings({this.id, this.name, this.value, this.floors});
|
||||
|
||||
Buildings.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
if (json['floors'] != null) {
|
||||
floors = [];
|
||||
json['floors'].forEach((v) {
|
||||
floors.add(new Floors.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
data['value'] = this.value;
|
||||
if (this.floors != null) {
|
||||
data['floors'] = this.floors.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Floors {
|
||||
int id;
|
||||
String name;
|
||||
int value;
|
||||
List<Departments> departments;
|
||||
|
||||
Floors({this.id, this.name, this.value, this.departments});
|
||||
|
||||
Floors.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
value = json['value'];
|
||||
if (json['departments'] != null) {
|
||||
departments = [];
|
||||
json['departments'].forEach((v) {
|
||||
departments.add(new Departments.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
data['value'] = this.value;
|
||||
if (this.departments != null) {
|
||||
data['departments'] = this.departments.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Departments {
|
||||
int id;
|
||||
String name;
|
||||
|
||||
Departments({this.id, this.name});
|
||||
|
||||
Departments.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// class Customer {
|
||||
// List<Data> data;
|
||||
// String message;
|
||||
// String innerMessage;
|
||||
// int responseCode;
|
||||
// bool isSuccess;
|
||||
//
|
||||
// Customer({this.data, this.message, this.innerMessage, this.responseCode, this.isSuccess});
|
||||
//
|
||||
// Customer.fromJson(Map<String, dynamic> json) {
|
||||
// if (json['data'] != null) {
|
||||
// data = [];
|
||||
// json['data'].forEach((v) {
|
||||
// data.add(new Data.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// message = json['message'];
|
||||
// innerMessage = json['innerMessage'];
|
||||
// responseCode = json['responseCode'];
|
||||
// isSuccess = json['isSuccess'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// data['message'] = this.message;
|
||||
// data['innerMessage'] = this.innerMessage;
|
||||
// data['responseCode'] = this.responseCode;
|
||||
// data['isSuccess'] = this.isSuccess;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Data {
|
||||
// int id;
|
||||
// int customerCode;
|
||||
// String custName;
|
||||
// List<Buildings> buildings;
|
||||
//
|
||||
// Data({this.id, this.customerCode, this.custName, this.buildings});
|
||||
//
|
||||
// Data.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// customerCode = json['customerCode'];
|
||||
// custName = json['custName'];
|
||||
// if (json['buildings'] != null) {
|
||||
// buildings = [];
|
||||
// json['buildings'].forEach((v) {
|
||||
// buildings.add(new Buildings.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['customerCode'] = this.customerCode;
|
||||
// data['custName'] = this.custName;
|
||||
// if (this.buildings != null) {
|
||||
// data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Buildings {
|
||||
// int id;
|
||||
// String name;
|
||||
// int value;
|
||||
// List<Floors> floors;
|
||||
//
|
||||
// Buildings({this.id, this.name, this.value, this.floors});
|
||||
//
|
||||
// Buildings.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// value = json['value'];
|
||||
// if (json['floors'] != null) {
|
||||
// floors = [];
|
||||
// json['floors'].forEach((v) {
|
||||
// floors.add(new Floors.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['name'] = this.name;
|
||||
// data['value'] = this.value;
|
||||
// if (this.floors != null) {
|
||||
// data['floors'] = this.floors.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Floors {
|
||||
// int id;
|
||||
// String name;
|
||||
// int value;
|
||||
// List<Departments> departments;
|
||||
//
|
||||
// Floors({this.id, this.name, this.value, this.departments});
|
||||
//
|
||||
// Floors.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// value = json['value'];
|
||||
// if (json['departments'] != null) {
|
||||
// departments = [];
|
||||
// json['departments'].forEach((v) {
|
||||
// departments.add(new Departments.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['name'] = this.name;
|
||||
// data['value'] = this.value;
|
||||
// if (this.departments != null) {
|
||||
// data['departments'] = this.departments.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Departments {
|
||||
// int id;
|
||||
// String name;
|
||||
//
|
||||
// Departments({this.id, this.name});
|
||||
//
|
||||
// Departments.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['name'] = this.name;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,43 +1,44 @@
|
||||
import 'asset.dart';
|
||||
import 'asset_transfer.dart';
|
||||
|
||||
class AssetTransferSearch extends AssetTransfer {
|
||||
Asset asset;
|
||||
int pageNumber = 10, pageSize;
|
||||
bool mostRecent;
|
||||
|
||||
Map<String, dynamic> toSearch() {
|
||||
final map = <String, dynamic>{};
|
||||
map['pageSize'] = pageSize;
|
||||
map['pageNumber'] = pageNumber;
|
||||
map['id'] = id;
|
||||
map['transferNo'] = transferNo;
|
||||
map['transferCode'] = transferCode;
|
||||
map['assetId'] = assetId;
|
||||
map['destSiteId'] = destSiteId;
|
||||
map['destBuildingId'] = destBuildingId;
|
||||
map['destFloorId'] = destFloorId;
|
||||
map['destDepartmentId'] = destDepartmentId;
|
||||
map['destRoomId'] = destRoomId;
|
||||
map['senderSiteId'] = senderSiteId;
|
||||
map['senderBuildingId'] = senderBuildingId;
|
||||
map['senderFloorId'] = senderFloorId;
|
||||
map['senderDepartmentId'] = senderDepartmentId;
|
||||
map['senderRoom'] = senderRoom;
|
||||
map['senderAssignedEmployeeId'] = senderAssignedEmployeeId;
|
||||
map['receiverAssignedEmployeeId'] = receiverAssignedEmployeeId;
|
||||
map['mostRecent'] = mostRecent;
|
||||
map['assetNumber'] = asset?.assetNumber;
|
||||
map['assetSerialNo'] = asset?.assetSerialNo;
|
||||
map['siteName'] = asset?.site?.custName;
|
||||
|
||||
/// TODO : the below parameters need to be discussed
|
||||
// map['relatedToEmployeeId'] = "";
|
||||
// map['assetGroup'] = {
|
||||
// "id": 1,
|
||||
// "name": "",
|
||||
// "code": "",
|
||||
// };
|
||||
return map;
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'asset.dart';
|
||||
// import 'asset_transfer.dart';
|
||||
//
|
||||
// class AssetTransferSearch extends AssetTransfer {
|
||||
// Asset asset;
|
||||
// int pageNumber = 10, pageSize;
|
||||
// bool mostRecent;
|
||||
//
|
||||
// Map<String, dynamic> toSearch() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['pageSize'] = pageSize;
|
||||
// map['pageNumber'] = pageNumber;
|
||||
// map['id'] = id;
|
||||
// map['transferNo'] = transferNo;
|
||||
// map['transferCode'] = transferCode;
|
||||
// map['assetId'] = assetId;
|
||||
// map['destSiteId'] = destSiteId;
|
||||
// map['destBuildingId'] = destBuildingId;
|
||||
// map['destFloorId'] = destFloorId;
|
||||
// map['destDepartmentId'] = destDepartmentId;
|
||||
// map['destRoomId'] = destRoomId;
|
||||
// map['senderSiteId'] = senderSiteId;
|
||||
// map['senderBuildingId'] = senderBuildingId;
|
||||
// map['senderFloorId'] = senderFloorId;
|
||||
// map['senderDepartmentId'] = senderDepartmentId;
|
||||
// map['senderRoom'] = senderRoom;
|
||||
// map['senderAssignedEmployeeId'] = senderAssignedEmployeeId;
|
||||
// map['receiverAssignedEmployeeId'] = receiverAssignedEmployeeId;
|
||||
// map['mostRecent'] = mostRecent;
|
||||
// map['assetNumber'] = asset?.assetNumber;
|
||||
// map['assetSerialNo'] = asset?.assetSerialNo;
|
||||
// map['siteName'] = asset?.site?.custName;
|
||||
//
|
||||
// /// TODO : the below parameters need to be discussed
|
||||
// // map['relatedToEmployeeId'] = "";
|
||||
// // map['assetGroup'] = {
|
||||
// // "id": 1,
|
||||
// // "name": "",
|
||||
// // "code": "",
|
||||
// // };
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,67 +1,68 @@
|
||||
import '../hospital.dart';
|
||||
import 'asset.dart';
|
||||
|
||||
@Deprecated("Use asset_transfer_search.dart instead of this one")
|
||||
class DeviceTransferSearch {
|
||||
Asset device;
|
||||
String title, room;
|
||||
bool mostRecent;
|
||||
Hospital hospital;
|
||||
Buildings building;
|
||||
List<Buildings> buildingsList;
|
||||
Floors floor;
|
||||
List<Floors> floorsList;
|
||||
Departments department;
|
||||
List<Departments> departmentsList;
|
||||
|
||||
DeviceTransferSearch({
|
||||
this.device,
|
||||
this.hospital,
|
||||
this.building,
|
||||
this.floor,
|
||||
this.department,
|
||||
this.room,
|
||||
this.title,
|
||||
this.mostRecent = true,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
Map<String, dynamic> search = {};
|
||||
if (title != null && title.isNotEmpty) {
|
||||
search["transferCode"] = title;
|
||||
}
|
||||
if (device != null) {
|
||||
search["assetId"] = device.id;
|
||||
}
|
||||
if (mostRecent != null) {
|
||||
search["mostRecent"] = mostRecent;
|
||||
}
|
||||
if (hospital?.id != null) {
|
||||
search["destSiteId"] = hospital.id;
|
||||
}
|
||||
if (building?.id != null) {
|
||||
search["destBuildingId"] = building.id;
|
||||
}
|
||||
if (floor?.id != null) {
|
||||
search["destFloorId"] = floor.id;
|
||||
}
|
||||
if (department?.id != null) {
|
||||
search["destDepartmentId"] = department.id;
|
||||
}
|
||||
if (room != null && room.isNotEmpty) {
|
||||
search["destRoom"] = department.id;
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
void fromSearch(DeviceTransferSearch newSearch) {
|
||||
title = newSearch.title;
|
||||
room = newSearch.room;
|
||||
mostRecent = newSearch.mostRecent;
|
||||
device = newSearch.device;
|
||||
hospital = newSearch.hospital;
|
||||
building = newSearch.building;
|
||||
floor = newSearch.floor;
|
||||
department = newSearch.department;
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import '../hospital.dart';
|
||||
// import 'asset.dart';
|
||||
//
|
||||
// @Deprecated("Use asset_transfer_search.dart instead of this one")
|
||||
// class DeviceTransferSearch {
|
||||
// Asset device;
|
||||
// String title, room;
|
||||
// bool mostRecent;
|
||||
// Hospital hospital;
|
||||
// Buildings building;
|
||||
// List<Buildings> buildingsList;
|
||||
// Floors floor;
|
||||
// List<Floors> floorsList;
|
||||
// Departments department;
|
||||
// List<Departments> departmentsList;
|
||||
//
|
||||
// DeviceTransferSearch({
|
||||
// this.device,
|
||||
// this.hospital,
|
||||
// this.building,
|
||||
// this.floor,
|
||||
// this.department,
|
||||
// this.room,
|
||||
// this.title,
|
||||
// this.mostRecent = true,
|
||||
// });
|
||||
//
|
||||
// Map<String, dynamic> toMap() {
|
||||
// Map<String, dynamic> search = {};
|
||||
// if (title != null && title.isNotEmpty) {
|
||||
// search["transferCode"] = title;
|
||||
// }
|
||||
// if (device != null) {
|
||||
// search["assetId"] = device.id;
|
||||
// }
|
||||
// if (mostRecent != null) {
|
||||
// search["mostRecent"] = mostRecent;
|
||||
// }
|
||||
// if (hospital?.id != null) {
|
||||
// search["destSiteId"] = hospital.id;
|
||||
// }
|
||||
// if (building?.id != null) {
|
||||
// search["destBuildingId"] = building.id;
|
||||
// }
|
||||
// if (floor?.id != null) {
|
||||
// search["destFloorId"] = floor.id;
|
||||
// }
|
||||
// if (department?.id != null) {
|
||||
// search["destDepartmentId"] = department.id;
|
||||
// }
|
||||
// if (room != null && room.isNotEmpty) {
|
||||
// search["destRoom"] = department.id;
|
||||
// }
|
||||
// return search;
|
||||
// }
|
||||
//
|
||||
// void fromSearch(DeviceTransferSearch newSearch) {
|
||||
// title = newSearch.title;
|
||||
// room = newSearch.room;
|
||||
// mostRecent = newSearch.mostRecent;
|
||||
// device = newSearch.device;
|
||||
// hospital = newSearch.hospital;
|
||||
// building = newSearch.building;
|
||||
// floor = newSearch.floor;
|
||||
// department = newSearch.department;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,49 +1,50 @@
|
||||
@Deprecated("Use the class inside model_definition.dart")
|
||||
class ModelDefinition {
|
||||
int id;
|
||||
String assetName;
|
||||
String modelDefCode;
|
||||
String modelName;
|
||||
String manufacturerName;
|
||||
String supplierName;
|
||||
String replacementDate;
|
||||
int lifeSpan;
|
||||
|
||||
ModelDefinition({
|
||||
this.id,
|
||||
this.assetName,
|
||||
this.modelDefCode,
|
||||
this.modelName,
|
||||
this.manufacturerName,
|
||||
this.supplierName,
|
||||
this.replacementDate,
|
||||
this.lifeSpan,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['assetName'] = assetName;
|
||||
data['modelDefCode'] = modelDefCode;
|
||||
data['modelName'] = modelName;
|
||||
data['manufacturerName'] = manufacturerName;
|
||||
data['supplierName'] = supplierName;
|
||||
data['replacementDate'] = replacementDate;
|
||||
data['lifeSpan'] = lifeSpan;
|
||||
return data;
|
||||
}
|
||||
|
||||
factory ModelDefinition.fromJson(Map<String, dynamic> map) {
|
||||
if (map == null) return null;
|
||||
return ModelDefinition(
|
||||
id: map['id'] as int,
|
||||
assetName: map['assetName'] as String,
|
||||
modelDefCode: map['modelDefCode'] as String,
|
||||
modelName: map['modelName'] as String,
|
||||
manufacturerName: map['manufacturerName'] as String,
|
||||
supplierName: map['supplierName'] as String,
|
||||
replacementDate: map['replacementDate'] as String,
|
||||
lifeSpan: map['lifeSpan'] as int,
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// @Deprecated("Use the class inside model_definition.dart")
|
||||
// class ModelDefinition {
|
||||
// int id;
|
||||
// String assetName;
|
||||
// String modelDefCode;
|
||||
// String modelName;
|
||||
// String manufacturerName;
|
||||
// String supplierName;
|
||||
// String replacementDate;
|
||||
// int lifeSpan;
|
||||
//
|
||||
// ModelDefinition({
|
||||
// this.id,
|
||||
// this.assetName,
|
||||
// this.modelDefCode,
|
||||
// this.modelName,
|
||||
// this.manufacturerName,
|
||||
// this.supplierName,
|
||||
// this.replacementDate,
|
||||
// this.lifeSpan,
|
||||
// });
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = <String, dynamic>{};
|
||||
// data['id'] = id;
|
||||
// data['assetName'] = assetName;
|
||||
// data['modelDefCode'] = modelDefCode;
|
||||
// data['modelName'] = modelName;
|
||||
// data['manufacturerName'] = manufacturerName;
|
||||
// data['supplierName'] = supplierName;
|
||||
// data['replacementDate'] = replacementDate;
|
||||
// data['lifeSpan'] = lifeSpan;
|
||||
// return data;
|
||||
// }
|
||||
//
|
||||
// factory ModelDefinition.fromJson(Map<String, dynamic> map) {
|
||||
// if (map == null) return null;
|
||||
// return ModelDefinition(
|
||||
// id: map['id'] as int,
|
||||
// assetName: map['assetName'] as String,
|
||||
// modelDefCode: map['modelDefCode'] as String,
|
||||
// modelName: map['modelName'] as String,
|
||||
// manufacturerName: map['manufacturerName'] as String,
|
||||
// supplierName: map['supplierName'] as String,
|
||||
// replacementDate: map['replacementDate'] as String,
|
||||
// lifeSpan: map['lifeSpan'] as int,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,50 +1,51 @@
|
||||
enum TranslationKeys {
|
||||
login,
|
||||
enterCredsToLogin,
|
||||
forgotPassword,
|
||||
password,
|
||||
username,
|
||||
requiredField,
|
||||
passwordLengthMessage,
|
||||
overview,
|
||||
myRequests,
|
||||
myAssets,
|
||||
contactUs,
|
||||
welcome,
|
||||
openWhatsapp,
|
||||
liveChat,
|
||||
callUs,
|
||||
gasRefillRequest,
|
||||
transferRequest,
|
||||
serviceRequest,
|
||||
newServiceRequest,
|
||||
search,
|
||||
filter,
|
||||
newGasRefillRequest,
|
||||
newTransferRequest,
|
||||
submitRequest,
|
||||
select,
|
||||
gasType,
|
||||
quantity,
|
||||
cylinderType,
|
||||
cylinderSize,
|
||||
department,
|
||||
httpError,
|
||||
tryAgain,
|
||||
destinationSite,
|
||||
add,
|
||||
site,
|
||||
onlyNumbers,
|
||||
youHaveToSelect,
|
||||
building,
|
||||
floor,
|
||||
createdSuccessfully,
|
||||
failedToCompleteRequest,
|
||||
youHaveToAddRequests,
|
||||
assetNo,
|
||||
manufacture,
|
||||
model,
|
||||
serialNumber,
|
||||
device,
|
||||
pickAsset,
|
||||
}
|
||||
///todo deleted
|
||||
// enum TranslationKeys {
|
||||
// login,
|
||||
// enterCredsToLogin,
|
||||
// forgotPassword,
|
||||
// password,
|
||||
// username,
|
||||
// requiredField,
|
||||
// passwordLengthMessage,
|
||||
// overview,
|
||||
// myRequests,
|
||||
// myAssets,
|
||||
// contactUs,
|
||||
// welcome,
|
||||
// openWhatsapp,
|
||||
// liveChat,
|
||||
// callUs,
|
||||
// gasRefillRequest,
|
||||
// transferRequest,
|
||||
// serviceRequest,
|
||||
// newServiceRequest,
|
||||
// search,
|
||||
// filter,
|
||||
// newGasRefillRequest,
|
||||
// newTransferRequest,
|
||||
// submitRequest,
|
||||
// select,
|
||||
// gasType,
|
||||
// quantity,
|
||||
// cylinderType,
|
||||
// cylinderSize,
|
||||
// department,
|
||||
// httpError,
|
||||
// tryAgain,
|
||||
// destinationSite,
|
||||
// add,
|
||||
// site,
|
||||
// onlyNumbers,
|
||||
// youHaveToSelect,
|
||||
// building,
|
||||
// floor,
|
||||
// createdSuccessfully,
|
||||
// failedToCompleteRequest,
|
||||
// youHaveToAddRequests,
|
||||
// assetNo,
|
||||
// manufacture,
|
||||
// model,
|
||||
// serialNumber,
|
||||
// device,
|
||||
// pickAsset,
|
||||
// }
|
||||
|
||||
@ -1,22 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTabBar extends StatelessWidget {
|
||||
const AppTabBar({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TabBar(
|
||||
tabs: [
|
||||
Tab(
|
||||
icon: Icon(Icons.cloud_outlined),
|
||||
),
|
||||
Tab(
|
||||
icon: Icon(Icons.beach_access_sharp),
|
||||
),
|
||||
Tab(
|
||||
icon: Icon(Icons.brightness_5_sharp),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
//
|
||||
// class AppTabBar extends StatelessWidget {
|
||||
// const AppTabBar({Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return TabBar(
|
||||
// tabs: [
|
||||
// Tab(
|
||||
// icon: Icon(Icons.cloud_outlined),
|
||||
// ),
|
||||
// Tab(
|
||||
// icon: Icon(Icons.beach_access_sharp),
|
||||
// ),
|
||||
// Tab(
|
||||
// icon: Icon(Icons.brightness_5_sharp),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,65 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
|
||||
import '../../app_style/app_color.dart';
|
||||
|
||||
class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
|
||||
const HomeAppBar({Key key, this.scaffoldKey}) : super(key: key);
|
||||
|
||||
@override
|
||||
Size get preferredSize => Size.fromHeight(60.toScreenHeight);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||
child: AppBar(
|
||||
backgroundColor: context.isDark ? AppColor.backgroundDark : AppColor.backgroundLight,
|
||||
automaticallyImplyLeading: false,
|
||||
elevation: 0,
|
||||
leadingWidth: 48.toScreenWidth,
|
||||
leading: InkWell(
|
||||
onTap: () {
|
||||
scaffoldKey.currentState.openDrawer();
|
||||
},
|
||||
child: CircleAvatar(child: Image.network("", fit: BoxFit.fill)),
|
||||
),
|
||||
actions: [
|
||||
Stack(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.notifications,
|
||||
color: context.isDark ? AppColor.neutral10 : AppColor.neutral20,
|
||||
size: 34,
|
||||
),
|
||||
|
||||
///TODO [zaid] : put notifications count rather than number 1
|
||||
if (1 != 0)
|
||||
PositionedDirectional(
|
||||
end: 0,
|
||||
top: 0,
|
||||
child: Container(
|
||||
height: 20.toScreenWidth,
|
||||
width: 20.toScreenWidth,
|
||||
padding: const EdgeInsets.all(1),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.red50,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
(1).toString(),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500, color: AppColor.neutral30),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
//
|
||||
// import '../../app_style/app_color.dart';
|
||||
//
|
||||
// class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
// final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
//
|
||||
// const HomeAppBar({Key key, this.scaffoldKey}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Size get preferredSize => Size.fromHeight(60.toScreenHeight);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||
// child: AppBar(
|
||||
// backgroundColor: context.isDark ? AppColor.backgroundDark : AppColor.backgroundLight,
|
||||
// automaticallyImplyLeading: false,
|
||||
// elevation: 0,
|
||||
// leadingWidth: 48.toScreenWidth,
|
||||
// leading: InkWell(
|
||||
// onTap: () {
|
||||
// scaffoldKey.currentState.openDrawer();
|
||||
// },
|
||||
// child: CircleAvatar(child: Image.network("", fit: BoxFit.fill)),
|
||||
// ),
|
||||
// actions: [
|
||||
// Stack(
|
||||
// children: <Widget>[
|
||||
// Icon(
|
||||
// Icons.notifications,
|
||||
// color: context.isDark ? AppColor.neutral10 : AppColor.neutral20,
|
||||
// size: 34,
|
||||
// ),
|
||||
//
|
||||
// ///TODO [zaid] : put notifications count rather than number 1
|
||||
// if (1 != 0)
|
||||
// PositionedDirectional(
|
||||
// end: 0,
|
||||
// top: 0,
|
||||
// child: Container(
|
||||
// height: 20.toScreenWidth,
|
||||
// width: 20.toScreenWidth,
|
||||
// padding: const EdgeInsets.all(1),
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.red50,
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
// child: Text(
|
||||
// (1).toString(),
|
||||
// style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500, color: AppColor.neutral30),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../../controllers/api_routes/api_manager.dart';
|
||||
import '../../../controllers/api_routes/urls.dart';
|
||||
|
||||
class PentryTaskStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading ?? false) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
Response response;
|
||||
try {
|
||||
response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List listJson = json.decode(response.body)["data"];
|
||||
items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
//
|
||||
// import '../../../controllers/api_routes/api_manager.dart';
|
||||
// import '../../../controllers/api_routes/urls.dart';
|
||||
//
|
||||
// class PentryTaskStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
// @override
|
||||
// Future getDate() async {
|
||||
// if (loading ?? false) return -2;
|
||||
// loading = true;
|
||||
// notifyListeners();
|
||||
// Response response;
|
||||
// try {
|
||||
// response = await ApiManager.instance.get(URLs.getPentryTaskStatus);
|
||||
// } catch (error) {
|
||||
// loading = false;
|
||||
// stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List listJson = json.decode(response.body)["data"];
|
||||
// items = listJson.map((department) => Lookup.fromJson(department)).toList();
|
||||
// }
|
||||
// loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,36 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import '../../models/lookup.dart';
|
||||
|
||||
class RequestStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getServiceRequestStatus);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
//
|
||||
// import '../../controllers/api_routes/api_manager.dart';
|
||||
// import '../../controllers/api_routes/urls.dart';
|
||||
// import '../../models/lookup.dart';
|
||||
//
|
||||
// class RequestStatusProvider extends LoadingListNotifier<Lookup> {
|
||||
// @override
|
||||
// Future getDate() async {
|
||||
// if (loading == true) return -2;
|
||||
// loading = true;
|
||||
// notifyListeners();
|
||||
// loading = true;
|
||||
// notifyListeners();
|
||||
// try {
|
||||
// Response response = await ApiManager.instance.get(URLs.getServiceRequestStatus);
|
||||
// stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// loading = false;
|
||||
// stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,36 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
|
||||
import '../../controllers/api_routes/api_manager.dart';
|
||||
import '../../controllers/api_routes/urls.dart';
|
||||
import '../../models/lookup.dart';
|
||||
|
||||
class AssetTypesProvider extends LoadingListNotifier<Lookup> {
|
||||
@override
|
||||
Future getDate() async {
|
||||
if (loading == true) return -2;
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
loading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
Response response = await ApiManager.instance.get(URLs.getAssetTypes);
|
||||
stateCode = response.statusCode;
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// client's request was successfully received
|
||||
List categoriesListJson = json.decode(response.body)["data"];
|
||||
items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
}
|
||||
loading = false;
|
||||
notifyListeners();
|
||||
return response.statusCode;
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
stateCode = -1;
|
||||
notifyListeners();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:http/http.dart';
|
||||
// import 'package:test_sa/providers/loading_list_notifier.dart';
|
||||
//
|
||||
// import '../../controllers/api_routes/api_manager.dart';
|
||||
// import '../../controllers/api_routes/urls.dart';
|
||||
// import '../../models/lookup.dart';
|
||||
//
|
||||
// class AssetTypesProvider extends LoadingListNotifier<Lookup> {
|
||||
// @override
|
||||
// Future getDate() async {
|
||||
// if (loading == true) return -2;
|
||||
// loading = true;
|
||||
// notifyListeners();
|
||||
// loading = true;
|
||||
// notifyListeners();
|
||||
// try {
|
||||
// Response response = await ApiManager.instance.get(URLs.getAssetTypes);
|
||||
// stateCode = response.statusCode;
|
||||
// if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
// // client's request was successfully received
|
||||
// List categoriesListJson = json.decode(response.body)["data"];
|
||||
// items = categoriesListJson.map((item) => Lookup.fromJson(item)).toList();
|
||||
// }
|
||||
// loading = false;
|
||||
// notifyListeners();
|
||||
// return response.statusCode;
|
||||
// } catch (error) {
|
||||
// loading = false;
|
||||
// stateCode = -1;
|
||||
// notifyListeners();
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,161 +1,162 @@
|
||||
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/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/controllers/validator/validator.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
|
||||
class Login extends StatefulWidget {
|
||||
static final String id = "/login";
|
||||
|
||||
@override
|
||||
_LoginState createState() => _LoginState();
|
||||
}
|
||||
|
||||
class _LoginState extends State<Login> {
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
User _user = User();
|
||||
bool _obscurePassword = true;
|
||||
bool _firstTime = true;
|
||||
double _height;
|
||||
double _width;
|
||||
String _payload;
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_height = MediaQuery.of(context).size.height;
|
||||
_width = MediaQuery.of(context).size.width;
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: SafeArea(
|
||||
child: LoadingManager(
|
||||
isLoading: _userProvider.isLoading || !_settingProvider.isLoaded,
|
||||
isFailedLoading: false,
|
||||
stateCode: 200,
|
||||
onRefresh: () async {},
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: SingleChildScrollView(
|
||||
//padding: EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
children: [
|
||||
//AppNameBar(),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 7,
|
||||
),
|
||||
Hero(
|
||||
tag: "logo",
|
||||
child: Image(
|
||||
height: _height / 6,
|
||||
fit: BoxFit.contain,
|
||||
image: AssetImage("assets/images/logo.png"),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24 * AppStyle.getScaleFactor(context), vertical: 24 * AppStyle.getScaleFactor(context)),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 24 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _user?.userName,
|
||||
hintText: context.translation.name,
|
||||
textAlign: TextAlign.left,
|
||||
style: Theme.of(context).textTheme.bodyText1,
|
||||
prefixIconData: Icons.account_circle,
|
||||
validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
|
||||
textInputType: TextInputType.name,
|
||||
onSaved: (value) {
|
||||
_user.userName = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
ATextFormField(
|
||||
initialValue: _user?.password,
|
||||
hintText: context.translation.password,
|
||||
obscureText: _obscurePassword,
|
||||
style: Theme.of(context).textTheme.bodyText1,
|
||||
prefixIconData: Icons.vpn_key_sharp,
|
||||
textAlign: TextAlign.left,
|
||||
validator: (value) => Validator.isValidPassword(value) ? null : context.translation.passwordValidateMessage,
|
||||
showPassword: () {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
setState(() {});
|
||||
},
|
||||
onSaved: (value) {
|
||||
_user.password = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 32 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
AButton(
|
||||
text: context.translation.signIn,
|
||||
onPressed: () async {
|
||||
if (!_formKey.currentState.validate()) return;
|
||||
_formKey.currentState.save();
|
||||
int status = await _userProvider.login(
|
||||
user: _user,
|
||||
);
|
||||
if (status >= 200 && status < 300) {
|
||||
if (_userProvider.user.isAuthenticated ?? false) {
|
||||
_settingProvider.setUser(_userProvider.user);
|
||||
Navigator.of(context).pushNamed(LandPage.routeName);
|
||||
} else {
|
||||
Fluttertoast.showToast(msg: _userProvider.user.message);
|
||||
}
|
||||
|
||||
// if (_userProvider.user.isActive)
|
||||
|
||||
// else
|
||||
// Fluttertoast.showToast(msg: context.translation.activationAlert);
|
||||
} else {
|
||||
if (status >= 400 && status < 500) return;
|
||||
|
||||
String errorMessage = status == 400 || _userProvider.user?.userName == null
|
||||
? context.translation.wrongEmailOrPassword
|
||||
: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(errorMessage),
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 140 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// AOutLinedButton(
|
||||
// text: context.translation.signUp,
|
||||
// //color: AColors.cyan,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(Register.id);
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// 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/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/controllers/validator/validator.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
// import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
//
|
||||
// class Login extends StatefulWidget {
|
||||
// static final String id = "/login";
|
||||
//
|
||||
// @override
|
||||
// _LoginState createState() => _LoginState();
|
||||
// }
|
||||
//
|
||||
// class _LoginState extends State<Login> {
|
||||
// UserProvider _userProvider;
|
||||
// SettingProvider _settingProvider;
|
||||
// User _user = User();
|
||||
// bool _obscurePassword = true;
|
||||
// bool _firstTime = true;
|
||||
// double _height;
|
||||
// double _width;
|
||||
// String _payload;
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _height = MediaQuery.of(context).size.height;
|
||||
// _width = MediaQuery.of(context).size.width;
|
||||
//
|
||||
// return Scaffold(
|
||||
// key: _scaffoldKey,
|
||||
// body: SafeArea(
|
||||
// child: LoadingManager(
|
||||
// isLoading: _userProvider.isLoading || !_settingProvider.isLoaded,
|
||||
// isFailedLoading: false,
|
||||
// stateCode: 200,
|
||||
// onRefresh: () async {},
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: SingleChildScrollView(
|
||||
// //padding: EdgeInsets.symmetric(horizontal: 32),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// //AppNameBar(),
|
||||
// SizedBox(
|
||||
// height: MediaQuery.of(context).size.height / 7,
|
||||
// ),
|
||||
// Hero(
|
||||
// tag: "logo",
|
||||
// child: Image(
|
||||
// height: _height / 6,
|
||||
// fit: BoxFit.contain,
|
||||
// image: AssetImage("assets/images/logo.png"),
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 24 * AppStyle.getScaleFactor(context), vertical: 24 * AppStyle.getScaleFactor(context)),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// height: 24 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _user?.userName,
|
||||
// hintText: context.translation.name,
|
||||
// textAlign: TextAlign.left,
|
||||
// style: Theme.of(context).textTheme.bodyText1,
|
||||
// prefixIconData: Icons.account_circle,
|
||||
// validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
|
||||
// textInputType: TextInputType.name,
|
||||
// onSaved: (value) {
|
||||
// _user.userName = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 12),
|
||||
// ATextFormField(
|
||||
// initialValue: _user?.password,
|
||||
// hintText: context.translation.password,
|
||||
// obscureText: _obscurePassword,
|
||||
// style: Theme.of(context).textTheme.bodyText1,
|
||||
// prefixIconData: Icons.vpn_key_sharp,
|
||||
// textAlign: TextAlign.left,
|
||||
// validator: (value) => Validator.isValidPassword(value) ? null : context.translation.passwordValidateMessage,
|
||||
// showPassword: () {
|
||||
// _obscurePassword = !_obscurePassword;
|
||||
// setState(() {});
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _user.password = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 32 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// AButton(
|
||||
// text: context.translation.signIn,
|
||||
// onPressed: () async {
|
||||
// if (!_formKey.currentState.validate()) return;
|
||||
// _formKey.currentState.save();
|
||||
// int status = await _userProvider.login(
|
||||
// user: _user,
|
||||
// );
|
||||
// if (status >= 200 && status < 300) {
|
||||
// if (_userProvider.user.isAuthenticated ?? false) {
|
||||
// _settingProvider.setUser(_userProvider.user);
|
||||
// Navigator.of(context).pushNamed(LandPage.routeName);
|
||||
// } else {
|
||||
// Fluttertoast.showToast(msg: _userProvider.user.message);
|
||||
// }
|
||||
//
|
||||
// // if (_userProvider.user.isActive)
|
||||
//
|
||||
// // else
|
||||
// // Fluttertoast.showToast(msg: context.translation.activationAlert);
|
||||
// } else {
|
||||
// if (status >= 400 && status < 500) return;
|
||||
//
|
||||
// String errorMessage = status == 400 || _userProvider.user?.userName == null
|
||||
// ? context.translation.wrongEmailOrPassword
|
||||
// : HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// content: Text(errorMessage),
|
||||
// ));
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// // SizedBox(
|
||||
// // height: 140 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // AOutLinedButton(
|
||||
// // text: context.translation.signUp,
|
||||
// // //color: AColors.cyan,
|
||||
// // onPressed: () {
|
||||
// // Navigator.of(context).pushNamed(Register.id);
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 32),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,212 +1,213 @@
|
||||
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/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/controllers/validator/validator.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/hospitals/hospital_button.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
|
||||
class Register extends StatefulWidget {
|
||||
static final String id = "/register";
|
||||
|
||||
@override
|
||||
_RegisterState createState() => _RegisterState();
|
||||
}
|
||||
|
||||
class _RegisterState extends State<Register> {
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
double _width;
|
||||
double _height;
|
||||
User _user = User();
|
||||
bool _obscurePassword = true;
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_width = MediaQuery.of(context).size.width;
|
||||
_height = MediaQuery.of(context).size.height;
|
||||
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
body: LoadingManager(
|
||||
isLoading: _userProvider.isLoading,
|
||||
isFailedLoading: false,
|
||||
stateCode: 200,
|
||||
onRefresh: () async {},
|
||||
child: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(20),
|
||||
children: [
|
||||
//AppNameBar(),
|
||||
//SizedBox(height: 16,),
|
||||
Hero(
|
||||
tag: "logo",
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Image(
|
||||
height: _height / 6,
|
||||
image: AssetImage("assets/images/logo.png"),
|
||||
),
|
||||
),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _user.userName,
|
||||
hintText: context.translation.name,
|
||||
prefixIconData: Icons.account_circle,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
|
||||
onSaved: (value) {
|
||||
_user.userName = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ATextFormField(
|
||||
initialValue: _user.email,
|
||||
hintText: context.translation.email,
|
||||
prefixIconData: Icons.email,
|
||||
textInputType: TextInputType.emailAddress,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
validator: (value) => Validator.isEmail(value) ? null : context.translation.emailValidateMessage,
|
||||
onSaved: (value) {
|
||||
_user.email = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ATextFormField(
|
||||
initialValue: _user.password,
|
||||
hintText: context.translation.password,
|
||||
prefixIconData: Icons.vpn_key_sharp,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
obscureText: _obscurePassword,
|
||||
validator: (value) => Validator.isValidPassword(value) ? null : context.translation.passwordValidateMessage,
|
||||
showPassword: () {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
setState(() {});
|
||||
},
|
||||
onSaved: (value) {
|
||||
_user.password = value;
|
||||
},
|
||||
onChange: (value) {
|
||||
_user.password = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ATextFormField(
|
||||
initialValue: _user.password,
|
||||
prefixIconData: Icons.vpn_key_sharp,
|
||||
hintText: context.translation.confirmPassword,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
obscureText: _obscurePassword,
|
||||
validator: (value) => _user.password == value ? null : context.translation.confirmPasswordValidateMessage,
|
||||
showPassword: () {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
HospitalButton(
|
||||
hospital: Hospital(id: _user.clientId, name: _user.clientName),
|
||||
onHospitalPick: (hospital) {
|
||||
_user.clientId = hospital.id;
|
||||
_user.clientName = hospital.name;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
// const SizedBox(height: 12),
|
||||
// DepartmentButton(
|
||||
// department: Department(id: _user.departmentId, name: _user.departmentName),
|
||||
// onDepartmentPick: (department) {
|
||||
// _user.departmentId = department.id;
|
||||
// _user.departmentName = department.name;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
ATextFormField(
|
||||
initialValue: _user.phoneNumber,
|
||||
hintText: context.translation.phoneNumber,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
prefixIconData: Icons.phone_android,
|
||||
validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
|
||||
textInputType: TextInputType.phone,
|
||||
onSaved: (value) {
|
||||
_user.phoneNumber = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.whatsApp,
|
||||
// hintText: context.translation.whatsApp,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// prefixIconData: FontAwesomeIcons.whatsapp,
|
||||
// prefixIconSize: 36,
|
||||
// validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
|
||||
// textInputType: TextInputType.phone,
|
||||
// onSaved: (value) {
|
||||
// _user.whatsApp = value;
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
AButton(
|
||||
text: context.translation.signUp,
|
||||
onPressed: () async {
|
||||
if (!_formKey.currentState.validate()) return;
|
||||
_formKey.currentState.save();
|
||||
if (_user.clientId == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(context.translation.hospitalRequired),
|
||||
));
|
||||
return;
|
||||
}
|
||||
if (_user.departmentId == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(context.translation.uniteRequired),
|
||||
));
|
||||
return;
|
||||
}
|
||||
int status = await _userProvider.register(
|
||||
user: _user,
|
||||
host: _settingProvider.host,
|
||||
);
|
||||
if (status >= 200 && status < 300) {
|
||||
Fluttertoast.showToast(msg: context.translation.activationAlert);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
String errorMessage = status == 402
|
||||
? context.translation.nameExist
|
||||
: status == 401
|
||||
? context.translation.emailExist
|
||||
: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(errorMessage),
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
ABackButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// 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/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/controllers/validator/validator.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
// import 'package:test_sa/views/widgets/hospitals/hospital_button.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
//
|
||||
// class Register extends StatefulWidget {
|
||||
// static final String id = "/register";
|
||||
//
|
||||
// @override
|
||||
// _RegisterState createState() => _RegisterState();
|
||||
// }
|
||||
//
|
||||
// class _RegisterState extends State<Register> {
|
||||
// UserProvider _userProvider;
|
||||
// SettingProvider _settingProvider;
|
||||
// double _width;
|
||||
// double _height;
|
||||
// User _user = User();
|
||||
// bool _obscurePassword = true;
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _width = MediaQuery.of(context).size.width;
|
||||
// _height = MediaQuery.of(context).size.height;
|
||||
//
|
||||
// return Scaffold(
|
||||
// key: _scaffoldKey,
|
||||
// body: LoadingManager(
|
||||
// isLoading: _userProvider.isLoading,
|
||||
// isFailedLoading: false,
|
||||
// stateCode: 200,
|
||||
// onRefresh: () async {},
|
||||
// child: SafeArea(
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// Form(
|
||||
// key: _formKey,
|
||||
// child: ListView(
|
||||
// padding: const EdgeInsets.all(20),
|
||||
// children: [
|
||||
// //AppNameBar(),
|
||||
// //SizedBox(height: 16,),
|
||||
// Hero(
|
||||
// tag: "logo",
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(16),
|
||||
// child: Image(
|
||||
// height: _height / 6,
|
||||
// image: AssetImage("assets/images/logo.png"),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.userName,
|
||||
// hintText: context.translation.name,
|
||||
// prefixIconData: Icons.account_circle,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// validator: (value) => Validator.hasValue(value) ? null : context.translation.nameValidateMessage,
|
||||
// onSaved: (value) {
|
||||
// _user.userName = value;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.email,
|
||||
// hintText: context.translation.email,
|
||||
// prefixIconData: Icons.email,
|
||||
// textInputType: TextInputType.emailAddress,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// validator: (value) => Validator.isEmail(value) ? null : context.translation.emailValidateMessage,
|
||||
// onSaved: (value) {
|
||||
// _user.email = value;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.password,
|
||||
// hintText: context.translation.password,
|
||||
// prefixIconData: Icons.vpn_key_sharp,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// obscureText: _obscurePassword,
|
||||
// validator: (value) => Validator.isValidPassword(value) ? null : context.translation.passwordValidateMessage,
|
||||
// showPassword: () {
|
||||
// _obscurePassword = !_obscurePassword;
|
||||
// setState(() {});
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _user.password = value;
|
||||
// },
|
||||
// onChange: (value) {
|
||||
// _user.password = value;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.password,
|
||||
// prefixIconData: Icons.vpn_key_sharp,
|
||||
// hintText: context.translation.confirmPassword,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// obscureText: _obscurePassword,
|
||||
// validator: (value) => _user.password == value ? null : context.translation.confirmPasswordValidateMessage,
|
||||
// showPassword: () {
|
||||
// _obscurePassword = !_obscurePassword;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
// HospitalButton(
|
||||
// hospital: Hospital(id: _user.clientId, name: _user.clientName),
|
||||
// onHospitalPick: (hospital) {
|
||||
// _user.clientId = hospital.id;
|
||||
// _user.clientName = hospital.name;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// // const SizedBox(height: 12),
|
||||
// // DepartmentButton(
|
||||
// // department: Department(id: _user.departmentId, name: _user.departmentName),
|
||||
// // onDepartmentPick: (department) {
|
||||
// // _user.departmentId = department.id;
|
||||
// // _user.departmentName = department.name;
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 12),
|
||||
// ATextFormField(
|
||||
// initialValue: _user.phoneNumber,
|
||||
// hintText: context.translation.phoneNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// prefixIconData: Icons.phone_android,
|
||||
// validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
|
||||
// textInputType: TextInputType.phone,
|
||||
// onSaved: (value) {
|
||||
// _user.phoneNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _user.whatsApp,
|
||||
// // hintText: context.translation.whatsApp,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // prefixIconData: FontAwesomeIcons.whatsapp,
|
||||
// // prefixIconSize: 36,
|
||||
// // validator: (value) => Validator.isPhoneNumber(value) ? null : context.translation.phoneNumberValidateMessage,
|
||||
// // textInputType: TextInputType.phone,
|
||||
// // onSaved: (value) {
|
||||
// // _user.whatsApp = value;
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 12),
|
||||
// AButton(
|
||||
// text: context.translation.signUp,
|
||||
// onPressed: () async {
|
||||
// if (!_formKey.currentState.validate()) return;
|
||||
// _formKey.currentState.save();
|
||||
// if (_user.clientId == null) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// content: Text(context.translation.hospitalRequired),
|
||||
// ));
|
||||
// return;
|
||||
// }
|
||||
// if (_user.departmentId == null) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// content: Text(context.translation.uniteRequired),
|
||||
// ));
|
||||
// return;
|
||||
// }
|
||||
// int status = await _userProvider.register(
|
||||
// user: _user,
|
||||
// host: _settingProvider.host,
|
||||
// );
|
||||
// if (status >= 200 && status < 300) {
|
||||
// Fluttertoast.showToast(msg: context.translation.activationAlert);
|
||||
// Navigator.of(context).pop();
|
||||
// } else {
|
||||
// String errorMessage = status == 402
|
||||
// ? context.translation.nameExist
|
||||
// : status == 401
|
||||
// ? context.translation.emailExist
|
||||
// : HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation);
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// content: Text(errorMessage),
|
||||
// ));
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ABackButton(),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,76 +1,77 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flare_flutter/flare_actor.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/notification/notification_manger.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/user.dart';
|
||||
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
||||
|
||||
import 'login.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
static const String id = '/splash';
|
||||
|
||||
const SplashScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
}
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
SettingProvider _settingProvider;
|
||||
UserProvider _userProvider;
|
||||
|
||||
_goToUserScreen(User user) {
|
||||
if (user.tokenlife != null && (DateTime.tryParse(user.tokenlife)?.isAfter(DateTime.now()) ?? false)) {
|
||||
_userProvider.user = user;
|
||||
// Navigator.of(context).pushNamed(Login.id);
|
||||
Navigator.of(context).pushNamed(LandPage.routeName);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Firebase.initializeApp();
|
||||
|
||||
NotificationManger.initialisation((notificationDetails) {
|
||||
// todo @sikander, check notifications payload, because notification model is different to need to check from backend
|
||||
// SystemNotificationModel notification = SystemNotificationModel.fromJson(json.decode(notificationDetails.payload));
|
||||
// if (notification.path == null || notification.path.isEmpty) return;
|
||||
// Navigator.pushNamed(context, notification.path, arguments: notification.requestId);
|
||||
}, (id, title, body, payload) async {});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
||||
_userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 1.1,
|
||||
child: FlareActor(
|
||||
"assets/rives/atoms_splash.flr",
|
||||
fit: BoxFit.contain,
|
||||
animation: "splash",
|
||||
callback: (animation) async {
|
||||
Navigator.of(context).pushNamed(Login.id);
|
||||
if (_settingProvider.isLoaded && _settingProvider.user != null) {
|
||||
_goToUserScreen(_settingProvider.user);
|
||||
}
|
||||
},
|
||||
),
|
||||
//const Center(child: CircularProgressIndicator())
|
||||
|
||||
// Image.asset("assets/images/logo.png",
|
||||
// fit: BoxFit.contain,
|
||||
// ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:firebase_core/firebase_core.dart';
|
||||
// import 'package:flare_flutter/flare_actor.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/notification/notification_manger.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/user.dart';
|
||||
// import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
||||
//
|
||||
// import 'login.dart';
|
||||
//
|
||||
// class SplashScreen extends StatefulWidget {
|
||||
// static const String id = '/splash';
|
||||
//
|
||||
// const SplashScreen({Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<SplashScreen> createState() => _SplashScreenState();
|
||||
// }
|
||||
//
|
||||
// class _SplashScreenState extends State<SplashScreen> {
|
||||
// SettingProvider _settingProvider;
|
||||
// UserProvider _userProvider;
|
||||
//
|
||||
// _goToUserScreen(User user) {
|
||||
// if (user.tokenlife != null && (DateTime.tryParse(user.tokenlife)?.isAfter(DateTime.now()) ?? false)) {
|
||||
// _userProvider.user = user;
|
||||
// // Navigator.of(context).pushNamed(Login.id);
|
||||
// Navigator.of(context).pushNamed(LandPage.routeName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// Firebase.initializeApp();
|
||||
//
|
||||
// NotificationManger.initialisation((notificationDetails) {
|
||||
// // todo @sikander, check notifications payload, because notification model is different to need to check from backend
|
||||
// // SystemNotificationModel notification = SystemNotificationModel.fromJson(json.decode(notificationDetails.payload));
|
||||
// // if (notification.path == null || notification.path.isEmpty) return;
|
||||
// // Navigator.pushNamed(context, notification.path, arguments: notification.requestId);
|
||||
// }, (id, title, body, payload) async {});
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
||||
// _userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
// return Scaffold(
|
||||
// backgroundColor: Colors.white,
|
||||
// body: Center(
|
||||
// child: SizedBox(
|
||||
// width: MediaQuery.of(context).size.width / 1.1,
|
||||
// child: FlareActor(
|
||||
// "assets/rives/atoms_splash.flr",
|
||||
// fit: BoxFit.contain,
|
||||
// animation: "splash",
|
||||
// callback: (animation) async {
|
||||
// Navigator.of(context).pushNamed(Login.id);
|
||||
// if (_settingProvider.isLoaded && _settingProvider.user != null) {
|
||||
// _goToUserScreen(_settingProvider.user);
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// //const Center(child: CircularProgressIndicator())
|
||||
//
|
||||
// // Image.asset("assets/images/logo.png",
|
||||
// // fit: BoxFit.contain,
|
||||
// // ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,72 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
||||
|
||||
import '../../../providers/work_order/vendor_provider.dart';
|
||||
|
||||
class AutoGeneratedVendorName extends StatefulWidget {
|
||||
final String initialValue;
|
||||
final Function(SupplierDetails) onSearch;
|
||||
|
||||
const AutoGeneratedVendorName({Key key, this.initialValue, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AutoGeneratedVendorName> createState() => _AutoGeneratedVendorNameState();
|
||||
}
|
||||
|
||||
class _AutoGeneratedVendorNameState extends State<AutoGeneratedVendorName> {
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TextEditingController(text: widget.initialValue ?? "");
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant AutoGeneratedVendorName oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
if (oldWidget.initialValue != widget.initialValue) {
|
||||
_controller = TextEditingController(text: widget.initialValue ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final vendorProvider = Provider.of<VendorProvider>(context, listen: false);
|
||||
return TypeAheadField<SupplierDetails>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Vendor Name",
|
||||
border: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
),
|
||||
suggestionsCallback: (vale) async {
|
||||
// await vendorProvider.getVendors(_controller.text.trim());
|
||||
// return vendorProvider.vendors;
|
||||
},
|
||||
itemBuilder: (context, vendor) {
|
||||
return ListTile(title: Text(vendor.suppliername));
|
||||
},
|
||||
onSuggestionSelected: (hospital) {
|
||||
widget.onSearch(hospital);
|
||||
},
|
||||
).toShadowContainer(context);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/models/service_request/supplier_details.dart';
|
||||
//
|
||||
// import '../../../providers/work_order/vendor_provider.dart';
|
||||
//
|
||||
// class AutoGeneratedVendorName extends StatefulWidget {
|
||||
// final String initialValue;
|
||||
// final Function(SupplierDetails) onSearch;
|
||||
//
|
||||
// const AutoGeneratedVendorName({Key key, this.initialValue, this.onSearch}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<AutoGeneratedVendorName> createState() => _AutoGeneratedVendorNameState();
|
||||
// }
|
||||
//
|
||||
// class _AutoGeneratedVendorNameState extends State<AutoGeneratedVendorName> {
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _controller = TextEditingController(text: widget.initialValue ?? "");
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant AutoGeneratedVendorName oldWidget) {
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
//
|
||||
// if (oldWidget.initialValue != widget.initialValue) {
|
||||
// _controller = TextEditingController(text: widget.initialValue ?? "");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final vendorProvider = Provider.of<VendorProvider>(context, listen: false);
|
||||
// return TypeAheadField<SupplierDetails>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.titleLarge,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: const InputDecoration(
|
||||
// hintText: "Vendor Name",
|
||||
// border: InputBorder.none,
|
||||
// disabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// textInputAction: TextInputAction.search,
|
||||
// ),
|
||||
// suggestionsCallback: (vale) async {
|
||||
// // await vendorProvider.getVendors(_controller.text.trim());
|
||||
// // return vendorProvider.vendors;
|
||||
// },
|
||||
// itemBuilder: (context, vendor) {
|
||||
// return ListTile(title: Text(vendor.suppliername));
|
||||
// },
|
||||
// onSuggestionSelected: (hospital) {
|
||||
// widget.onSearch(hospital);
|
||||
// },
|
||||
// ).toShadowContainer(context);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,214 +1,215 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/service_request/search_work_order.dart';
|
||||
|
||||
import '../../../models/service_request/spare_parts.dart';
|
||||
import '../../app_style/sizing.dart';
|
||||
import '../../widgets/app_text_form_field.dart';
|
||||
import '../../widgets/buttons/app_button.dart';
|
||||
import '../../widgets/parts/part_item.dart';
|
||||
import '../../widgets/titles/app_sub_title.dart';
|
||||
|
||||
class SparePartsBottomSheet extends StatefulWidget {
|
||||
final SearchWorkOrder subWorkOrder;
|
||||
final num assetId;
|
||||
|
||||
const SparePartsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SparePartsBottomSheet> createState() => _SparePartsBottomSheetState();
|
||||
}
|
||||
|
||||
class _SparePartsBottomSheetState extends State<SparePartsBottomSheet> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final SearchWorkOrder _workOrder = SearchWorkOrder();
|
||||
bool _validate = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_workOrder.copyFrom(widget.subWorkOrder);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_workOrder.sparePartsWorkOrders = widget.subWorkOrder.sparePartsWorkOrders;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
topRight: Radius.circular(15),
|
||||
),
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
height: size.height * 0.9,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const ASubTitle("Spare Parts"),
|
||||
const SizedBox(height: 8),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
margin: const EdgeInsets.symmetric(vertical: 16),
|
||||
// decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: const [
|
||||
// BoxShadow(
|
||||
// color: AColors.grey,
|
||||
// offset: Offset(0, -1),
|
||||
// )
|
||||
// ]),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ASubTitle(context.translation.partNumber),
|
||||
_validate && _workOrder.sparePartsWorkOrders == null
|
||||
? ASubTitle(
|
||||
context.translation.requiredWord,
|
||||
color: Colors.red,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
const SizedBox(height: 4),
|
||||
// AutoCompletePartsField(
|
||||
// assetId: widget.assetId,
|
||||
// onPick: (part) {
|
||||
// _workOrder.sparePartsWorkOrders ??= [];
|
||||
// _workOrder.sparePartsWorkOrders.add(SparePartsWorkOrders(
|
||||
// id: part.reportPartID,
|
||||
// qty: part.quantity,
|
||||
// sparePart: SparePart(id: part.id, partName: part.partName, partNo: part.partNo),
|
||||
// installQty: part.installQty,
|
||||
// returnQty: part.returnQty,
|
||||
// ));
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
if (_workOrder.sparePartsWorkOrders?.isNotEmpty ?? false)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(flex: 3, child: Text(context.translation.number)),
|
||||
Expanded(flex: 1, child: Text(context.translation.quantity)),
|
||||
],
|
||||
),
|
||||
if (_workOrder.sparePartsWorkOrders?.isNotEmpty ?? false)
|
||||
Column(
|
||||
children: List.generate(
|
||||
_workOrder.sparePartsWorkOrders?.length,
|
||||
(index) {
|
||||
final spare = _workOrder.sparePartsWorkOrders[index];
|
||||
SparePartsWorkOrders part = SparePartsWorkOrders(
|
||||
id: spare.sparePart?.id,
|
||||
sparePart: SparePart(
|
||||
id: spare.id,
|
||||
partNo: spare.sparePart?.partNo,
|
||||
partName: spare.sparePart?.partName,
|
||||
),
|
||||
qty: spare.qty?.toInt(),
|
||||
installQty: spare.installQty,
|
||||
returnQty: spare.returnQty,
|
||||
);
|
||||
return Column(
|
||||
children: [
|
||||
PartItem(
|
||||
part: part,
|
||||
onEdit: (qty) {
|
||||
spare.qty = qty;
|
||||
},
|
||||
onDelete: (part) {
|
||||
_workOrder.sparePartsWorkOrders.remove(spare);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
if (_workOrder.calllastSituation?.name?.toLowerCase()?.contains("part installation") ?? false)
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ATextFormField(
|
||||
initialValue: part?.returnQty?.toString(),
|
||||
labelText: "Return Quantity",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
spare.returnQty = num.tryParse(value)?.toDouble();
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ATextFormField(
|
||||
initialValue: part?.installQty?.toString(),
|
||||
labelText: "Install Quantity",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
spare.installQty = num.tryParse(value)?.toDouble();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
AButton(
|
||||
text: context.translation.submit,
|
||||
onPressed: () async {
|
||||
_formKey.currentState.save();
|
||||
widget.subWorkOrder.copyFrom(_workOrder);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/service_request/search_work_order.dart';
|
||||
//
|
||||
// import '../../../models/service_request/spare_parts.dart';
|
||||
// import '../../app_style/sizing.dart';
|
||||
// import '../../widgets/app_text_form_field.dart';
|
||||
// import '../../widgets/buttons/app_button.dart';
|
||||
// import '../../widgets/parts/part_item.dart';
|
||||
// import '../../widgets/titles/app_sub_title.dart';
|
||||
//
|
||||
// class SparePartsBottomSheet extends StatefulWidget {
|
||||
// final SearchWorkOrder subWorkOrder;
|
||||
// final num assetId;
|
||||
//
|
||||
// const SparePartsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<SparePartsBottomSheet> createState() => _SparePartsBottomSheetState();
|
||||
// }
|
||||
//
|
||||
// class _SparePartsBottomSheetState extends State<SparePartsBottomSheet> {
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
// final SearchWorkOrder _workOrder = SearchWorkOrder();
|
||||
// bool _validate = false;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _workOrder.copyFrom(widget.subWorkOrder);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _workOrder.sparePartsWorkOrders = widget.subWorkOrder.sparePartsWorkOrders;
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final size = MediaQuery.of(context).size;
|
||||
//
|
||||
// return Padding(
|
||||
// padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
// child: ClipRRect(
|
||||
// borderRadius: const BorderRadius.only(
|
||||
// topLeft: Radius.circular(15),
|
||||
// topRight: Radius.circular(15),
|
||||
// ),
|
||||
// clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
// child: Container(
|
||||
// color: Colors.white,
|
||||
// height: size.height * 0.9,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const ASubTitle("Spare Parts"),
|
||||
// const SizedBox(height: 8),
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: SingleChildScrollView(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Container(
|
||||
// width: double.infinity,
|
||||
// padding: const EdgeInsets.all(16),
|
||||
// margin: const EdgeInsets.symmetric(vertical: 16),
|
||||
// // decoration: BoxDecoration(color: AColors.grey, borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), boxShadow: const [
|
||||
// // BoxShadow(
|
||||
// // color: AColors.grey,
|
||||
// // offset: Offset(0, -1),
|
||||
// // )
|
||||
// // ]),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// flex: 3,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// ASubTitle(context.translation.partNumber),
|
||||
// _validate && _workOrder.sparePartsWorkOrders == null
|
||||
// ? ASubTitle(
|
||||
// context.translation.requiredWord,
|
||||
// color: Colors.red,
|
||||
// )
|
||||
// : const SizedBox.shrink(),
|
||||
// const SizedBox(height: 4),
|
||||
// // AutoCompletePartsField(
|
||||
// // assetId: widget.assetId,
|
||||
// // onPick: (part) {
|
||||
// // _workOrder.sparePartsWorkOrders ??= [];
|
||||
// // _workOrder.sparePartsWorkOrders.add(SparePartsWorkOrders(
|
||||
// // id: part.reportPartID,
|
||||
// // qty: part.quantity,
|
||||
// // sparePart: SparePart(id: part.id, partName: part.partName, partNo: part.partNo),
|
||||
// // installQty: part.installQty,
|
||||
// // returnQty: part.returnQty,
|
||||
// // ));
|
||||
// // },
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// if (_workOrder.sparePartsWorkOrders?.isNotEmpty ?? false)
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(flex: 3, child: Text(context.translation.number)),
|
||||
// Expanded(flex: 1, child: Text(context.translation.quantity)),
|
||||
// ],
|
||||
// ),
|
||||
// if (_workOrder.sparePartsWorkOrders?.isNotEmpty ?? false)
|
||||
// Column(
|
||||
// children: List.generate(
|
||||
// _workOrder.sparePartsWorkOrders?.length,
|
||||
// (index) {
|
||||
// final spare = _workOrder.sparePartsWorkOrders[index];
|
||||
// SparePartsWorkOrders part = SparePartsWorkOrders(
|
||||
// id: spare.sparePart?.id,
|
||||
// sparePart: SparePart(
|
||||
// id: spare.id,
|
||||
// partNo: spare.sparePart?.partNo,
|
||||
// partName: spare.sparePart?.partName,
|
||||
// ),
|
||||
// qty: spare.qty?.toInt(),
|
||||
// installQty: spare.installQty,
|
||||
// returnQty: spare.returnQty,
|
||||
// );
|
||||
// return Column(
|
||||
// children: [
|
||||
// PartItem(
|
||||
// part: part,
|
||||
// onEdit: (qty) {
|
||||
// spare.qty = qty;
|
||||
// },
|
||||
// onDelete: (part) {
|
||||
// _workOrder.sparePartsWorkOrders.remove(spare);
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// if (_workOrder.calllastSituation?.name?.toLowerCase()?.contains("part installation") ?? false)
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: ATextFormField(
|
||||
// initialValue: part?.returnQty?.toString(),
|
||||
// labelText: "Return Quantity",
|
||||
// textAlign: TextAlign.center,
|
||||
// style: Theme.of(context).textTheme.titleMedium,
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// spare.returnQty = num.tryParse(value)?.toDouble();
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(width: 8),
|
||||
// Expanded(
|
||||
// child: ATextFormField(
|
||||
// initialValue: part?.installQty?.toString(),
|
||||
// labelText: "Install Quantity",
|
||||
// textAlign: TextAlign.center,
|
||||
// style: Theme.of(context).textTheme.titleMedium,
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// spare.installQty = num.tryParse(value)?.toDouble();
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 24),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// AButton(
|
||||
// text: context.translation.submit,
|
||||
// onPressed: () async {
|
||||
// _formKey.currentState.save();
|
||||
// widget.subWorkOrder.copyFrom(_workOrder);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,252 +1,253 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/service_request/search_work_order.dart';
|
||||
import 'package:test_sa/models/service_request/supplier_details.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart';
|
||||
import 'package:test_sa/views/widgets/status/report/service_report_maintenance_situation.dart';
|
||||
import 'package:test_sa/views/widgets/status/report/service_report_repair_location.dart';
|
||||
import 'package:test_sa/views/widgets/status/service_request/supplier_engineers_menu.dart';
|
||||
|
||||
import '../../../controllers/providers/api/status_drop_down/report/service_report_maintenance_situation_provider.dart';
|
||||
import '../../../models/service_request/supp_engineer_work_orders.dart';
|
||||
import '../../widgets/timer/app_timer.dart';
|
||||
import '../../widgets/titles/app_sub_title.dart';
|
||||
import 'auto_generated_vendor_name.dart';
|
||||
|
||||
class WorkOrderDetailsBottomSheet extends StatefulWidget {
|
||||
final SearchWorkOrder subWorkOrder;
|
||||
final num assetId;
|
||||
|
||||
const WorkOrderDetailsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<WorkOrderDetailsBottomSheet> createState() => _WorkOrderDetailsBottomSheetState();
|
||||
}
|
||||
|
||||
class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomSheet> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final SearchWorkOrder _workOrder = SearchWorkOrder();
|
||||
bool _showVendorFields = false;
|
||||
SuppEngineerWorkOrders engineer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_workOrder.copyFrom(widget.subWorkOrder);
|
||||
if (checkVendorFieldsVisibility(_workOrder.calllastSituation)) {
|
||||
if (_workOrder.suppEngineerWorkOrders?.isNotEmpty ?? false) {
|
||||
engineer = _workOrder.suppEngineerWorkOrders?.last;
|
||||
engineer?.id = engineer?.supplierContactId;
|
||||
}
|
||||
_workOrder.supplier ??= SupplierDetails(id: _workOrder?.supplier?.id);
|
||||
}
|
||||
if (context.mounted) {
|
||||
Provider.of<ServiceReportMaintenanceSituationProvider>(context, listen: false).reset();
|
||||
}
|
||||
}
|
||||
|
||||
bool checkVendorFieldsVisibility(Lookup callsLastSituation) {
|
||||
bool result = (_workOrder.supplier?.suppliername?.isNotEmpty ?? false) ||
|
||||
(callsLastSituation?.name?.toLowerCase()?.contains("under repair-vendor") ?? false) ||
|
||||
(callsLastSituation?.name?.toLowerCase()?.contains("waiting for vendor") ?? false);
|
||||
_showVendorFields = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = MediaQuery.of(context).size;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
topRight: Radius.circular(15),
|
||||
),
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
height: size.height * 0.9,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const ASubTitle("WO Details"),
|
||||
const SizedBox(height: 8),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
ATextFormField(enable: false, hintText: "Assigned Employee: ${_workOrder.assignedEmployee?.name}"),
|
||||
const SizedBox(height: 8),
|
||||
const ASubTitle("Assistant Employee"),
|
||||
const SizedBox(height: 4),
|
||||
ServiceReportAssistantEmployeeMenu(
|
||||
assetId: widget.assetId,
|
||||
initialValue: (_workOrder.assistantEmployees?.isNotEmpty ?? false) ? _workOrder.assistantEmployees?.first : null,
|
||||
onSelect: (assistantsEmployee) {
|
||||
if (assistantsEmployee == null) {
|
||||
_workOrder.assistantEmployees = [];
|
||||
} else {
|
||||
_workOrder.assistantEmployees = [assistantsEmployee];
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ASubTitle(context.translation.workingHours),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppTimer(
|
||||
timer: _workOrder.timer,
|
||||
onChange: (timer) async {
|
||||
_workOrder.timer = timer;
|
||||
_workOrder.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
|
||||
return true;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ATextFormField(
|
||||
labelText: "Travel Hours",
|
||||
initialValue: _workOrder.travelingHours?.toString(),
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
_workOrder.travelingHours = num.tryParse(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ATextFormField(
|
||||
labelText: "Travel Expense",
|
||||
initialValue: _workOrder.travelingExpenses?.toString(),
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
_workOrder.travelingExpenses = num.tryParse(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ASubTitle(context.translation.callLastSituation),
|
||||
const SizedBox(height: 4),
|
||||
ServiceReportMaintenanceSituation(
|
||||
initialValue: _workOrder.calllastSituation,
|
||||
onSelect: (status) {
|
||||
if (checkVendorFieldsVisibility(status)) {
|
||||
_workOrder.supplier ??= SupplierDetails(id: _workOrder?.supplier?.id);
|
||||
engineer = null;
|
||||
}
|
||||
if (status?.value == 12 || _workOrder.calllastSituation?.value == 12) {
|
||||
_workOrder.calllastSituation = status;
|
||||
_workOrder.mrNumber = null;
|
||||
setState(() {});
|
||||
} else {
|
||||
_workOrder.calllastSituation = status;
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
woId: widget.subWorkOrder?.parentWOId?.toString(),
|
||||
),
|
||||
if (_workOrder.calllastSituation.value == 12) const ASubTitle(" You have to add parts", color: Colors.amber, padding: EdgeInsets.all(2), font: 11),
|
||||
if (_workOrder.calllastSituation.value == 12) const SizedBox(height: 8),
|
||||
if (_workOrder.calllastSituation.value == 12)
|
||||
ATextFormField(
|
||||
labelText: "MR number",
|
||||
initialValue: _workOrder.mrNumber,
|
||||
onSaved: (value) {
|
||||
_workOrder.mrNumber = value;
|
||||
},
|
||||
),
|
||||
if (_showVendorFields) const SizedBox(height: 8),
|
||||
if (_showVendorFields)
|
||||
AutoGeneratedVendorName(
|
||||
initialValue: _workOrder.supplier?.suppliername,
|
||||
onSearch: (supplier) {
|
||||
_workOrder.supplier.id = supplier.id;
|
||||
_workOrder.supplier.suppliername = supplier.suppliername;
|
||||
_workOrder.supplier.suppPersons = supplier.suppPersons;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
if (_showVendorFields) const SizedBox(height: 8),
|
||||
if (_showVendorFields)
|
||||
SupplierEngineersMenu(
|
||||
initialValue: engineer,
|
||||
engineers: _workOrder?.supplier?.suppPersons,
|
||||
onSelect: (engineer) {
|
||||
if (engineer != null) {
|
||||
this.engineer = engineer;
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const ASubTitle("Repair Location"),
|
||||
const SizedBox(height: 4),
|
||||
ServiceReportRepairLocation(
|
||||
initialValue: _workOrder.repairLocation,
|
||||
onSelect: (status) {
|
||||
_workOrder.repairLocation = status;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ATextFormField(
|
||||
labelText: "Technical Comments",
|
||||
initialValue: _workOrder.comment,
|
||||
textInputType: TextInputType.multiline,
|
||||
onSaved: (value) {
|
||||
_workOrder.comment = value;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
AButton(
|
||||
text: context.translation.submit,
|
||||
onPressed: () async {
|
||||
if (_workOrder?.workingHours == null) {
|
||||
await Fluttertoast.showToast(msg: "Working Hours Timer Isn't Started");
|
||||
return;
|
||||
}
|
||||
if (_showVendorFields && (_workOrder.supplier.suppliername == null || _workOrder.supplier.suppliername.isEmpty)) {
|
||||
await Fluttertoast.showToast(msg: "Vendor Name Field is Required");
|
||||
return;
|
||||
}
|
||||
if (_showVendorFields && _workOrder.suppEngineerWorkOrders == null) {
|
||||
await Fluttertoast.showToast(msg: "Vendor Engineer Field is Required");
|
||||
return;
|
||||
}
|
||||
_workOrder.suppEngineerWorkOrders ?? [];
|
||||
if (engineer != null) _workOrder.suppEngineerWorkOrders.add(engineer..id = 0);
|
||||
if (_workOrder.calllastSituation == null) {
|
||||
await Fluttertoast.showToast(msg: "Call Last Situation Field is Required");
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
widget.subWorkOrder.copyFrom(_workOrder);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:fluttertoast/fluttertoast.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/service_request/search_work_order.dart';
|
||||
// import 'package:test_sa/models/service_request/supplier_details.dart';
|
||||
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_button.dart';
|
||||
// import 'package:test_sa/views/widgets/status/report/service_report_assistant_employee_menu.dart';
|
||||
// import 'package:test_sa/views/widgets/status/report/service_report_maintenance_situation.dart';
|
||||
// import 'package:test_sa/views/widgets/status/report/service_report_repair_location.dart';
|
||||
// import 'package:test_sa/views/widgets/status/service_request/supplier_engineers_menu.dart';
|
||||
//
|
||||
// import '../../../controllers/providers/api/status_drop_down/report/service_report_maintenance_situation_provider.dart';
|
||||
// import '../../../models/service_request/supp_engineer_work_orders.dart';
|
||||
// import '../../widgets/timer/app_timer.dart';
|
||||
// import '../../widgets/titles/app_sub_title.dart';
|
||||
// import 'auto_generated_vendor_name.dart';
|
||||
//
|
||||
// class WorkOrderDetailsBottomSheet extends StatefulWidget {
|
||||
// final SearchWorkOrder subWorkOrder;
|
||||
// final num assetId;
|
||||
//
|
||||
// const WorkOrderDetailsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<WorkOrderDetailsBottomSheet> createState() => _WorkOrderDetailsBottomSheetState();
|
||||
// }
|
||||
//
|
||||
// class _WorkOrderDetailsBottomSheetState extends State<WorkOrderDetailsBottomSheet> {
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
// final SearchWorkOrder _workOrder = SearchWorkOrder();
|
||||
// bool _showVendorFields = false;
|
||||
// SuppEngineerWorkOrders engineer;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _workOrder.copyFrom(widget.subWorkOrder);
|
||||
// if (checkVendorFieldsVisibility(_workOrder.calllastSituation)) {
|
||||
// if (_workOrder.suppEngineerWorkOrders?.isNotEmpty ?? false) {
|
||||
// engineer = _workOrder.suppEngineerWorkOrders?.last;
|
||||
// engineer?.id = engineer?.supplierContactId;
|
||||
// }
|
||||
// _workOrder.supplier ??= SupplierDetails(id: _workOrder?.supplier?.id);
|
||||
// }
|
||||
// if (context.mounted) {
|
||||
// Provider.of<ServiceReportMaintenanceSituationProvider>(context, listen: false).reset();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// bool checkVendorFieldsVisibility(Lookup callsLastSituation) {
|
||||
// bool result = (_workOrder.supplier?.suppliername?.isNotEmpty ?? false) ||
|
||||
// (callsLastSituation?.name?.toLowerCase()?.contains("under repair-vendor") ?? false) ||
|
||||
// (callsLastSituation?.name?.toLowerCase()?.contains("waiting for vendor") ?? false);
|
||||
// _showVendorFields = result;
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final size = MediaQuery.of(context).size;
|
||||
//
|
||||
// return Padding(
|
||||
// padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
// child: ClipRRect(
|
||||
// borderRadius: const BorderRadius.only(
|
||||
// topLeft: Radius.circular(15),
|
||||
// topRight: Radius.circular(15),
|
||||
// ),
|
||||
// clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
// child: Container(
|
||||
// color: Colors.white,
|
||||
// height: size.height * 0.9,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const ASubTitle("WO Details"),
|
||||
// const SizedBox(height: 8),
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: SingleChildScrollView(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// const SizedBox(height: 8),
|
||||
// ATextFormField(enable: false, hintText: "Assigned Employee: ${_workOrder.assignedEmployee?.name}"),
|
||||
// const SizedBox(height: 8),
|
||||
// const ASubTitle("Assistant Employee"),
|
||||
// const SizedBox(height: 4),
|
||||
// ServiceReportAssistantEmployeeMenu(
|
||||
// assetId: widget.assetId,
|
||||
// initialValue: (_workOrder.assistantEmployees?.isNotEmpty ?? false) ? _workOrder.assistantEmployees?.first : null,
|
||||
// onSelect: (assistantsEmployee) {
|
||||
// if (assistantsEmployee == null) {
|
||||
// _workOrder.assistantEmployees = [];
|
||||
// } else {
|
||||
// _workOrder.assistantEmployees = [assistantsEmployee];
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// ASubTitle(context.translation.workingHours),
|
||||
// const SizedBox(height: 8),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: AppTimer(
|
||||
// timer: _workOrder.timer,
|
||||
// onChange: (timer) async {
|
||||
// _workOrder.timer = timer;
|
||||
// _workOrder.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0");
|
||||
// return true;
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
// ATextFormField(
|
||||
// labelText: "Travel Hours",
|
||||
// initialValue: _workOrder.travelingHours?.toString(),
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// _workOrder.travelingHours = num.tryParse(value);
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// ATextFormField(
|
||||
// labelText: "Travel Expense",
|
||||
// initialValue: _workOrder.travelingExpenses?.toString(),
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// _workOrder.travelingExpenses = num.tryParse(value);
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// ASubTitle(context.translation.callLastSituation),
|
||||
// const SizedBox(height: 4),
|
||||
// ServiceReportMaintenanceSituation(
|
||||
// initialValue: _workOrder.calllastSituation,
|
||||
// onSelect: (status) {
|
||||
// if (checkVendorFieldsVisibility(status)) {
|
||||
// _workOrder.supplier ??= SupplierDetails(id: _workOrder?.supplier?.id);
|
||||
// engineer = null;
|
||||
// }
|
||||
// if (status?.value == 12 || _workOrder.calllastSituation?.value == 12) {
|
||||
// _workOrder.calllastSituation = status;
|
||||
// _workOrder.mrNumber = null;
|
||||
// setState(() {});
|
||||
// } else {
|
||||
// _workOrder.calllastSituation = status;
|
||||
// }
|
||||
// setState(() {});
|
||||
// },
|
||||
// woId: widget.subWorkOrder?.parentWOId?.toString(),
|
||||
// ),
|
||||
// if (_workOrder.calllastSituation.value == 12) const ASubTitle(" You have to add parts", color: Colors.amber, padding: EdgeInsets.all(2), font: 11),
|
||||
// if (_workOrder.calllastSituation.value == 12) const SizedBox(height: 8),
|
||||
// if (_workOrder.calllastSituation.value == 12)
|
||||
// ATextFormField(
|
||||
// labelText: "MR number",
|
||||
// initialValue: _workOrder.mrNumber,
|
||||
// onSaved: (value) {
|
||||
// _workOrder.mrNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// if (_showVendorFields) const SizedBox(height: 8),
|
||||
// if (_showVendorFields)
|
||||
// AutoGeneratedVendorName(
|
||||
// initialValue: _workOrder.supplier?.suppliername,
|
||||
// onSearch: (supplier) {
|
||||
// _workOrder.supplier.id = supplier.id;
|
||||
// _workOrder.supplier.suppliername = supplier.suppliername;
|
||||
// _workOrder.supplier.suppPersons = supplier.suppPersons;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// if (_showVendorFields) const SizedBox(height: 8),
|
||||
// if (_showVendorFields)
|
||||
// SupplierEngineersMenu(
|
||||
// initialValue: engineer,
|
||||
// engineers: _workOrder?.supplier?.suppPersons,
|
||||
// onSelect: (engineer) {
|
||||
// if (engineer != null) {
|
||||
// this.engineer = engineer;
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// const ASubTitle("Repair Location"),
|
||||
// const SizedBox(height: 4),
|
||||
// ServiceReportRepairLocation(
|
||||
// initialValue: _workOrder.repairLocation,
|
||||
// onSelect: (status) {
|
||||
// _workOrder.repairLocation = status;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// ATextFormField(
|
||||
// labelText: "Technical Comments",
|
||||
// initialValue: _workOrder.comment,
|
||||
// textInputType: TextInputType.multiline,
|
||||
// onSaved: (value) {
|
||||
// _workOrder.comment = value;
|
||||
// },
|
||||
// ),
|
||||
// const SizedBox(height: 24),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// AButton(
|
||||
// text: context.translation.submit,
|
||||
// onPressed: () async {
|
||||
// if (_workOrder?.workingHours == null) {
|
||||
// await Fluttertoast.showToast(msg: "Working Hours Timer Isn't Started");
|
||||
// return;
|
||||
// }
|
||||
// if (_showVendorFields && (_workOrder.supplier.suppliername == null || _workOrder.supplier.suppliername.isEmpty)) {
|
||||
// await Fluttertoast.showToast(msg: "Vendor Name Field is Required");
|
||||
// return;
|
||||
// }
|
||||
// if (_showVendorFields && _workOrder.suppEngineerWorkOrders == null) {
|
||||
// await Fluttertoast.showToast(msg: "Vendor Engineer Field is Required");
|
||||
// return;
|
||||
// }
|
||||
// _workOrder.suppEngineerWorkOrders ?? [];
|
||||
// if (engineer != null) _workOrder.suppEngineerWorkOrders.add(engineer..id = 0);
|
||||
// if (_workOrder.calllastSituation == null) {
|
||||
// await Fluttertoast.showToast(msg: "Call Last Situation Field is Required");
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// widget.subWorkOrder.copyFrom(_workOrder);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,41 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
import '../../../models/service_request/search_work_order.dart';
|
||||
|
||||
class WorkOrderDetails extends StatelessWidget {
|
||||
final SearchWorkOrder item;
|
||||
final Lookup assetType;
|
||||
|
||||
const WorkOrderDetails({@required this.item, this.assetType, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildRow(context.translation.callId, item.callRequest?.id?.toString() ?? "", context),
|
||||
_buildRow(context.translation.assetNumber, item.callRequest?.asset?.assetNumber ?? "", context),
|
||||
_buildRow("WO No", item.workOrderNo, context),
|
||||
_buildRow(context.translation.assetName, item.callRequest?.asset?.assetNumber ?? '', context),
|
||||
_buildRow(context.translation.department, item.callRequest?.asset?.department ?? '', context),
|
||||
_buildRow(context.translation.assetSN, item.callRequest?.asset?.assetSerialNo ?? '', context),
|
||||
_buildRow(context.translation.assetType, assetType?.name ?? (item.assetType?.name ?? ""), context),
|
||||
_buildRow(context.translation.model, item.callRequest?.asset?.modelDefinition?.modelName ?? "", context),
|
||||
_buildRow(context.translation.manufacture, item.callRequest?.asset?.modelDefinition?.manufacturerName ?? "", context),
|
||||
_buildRow(context.translation.site, item.callRequest?.asset?.site?.custName ?? "", context),
|
||||
],
|
||||
).toShadowContainer(context);
|
||||
}
|
||||
|
||||
Widget _buildRow(String title, String value, BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
"$title: $value".bodyText(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/text_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// import '../../../models/service_request/search_work_order.dart';
|
||||
//
|
||||
// class WorkOrderDetails extends StatelessWidget {
|
||||
// final SearchWorkOrder item;
|
||||
// final Lookup assetType;
|
||||
//
|
||||
// const WorkOrderDetails({@required this.item, this.assetType, Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// _buildRow(context.translation.callId, item.callRequest?.id?.toString() ?? "", context),
|
||||
// _buildRow(context.translation.assetNumber, item.callRequest?.asset?.assetNumber ?? "", context),
|
||||
// _buildRow("WO No", item.workOrderNo, context),
|
||||
// _buildRow(context.translation.assetName, item.callRequest?.asset?.assetNumber ?? '', context),
|
||||
// _buildRow(context.translation.department, item.callRequest?.asset?.department ?? '', context),
|
||||
// _buildRow(context.translation.assetSN, item.callRequest?.asset?.assetSerialNo ?? '', context),
|
||||
// _buildRow(context.translation.assetType, assetType?.name ?? (item.assetType?.name ?? ""), context),
|
||||
// _buildRow(context.translation.model, item.callRequest?.asset?.modelDefinition?.modelName ?? "", context),
|
||||
// _buildRow(context.translation.manufacture, item.callRequest?.asset?.modelDefinition?.manufacturerName ?? "", context),
|
||||
// _buildRow(context.translation.site, item.callRequest?.asset?.site?.custName ?? "", context),
|
||||
// ],
|
||||
// ).toShadowContainer(context);
|
||||
// }
|
||||
//
|
||||
// Widget _buildRow(String title, String value, BuildContext context) {
|
||||
// return Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// "$title: $value".bodyText(context),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,151 +1,152 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../../../models/service_request/search_work_order.dart';
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
||||
Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
backgroundColor: itemColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
item.callRequest.status.value == 5 || item.callRequest.status.value == 3
|
||||
? Fluttertoast.showToast(
|
||||
msg: "Request is ${item.callRequest.status.name}. No more sub work orders will be create.",
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
)
|
||||
: onPressed(item);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.callRequest.callNo ?? "-----",
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
// Text(
|
||||
// item.callRequest.asset.id.toString(),
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Asset Name:",
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
8.width,
|
||||
Expanded(
|
||||
child: Text(
|
||||
//CallRequest.Asset.ModelDefinition.AssetND
|
||||
// .AssetName
|
||||
item.callRequest.asset.modelDefinition.assetName,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Asset Number:",
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
//if (item.clientName != null)
|
||||
Text(
|
||||
item.callRequest.asset.assetNumber,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Asset SN:",
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
//if (item.clientName != null)
|
||||
Text(
|
||||
item.callRequest.asset.assetSerialNo,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
item.currentSituation.name,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: onItemColor,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.translation.status,
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
color: onItemColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
// if (item.callRequest.status?.id != null) StatusLabel(label: item.callRequest.status.name, backgroundColor: AColors.getGasStatusColor(item.callRequest.status.id)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:fluttertoast/fluttertoast.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import '../../../models/service_request/search_work_order.dart';
|
||||
//
|
||||
// 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
|
||||
// Widget build(BuildContext context) {
|
||||
// Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
||||
// Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary;
|
||||
//
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||
// backgroundColor: itemColor,
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)),
|
||||
// ),
|
||||
// ),
|
||||
// onPressed: () {
|
||||
// item.callRequest.status.value == 5 || item.callRequest.status.value == 3
|
||||
// ? Fluttertoast.showToast(
|
||||
// msg: "Request is ${item.callRequest.status.name}. No more sub work orders will be create.",
|
||||
// toastLength: Toast.LENGTH_LONG,
|
||||
// gravity: ToastGravity.BOTTOM,
|
||||
// )
|
||||
// : onPressed(item);
|
||||
// },
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// item.callRequest.callNo ?? "-----",
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// // Text(
|
||||
// // item.callRequest.asset.id.toString(),
|
||||
// // style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// // color: onItemColor,
|
||||
// // ),
|
||||
// // ),
|
||||
// Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Asset Name:",
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// 8.width,
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// //CallRequest.Asset.ModelDefinition.AssetND
|
||||
// // .AssetName
|
||||
// item.callRequest.asset.modelDefinition.assetName,
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// "Asset Number:",
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// //if (item.clientName != null)
|
||||
// Text(
|
||||
// item.callRequest.asset.assetNumber,
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// "Asset SN:",
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// //if (item.clientName != null)
|
||||
// Text(
|
||||
// item.callRequest.asset.assetSerialNo,
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Text(
|
||||
// item.currentSituation.name,
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// Divider(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// context.translation.status,
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// color: onItemColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// // if (item.callRequest.status?.id != null) StatusLabel(label: item.callRequest.status.name, backgroundColor: AColors.getGasStatusColor(item.callRequest.status.id)),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,63 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/pages/sub_workorder/workorder_details.dart';
|
||||
|
||||
import '../../../models/service_request/search_work_order.dart';
|
||||
import '../../widgets/buttons/app_back_button.dart';
|
||||
import '../../widgets/loaders/loading_manager.dart';
|
||||
|
||||
class WorkOrderUpdate extends StatefulWidget {
|
||||
final SearchWorkOrder item;
|
||||
|
||||
const WorkOrderUpdate({@required this.item, Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<WorkOrderUpdate> createState() => _WorkOrderUpdateState();
|
||||
}
|
||||
|
||||
class _WorkOrderUpdateState extends State<WorkOrderUpdate> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: LoadingManager(
|
||||
isLoading: _isLoading,
|
||||
isFailedLoading: false,
|
||||
stateCode: 200,
|
||||
onRefresh: () async {},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const ABackButton(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Work Order",
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 58),
|
||||
],
|
||||
),
|
||||
),
|
||||
WorkOrderDetails(
|
||||
item: widget.item,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/pages/sub_workorder/workorder_details.dart';
|
||||
//
|
||||
// import '../../../models/service_request/search_work_order.dart';
|
||||
// import '../../widgets/buttons/app_back_button.dart';
|
||||
// import '../../widgets/loaders/loading_manager.dart';
|
||||
//
|
||||
// class WorkOrderUpdate extends StatefulWidget {
|
||||
// final SearchWorkOrder item;
|
||||
//
|
||||
// const WorkOrderUpdate({@required this.item, Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<WorkOrderUpdate> createState() => _WorkOrderUpdateState();
|
||||
// }
|
||||
//
|
||||
// class _WorkOrderUpdateState extends State<WorkOrderUpdate> {
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
//
|
||||
// bool _isLoading = false;
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// body: SafeArea(
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: LoadingManager(
|
||||
// isLoading: _isLoading,
|
||||
// isFailedLoading: false,
|
||||
// stateCode: 200,
|
||||
// onRefresh: () async {},
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Container(
|
||||
// color: Theme.of(context).colorScheme.primary,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// const ABackButton(),
|
||||
// Expanded(
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// "Work Order",
|
||||
// // style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(width: 58),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// WorkOrderDetails(
|
||||
// item: widget.item,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,436 +1,437 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart';
|
||||
import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart';
|
||||
import 'package:test_sa/views/pages/user/ppm/ppm_page.dart';
|
||||
import 'package:test_sa/views/pages/user/requests/create_service_request_page.dart';
|
||||
import 'package:test_sa/views/widgets/dialogs/dialog.dart';
|
||||
|
||||
import '../../../models/enums/user_types.dart';
|
||||
import '../../widgets/land_page/land_page_item.dart';
|
||||
import '../device_transfer/request_device_transfer.dart';
|
||||
import 'requests/requests_page.dart';
|
||||
|
||||
@Deprecated("Use the page which is inside the [new_views/pages/land_page] folder")
|
||||
class LandPage extends StatefulWidget {
|
||||
static const String id = "/old-land-page";
|
||||
|
||||
const LandPage({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LandPage> createState() => _LandPageState();
|
||||
}
|
||||
|
||||
class _LandPageState extends State<LandPage> {
|
||||
double _height;
|
||||
double _width;
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
// DepartmentsProvider _departmentsProvider;
|
||||
// DevicesProvider _devicesProvider;
|
||||
double _buttonHeight;
|
||||
bool firstTime = true;
|
||||
|
||||
// ServiceRequestsProvider _serviceRequestsProvider;
|
||||
// PreventiveMaintenanceVisitsProvider _preventiveMaintenanceVisitsProvider;
|
||||
// RegularVisitsProvider _regularVisitsProvider;
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
try {
|
||||
FirebaseNotificationManger.initialized(context);
|
||||
} catch (error) {}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String path = ModalRoute.of(context).settings.arguments;
|
||||
_height = MediaQuery.of(context).size.height;
|
||||
_width = MediaQuery.of(context).size.width;
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
// _departmentsProvider = Provider.of<DepartmentsProvider>(context);
|
||||
// _devicesProvider = Provider.of<DevicesProvider>(context);
|
||||
// _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
||||
// _preventiveMaintenanceVisitsProvider = Provider.of<PreventiveMaintenanceVisitsProvider>(context);
|
||||
// _regularVisitsProvider = Provider.of<RegularVisitsProvider>(context);
|
||||
//
|
||||
if (firstTime) {
|
||||
if (path != null) {
|
||||
Navigator.of(context).pushNamed("/" + path.split("/").first, arguments: path.split("/").last);
|
||||
}
|
||||
firstTime = false;
|
||||
}
|
||||
_buttonHeight = 68 * AppStyle.getScaleFactor(context);
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
bool result = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => AAlertDialog(
|
||||
// title: _subtitle.exit,
|
||||
title: context.translation.exit,
|
||||
// content: _subtitle.exitAlert,
|
||||
content: context.translation.sureExit,
|
||||
));
|
||||
if (result == true) {
|
||||
if (Platform.isAndroid) {
|
||||
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey, //backgroundColor: Color(0xffF8F8F8),
|
||||
body: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: [
|
||||
//AppNameBar(),
|
||||
// SizedBox(
|
||||
// height: _height/3.2,
|
||||
// width: _width,
|
||||
// child: CarouselSlider.builder(
|
||||
// options: CarouselOptions(
|
||||
// height: _height/3,
|
||||
// autoPlay: true,
|
||||
// viewportFraction: 1
|
||||
// ),
|
||||
// itemCount: 4,
|
||||
// itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
|
||||
// Image(
|
||||
// //width: _width,
|
||||
// image: AssetImage("assets/images/$itemIndex.png"),
|
||||
// fit: BoxFit.cover,
|
||||
// )
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 48 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Hero(
|
||||
// tag: "logo",
|
||||
// child: Image(
|
||||
// height: _height / 6,
|
||||
// image: const AssetImage("assets/images/logo.png"),
|
||||
// ),
|
||||
// ),
|
||||
GridView.count(
|
||||
shrinkWrap: true,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
childAspectRatio: 1,
|
||||
children: [
|
||||
if (_userProvider.user != null && _userProvider.user.type == UsersTypes.normal_user)
|
||||
LandPageItem(
|
||||
// text: _subtitle.newServiceRequest,
|
||||
text: context.translation.newServiceRequest,
|
||||
icon: FontAwesomeIcons.screwdriverWrench,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(CreateServiceRequestPage.id);
|
||||
},
|
||||
),
|
||||
LandPageItem(
|
||||
// text: _subtitle.trackServiceRequest,
|
||||
text: context.translation.trackServiceRequest,
|
||||
icon: FontAwesomeIcons.listCheck,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(ServiceRequestsPage.id);
|
||||
},
|
||||
),
|
||||
//if (_userProvider.user.type == UsersTypes.engineer)
|
||||
LandPageItem(
|
||||
// text: _subtitle.preventiveMaintenance,
|
||||
text: context.translation.preventiveMaintenance,
|
||||
icon: FontAwesomeIcons.personWalking,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(PpmPage.id);
|
||||
},
|
||||
),
|
||||
//if (_userProvider.user.type == UsersTypes.engineer)
|
||||
// LandPageItem(
|
||||
// text: _subtitle.preventiveMaintenance,
|
||||
// icon: FontAwesomeIcons.toolbox,
|
||||
// onPressed: (){
|
||||
// Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id);
|
||||
// },
|
||||
// ),
|
||||
if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.engineer)
|
||||
LandPageItem(
|
||||
text: context.translation.requestGasRefill,
|
||||
icon: FontAwesomeIcons.truckFast,
|
||||
onPressed: () {
|
||||
// Navigator.of(context).pushNamed(RequestGasRefill.id);
|
||||
Navigator.of(context).pushNamed(NewGasRefillRequestPage.routeName);
|
||||
},
|
||||
),
|
||||
LandPageItem(
|
||||
text: context.translation.trackGasRefill,
|
||||
icon: Icons.content_paste_search,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(TrackGasRefillPage.id);
|
||||
},
|
||||
),
|
||||
LandPageItem(
|
||||
text: context.translation.deviceTransfer,
|
||||
icon: FontAwesomeIcons.rightLeft,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(RequestDeviceTransfer.id);
|
||||
},
|
||||
),
|
||||
LandPageItem(
|
||||
text: context.translation.trackAssetTransfer,
|
||||
icon: FontAwesomeIcons.peopleCarryBox,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
|
||||
},
|
||||
),
|
||||
// if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
|
||||
// LandPageItem(
|
||||
// text: "Create Sub Work Order",
|
||||
// svgPath: "assets/images/sub_workorder_icon.svg",
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
// Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: ABackButton(
|
||||
// icon: Icons.power_settings_new_rounded,
|
||||
// onPressed: () async {
|
||||
// bool result = await showDialog(
|
||||
// context: context,
|
||||
// builder: (_) => const AAlertDialog(
|
||||
// // title: _subtitle.signOut,
|
||||
// title: "Sign Out",
|
||||
// // content: _subtitle.signOutAlert,
|
||||
// content: "Are you sure you want to exit?",
|
||||
// ));
|
||||
// if (result) {
|
||||
// // _devicesProvider.reset();
|
||||
// // _departmentsProvider.reset();
|
||||
// // _serviceRequestsProvider.reset();
|
||||
// // _regularVisitsProvider.reset();
|
||||
// // _preventiveMaintenanceVisitsProvider.reset();
|
||||
// _settingProvider.resetSettings();
|
||||
// _userProvider.reset();
|
||||
// Navigator.of(context).pop();
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// Align(
|
||||
// alignment: Alignment.topRight,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
// child: AIconButton(
|
||||
// iconData: Icons.menu,
|
||||
// color: AColors.primaryColor,
|
||||
// buttonSize: 42,
|
||||
// backgroundColor: AColors.white,
|
||||
// onPressed: () {
|
||||
// _scaffoldKey.currentState.openEndDrawer();
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
// endDrawer: Drawer(
|
||||
// backgroundColor: Colors.white,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// 40.height,
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// const Icon(Icons.clear).onPress(() => Navigator.pop(context)),
|
||||
// ],
|
||||
// ).paddingOnly(start: 4, end: 14),
|
||||
// Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// height: 50 * AppStyle.getScaleFactor(context),
|
||||
// width: 50 * AppStyle.getScaleFactor(context),
|
||||
// padding: EdgeInsets.all(4),
|
||||
// decoration: BoxDecoration(border: Border.all(color: Theme.of(context).primaryColor, width: 2), shape: BoxShape.circle),
|
||||
// child: ClipOval(
|
||||
// child: ClipOval(
|
||||
// child: Icon(
|
||||
// Icons.person,
|
||||
// size: 36,
|
||||
// color: Theme.of(context).colorScheme.primary,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// 12.width,
|
||||
// Text(
|
||||
// _userProvider.user?.userName ?? "??",
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ).expanded
|
||||
// ],
|
||||
// ).paddingOnly(start: 14, end: 14, top: 21, bottom: 21),
|
||||
// Divider(
|
||||
// height: 1,
|
||||
// thickness: 1,
|
||||
// color: AColors.greyEF,
|
||||
// ),
|
||||
// ListView(
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Radio(
|
||||
// value: "en",
|
||||
// activeColor: AColors.grey3A,
|
||||
// focusColor: AColors.grey3A,
|
||||
// groupValue: _settingProvider.language,
|
||||
// onChanged: (value) {
|
||||
// _settingProvider.setLanguage(value);
|
||||
// }),
|
||||
// Text(
|
||||
// "English",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Radio(
|
||||
// value: "ar",
|
||||
// activeColor: AColors.grey3A,
|
||||
// focusColor: AColors.grey3A,
|
||||
// groupValue: _settingProvider.language,
|
||||
// onChanged: (value) {
|
||||
// _settingProvider.setLanguage(value);
|
||||
// }),
|
||||
// Text(
|
||||
// "عربي",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Radio(
|
||||
// value: true,
|
||||
// activeColor: AColors.grey3A,
|
||||
// focusColor: AColors.grey3A,
|
||||
// groupValue: _settingProvider.language,
|
||||
// onChanged: (value) {
|
||||
// _settingProvider.setDarkTheme(value);
|
||||
// }),
|
||||
// Text(
|
||||
// "Dark",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Radio(
|
||||
// value: false,
|
||||
// activeColor: AColors.grey3A,
|
||||
// focusColor: AColors.grey3A,
|
||||
// groupValue: _settingProvider.language,
|
||||
// onChanged: (value) {
|
||||
// _settingProvider.setDarkTheme(value);
|
||||
// }),
|
||||
// Text(
|
||||
// "Light",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// // DrawerItem(
|
||||
// // icon: Icons.notifications,
|
||||
// // title: _subtitle.notifications,
|
||||
// // onPressed: () {
|
||||
// // Navigator.of(context).pushNamed(NotificationsPage.id);
|
||||
// // },
|
||||
// // ),
|
||||
// DrawerItem(
|
||||
// icon: Icons.mail,
|
||||
// // title: _subtitle.email,
|
||||
// title: "Email",
|
||||
// onPressed: () {
|
||||
// launch("mailto:customerservice@Test SA.com");
|
||||
// },
|
||||
// ),
|
||||
// // DrawerItem(
|
||||
// // icon: Icons.phone_in_talk,
|
||||
// // title: "${_subtitle.hotLine} 15564",
|
||||
// // onPressed: () {
|
||||
// // launch("tel:15564");
|
||||
// // },
|
||||
// // ),
|
||||
// // DrawerItem(
|
||||
// // icon: FontAwesomeIcons.linkedinIn,
|
||||
// // title: _subtitle.linkedIn,
|
||||
// // onPressed: () {
|
||||
// // launch("https://www.linkedin.com/company/Test SA/");
|
||||
// // },
|
||||
// // ),
|
||||
// // DrawerItem(
|
||||
// // icon: FontAwesomeIcons.globe,
|
||||
// // title: _subtitle.ourWebsite,
|
||||
// // onPressed: () {
|
||||
// // launch("https://www.Test SA.com/");
|
||||
// // },
|
||||
// // ),
|
||||
// DrawerItem(
|
||||
// icon: Icons.share,
|
||||
// // title: _subtitle.shareApp,
|
||||
// title: "Share App",
|
||||
// onPressed: () async {
|
||||
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
// String shareLink = "\n https://play.google.com/store/apps/details?id=" + packageInfo.packageName + "\n https://apps.apple.com/us/app/";
|
||||
// Share.share(shareLink);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ).expanded,
|
||||
// Divider(height: 1, thickness: 1, color: AColors.greyEF),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Powered By Cloud Solutions",
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(fontWeight: FontWeight.w500, color: AColors.grey3A, fontSize: 12),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// 6.width,
|
||||
// Image.asset("assets/images/cloud_logo.png", width: 32, height: 32)
|
||||
// ],
|
||||
// ).paddingOnly(start: 20, end: 20, top: 8, bottom: 8),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:io';
|
||||
//
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/notification/firebase_notification_manger.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/pages/device_transfer/track_device_transfer.dart';
|
||||
// import 'package:test_sa/views/pages/user/gas_refill/track_gas_refill.dart';
|
||||
// import 'package:test_sa/views/pages/user/ppm/ppm_page.dart';
|
||||
// import 'package:test_sa/views/pages/user/requests/create_service_request_page.dart';
|
||||
// import 'package:test_sa/views/widgets/dialogs/dialog.dart';
|
||||
//
|
||||
// import '../../../models/enums/user_types.dart';
|
||||
// import '../../widgets/land_page/land_page_item.dart';
|
||||
// import '../device_transfer/request_device_transfer.dart';
|
||||
// import 'requests/requests_page.dart';
|
||||
//
|
||||
// @Deprecated("Use the page which is inside the [new_views/pages/land_page] folder")
|
||||
// class LandPage extends StatefulWidget {
|
||||
// static const String id = "/old-land-page";
|
||||
//
|
||||
// const LandPage({Key key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<LandPage> createState() => _LandPageState();
|
||||
// }
|
||||
//
|
||||
// class _LandPageState extends State<LandPage> {
|
||||
// double _height;
|
||||
// double _width;
|
||||
// UserProvider _userProvider;
|
||||
// SettingProvider _settingProvider;
|
||||
//
|
||||
// // DepartmentsProvider _departmentsProvider;
|
||||
// // DevicesProvider _devicesProvider;
|
||||
// double _buttonHeight;
|
||||
// bool firstTime = true;
|
||||
//
|
||||
// // ServiceRequestsProvider _serviceRequestsProvider;
|
||||
// // PreventiveMaintenanceVisitsProvider _preventiveMaintenanceVisitsProvider;
|
||||
// // RegularVisitsProvider _regularVisitsProvider;
|
||||
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
// try {
|
||||
// FirebaseNotificationManger.initialized(context);
|
||||
// } catch (error) {}
|
||||
// });
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// String path = ModalRoute.of(context).settings.arguments;
|
||||
// _height = MediaQuery.of(context).size.height;
|
||||
// _width = MediaQuery.of(context).size.width;
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// // _departmentsProvider = Provider.of<DepartmentsProvider>(context);
|
||||
// // _devicesProvider = Provider.of<DevicesProvider>(context);
|
||||
// // _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context);
|
||||
// // _preventiveMaintenanceVisitsProvider = Provider.of<PreventiveMaintenanceVisitsProvider>(context);
|
||||
// // _regularVisitsProvider = Provider.of<RegularVisitsProvider>(context);
|
||||
// //
|
||||
// if (firstTime) {
|
||||
// if (path != null) {
|
||||
// Navigator.of(context).pushNamed("/" + path.split("/").first, arguments: path.split("/").last);
|
||||
// }
|
||||
// firstTime = false;
|
||||
// }
|
||||
// _buttonHeight = 68 * AppStyle.getScaleFactor(context);
|
||||
// return WillPopScope(
|
||||
// onWillPop: () async {
|
||||
// bool result = await showDialog(
|
||||
// context: context,
|
||||
// builder: (_) => AAlertDialog(
|
||||
// // title: _subtitle.exit,
|
||||
// title: context.translation.exit,
|
||||
// // content: _subtitle.exitAlert,
|
||||
// content: context.translation.sureExit,
|
||||
// ));
|
||||
// if (result == true) {
|
||||
// if (Platform.isAndroid) {
|
||||
// SystemChannels.platform.invokeMethod('SystemNavigator.pop');
|
||||
// } else {
|
||||
// exit(0);
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// },
|
||||
// child: Scaffold(
|
||||
// key: _scaffoldKey, //backgroundColor: Color(0xffF8F8F8),
|
||||
// body: SafeArea(
|
||||
// child: Stack(
|
||||
// children: [
|
||||
// ListView(
|
||||
// padding: const EdgeInsets.all(16.0),
|
||||
// children: [
|
||||
// //AppNameBar(),
|
||||
// // SizedBox(
|
||||
// // height: _height/3.2,
|
||||
// // width: _width,
|
||||
// // child: CarouselSlider.builder(
|
||||
// // options: CarouselOptions(
|
||||
// // height: _height/3,
|
||||
// // autoPlay: true,
|
||||
// // viewportFraction: 1
|
||||
// // ),
|
||||
// // itemCount: 4,
|
||||
// // itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
|
||||
// // Image(
|
||||
// // //width: _width,
|
||||
// // image: AssetImage("assets/images/$itemIndex.png"),
|
||||
// // fit: BoxFit.cover,
|
||||
// // )
|
||||
// // ),
|
||||
// // ),
|
||||
// // SizedBox(
|
||||
// // height: 48 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // Hero(
|
||||
// // tag: "logo",
|
||||
// // child: Image(
|
||||
// // height: _height / 6,
|
||||
// // image: const AssetImage("assets/images/logo.png"),
|
||||
// // ),
|
||||
// // ),
|
||||
// GridView.count(
|
||||
// shrinkWrap: true,
|
||||
// physics: const ClampingScrollPhysics(),
|
||||
// crossAxisCount: 2,
|
||||
// crossAxisSpacing: 12,
|
||||
// mainAxisSpacing: 12,
|
||||
// childAspectRatio: 1,
|
||||
// children: [
|
||||
// if (_userProvider.user != null && _userProvider.user.type == UsersTypes.normal_user)
|
||||
// LandPageItem(
|
||||
// // text: _subtitle.newServiceRequest,
|
||||
// text: context.translation.newServiceRequest,
|
||||
// icon: FontAwesomeIcons.screwdriverWrench,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(CreateServiceRequestPage.id);
|
||||
// },
|
||||
// ),
|
||||
// LandPageItem(
|
||||
// // text: _subtitle.trackServiceRequest,
|
||||
// text: context.translation.trackServiceRequest,
|
||||
// icon: FontAwesomeIcons.listCheck,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(ServiceRequestsPage.id);
|
||||
// },
|
||||
// ),
|
||||
// //if (_userProvider.user.type == UsersTypes.engineer)
|
||||
// LandPageItem(
|
||||
// // text: _subtitle.preventiveMaintenance,
|
||||
// text: context.translation.preventiveMaintenance,
|
||||
// icon: FontAwesomeIcons.personWalking,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(PpmPage.id);
|
||||
// },
|
||||
// ),
|
||||
// //if (_userProvider.user.type == UsersTypes.engineer)
|
||||
// // LandPageItem(
|
||||
// // text: _subtitle.preventiveMaintenance,
|
||||
// // icon: FontAwesomeIcons.toolbox,
|
||||
// // onPressed: (){
|
||||
// // Navigator.of(context).pushNamed(PreventiveMaintenanceVisitsPage.id);
|
||||
// // },
|
||||
// // ),
|
||||
// if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.engineer)
|
||||
// LandPageItem(
|
||||
// text: context.translation.requestGasRefill,
|
||||
// icon: FontAwesomeIcons.truckFast,
|
||||
// onPressed: () {
|
||||
// // Navigator.of(context).pushNamed(RequestGasRefill.id);
|
||||
// Navigator.of(context).pushNamed(NewGasRefillRequestPage.routeName);
|
||||
// },
|
||||
// ),
|
||||
// LandPageItem(
|
||||
// text: context.translation.trackGasRefill,
|
||||
// icon: Icons.content_paste_search,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(TrackGasRefillPage.id);
|
||||
// },
|
||||
// ),
|
||||
// LandPageItem(
|
||||
// text: context.translation.deviceTransfer,
|
||||
// icon: FontAwesomeIcons.rightLeft,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(RequestDeviceTransfer.id);
|
||||
// },
|
||||
// ),
|
||||
// LandPageItem(
|
||||
// text: context.translation.trackAssetTransfer,
|
||||
// icon: FontAwesomeIcons.peopleCarryBox,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pushNamed(TrackDeviceTransferPage.id);
|
||||
// },
|
||||
// ),
|
||||
// // if (_userProvider?.user != null && _userProvider?.user?.type != UsersTypes.normal_user)
|
||||
// // LandPageItem(
|
||||
// // text: "Create Sub Work Order",
|
||||
// // svgPath: "assets/images/sub_workorder_icon.svg",
|
||||
// // onPressed: () {
|
||||
// // Navigator.of(context).pushNamed(SearchSubWorkOrderPage.id);
|
||||
// // },
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// // Align(
|
||||
// // alignment: Alignment.topLeft,
|
||||
// // child: ABackButton(
|
||||
// // icon: Icons.power_settings_new_rounded,
|
||||
// // onPressed: () async {
|
||||
// // bool result = await showDialog(
|
||||
// // context: context,
|
||||
// // builder: (_) => const AAlertDialog(
|
||||
// // // title: _subtitle.signOut,
|
||||
// // title: "Sign Out",
|
||||
// // // content: _subtitle.signOutAlert,
|
||||
// // content: "Are you sure you want to exit?",
|
||||
// // ));
|
||||
// // if (result) {
|
||||
// // // _devicesProvider.reset();
|
||||
// // // _departmentsProvider.reset();
|
||||
// // // _serviceRequestsProvider.reset();
|
||||
// // // _regularVisitsProvider.reset();
|
||||
// // // _preventiveMaintenanceVisitsProvider.reset();
|
||||
// // _settingProvider.resetSettings();
|
||||
// // _userProvider.reset();
|
||||
// // Navigator.of(context).pop();
|
||||
// // }
|
||||
// // },
|
||||
// // ),
|
||||
// // ),
|
||||
// // Align(
|
||||
// // alignment: Alignment.topRight,
|
||||
// // child: Padding(
|
||||
// // padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
// // child: AIconButton(
|
||||
// // iconData: Icons.menu,
|
||||
// // color: AColors.primaryColor,
|
||||
// // buttonSize: 42,
|
||||
// // backgroundColor: AColors.white,
|
||||
// // onPressed: () {
|
||||
// // _scaffoldKey.currentState.openEndDrawer();
|
||||
// // },
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// // endDrawer: Drawer(
|
||||
// // backgroundColor: Colors.white,
|
||||
// // child: Column(
|
||||
// // children: [
|
||||
// // 40.height,
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.end,
|
||||
// // children: [
|
||||
// // const Icon(Icons.clear).onPress(() => Navigator.pop(context)),
|
||||
// // ],
|
||||
// // ).paddingOnly(start: 4, end: 14),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Container(
|
||||
// // height: 50 * AppStyle.getScaleFactor(context),
|
||||
// // width: 50 * AppStyle.getScaleFactor(context),
|
||||
// // padding: EdgeInsets.all(4),
|
||||
// // decoration: BoxDecoration(border: Border.all(color: Theme.of(context).primaryColor, width: 2), shape: BoxShape.circle),
|
||||
// // child: ClipOval(
|
||||
// // child: ClipOval(
|
||||
// // child: Icon(
|
||||
// // Icons.person,
|
||||
// // size: 36,
|
||||
// // color: Theme.of(context).colorScheme.primary,
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// // 12.width,
|
||||
// // Text(
|
||||
// // _userProvider.user?.userName ?? "??",
|
||||
// // style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
// // fontWeight: FontWeight.w600,
|
||||
// // ),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ).expanded
|
||||
// // ],
|
||||
// // ).paddingOnly(start: 14, end: 14, top: 21, bottom: 21),
|
||||
// // Divider(
|
||||
// // height: 1,
|
||||
// // thickness: 1,
|
||||
// // color: AColors.greyEF,
|
||||
// // ),
|
||||
// // ListView(
|
||||
// // children: [
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Radio(
|
||||
// // value: "en",
|
||||
// // activeColor: AColors.grey3A,
|
||||
// // focusColor: AColors.grey3A,
|
||||
// // groupValue: _settingProvider.language,
|
||||
// // onChanged: (value) {
|
||||
// // _settingProvider.setLanguage(value);
|
||||
// // }),
|
||||
// // Text(
|
||||
// // "English",
|
||||
// // style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // Radio(
|
||||
// // value: "ar",
|
||||
// // activeColor: AColors.grey3A,
|
||||
// // focusColor: AColors.grey3A,
|
||||
// // groupValue: _settingProvider.language,
|
||||
// // onChanged: (value) {
|
||||
// // _settingProvider.setLanguage(value);
|
||||
// // }),
|
||||
// // Text(
|
||||
// // "عربي",
|
||||
// // style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // Row(
|
||||
// // children: [
|
||||
// // Radio(
|
||||
// // value: true,
|
||||
// // activeColor: AColors.grey3A,
|
||||
// // focusColor: AColors.grey3A,
|
||||
// // groupValue: _settingProvider.language,
|
||||
// // onChanged: (value) {
|
||||
// // _settingProvider.setDarkTheme(value);
|
||||
// // }),
|
||||
// // Text(
|
||||
// // "Dark",
|
||||
// // style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // Radio(
|
||||
// // value: false,
|
||||
// // activeColor: AColors.grey3A,
|
||||
// // focusColor: AColors.grey3A,
|
||||
// // groupValue: _settingProvider.language,
|
||||
// // onChanged: (value) {
|
||||
// // _settingProvider.setDarkTheme(value);
|
||||
// // }),
|
||||
// // Text(
|
||||
// // "Light",
|
||||
// // style: Theme.of(context).textTheme.bodyText1.copyWith(color: AColors.grey3A),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ],
|
||||
// // ),
|
||||
// // // DrawerItem(
|
||||
// // // icon: Icons.notifications,
|
||||
// // // title: _subtitle.notifications,
|
||||
// // // onPressed: () {
|
||||
// // // Navigator.of(context).pushNamed(NotificationsPage.id);
|
||||
// // // },
|
||||
// // // ),
|
||||
// // DrawerItem(
|
||||
// // icon: Icons.mail,
|
||||
// // // title: _subtitle.email,
|
||||
// // title: "Email",
|
||||
// // onPressed: () {
|
||||
// // launch("mailto:customerservice@Test SA.com");
|
||||
// // },
|
||||
// // ),
|
||||
// // // DrawerItem(
|
||||
// // // icon: Icons.phone_in_talk,
|
||||
// // // title: "${_subtitle.hotLine} 15564",
|
||||
// // // onPressed: () {
|
||||
// // // launch("tel:15564");
|
||||
// // // },
|
||||
// // // ),
|
||||
// // // DrawerItem(
|
||||
// // // icon: FontAwesomeIcons.linkedinIn,
|
||||
// // // title: _subtitle.linkedIn,
|
||||
// // // onPressed: () {
|
||||
// // // launch("https://www.linkedin.com/company/Test SA/");
|
||||
// // // },
|
||||
// // // ),
|
||||
// // // DrawerItem(
|
||||
// // // icon: FontAwesomeIcons.globe,
|
||||
// // // title: _subtitle.ourWebsite,
|
||||
// // // onPressed: () {
|
||||
// // // launch("https://www.Test SA.com/");
|
||||
// // // },
|
||||
// // // ),
|
||||
// // DrawerItem(
|
||||
// // icon: Icons.share,
|
||||
// // // title: _subtitle.shareApp,
|
||||
// // title: "Share App",
|
||||
// // onPressed: () async {
|
||||
// // PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
// // String shareLink = "\n https://play.google.com/store/apps/details?id=" + packageInfo.packageName + "\n https://apps.apple.com/us/app/";
|
||||
// // Share.share(shareLink);
|
||||
// // },
|
||||
// // ),
|
||||
// // ],
|
||||
// // ).expanded,
|
||||
// // Divider(height: 1, thickness: 1, color: AColors.greyEF),
|
||||
// // Row(
|
||||
// // mainAxisAlignment: MainAxisAlignment.center,
|
||||
// // children: [
|
||||
// // Text(
|
||||
// // "Powered By Cloud Solutions",
|
||||
// // style: Theme.of(context).textTheme.headline6.copyWith(fontWeight: FontWeight.w500, color: AColors.grey3A, fontSize: 12),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // 6.width,
|
||||
// // Image.asset("assets/images/cloud_logo.png", width: 32, height: 32)
|
||||
// // ],
|
||||
// // ).paddingOnly(start: 20, end: 20, top: 8, bottom: 8),
|
||||
// // ],
|
||||
// // ),
|
||||
// // ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,49 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/ppm/ppm.dart';
|
||||
|
||||
class FutureEditPpm extends StatefulWidget {
|
||||
final Ppm ppm;
|
||||
|
||||
const FutureEditPpm({Key key, this.ppm}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FutureEditPpm> createState() => _FutureEditPpmState();
|
||||
}
|
||||
|
||||
class _FutureEditPpmState extends State<FutureEditPpm> {
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
//String requestId = ModalRoute.of(context).settings.arguments;
|
||||
|
||||
// return Scaffold(
|
||||
// body: FutureBuilder<Pentry>(
|
||||
// future: RegularVisitsProvider().getPentry(user: _userProvider.user, host: _settingProvider.host, id: widget.ppm.id),
|
||||
// builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot) {
|
||||
// if (snapshot.hasError) {
|
||||
// return FailedLoading(
|
||||
// message: context.translation.failedToCompleteRequest,
|
||||
// onReload: () {
|
||||
// setState(() {});
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// if (snapshot.hasData) {
|
||||
// return EditPentry(
|
||||
// pentry: snapshot.data,
|
||||
// ppm: widget.ppm,
|
||||
// );
|
||||
// }
|
||||
// return const Center(child: ALoading());
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/ppm/ppm.dart';
|
||||
//
|
||||
// class FutureEditPpm extends StatefulWidget {
|
||||
// final Ppm ppm;
|
||||
//
|
||||
// const FutureEditPpm({Key key, this.ppm}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<FutureEditPpm> createState() => _FutureEditPpmState();
|
||||
// }
|
||||
//
|
||||
// class _FutureEditPpmState extends State<FutureEditPpm> {
|
||||
// UserProvider _userProvider;
|
||||
// SettingProvider _settingProvider;
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// //String requestId = ModalRoute.of(context).settings.arguments;
|
||||
//
|
||||
// // return Scaffold(
|
||||
// // body: FutureBuilder<Pentry>(
|
||||
// // future: RegularVisitsProvider().getPentry(user: _userProvider.user, host: _settingProvider.host, id: widget.ppm.id),
|
||||
// // builder: (BuildContext context, AsyncSnapshot<Pentry> snapshot) {
|
||||
// // if (snapshot.hasError) {
|
||||
// // return FailedLoading(
|
||||
// // message: context.translation.failedToCompleteRequest,
|
||||
// // onReload: () {
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // );
|
||||
// // }
|
||||
// // if (snapshot.hasData) {
|
||||
// // return EditPentry(
|
||||
// // pentry: snapshot.data,
|
||||
// // ppm: widget.ppm,
|
||||
// // );
|
||||
// // }
|
||||
// // return const Center(child: ALoading());
|
||||
// // },
|
||||
// // ),
|
||||
// // );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AppNameBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 50 * AppStyle.getScaleFactor(context),
|
||||
// color: AColors.primaryColor,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Test SA",
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(/*color: AColors.white,*/ fontStyle: FontStyle.italic),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AppNameBar extends StatelessWidget {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// height: 50 * AppStyle.getScaleFactor(context),
|
||||
// // color: AColors.primaryColor,
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// "Test SA",
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(/*color: AColors.white,*/ fontStyle: FontStyle.italic),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,27 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AFlatButton extends StatelessWidget {
|
||||
final String text;
|
||||
final Color textColor;
|
||||
final TextStyle style;
|
||||
final EdgeInsets padding;
|
||||
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(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: this.textColor ?? Colors.black,
|
||||
padding: padding,
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
text ?? "",
|
||||
style: style ?? Theme.of(context).textTheme.bodyText1,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AFlatButton extends StatelessWidget {
|
||||
// final String text;
|
||||
// final Color textColor;
|
||||
// final TextStyle style;
|
||||
// final EdgeInsets padding;
|
||||
// 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(
|
||||
// style: TextButton.styleFrom(
|
||||
// foregroundColor: this.textColor ?? Colors.black,
|
||||
// padding: padding,
|
||||
// ),
|
||||
// onPressed: onPressed,
|
||||
// child: Text(
|
||||
// text ?? "",
|
||||
// style: style ?? Theme.of(context).textTheme.bodyText1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AOutLinedButton extends StatelessWidget {
|
||||
final String text;
|
||||
final Color color;
|
||||
final EdgeInsets padding;
|
||||
final TextStyle textStyle;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
const AOutLinedButton({Key key, this.color/*= AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return OutlinedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: padding ?? EdgeInsets.symmetric(vertical: 12),
|
||||
textStyle: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(fontSize: 18),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
text ?? "",
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.primaryColor, fontSize: 14, fontWeight: FontWeight.w600),
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AOutLinedButton extends StatelessWidget {
|
||||
// final String text;
|
||||
// final Color color;
|
||||
// final EdgeInsets padding;
|
||||
// final TextStyle textStyle;
|
||||
// final VoidCallback onPressed;
|
||||
//
|
||||
// const AOutLinedButton({Key key, this.color/*= AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return OutlinedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// padding: padding ?? EdgeInsets.symmetric(vertical: 12),
|
||||
// textStyle: textStyle ?? Theme.of(context).textTheme.subtitle2.copyWith(fontSize: 18),
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
// ),
|
||||
// onPressed: onPressed,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// text ?? "",
|
||||
// // style: Theme.of(context).textTheme.subtitle2.copyWith(color: AColors.primaryColor, fontSize: 14, fontWeight: FontWeight.w600),
|
||||
// textAlign: TextAlign.center,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,28 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class ASmallButton extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final Color color;
|
||||
final EdgeInsets padding;
|
||||
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(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: padding,
|
||||
primary: color ?? Theme.of(context).primaryColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
),
|
||||
child: Text(
|
||||
text ?? "",
|
||||
style: style ?? Theme.of(context).textTheme.bodyText1.copyWith(color: color == Colors.white ? Theme.of(context).primaryColor : Colors.white),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
onPressed: onPressed);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class ASmallButton extends StatelessWidget {
|
||||
// final String text;
|
||||
// final TextStyle style;
|
||||
// final Color color;
|
||||
// final EdgeInsets padding;
|
||||
// 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(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// padding: padding,
|
||||
// primary: color ?? Theme.of(context).primaryColor,
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
// ),
|
||||
// child: Text(
|
||||
// text ?? "",
|
||||
// style: style ?? Theme.of(context).textTheme.bodyText1.copyWith(color: color == Colors.white ? Theme.of(context).primaryColor : Colors.white),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// onPressed: onPressed);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,23 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CarveInImage extends CustomClipper<Path> {
|
||||
final double gab;
|
||||
var radius = 10.0;
|
||||
|
||||
CarveInImage(this.gab);
|
||||
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
Path path = Path();
|
||||
path.lineTo(0, size.height);
|
||||
path.lineTo(size.width / 2 - gab / 2, size.height);
|
||||
path.arcToPoint(Offset(size.width / 2 + gab / 2, size.height), radius: Radius.circular(gab / 2));
|
||||
path.lineTo(size.width, size.height);
|
||||
path.lineTo(size.width, 0);
|
||||
path.lineTo(0, 0);
|
||||
return path;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(CustomClipper<Path> oldClipper) => true;
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
//
|
||||
// class CarveInImage extends CustomClipper<Path> {
|
||||
// final double gab;
|
||||
// var radius = 10.0;
|
||||
//
|
||||
// CarveInImage(this.gab);
|
||||
//
|
||||
// @override
|
||||
// Path getClip(Size size) {
|
||||
// Path path = Path();
|
||||
// path.lineTo(0, size.height);
|
||||
// path.lineTo(size.width / 2 - gab / 2, size.height);
|
||||
// path.arcToPoint(Offset(size.width / 2 + gab / 2, size.height), radius: Radius.circular(gab / 2));
|
||||
// path.lineTo(size.width, size.height);
|
||||
// path.lineTo(size.width, 0);
|
||||
// path.lineTo(0, 0);
|
||||
// return path;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// bool shouldReclip(CustomClipper<Path> oldClipper) => true;
|
||||
// }
|
||||
|
||||
@ -1,79 +1,80 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import 'date_picker.dart';
|
||||
|
||||
class FromToDateBar extends StatefulWidget {
|
||||
final DateTime from;
|
||||
final DateTime to;
|
||||
final Function(DateTime) onPickFrom;
|
||||
final Function(DateTime) onPickTo;
|
||||
|
||||
const FromToDateBar({Key key, this.from, this.to, this.onPickFrom, this.onPickTo}) : super(key: key);
|
||||
|
||||
@override
|
||||
_FromToDateBarState createState() => _FromToDateBarState();
|
||||
}
|
||||
|
||||
class _FromToDateBarState extends State<FromToDateBar> {
|
||||
DateTime _from;
|
||||
DateTime _to;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_from = widget.from;
|
||||
_to = widget.to;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.from,
|
||||
style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ADatePicker(
|
||||
date: _from,
|
||||
from: DateTime(1950),
|
||||
onDatePicker: (date) {
|
||||
_from = date;
|
||||
setState(() {});
|
||||
widget.onPickFrom(date);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
context.translation.to,
|
||||
style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ADatePicker(
|
||||
date: _to,
|
||||
from: DateTime(1950),
|
||||
onDatePicker: (date) {
|
||||
_to = date;
|
||||
setState(() {});
|
||||
widget.onPickTo(date);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox.shrink(),
|
||||
SizedBox.shrink(),
|
||||
SizedBox.shrink(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import 'date_picker.dart';
|
||||
//
|
||||
// class FromToDateBar extends StatefulWidget {
|
||||
// final DateTime from;
|
||||
// final DateTime to;
|
||||
// final Function(DateTime) onPickFrom;
|
||||
// final Function(DateTime) onPickTo;
|
||||
//
|
||||
// const FromToDateBar({Key key, this.from, this.to, this.onPickFrom, this.onPickTo}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _FromToDateBarState createState() => _FromToDateBarState();
|
||||
// }
|
||||
//
|
||||
// class _FromToDateBarState extends State<FromToDateBar> {
|
||||
// DateTime _from;
|
||||
// DateTime _to;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _from = widget.from;
|
||||
// _to = widget.to;
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
// children: [
|
||||
// Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// context.translation.from,
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ADatePicker(
|
||||
// date: _from,
|
||||
// from: DateTime(1950),
|
||||
// onDatePicker: (date) {
|
||||
// _from = date;
|
||||
// setState(() {});
|
||||
// widget.onPickFrom(date);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// context.translation.to,
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ADatePicker(
|
||||
// date: _to,
|
||||
// from: DateTime(1950),
|
||||
// onDatePicker: (date) {
|
||||
// _to = date;
|
||||
// setState(() {});
|
||||
// widget.onPickTo(date);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox.shrink(),
|
||||
// SizedBox.shrink(),
|
||||
// SizedBox.shrink(),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,72 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class ADateTimePicker extends StatelessWidget {
|
||||
final DateTime date;
|
||||
final DateTime from;
|
||||
final DateTime to;
|
||||
final Function(DateTime) onDateTimePicker;
|
||||
final bool enable;
|
||||
|
||||
const ADateTimePicker({Key key, this.date, this.onDateTimePicker, this.from, this.to, this.enable}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
textStyle: Theme.of(context).textTheme.subtitle2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12 * AppStyle.getScaleFactor(context)),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
date == null ? "Pick Time" : date.toString().substring(0, date.toString().lastIndexOf(":")),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
onPressed: enable
|
||||
? () async {
|
||||
// TimeOfDay picked = await showTimePicker(context: context, initialTime: TimeOfDay.now());
|
||||
onDateTimePicker(await showDateTimePicker(context: context, initialDate: date, firstDate: from, lastDate: to));
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<DateTime> showDateTimePicker({
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate,
|
||||
}) async {
|
||||
initialDate ??= DateTime.now();
|
||||
firstDate ??= initialDate.subtract(const Duration(days: 365 * 100));
|
||||
lastDate ??= firstDate.add(const Duration(days: 365 * 200));
|
||||
|
||||
final DateTime selectedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initialDate,
|
||||
firstDate: firstDate,
|
||||
lastDate: lastDate,
|
||||
);
|
||||
|
||||
if (selectedDate == null) return null;
|
||||
|
||||
if (!context.mounted) return selectedDate;
|
||||
|
||||
final TimeOfDay selectedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.fromDateTime(selectedDate),
|
||||
);
|
||||
|
||||
return selectedTime == null
|
||||
? selectedDate
|
||||
: DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month,
|
||||
selectedDate.day,
|
||||
selectedTime.hour,
|
||||
selectedTime.minute,
|
||||
);
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class ADateTimePicker extends StatelessWidget {
|
||||
// final DateTime date;
|
||||
// final DateTime from;
|
||||
// final DateTime to;
|
||||
// final Function(DateTime) onDateTimePicker;
|
||||
// final bool enable;
|
||||
//
|
||||
// const ADateTimePicker({Key key, this.date, this.onDateTimePicker, this.from, this.to, this.enable}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// foregroundColor: Colors.white,
|
||||
// textStyle: Theme.of(context).textTheme.subtitle2,
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(12 * AppStyle.getScaleFactor(context)),
|
||||
// ),
|
||||
// ),
|
||||
// child: Text(
|
||||
// date == null ? "Pick Time" : date.toString().substring(0, date.toString().lastIndexOf(":")),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// onPressed: enable
|
||||
// ? () async {
|
||||
// // TimeOfDay picked = await showTimePicker(context: context, initialTime: TimeOfDay.now());
|
||||
// onDateTimePicker(await showDateTimePicker(context: context, initialDate: date, firstDate: from, lastDate: to));
|
||||
// }
|
||||
// : null,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<DateTime> showDateTimePicker({
|
||||
// BuildContext context,
|
||||
// DateTime initialDate,
|
||||
// DateTime firstDate,
|
||||
// DateTime lastDate,
|
||||
// }) async {
|
||||
// initialDate ??= DateTime.now();
|
||||
// firstDate ??= initialDate.subtract(const Duration(days: 365 * 100));
|
||||
// lastDate ??= firstDate.add(const Duration(days: 365 * 200));
|
||||
//
|
||||
// final DateTime selectedDate = await showDatePicker(
|
||||
// context: context,
|
||||
// initialDate: initialDate,
|
||||
// firstDate: firstDate,
|
||||
// lastDate: lastDate,
|
||||
// );
|
||||
//
|
||||
// if (selectedDate == null) return null;
|
||||
//
|
||||
// if (!context.mounted) return selectedDate;
|
||||
//
|
||||
// final TimeOfDay selectedTime = await showTimePicker(
|
||||
// context: context,
|
||||
// initialTime: TimeOfDay.fromDateTime(selectedDate),
|
||||
// );
|
||||
//
|
||||
// return selectedTime == null
|
||||
// ? selectedDate
|
||||
// : DateTime(
|
||||
// selectedDate.year,
|
||||
// selectedDate.month,
|
||||
// selectedDate.day,
|
||||
// selectedTime.hour,
|
||||
// selectedTime.minute,
|
||||
// );
|
||||
// }
|
||||
|
||||
@ -1,47 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/department.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/departments/single_department_picker.dart';
|
||||
|
||||
class DepartmentButton extends StatelessWidget {
|
||||
final Function(Department) onDepartmentPick;
|
||||
final Department department;
|
||||
|
||||
const DepartmentButton({Key key, this.department, this.onDepartmentPick}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
),
|
||||
// foregroundColor: AColors.primaryColor,
|
||||
// backgroundColor: AColors.inputFieldBackgroundColor,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
department?.name ?? context.translation.pickUnite,
|
||||
style: Theme.of(context).textTheme.bodyText1,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
// const Icon(Icons.keyboard_arrow_down, size: 28, color: AColors.grey3A),
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
Department _department = await Navigator.of(context).pushNamed(SingleDepartmentPicker.id) as Department;
|
||||
onDepartmentPick(_department);
|
||||
});
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/department.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/departments/single_department_picker.dart';
|
||||
//
|
||||
// class DepartmentButton extends StatelessWidget {
|
||||
// final Function(Department) onDepartmentPick;
|
||||
// final Department department;
|
||||
//
|
||||
// const DepartmentButton({Key key, this.department, this.onDepartmentPick}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// elevation: 0,
|
||||
// padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// ),
|
||||
// // foregroundColor: AColors.primaryColor,
|
||||
// // backgroundColor: AColors.inputFieldBackgroundColor,
|
||||
// ),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
// child: Text(
|
||||
// department?.name ?? context.translation.pickUnite,
|
||||
// style: Theme.of(context).textTheme.bodyText1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// textDirection: TextDirection.rtl,
|
||||
// textAlign: TextAlign.left,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// // const Icon(Icons.keyboard_arrow_down, size: 28, color: AColors.grey3A),
|
||||
// ],
|
||||
// ),
|
||||
// onPressed: () async {
|
||||
// Department _department = await Navigator.of(context).pushNamed(SingleDepartmentPicker.id) as Department;
|
||||
// onDepartmentPick(_department);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,75 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/image_loader.dart';
|
||||
import 'package:test_sa/views/widgets/requests/info_row.dart';
|
||||
import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
|
||||
import '../../../controllers/providers/api/user_provider.dart';
|
||||
import '../../../models/device/device_transfer_info.dart';
|
||||
import '../images/multi_image_picker.dart';
|
||||
|
||||
class DeviceTransferInfoSection extends StatelessWidget {
|
||||
final DeviceTransferInfo info;
|
||||
final bool isSender;
|
||||
final VoidCallback onEdit;
|
||||
|
||||
const DeviceTransferInfoSection({Key key, this.info, this.onEdit, this.isSender}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
info.userName = Provider.of<UserProvider>(context).user.username;
|
||||
info.attachments ??= [];
|
||||
return Column(
|
||||
children: [
|
||||
RequestInfoRow(
|
||||
title: context.translation.hospital,
|
||||
info: info.client.name,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: context.translation.department,
|
||||
info: info.department.name,
|
||||
),
|
||||
// RequestInfoRow(
|
||||
// title: isSender ? "Sender Name " : "Receiver Name",
|
||||
// info: info.userName,
|
||||
// ),
|
||||
RequestInfoRow(
|
||||
title: context.translation.workingHours,
|
||||
info: info.workingHours,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: context.translation.travelingHours,
|
||||
info: info.travelingHours,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: "Comment",
|
||||
info: info.comment,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: "Assigned Engineer",
|
||||
info: info.assignedEmployeeName,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: "Signature",
|
||||
info: info.engSignature?.isEmpty != false ? context.translation.noDateFound : null,
|
||||
contentWidget: info.engSignature?.isEmpty != false ? null : ImageLoader(url: info.engSignature),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: MultiFilesPicker(
|
||||
label: "Attachments",
|
||||
files: info.attachments,
|
||||
enabled: false,
|
||||
),
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: context.translation.status,
|
||||
infoWidget: StatusLabel(
|
||||
label: info.status?.name, /*backgroundColor: AColors.getGasStatusColor(info.status?.id)*/
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/image_loader.dart';
|
||||
// import 'package:test_sa/views/widgets/requests/info_row.dart';
|
||||
// import 'package:test_sa/views/widgets/requests/request_status.dart';
|
||||
//
|
||||
// import '../../../controllers/providers/api/user_provider.dart';
|
||||
// import '../../../models/device/device_transfer_info.dart';
|
||||
// import '../images/multi_image_picker.dart';
|
||||
//
|
||||
// class DeviceTransferInfoSection extends StatelessWidget {
|
||||
// final DeviceTransferInfo info;
|
||||
// final bool isSender;
|
||||
// final VoidCallback onEdit;
|
||||
//
|
||||
// const DeviceTransferInfoSection({Key key, this.info, this.onEdit, this.isSender}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// info.userName = Provider.of<UserProvider>(context).user.username;
|
||||
// info.attachments ??= [];
|
||||
// return Column(
|
||||
// children: [
|
||||
// RequestInfoRow(
|
||||
// title: context.translation.hospital,
|
||||
// info: info.client.name,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: context.translation.department,
|
||||
// info: info.department.name,
|
||||
// ),
|
||||
// // RequestInfoRow(
|
||||
// // title: isSender ? "Sender Name " : "Receiver Name",
|
||||
// // info: info.userName,
|
||||
// // ),
|
||||
// RequestInfoRow(
|
||||
// title: context.translation.workingHours,
|
||||
// info: info.workingHours,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: context.translation.travelingHours,
|
||||
// info: info.travelingHours,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: "Comment",
|
||||
// info: info.comment,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: "Assigned Engineer",
|
||||
// info: info.assignedEmployeeName,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: "Signature",
|
||||
// info: info.engSignature?.isEmpty != false ? context.translation.noDateFound : null,
|
||||
// contentWidget: info.engSignature?.isEmpty != false ? null : ImageLoader(url: info.engSignature),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
// child: MultiFilesPicker(
|
||||
// label: "Attachments",
|
||||
// files: info.attachments,
|
||||
// enabled: false,
|
||||
// ),
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: context.translation.status,
|
||||
// infoWidget: StatusLabel(
|
||||
// label: info.status?.name, /*backgroundColor: AColors.getGasStatusColor(info.status?.id)*/
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,41 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class DrawerItem extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
const DrawerItem({Key key, this.title, this.icon, this.onPressed}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(0.0),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
primary: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, /*color: AColors.grey3A,*/ size: 20),
|
||||
12.width,
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
fontSize: 14, /* color: AColors.grey3A*/
|
||||
),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
).paddingOnly(start: 20, end: 20),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class DrawerItem extends StatelessWidget {
|
||||
// final String title;
|
||||
// final IconData icon;
|
||||
// final VoidCallback onPressed;
|
||||
//
|
||||
// const DrawerItem({Key key, this.title, this.icon, this.onPressed}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.all(0.0),
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// padding: EdgeInsets.zero,
|
||||
// elevation: 0,
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
// primary: Theme.of(context).colorScheme.onPrimary,
|
||||
// ),
|
||||
// onPressed: onPressed,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Icon(icon, /*color: AColors.grey3A,*/ size: 20),
|
||||
// 12.width,
|
||||
// Text(
|
||||
// title,
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
// fontSize: 14, /* color: AColors.grey3A*/
|
||||
// ),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ).paddingOnly(start: 20, end: 20),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,97 +1,98 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
|
||||
import '../../../models/device/asset.dart';
|
||||
|
||||
class AutoCompleteDeviceField extends StatefulWidget {
|
||||
final Asset initialValue;
|
||||
final int hospitalId;
|
||||
final Function(int) onPick;
|
||||
|
||||
const AutoCompleteDeviceField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AutoCompleteDeviceFieldState createState() => _AutoCompleteDeviceFieldState();
|
||||
}
|
||||
|
||||
class _AutoCompleteDeviceFieldState extends State<AutoCompleteDeviceField> {
|
||||
SettingProvider _settingProvider;
|
||||
AssetProvider _devicesProvider;
|
||||
UserProvider _userProvider;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue.assetSerialNo);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_devicesProvider = Provider.of<AssetProvider>(context);
|
||||
|
||||
return LoadingManager(
|
||||
isLoading: _devicesProvider.isLoading,
|
||||
isFailedLoading: _devicesProvider.devices == null,
|
||||
stateCode: _devicesProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
_devicesProvider.reset();
|
||||
await _devicesProvider.getAssets();
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
// border: Border.all(color: AColors.black),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
boxShadow: [AppStyle.boxShadow]),
|
||||
child: TypeAheadField<Asset>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
),
|
||||
suggestionsCallback: (value) async {
|
||||
return await _devicesProvider.getDevicesList(
|
||||
host: _settingProvider.host,
|
||||
user: _userProvider.user,
|
||||
hospitalId: widget.hospitalId ?? _userProvider.user.clientId,
|
||||
// serialNumber: value,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, device) {
|
||||
return ListTile(
|
||||
title: Text(device.assetSerialNo),
|
||||
subtitle: Text("${device.modelDefinition.modelName}/${device.modelDefinition.manufacturerName}"),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (device) {
|
||||
_controller.text = device.assetSerialNo;
|
||||
widget.onPick(device.id);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
//
|
||||
// import '../../../models/device/asset.dart';
|
||||
//
|
||||
// class AutoCompleteDeviceField extends StatefulWidget {
|
||||
// final Asset initialValue;
|
||||
// final int hospitalId;
|
||||
// final Function(int) onPick;
|
||||
//
|
||||
// const AutoCompleteDeviceField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _AutoCompleteDeviceFieldState createState() => _AutoCompleteDeviceFieldState();
|
||||
// }
|
||||
//
|
||||
// class _AutoCompleteDeviceFieldState extends State<AutoCompleteDeviceField> {
|
||||
// SettingProvider _settingProvider;
|
||||
// AssetProvider _devicesProvider;
|
||||
// UserProvider _userProvider;
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController(text: widget.initialValue.assetSerialNo);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _devicesProvider = Provider.of<AssetProvider>(context);
|
||||
//
|
||||
// return LoadingManager(
|
||||
// isLoading: _devicesProvider.isLoading,
|
||||
// isFailedLoading: _devicesProvider.devices == null,
|
||||
// stateCode: _devicesProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// _devicesProvider.reset();
|
||||
// await _devicesProvider.getAssets();
|
||||
// },
|
||||
// child: Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // border: Border.all(color: AColors.black),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [AppStyle.boxShadow]),
|
||||
// child: TypeAheadField<Asset>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: const InputDecoration(
|
||||
// border: InputBorder.none,
|
||||
// disabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// textInputAction: TextInputAction.search,
|
||||
// ),
|
||||
// suggestionsCallback: (value) async {
|
||||
// return await _devicesProvider.getDevicesList(
|
||||
// host: _settingProvider.host,
|
||||
// user: _userProvider.user,
|
||||
// hospitalId: widget.hospitalId ?? _userProvider.user.clientId,
|
||||
// // serialNumber: value,
|
||||
// );
|
||||
// },
|
||||
// itemBuilder: (context, device) {
|
||||
// return ListTile(
|
||||
// title: Text(device.assetSerialNo),
|
||||
// subtitle: Text("${device.modelDefinition.modelName}/${device.modelDefinition.manufacturerName}"),
|
||||
// );
|
||||
// },
|
||||
// onSuggestionSelected: (device) {
|
||||
// _controller.text = device.assetSerialNo;
|
||||
// widget.onPick(device.id);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,86 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AutoCompleteModelField extends StatefulWidget {
|
||||
final Lookup initialValue;
|
||||
final Function(Lookup) onPick;
|
||||
|
||||
const AutoCompleteModelField({
|
||||
Key key,
|
||||
this.initialValue,
|
||||
this.onPick,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AutoCompleteModelFieldState createState() => _AutoCompleteModelFieldState();
|
||||
}
|
||||
|
||||
class _AutoCompleteModelFieldState extends State<AutoCompleteModelField> {
|
||||
SettingProvider _settingProvider;
|
||||
AssetProvider _devicesProvider;
|
||||
UserProvider _userProvider;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue?.name);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_devicesProvider = Provider.of<AssetProvider>(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
// border: Border.all(color: AColors.black),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
boxShadow: [AppStyle.boxShadow]),
|
||||
child: TypeAheadField<Lookup>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "Model",
|
||||
border: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
),
|
||||
suggestionsCallback: (value) async {
|
||||
return await _devicesProvider.getModels(
|
||||
code: value,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, lookup) {
|
||||
return ListTile(
|
||||
title: Text(lookup.name),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (lookup) {
|
||||
_controller.text = lookup.name;
|
||||
widget.onPick(lookup);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AutoCompleteModelField extends StatefulWidget {
|
||||
// final Lookup initialValue;
|
||||
// final Function(Lookup) onPick;
|
||||
//
|
||||
// const AutoCompleteModelField({
|
||||
// Key key,
|
||||
// this.initialValue,
|
||||
// this.onPick,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _AutoCompleteModelFieldState createState() => _AutoCompleteModelFieldState();
|
||||
// }
|
||||
//
|
||||
// class _AutoCompleteModelFieldState extends State<AutoCompleteModelField> {
|
||||
// SettingProvider _settingProvider;
|
||||
// AssetProvider _devicesProvider;
|
||||
// UserProvider _userProvider;
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController(text: widget.initialValue?.name);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _devicesProvider = Provider.of<AssetProvider>(context);
|
||||
//
|
||||
// return Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // border: Border.all(color: AColors.black),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [AppStyle.boxShadow]),
|
||||
// child: TypeAheadField<Lookup>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: const InputDecoration(
|
||||
// hintText: "Model",
|
||||
// border: InputBorder.none,
|
||||
// disabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// textInputAction: TextInputAction.search,
|
||||
// ),
|
||||
// suggestionsCallback: (value) async {
|
||||
// return await _devicesProvider.getModels(
|
||||
// code: value,
|
||||
// );
|
||||
// },
|
||||
// itemBuilder: (context, lookup) {
|
||||
// return ListTile(
|
||||
// title: Text(lookup.name),
|
||||
// );
|
||||
// },
|
||||
// onSuggestionSelected: (lookup) {
|
||||
// _controller.text = lookup.name;
|
||||
// widget.onPick(lookup);
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,110 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../loaders/app_loading.dart';
|
||||
|
||||
class BuildingTypeMenu extends StatefulWidget {
|
||||
final Function(Buildings) onSelect;
|
||||
Buildings initialValue;
|
||||
List<Buildings> building;
|
||||
bool enabled, loading;
|
||||
|
||||
BuildingTypeMenu({
|
||||
Key key,
|
||||
this.onSelect,
|
||||
this.initialValue,
|
||||
this.building = const [],
|
||||
this.enabled = true,
|
||||
this.loading = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_BuildingTypeMenuState createState() {
|
||||
return _BuildingTypeMenuState();
|
||||
}
|
||||
}
|
||||
|
||||
class _BuildingTypeMenuState extends State<BuildingTypeMenu> {
|
||||
Buildings _selectedBuilding;
|
||||
List<Buildings> _building;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedBuilding = widget.initialValue;
|
||||
_building = widget.building;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant BuildingTypeMenu oldWidget) {
|
||||
if (oldWidget.building != widget.building) {
|
||||
_building = widget.building;
|
||||
_selectedBuilding = null;
|
||||
}
|
||||
if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
_selectedBuilding = widget.initialValue;
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 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: widget.loading
|
||||
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
: (widget.enabled && (_building?.isEmpty ?? false)) || (!widget.enabled)
|
||||
? ListTile(
|
||||
title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
)
|
||||
: DropdownButton<Buildings>(
|
||||
value: _selectedBuilding,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
elevation: 0,
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
"Select Building",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
underline: const SizedBox.shrink(),
|
||||
onChanged: (Buildings newValue) {
|
||||
setState(() {
|
||||
_selectedBuilding = newValue;
|
||||
});
|
||||
widget.onSelect(newValue);
|
||||
},
|
||||
items: _building?.map<DropdownMenuItem<Buildings>>((Buildings value) {
|
||||
return DropdownMenuItem<Buildings>(
|
||||
value: value,
|
||||
child: Text(
|
||||
value.name ?? "",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 11,
|
||||
//fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
);
|
||||
})?.toList() ??
|
||||
[],
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import '../loaders/app_loading.dart';
|
||||
//
|
||||
// class BuildingTypeMenu extends StatefulWidget {
|
||||
// final Function(Buildings) onSelect;
|
||||
// Buildings initialValue;
|
||||
// List<Buildings> building;
|
||||
// bool enabled, loading;
|
||||
//
|
||||
// BuildingTypeMenu({
|
||||
// Key key,
|
||||
// this.onSelect,
|
||||
// this.initialValue,
|
||||
// this.building = const [],
|
||||
// this.enabled = true,
|
||||
// this.loading = false,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _BuildingTypeMenuState createState() {
|
||||
// return _BuildingTypeMenuState();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class _BuildingTypeMenuState extends State<BuildingTypeMenu> {
|
||||
// Buildings _selectedBuilding;
|
||||
// List<Buildings> _building;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _selectedBuilding = widget.initialValue;
|
||||
// _building = widget.building;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant BuildingTypeMenu oldWidget) {
|
||||
// if (oldWidget.building != widget.building) {
|
||||
// _building = widget.building;
|
||||
// _selectedBuilding = null;
|
||||
// }
|
||||
// if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
// _selectedBuilding = widget.initialValue;
|
||||
// }
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 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: widget.loading
|
||||
// ? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
// : (widget.enabled && (_building?.isEmpty ?? false)) || (!widget.enabled)
|
||||
// ? ListTile(
|
||||
// title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
// )
|
||||
// : DropdownButton<Buildings>(
|
||||
// value: _selectedBuilding,
|
||||
// iconSize: 24,
|
||||
// icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
// elevation: 0,
|
||||
// isExpanded: true,
|
||||
// hint: Text(
|
||||
// "Select Building",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// ),
|
||||
// style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
// underline: const SizedBox.shrink(),
|
||||
// onChanged: (Buildings newValue) {
|
||||
// setState(() {
|
||||
// _selectedBuilding = newValue;
|
||||
// });
|
||||
// widget.onSelect(newValue);
|
||||
// },
|
||||
// items: _building?.map<DropdownMenuItem<Buildings>>((Buildings value) {
|
||||
// return DropdownMenuItem<Buildings>(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value.name ?? "",
|
||||
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// fontSize: 11,
|
||||
// //fontWeight: FontWeight.bold
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// })?.toList() ??
|
||||
// [],
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,111 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../loaders/app_loading.dart';
|
||||
|
||||
class DepartmentTypeMenu extends StatefulWidget {
|
||||
final Function(Departments) onSelect;
|
||||
Departments initialValue;
|
||||
List<Departments> departments;
|
||||
bool enabled, loading;
|
||||
|
||||
DepartmentTypeMenu({
|
||||
Key key,
|
||||
this.onSelect,
|
||||
this.initialValue,
|
||||
this.departments = const [],
|
||||
this.enabled = true,
|
||||
this.loading = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DepartmentTypeMenuState createState() {
|
||||
return _DepartmentTypeMenuState();
|
||||
}
|
||||
}
|
||||
|
||||
class _DepartmentTypeMenuState extends State<DepartmentTypeMenu> {
|
||||
Departments _selected;
|
||||
List<Departments> _departments;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selected = widget.initialValue;
|
||||
_departments = widget.departments;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant DepartmentTypeMenu oldWidget) {
|
||||
if (oldWidget.departments != widget.departments) {
|
||||
_departments = widget.departments;
|
||||
_selected = null;
|
||||
}
|
||||
if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
_selected = widget.initialValue;
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
// color: AColors.inputFieldBackgroundColor,
|
||||
border: Border.all(
|
||||
color: Color(0xffefefef),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: const [
|
||||
// AppStyle.boxShadow
|
||||
// ]
|
||||
),
|
||||
child: widget.loading
|
||||
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
: (widget.enabled && (_departments?.isEmpty ?? false)) || (!widget.enabled)
|
||||
? ListTile(
|
||||
title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
)
|
||||
: DropdownButton<Departments>(
|
||||
value: _selected,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
elevation: 0,
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
"Select Department",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
underline: SizedBox.shrink(),
|
||||
onChanged: (Departments newValue) {
|
||||
setState(() {
|
||||
_selected = newValue;
|
||||
});
|
||||
widget.onSelect(newValue);
|
||||
},
|
||||
items: widget?.departments?.map<DropdownMenuItem<Departments>>((Departments value) {
|
||||
return DropdownMenuItem<Departments>(
|
||||
value: value,
|
||||
child: Text(
|
||||
value?.name ?? "",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 11,
|
||||
//fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
);
|
||||
})?.toList() ??
|
||||
[],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import '../loaders/app_loading.dart';
|
||||
//
|
||||
// class DepartmentTypeMenu extends StatefulWidget {
|
||||
// final Function(Departments) onSelect;
|
||||
// Departments initialValue;
|
||||
// List<Departments> departments;
|
||||
// bool enabled, loading;
|
||||
//
|
||||
// DepartmentTypeMenu({
|
||||
// Key key,
|
||||
// this.onSelect,
|
||||
// this.initialValue,
|
||||
// this.departments = const [],
|
||||
// this.enabled = true,
|
||||
// this.loading = false,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _DepartmentTypeMenuState createState() {
|
||||
// return _DepartmentTypeMenuState();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class _DepartmentTypeMenuState extends State<DepartmentTypeMenu> {
|
||||
// Departments _selected;
|
||||
// List<Departments> _departments;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _selected = widget.initialValue;
|
||||
// _departments = widget.departments;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant DepartmentTypeMenu oldWidget) {
|
||||
// if (oldWidget.departments != widget.departments) {
|
||||
// _departments = widget.departments;
|
||||
// _selected = null;
|
||||
// }
|
||||
// if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
// _selected = widget.initialValue;
|
||||
// }
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// // color: AColors.inputFieldBackgroundColor,
|
||||
// border: Border.all(
|
||||
// color: Color(0xffefefef),
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// // boxShadow: const [
|
||||
// // AppStyle.boxShadow
|
||||
// // ]
|
||||
// ),
|
||||
// child: widget.loading
|
||||
// ? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
// : (widget.enabled && (_departments?.isEmpty ?? false)) || (!widget.enabled)
|
||||
// ? ListTile(
|
||||
// title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
// )
|
||||
// : DropdownButton<Departments>(
|
||||
// value: _selected,
|
||||
// iconSize: 24,
|
||||
// icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
// elevation: 0,
|
||||
// isExpanded: true,
|
||||
// hint: Text(
|
||||
// "Select Department",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// ),
|
||||
// style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
// underline: SizedBox.shrink(),
|
||||
// onChanged: (Departments newValue) {
|
||||
// setState(() {
|
||||
// _selected = newValue;
|
||||
// });
|
||||
// widget.onSelect(newValue);
|
||||
// },
|
||||
// items: widget?.departments?.map<DropdownMenuItem<Departments>>((Departments value) {
|
||||
// return DropdownMenuItem<Departments>(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value?.name ?? "",
|
||||
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// fontSize: 11,
|
||||
// //fontWeight: FontWeight.bold
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// })?.toList() ??
|
||||
// [],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,112 +1,113 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../loaders/app_loading.dart';
|
||||
|
||||
class FloorTypeMenu extends StatefulWidget {
|
||||
final Function(Floors) onSelect;
|
||||
Floors initialValue;
|
||||
List<Floors> floors;
|
||||
bool enabled;
|
||||
bool loading;
|
||||
|
||||
FloorTypeMenu({
|
||||
Key key,
|
||||
this.onSelect,
|
||||
this.initialValue,
|
||||
this.floors = const [],
|
||||
this.enabled = true,
|
||||
this.loading = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_FloorTypeMenuState createState() {
|
||||
return _FloorTypeMenuState();
|
||||
}
|
||||
}
|
||||
|
||||
class _FloorTypeMenuState extends State<FloorTypeMenu> {
|
||||
Floors _selected;
|
||||
List<Floors> _floors;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selected = widget.initialValue;
|
||||
_floors = widget.floors;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant FloorTypeMenu oldWidget) {
|
||||
if (oldWidget.floors != widget.floors) {
|
||||
_floors = widget.floors;
|
||||
_selected = null;
|
||||
}
|
||||
if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
_selected = widget.initialValue;
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 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: widget.loading
|
||||
? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
: (widget.enabled && (_floors?.isEmpty ?? false)) || (!widget.enabled)
|
||||
? ListTile(
|
||||
title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
)
|
||||
: DropdownButton<Floors>(
|
||||
value: _selected,
|
||||
iconSize: 24,
|
||||
icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
elevation: 0,
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
"Select Floor",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
underline: const SizedBox.shrink(),
|
||||
onChanged: (Floors newValue) {
|
||||
setState(() {
|
||||
_selected = newValue;
|
||||
});
|
||||
widget.onSelect(newValue);
|
||||
},
|
||||
items: _floors?.map<DropdownMenuItem<Floors>>((Floors value) {
|
||||
return DropdownMenuItem<Floors>(
|
||||
value: value,
|
||||
child: Text(
|
||||
value.name ?? "",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 11,
|
||||
//fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
);
|
||||
})?.toList() ??
|
||||
[],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import '../loaders/app_loading.dart';
|
||||
//
|
||||
// class FloorTypeMenu extends StatefulWidget {
|
||||
// final Function(Floors) onSelect;
|
||||
// Floors initialValue;
|
||||
// List<Floors> floors;
|
||||
// bool enabled;
|
||||
// bool loading;
|
||||
//
|
||||
// FloorTypeMenu({
|
||||
// Key key,
|
||||
// this.onSelect,
|
||||
// this.initialValue,
|
||||
// this.floors = const [],
|
||||
// this.enabled = true,
|
||||
// this.loading = false,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _FloorTypeMenuState createState() {
|
||||
// return _FloorTypeMenuState();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class _FloorTypeMenuState extends State<FloorTypeMenu> {
|
||||
// Floors _selected;
|
||||
// List<Floors> _floors;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _selected = widget.initialValue;
|
||||
// _floors = widget.floors;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant FloorTypeMenu oldWidget) {
|
||||
// if (oldWidget.floors != widget.floors) {
|
||||
// _floors = widget.floors;
|
||||
// _selected = null;
|
||||
// }
|
||||
// if (oldWidget.initialValue != widget.initialValue && widget.initialValue != null) {
|
||||
// _selected = widget.initialValue;
|
||||
// }
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 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: widget.loading
|
||||
// ? const Padding(padding: EdgeInsets.all(8.0), child: ALoading())
|
||||
// : (widget.enabled && (_floors?.isEmpty ?? false)) || (!widget.enabled)
|
||||
// ? ListTile(
|
||||
// title: Center(child: Text(widget.initialValue?.name ?? "")),
|
||||
// )
|
||||
// : DropdownButton<Floors>(
|
||||
// value: _selected,
|
||||
// iconSize: 24,
|
||||
// icon: const Icon(Icons.keyboard_arrow_down_rounded),
|
||||
// elevation: 0,
|
||||
// isExpanded: true,
|
||||
// hint: Text(
|
||||
// "Select Floor",
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// ),
|
||||
// style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
// underline: const SizedBox.shrink(),
|
||||
// onChanged: (Floors newValue) {
|
||||
// setState(() {
|
||||
// _selected = newValue;
|
||||
// });
|
||||
// widget.onSelect(newValue);
|
||||
// },
|
||||
// items: _floors?.map<DropdownMenuItem<Floors>>((Floors value) {
|
||||
// return DropdownMenuItem<Floors>(
|
||||
// value: value,
|
||||
// child: Text(
|
||||
// value.name ?? "",
|
||||
// style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// fontSize: 11,
|
||||
// //fontWeight: FontWeight.bold
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// })?.toList() ??
|
||||
// [],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,90 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
|
||||
import '../../../models/new_models/gas_refill_model.dart';
|
||||
import '../buttons/app_button.dart';
|
||||
import '../titles/app_sub_title.dart';
|
||||
|
||||
class GasRefillCreateDetailsItem extends StatefulWidget {
|
||||
final GasRefillDetails model;
|
||||
final VoidCallback onPressed;
|
||||
final bool isUpdate;
|
||||
|
||||
const GasRefillCreateDetailsItem({Key key, this.isUpdate, this.model, this.onPressed}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GasRefillCreateDetailsItem> createState() => _GasRefillCreateDetailsItemState();
|
||||
}
|
||||
|
||||
class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem> {
|
||||
GlobalKey<FormState> _formKey;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_formKey = GlobalKey<FormState>();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final startEditing = widget.isUpdate && (widget.model.selectedForEditing ?? false);
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: Text(widget.model.gasType.name)),
|
||||
IconButton(onPressed: widget.onPressed, /* color: widget.isUpdate ? AColors.cyan : AColors.red,*/ icon: Icon(widget.isUpdate ? Icons.edit : Icons.delete))
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text("Quantity: ${widget.model.requestedQty.toStringAsFixed(0)}"),
|
||||
Text("Cylinder Size: ${widget.model.cylinderSize.name}"),
|
||||
Text("Cylinder Type: ${widget.model.cylinderType.name}"),
|
||||
],
|
||||
),
|
||||
if (widget.model.deliverdQty != null)
|
||||
Row(
|
||||
children: [
|
||||
const Text("Delivered Quantity: "),
|
||||
Text(widget.model.deliverdQty.toStringAsFixed(0)),
|
||||
],
|
||||
),
|
||||
if (startEditing) const SizedBox(height: 16),
|
||||
if (startEditing) ASubTitle(context.translation.deliveredQuantity),
|
||||
if (startEditing) const SizedBox(height: 4),
|
||||
if (startEditing)
|
||||
ATextFormField(
|
||||
initialValue: widget.model.deliverdQty?.toString() ?? "0",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
if (value.isNotEmpty) {
|
||||
widget.model.deliverdQty = double.tryParse(value);
|
||||
} else {
|
||||
widget.model.deliverdQty = 0;
|
||||
}
|
||||
},
|
||||
),
|
||||
if (startEditing) const SizedBox(height: 8),
|
||||
if (startEditing)
|
||||
AButton(
|
||||
text: context.translation.edit,
|
||||
onPressed: () {
|
||||
_formKey.currentState?.save();
|
||||
widget.onPressed();
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
//
|
||||
// import '../../../models/new_models/gas_refill_model.dart';
|
||||
// import '../buttons/app_button.dart';
|
||||
// import '../titles/app_sub_title.dart';
|
||||
//
|
||||
// class GasRefillCreateDetailsItem extends StatefulWidget {
|
||||
// final GasRefillDetails model;
|
||||
// final VoidCallback onPressed;
|
||||
// final bool isUpdate;
|
||||
//
|
||||
// const GasRefillCreateDetailsItem({Key key, this.isUpdate, this.model, this.onPressed}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<GasRefillCreateDetailsItem> createState() => _GasRefillCreateDetailsItemState();
|
||||
// }
|
||||
//
|
||||
// class _GasRefillCreateDetailsItemState extends State<GasRefillCreateDetailsItem> {
|
||||
// GlobalKey<FormState> _formKey;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _formKey = GlobalKey<FormState>();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final startEditing = widget.isUpdate && (widget.model.selectedForEditing ?? false);
|
||||
// return Form(
|
||||
// key: _formKey,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(child: Text(widget.model.gasType.name)),
|
||||
// IconButton(onPressed: widget.onPressed, /* color: widget.isUpdate ? AColors.cyan : AColors.red,*/ icon: Icon(widget.isUpdate ? Icons.edit : Icons.delete))
|
||||
// ],
|
||||
// ),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// children: [
|
||||
// Text("Quantity: ${widget.model.requestedQty.toStringAsFixed(0)}"),
|
||||
// Text("Cylinder Size: ${widget.model.cylinderSize.name}"),
|
||||
// Text("Cylinder Type: ${widget.model.cylinderType.name}"),
|
||||
// ],
|
||||
// ),
|
||||
// if (widget.model.deliverdQty != null)
|
||||
// Row(
|
||||
// children: [
|
||||
// const Text("Delivered Quantity: "),
|
||||
// Text(widget.model.deliverdQty.toStringAsFixed(0)),
|
||||
// ],
|
||||
// ),
|
||||
// if (startEditing) const SizedBox(height: 16),
|
||||
// if (startEditing) ASubTitle(context.translation.deliveredQuantity),
|
||||
// if (startEditing) const SizedBox(height: 4),
|
||||
// if (startEditing)
|
||||
// ATextFormField(
|
||||
// initialValue: widget.model.deliverdQty?.toString() ?? "0",
|
||||
// textAlign: TextAlign.center,
|
||||
// style: Theme.of(context).textTheme.titleMedium,
|
||||
// // validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// if (value.isNotEmpty) {
|
||||
// widget.model.deliverdQty = double.tryParse(value);
|
||||
// } else {
|
||||
// widget.model.deliverdQty = 0;
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// if (startEditing) const SizedBox(height: 8),
|
||||
// if (startEditing)
|
||||
// AButton(
|
||||
// text: context.translation.edit,
|
||||
// onPressed: () {
|
||||
// _formKey.currentState?.save();
|
||||
// widget.onPressed();
|
||||
// },
|
||||
// ),
|
||||
// const Divider(),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,65 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/controllers/validator/validator.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
import 'package:test_sa/views/widgets/requests/info_row.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_title.dart';
|
||||
|
||||
import '../../../models/new_models/gas_refill_model.dart';
|
||||
|
||||
class GasRefillUpdateDetailsItem extends StatelessWidget {
|
||||
final GasRefillDetails details;
|
||||
final bool enableEdit;
|
||||
final bool validate;
|
||||
|
||||
const GasRefillUpdateDetailsItem({Key key, this.details, this.enableEdit, this.validate}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ATitle(details.gasType.name),
|
||||
RequestInfoRow(
|
||||
title: "Cylinder Size",
|
||||
info: details.cylinderSize.name,
|
||||
),
|
||||
RequestInfoRow(
|
||||
title: "Requested Quantity",
|
||||
info: details.deliverdQty?.toStringAsFixed(0) ?? "",
|
||||
),
|
||||
enableEdit
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ASubTitle(context.translation.quantity),
|
||||
if (validate && details.deliverdQty == null)
|
||||
ASubTitle(
|
||||
context.translation.requiredWord,
|
||||
color: Colors.red,
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: (details.deliverdQty ?? "").toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
||||
textInputType: TextInputType.number,
|
||||
onSaved: (value) {
|
||||
details.deliverdQty = double.tryParse(value);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: RequestInfoRow(
|
||||
title: "Delivered Quantity",
|
||||
info: details.deliverdQty?.toStringAsFixed(0),
|
||||
),
|
||||
//SizedBox(height: 16,)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/controllers/validator/validator.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
||||
// import 'package:test_sa/views/widgets/requests/info_row.dart';
|
||||
// import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
// import 'package:test_sa/views/widgets/titles/app_title.dart';
|
||||
//
|
||||
// import '../../../models/new_models/gas_refill_model.dart';
|
||||
//
|
||||
// class GasRefillUpdateDetailsItem extends StatelessWidget {
|
||||
// final GasRefillDetails details;
|
||||
// final bool enableEdit;
|
||||
// final bool validate;
|
||||
//
|
||||
// const GasRefillUpdateDetailsItem({Key key, this.details, this.enableEdit, this.validate}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// ATitle(details.gasType.name),
|
||||
// RequestInfoRow(
|
||||
// title: "Cylinder Size",
|
||||
// info: details.cylinderSize.name,
|
||||
// ),
|
||||
// RequestInfoRow(
|
||||
// title: "Requested Quantity",
|
||||
// info: details.deliverdQty?.toStringAsFixed(0) ?? "",
|
||||
// ),
|
||||
// enableEdit
|
||||
// ? Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// ASubTitle(context.translation.quantity),
|
||||
// if (validate && details.deliverdQty == null)
|
||||
// ASubTitle(
|
||||
// context.translation.requiredWord,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 4,
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: (details.deliverdQty ?? "").toString(),
|
||||
// textAlign: TextAlign.center,
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
||||
// textInputType: TextInputType.number,
|
||||
// onSaved: (value) {
|
||||
// details.deliverdQty = double.tryParse(value);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// )
|
||||
// : RequestInfoRow(
|
||||
// title: "Delivered Quantity",
|
||||
// info: details.deliverdQty?.toStringAsFixed(0),
|
||||
// ),
|
||||
// //SizedBox(height: 16,)
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,95 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
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({
|
||||
Key key,
|
||||
this.onSearch,
|
||||
this.initialValue,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HospitalAutoCompleteFieldState createState() => _HospitalAutoCompleteFieldState();
|
||||
}
|
||||
|
||||
class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
|
||||
SettingProvider _settingProvider;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant HospitalAutoCompleteField oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
if (oldWidget.initialValue != widget.initialValue) {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
// color: AColors.inputFieldBackgroundColor,
|
||||
border: Border.all(
|
||||
color: Color(0xffefefef),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [
|
||||
// AppStyle.boxShadow
|
||||
// ]
|
||||
),
|
||||
child: TypeAheadField<Hospital>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.translation.hospital,
|
||||
border: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
),
|
||||
suggestionsCallback: (vale) async {
|
||||
return await HospitalsProvider().getHospitalsList(host: _settingProvider.host, title: vale);
|
||||
},
|
||||
itemBuilder: (context, hospital) {
|
||||
return ListTile(
|
||||
title: Text(hospital.name),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (hospital) {
|
||||
widget.onSearch(hospital);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// 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({
|
||||
// Key key,
|
||||
// this.onSearch,
|
||||
// this.initialValue,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _HospitalAutoCompleteFieldState createState() => _HospitalAutoCompleteFieldState();
|
||||
// }
|
||||
//
|
||||
// class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
|
||||
// SettingProvider _settingProvider;
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController(text: widget.initialValue);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant HospitalAutoCompleteField oldWidget) {
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
//
|
||||
// if (oldWidget.initialValue != widget.initialValue) {
|
||||
// _controller = TextEditingController(text: widget.initialValue);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
//
|
||||
// return Container(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// // color: AColors.inputFieldBackgroundColor,
|
||||
// border: Border.all(
|
||||
// color: Color(0xffefefef),
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// // boxShadow: [
|
||||
// // AppStyle.boxShadow
|
||||
// // ]
|
||||
// ),
|
||||
// child: TypeAheadField<Hospital>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: InputDecoration(
|
||||
// hintText: context.translation.hospital,
|
||||
// border: InputBorder.none,
|
||||
// disabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// textInputAction: TextInputAction.search,
|
||||
// ),
|
||||
// suggestionsCallback: (vale) async {
|
||||
// return await HospitalsProvider().getHospitalsList(host: _settingProvider.host, title: vale);
|
||||
// },
|
||||
// itemBuilder: (context, hospital) {
|
||||
// return ListTile(
|
||||
// title: Text(hospital.name),
|
||||
// );
|
||||
// },
|
||||
// onSuggestionSelected: (hospital) {
|
||||
// widget.onSearch(hospital);
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,107 +1,108 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/hospital.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;
|
||||
|
||||
const HospitalAutoCompleteField({
|
||||
Key key,
|
||||
this.onSearch,
|
||||
this.initialValue,
|
||||
this.enabled = true,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HospitalAutoCompleteFieldState createState() => _HospitalAutoCompleteFieldState();
|
||||
}
|
||||
|
||||
class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
|
||||
SettingProvider _settingProvider;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant HospitalAutoCompleteField oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
if (oldWidget.initialValue != widget.initialValue) {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
// color: AColors.inputFieldBackgroundColor,
|
||||
border: Border.all(
|
||||
color: Color(0xffefefef),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [
|
||||
// AppStyle.boxShadow
|
||||
// ]
|
||||
),
|
||||
child: widget.enabled
|
||||
? TypeAheadField<Hospital>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(
|
||||
hintText: context.translation.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)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/hospitals_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/hospital.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;
|
||||
//
|
||||
// const HospitalAutoCompleteField({
|
||||
// Key key,
|
||||
// this.onSearch,
|
||||
// this.initialValue,
|
||||
// this.enabled = true,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _HospitalAutoCompleteFieldState createState() => _HospitalAutoCompleteFieldState();
|
||||
// }
|
||||
//
|
||||
// class _HospitalAutoCompleteFieldState extends State<HospitalAutoCompleteField> {
|
||||
// SettingProvider _settingProvider;
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController(text: widget.initialValue);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant HospitalAutoCompleteField oldWidget) {
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
//
|
||||
// if (oldWidget.initialValue != widget.initialValue) {
|
||||
// _controller = TextEditingController(text: widget.initialValue);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
//
|
||||
// return Container(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// // color: AColors.inputFieldBackgroundColor,
|
||||
// border: Border.all(
|
||||
// color: Color(0xffefefef),
|
||||
// ),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// // boxShadow: [
|
||||
// // AppStyle.boxShadow
|
||||
// // ]
|
||||
// ),
|
||||
// child: widget.enabled
|
||||
// ? TypeAheadField<Hospital>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: InputDecoration(
|
||||
// hintText: context.translation.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)),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,48 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/hospital.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/hospitals/single_hospital_picker.dart';
|
||||
|
||||
class HospitalButton extends StatelessWidget {
|
||||
final Function(Hospital) onHospitalPick;
|
||||
final Hospital hospital;
|
||||
|
||||
const HospitalButton({Key key, this.hospital, this.onHospitalPick}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
// foregroundColor: AColors.primaryColor,
|
||||
// backgroundColor: AColors.inputFieldBackgroundColor,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(
|
||||
hospital?.name ?? context.translation.pickHospital,
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 14, color: AColors.grey3A),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
size: 28, /*color: AColors.grey3A*/
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
Hospital _hospital = await Navigator.of(context).pushNamed(SingleHospitalPicker.id) as Hospital;
|
||||
onHospitalPick(_hospital);
|
||||
});
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/hospital.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/hospitals/single_hospital_picker.dart';
|
||||
//
|
||||
// class HospitalButton extends StatelessWidget {
|
||||
// final Function(Hospital) onHospitalPick;
|
||||
// final Hospital hospital;
|
||||
//
|
||||
// const HospitalButton({Key key, this.hospital, this.onHospitalPick}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// elevation: 0,
|
||||
// // foregroundColor: AColors.primaryColor,
|
||||
// // backgroundColor: AColors.inputFieldBackgroundColor,
|
||||
// padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
// ),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
// child: Text(
|
||||
// hospital?.name ?? context.translation.pickHospital,
|
||||
// // style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 14, color: AColors.grey3A),
|
||||
// // textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// textDirection: TextDirection.rtl,
|
||||
// textAlign: TextAlign.left,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const Icon(
|
||||
// Icons.keyboard_arrow_down,
|
||||
// size: 28, /*color: AColors.grey3A*/
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// onPressed: () async {
|
||||
// Hospital _hospital = await Navigator.of(context).pushNamed(SingleHospitalPicker.id) as Hospital;
|
||||
// onHospitalPick(_hospital);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,32 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import 'image_item.dart';
|
||||
import 'images_viewer.dart';
|
||||
|
||||
class ImagesList extends StatelessWidget {
|
||||
final List<String> images;
|
||||
final EdgeInsets padding;
|
||||
|
||||
const ImagesList({Key key, this.images, this.padding}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
padding: padding ?? EdgeInsets.symmetric(horizontal: 32 * AppStyle.getScaleFactor(context)),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: images.length,
|
||||
itemBuilder: (context, itemIndex) {
|
||||
return ImageItem(
|
||||
url: images[itemIndex],
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (_) => ImagesViewer(
|
||||
initialIndex: itemIndex,
|
||||
images: images,
|
||||
)));
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import 'image_item.dart';
|
||||
// import 'images_viewer.dart';
|
||||
//
|
||||
// class ImagesList extends StatelessWidget {
|
||||
// final List<String> images;
|
||||
// final EdgeInsets padding;
|
||||
//
|
||||
// const ImagesList({Key key, this.images, this.padding}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return ListView.builder(
|
||||
// padding: padding ?? EdgeInsets.symmetric(horizontal: 32 * AppStyle.getScaleFactor(context)),
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// itemCount: images.length,
|
||||
// itemBuilder: (context, itemIndex) {
|
||||
// return ImageItem(
|
||||
// url: images[itemIndex],
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).push(MaterialPageRoute(
|
||||
// builder: (_) => ImagesViewer(
|
||||
// initialIndex: itemIndex,
|
||||
// images: images,
|
||||
// )));
|
||||
// },
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,86 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
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,
|
||||
this.initialIndex = 0,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: DefaultTabController(
|
||||
length: images.length,
|
||||
initialIndex: initialIndex,
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
images.length == 1
|
||||
? SizedBox.shrink()
|
||||
: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
TabBar(
|
||||
isScrollable: images.length * 84 > MediaQuery.of(context).size.width,
|
||||
indicator: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(24 * AppStyle.getScaleFactor(context)),
|
||||
bottomLeft: Radius.circular(24 * AppStyle.getScaleFactor(context)),
|
||||
),
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: images
|
||||
.map((imagePath) => InteractiveViewer(
|
||||
child: Container(
|
||||
height: 60,
|
||||
width: 80,
|
||||
padding: EdgeInsets.all(
|
||||
AppStyle.getScaleFactor(context),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(22 * AppStyle.getScaleFactor(context)),
|
||||
bottomLeft: Radius.circular(22 * AppStyle.getScaleFactor(context)),
|
||||
),
|
||||
child: ImageLoader(
|
||||
url: imagePath,
|
||||
boxFit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
children: images
|
||||
.map((imagePath) => InteractiveViewer(
|
||||
child: ImageLoader(
|
||||
url: imagePath,
|
||||
boxFit: BoxFit.contain,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// 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,
|
||||
// this.initialIndex = 0,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// body: DefaultTabController(
|
||||
// length: images.length,
|
||||
// initialIndex: initialIndex,
|
||||
// child: SafeArea(
|
||||
// child: Column(
|
||||
// children: [
|
||||
// images.length == 1
|
||||
// ? SizedBox.shrink()
|
||||
// : Column(
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// height: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// TabBar(
|
||||
// isScrollable: images.length * 84 > MediaQuery.of(context).size.width,
|
||||
// indicator: BoxDecoration(
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// borderRadius: BorderRadius.only(
|
||||
// topRight: Radius.circular(24 * AppStyle.getScaleFactor(context)),
|
||||
// bottomLeft: Radius.circular(24 * AppStyle.getScaleFactor(context)),
|
||||
// ),
|
||||
// ),
|
||||
// indicatorSize: TabBarIndicatorSize.label,
|
||||
// tabs: images
|
||||
// .map((imagePath) => InteractiveViewer(
|
||||
// child: Container(
|
||||
// height: 60,
|
||||
// width: 80,
|
||||
// padding: EdgeInsets.all(
|
||||
// AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// child: ClipRRect(
|
||||
// borderRadius: BorderRadius.only(
|
||||
// topRight: Radius.circular(22 * AppStyle.getScaleFactor(context)),
|
||||
// bottomLeft: Radius.circular(22 * AppStyle.getScaleFactor(context)),
|
||||
// ),
|
||||
// child: ImageLoader(
|
||||
// url: imagePath,
|
||||
// boxFit: BoxFit.cover,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ))
|
||||
// .toList(),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// Expanded(
|
||||
// child: TabBarView(
|
||||
// children: images
|
||||
// .map((imagePath) => InteractiveViewer(
|
||||
// child: ImageLoader(
|
||||
// url: imagePath,
|
||||
// boxFit: BoxFit.contain,
|
||||
// ),
|
||||
// ))
|
||||
// .toList(),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,143 +1,144 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AMiniOneFilePicker extends StatefulWidget {
|
||||
final Function(File) onPick;
|
||||
final File file;
|
||||
final String label;
|
||||
final bool error;
|
||||
|
||||
const AMiniOneFilePicker({Key key, this.label, this.error, this.file, this.onPick}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AMiniOneFilePickerState createState() => _AMiniOneFilePickerState();
|
||||
}
|
||||
|
||||
class _AMiniOneFilePickerState extends State<AMiniOneFilePicker> {
|
||||
File _file;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_file = widget.file;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: widget.label != null,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 8 * AppStyle.getScaleFactor(context)),
|
||||
Text(
|
||||
widget.label ?? '',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: _file == null && widget.error == true,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
context.translation.requiredFile,
|
||||
style: Theme.of(context).textTheme.titleLarge.copyWith(color: Colors.red),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
//primary: Colors.grey[200],
|
||||
textStyle: Theme.of(context).textTheme.labelSmall,
|
||||
padding: _file == null ? null : EdgeInsets.zero,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
_file == null ? context.translation.pickFile : _file.path.split("/").last,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
onFilePicker(context.translation);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fromFilePicker(AppLocalizations subtitle) async {
|
||||
FilePickerResult result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx'],
|
||||
);
|
||||
if (result != null) {
|
||||
for (var path in result.paths) {
|
||||
_file = File(path);
|
||||
widget.onPick(_file);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
onFilePicker(AppLocalizations subtitle) async {
|
||||
ImageSource source = await showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => CupertinoAlertDialog(
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(subtitle.pickFromCamera),
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop(ImageSource.camera);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(subtitle.pickFromGallery),
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop(ImageSource.gallery);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(subtitle.pickFromFiles),
|
||||
onPressed: () async {
|
||||
await fromFilePicker(subtitle);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (source == null) return;
|
||||
|
||||
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
||||
|
||||
if (pickedFile != null) {
|
||||
File fileImage = File(pickedFile.path);
|
||||
if (fileImage != null) {
|
||||
_file = File(pickedFile.path);
|
||||
widget.onPick(_file);
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:io';
|
||||
//
|
||||
// import 'package:file_picker/file_picker.dart';
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
// import 'package:image_picker/image_picker.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AMiniOneFilePicker extends StatefulWidget {
|
||||
// final Function(File) onPick;
|
||||
// final File file;
|
||||
// final String label;
|
||||
// final bool error;
|
||||
//
|
||||
// const AMiniOneFilePicker({Key key, this.label, this.error, this.file, this.onPick}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _AMiniOneFilePickerState createState() => _AMiniOneFilePickerState();
|
||||
// }
|
||||
//
|
||||
// class _AMiniOneFilePickerState extends State<AMiniOneFilePicker> {
|
||||
// File _file;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _file = widget.file;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Visibility(
|
||||
// visible: widget.label != null,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// SizedBox(height: 8 * AppStyle.getScaleFactor(context)),
|
||||
// Text(
|
||||
// widget.label ?? '',
|
||||
// style: Theme.of(context).textTheme.titleLarge,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: _file == null && widget.error == true,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// const SizedBox(height: 4),
|
||||
// Text(
|
||||
// context.translation.requiredFile,
|
||||
// style: Theme.of(context).textTheme.titleLarge.copyWith(color: Colors.red),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// SizedBox(
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
// //primary: Colors.grey[200],
|
||||
// textStyle: Theme.of(context).textTheme.labelSmall,
|
||||
// padding: _file == null ? null : EdgeInsets.zero,
|
||||
// ),
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// _file == null ? context.translation.pickFile : _file.path.split("/").last,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// onPressed: () async {
|
||||
// onFilePicker(context.translation);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// fromFilePicker(AppLocalizations subtitle) async {
|
||||
// FilePickerResult result = await FilePicker.platform.pickFiles(
|
||||
// type: FileType.custom,
|
||||
// allowedExtensions: ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx'],
|
||||
// );
|
||||
// if (result != null) {
|
||||
// for (var path in result.paths) {
|
||||
// _file = File(path);
|
||||
// widget.onPick(_file);
|
||||
// }
|
||||
// setState(() {});
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// onFilePicker(AppLocalizations subtitle) async {
|
||||
// ImageSource source = await showDialog(
|
||||
// context: context,
|
||||
// builder: (dialogContext) => CupertinoAlertDialog(
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: Text(subtitle.pickFromCamera),
|
||||
// onPressed: () {
|
||||
// Navigator.of(dialogContext).pop(ImageSource.camera);
|
||||
// },
|
||||
// ),
|
||||
// TextButton(
|
||||
// child: Text(subtitle.pickFromGallery),
|
||||
// onPressed: () {
|
||||
// Navigator.of(dialogContext).pop(ImageSource.gallery);
|
||||
// },
|
||||
// ),
|
||||
// TextButton(
|
||||
// child: Text(subtitle.pickFromFiles),
|
||||
// onPressed: () async {
|
||||
// await fromFilePicker(subtitle);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// if (source == null) return;
|
||||
//
|
||||
// final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 800, maxHeight: 800);
|
||||
//
|
||||
// if (pickedFile != null) {
|
||||
// File fileImage = File(pickedFile.path);
|
||||
// if (fileImage != null) {
|
||||
// _file = File(pickedFile.path);
|
||||
// widget.onPick(_file);
|
||||
// }
|
||||
// }
|
||||
// setState(() {});
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,127 +1,128 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class AOneImagePicker extends StatefulWidget {
|
||||
final Function(File) onPick;
|
||||
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
|
||||
_AOneImagePickerState createState() => _AOneImagePickerState();
|
||||
}
|
||||
|
||||
class _AOneImagePickerState extends State<AOneImagePicker> {
|
||||
File _image;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_image = widget.image;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: widget.label != null,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
Text(
|
||||
widget.label ?? '',
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: _image == null && widget.error == true,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
context.translation.requiredImage,
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(color: Colors.red),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height / 8,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
primary: Colors.grey[200],
|
||||
padding: _image == null ? null : EdgeInsets.zero,
|
||||
),
|
||||
child: _image == null
|
||||
? Text(
|
||||
context.translation.pickImage,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
)
|
||||
: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
child: Image(
|
||||
height: MediaQuery.of(context).size.height / 6,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
image: FileImage(_image),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
ImageSource source = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => CupertinoAlertDialog(
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("pick from camera"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(ImageSource.camera);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text("pick from gallery"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(ImageSource.gallery);
|
||||
},
|
||||
),
|
||||
],
|
||||
));
|
||||
if (source == null) return;
|
||||
|
||||
final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 1000, maxHeight: 1000);
|
||||
|
||||
setState(() {
|
||||
if (pickedFile != null) {
|
||||
_image = File(pickedFile.path);
|
||||
widget.onPick(_image);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'dart:io';
|
||||
//
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:image_picker/image_picker.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class AOneImagePicker extends StatefulWidget {
|
||||
// final Function(File) onPick;
|
||||
// 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
|
||||
// _AOneImagePickerState createState() => _AOneImagePickerState();
|
||||
// }
|
||||
//
|
||||
// class _AOneImagePickerState extends State<AOneImagePicker> {
|
||||
// File _image;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _image = widget.image;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Visibility(
|
||||
// visible: widget.label != null,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// height: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Text(
|
||||
// widget.label ?? '',
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: _image == null && widget.error == true,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// height: 4,
|
||||
// ),
|
||||
// Text(
|
||||
// context.translation.requiredImage,
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(color: Colors.red),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8,
|
||||
// ),
|
||||
// Container(
|
||||
// height: MediaQuery.of(context).size.height / 8,
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context))),
|
||||
// primary: Colors.grey[200],
|
||||
// padding: _image == null ? null : EdgeInsets.zero,
|
||||
// ),
|
||||
// child: _image == null
|
||||
// ? Text(
|
||||
// context.translation.pickImage,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// )
|
||||
// : ClipRRect(
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// child: Image(
|
||||
// height: MediaQuery.of(context).size.height / 6,
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// image: FileImage(_image),
|
||||
// fit: BoxFit.cover,
|
||||
// ),
|
||||
// ),
|
||||
// onPressed: () async {
|
||||
// ImageSource source = await showDialog(
|
||||
// context: context,
|
||||
// builder: (_) => CupertinoAlertDialog(
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: Text("pick from camera"),
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop(ImageSource.camera);
|
||||
// },
|
||||
// ),
|
||||
// TextButton(
|
||||
// child: Text("pick from gallery"),
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop(ImageSource.gallery);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ));
|
||||
// if (source == null) return;
|
||||
//
|
||||
// final pickedFile = await ImagePicker().pickImage(source: source, imageQuality: 70, maxWidth: 1000, maxHeight: 1000);
|
||||
//
|
||||
// setState(() {
|
||||
// if (pickedFile != null) {
|
||||
// _image = File(pickedFile.path);
|
||||
// widget.onPick(_image);
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,140 +1,141 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
|
||||
class InputWidget extends StatefulWidget {
|
||||
final String labelText;
|
||||
final String hintText;
|
||||
final TextEditingController controller;
|
||||
final VoidCallback suffixTap;
|
||||
final bool isEnable;
|
||||
final bool hasSelection;
|
||||
final int lines;
|
||||
final bool isInputTypeNum;
|
||||
final bool isTextIsPassword;
|
||||
final bool isBackgroundEnable;
|
||||
final bool isEnableBorder;
|
||||
final double verticalPadding;
|
||||
final double horizontalPadding;
|
||||
final Function(String) onChange;
|
||||
final Function(String) validator;
|
||||
|
||||
InputWidget(
|
||||
this.labelText,
|
||||
this.hintText,
|
||||
this.controller, {
|
||||
Key key,
|
||||
this.isTextIsPassword = false,
|
||||
this.suffixTap,
|
||||
this.validator,
|
||||
this.isEnable = true,
|
||||
this.hasSelection = false,
|
||||
this.isEnableBorder = false,
|
||||
this.lines = 1,
|
||||
this.onChange,
|
||||
this.isInputTypeNum = false,
|
||||
this.isBackgroundEnable = false,
|
||||
this.verticalPadding = 10,
|
||||
this.horizontalPadding = 16,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_InputWidgetState createState() {
|
||||
return _InputWidgetState();
|
||||
}
|
||||
}
|
||||
|
||||
class _InputWidgetState extends State<InputWidget> {
|
||||
bool isObscureText;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
isObscureText = widget.isTextIsPassword;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 56,
|
||||
padding: EdgeInsets.only(left: widget.horizontalPadding, right: widget.horizontalPadding, bottom: widget.verticalPadding, top: widget.verticalPadding),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: widget.isBackgroundEnable ? Color(0xffF7F7F7) : Colors.white,
|
||||
border: Border.all(
|
||||
color: widget.isEnableBorder ? Color(0xffefefef) : Colors.transparent,
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
blurRadius: 10.0,
|
||||
spreadRadius: 0.0,
|
||||
offset: Offset(0, 0),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: widget.hasSelection ? () {} : null,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.labelText,
|
||||
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
||||
),
|
||||
TextFormField(
|
||||
enabled: widget.isEnable,
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
keyboardType: widget.isInputTypeNum ? TextInputType.number : TextInputType.text,
|
||||
controller: widget.controller,
|
||||
maxLines: widget.lines,
|
||||
validator: widget.validator,
|
||||
obscuringCharacter: "*",
|
||||
obscureText: isObscureText,
|
||||
onChanged: widget.onChange,
|
||||
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.primary50 : AppColor.neutral50),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: widget.hintText,
|
||||
// hintStyle: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.primary50 : AppColor.neutral50),
|
||||
hintStyle: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20.withOpacity(.4)),
|
||||
//suffixIconConstraints: const BoxConstraints(minWidth: 50),
|
||||
// suffixIcon: widget.suffixTap == null ? null : IconButton(icon: const Icon(Icons.mic, color: MyColors.darkTextColor), onPressed: widget.suffixTap),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (widget.isTextIsPassword) ...[
|
||||
16.width,
|
||||
Icon(isObscureText ? Icons.visibility_rounded : Icons.visibility_off_rounded).onPress(() {
|
||||
setState(() {
|
||||
isObscureText = !isObscureText;
|
||||
});
|
||||
})
|
||||
],
|
||||
if (widget.hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/extensions/text_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
//
|
||||
// class InputWidget extends StatefulWidget {
|
||||
// final String labelText;
|
||||
// final String hintText;
|
||||
// final TextEditingController controller;
|
||||
// final VoidCallback suffixTap;
|
||||
// final bool isEnable;
|
||||
// final bool hasSelection;
|
||||
// final int lines;
|
||||
// final bool isInputTypeNum;
|
||||
// final bool isTextIsPassword;
|
||||
// final bool isBackgroundEnable;
|
||||
// final bool isEnableBorder;
|
||||
// final double verticalPadding;
|
||||
// final double horizontalPadding;
|
||||
// final Function(String) onChange;
|
||||
// final Function(String) validator;
|
||||
//
|
||||
// InputWidget(
|
||||
// this.labelText,
|
||||
// this.hintText,
|
||||
// this.controller, {
|
||||
// Key key,
|
||||
// this.isTextIsPassword = false,
|
||||
// this.suffixTap,
|
||||
// this.validator,
|
||||
// this.isEnable = true,
|
||||
// this.hasSelection = false,
|
||||
// this.isEnableBorder = false,
|
||||
// this.lines = 1,
|
||||
// this.onChange,
|
||||
// this.isInputTypeNum = false,
|
||||
// this.isBackgroundEnable = false,
|
||||
// this.verticalPadding = 10,
|
||||
// this.horizontalPadding = 16,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _InputWidgetState createState() {
|
||||
// return _InputWidgetState();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class _InputWidgetState extends State<InputWidget> {
|
||||
// bool isObscureText;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// isObscureText = widget.isTextIsPassword;
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// height: 56,
|
||||
// padding: EdgeInsets.only(left: widget.horizontalPadding, right: widget.horizontalPadding, bottom: widget.verticalPadding, top: widget.verticalPadding),
|
||||
// alignment: Alignment.center,
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// color: widget.isBackgroundEnable ? Color(0xffF7F7F7) : Colors.white,
|
||||
// border: Border.all(
|
||||
// color: widget.isEnableBorder ? Color(0xffefefef) : Colors.transparent,
|
||||
// width: 1,
|
||||
// ),
|
||||
// boxShadow: const [
|
||||
// BoxShadow(
|
||||
// color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
// blurRadius: 10.0,
|
||||
// spreadRadius: 0.0,
|
||||
// offset: Offset(0, 0),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: InkWell(
|
||||
// onTap: widget.hasSelection ? () {} : null,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// widget.labelText,
|
||||
// style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20),
|
||||
// ),
|
||||
// TextFormField(
|
||||
// enabled: widget.isEnable,
|
||||
// scrollPadding: EdgeInsets.zero,
|
||||
// keyboardType: widget.isInputTypeNum ? TextInputType.number : TextInputType.text,
|
||||
// controller: widget.controller,
|
||||
// maxLines: widget.lines,
|
||||
// validator: widget.validator,
|
||||
// obscuringCharacter: "*",
|
||||
// obscureText: isObscureText,
|
||||
// onChanged: widget.onChange,
|
||||
// style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.primary50 : AppColor.neutral50),
|
||||
// decoration: InputDecoration(
|
||||
// isDense: true,
|
||||
// hintText: widget.hintText,
|
||||
// // hintStyle: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.primary50 : AppColor.neutral50),
|
||||
// hintStyle: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20.withOpacity(.4)),
|
||||
// //suffixIconConstraints: const BoxConstraints(minWidth: 50),
|
||||
// // suffixIcon: widget.suffixTap == null ? null : IconButton(icon: const Icon(Icons.mic, color: MyColors.darkTextColor), onPressed: widget.suffixTap),
|
||||
// contentPadding: EdgeInsets.zero,
|
||||
// border: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// if (widget.isTextIsPassword) ...[
|
||||
// 16.width,
|
||||
// Icon(isObscureText ? Icons.visibility_rounded : Icons.visibility_off_rounded).onPress(() {
|
||||
// setState(() {
|
||||
// isObscureText = !isObscureText;
|
||||
// });
|
||||
// })
|
||||
// ],
|
||||
// if (widget.hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,46 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../../../new_views/app_style/app_color.dart';
|
||||
|
||||
class LandPageItem extends StatelessWidget {
|
||||
final String text;
|
||||
final IconData icon;
|
||||
final VoidCallback onPressed;
|
||||
final String svgPath;
|
||||
|
||||
const LandPageItem({Key key, this.svgPath, this.text, this.icon, this.onPressed}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onPressed,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
if (icon != null)
|
||||
Icon(
|
||||
icon,
|
||||
// color: AColors.primaryColor,
|
||||
size: 42 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
if (svgPath != null)
|
||||
SvgPicture.asset(
|
||||
svgPath,
|
||||
width: 42 * AppStyle.getScaleFactor(context),
|
||||
height: 42 * AppStyle.getScaleFactor(context),
|
||||
// color: AColors.primaryColor,
|
||||
),
|
||||
Text(text,
|
||||
style: TextStyle(
|
||||
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
||||
)),
|
||||
],
|
||||
).toShadowContainer(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_svg/svg.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// import '../../../new_views/app_style/app_color.dart';
|
||||
//
|
||||
// class LandPageItem extends StatelessWidget {
|
||||
// final String text;
|
||||
// final IconData icon;
|
||||
// final VoidCallback onPressed;
|
||||
// final String svgPath;
|
||||
//
|
||||
// const LandPageItem({Key key, this.svgPath, this.text, this.icon, this.onPressed}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return InkWell(
|
||||
// onTap: onPressed,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: <Widget>[
|
||||
// if (icon != null)
|
||||
// Icon(
|
||||
// icon,
|
||||
// // color: AColors.primaryColor,
|
||||
// size: 42 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// if (svgPath != null)
|
||||
// SvgPicture.asset(
|
||||
// svgPath,
|
||||
// width: 42 * AppStyle.getScaleFactor(context),
|
||||
// height: 42 * AppStyle.getScaleFactor(context),
|
||||
// // color: AColors.primaryColor,
|
||||
// ),
|
||||
// Text(text,
|
||||
// style: TextStyle(
|
||||
// color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
||||
// )),
|
||||
// ],
|
||||
// ).toShadowContainer(context),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,105 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
|
||||
|
||||
import '../../../models/service_request/spare_parts.dart';
|
||||
|
||||
class PartItem extends StatefulWidget {
|
||||
final SparePartsWorkOrders part;
|
||||
final Function(SparePartsWorkOrders) onDelete;
|
||||
final Function(int qty) onEdit;
|
||||
|
||||
const PartItem({Key key, this.part, this.onEdit, this.onDelete}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PartItemState createState() => _PartItemState();
|
||||
}
|
||||
|
||||
class _PartItemState extends State<PartItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
const Divider(),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget?.part?.sparePart?.partNo ?? "",
|
||||
style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
AIconButton2(
|
||||
iconData: Icons.add,
|
||||
color: Theme.of(context).primaryColor,
|
||||
onPressed: () {
|
||||
if (widget.onEdit == null) {
|
||||
++widget.part.qty;
|
||||
} else {
|
||||
widget.onEdit(++widget.part.qty);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
AIconButton2(
|
||||
iconData: Icons.remove,
|
||||
color: Theme.of(context).primaryColor,
|
||||
onPressed: widget.part.qty < 2
|
||||
? null
|
||||
: () {
|
||||
if (widget.onEdit == null) {
|
||||
--widget.part.qty;
|
||||
} else {
|
||||
widget.onEdit(--widget.part.qty);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
Text(
|
||||
widget.part.qty.toString(),
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
//fontSize: 12,
|
||||
//fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 8 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
widget.part?.sparePart?.partName == null
|
||||
? const SizedBox.shrink()
|
||||
: Text(
|
||||
widget.part?.sparePart?.partName,
|
||||
style: Theme.of(context).textTheme.caption.copyWith(fontSize: 11, fontWeight: FontWeight.bold),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
// Row(crossAxisAlignment: ,)
|
||||
],
|
||||
),
|
||||
),
|
||||
AIconButton2(
|
||||
iconData: Icons.close,
|
||||
color: Colors.red,
|
||||
onPressed: () {
|
||||
widget.onDelete(widget.part);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
|
||||
//
|
||||
// import '../../../models/service_request/spare_parts.dart';
|
||||
//
|
||||
// class PartItem extends StatefulWidget {
|
||||
// final SparePartsWorkOrders part;
|
||||
// final Function(SparePartsWorkOrders) onDelete;
|
||||
// final Function(int qty) onEdit;
|
||||
//
|
||||
// const PartItem({Key key, this.part, this.onEdit, this.onDelete}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _PartItemState createState() => _PartItemState();
|
||||
// }
|
||||
//
|
||||
// class _PartItemState extends State<PartItem> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// children: [
|
||||
// const Divider(),
|
||||
// Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// widget?.part?.sparePart?.partNo ?? "",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(fontSize: 12, fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// ),
|
||||
// AIconButton2(
|
||||
// iconData: Icons.add,
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// onPressed: () {
|
||||
// if (widget.onEdit == null) {
|
||||
// ++widget.part.qty;
|
||||
// } else {
|
||||
// widget.onEdit(++widget.part.qty);
|
||||
// }
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// AIconButton2(
|
||||
// iconData: Icons.remove,
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// onPressed: widget.part.qty < 2
|
||||
// ? null
|
||||
// : () {
|
||||
// if (widget.onEdit == null) {
|
||||
// --widget.part.qty;
|
||||
// } else {
|
||||
// widget.onEdit(--widget.part.qty);
|
||||
// }
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Text(
|
||||
// widget.part.qty.toString(),
|
||||
// style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
// //fontSize: 12,
|
||||
// //fontWeight: FontWeight.bold
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// width: 8 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// widget.part?.sparePart?.partName == null
|
||||
// ? const SizedBox.shrink()
|
||||
// : Text(
|
||||
// widget.part?.sparePart?.partName,
|
||||
// style: Theme.of(context).textTheme.caption.copyWith(fontSize: 11, fontWeight: FontWeight.bold),
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
//
|
||||
// // Row(crossAxisAlignment: ,)
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// AIconButton2(
|
||||
// iconData: Icons.close,
|
||||
// color: Colors.red,
|
||||
// onPressed: () {
|
||||
// widget.onDelete(widget.part);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,110 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
|
||||
import '../../../../extensions/text_extensions.dart';
|
||||
import '../../../../models/device/asset.dart';
|
||||
import '../../../../models/device/asset_search.dart';
|
||||
import '../../../../new_views/app_style/app_color.dart';
|
||||
import '../../../../new_views/app_style/app_text_style.dart';
|
||||
import '../../../app_style/sizing.dart';
|
||||
|
||||
class AutoCompleteDeviceNumberField extends StatefulWidget {
|
||||
final Lookup initialValue;
|
||||
final int hospitalId;
|
||||
final Function(Lookup) onPick;
|
||||
|
||||
const AutoCompleteDeviceNumberField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AutoCompleteDeviceNumberField> createState() => _AutoCompleteDeviceNumberFieldState();
|
||||
}
|
||||
|
||||
class _AutoCompleteDeviceNumberFieldState extends State<AutoCompleteDeviceNumberField> {
|
||||
SettingProvider _settingProvider;
|
||||
AssetProvider _devicesProvider;
|
||||
UserProvider _userProvider;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue?.name);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant AutoCompleteDeviceNumberField oldWidget) {
|
||||
if (widget.initialValue != oldWidget.initialValue) {
|
||||
_controller = TextEditingController(text: widget.initialValue?.name);
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_settingProvider = Provider.of<SettingProvider>(context);
|
||||
_userProvider = Provider.of<UserProvider>(context);
|
||||
_devicesProvider = Provider.of<AssetProvider>(context);
|
||||
final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background(context),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
),
|
||||
child: TypeAheadField<Asset>(
|
||||
minCharsForSuggestions: 1,
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: AppTextStyles.bodyText,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.start,
|
||||
textInputAction: TextInputAction.search,
|
||||
decoration: InputDecoration(
|
||||
border: border,
|
||||
disabledBorder: border,
|
||||
focusedBorder: border,
|
||||
enabledBorder: border,
|
||||
errorBorder: border,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
|
||||
constraints: const BoxConstraints(),
|
||||
suffixIconConstraints: const BoxConstraints(minWidth: 0),
|
||||
filled: true,
|
||||
fillColor: (context.isDark ? AppColor.neutral50 : AppColor.background(context)),
|
||||
errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
|
||||
floatingLabelStyle: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
|
||||
labelText: context.translation.assetNumber,
|
||||
),
|
||||
),
|
||||
suggestionsCallback: (value) async {
|
||||
return await _devicesProvider.getDevicesList(
|
||||
host: _settingProvider.host,
|
||||
user: _userProvider.user,
|
||||
hospitalId: widget.hospitalId,
|
||||
addPagination: false,
|
||||
search: AssetSearch(assetNo: value),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, device) {
|
||||
return device.assetNumber.bodyText(context).paddingOnly(bottom: 16, start: 16);
|
||||
},
|
||||
onSuggestionSelected: (device) {
|
||||
_controller.text = device.assetNumber;
|
||||
widget.onPick(Lookup(id: device.id, name: device.assetNumber));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/devices_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/extensions/int_extensions.dart';
|
||||
// import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
//
|
||||
// import '../../../../extensions/text_extensions.dart';
|
||||
// import '../../../../models/device/asset.dart';
|
||||
// import '../../../../models/device/asset_search.dart';
|
||||
// import '../../../../new_views/app_style/app_color.dart';
|
||||
// import '../../../../new_views/app_style/app_text_style.dart';
|
||||
// import '../../../app_style/sizing.dart';
|
||||
//
|
||||
// class AutoCompleteDeviceNumberField extends StatefulWidget {
|
||||
// final Lookup initialValue;
|
||||
// final int hospitalId;
|
||||
// final Function(Lookup) onPick;
|
||||
//
|
||||
// const AutoCompleteDeviceNumberField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<AutoCompleteDeviceNumberField> createState() => _AutoCompleteDeviceNumberFieldState();
|
||||
// }
|
||||
//
|
||||
// class _AutoCompleteDeviceNumberFieldState extends State<AutoCompleteDeviceNumberField> {
|
||||
// SettingProvider _settingProvider;
|
||||
// AssetProvider _devicesProvider;
|
||||
// UserProvider _userProvider;
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController(text: widget.initialValue?.name);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void didUpdateWidget(covariant AutoCompleteDeviceNumberField oldWidget) {
|
||||
// if (widget.initialValue != oldWidget.initialValue) {
|
||||
// _controller = TextEditingController(text: widget.initialValue?.name);
|
||||
// }
|
||||
// super.didUpdateWidget(oldWidget);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _settingProvider = Provider.of<SettingProvider>(context);
|
||||
// _userProvider = Provider.of<UserProvider>(context);
|
||||
// _devicesProvider = Provider.of<AssetProvider>(context);
|
||||
// final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
|
||||
// return Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColor.background(context),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
// ),
|
||||
// child: TypeAheadField<Asset>(
|
||||
// minCharsForSuggestions: 1,
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: AppTextStyles.bodyText,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.start,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// decoration: InputDecoration(
|
||||
// border: border,
|
||||
// disabledBorder: border,
|
||||
// focusedBorder: border,
|
||||
// enabledBorder: border,
|
||||
// errorBorder: border,
|
||||
// contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
|
||||
// constraints: const BoxConstraints(),
|
||||
// suffixIconConstraints: const BoxConstraints(minWidth: 0),
|
||||
// filled: true,
|
||||
// fillColor: (context.isDark ? AppColor.neutral50 : AppColor.background(context)),
|
||||
// errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
|
||||
// floatingLabelStyle: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
|
||||
// labelText: context.translation.assetNumber,
|
||||
// ),
|
||||
// ),
|
||||
// suggestionsCallback: (value) async {
|
||||
// return await _devicesProvider.getDevicesList(
|
||||
// host: _settingProvider.host,
|
||||
// user: _userProvider.user,
|
||||
// hospitalId: widget.hospitalId,
|
||||
// addPagination: false,
|
||||
// search: AssetSearch(assetNo: value),
|
||||
// );
|
||||
// },
|
||||
// itemBuilder: (context, device) {
|
||||
// return device.assetNumber.bodyText(context).paddingOnly(bottom: 16, start: 16);
|
||||
// },
|
||||
// onSuggestionSelected: (device) {
|
||||
// _controller.text = device.assetNumber;
|
||||
// widget.onPick(Lookup(id: device.id, name: device.assetNumber));
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,75 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class RequestInfoRow extends StatelessWidget {
|
||||
final String title;
|
||||
final String info;
|
||||
final String content;
|
||||
final Widget contentWidget;
|
||||
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) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
if (content != null && content.isEmpty) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
title + " : ",
|
||||
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
//fontSize: 12
|
||||
),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
if (info != null)
|
||||
Expanded(
|
||||
child: Text(
|
||||
info,
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
textAlign: TextAlign.right,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
if (infoWidget != null)
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
infoWidget,
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (content != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
content ?? 'No data found',
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
textAlign: TextAlign.center,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (contentWidget != null) contentWidget,
|
||||
Divider(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class RequestInfoRow extends StatelessWidget {
|
||||
// final String title;
|
||||
// final String info;
|
||||
// final String content;
|
||||
// final Widget contentWidget;
|
||||
// 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) {
|
||||
// return SizedBox.shrink();
|
||||
// }
|
||||
// if (content != null && content.isEmpty) {
|
||||
// return SizedBox.shrink();
|
||||
// }
|
||||
// return Column(
|
||||
// children: [
|
||||
// Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// title + " : ",
|
||||
// style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||||
// //fontSize: 12
|
||||
// ),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// if (info != null)
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// info,
|
||||
// style: Theme.of(context).textTheme.bodyText2,
|
||||
// textAlign: TextAlign.right,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// if (infoWidget != null)
|
||||
// Expanded(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// infoWidget,
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// if (content != null)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// content ?? 'No data found',
|
||||
// style: Theme.of(context).textTheme.bodyText2,
|
||||
// textAlign: TextAlign.center,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// if (contentWidget != null) contentWidget,
|
||||
// Divider(
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,142 +1,143 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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/service_requests_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/service_request/service_request.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||
import 'package:test_sa/views/widgets/status/employee/assigned_to_menu.dart';
|
||||
|
||||
class ServiceRequestsUpdateDialog extends StatefulWidget {
|
||||
final ServiceRequest request;
|
||||
|
||||
const ServiceRequestsUpdateDialog({
|
||||
Key key,
|
||||
this.request,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ServiceRequestsUpdateDialog> createState() => _ServiceRequestsUpdateDialogState();
|
||||
}
|
||||
|
||||
class _ServiceRequestsUpdateDialogState extends State<ServiceRequestsUpdateDialog> with TickerProviderStateMixin {
|
||||
DateTime _dateTime;
|
||||
Lookup _employee;
|
||||
|
||||
UserProvider _userProvider;
|
||||
SettingProvider _settingProvider;
|
||||
ServiceRequestsProvider _serviceRequestsProvider;
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
_update() async {
|
||||
if (_dateTime == null && _employee == null) {
|
||||
Fluttertoast.showToast(
|
||||
msg: context.translation.noDateFound,
|
||||
);
|
||||
return;
|
||||
}
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(context.translation.updatingDots),
|
||||
content: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
},
|
||||
);
|
||||
int status = await _serviceRequestsProvider.updateRequest(user: _userProvider.user, request: widget.request);
|
||||
if (status == 200) Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
Fluttertoast.showToast(
|
||||
msg: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
_settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
||||
_serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
// height: MediaQuery.of(context).size.height / 1.2,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.update,
|
||||
onPressed: _update,
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
context.translation.date,
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
),
|
||||
ADatePicker(
|
||||
date: _dateTime,
|
||||
from: DateTime.now(),
|
||||
onDatePicker: (date) {
|
||||
_dateTime = date;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
AssignedToMenu(
|
||||
initialValue: _employee,
|
||||
onSelect: (employee) {
|
||||
_employee = employee;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/cupertino.dart';
|
||||
// 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/service_requests_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/service_request/service_request.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
// import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
|
||||
// import 'package:test_sa/views/widgets/status/employee/assigned_to_menu.dart';
|
||||
//
|
||||
// class ServiceRequestsUpdateDialog extends StatefulWidget {
|
||||
// final ServiceRequest request;
|
||||
//
|
||||
// const ServiceRequestsUpdateDialog({
|
||||
// Key key,
|
||||
// this.request,
|
||||
// }) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// State<ServiceRequestsUpdateDialog> createState() => _ServiceRequestsUpdateDialogState();
|
||||
// }
|
||||
//
|
||||
// class _ServiceRequestsUpdateDialogState extends State<ServiceRequestsUpdateDialog> with TickerProviderStateMixin {
|
||||
// DateTime _dateTime;
|
||||
// Lookup _employee;
|
||||
//
|
||||
// UserProvider _userProvider;
|
||||
// SettingProvider _settingProvider;
|
||||
// ServiceRequestsProvider _serviceRequestsProvider;
|
||||
//
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
//
|
||||
// _update() async {
|
||||
// if (_dateTime == null && _employee == null) {
|
||||
// Fluttertoast.showToast(
|
||||
// msg: context.translation.noDateFound,
|
||||
// );
|
||||
// return;
|
||||
// }
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// barrierDismissible: false,
|
||||
// builder: (BuildContext context) {
|
||||
// return CupertinoAlertDialog(
|
||||
// title: Text(context.translation.updatingDots),
|
||||
// content: Center(child: CircularProgressIndicator()),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// int status = await _serviceRequestsProvider.updateRequest(user: _userProvider.user, request: widget.request);
|
||||
// if (status == 200) Navigator.of(context).pop();
|
||||
// Navigator.of(context).pop();
|
||||
// Fluttertoast.showToast(
|
||||
// msg: HttpStatusManger.getStatusMessage(status: status, subtitle: context.translation),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// _userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
// _settingProvider = Provider.of<SettingProvider>(context, listen: false);
|
||||
// _serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
|
||||
// return Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// SizedBox(
|
||||
// // height: MediaQuery.of(context).size.height / 1.2,
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(16.0),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// ASmallButton(
|
||||
// text: context.translation.cancel,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// ),
|
||||
// ASmallButton(
|
||||
// text: context.translation.update,
|
||||
// onPressed: _update,
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// context.translation.date,
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ),
|
||||
// ADatePicker(
|
||||
// date: _dateTime,
|
||||
// from: DateTime.now(),
|
||||
// onDatePicker: (date) {
|
||||
// _dateTime = date;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// AssignedToMenu(
|
||||
// initialValue: _employee,
|
||||
// onSelect: (employee) {
|
||||
// _employee = employee;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,196 +1,197 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/device/asset_transfer.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/equipment/pick_asset.dart';
|
||||
|
||||
import '../../../models/device/asset_transfer_search.dart';
|
||||
import '../app_text_form_field.dart';
|
||||
import '../switch_button.dart';
|
||||
|
||||
class AssetTransferSearchDialog extends StatefulWidget {
|
||||
final AssetTransfer initialSearchValue;
|
||||
final bool expandedSearch;
|
||||
final Function(AssetTransfer) onSearch;
|
||||
|
||||
const AssetTransferSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
AssetTransferSearchDialogState createState() => AssetTransferSearchDialogState();
|
||||
}
|
||||
|
||||
class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> with TickerProviderStateMixin {
|
||||
AssetTransferSearch _search;
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_search = AssetTransferSearch();
|
||||
// _search.fromSearch(widget.initialSearchValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 20),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.search,
|
||||
onPressed: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
ASwitchButton(
|
||||
title: "Most Recent",
|
||||
value: _search.mostRecent ?? false,
|
||||
onChange: (value) {
|
||||
_search.mostRecent = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
PickAsset(
|
||||
device: _search.asset,
|
||||
onPickAsset: (device) {
|
||||
_search.asset = device;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
ATextFormField(
|
||||
initialValue: "_search.title",
|
||||
hintText: context.translation.title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
// _search.title = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
// HospitalAutoCompleteField(
|
||||
// initialValue: _search?.hospital?.name,
|
||||
// onSearch: (selected) async {
|
||||
// _search.building = null;
|
||||
// _search.floor = null;
|
||||
// _search.department = null;
|
||||
// _search.buildingsList = null;
|
||||
// _search.floorsList = null;
|
||||
// _search.departmentsList = null;
|
||||
// _isLoading = true;
|
||||
// setState(() {});
|
||||
// await HospitalsProvider().getHospitalsListByVal(searchVal: selected?.name ?? "").then((value) {
|
||||
// _search.hospital = value?.firstWhere((element) => element.name == selected.name, orElse: () => null);
|
||||
// _search.buildingsList = _search.hospital?.buildings;
|
||||
// });
|
||||
// _isLoading = false;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 8),
|
||||
// BuildingTypeMenu(
|
||||
// initialValue: _search?.building,
|
||||
// building: _search.buildingsList,
|
||||
// enabled: !_isLoading,
|
||||
// onSelect: (status) {
|
||||
// _search.building = status;
|
||||
// _search.floorsList = status?.floors;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 8),
|
||||
// FloorTypeMenu(
|
||||
// initialValue: _search?.floor,
|
||||
// floors: _search.floorsList,
|
||||
// enabled: !_isLoading,
|
||||
// onSelect: (status) {
|
||||
// _search.floor = status;
|
||||
// _search.departmentsList = _search.floor?.departments;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
const SizedBox(height: 8),
|
||||
// DepartmentTypeMenu(
|
||||
// initialValue: _search?.department,
|
||||
// departments: _search.departmentsList,
|
||||
// enabled: !_isLoading,
|
||||
// onSelect: (status) {
|
||||
// _search.department = status;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
ATextFormField(
|
||||
initialValue: "_search.room",
|
||||
hintText: context.translation.room,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
// _search.room = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)),
|
||||
// Visibility(
|
||||
// visible: (_search.toMap()..remove("mostRecent"))?.isNotEmpty ?? false,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// child: AButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// text: context.translation.clearSearch,
|
||||
// onPressed: () {
|
||||
// _search = DeviceTransferSearch();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/device/asset_transfer.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
// import 'package:test_sa/views/widgets/equipment/pick_asset.dart';
|
||||
//
|
||||
// import '../../../models/device/asset_transfer_search.dart';
|
||||
// import '../app_text_form_field.dart';
|
||||
// import '../switch_button.dart';
|
||||
//
|
||||
// class AssetTransferSearchDialog extends StatefulWidget {
|
||||
// final AssetTransfer initialSearchValue;
|
||||
// final bool expandedSearch;
|
||||
// final Function(AssetTransfer) onSearch;
|
||||
//
|
||||
// const AssetTransferSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// AssetTransferSearchDialogState createState() => AssetTransferSearchDialogState();
|
||||
// }
|
||||
//
|
||||
// class AssetTransferSearchDialogState extends State<AssetTransferSearchDialog> with TickerProviderStateMixin {
|
||||
// AssetTransferSearch _search;
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
// bool _isLoading = false;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _search = AssetTransferSearch();
|
||||
// // _search.fromSearch(widget.initialSearchValue);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Padding(
|
||||
// padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
// child: ClipRRect(
|
||||
// borderRadius: const BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
|
||||
// clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
// child: Container(
|
||||
// color: Colors.white,
|
||||
// height: MediaQuery.of(context).size.height / 1.3,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 20),
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: ListView(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// ASmallButton(
|
||||
// text: context.translation.cancel,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// ),
|
||||
// ASmallButton(
|
||||
// text: context.translation.search,
|
||||
// onPressed: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ASwitchButton(
|
||||
// title: "Most Recent",
|
||||
// value: _search.mostRecent ?? false,
|
||||
// onChange: (value) {
|
||||
// _search.mostRecent = value;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
// PickAsset(
|
||||
// device: _search.asset,
|
||||
// onPickAsset: (device) {
|
||||
// _search.asset = device;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
// ATextFormField(
|
||||
// initialValue: "_search.title",
|
||||
// hintText: context.translation.title,
|
||||
// style: Theme.of(context).textTheme.titleLarge,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// // _search.title = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
// // HospitalAutoCompleteField(
|
||||
// // initialValue: _search?.hospital?.name,
|
||||
// // onSearch: (selected) async {
|
||||
// // _search.building = null;
|
||||
// // _search.floor = null;
|
||||
// // _search.department = null;
|
||||
// // _search.buildingsList = null;
|
||||
// // _search.floorsList = null;
|
||||
// // _search.departmentsList = null;
|
||||
// // _isLoading = true;
|
||||
// // setState(() {});
|
||||
// // await HospitalsProvider().getHospitalsListByVal(searchVal: selected?.name ?? "").then((value) {
|
||||
// // _search.hospital = value?.firstWhere((element) => element.name == selected.name, orElse: () => null);
|
||||
// // _search.buildingsList = _search.hospital?.buildings;
|
||||
// // });
|
||||
// // _isLoading = false;
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 8),
|
||||
// // BuildingTypeMenu(
|
||||
// // initialValue: _search?.building,
|
||||
// // building: _search.buildingsList,
|
||||
// // enabled: !_isLoading,
|
||||
// // onSelect: (status) {
|
||||
// // _search.building = status;
|
||||
// // _search.floorsList = status?.floors;
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 8),
|
||||
// // FloorTypeMenu(
|
||||
// // initialValue: _search?.floor,
|
||||
// // floors: _search.floorsList,
|
||||
// // enabled: !_isLoading,
|
||||
// // onSelect: (status) {
|
||||
// // _search.floor = status;
|
||||
// // _search.departmentsList = _search.floor?.departments;
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // ),
|
||||
// const SizedBox(height: 8),
|
||||
// // DepartmentTypeMenu(
|
||||
// // initialValue: _search?.department,
|
||||
// // departments: _search.departmentsList,
|
||||
// // enabled: !_isLoading,
|
||||
// // onSelect: (status) {
|
||||
// // _search.department = status;
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // ),
|
||||
// SizedBox(height: 8.0 * AppStyle.getScaleFactor(context)),
|
||||
// ATextFormField(
|
||||
// initialValue: "_search.room",
|
||||
// hintText: context.translation.room,
|
||||
// style: Theme.of(context).textTheme.titleLarge,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// // _search.room = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(height: 16.0 * AppStyle.getScaleFactor(context)),
|
||||
// // Visibility(
|
||||
// // visible: (_search.toMap()..remove("mostRecent"))?.isNotEmpty ?? false,
|
||||
// // child: Padding(
|
||||
// // padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// // child: AButton(
|
||||
// // padding: EdgeInsets.zero,
|
||||
// // text: context.translation.clearSearch,
|
||||
// // onPressed: () {
|
||||
// // _search = DeviceTransferSearch();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,56 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class FilterItem extends StatelessWidget {
|
||||
final bool isSelected;
|
||||
final Lookup status;
|
||||
final VoidCallback onSelected;
|
||||
|
||||
const FilterItem({Key key, this.status, this.isSelected, this.onSelected}) : super(key: key);
|
||||
|
||||
//
|
||||
// Color getStatusColor() {
|
||||
// switch (status.id) {
|
||||
// case 0:
|
||||
// return AColors.green;
|
||||
// case 4:
|
||||
// return AColors.deepRed;
|
||||
// case 6:
|
||||
// return AColors.green;
|
||||
// case 5:
|
||||
// return AColors.orange;
|
||||
// case 8:
|
||||
// return AColors.green;
|
||||
// case 9:
|
||||
// return AColors.orange;
|
||||
// default:
|
||||
// return AColors.grey;
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Opacity(
|
||||
opacity: isSelected ? 1 : .5,
|
||||
child: SizedBox(
|
||||
height: 30,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
// primary: getStatusColor(),
|
||||
),
|
||||
child: Text(
|
||||
status.name ?? "",
|
||||
style: Theme.of(context).textTheme.bodyText1.copyWith(
|
||||
// color: getStatusColor().computeLuminance() > 0.5 ? AColors.black : Colors.white,
|
||||
),
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
onPressed: onSelected,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class FilterItem extends StatelessWidget {
|
||||
// final bool isSelected;
|
||||
// final Lookup status;
|
||||
// final VoidCallback onSelected;
|
||||
//
|
||||
// const FilterItem({Key key, this.status, this.isSelected, this.onSelected}) : super(key: key);
|
||||
//
|
||||
// //
|
||||
// // Color getStatusColor() {
|
||||
// // switch (status.id) {
|
||||
// // case 0:
|
||||
// // return AColors.green;
|
||||
// // case 4:
|
||||
// // return AColors.deepRed;
|
||||
// // case 6:
|
||||
// // return AColors.green;
|
||||
// // case 5:
|
||||
// // return AColors.orange;
|
||||
// // case 8:
|
||||
// // return AColors.green;
|
||||
// // case 9:
|
||||
// // return AColors.orange;
|
||||
// // default:
|
||||
// // return AColors.grey;
|
||||
// // }
|
||||
// // }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Opacity(
|
||||
// opacity: isSelected ? 1 : .5,
|
||||
// child: SizedBox(
|
||||
// height: 30,
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context))),
|
||||
// // primary: getStatusColor(),
|
||||
// ),
|
||||
// child: Text(
|
||||
// status.name ?? "",
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(
|
||||
// // color: getStatusColor().computeLuminance() > 0.5 ? AColors.black : Colors.white,
|
||||
// ),
|
||||
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// onPressed: onSelected,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,334 +1,335 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/ppm/ppm_search.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
|
||||
import '../switch_button.dart';
|
||||
|
||||
class PpmSearchDialog extends StatefulWidget {
|
||||
final PpmSearch initialSearchValue;
|
||||
final bool expandedSearch;
|
||||
final Function(PpmSearch) onSearch;
|
||||
|
||||
const PpmSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PpmSearchDialogState createState() => _PpmSearchDialogState();
|
||||
}
|
||||
|
||||
class _PpmSearchDialogState extends State<PpmSearchDialog> with TickerProviderStateMixin {
|
||||
PpmSearch _search;
|
||||
List<Lookup> status = [
|
||||
Lookup(
|
||||
name: "Done",
|
||||
id: 0,
|
||||
),
|
||||
Lookup(name: "Not Yet", id: 1),
|
||||
Lookup(
|
||||
name: "On Hold",
|
||||
id: 2,
|
||||
),
|
||||
];
|
||||
|
||||
List<Lookup> contactStatus = [
|
||||
// Lookup(name: "Hospital Employee", value: "H",),
|
||||
// Lookup(name: "Under Warranty", value: "CW"),
|
||||
// Lookup(name: "Under Maintenance Contract", value: "CC",),
|
||||
];
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_search = PpmSearch();
|
||||
|
||||
/// todo : working
|
||||
// _search.fromSearch(widget.initialSearchValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime today = DateTime.now();
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.3,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
// shrinkWrap: true,
|
||||
// physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.search,
|
||||
onPressed: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
ASwitchButton(
|
||||
title: "Most Recent",
|
||||
value: _search.mostRecent ?? false,
|
||||
onChange: (value) {
|
||||
_search.mostRecent = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceNumber,
|
||||
// hintText: context.translation.assetNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceName,
|
||||
// hintText: context.translation.assetName,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceName = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceSerialNumber,
|
||||
// hintText: context.translation.serialNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceSerialNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// HospitalAutoCompleteField(
|
||||
// initialValue: _search.hospital?.name,
|
||||
// // onSave: (value){
|
||||
// // _search.hospital = value;
|
||||
// // },
|
||||
// onSearch: (value) {
|
||||
// _search.hospital = value;
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// // SizedBox(height: 8.0 * AppStyle.getScaleFactor(context),),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.brand,
|
||||
// // hintText: _subtitle.brand,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: (){
|
||||
// // if(!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value){
|
||||
// // _search.brand = value;
|
||||
// // },
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// AutoCompleteModelField(
|
||||
// initialValue: _search.model,
|
||||
// onPick: (lookup) {
|
||||
// _search.model = lookup;
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.model,
|
||||
// // hintText: _subtitle.model,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: (){
|
||||
// // if(!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value){
|
||||
// // _search.model = value;
|
||||
// // },
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.status),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// PentryVisitsStatusMenu(
|
||||
// initialValue: _search.statusValue,
|
||||
// onSelect: (status) {
|
||||
// _search.statusValue = status;
|
||||
// },
|
||||
// ),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// status.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.statusValue == status[index].id;
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.statusValue = null;
|
||||
// } else {
|
||||
// _search.statusValue = status[index].id;
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: status[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.contactStatus),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// AssignedToMenu(
|
||||
// initialValue: _search.contactStatus,
|
||||
// onSelect: (status) {
|
||||
// _search.contactStatus = status;
|
||||
// },
|
||||
// ),
|
||||
// Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// children: List.generate(
|
||||
// contactStatus.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.contactStatus == contactStatus[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.contactStatus = null;
|
||||
// } else {
|
||||
// _search.contactStatus = contactStatus[index];
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: contactStatus[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.actualDate),
|
||||
SizedBox(
|
||||
height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
// FromToDateBar(
|
||||
// from: _search.actualDateFrom,
|
||||
// to: _search.actualDateTo,
|
||||
// onPickFrom: (date) {
|
||||
// _search.actualDateFrom = date;
|
||||
// },
|
||||
// onPickTo: (date) {
|
||||
// _search.actualDateTo = date;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.expectDate),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// FromToDateBar(
|
||||
// from: _search.expectedDateFrom ?? DateTime(today.year, today.month, 1),
|
||||
// to: _search.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
|
||||
// onPickFrom: (date) {
|
||||
// _search.expectedDateFrom = date;
|
||||
// },
|
||||
// onPickTo: (date) {
|
||||
// _search.expectedDateTo = date;
|
||||
// },
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: _search.toMap().isNotEmpty,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// child: AButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// text: context.translation.clearSearch,
|
||||
// onPressed: () {
|
||||
// _search = VisitsSearch();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/ppm/ppm_search.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
// import 'package:test_sa/views/widgets/buttons/app_small_button.dart';
|
||||
// import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
//
|
||||
// import '../switch_button.dart';
|
||||
//
|
||||
// class PpmSearchDialog extends StatefulWidget {
|
||||
// final PpmSearch initialSearchValue;
|
||||
// final bool expandedSearch;
|
||||
// final Function(PpmSearch) onSearch;
|
||||
//
|
||||
// const PpmSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _PpmSearchDialogState createState() => _PpmSearchDialogState();
|
||||
// }
|
||||
//
|
||||
// class _PpmSearchDialogState extends State<PpmSearchDialog> with TickerProviderStateMixin {
|
||||
// PpmSearch _search;
|
||||
// List<Lookup> status = [
|
||||
// Lookup(
|
||||
// name: "Done",
|
||||
// id: 0,
|
||||
// ),
|
||||
// Lookup(name: "Not Yet", id: 1),
|
||||
// Lookup(
|
||||
// name: "On Hold",
|
||||
// id: 2,
|
||||
// ),
|
||||
// ];
|
||||
//
|
||||
// List<Lookup> contactStatus = [
|
||||
// // Lookup(name: "Hospital Employee", value: "H",),
|
||||
// // Lookup(name: "Under Warranty", value: "CW"),
|
||||
// // Lookup(name: "Under Maintenance Contract", value: "CC",),
|
||||
// ];
|
||||
//
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _search = PpmSearch();
|
||||
//
|
||||
// /// todo : working
|
||||
// // _search.fromSearch(widget.initialSearchValue);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// DateTime today = DateTime.now();
|
||||
// return SizedBox(
|
||||
// height: MediaQuery.of(context).size.height / 1.3,
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: ListView(
|
||||
// // shrinkWrap: true,
|
||||
// // physics: const ClampingScrollPhysics(),
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// ASmallButton(
|
||||
// text: context.translation.cancel,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// ),
|
||||
// ASmallButton(
|
||||
// text: context.translation.search,
|
||||
// onPressed: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ASwitchButton(
|
||||
// title: "Most Recent",
|
||||
// value: _search.mostRecent ?? false,
|
||||
// onChange: (value) {
|
||||
// _search.mostRecent = value;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.deviceNumber,
|
||||
// // hintText: context.translation.assetNumber,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: () {
|
||||
// // if (!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value) {
|
||||
// // _search.deviceNumber = value;
|
||||
// // },
|
||||
// // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.deviceName,
|
||||
// // hintText: context.translation.assetName,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: () {
|
||||
// // if (!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value) {
|
||||
// // _search.deviceName = value;
|
||||
// // },
|
||||
// // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ATextFormField(
|
||||
// // initialValue: _search.deviceSerialNumber,
|
||||
// // hintText: context.translation.serialNumber,
|
||||
// // style: Theme.of(context).textTheme.headline6,
|
||||
// // textInputAction: TextInputAction.search,
|
||||
// // onAction: () {
|
||||
// // if (!_formKey.currentState.validate()) {
|
||||
// // return;
|
||||
// // }
|
||||
// // _formKey.currentState.save();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // onSaved: (value) {
|
||||
// // _search.deviceSerialNumber = value;
|
||||
// // },
|
||||
// // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // HospitalAutoCompleteField(
|
||||
// // initialValue: _search.hospital?.name,
|
||||
// // // onSave: (value){
|
||||
// // // _search.hospital = value;
|
||||
// // // },
|
||||
// // onSearch: (value) {
|
||||
// // _search.hospital = value;
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // ),
|
||||
// // // SizedBox(height: 8.0 * AppStyle.getScaleFactor(context),),
|
||||
// // // ATextFormField(
|
||||
// // // initialValue: _search.brand,
|
||||
// // // hintText: _subtitle.brand,
|
||||
// // // style: Theme.of(context).textTheme.headline6,
|
||||
// // // textInputAction: TextInputAction.search,
|
||||
// // // onAction: (){
|
||||
// // // if(!_formKey.currentState.validate()) {
|
||||
// // // return;
|
||||
// // // }
|
||||
// // // _formKey.currentState.save();
|
||||
// // // Navigator.of(context).pop(_search);
|
||||
// // // },
|
||||
// // // onSaved: (value){
|
||||
// // // _search.brand = value;
|
||||
// // // },
|
||||
// // // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // AutoCompleteModelField(
|
||||
// // initialValue: _search.model,
|
||||
// // onPick: (lookup) {
|
||||
// // _search.model = lookup;
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // ),
|
||||
// // // ATextFormField(
|
||||
// // // initialValue: _search.model,
|
||||
// // // hintText: _subtitle.model,
|
||||
// // // style: Theme.of(context).textTheme.headline6,
|
||||
// // // textInputAction: TextInputAction.search,
|
||||
// // // onAction: (){
|
||||
// // // if(!_formKey.currentState.validate()) {
|
||||
// // // return;
|
||||
// // // }
|
||||
// // // _formKey.currentState.save();
|
||||
// // // Navigator.of(context).pop(_search);
|
||||
// // // },
|
||||
// // // onSaved: (value){
|
||||
// // // _search.model = value;
|
||||
// // // },
|
||||
// // // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ASubTitle(context.translation.status),
|
||||
// // SizedBox(
|
||||
// // height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // PentryVisitsStatusMenu(
|
||||
// // initialValue: _search.statusValue,
|
||||
// // onSelect: (status) {
|
||||
// // _search.statusValue = status;
|
||||
// // },
|
||||
// // ),
|
||||
// // Wrap(
|
||||
// // spacing: 10,
|
||||
// // runSpacing: 10,
|
||||
// // children: List.generate(
|
||||
// // status.length,
|
||||
// // (index) {
|
||||
// // bool isSelected = _search.statusValue == status[index].id;
|
||||
// // return FilterItem(
|
||||
// // isSelected: isSelected,
|
||||
// // onSelected: (){
|
||||
// // if(isSelected) {
|
||||
// // _search.statusValue = null;
|
||||
// // } else {
|
||||
// // _search.statusValue = status[index].id;
|
||||
// // }
|
||||
// //
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // status: status[index],
|
||||
// // );
|
||||
// // }
|
||||
// //
|
||||
// // ),
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.contactStatus),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// // AssignedToMenu(
|
||||
// // initialValue: _search.contactStatus,
|
||||
// // onSelect: (status) {
|
||||
// // _search.contactStatus = status;
|
||||
// // },
|
||||
// // ),
|
||||
// // Wrap(
|
||||
// // spacing: 10,
|
||||
// // runSpacing: 10,
|
||||
// // children: List.generate(
|
||||
// // contactStatus.length,
|
||||
// // (index) {
|
||||
// // bool isSelected = _search.contactStatus == contactStatus[index];
|
||||
// // return FilterItem(
|
||||
// // isSelected: isSelected,
|
||||
// // onSelected: (){
|
||||
// // if(isSelected) {
|
||||
// // _search.contactStatus = null;
|
||||
// // } else {
|
||||
// // _search.contactStatus = contactStatus[index];
|
||||
// // }
|
||||
// //
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // status: contactStatus[index],
|
||||
// // );
|
||||
// // }
|
||||
// //
|
||||
// // ),
|
||||
// // ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.actualDate),
|
||||
// SizedBox(
|
||||
// height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// // FromToDateBar(
|
||||
// // from: _search.actualDateFrom,
|
||||
// // to: _search.actualDateTo,
|
||||
// // onPickFrom: (date) {
|
||||
// // _search.actualDateFrom = date;
|
||||
// // },
|
||||
// // onPickTo: (date) {
|
||||
// // _search.actualDateTo = date;
|
||||
// // },
|
||||
// // ),
|
||||
// // SizedBox(
|
||||
// // height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // ASubTitle(context.translation.expectDate),
|
||||
// // SizedBox(
|
||||
// // height: 4.0 * AppStyle.getScaleFactor(context),
|
||||
// // ),
|
||||
// // FromToDateBar(
|
||||
// // from: _search.expectedDateFrom ?? DateTime(today.year, today.month, 1),
|
||||
// // to: _search.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
|
||||
// // onPickFrom: (date) {
|
||||
// // _search.expectedDateFrom = date;
|
||||
// // },
|
||||
// // onPickTo: (date) {
|
||||
// // _search.expectedDateTo = date;
|
||||
// // },
|
||||
// // ),
|
||||
// // Visibility(
|
||||
// // visible: _search.toMap().isNotEmpty,
|
||||
// // child: Padding(
|
||||
// // padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// // child: AButton(
|
||||
// // padding: EdgeInsets.zero,
|
||||
// // text: context.translation.clearSearch,
|
||||
// // onPressed: () {
|
||||
// // _search = VisitsSearch();
|
||||
// // Navigator.of(context).pop(_search);
|
||||
// // },
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,329 +1,330 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/models/service_request/service_request_search.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/buttons/app_small_button.dart';
|
||||
import 'package:test_sa/views/widgets/hospitals/hospital_auto_complete_field.dart';
|
||||
import 'package:test_sa/views/widgets/status/service_request/service_request_status_mune.dart';
|
||||
import 'package:test_sa/views/widgets/switch_button.dart';
|
||||
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
|
||||
import '../../../models/employee.dart';
|
||||
import '../../../models/new_models/assigned_employee.dart';
|
||||
import '../app_text_form_field.dart';
|
||||
import '../date_and_time/date_picker.dart';
|
||||
import '../status/report/service_report_all_users.dart';
|
||||
import '../status/report/service_report_visit_date_operator.dart';
|
||||
|
||||
class ServiceRequestsSearchDialog extends StatefulWidget {
|
||||
final ServiceRequestSearch initialSearchValue;
|
||||
final bool expandedSearch;
|
||||
final Function(ServiceRequestSearch) onSearch;
|
||||
|
||||
const ServiceRequestsSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ServiceRequestsSearchDialogState createState() => _ServiceRequestsSearchDialogState();
|
||||
}
|
||||
|
||||
class _ServiceRequestsSearchDialogState extends State<ServiceRequestsSearchDialog> with TickerProviderStateMixin {
|
||||
ServiceRequestSearch _search;
|
||||
List<Lookup> status = [
|
||||
Lookup(
|
||||
name: "New",
|
||||
id: 4,
|
||||
),
|
||||
Lookup(
|
||||
name: "Repaired",
|
||||
id: 6,
|
||||
),
|
||||
Lookup(name: "Repeated", id: 8),
|
||||
Lookup(
|
||||
name: "Closed",
|
||||
id: 9,
|
||||
),
|
||||
Lookup(
|
||||
name: "Under Repair",
|
||||
id: 5,
|
||||
),
|
||||
];
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_search = ServiceRequestSearch();
|
||||
_search.fromSearch(widget.initialSearchValue);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height / 1.2,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ASmallButton(
|
||||
text: context.translation.cancel,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
ASmallButton(
|
||||
text: context.translation.search,
|
||||
onPressed: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASwitchButton(
|
||||
title: "Most Recent",
|
||||
value: _search.mostRecent ?? false,
|
||||
onChange: (value) {
|
||||
_search.mostRecent = value;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
labelText: "Call ID",
|
||||
onSaved: (value) {
|
||||
_search.callId = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceNumber,
|
||||
hintText: context.translation.assetNumber,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceNumber = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceSerialNumber,
|
||||
hintText: context.translation.serialNumber,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceSerialNumber = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
HospitalAutoCompleteField(
|
||||
initialValue: _search.hospital?.name,
|
||||
// onSave: (value){
|
||||
// _search.hospital = value;
|
||||
// },
|
||||
onSearch: (value) {
|
||||
_search.hospital = value;
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.deviceName,
|
||||
hintText: context.translation.deviceName,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.deviceName = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ATextFormField(
|
||||
initialValue: _search.model,
|
||||
hintText: context.translation.model,
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
textInputAction: TextInputAction.search,
|
||||
onAction: () {
|
||||
if (!_formKey.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_formKey.currentState.save();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
onSaved: (value) {
|
||||
_search.model = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 16 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
const ASubTitle("Status"),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
ServiceRequestStatusMenu(
|
||||
initialValue: _search.statusValue,
|
||||
onSelect: (status) {
|
||||
_search.statusValue = status;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 16 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
ASubTitle(context.translation.assignedEmployee),
|
||||
const SizedBox(height: 4),
|
||||
ServiceReportAllUsers(
|
||||
initialValue: _search.assignedEmployee == null ? null : Employee(id: _search.assignedEmployee.id, name: _search.assignedEmployee.name),
|
||||
onSelect: (engineer) {
|
||||
_search.assignedEmployee = AssignedEmployee(id: engineer.id, name: engineer.name);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 16 * AppStyle.getScaleFactor(context),
|
||||
),
|
||||
const ASubTitle("Request Date"),
|
||||
const SizedBox(height: 4),
|
||||
ServiceReportVisitDateOperator(
|
||||
initialValue: _search.dateOperator,
|
||||
onSelect: (status) {
|
||||
_search.dateOperator = status;
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const ASubTitle("From"),
|
||||
ADatePicker(
|
||||
date: DateTime.tryParse(_search.from ?? ""),
|
||||
from: DateTime(1950),
|
||||
onDatePicker: (date) {
|
||||
_search.from = date?.toIso8601String();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const SizedBox(width: 16),
|
||||
if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false)
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const ASubTitle("To"),
|
||||
ADatePicker(
|
||||
date: DateTime.tryParse(_search.to ?? ""),
|
||||
from: DateTime(1950),
|
||||
onDatePicker: (date) {
|
||||
_search.to = date?.toIso8601String();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
// child: Wrap(
|
||||
// spacing: 10,
|
||||
// runSpacing: 10,
|
||||
// alignment: WrapAlignment.spaceEvenly,
|
||||
// children: List.generate(
|
||||
// status.length,
|
||||
// (index) {
|
||||
// bool isSelected = _search.statusValue == status[index];
|
||||
// return FilterItem(
|
||||
// isSelected: isSelected,
|
||||
// onSelected: (){
|
||||
// if(isSelected) {
|
||||
// _search.statusValue = null;
|
||||
// } else {
|
||||
// _search.statusValue = status[index];
|
||||
// }
|
||||
//
|
||||
// setState(() {});
|
||||
// },
|
||||
// status: status[index],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
Visibility(
|
||||
visible: widget.initialSearchValue.toMap().isNotEmpty,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
child: AButton(
|
||||
padding: EdgeInsets.zero,
|
||||
text: context.translation.clearSearch,
|
||||
onPressed: () {
|
||||
_search = ServiceRequestSearch();
|
||||
Navigator.of(context).pop(_search);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:test_sa/extensions/context_extension.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/models/service_request/service_request_search.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/buttons/app_small_button.dart';
|
||||
// import 'package:test_sa/views/widgets/hospitals/hospital_auto_complete_field.dart';
|
||||
// import 'package:test_sa/views/widgets/status/service_request/service_request_status_mune.dart';
|
||||
// import 'package:test_sa/views/widgets/switch_button.dart';
|
||||
// import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
|
||||
//
|
||||
// import '../../../models/employee.dart';
|
||||
// import '../../../models/new_models/assigned_employee.dart';
|
||||
// import '../app_text_form_field.dart';
|
||||
// import '../date_and_time/date_picker.dart';
|
||||
// import '../status/report/service_report_all_users.dart';
|
||||
// import '../status/report/service_report_visit_date_operator.dart';
|
||||
//
|
||||
// class ServiceRequestsSearchDialog extends StatefulWidget {
|
||||
// final ServiceRequestSearch initialSearchValue;
|
||||
// final bool expandedSearch;
|
||||
// final Function(ServiceRequestSearch) onSearch;
|
||||
//
|
||||
// const ServiceRequestsSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _ServiceRequestsSearchDialogState createState() => _ServiceRequestsSearchDialogState();
|
||||
// }
|
||||
//
|
||||
// class _ServiceRequestsSearchDialogState extends State<ServiceRequestsSearchDialog> with TickerProviderStateMixin {
|
||||
// ServiceRequestSearch _search;
|
||||
// List<Lookup> status = [
|
||||
// Lookup(
|
||||
// name: "New",
|
||||
// id: 4,
|
||||
// ),
|
||||
// Lookup(
|
||||
// name: "Repaired",
|
||||
// id: 6,
|
||||
// ),
|
||||
// Lookup(name: "Repeated", id: 8),
|
||||
// Lookup(
|
||||
// name: "Closed",
|
||||
// id: 9,
|
||||
// ),
|
||||
// Lookup(
|
||||
// name: "Under Repair",
|
||||
// id: 5,
|
||||
// ),
|
||||
// ];
|
||||
//
|
||||
// final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _search = ServiceRequestSearch();
|
||||
// _search.fromSearch(widget.initialSearchValue);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return SizedBox(
|
||||
// height: MediaQuery.of(context).size.height / 1.2,
|
||||
// child: Form(
|
||||
// key: _formKey,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(16.0),
|
||||
// child: SingleChildScrollView(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// ASmallButton(
|
||||
// text: context.translation.cancel,
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// ),
|
||||
// ASmallButton(
|
||||
// text: context.translation.search,
|
||||
// onPressed: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASwitchButton(
|
||||
// title: "Most Recent",
|
||||
// value: _search.mostRecent ?? false,
|
||||
// onChange: (value) {
|
||||
// _search.mostRecent = value;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// labelText: "Call ID",
|
||||
// onSaved: (value) {
|
||||
// _search.callId = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceNumber,
|
||||
// hintText: context.translation.assetNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceSerialNumber,
|
||||
// hintText: context.translation.serialNumber,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceSerialNumber = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// HospitalAutoCompleteField(
|
||||
// initialValue: _search.hospital?.name,
|
||||
// // onSave: (value){
|
||||
// // _search.hospital = value;
|
||||
// // },
|
||||
// onSearch: (value) {
|
||||
// _search.hospital = value;
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.deviceName,
|
||||
// hintText: context.translation.deviceName,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.deviceName = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 8.0 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ATextFormField(
|
||||
// initialValue: _search.model,
|
||||
// hintText: context.translation.model,
|
||||
// style: Theme.of(context).textTheme.headline6,
|
||||
// textInputAction: TextInputAction.search,
|
||||
// onAction: () {
|
||||
// if (!_formKey.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
// _formKey.currentState.save();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// onSaved: (value) {
|
||||
// _search.model = value;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 16 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// const ASubTitle("Status"),
|
||||
// const SizedBox(
|
||||
// height: 4,
|
||||
// ),
|
||||
// ServiceRequestStatusMenu(
|
||||
// initialValue: _search.statusValue,
|
||||
// onSelect: (status) {
|
||||
// _search.statusValue = status;
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 16 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// ASubTitle(context.translation.assignedEmployee),
|
||||
// const SizedBox(height: 4),
|
||||
// ServiceReportAllUsers(
|
||||
// initialValue: _search.assignedEmployee == null ? null : Employee(id: _search.assignedEmployee.id, name: _search.assignedEmployee.name),
|
||||
// onSelect: (engineer) {
|
||||
// _search.assignedEmployee = AssignedEmployee(id: engineer.id, name: engineer.name);
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 16 * AppStyle.getScaleFactor(context),
|
||||
// ),
|
||||
// const ASubTitle("Request Date"),
|
||||
// const SizedBox(height: 4),
|
||||
// ServiceReportVisitDateOperator(
|
||||
// initialValue: _search.dateOperator,
|
||||
// onSelect: (status) {
|
||||
// _search.dateOperator = status;
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// Row(
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
// children: [
|
||||
// if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const ASubTitle("From"),
|
||||
// ADatePicker(
|
||||
// date: DateTime.tryParse(_search.from ?? ""),
|
||||
// from: DateTime(1950),
|
||||
// onDatePicker: (date) {
|
||||
// _search.from = date?.toIso8601String();
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const SizedBox(width: 16),
|
||||
// if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false)
|
||||
// Expanded(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
// children: [
|
||||
// const ASubTitle("To"),
|
||||
// ADatePicker(
|
||||
// date: DateTime.tryParse(_search.to ?? ""),
|
||||
// from: DateTime(1950),
|
||||
// onDatePicker: (date) {
|
||||
// _search.to = date?.toIso8601String();
|
||||
// setState(() {});
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(width: 16),
|
||||
// // Padding(
|
||||
// // padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
// // child: Wrap(
|
||||
// // spacing: 10,
|
||||
// // runSpacing: 10,
|
||||
// // alignment: WrapAlignment.spaceEvenly,
|
||||
// // children: List.generate(
|
||||
// // status.length,
|
||||
// // (index) {
|
||||
// // bool isSelected = _search.statusValue == status[index];
|
||||
// // return FilterItem(
|
||||
// // isSelected: isSelected,
|
||||
// // onSelected: (){
|
||||
// // if(isSelected) {
|
||||
// // _search.statusValue = null;
|
||||
// // } else {
|
||||
// // _search.statusValue = status[index];
|
||||
// // }
|
||||
// //
|
||||
// // setState(() {});
|
||||
// // },
|
||||
// // status: status[index],
|
||||
// // );
|
||||
// // }
|
||||
// //
|
||||
// // ),
|
||||
// // ),
|
||||
// // ),
|
||||
//
|
||||
// Visibility(
|
||||
// visible: widget.initialSearchValue.toMap().isNotEmpty,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||
// child: AButton(
|
||||
// padding: EdgeInsets.zero,
|
||||
// text: context.translation.clearSearch,
|
||||
// onPressed: () {
|
||||
// _search = ServiceRequestSearch();
|
||||
// Navigator.of(context).pop(_search);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,37 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/asset_transfer_status_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class AssetStatusMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
final bool enabled;
|
||||
|
||||
const AssetStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final assetProvider = Provider.of<AssetTransferStatusProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: assetProvider.isLoading,
|
||||
isFailedLoading: assetProvider.items == null,
|
||||
stateCode: assetProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
assetProvider.reset();
|
||||
await assetProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: assetProvider.items,
|
||||
onSelect: onSelect,
|
||||
enabled: enabled,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/asset_transfer_status_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class AssetStatusMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
// final bool enabled;
|
||||
//
|
||||
// const AssetStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final assetProvider = Provider.of<AssetTransferStatusProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: assetProvider.isLoading,
|
||||
// isFailedLoading: assetProvider.items == null,
|
||||
// stateCode: assetProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// assetProvider.reset();
|
||||
// await assetProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: assetProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// enabled: enabled,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/employee/assigned_to_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class AssignedToMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
|
||||
const AssignedToMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<AssignedToProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/employee/assigned_to_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class AssignedToMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
//
|
||||
// const AssignedToMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<AssignedToProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_size_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class GasCylinderSizeMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
|
||||
const GasCylinderSizeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<GasCylinderSizesProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_size_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class GasCylinderSizeMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
//
|
||||
// const GasCylinderSizeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<GasCylinderSizesProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_type_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class GasCylinderTypesMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
|
||||
const GasCylinderTypesMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<GasCylinderTypesProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_cylinder_type_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class GasCylinderTypesMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
//
|
||||
// const GasCylinderTypesMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<GasCylinderTypesProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,37 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_status_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class GasStatusMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
final bool enabled;
|
||||
|
||||
const GasStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<GasStatusProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
enabled: enabled,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_status_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class GasStatusMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
// final bool enabled;
|
||||
//
|
||||
// const GasStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<GasStatusProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// enabled: enabled,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_types_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class GasTypeMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
|
||||
const GasTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<GasTypesProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/gas_refill/gas_types_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class GasTypeMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
//
|
||||
// const GasTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<GasTypesProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,117 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
class MultiStatusMenu extends StatefulWidget {
|
||||
final List<Lookup> statuses;
|
||||
final List<Lookup> initialSelectedStatus;
|
||||
final Function(List<Lookup>) onSelect;
|
||||
|
||||
const MultiStatusMenu({Key key, this.statuses, this.onSelect, this.initialSelectedStatus}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MultiStatusMenuState createState() => _MultiStatusMenuState();
|
||||
}
|
||||
|
||||
class _MultiStatusMenuState extends State<MultiStatusMenu> {
|
||||
List<Lookup> _selectedStatus = [];
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController();
|
||||
_selectedStatus.addAll(widget.initialSelectedStatus);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.clear();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.start,
|
||||
alignment: WrapAlignment.start,
|
||||
runAlignment: WrapAlignment.start,
|
||||
children: List.generate(_selectedStatus.length, (index) {
|
||||
final status = _selectedStatus[index];
|
||||
return Container(
|
||||
height: 36 * AppStyle.getScaleFactor(context),
|
||||
margin: EdgeInsets.all(4 * AppStyle.getScaleFactor(context)),
|
||||
//padding: EdgeInsets.all(4 * AppStyle.getScaleFactor(context)),
|
||||
decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(8)),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
status.name,
|
||||
style: Theme.of(context).textTheme.bodyText1.copyWith(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
onPressed: () {
|
||||
_selectedStatus.remove(status);
|
||||
widget.onSelect(_selectedStatus);
|
||||
setState(() {});
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
],
|
||||
));
|
||||
}),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
// border: Border.all(color: AColors.black),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
boxShadow: const [AppStyle.boxShadow]),
|
||||
child: TypeAheadField<Lookup>(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
),
|
||||
suggestionsCallback: (vale) {
|
||||
return widget.statuses.where((Lookup option) {
|
||||
return option.name.toLowerCase().contains(_controller.text);
|
||||
});
|
||||
},
|
||||
itemBuilder: (context, part) {
|
||||
return ListTile(
|
||||
title: Text(part.name),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (status) {
|
||||
_controller.clear();
|
||||
if (!_selectedStatus.contains(status)) {
|
||||
_selectedStatus.add(status);
|
||||
widget.onSelect(_selectedStatus);
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||
//
|
||||
// class MultiStatusMenu extends StatefulWidget {
|
||||
// final List<Lookup> statuses;
|
||||
// final List<Lookup> initialSelectedStatus;
|
||||
// final Function(List<Lookup>) onSelect;
|
||||
//
|
||||
// const MultiStatusMenu({Key key, this.statuses, this.onSelect, this.initialSelectedStatus}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// _MultiStatusMenuState createState() => _MultiStatusMenuState();
|
||||
// }
|
||||
//
|
||||
// class _MultiStatusMenuState extends State<MultiStatusMenu> {
|
||||
// List<Lookup> _selectedStatus = [];
|
||||
// TextEditingController _controller;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// _controller = TextEditingController();
|
||||
// _selectedStatus.addAll(widget.initialSelectedStatus);
|
||||
// super.initState();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _controller.clear();
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Wrap(
|
||||
// crossAxisAlignment: WrapCrossAlignment.start,
|
||||
// alignment: WrapAlignment.start,
|
||||
// runAlignment: WrapAlignment.start,
|
||||
// children: List.generate(_selectedStatus.length, (index) {
|
||||
// final status = _selectedStatus[index];
|
||||
// return Container(
|
||||
// height: 36 * AppStyle.getScaleFactor(context),
|
||||
// margin: EdgeInsets.all(4 * AppStyle.getScaleFactor(context)),
|
||||
// //padding: EdgeInsets.all(4 * AppStyle.getScaleFactor(context)),
|
||||
// decoration: BoxDecoration(color: Theme.of(context).colorScheme.primary, borderRadius: BorderRadius.circular(8)),
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// const SizedBox(
|
||||
// width: 12,
|
||||
// ),
|
||||
// Text(
|
||||
// status.name,
|
||||
// style: Theme.of(context).textTheme.bodyText1.copyWith(
|
||||
// color: Theme.of(context).colorScheme.onPrimary,
|
||||
// ),
|
||||
// ),
|
||||
// IconButton(
|
||||
// color: Theme.of(context).colorScheme.onPrimary,
|
||||
// onPressed: () {
|
||||
// _selectedStatus.remove(status);
|
||||
// widget.onSelect(_selectedStatus);
|
||||
// setState(() {});
|
||||
// },
|
||||
// icon: const Icon(Icons.delete))
|
||||
// ],
|
||||
// ));
|
||||
// }),
|
||||
// ),
|
||||
// Container(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// // border: Border.all(color: AColors.black),
|
||||
// borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: const [AppStyle.boxShadow]),
|
||||
// child: TypeAheadField<Lookup>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// style: Theme.of(context).textTheme.subtitle1,
|
||||
// controller: _controller,
|
||||
// textAlign: TextAlign.center,
|
||||
// decoration: const InputDecoration(
|
||||
// border: InputBorder.none,
|
||||
// disabledBorder: InputBorder.none,
|
||||
// focusedBorder: InputBorder.none,
|
||||
// enabledBorder: InputBorder.none,
|
||||
// ),
|
||||
// textInputAction: TextInputAction.search,
|
||||
// ),
|
||||
// suggestionsCallback: (vale) {
|
||||
// return widget.statuses.where((Lookup option) {
|
||||
// return option.name.toLowerCase().contains(_controller.text);
|
||||
// });
|
||||
// },
|
||||
// itemBuilder: (context, part) {
|
||||
// return ListTile(
|
||||
// title: Text(part.name),
|
||||
// );
|
||||
// },
|
||||
// onSuggestionSelected: (status) {
|
||||
// _controller.clear();
|
||||
// if (!_selectedStatus.contains(status)) {
|
||||
// _selectedStatus.add(status);
|
||||
// widget.onSelect(_selectedStatus);
|
||||
// setState(() {});
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,35 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_status_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/models/lookup.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
|
||||
class PentryStatusMenu extends StatelessWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
final Lookup initialValue;
|
||||
|
||||
const PentryStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingProvider = Provider.of<SettingProvider>(context);
|
||||
final userProvider = Provider.of<UserProvider>(context);
|
||||
final menuProvider = Provider.of<PentryStatusProvider>(context);
|
||||
return LoadingManager(
|
||||
isLoading: menuProvider.isLoading,
|
||||
isFailedLoading: menuProvider.items == null,
|
||||
stateCode: menuProvider.stateCode,
|
||||
onRefresh: () async {
|
||||
menuProvider.reset();
|
||||
await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
},
|
||||
child: SingleStatusMenu(
|
||||
initialStatus: initialValue,
|
||||
statuses: menuProvider.items,
|
||||
onSelect: onSelect,
|
||||
));
|
||||
}
|
||||
}
|
||||
///todo deleted
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/status_drop_down/pentry/pentry_status_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
// import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
// import 'package:test_sa/models/lookup.dart';
|
||||
// import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
||||
// import 'package:test_sa/views/widgets/status/single_status_menu.dart';
|
||||
//
|
||||
// class PentryStatusMenu extends StatelessWidget {
|
||||
// final Function(Lookup) onSelect;
|
||||
// final Lookup initialValue;
|
||||
//
|
||||
// const PentryStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// final settingProvider = Provider.of<SettingProvider>(context);
|
||||
// final userProvider = Provider.of<UserProvider>(context);
|
||||
// final menuProvider = Provider.of<PentryStatusProvider>(context);
|
||||
// return LoadingManager(
|
||||
// isLoading: menuProvider.isLoading,
|
||||
// isFailedLoading: menuProvider.items == null,
|
||||
// stateCode: menuProvider.stateCode,
|
||||
// onRefresh: () async {
|
||||
// menuProvider.reset();
|
||||
// await menuProvider.getData(user: userProvider.user, host: settingProvider.host);
|
||||
// },
|
||||
// child: SingleStatusMenu(
|
||||
// initialStatus: initialValue,
|
||||
// statuses: menuProvider.items,
|
||||
// onSelect: onSelect,
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue