CMC error Fixes

merge-update-with-lab-changes
Mirza.Shafique 5 years ago
parent 062ca5c11c
commit 5e383e57d9

@ -23,6 +23,7 @@ class NewCMCStepOnePage extends StatefulWidget {
final double latitude; final double latitude;
final double longitude; final double longitude;
const NewCMCStepOnePage({Key key, this.cMCInsertPresOrderRequestModel, this.model, this.changePageViewIndex, this.latitude, this.longitude}) : super(key: key); const NewCMCStepOnePage({Key key, this.cMCInsertPresOrderRequestModel, this.model, this.changePageViewIndex, this.latitude, this.longitude}) : super(key: key);
@override @override
@ -30,6 +31,7 @@ class NewCMCStepOnePage extends StatefulWidget {
} }
class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> { class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
int selectedItem=0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -60,6 +62,7 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
value: widget.model.cmcAllServicesList[index].serviceID, value: widget.model.cmcAllServicesList[index].serviceID,
activeColor: Colors.red[800], activeColor: Colors.red[800],
onChanged: (newValue) async { onChanged: (newValue) async {
selectedItem=index;
PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
price: widget.model.cmcAllServicesList[index].price, price: widget.model.cmcAllServicesList[index].price,
serviceID: widget.model.cmcAllServicesList[index].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[index].serviceID.toString(),
@ -71,8 +74,8 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
setState(() { setState(() {
widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
}); });
CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: newValue); // CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: newValue);
await widget.model.getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel); // await widget.model.getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel);
}, },
groupValue: widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length > 0 groupValue: widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length > 0
? int.parse(widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList[0].serviceID) ? int.parse(widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList[0].serviceID)
@ -102,7 +105,10 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
return mDivider(Colors.grey); return mDivider(Colors.grey);
}, },
itemCount: widget.model.cmcAllServicesList.length), itemCount: widget.model.cmcAllServicesList.length),
Image.asset(projectViewModel.isArabic?"assets/images/cc_ar.png":"assets/images/cc_en.png",width: double.infinity,), Image.asset(
projectViewModel.isArabic ? "assets/images/cc_ar.png" : "assets/images/cc_en.png",
width: double.infinity,
),
// Card( // Card(
// shape: cardRadius(12), // shape: cardRadius(12),
// elevation: 4, // elevation: 4,
@ -158,15 +164,16 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
TranslationBase.of(context).next, TranslationBase.of(context).next,
() async { () async {
if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length != 0 || widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList == null) { if (widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList.length != 0 || widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList == null) {
int index = widget.model.cmcAllServicesList.length; // int index = widget.model.cmcAllServicesList.length;
PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
price: widget.model.cmcAllServicesList[index - 1].price, price: widget.model.cmcAllServicesList[selectedItem].price,
serviceID: widget.model.cmcAllServicesList[index - 1].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[selectedItem].serviceID.toString(),
selectedServiceName: widget.model.cmcAllServicesList[index - 1].description, selectedServiceName: widget.model.cmcAllServicesList[selectedItem].description,
selectedServiceNameAR: widget.model.cmcAllServicesList[index - 1].descriptionN, selectedServiceNameAR: widget.model.cmcAllServicesList[selectedItem].descriptionN,
recordID: 1, recordID: 1,
totalPrice: widget.model.cmcAllServicesList[index - 1].totalPrice, totalPrice: widget.model.cmcAllServicesList[selectedItem].totalPrice,
vAT: widget.model.cmcAllServicesList[index - 1].vAT); vAT: widget.model.cmcAllServicesList[selectedItem].vAT,
);
widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
await widget.model.getCustomerInfo(); await widget.model.getCustomerInfo();
@ -180,8 +187,8 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
latitude: widget.latitude, latitude: widget.latitude,
cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel, cmcInsertPresOrderRequestModel: widget.cMCInsertPresOrderRequestModel,
model: widget.model, model: widget.model,
)); ),
// widget.changePageViewIndex(1); );
} }
} }
}, },

@ -56,29 +56,47 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
if (await this.sharedPref.getDouble(USER_LAT) != null && await this.sharedPref.getDouble(USER_LONG) != null) { if (await this.sharedPref.getDouble(USER_LAT) != null && await this.sharedPref.getDouble(USER_LONG) != null) {
var lat = await this.sharedPref.getDouble(USER_LAT); var lat = await this.sharedPref.getDouble(USER_LAT);
var long = await this.sharedPref.getDouble(USER_LONG); var long = await this.sharedPref.getDouble(USER_LONG);
latitude = lat;
longitude = long;
currentPostion = LatLng(lat, long); currentPostion = LatLng(lat, long);
setMap(); setMap();
} else { } else {
if (await Permission.location.request().isGranted) { if (await Permission.location.request().isGranted) {
var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low); var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
currentPostion = LatLng(position.latitude, position.longitude); currentPostion = LatLng(position.latitude, position.longitude);
latitude = position.latitude;
longitude = position.longitude;
setMap(); setMap();
} else { } else {
requestPermissions().then((value) async { requestPermissions().then(
(value) async {
if (value[Permission.location].isGranted) { if (value[Permission.location].isGranted) {
var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low); var position = await GeolocatorPlatform.instance.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
currentPostion = LatLng(position.latitude, position.longitude); currentPostion = LatLng(position.latitude, position.longitude);
latitude = position.latitude;
longitude = position.longitude;
setMap(); setMap();
} }
}); },
);
} }
} }
} }
@override @override
void initState() { void initState() {
_getUserLocation();
super.initState(); super.initState();
appMap = AppMap(
cameraPosition.toMap(),
onCameraMove: (camera) {
setState(() {});
_updatePosition(camera);
},
onMapCreated: () {
print("_getUserLocation");
_getUserLocation();
},
);
} }
setMap() { setMap() {
@ -87,7 +105,7 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
target: currentPostion, target: currentPostion,
zoom: 14.4746, zoom: 14.4746,
); );
appMap.moveTo(cameraPostion: cameraPosition); if (appMap != null) appMap.moveTo(cameraPostion: cameraPosition);
}); });
} }
@ -125,6 +143,7 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
} }
AppMap appMap; AppMap appMap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -181,7 +200,6 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
), ),
InkWell( InkWell(
onTap: () async { onTap: () async {
bool isNeedToUpdate = false; bool isNeedToUpdate = false;
await Navigator.of(context).push(new MaterialPageRoute<dynamic>( await Navigator.of(context).push(new MaterialPageRoute<dynamic>(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -225,9 +243,7 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
appMap = AppMap(cameraPosition.toMap(), onCameraMove: (camera){ if (appMap != null) appMap,
_updatePosition(camera);
}),
Icon( Icon(
Icons.place, Icons.place,
color: CustomColors.accentColor, color: CustomColors.accentColor,

@ -1,4 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -7,19 +6,18 @@ import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:huawei_map/map.dart' as hmsMap; import 'package:huawei_map/map.dart' as hmsMap;
class AppMap extends StatefulWidget { class AppMap extends StatefulWidget {
CameraPositionCallback onCameraMove; CameraPositionCallback onCameraMove;
Map initialCamera; Map initialCamera;
AppMapState _state; AppMapState _state;
Function onMapCreated;
AppMap(this.initialCamera, {this.onCameraMove}); AppMap(this.initialCamera, {this.onCameraMove, this.onMapCreated});
@override @override
State<StatefulWidget> createState() => _state = AppMapState(); State<StatefulWidget> createState() => _state = AppMapState();
moveTo({@required CameraPosition cameraPostion}) { moveTo({@required CameraPosition cameraPostion}) {
if (_state.isHuawei) { if (_state.isHuawei) {
final cameraJson = cameraPostion.toMap(); final cameraJson = cameraPostion.toMap();
@ -32,8 +30,7 @@ class AppMap extends StatefulWidget{
} }
class AppMapState extends State<AppMap> { class AppMapState extends State<AppMap> {
bool isHuawei = false;
bool isHuawei;
Completer<GoogleMapController> _googleMapControllerComp = Completer(); Completer<GoogleMapController> _googleMapControllerComp = Completer();
GoogleMapController googleMapController; GoogleMapController googleMapController;
@ -45,6 +42,7 @@ class AppMapState extends State<AppMap>{
isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable; isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable;
setState(() {}); setState(() {});
} }
@override @override
void initState() { void initState() {
checkIsHuawei(); checkIsHuawei();
@ -52,17 +50,14 @@ class AppMapState extends State<AppMap>{
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if(isHuawei == null) if (isHuawei == null) return CircularProgressIndicator();
return CircularProgressIndicator();
return map(); return map();
} }
Widget map() => isHuawei ? huaweiMap() : googleMap(); Widget map() => isHuawei ? huaweiMap() : googleMap();
Widget googleMap() {
googleMap(){ return GoogleMap(
return
GoogleMap(
mapType: MapType.normal, mapType: MapType.normal,
zoomControlsEnabled: false, zoomControlsEnabled: false,
myLocationButtonEnabled: true, myLocationButtonEnabled: true,
@ -72,6 +67,7 @@ class AppMapState extends State<AppMap>{
onMapCreated: (GoogleMapController controller) { onMapCreated: (GoogleMapController controller) {
googleMapController = controller; googleMapController = controller;
_googleMapControllerComp.complete(controller); _googleMapControllerComp.complete(controller);
widget.onMapCreated();
}, },
); );
} }
@ -87,8 +83,8 @@ class AppMapState extends State<AppMap>{
onMapCreated: (controller) { onMapCreated: (controller) {
_huaweiMapController = controller; _huaweiMapController = controller;
_huaweiMapControllerComp.complete(controller); _huaweiMapControllerComp.complete(controller);
widget.onMapCreated();
}, },
); );
} }
} }
Loading…
Cancel
Save