main_design2.0
nextwo 2 years ago
parent d33c97d1df
commit b3c577d03e

@ -70,7 +70,7 @@ class URLs {
static get getServiceReportLastCalls => "$_baseUrl/WorkOrder/GetLookupCallLastSituationBasedOnCase"; // get static get getServiceReportLastCalls => "$_baseUrl/WorkOrder/GetLookupCallLastSituationBasedOnCase"; // get
static get getAssetTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=500"; // get static get getAssetTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=500"; // get
static get getPartNumber => "$_baseUrl/PartCatalog/GetPartAutoComplete"; // get static get getPartNumber => "$_baseUrl/PartCatalog/GetPartAutoComplete"; // get
static get getServiceReportPriority => "$_baseUrl/Lookups/GetLookup?lookupEnum=602"; // get static get getServiceReportPriority => "$_baseUrl/Lookups/GetLookup?lookupEnum=4"; // get
static get getServiceReportDefectTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=601"; // get static get getServiceReportDefectTypes => "$_baseUrl/Lookups/GetLookup?lookupEnum=601"; // get
static get getCallRequestForWorkOrder => "$_baseUrl/CallRequest/GetCallRequestForWorkOrder"; // get static get getCallRequestForWorkOrder => "$_baseUrl/CallRequest/GetCallRequestForWorkOrder"; // get

@ -185,24 +185,23 @@ class GasRefillProvider extends ChangeNotifier {
}) })
.toList(); .toList();
log(body.toString()); log(body.toString());
return -1; Response response;
// Response response; try {
// try { response = await ApiManager.instance.put(URLs.updateGasRefill, body: body);
// response = await ApiManager.instance.put(URLs.updateGasRefill, body: body); // response = await post(
// // response = await post( // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"),
// // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"), // body: body,
// // body: body, // );
// // );
// stateCode = response.statusCode;
// stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) {
// if (response.statusCode >= 200 && response.statusCode < 300) { oldModel.fromGasRefillModel(newModel);
// oldModel.fromGasRefillModel(newModel); notifyListeners();
// notifyListeners(); }
// } return response.statusCode;
// return response.statusCode; } catch (error) {
// } catch (error) { return -1;
// return -1; }
// }
} }
Hospital hospital; Hospital hospital;

@ -25,9 +25,9 @@ import '../../../../models/enums/user_types.dart';
import '../../../app_style/colors.dart'; import '../../../app_style/colors.dart';
class GasRefillDetails extends StatefulWidget { class GasRefillDetails extends StatefulWidget {
final GasRefillModel model; GasRefillModel model;
const GasRefillDetails({Key key, this.model}) : super(key: key); GasRefillDetails({Key key, this.model}) : super(key: key);
@override @override
State<GasRefillDetails> createState() => _GasRefillDetailsState(); State<GasRefillDetails> createState() => _GasRefillDetailsState();
@ -102,7 +102,9 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
child: Row( child: Row(
children: [ children: [
const ABackButton(), ABackButton(onPressed: (){
Navigator.of(context).pop(_model);
},),
Expanded( Expanded(
child: Center( child: Center(
child: Text( child: Text(
@ -123,14 +125,17 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
_model.fromGasRefillModel(widget.model); _model.fromGasRefillModel(widget.model);
print(widget.model.startDate); print(widget.model.startDate);
// setState(() {}); // setState(() {});
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => RequestGasRefill( builder: (context) => RequestGasRefill(
gasRefillModel: widget.model, gasRefillModel: widget.model,
), ),
), ),
); ).then((value) {
_model.status= value;
});
setState(() {});
}, },
), ),
const SizedBox( const SizedBox(

@ -106,7 +106,8 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully, msg: _subtitle.requestCompleteSuccessfully,
); );
Navigator.of(context).pop(); Navigator.of(context).pop(_formModel.status);
setState(() { });
} else { } else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle); String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
@ -151,7 +152,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
if (_gasRefillProvider == null) { if (_gasRefillProvider == null) {
_gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false); _gasRefillProvider = Provider.of<GasRefillProvider>(context, listen: false);
_gasRefillProvider.reset(); //_gasRefillProvider.reset();
} }
if (_firstTime) { if (_firstTime) {
if (widget.gasRefillModel != null) { if (widget.gasRefillModel != null) {

@ -189,7 +189,7 @@ class CreateRequestPageState extends State<CreateRequestPage> {
height: 4, height: 4,
), ),
ServiceRequestPriorityMenu( ServiceRequestPriorityMenu(
initialValue: _serviceRequest.priority, initialValue: widget.serviceRequest.priority,
onSelect: (status) { onSelect: (status) {
_serviceRequest.priority = status; _serviceRequest.priority = status;
}, },
@ -341,13 +341,13 @@ class CreateRequestPageState extends State<CreateRequestPage> {
child: AButton( child: AButton(
text: widget.serviceRequest == null ? _subtitle.submit : _subtitle.update, text: widget.serviceRequest == null ? _subtitle.submit : _subtitle.update,
onPressed: () async { onPressed: () async {
if (!_formKey.currentState.validate()) return; //if (!_formKey.currentState.validate()) return;
if (_device?.id == null) { if (_device?.id == null) {
Fluttertoast.showToast(msg: _subtitle.pickDevice); Fluttertoast.showToast(msg: _subtitle.pickDevice);
return; return;
} }
if (_serviceRequest.firstAction?.name == "Need a visit" && _dateTime == null) { if (_serviceRequest.firstAction?.name == "Need a visit" && _dateTime == null) {
Fluttertoast.showToast(msg: _subtitle.noDateFound); Fluttertoast.showToast(msg: "first action is required");
return; return;
} }
if (widget.serviceRequest != null && (_serviceRequest?.engineerId == null || (_serviceRequest?.engineerId?.isEmpty ?? false))) { if (widget.serviceRequest != null && (_serviceRequest?.engineerId == null || (_serviceRequest?.engineerId?.isEmpty ?? false))) {

@ -7,37 +7,45 @@ import 'package:test_sa/views/widgets/gas_refill/gas_refill_item.dart';
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart'; import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
import 'package:test_sa/views/widgets/loaders/no_item_found.dart'; import 'package:test_sa/views/widgets/loaders/no_item_found.dart';
class GasRefillList extends StatelessWidget { class GasRefillList extends StatefulWidget {
final List<GasRefillModel> items; final List<GasRefillModel> items;
final bool nextPage; final bool nextPage;
final Future<void> Function() onLazyLoad; final Future<void> Function() onLazyLoad;
const GasRefillList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); const GasRefillList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key);
@override
State<GasRefillList> createState() => _GasRefillListState();
}
class _GasRefillListState extends State<GasRefillList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (items.length == 0) { if (widget.items.length == 0) {
Subtitle subtitle = AppLocalization.of(context).subtitle; Subtitle subtitle = AppLocalization.of(context).subtitle;
return NoItemFound( return NoItemFound(
message: subtitle.noServiceRequestFound, message: subtitle.noServiceRequestFound,
); );
} }
return LazyLoading( return LazyLoading(
nextPage: nextPage, nextPage: widget.nextPage,
onLazyLoad: onLazyLoad, onLazyLoad: widget.onLazyLoad,
child: ListView.builder( child: ListView.builder(
//physics: const BouncingScrollPhysics(), //physics: const BouncingScrollPhysics(),
itemCount: items.length, itemCount: widget.items.length,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
itemBuilder: (context, itemIndex) { itemBuilder: (context, itemIndex) {
return GasRefillItem( return GasRefillItem(
index: itemIndex, index: itemIndex,
item: items[itemIndex], item: widget.items[itemIndex],
onPressed: (model) { onPressed: (model) {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (_) => GasRefillDetails( builder: (_) => GasRefillDetails(
model: model, model: model,
))); ))).then((value) {
model=value;
setState(() {});
});
}, },
); );
}), }),

Loading…
Cancel
Save