Merge branch 'mirza_home_page' into development_new_design_2.0

merge-requests/390/head
Mirza.Shafique 5 years ago
commit a67c5afcfb

@ -23,12 +23,9 @@ class CMCService extends BaseService {
bool isOrderUpdated; bool isOrderUpdated;
Future getCMCAllServices() async { Future getCMCAllServices() async {
GetCMCServicesRequestModel getCMCServicesRequestModel = new GetCMCServicesRequestModel(genderID: user.gender, identificationNo: user.patientIdentificationNo);
GetCMCServicesRequestModel getCMCServicesRequestModel= new GetCMCServicesRequestModel(genderID: user.gender, identificationNo: user.patientIdentificationNo);
hasError = false; hasError = false;
await baseAppClient.post(HHC_GET_ALL_CMC_SERVICES, await baseAppClient.post(HHC_GET_ALL_CMC_SERVICES, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) {
cmcAllServicesList.clear(); cmcAllServicesList.clear();
response['PatientER_CMC_GetAllServicesList'].forEach((data) { response['PatientER_CMC_GetAllServicesList'].forEach((data) {
cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data)); cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data));
@ -39,79 +36,67 @@ class CMCService extends BaseService {
}, body: getCMCServicesRequestModel.toJson()); }, body: getCMCServicesRequestModel.toJson());
} }
Future getCmcAllPresOrders() async { Future getCmcAllPresOrders() async {
GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel = GetHHCAllPresOrdersRequestModel();
GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel= GetHHCAllPresOrdersRequestModel();
hasError = false; hasError = false;
await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS, await baseAppClient.post(GET_PATIENT_ALL_PRES_ORDERS, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) { cmcAllPresOrdersList.clear();
cmcAllPresOrdersList.clear(); cmcAllOrderDetail.clear();
cmcAllOrderDetail.clear(); response['PatientER_GetPatientAllPresOrdersList'].forEach((data) {
response['PatientER_GetPatientAllPresOrdersList'].forEach((data) { if (data['ServiceID'] == OrderService.Comprehensive_Medical_Checkup.getIdOrderService()) cmcAllPresOrdersList.add(GetHHCAllPresOrdersResponseModel.fromJson(data));
if (data['ServiceID'] == OrderService.Comprehensive_Medical_Checkup.getIdOrderService())
cmcAllPresOrdersList
.add(GetHHCAllPresOrdersResponseModel.fromJson(data));
}); });
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: getHHCAllPresOrdersRequestModel.toJson()); }, body: getHHCAllPresOrdersRequestModel.toJson());
} }
Future getOrderDetailByOrderID(GetOrderDetailByOrderIDRequestModel getOrderDetailByOrderIDRequestModel) async { Future getOrderDetailByOrderID(GetOrderDetailByOrderIDRequestModel getOrderDetailByOrderIDRequestModel) async {
hasError = false; hasError = false;
await baseAppClient.post(GET_CMC_ORDER_DETAIL_BY_ID, await baseAppClient.post(GET_CMC_ORDER_DETAIL_BY_ID, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) { cmcAllOrderDetail.clear();
cmcAllOrderDetail.clear(); response['PatientER_CMC_GetTransactionsForOrderList'].forEach((data) {
response['PatientER_CMC_GetTransactionsForOrderList'].forEach((data) { cmcAllOrderDetail.add(GetOrderDetailByOrderIDResponseModel.fromJson(data));
cmcAllOrderDetail.add(GetOrderDetailByOrderIDResponseModel.fromJson(data)); });
}); }, onFailure: (String error, int statusCode) {
}, onFailure: (String error, int statusCode) { hasError = true;
hasError = true; super.error = error;
super.error = error; }, body: getOrderDetailByOrderIDRequestModel.toJson());
}, body: getOrderDetailByOrderIDRequestModel.toJson());
} }
Future getCheckupItems(CMCGetItemsRequestModel cMCGetItemsRequestModel) async { Future getCheckupItems(CMCGetItemsRequestModel cMCGetItemsRequestModel) async {
hasError = false; hasError = false;
await baseAppClient.post(GET_CHECK_UP_ITEMS, await baseAppClient.post(GET_CHECK_UP_ITEMS, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) { checkupItemsList.clear();
checkupItemsList.clear(); response['GetCheckUpItemsList'].forEach((data) {
response['GetCheckUpItemsList'].forEach((data) { checkupItemsList.add(CMCGetItemsResponseModel.fromJson(data));
checkupItemsList.add(CMCGetItemsResponseModel.fromJson(data)); });
}); }, onFailure: (String error, int statusCode) {
}, onFailure: (String error, int statusCode) { hasError = true;
hasError = true; super.error = error;
super.error = error; }, body: cMCGetItemsRequestModel.toJson());
}, body: cMCGetItemsRequestModel.toJson());
} }
Future updateCmcPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async { Future updateCmcPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async {
hasError = false; hasError = false;
await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, await baseAppClient.post(PATIENT_ER_UPDATE_PRES_ORDER, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) { isOrderUpdated = true;
isOrderUpdated = true; }, onFailure: (String error, int statusCode) {
}, onFailure: (String error, int statusCode) { hasError = true;
hasError = true; super.error = error;
super.error = error; }, body: updatePresOrderRequestModel.toJson());
}, body: updatePresOrderRequestModel.toJson());
} }
Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async {
hasError = false; hasError = false;
await baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, String reqId="";
onSuccess: (dynamic response, int statusCode) { await baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, onSuccess: (dynamic response, int statusCode) {
isOrderUpdated = true; isOrderUpdated = true;
}, onFailure: (String error, int statusCode) { reqId=response['RequestNo'].toString();
hasError = true; }, onFailure: (String error, int statusCode) {
super.error = error; hasError = true;
}, body: order.toJson()); super.error = error;
}, body: order.toJson());
return reqId;
} }
} }

@ -17,34 +17,28 @@ import '../../../locator.dart';
import 'add_new_address_Request_Model.dart'; import 'add_new_address_Request_Model.dart';
class CMCViewModel extends BaseViewModel { class CMCViewModel extends BaseViewModel {
CMCService _cMCService = CMCService _cMCService = locator<CMCService>();
locator<CMCService>(); CustomerAddressesService _customerAddressesService = locator<CustomerAddressesService>();
CustomerAddressesService _customerAddressesService =
locator<CustomerAddressesService>();
List<AddressInfo> get addressesList =>
_customerAddressesService.addressesList;
List<GetCMCServicesResponseModel> get cmcAllServicesList =>
_cMCService.cmcAllServicesList; List<AddressInfo> get addressesList => _customerAddressesService.addressesList;
List<GetHHCAllPresOrdersResponseModel> get cmcAllPresOrders => List<GetCMCServicesResponseModel> get cmcAllServicesList => _cMCService.cmcAllServicesList;
_cMCService.cmcAllPresOrdersList;
List<GetOrderDetailByOrderIDResponseModel> get cmcAllOrderDetail => List<GetHHCAllPresOrdersResponseModel> get cmcAllPresOrders => _cMCService.cmcAllPresOrdersList;
_cMCService.cmcAllOrderDetail;
List<CMCGetItemsResponseModel> get checkupItems =>
_cMCService.checkupItemsList;
PharmacyModuleService _pharmacyModuleService = locator<PharmacyModuleService>(); List<GetOrderDetailByOrderIDResponseModel> get cmcAllOrderDetail => _cMCService.cmcAllOrderDetail;
List<CMCGetItemsResponseModel> get checkupItems => _cMCService.checkupItemsList;
PharmacyModuleService _pharmacyModuleService = locator<PharmacyModuleService>();
bool get isOrderUpdated => _cMCService.isOrderUpdated; bool get isOrderUpdated => _cMCService.isOrderUpdated;
Future getCMCAllServices() async { Future getCMCAllServices() async {
await _cMCService await _cMCService.getCMCAllServices();
.getCMCAllServices();
CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: cmcAllServicesList[0].iD); CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: cmcAllServicesList[0].iD);
await getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel,isFirst: true); await getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel, isFirst: true);
if (_cMCService.hasError) { if (_cMCService.hasError) {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.Error); setState(ViewState.Error);
@ -52,16 +46,15 @@ class CMCViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
Future getCheckupItems({CMCGetItemsRequestModel cMCGetItemsRequestModel, bool isFirst = false}) async { Future getCheckupItems({CMCGetItemsRequestModel cMCGetItemsRequestModel, bool isFirst = false}) async {
if(!isFirst) if (!isFirst) setState(ViewState.Busy);
setState(ViewState.Busy);
await _cMCService.getCheckupItems(cMCGetItemsRequestModel); await _cMCService.getCheckupItems(cMCGetItemsRequestModel);
if (_cMCService.hasError) { if (_cMCService.hasError) {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.Error); setState(ViewState.Error);
} }
if(!isFirst) if (!isFirst) setState(ViewState.Idle);
setState(ViewState.Idle);
} }
Future getCmcAllPresOrders() async { Future getCmcAllPresOrders() async {
@ -71,9 +64,7 @@ class CMCViewModel extends BaseViewModel {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else { } else {
var pendingOrder = _cMCService.cmcAllPresOrdersList.firstWhere( var pendingOrder = _cMCService.cmcAllPresOrdersList.firstWhere((element) => element.status == 1 || element.status == 2, orElse: () => null);
(element) => element.status == 1 || element.status == 2,
orElse: () => null);
if (pendingOrder != null) { if (pendingOrder != null) {
await getOrderDetailByOrderID(pendingOrder); await getOrderDetailByOrderID(pendingOrder);
setState(ViewState.Idle); setState(ViewState.Idle);
@ -83,11 +74,9 @@ class CMCViewModel extends BaseViewModel {
} }
} }
Future updateCmcPresOrder( Future updateCmcPresOrder(UpdatePresOrderRequestModel updatePresOrderRequestModel) async {
UpdatePresOrderRequestModel updatePresOrderRequestModel) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _cMCService.updateCmcPresOrder( await _cMCService.updateCmcPresOrder(updatePresOrderRequestModel);
updatePresOrderRequestModel);
if (_cMCService.hasError) { if (_cMCService.hasError) {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
@ -97,23 +86,24 @@ class CMCViewModel extends BaseViewModel {
} }
Future getOrderDetailByOrderID(GetHHCAllPresOrdersResponseModel order) async { Future getOrderDetailByOrderID(GetHHCAllPresOrdersResponseModel order) async {
GetOrderDetailByOrderIDRequestModel getOrderDetailByOrderIDRequestModel = GetOrderDetailByOrderIDRequestModel getOrderDetailByOrderIDRequestModel = GetOrderDetailByOrderIDRequestModel(presOrderID: order.iD);
GetOrderDetailByOrderIDRequestModel(presOrderID: order.iD); await _cMCService.getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel);
await _cMCService
.getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel);
} }
//TODO check it in uat //TODO check it in uat
Future insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async {
setState(ViewState.Busy); setState(ViewState.Busy);
order.createdBy = user.patientID; order.createdBy = user.patientID;
order.orderServiceID = OrderService.Comprehensive_Medical_Checkup.getIdOrderService(); order.orderServiceID = OrderService.Comprehensive_Medical_Checkup.getIdOrderService();
await _cMCService.insertPresPresOrder(order: order); String requestId = await _cMCService.insertPresPresOrder(order: order);
if (_cMCService.hasError) { if (_cMCService.hasError) {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else { } else {
getCmcAllPresOrders(); getCmcAllPresOrders();
} }
return requestId;
} }
Future getCustomerAddresses() async { Future getCustomerAddresses() async {
@ -129,7 +119,7 @@ class CMCViewModel extends BaseViewModel {
Future getCustomerInfo() async { Future getCustomerInfo() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _pharmacyModuleService.generatePharmacyToken().then((value) async{ await _pharmacyModuleService.generatePharmacyToken().then((value) async {
await _customerAddressesService.getCustomerInfo(); await _customerAddressesService.getCustomerInfo();
}); });
if (_customerAddressesService.hasError) { if (_customerAddressesService.hasError) {
@ -140,14 +130,9 @@ class CMCViewModel extends BaseViewModel {
} }
} }
Future addAddressInfo( Future addAddressInfo({AddNewAddressRequestModel addNewAddressRequestModel}) async {
{AddNewAddressRequestModel addNewAddressRequestModel}) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _customerAddressesService.addAddressInfo( await _customerAddressesService.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
addNewAddressRequestModel: addNewAddressRequestModel
);
if (_customerAddressesService.hasError) { if (_customerAddressesService.hasError) {
error = _customerAddressesService.error; error = _customerAddressesService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);

@ -10,9 +10,7 @@ class ConfirmCancelOrderDialog extends StatefulWidget {
final CMCViewModel model; final CMCViewModel model;
final Function onTap; final Function onTap;
ConfirmCancelOrderDialog({Key key, this.model, this.onTap});
ConfirmCancelOrderDialog(
{Key key, this.model, this.onTap});
@override @override
_ConfirmCancelOrderDialogState createState() => _ConfirmCancelOrderDialogState(); _ConfirmCancelOrderDialogState createState() => _ConfirmCancelOrderDialogState();
@ -27,11 +25,13 @@ class _ConfirmCancelOrderDialogState extends State<ConfirmCancelOrderDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SimpleDialog( return SimpleDialog(
contentPadding: EdgeInsets.fromLTRB(28.0, 24.0, 28.0, 0.0), contentPadding: EdgeInsets.fromLTRB(28.0, 2.0, 28.0, 0.0),
title: Center( title: Text(
child: Texts( TranslationBase.of(context).confirm,
TranslationBase.of(context).confirm, style: TextStyle(
color: Colors.black, fontSize: 16,
fontWeight: FontWeight.bold,
letterSpacing: -0.46,
), ),
), ),
children: [ children: [
@ -39,13 +39,13 @@ class _ConfirmCancelOrderDialogState extends State<ConfirmCancelOrderDialog> {
children: [ children: [
Divider(), Divider(),
Center( Center(
child: Texts( child: Text(
TranslationBase.of(context).cancelOrderMsg , TranslationBase.of(context).cancelOrderMsg,
color: Colors.grey, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, letterSpacing: -0.46, color: Colors.grey[600]),
), ),
), ),
SizedBox( SizedBox(
height: 5.0, height: 12.0,
), ),
Row( Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -60,9 +60,14 @@ class _ConfirmCancelOrderDialogState extends State<ConfirmCancelOrderDialog> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
child: Center( child: Center(
child: Texts( child: Text(
TranslationBase.of(context).cancel.toUpperCase(), TranslationBase.of(context).cancel.toUpperCase(),
color: Colors.red, style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
letterSpacing: -0.46,
color: Colors.red,
),
), ),
), ),
), ),
@ -77,28 +82,32 @@ class _ConfirmCancelOrderDialogState extends State<ConfirmCancelOrderDialog> {
Expanded( Expanded(
flex: 1, flex: 1,
child: InkWell( child: InkWell(
onTap: () async{ onTap: () async {
widget.onTap(); widget.onTap();
Navigator.pop(context); Navigator.pop(context);
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Center( child: Center(
child: Texts( child: Text(
TranslationBase.of(context).ok, TranslationBase.of(context).ok.toUpperCase(),
fontWeight: FontWeight.w400, style: TextStyle(
)), fontSize: 14,
fontWeight: FontWeight.w700,
letterSpacing: -0.46,
),
)),
), ),
), ),
), ),
], ],
) ),
SizedBox(
height: 5.0,
),
], ],
) )
], ],
); );
} }
} }

@ -0,0 +1,98 @@
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:flutter/material.dart';
import 'package:progress_hud_v2/generated/i18n.dart';
Future<void> showCMCConfirmDialog(BuildContext context, String requestId, {Function onClick}) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return Dialog(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ConfirmDialog(requestId,onClick: onClick,),
],
),
);
},
);
}
class ConfirmDialog extends StatelessWidget {
String requestId;
Function onClick;
ConfirmDialog(this.requestId, {this.onClick});
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
mFlex(1),
IconButton(
icon: Icon(
Icons.close,
),
onPressed: () {
onClick();
Navigator.pop(context);
},
),
],
),
Text(
"Request has been sent successfully. You will be contacted soon.",
textAlign: TextAlign.start,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
letterSpacing: -0.46,
),
),
mHeight(20),
Text(
"Request ID",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.grey[600],
letterSpacing: -0.46,
),
),
Text(
requestId ?? "",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
letterSpacing: -0.46,
),
),
mHeight(20),
Container(
width: MediaQuery.of(context).size.width * 0.9,
child: SecondaryButton(
label: TranslationBase.of(context).ok.toUpperCase(),
color: CustomColors.accentColor,
onTap: () async {
onClick();
Navigator.pop(context);
},
textColor: Theme.of(context).backgroundColor),
),
],
),
);
}
}

@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -47,19 +48,14 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
price: widget.model.cmcAllServicesList[0].price, price: widget.model.cmcAllServicesList[0].price,
serviceID: widget.model.cmcAllServicesList[0].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[0].serviceID.toString(),
selectedServiceName: widget.model.cmcAllServicesList[0].description, selectedServiceName: widget.model.cmcAllServicesList[0].description,
selectedServiceNameAR: selectedServiceNameAR: widget.model.cmcAllServicesList[0].descriptionN,
widget.model.cmcAllServicesList[0].descriptionN,
recordID: 1, recordID: 1,
totalPrice: widget.model.cmcAllServicesList[0].totalPrice, totalPrice: widget.model.cmcAllServicesList[0].totalPrice,
vAT: widget.model.cmcAllServicesList[0].vAT); vAT: widget.model.cmcAllServicesList[0].vAT);
cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel( cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel(patientERCMCInsertServicesList: [patientERCMCInsertServicesList]);
patientERCMCInsertServicesList: [patientERCMCInsertServicesList]);
} }
cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel( cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel(patientERCMCInsertServicesList: patientERCMCInsertServicesList != null ? [patientERCMCInsertServicesList] : []);
patientERCMCInsertServicesList: patientERCMCInsertServicesList != null
? [patientERCMCInsertServicesList]
: []);
_controller = new PageController(); _controller = new PageController();
@ -89,26 +85,18 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
void showConfirmMessage( void showConfirmMessage(CMCViewModel model, GetOrderDetailByOrderIDResponseModel order) {
CMCViewModel model, GetOrderDetailByOrderIDResponseModel order) {
showDialog( showDialog(
context: context, context: context,
child: ConfirmCancelOrderDialog( child: ConfirmCancelOrderDialog(
model: model, model: model,
onTap: () async { onTap: () async {
UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel updatePresOrderRequestModel = UpdatePresOrderRequestModel(presOrderID: order.presOrderID, rejectionReason: "", presOrderStatus: 4, editedBy: 3);
UpdatePresOrderRequestModel(
presOrderID: order.presOrderID,
rejectionReason: "",
presOrderStatus: 4,
editedBy: 3);
await model.updateCmcPresOrder(updatePresOrderRequestModel); await model.updateCmcPresOrder(updatePresOrderRequestModel);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
} else { } else {
AppToast.showSuccessToast( AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully);
message:
TranslationBase.of(context).processDoneSuccessfully);
await model.getCmcAllPresOrders(); await model.getCmcAllPresOrders();
} }
}, },
@ -119,282 +107,118 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
body: SafeArea( body: SafeArea(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
height: MediaQuery.of(context).size.height * 0.8, child: widget.model.cmcAllOrderDetail.length != 0
child: Column( ? Column(
children: [ children: [
Container(
Expanded( width: double.infinity,
child: PageView( padding: EdgeInsets.only(left: 12, right: 12, top: 12),
physics: NeverScrollableScrollPhysics(), child: Card(
controller: _controller, shape: cardRadius(12),
onPageChanged: (index) { elevation: 2,
setState(() { margin: EdgeInsets.zero,
_currentIndex = index; color: Color(0xffcd9e1b),
}); clipBehavior: Clip.antiAlias,
}, child: Container(
scrollDirection: Axis.horizontal, // decoration: containerColorRadiusLeft(Colors.white, 12),
children: <Widget>[ margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 8, right: projectViewModel.isArabic ? 8 : 0),
widget.model.cmcAllOrderDetail.length != 0 padding: EdgeInsets.all(12),
? FractionallySizedBox( // color: Colors.white,
widthFactor: 0.9, decoration: BoxDecoration(
child: SingleChildScrollView( shape: BoxShape.rectangle,
child: Column( color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
topRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
bottomLeft: projectViewModel.isArabic ? Radius.zero : Radius.circular(12.0),
bottomRight: projectViewModel.isArabic ? Radius.circular(12.0) : Radius.zero,
),
),
// clipBehavior: Clip.antiAlias,
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context).OrderStatus +
' ' +
(projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].descriptionN : widget.model.cmcAllOrderDetail[0].description),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
color: Color(0xffcd9e1b),
fontWeight: FontWeight.w700,
),
),
mHeight(12),
Text(
TranslationBase.of(context).requestID + ' ' + widget.model.cmcAllOrderDetail[0].iD.toString(),
style: TextStyle(
fontSize: 16,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
Text(
TranslationBase.of(context).serviceName,
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w500,
),
),
Text(
!projectViewModel.isArabic ? widget.model.cmcAllOrderDetail[0].description.toString() : widget.model.cmcAllOrderDetail[0].descriptionN.toString(),
style: TextStyle(
fontSize: 12,
letterSpacing: -0.48,
fontWeight: FontWeight.w700,
),
),
],
),
),
Column(
children: [ children: [
Container( Text(
width: double.infinity, DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(widget.model.cmcAllOrderDetail[0].createdOn)),
margin: EdgeInsets.only(top: 15), style: TextStyle(
decoration: BoxDecoration( fontSize: 12,
border: Border.all( letterSpacing: -0.48,
color: Colors.grey, width: 1), fontWeight: FontWeight.w700,
borderRadius:
BorderRadius.circular(12),
color:
Theme.of(context).primaryColor),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
height: 12,
),
Container(
width: double.infinity,
padding: EdgeInsets.only(
left: 15,
bottom: 15,
top: 15,
right: 15),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
// borderRadius: BorderRadius.circular(12),
color: Theme.of(context)
.primaryColor),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context)
.requestID,
bold: false,
fontSize: 13,
),
SizedBox(
height: 4,
),
Texts(
widget.model
.cmcAllOrderDetail[0].iD
.toString(),
fontSize: 22,
),
],
),
),
Container(
width: double.infinity,
padding: EdgeInsets.only(
left: 15,
bottom: 15,
top: 15,
right: 15),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
// borderRadius: BorderRadius.circular(12),
color: Theme.of(context)
.primaryColor),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context)
.OrderStatus,
bold: false,
fontSize: 13,
),
SizedBox(
height: 4,
),
Texts(
projectViewModel.isArabic
? widget
.model
.cmcAllOrderDetail[0]
.descriptionN
: widget
.model
.cmcAllOrderDetail[0]
.description,
fontSize: 22,
),
],
),
),
Container(
width: double.infinity,
padding: EdgeInsets.only(
left: 15,
bottom: 15,
top: 15,
right: 15),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
// borderRadius: BorderRadius.circular(12),
color: Theme.of(context)
.primaryColor),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context)
.pickupDate,
bold: false,
fontSize: 13,
),
SizedBox(
height: 4,
),
Texts(
DateUtil.getDayMonthYearDateFormatted(
DateUtil.convertStringToDate(
widget
.model
.cmcAllOrderDetail[
0]
.createdOn)),
fontSize: 22,
),
],
),
),
Container(
width: double.infinity,
padding: EdgeInsets.only(
left: 15, bottom: 15, top: 15),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
// borderRadius: BorderRadius.circular(12),
color: Theme.of(context)
.primaryColor),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Texts(
TranslationBase.of(context)
.serviceName,
bold: false,
fontSize: 13,
),
SizedBox(
height: 4,
),
Texts(
!projectViewModel.isArabic
? widget
.model
.cmcAllOrderDetail[0]
.description
.toString()
: widget
.model
.cmcAllOrderDetail[0]
.descriptionN
.toString(),
fontSize: 22,
),
],
),
),
SizedBox(
height: 12,
),
Center(
child: Container(
width: MediaQuery.of(context)
.size
.width *
0.85,
child: SecondaryButton(
label: TranslationBase.of(
context)
.cancel
.toUpperCase(),
onTap: () {
showConfirmMessage(
widget.model,
widget.model
.cmcAllOrderDetail[0]);
},
color: Colors.red[800],
disabled: false,
textColor: Theme.of(context)
.backgroundColor),
),
),
SizedBox(
height: 22,
),
],
), ),
), ),
SizedBox( mHeight(8),
height: 22, SecondaryButton(
), onTap: () {
showConfirmMessage(widget.model, widget.model.cmcAllOrderDetail[0]);
},
label: TranslationBase.of(context).cancel,
color: Colors.red[900],
small: true,
)
], ],
), ),
), ],
) ),
: Container(
color: Colors.red,
child: NewCMCStepOnePage(
changePageViewIndex: changePageViewIndex,
cMCInsertPresOrderRequestModel:
cMCInsertPresOrderRequestModel,
model: widget.model,
),
), ),
NewCMCStepTowPage( ),
longitude: _longitude,
latitude: _latitude,
changePageViewIndex: changePageViewIndex,
cmcInsertPresOrderRequestModel:
cMCInsertPresOrderRequestModel,
model: widget.model,
),
NewCMCStepThreePage(
changePageViewIndex: changePageViewIndex,
cmcInsertPresOrderRequestModel:
cMCInsertPresOrderRequestModel,
model: widget.model,
), ),
], ],
)
: Container(
color: Colors.red,
child: NewCMCStepOnePage(
changePageViewIndex: changePageViewIndex,
cMCInsertPresOrderRequestModel: cMCInsertPresOrderRequestModel,
model: widget.model,
latitude: _latitude,
longitude: _longitude,
),
), ),
),
],
),
), ),
), ),
), ),

@ -14,12 +14,16 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'new_cmc_step_tow_page.dart';
class NewCMCStepOnePage extends StatefulWidget { class NewCMCStepOnePage extends StatefulWidget {
final CMCInsertPresOrderRequestModel cMCInsertPresOrderRequestModel; final CMCInsertPresOrderRequestModel cMCInsertPresOrderRequestModel;
final Function changePageViewIndex; final Function changePageViewIndex;
final CMCViewModel model; final CMCViewModel model;
const NewCMCStepOnePage({Key key, this.cMCInsertPresOrderRequestModel, this.model, this.changePageViewIndex}) : super(key: key); final double latitude;
final double longitude;
const NewCMCStepOnePage({Key key, this.cMCInsertPresOrderRequestModel, this.model, this.changePageViewIndex,this.latitude,this.longitude}) : super(key: key);
@override @override
_NewCMCStepOnePageState createState() => _NewCMCStepOnePageState(); _NewCMCStepOnePageState createState() => _NewCMCStepOnePageState();
@ -178,7 +182,13 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
if (widget.model.state == ViewState.ErrorLocal) { if (widget.model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(); Utils.showErrorToast();
} else { } else {
widget.changePageViewIndex(1); navigateTo(context,NewCMCStepTowPage(
longitude: widget.longitude,
latitude: widget.latitude,
cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel,
model: widget.model,
));
// widget.changePageViewIndex(1);
} }
} }
}, },

@ -2,9 +2,13 @@ import 'dart:async';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/Dialog/confirm_dialog.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -15,14 +19,9 @@ import 'package:provider/provider.dart';
class NewCMCStepThreePage extends StatefulWidget { class NewCMCStepThreePage extends StatefulWidget {
final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel; final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel;
final Function changePageViewIndex;
final CMCViewModel model; final CMCViewModel model;
NewCMCStepThreePage( NewCMCStepThreePage({Key key, this.model, this.cmcInsertPresOrderRequestModel});
{Key key,
this.changePageViewIndex,
this.model,
this.cmcInsertPresOrderRequestModel});
@override @override
_NewCMCStepThreePageState createState() => _NewCMCStepThreePageState(); _NewCMCStepThreePageState createState() => _NewCMCStepThreePageState();
@ -44,15 +43,12 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
markers.add( markers.add(
Marker( Marker(
markerId: MarkerId( markerId: MarkerId(
widget.cmcInsertPresOrderRequestModel.latitude.hashCode widget.cmcInsertPresOrderRequestModel.latitude.hashCode.toString(),
.toString(),
), ),
position: LatLng(widget.cmcInsertPresOrderRequestModel.latitude, position: LatLng(widget.cmcInsertPresOrderRequestModel.latitude, widget.cmcInsertPresOrderRequestModel.longitude)),
widget.cmcInsertPresOrderRequestModel.longitude)),
); );
_kGooglePlex = CameraPosition( _kGooglePlex = CameraPosition(
target: LatLng(widget.cmcInsertPresOrderRequestModel.latitude, target: LatLng(widget.cmcInsertPresOrderRequestModel.latitude, widget.cmcInsertPresOrderRequestModel.longitude),
widget.cmcInsertPresOrderRequestModel.longitude),
zoom: 14.4746, zoom: 14.4746,
); );
} }
@ -63,7 +59,15 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold( return AppScaffold(
isShowDecPage: false, isShowAppBar: true,
description: TranslationBase.of(context).infoCMC,
imagesInfo: [
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
],
appBarTitle: TranslationBase.of(context).comprehensiveMedicalCheckup,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGreyColor,
baseViewModel: widget.model, baseViewModel: widget.model,
body: SingleChildScrollView( body: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
@ -74,79 +78,93 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Text(
TranslationBase.of(context).orderDetails, TranslationBase.of(context).orderSummary,
fontWeight: FontWeight.bold, style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
letterSpacing: -0.46,
),
), ),
SizedBox( SizedBox(
height: 12, height: 12,
), ),
Container( Card(
decoration: BoxDecoration( shape: cardRadius(12),
color: Theme.of(context).primaryColor, elevation: 4,
borderRadius: BorderRadius.circular(12)), child: Container(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Texts( Text(
TranslationBase.of(context).orderLocation + " : ", TranslationBase.of(context).orderDetails + " : ",
fontWeight: FontWeight.bold, style: TextStyle(
), fontSize: 14,
SizedBox( fontWeight: FontWeight.bold,
height: 12, letterSpacing: -0.46,
), color: CustomColors.grey,
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: 200,
child: GoogleMap(
mapType: MapType.normal,
markers: markers,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
), ),
), ),
), SizedBox(
SizedBox( height: 6,
height: 12, ),
), Padding(
Texts(TranslationBase.of(context).selectedService), padding: const EdgeInsets.all(8.0),
...List.generate( child: Container(
widget.cmcInsertPresOrderRequestModel height: 200,
.patientERCMCInsertServicesList.length, decoration: containerColorRadiusBorder(Colors.white, 12, Colors.grey),
(index) => Container( clipBehavior: Clip.antiAlias,
child: Column( child: Card(
crossAxisAlignment: CrossAxisAlignment.start, shape: cardRadius(12),
children: [ clipBehavior: Clip.antiAlias,
Texts( elevation: 0,
TranslationBase.of(context).serviceName, margin: const EdgeInsets.all(0),
fontSize: 12, child: GoogleMap(
fontWeight: FontWeight.bold, mapType: MapType.normal,
), markers: markers,
SizedBox( initialCameraPosition: _kGooglePlex,
height: 5, onMapCreated: (GoogleMapController controller) {
), _controller.complete(controller);
Texts( },
projectViewModel.isArabic
? widget
.cmcInsertPresOrderRequestModel
.patientERCMCInsertServicesList[index]
.selectedServiceNameAR
: widget
.cmcInsertPresOrderRequestModel
.patientERCMCInsertServicesList[index]
.selectedServiceName,
fontSize: 15,
bold: true,
), ),
], ),
),
),
SizedBox(
height: 12,
),
Text(
TranslationBase.of(context).selectedService,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
letterSpacing: -0.46,
color: CustomColors.grey,
), ),
), ),
) ...List.generate(
], widget.cmcInsertPresOrderRequestModel.patientERCMCInsertServicesList.length,
(index) => Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
projectViewModel.isArabic
? widget.cmcInsertPresOrderRequestModel.patientERCMCInsertServicesList[index].selectedServiceNameAR
: widget.cmcInsertPresOrderRequestModel.patientERCMCInsertServicesList[index].selectedServiceName,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
letterSpacing: -0.46,
),
),
],
),
),
)
],
),
), ),
) )
], ],
@ -156,18 +174,30 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
bottomSheet: Container( bottomSheet: Container(
height: MediaQuery.of(context).size.height * 0.10, height: MediaQuery.of(context).size.height * 0.10,
width: double.infinity, width: double.infinity,
color: Colors.white,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Container( Container(
width: MediaQuery.of(context).size.width * 0.9, width: MediaQuery.of(context).size.width * 0.9,
child: SecondaryButton( child: SecondaryButton(
label: TranslationBase.of(context).confirm, label: TranslationBase.of(context).confirm,
color: Colors.grey[800], color: CustomColors.green,
onTap: () async { onTap: () async {
await widget.model.insertPresPresOrder( String requestId = await widget.model.insertPresPresOrder(order: widget.cmcInsertPresOrderRequestModel);
order: widget.cmcInsertPresOrderRequestModel);
if (widget.model.state != ViewState.ErrorLocal) { if (widget.model.state != ViewState.ErrorLocal) {
widget.changePageViewIndex(0); //show scuccess dialog
showCMCConfirmDialog(
context,
requestId,
onClick: () {
Navigator.pop(context);
Navigator.pop(context);
},
);
} else {
} }
}, },
textColor: Theme.of(context).backgroundColor), textColor: Theme.of(context).backgroundColor),

@ -1,9 +1,14 @@
import 'dart:async';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_insert_pres_order_request_model.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/cmc_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/select_location_dialog.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/location_page.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -18,24 +23,16 @@ import 'package:google_maps_place_picker/google_maps_place_picker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'cmc_location_page.dart'; import 'cmc_location_page.dart';
import 'new_cmc_step_three_page.dart';
class NewCMCStepTowPage extends StatefulWidget { class NewCMCStepTowPage extends StatefulWidget {
final Function(PickResult) onPick; final Function(PickResult) onPick;
final double latitude; final double latitude;
final double longitude; final double longitude;
final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel; final CMCInsertPresOrderRequestModel cmcInsertPresOrderRequestModel;
final Function changePageViewIndex;
final CMCViewModel model; final CMCViewModel model;
const NewCMCStepTowPage( const NewCMCStepTowPage({Key key, this.onPick, this.latitude, this.longitude, this.cmcInsertPresOrderRequestModel, this.model}) : super(key: key);
{Key key,
this.onPick,
this.latitude,
this.longitude,
this.cmcInsertPresOrderRequestModel,
this.changePageViewIndex,
this.model})
: super(key: key);
@override @override
_NewCMCStepTowPageState createState() => _NewCMCStepTowPageState(); _NewCMCStepTowPageState createState() => _NewCMCStepTowPageState();
@ -47,6 +44,14 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
AddressInfo _selectedAddress; AddressInfo _selectedAddress;
bool showCurrentLocation = false; bool showCurrentLocation = false;
Completer<GoogleMapController> _controller = Completer();
static CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
final Set<Marker> markers = new Set();
@override @override
void initState() { void initState() {
if (widget.cmcInsertPresOrderRequestModel.latitude == null) { if (widget.cmcInsertPresOrderRequestModel.latitude == null) {
@ -54,29 +59,43 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
} else { } else {
latitude = widget.cmcInsertPresOrderRequestModel.latitude; latitude = widget.cmcInsertPresOrderRequestModel.latitude;
longitude = widget.cmcInsertPresOrderRequestModel.longitude; longitude = widget.cmcInsertPresOrderRequestModel.longitude;
setMap();
} }
super.initState(); super.initState();
} }
setLatitudeAndLongitude({bool isSetState = false, String latLong}) async { setMap() {
if (latLong == null){ markers.clear();
if(widget.model.addressesList.isEmpty) { markers.add(
Marker(
markerId: MarkerId(
latitude.hashCode.toString(),
),
position: LatLng(latitude, longitude)),
);
_kGooglePlex = CameraPosition(
target: LatLng(latitude, longitude),
zoom: 14.4746,
);
}
setLatitudeAndLongitude({bool isSetState = false, String latLong}) async {
if (latLong == null) {
if (widget.model.addressesList.isEmpty) {
setState(() { setState(() {
showCurrentLocation = true; showCurrentLocation = true;
}); });
} else { } else {
latLong = widget latLong = widget.model.addressesList[widget.model.addressesList.length - 1].latLong;
.model.addressesList[widget.model.addressesList.length - 1].latLong;
} }
} }
if(!showCurrentLocation) { if (!showCurrentLocation) {
List latLongArr = latLong.split(','); List latLongArr = latLong.split(',');
latitude = double.parse(latLongArr[0]); latitude = double.parse(latLongArr[0]);
longitude = double.parse(latLongArr[1]); longitude = double.parse(latLongArr[1]);
setMap();
} }
} }
@ -84,113 +103,119 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return AppScaffold( return AppScaffold(
isShowDecPage: false, isShowAppBar: true,
body: Stack( description: TranslationBase.of(context).infoCMC,
imagesInfo: [
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
],
appBarTitle: TranslationBase.of(context).comprehensiveMedicalCheckup,
showNewAppBar: true,
showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGreyColor,
body: Column(
children: [ children: [
PlacePicker( if (widget.model.addressesList.isNotEmpty)
apiKey: GOOGLE_API_KEY, Card(
enableMyLocationButton: true, margin: EdgeInsets.only(left: 12, right: 12, bottom: 12),
automaticallyImplyAppBarLeading: false, shape: cardRadius(12),
autocompleteOnTrailingWhitespace: true, elevation: 3,
selectInitialPosition: true,
autocompleteLanguage: projectViewModel.currentLanguage,
enableMapTypeButton: true,
searchForInitialValue: false,
onPlacePicked: (PickResult result) {
print(result.adrAddress);
widget.changePageViewIndex(3);
},
selectedPlaceWidgetBuilder:
(_, selectedPlace, state, isSearchBarFocused) {
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
return isSearchBarFocused
? Container()
: FloatingCard(
bottomPosition: 0.0,
leftPosition: 0.0,
rightPosition: 0.0,
width: 500,
borderRadius: BorderRadius.circular(12.0),
child: state == SearchingState.Searching
? Center(child: CircularProgressIndicator())
: Container(
margin: EdgeInsets.all(12),
child: Column(
children: [
SecondaryButton(
color: Colors.grey[800],
textColor: Colors.white,
onTap: () {
Navigator.push(
context,
FadePage(
page: CMCLocationPage(
latitude: latitude,
longitude: longitude,
),
),
);
},
label: TranslationBase.of(context)
.addNewAddress,
),
SizedBox(
height: 10,
),
SecondaryButton(
color: Colors.red[800],
textColor: Colors.white,
onTap: () {
setState(() {
widget.cmcInsertPresOrderRequestModel
.latitude =
selectedPlace.geometry.location.lat;
widget.cmcInsertPresOrderRequestModel
.longitude =
selectedPlace.geometry.location.lng;
});
widget.changePageViewIndex(3);
},
label: TranslationBase.of(context).confirm,
),
],
)),
);
},
initialPosition: LatLng(latitude, longitude),
useCurrentLocation: showCurrentLocation,
),
if(widget.model.addressesList.isNotEmpty)
Container(
child: InkWell(
onTap: () =>
confirmSelectLocationDialog(widget.model.addressesList),
child: Container( child: Container(
padding: EdgeInsets.all(10), child: InkWell(
width: double.infinity, onTap: () => confirmSelectLocationDialog(widget.model.addressesList),
// height: 65, child: Container(
decoration: BoxDecoration( padding: EdgeInsets.all(8),
borderRadius: BorderRadius.circular(10), width: double.infinity,
color: Theme.of(context).primaryColor), // height: 65,
child: Row( decoration: BoxDecoration(
mainAxisAlignment: MainAxisAlignment.spaceBetween, borderRadius: BorderRadius.circular(10),
children: [ color: Colors.white,
Expanded( ),
child: Texts( child: Row(
getAddressName(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
fontSize: 14, children: [
), Expanded(
child: Text(
getAddressName(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.45,
),
),
),
Icon(Icons.arrow_drop_down)
],
), ),
Icon(Icons.arrow_drop_down) ),
],
), ),
height: 50,
width: double.infinity,
),
),
InkWell(
onTap: () {
Navigator.push(
context,
FadePage(
page: CMCLocationPage(
latitude: latitude,
longitude: longitude,
),
),
);
},
child: Padding(
padding: EdgeInsets.only(left: 12, right: 12, bottom: 16, top: 8),
child: Row(
children: [
Icon(Icons.add_circle_outline_sharp),
mWidth(12),
Text(
TranslationBase.of(context).addNewAddress,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: -0.46,
),
),
],
), ),
), ),
height: 56, ),
width: double.infinity, Expanded(
color: Theme.of(context).scaffoldBackgroundColor, child: GoogleMap(
) mapType: MapType.normal,
markers: markers,
zoomControlsEnabled: false,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
),
Padding(
padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
child: SecondaryButton(
color: Colors.red[800],
textColor: Colors.white,
onTap: () {
setState(() {
widget.cmcInsertPresOrderRequestModel.latitude = latitude;
widget.cmcInsertPresOrderRequestModel.longitude = longitude;
});
// widget.changePageViewIndex(3);
navigateTo(
context,
NewCMCStepThreePage(
cmcInsertPresOrderRequestModel: widget.cmcInsertPresOrderRequestModel,
model: widget.model,
),
);
},
label: TranslationBase.of(context).continues,
),
),
], ],
), ),
); );

@ -10,8 +10,7 @@ class SelectLocationDialog extends StatefulWidget {
final Function(AddressInfo) onValueSelected; final Function(AddressInfo) onValueSelected;
AddressInfo selectedAddress; AddressInfo selectedAddress;
SelectLocationDialog( SelectLocationDialog({Key key, this.addresses, this.onValueSelected, this.selectedAddress});
{Key key, this.addresses, this.onValueSelected, this.selectedAddress});
@override @override
_SelectLocationDialogState createState() => _SelectLocationDialogState(); _SelectLocationDialogState createState() => _SelectLocationDialogState();
@ -27,7 +26,14 @@ class _SelectLocationDialogState extends State<SelectLocationDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SimpleDialog( return SimpleDialog(
title: Texts(TranslationBase.of(context).selectAddress), title: Text(
TranslationBase.of(context).selectAddress,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: -0.46,
),
),
children: [ children: [
Column( Column(
children: [ children: [
@ -39,7 +45,7 @@ class _SelectLocationDialogState extends State<SelectLocationDialog> {
Divider(), Divider(),
...List.generate( ...List.generate(
widget.addresses.length, widget.addresses.length,
(index) => Column( (index) => Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
@ -56,7 +62,13 @@ class _SelectLocationDialogState extends State<SelectLocationDialog> {
}); });
}, },
child: ListTile( child: ListTile(
title: Text(widget.addresses[index].address1), title: Text(
widget.addresses[index].address1,
style: TextStyle(
fontWeight: FontWeight.w600,
letterSpacing: -0.46,
),
),
leading: Radio( leading: Radio(
value: widget.addresses[index], value: widget.addresses[index],
groupValue: widget.selectedAddress, groupValue: widget.selectedAddress,
@ -98,9 +110,14 @@ class _SelectLocationDialogState extends State<SelectLocationDialog> {
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
child: Center( child: Center(
child: Texts( child: Text(
TranslationBase.of(context).cancel.toUpperCase(), TranslationBase.of(context).cancel.toUpperCase(),
color: Colors.red, style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: -0.46,
color: Colors.red,
),
), ),
), ),
), ),
@ -122,10 +139,14 @@ class _SelectLocationDialogState extends State<SelectLocationDialog> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Center( child: Center(
child: Texts( child: Text(
TranslationBase.of(context).ok, TranslationBase.of(context).ok.toUpperCase(),
fontWeight: FontWeight.w400, style: TextStyle(
)), fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: -0.46,
),
)),
), ),
), ),
), ),

@ -163,7 +163,7 @@ class _AppDrawerState extends State<AppDrawer> {
} else { } else {
projectProvider.changeLanguage('ar'); projectProvider.changeLanguage('ar');
} }
var themeNotifier = Provider.of<ThemeNotifier>(context, listen: true); var themeNotifier = Provider.of<ThemeNotifier>(context, listen: false);
themeNotifier.setTheme(defaultTheme(fontName: projectProvider.isArabic ? 'Cairo' : 'Poppins')); themeNotifier.setTheme(defaultTheme(fontName: projectProvider.isArabic ? 'Cairo' : 'Poppins'));
}, },
), ),

Loading…
Cancel
Save