DateTime Fixes

merge-requests/599/merge
haroon amjad 4 years ago
parent a9e48e487f
commit 842e099953

@ -395,7 +395,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnar
var CHANNEL = 3; var CHANNEL = 3;
var GENERAL_ID = 'Cs2020@2016\$2958'; var GENERAL_ID = 'Cs2020@2016\$2958';
var IP_ADDRESS = '10.20.10.20'; var IP_ADDRESS = '10.20.10.20';
var VERSION_ID = 8.0; var VERSION_ID = 8.2;
var SETUP_ID = '91877'; var SETUP_ID = '91877';
var LANGUAGE = 2; var LANGUAGE = 2;
var PATIENT_OUT_SA = 0; var PATIENT_OUT_SA = 0;

@ -132,7 +132,7 @@ class BaseAppClient {
// body['IdentificationNo'] = 2076117163; // body['IdentificationNo'] = 2076117163;
// body['MobileNo'] = "966503109207"; // body['MobileNo'] = "966503109207";
// body['PatientID'] = 3628809; //3844083 // body['PatientID'] = 793807; //3844083
// body['TokenID'] = "@dm!n"; // body['TokenID'] = "@dm!n";
// Patient ID: 3027574 // Patient ID: 3027574
@ -141,11 +141,11 @@ class BaseAppClient {
body.removeWhere((key, value) => key == null || value == null); body.removeWhere((key, value) => key == null || value == null);
// if (BASE_URL == "https://uat.hmgwebservices.com/") { if (BASE_URL == "https://uat.hmgwebservices.com/") {
print("URL : $url"); print("URL : $url");
final jsonBody = json.encode(body); final jsonBody = json.encode(body);
print(jsonBody); print(jsonBody);
// } }
if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) { if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) {
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers);

@ -0,0 +1,23 @@
class LocationDetails {
double _lat;
double _long;
String _formattedAddress;
double get lat => _lat;
set lat(double lat) {
_lat = lat;
}
double get long => _long;
set long(double long) {
_long = long;
}
String get formattedAddress => _formattedAddress;
set formattedAddress(String formattedAddress) {
_formattedAddress = formattedAddress;
}
}

@ -1,18 +1,28 @@
import 'dart:io';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/add_new_address_Request_Model.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/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.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/widgets/app_map/google_huawei_map.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart';
import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart'; import 'package:google_maps_place_picker/google_maps_place_picker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -23,7 +33,6 @@ class CMCLocationPage extends StatefulWidget {
final double longitude; final double longitude;
final dynamic model; final dynamic model;
const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) : super(key: key); const CMCLocationPage({Key key, this.onPick, this.latitude, this.longitude, this.model}) : super(key: key);
@override @override
@ -35,10 +44,40 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
double longitude = 0; double longitude = 0;
bool showCurrentLocation = false; bool showCurrentLocation = false;
Function onPick; Function onPick;
bool isHuawei = false;
Placemark selectedPlace;
AppMap appMap;
static CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
LatLng currentPostion;
AppSharedPreferences sharedPref = AppSharedPreferences();
@override @override
void initState() { void initState() {
onPick=widget.onPick; checkIsHuawei();
appMap = AppMap(
_kGooglePlex.toMap(),
onCameraMove: (camera) {
_updatePosition(camera);
},
onMapCreated: () {
currentPostion = LatLng(widget.latitude, widget.longitude);
latitude = widget.latitude;
longitude = widget.longitude;
_getUserLocation();
setState(() {});
},
onCameraIdle: () async {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
selectedPlace = placemarks[0];
print(selectedPlace);
},
);
onPick = widget.onPick;
latitude = widget.latitude; latitude = widget.latitude;
longitude = widget.longitude; longitude = widget.longitude;
if (latitude == 0.0 && longitude == 0.0) { if (latitude == 0.0 && longitude == 0.0) {
@ -47,6 +86,12 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
super.initState(); super.initState();
} }
checkIsHuawei() async {
isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable;
print(isHuawei);
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -65,89 +110,194 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'), 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).addNewAddress, appBarTitle: TranslationBase.of(context).addNewAddress,
body: PlacePicker( body: isHuawei
apiKey: GOOGLE_API_KEY, ? Column(
enableMyLocationButton: true, children: [
automaticallyImplyAppBarLeading: false, Expanded(
autocompleteOnTrailingWhitespace: true, child: Stack(
selectInitialPosition: true, alignment: Alignment.center,
autocompleteLanguage: projectViewModel.currentLanguage, children: [
enableMapTypeButton: true, if (appMap != null) appMap,
searchForInitialValue: false, Container(
onPlacePicked: (PickResult result) { margin: EdgeInsets.only(bottom: 50.0),
print(result.adrAddress); child: Icon(
}, Icons.place,
selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { color: CustomColors.accentColor,
print("state: $state, isSearchBarFocused: $isSearchBarFocused"); size: 50,
),
return isSearchBarFocused ),
? Container() ],
: FloatingCard( ),
bottomPosition: 0.0, ),
leftPosition: 0.0, Container(
rightPosition: 0.0, padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
width: 500, child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
borderRadius: BorderRadius.circular(12.0), AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
child: state == SearchingState.Searching customer: Customer(addresses: [
? Center(child: CircularProgressIndicator()) Addresses(
: Container( address1: selectedPlace.street,
margin: EdgeInsets.all(12), address2: selectedPlace.street,
child: Column( customerAttributes: "",
children: [ city: selectedPlace.administrativeArea,
SecondaryButton( createdOnUtc: "",
color: CustomColors.accentColor, id: "0",
textColor: Colors.white, faxNumber: "",
onTap: () async { phoneNumber: projectViewModel.user.mobileNumber,
print(selectedPlace); province: selectedPlace.administrativeArea,
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( countryId: 69,
customer: Customer( latLong: latitude.toStringAsFixed(6) + "," + longitude.toStringAsFixed(6),
addresses: [ country: selectedPlace.country,
Addresses( zipPostalCode: selectedPlace.postalCode,
address1: selectedPlace.formattedAddress, email: projectViewModel.user.emailAddress)
address2: selectedPlace.formattedAddress, ]),
customerAttributes: "", );
city: "", await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
createdOnUtc: "", if (model.state == ViewState.ErrorLocal) {
id: "0", Utils.showErrorToast(model.error);
latLong: selectedPlace.geometry.location.lat.toString() + "," + selectedPlace.geometry.location.lng.toString(), } else {
email: "", AppToast.showSuccessToast(message: "Address Added Successfully");
) }
], Navigator.of(context).pop(addNewAddressRequestModel);
}),
),
],
)
: PlacePicker(
apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true,
automaticallyImplyAppBarLeading: false,
autocompleteOnTrailingWhitespace: true,
selectInitialPosition: true,
autocompleteLanguage: projectViewModel.currentLanguage,
enableMapTypeButton: true,
searchForInitialValue: false,
onPlacePicked: (PickResult result) {
print(result.adrAddress);
},
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: CustomColors.accentColor,
textColor: Colors.white,
onTap: () async {
print(selectedPlace);
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
customer: Customer(
addresses: [
Addresses(
address1: selectedPlace.formattedAddress,
address2: selectedPlace.formattedAddress,
customerAttributes: "",
city: "",
createdOnUtc: "",
id: "0",
latLong: selectedPlace.geometry.location.lat.toString() + "," + selectedPlace.geometry.location.lng.toString(),
email: "",
)
],
),
);
selectedPlace.addressComponents.forEach((e) {
if (e.types.contains("country")) {
addNewAddressRequestModel.customer.addresses[0].country = e.longName;
}
if (e.types.contains("postal_code")) {
addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
}
if (e.types.contains("locality")) {
addNewAddressRequestModel.customer.addresses[0].city = e.longName;
}
});
await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
} else {
onPick();
AppToast.showSuccessToast(message: "Address Added Successfully");
}
Navigator.of(context).pop();
},
label: TranslationBase.of(context).addNewAddress,
), ),
); ],
),
selectedPlace.addressComponents.forEach((e) {
if (e.types.contains("country")) {
addNewAddressRequestModel.customer.addresses[0].country = e.longName;
}
if (e.types.contains("postal_code")) {
addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
}
if (e.types.contains("locality")) {
addNewAddressRequestModel.customer.addresses[0].city = e.longName;
}
});
await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
} else {
onPick();
AppToast.showSuccessToast(message: "Address Added Successfully");
}
Navigator.of(context).pop();
},
label: TranslationBase.of(context).addNewAddress,
), ),
], );
), },
), initialPosition: LatLng(latitude, longitude),
); useCurrentLocation: showCurrentLocation,
}, ),
initialPosition: LatLng(latitude, longitude),
useCurrentLocation: showCurrentLocation,
),
), ),
); );
} }
void _getUserLocation() async {
if (await this.sharedPref.getDouble(USER_LAT) != null && await this.sharedPref.getDouble(USER_LONG) != null) {
var lat = await this.sharedPref.getDouble(USER_LAT);
var long = await this.sharedPref.getDouble(USER_LONG);
latitude = lat;
longitude = long;
currentPostion = LatLng(lat, long);
setMap();
} else {
if (await PermissionService.isLocationEnabled()) {
Geolocator.getLastKnownPosition().then((value) {
latitude = value.latitude;
longitude = value.longitude;
currentPostion = LatLng(latitude, longitude);
setMap();
});
} else {
if (Platform.isAndroid) {
Utils.showPermissionConsentDialog(context, TranslationBase.of(context).locationPermissionDialog, () {
Geolocator.getLastKnownPosition().then((value) {
latitude = value.latitude;
longitude = value.longitude;
currentPostion = LatLng(latitude, longitude);
setMap();
});
});
} else {
Geolocator.getLastKnownPosition().then((value) {
latitude = value.latitude;
longitude = value.longitude;
setMap();
});
}
}
}
}
setMap() {
setState(() {
_kGooglePlex = CameraPosition(
target: currentPostion,
zoom: 14.4746,
);
appMap.moveTo(cameraPostion: _kGooglePlex);
});
}
void _updatePosition(CameraPosition _position) {
print(_position);
latitude = _position.target.latitude;
longitude = _position.target.longitude;
}
} }

@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
@ -9,6 +8,7 @@ import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/permission/permission_service.dart'; import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -18,6 +18,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart';
import 'package:geocoding/geocoding.dart'; import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
@ -43,6 +44,8 @@ class _LocationPageState extends State<LocationPage> {
GoogleMapController mapController; GoogleMapController mapController;
bool isHuawei = false;
AppMap appMap; AppMap appMap;
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
static CameraPosition _kGooglePlex = CameraPosition( static CameraPosition _kGooglePlex = CameraPosition(
@ -50,6 +53,7 @@ class _LocationPageState extends State<LocationPage> {
zoom: 14.4746, zoom: 14.4746,
); );
LatLng currentPostion; LatLng currentPostion;
// Completer<GoogleMapController> mapController = Completer(); // Completer<GoogleMapController> mapController = Completer();
Placemark selectedPlace; Placemark selectedPlace;
@ -57,6 +61,7 @@ class _LocationPageState extends State<LocationPage> {
void initState() { void initState() {
latitude = widget.latitude; latitude = widget.latitude;
longitude = widget.longitude; longitude = widget.longitude;
checkIsHuawei();
if (latitude == 0.0 && longitude == 0.0) { if (latitude == 0.0 && longitude == 0.0) {
showCurrentLocation = true; showCurrentLocation = true;
} }
@ -70,12 +75,12 @@ class _LocationPageState extends State<LocationPage> {
latitude = widget.latitude; latitude = widget.latitude;
longitude = widget.longitude; longitude = widget.longitude;
_getUserLocation(); _getUserLocation();
// setMap();
setState(() {}); setState(() {});
}, },
onCameraIdle: () async { onCameraIdle: () async {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude); List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
selectedPlace = placemarks[0]; selectedPlace = placemarks[0];
print(selectedPlace);
}, },
); );
super.initState(); super.initState();
@ -93,213 +98,136 @@ class _LocationPageState extends State<LocationPage> {
baseViewModel: model, baseViewModel: model,
showNewAppBarTitle: true, showNewAppBarTitle: true,
showNewAppBar: true, showNewAppBar: true,
body: body: isHuawei
// Column( ? Column(
// children: [ children: [
// Expanded( Expanded(
// child: Stack( child: Stack(
// alignment: Alignment.center, alignment: Alignment.center,
// children: [ children: [
// if (appMap != null) appMap, if (appMap != null) appMap,
// Container( Container(
// margin: EdgeInsets.only(bottom: 50.0), margin: EdgeInsets.only(bottom: 50.0),
// child: Icon( child: Icon(
// Icons.place, Icons.place,
// color: CustomColors.accentColor, color: CustomColors.accentColor,
// size: 50, size: 50,
// ), ),
// ), ),
// ], ],
// ), ),
// ), ),
// Container( Container(
// padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14), padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
// child: DefaultButton(TranslationBase.of(context).addNewAddress, () async { child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
// AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
// customer: Customer(addresses: [ customer: Customer(addresses: [
// Addresses( Addresses(
// address1: selectedPlace.name, address1: selectedPlace.street,
// address2: selectedPlace.street, address2: selectedPlace.street,
// customerAttributes: "", customerAttributes: "",
// city: selectedPlace.locality, city: selectedPlace.administrativeArea,
// createdOnUtc: "", createdOnUtc: "",
// id: "0", id: "0",
// faxNumber: "", faxNumber: "",
// phoneNumber: projectViewModel.user.mobileNumber, phoneNumber: projectViewModel.user.mobileNumber,
// province: selectedPlace.locality, province: selectedPlace.administrativeArea,
// countryId: 69, countryId: 69,
// latLong: "$latitude,$longitude", latLong: latitude.toStringAsFixed(6) + "," + longitude.toStringAsFixed(6),
// country: selectedPlace.country, country: selectedPlace.country,
// zipPostalCode: selectedPlace.postalCode, zipPostalCode: selectedPlace.postalCode,
// email: projectViewModel.user.emailAddress) email: projectViewModel.user.emailAddress)
// ]), ]),
// ); );
// await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel); await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
// if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
// Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
// } else { } else {
// AppToast.showSuccessToast(message: "Address Added Successfully"); AppToast.showSuccessToast(message: "Address Added Successfully");
// } }
// Navigator.of(context).pop(addNewAddressRequestModel); Navigator.of(context).pop(addNewAddressRequestModel);
// }), }),
// ), ),
// ], ],
// ), )
: PlacePicker(
PlacePicker( apiKey: GOOGLE_API_KEY,
apiKey: GOOGLE_API_KEY, enableMyLocationButton: true,
enableMyLocationButton: true, automaticallyImplyAppBarLeading: false,
automaticallyImplyAppBarLeading: false, autocompleteOnTrailingWhitespace: true,
autocompleteOnTrailingWhitespace: true, selectInitialPosition: true,
selectInitialPosition: true, autocompleteLanguage: projectViewModel.currentLanguage,
autocompleteLanguage: projectViewModel.currentLanguage, enableMapTypeButton: true,
enableMapTypeButton: true, searchForInitialValue: false,
searchForInitialValue: false, onMapCreated: (GoogleMapController controller) {
onMapCreated: (GoogleMapController controller) { mapController = controller;
mapController = controller; },
}, onPlacePicked: (PickResult result) {
onPlacePicked: (PickResult result) { print(result.adrAddress);
print(result.adrAddress); },
}, selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { print("state: $state, isSearchBarFocused: $isSearchBarFocused");
print("state: $state, isSearchBarFocused: $isSearchBarFocused"); return isSearchBarFocused
return isSearchBarFocused ? Container()
? Container() : FloatingCard(
: FloatingCard( bottomPosition: 0.0,
bottomPosition: 0.0, leftPosition: 0.0,
leftPosition: 0.0, rightPosition: 0.0,
rightPosition: 0.0, width: 500,
width: 500, borderRadius: BorderRadius.circular(0.0),
borderRadius: BorderRadius.circular(0.0), child: state == SearchingState.Searching
child: state == SearchingState.Searching ? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer : DefaultButton(TranslationBase.of(context).addNewAddress, () async {
: DefaultButton(TranslationBase.of(context).addNewAddress, () async { AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( customer: Customer(addresses: [
customer: Customer(addresses: [ Addresses(
Addresses( address1: selectedPlace.formattedAddress,
address1: selectedPlace.formattedAddress, address2: selectedPlace.formattedAddress,
address2: selectedPlace.formattedAddress, customerAttributes: "",
customerAttributes: "", createdOnUtc: "",
createdOnUtc: "", id: "0",
id: "0", faxNumber: "",
faxNumber: "", phoneNumber: projectViewModel.user.mobileNumber,
phoneNumber: projectViewModel.user.mobileNumber, countryId: 69,
countryId: 69, latLong: selectedPlace.geometry.location.lat.toString() + "," + selectedPlace.geometry.location.lng.toString(),
latLong: selectedPlace.geometry.location.lat.toString() + "," + selectedPlace.geometry.location.lng.toString(), email: projectViewModel.user.emailAddress)
email: projectViewModel.user.emailAddress) ]),
// Addresses( );
// address1: selectedPlace.formattedAddress,
// address2: selectedPlace.formattedAddress,
// customerAttributes: "",
// city: "",
// createdOnUtc: "",
// id: "0",
// latLong: "${selectedPlace.geometry.location}",
// email: "")
]),
);
selectedPlace.addressComponents.forEach((e) { selectedPlace.addressComponents.forEach((e) {
if (e.types.contains("country")) { if (e.types.contains("country")) {
addNewAddressRequestModel.customer.addresses[0].country = e.longName; addNewAddressRequestModel.customer.addresses[0].country = e.longName;
} }
if (e.types.contains("postal_code")) { if (e.types.contains("postal_code")) {
addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName; addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
} }
if (e.types.contains("locality")) { if (e.types.contains("locality")) {
addNewAddressRequestModel.customer.addresses[0].city = e.longName; addNewAddressRequestModel.customer.addresses[0].city = e.longName;
} }
}); });
await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel); await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
} else { } else {
AppToast.showSuccessToast(message: "Address Added Successfully"); AppToast.showSuccessToast(message: "Address Added Successfully");
} }
Navigator.of(context).pop(addNewAddressRequestModel); Navigator.of(context).pop(addNewAddressRequestModel);
}).insideContainer); }).insideContainer);
}, },
initialPosition: LatLng(latitude, longitude), initialPosition: LatLng(latitude, longitude),
useCurrentLocation: showCurrentLocation, useCurrentLocation: showCurrentLocation,
), ),
// Expanded(
// child: Stack(
// alignment: Alignment.center,
// children: [
// if (appMap != null) appMap,
// Container(
// margin: EdgeInsets.only(bottom: 50.0),
// child: Icon(
// Icons.place,
// color: CustomColors.accentColor,
// size: 50,
// ),
// ),
// // FloatingCard(
// // bottomPosition: 0.0,
// // leftPosition: 0.0,
// // rightPosition: 0.0,
// // width: 500,
// // borderRadius: BorderRadius.circular(0.0),
// // // child: state == SearchingState.Searching
// // // ? SizedBox(height: 43, child: Center(child: CircularProgressIndicator())).insideContainer
// // // :
// // child: DefaultButton(TranslationBase.of(context).addNewAddress, () async {
// // AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
// // customer: Customer(addresses: [
// // // Addresses(
// // // address1: selectedPlace.formattedAddress,
// // // address2: selectedPlace.formattedAddress,
// // // customerAttributes: "",
// // // createdOnUtc: "",
// // // id: "0",
// // // faxNumber: "",
// // // phoneNumber: projectViewModel.user.mobileNumber,
// // // countryId: 69,
// // // latLong: "$latitude,$longitude",
// // // email: projectViewModel.user.emailAddress)
// //
// // // Addresses(
// // // address1: selectedPlace.formattedAddress,
// // // address2: selectedPlace.formattedAddress,
// // // customerAttributes: "",
// // // city: "",
// // // createdOnUtc: "",
// // // id: "0",
// // // latLong: "${selectedPlace.geometry.location}",
// // // email: "")
// // ]),
// // );
// //
// // // selectedPlace.addressComponents.forEach((e) {
// // // if (e.types.contains("country")) {
// // // addNewAddressRequestModel.customer.addresses[0].country = e.longName;
// // // }
// // // if (e.types.contains("postal_code")) {
// // // addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
// // // }
// // // if (e.types.contains("locality")) {
// // // addNewAddressRequestModel.customer.addresses[0].city = e.longName;
// // // }
// // // });
// //
// // await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
// // if (model.state == ViewState.ErrorLocal) {
// // Utils.showErrorToast(model.error);
// // } else {
// // AppToast.showSuccessToast(message: "Address Added Successfully");
// // }
// // Navigator.of(context).pop(addNewAddressRequestModel);
// // }).insideContainer),
// ],
// ),
// ),
), ),
); );
} }
checkIsHuawei() async {
isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable;
print(isHuawei);
setState(() {});
}
void _getUserLocation() async { void _getUserLocation() async {
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);

@ -66,6 +66,9 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
_getUserLocation(); _getUserLocation();
setState(() {}); setState(() {});
}, },
onCameraIdle: () {
print("onCameraIdle");
},
); );
super.initState(); super.initState();
} }
@ -217,30 +220,6 @@ class _NewHomeHealthCareStepTowPageState extends State<NewHomeHealthCareStepTowP
), ),
), ),
), ),
// Expanded(
// child: Stack(
// alignment: Alignment.center,
// children: [
// GoogleMap(
// mapType: MapType.normal,
// zoomControlsEnabled: false,
// myLocationButtonEnabled: true,
// myLocationEnabled: true,
// initialCameraPosition: _kGooglePlex,
// onCameraMove: ((_position) => _updatePosition(_position)),
// onMapCreated: (GoogleMapController controller) {
// googleMapController = controller;
// _controller.complete(controller);
// },
// ),
// Icon(
// Icons.place,
// color: CustomColors.accentColor,
// size: 50,
// ),
// ],
// ),
// ),
Expanded( Expanded(
child: Stack( child: Stack(
alignment: Alignment.center, alignment: Alignment.center,

@ -245,18 +245,19 @@ class _BookConfirmState extends State<BookConfirm> {
); );
} }
cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context) { cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context) async {
ConfirmDialog.closeAlertDialog(context); ConfirmDialog.closeAlertDialog(context);
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService(); DoctorsListService service = new DoctorsListService();
bool isLiveCareSchedule = await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT);
service.cancelAppointment(appo, context).then((res) { service.cancelAppointment(appo, context).then((res) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
Future.delayed(new Duration(milliseconds: 1500), () async { Future.delayed(new Duration(milliseconds: 1500), () async {
if (await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT) != null && !await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) { if (isLiveCareSchedule != null && isLiveCareSchedule) {
insertAppointment(context, widget.doctor, widget.initialSlotDuration);
} else {
insertLiveCareScheduledAppointment(context, widget.doctor); insertLiveCareScheduledAppointment(context, widget.doctor);
} else {
insertAppointment(context, widget.doctor, widget.initialSlotDuration);
} }
}); });
} else { } else {

@ -230,10 +230,16 @@ class _DocAvailableAppointmentsState extends State<DocAvailableAppointments> wit
Map<DateTime, List> _eventsParsed; Map<DateTime, List> _eventsParsed;
List<FreeSlot> slotsList = []; List<FreeSlot> slotsList = [];
DateTime date; DateTime date;
// print("TIMEZONE");
// print(DateTime.now().timeZoneName);
final DateFormat formatter = DateFormat('HH:mm'); final DateFormat formatter = DateFormat('HH:mm');
final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); final DateFormat dateFormatter = DateFormat('yyyy-MM-dd');
for (var i = 0; i < freeSlotsResponse.length; i++) { for (var i = 0; i < freeSlotsResponse.length; i++) {
date = Jiffy(DateUtil.convertStringToDate(freeSlotsResponse[i])).add(hours: 3).dateTime; if ((widget.doctor.projectID == 2 && DateTime.now().timeZoneName == "+04") || widget.doctor.projectID == 3 && DateTime.now().timeZoneName == "+04") {
date = Jiffy(DateUtil.convertStringToDate(freeSlotsResponse[i])).subtract(hours: 1).dateTime;
} else {
date = DateUtil.convertStringToDate(freeSlotsResponse[i]);
}
slotsList.add(FreeSlot(date, ['slot'])); slotsList.add(FreeSlot(date, ['slot']));
docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date)); docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date));
} }

@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/ambulanceRequest/locationDetails.dart';
import 'package:diplomaticquarterapp/pages/ErService/widgets/AppointmentCard.dart'; import 'package:diplomaticquarterapp/pages/ErService/widgets/AppointmentCard.dart';
import 'package:diplomaticquarterapp/uitl/ProgressDialog.dart'; import 'package:diplomaticquarterapp/uitl/ProgressDialog.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
@ -11,7 +12,6 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart'; import 'package:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart';
@ -19,7 +19,6 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
import '../AvailableAppointmentsPage.dart'; import '../AvailableAppointmentsPage.dart';
@ -44,7 +43,7 @@ class _PickupLocationState extends State<PickupLocation> {
double _longitude; double _longitude;
AppoitmentAllHistoryResultList myAppointment; AppoitmentAllHistoryResultList myAppointment;
HospitalsModel _selectedHospital; HospitalsModel _selectedHospital;
PickResult _result; LocationDetails _result;
@override @override
void initState() { void initState() {
@ -496,15 +495,15 @@ class _PickupLocationState extends State<PickupLocation> {
setState(() { setState(() {
widget.patientER_RC.transportationDetails.pickupSpot = _isInsideHome ? 1 : 0; widget.patientER_RC.transportationDetails.pickupSpot = _isInsideHome ? 1 : 0;
if (widget.patientER_RC.transportationDetails.direction == 0) { if (widget.patientER_RC.transportationDetails.direction == 0) {
widget.patientER_RC.transportationDetails.dropoffLatitude = _result.geometry.location.lat.toString(); widget.patientER_RC.transportationDetails.dropoffLatitude = _result.lat.toStringAsFixed(6);
widget.patientER_RC.transportationDetails.dropoffLongitude = _result.geometry.location.lng.toString(); widget.patientER_RC.transportationDetails.dropoffLongitude = _result.long.toStringAsFixed(6);
widget.patientER_RC.transportationDetails.pickupLatitude = _selectedHospital.latitude; widget.patientER_RC.transportationDetails.pickupLatitude = _selectedHospital.latitude;
widget.patientER_RC.transportationDetails.pickupLongitude = _selectedHospital.longitude; widget.patientER_RC.transportationDetails.pickupLongitude = _selectedHospital.longitude;
} else { } else {
widget.patientER_RC.transportationDetails.pickupLatitude = _selectedHospital.latitude; widget.patientER_RC.transportationDetails.pickupLatitude = _selectedHospital.latitude;
widget.patientER_RC.transportationDetails.pickupLongitude = _selectedHospital.longitude; widget.patientER_RC.transportationDetails.pickupLongitude = _selectedHospital.longitude;
widget.patientER_RC.transportationDetails.dropoffLatitude = _result.geometry.location.lat.toString(); widget.patientER_RC.transportationDetails.dropoffLatitude = _result.lat.toStringAsFixed(6);
widget.patientER_RC.transportationDetails.dropoffLongitude = _result.geometry.location.lng.toString(); widget.patientER_RC.transportationDetails.dropoffLongitude = _result.long.toStringAsFixed(6);
} }
// widget.patientER.latitude = // widget.patientER.latitude =

@ -247,7 +247,7 @@ class _ToDoState extends State<ToDo> with SingleTickerProviderStateMixin {
children: <Widget>[ children: <Widget>[
MyRichText(TranslationBase.of(context).clinic + ": ", widget.appoList[index].clinicName, projectViewModel.isArabic), MyRichText(TranslationBase.of(context).clinic + ": ", widget.appoList[index].clinicName, projectViewModel.isArabic),
MyRichText(TranslationBase.of(context).appointmentDate + ": ", MyRichText(TranslationBase.of(context).appointmentDate + ": ",
DateUtil.getDayMonthYearHourMinuteDateFormatted(DateUtil.convertStringToDate(widget.appoList[index].appointmentDate)), projectViewModel.isArabic), DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(widget.appoList[index].appointmentDate)) + " " + widget.appoList[index].startTime.substring(0, 5), projectViewModel.isArabic),
MyRichText(TranslationBase.of(context).branch, widget.appoList[index].projectName, projectViewModel.isArabic), MyRichText(TranslationBase.of(context).branch, widget.appoList[index].projectName, projectViewModel.isArabic),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,

@ -198,6 +198,7 @@ class _PaymentMethodState extends State<PaymentMethod> {
), ),
), ),
), ),
// if (projectViewModel.havePrivilege(90))
// Container( // Container(
// width: double.infinity, // width: double.infinity,
// child: InkWell( // child: InkWell(

@ -283,7 +283,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
super.initState(); super.initState();
PushNotificationHandler.getInstance().onResume(); PushNotificationHandler.getInstance().onResume();
// VoIP Callbacks // // VoIP Callbacks
// voIPKit.getVoIPToken().then((value) { // voIPKit.getVoIPToken().then((value) {
// print('🎈 example: getVoIPToken: $value'); // print('🎈 example: getVoIPToken: $value');
// sharedPref.setString("VOIPToken", value); // sharedPref.setString("VOIPToken", value);

@ -10,6 +10,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart';
import 'OpenTokPlatformBridge.dart'; import 'OpenTokPlatformBridge.dart';
@ -36,6 +37,7 @@ class OpenTokState extends State<OpenTokConnectCallPage>{
var audioMute = false; var audioMute = false;
var videoMute = false; var videoMute = false;
final voIPKit = FlutterIOSVoIPKit.instance;
initOpenTok(){ initOpenTok(){
openTokPlatform = OpenTokPlatformBridge.init( openTokPlatform = OpenTokPlatformBridge.init(
@ -196,6 +198,7 @@ class OpenTokState extends State<OpenTokConnectCallPage>{
Future<void> _onHangup() async { Future<void> _onHangup() async {
print('onHangup'); print('onHangup');
await openTokPlatform.hangupCall(); await openTokPlatform.hangupCall();
voIPKit.endCall();
endCallAPI(); endCallAPI();
Navigator.of(context).pop(); Navigator.of(context).pop();
} }

@ -5,16 +5,15 @@ class DateUtil {
/// convert String To Date function /// convert String To Date function
/// [date] String we want to convert /// [date] String we want to convert
static DateTime convertStringToDate(String date) { static DateTime convertStringToDate(String date) {
// /Date(1585774800000+0300)/
if (date != null) { if (date != null) {
const start = "/Date("; const start = "/Date(";
const end = "+0300)"; const end = "+0300)/";
final startIndex = date.indexOf(start); final startIndex = date.indexOf(start);
final endIndex = date.indexOf(end, startIndex + start.length); final endIndex = date.indexOf(end, startIndex + start.length);
return DateTime.fromMillisecondsSinceEpoch( return DateTime.fromMillisecondsSinceEpoch(
int.parse( int.parse(
date.substring(startIndex + start.length, endIndex), date.substring(startIndex + start.length, endIndex),
), isUtc: true )
); );
} else } else
return DateTime.now(); return DateTime.now();

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
@ -8,12 +9,16 @@ import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart';
import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notification_details_page.dart'; import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notification_details_page.dart';
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart'; import 'package:diplomaticquarterapp/pages/livecare/incoming_call.dart';
import 'package:diplomaticquarterapp/pages/webRTC/OpenTok/OpenTok.dart';
import 'package:diplomaticquarterapp/uitl/app-permissions.dart'; import 'package:diplomaticquarterapp/uitl/app-permissions.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:firebase_messaging/firebase_messaging.dart' as fir; import 'package:firebase_messaging/firebase_messaging.dart' as fir;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart';
import 'package:flutter_ios_voip_kit/call_state_type.dart';
import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart';
import 'package:huawei_push/huawei_push.dart' as h_push; import 'package:huawei_push/huawei_push.dart' as h_push;
import 'app_shared_preferences.dart'; import 'app_shared_preferences.dart';
@ -80,6 +85,10 @@ RemoteMessage toFirebaseRemoteMessage(h_push.RemoteMessage message) {
return fire_message; return fire_message;
} }
callPage(String sessionID, String token) async {
await NavigationService.navigateToPage(OpenTokConnectCallPage(apiKey: OPENTOK_API_KEY, sessionId: sessionID, token: token));
}
_incomingCall(Map data) async { _incomingCall(Map data) async {
LandingPage.incomingCallData = IncomingCallData.fromJson(data); LandingPage.incomingCallData = IncomingCallData.fromJson(data);
if (LandingPage.isOpenCallPage == false) { if (LandingPage.isOpenCallPage == false) {
@ -95,6 +104,30 @@ _incomingCall(Map data) async {
class PushNotificationHandler { class PushNotificationHandler {
final BuildContext context; final BuildContext context;
static PushNotificationHandler _instance; static PushNotificationHandler _instance;
final voIPKit = FlutterIOSVoIPKit.instance;
Timer timeOutTimer;
bool isTalking = false;
var data = {
"AppointmentNo": "2016059247",
"ProjectID": "15",
"NotificationType": "10",
"background": "0",
"doctorname": "Call from postman",
"clinicname": "LIVECARE FAMILY MEDICINE AND GP",
"speciality": "General Practioner",
"appointmentdate": "2022-01-19",
"appointmenttime": "12:10",
"PatientName": "Testing",
"session_id": "1_MX40NjIwOTk2Mn5-MTY1NDE2NDQxMjc2Mn5xc3NCZkNIejJOdzgzTkg2TmlXblhQdnl-fg",
"token":
"T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9MTliNTA3NDAxYmU0MjI5OGY5NTcxZTdhNzQyMTcyZjRjMjBhNjljZTpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWTFOREUyTkRReE1qYzJNbjV4YzNOQ1prTkllakpPZHpnelRrZzJUbWxYYmxoUWRubC1mZyZjcmVhdGVfdGltZT0xNjU0MTY0NDEzJm5vbmNlPTAuNjM3ODkzNDk4NDQ2NTIxOSZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjU0MjUwODEzJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9",
"DoctorImageURL": "https://image.shutterstock.com/image-vector/sample-stamp-square-grunge-sign-260nw-1474408826.jpg",
"callerID": "9920",
"PatientID": "1231755",
"is_call": "true"
};
PushNotificationHandler(this.context) { PushNotificationHandler(this.context) {
PushNotificationHandler._instance = this; PushNotificationHandler._instance = this;
@ -102,80 +135,162 @@ class PushNotificationHandler {
static PushNotificationHandler getInstance() => _instance; static PushNotificationHandler getInstance() => _instance;
init() async { void _timeOut({
final fcmToken = await FirebaseMessaging.instance.getToken(); int seconds = 15,
if (fcmToken != null) onToken(fcmToken); }) async {
if (Platform.isIOS) { timeOutTimer = Timer(Duration(seconds: seconds), () async {
final permission = await FirebaseMessaging.instance.requestPermission(); print('🎈 example: timeOut');
if (permission.authorizationStatus == AuthorizationStatus.denied) return; final incomingCallerName = await voIPKit.getIncomingCallerName();
} voIPKit.unansweredIncomingCall(
skipLocalNotification: false,
missedCallTitle: '📞 Missed call',
missedCallBody: 'There was a call from $incomingCallerName',
);
});
}
// if (Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) { init() async {
// // 'Android HMS' (Handle Huawei Push_Kit Streams) // VoIP Callbacks
// voIPKit.getVoIPToken().then((value) {
// print('🎈 example: getVoIPToken: $value');
// // sharedPref.setString("VOIPToken", value);
// });
// //
// h_push.Push.enableLogger(); // voIPKit.onDidReceiveIncomingPush = (
// final result = await h_push.Push.setAutoInitEnabled(true); // Map<String, dynamic> payload,
// ) async {
// print('🎈 example: onDidReceiveIncomingPush $payload');
// _timeOut();
// };
// //
// h_push.Push.onNotificationOpenedApp.listen((message) { // voIPKit.onDidRejectIncomingCall = (
// newMessage(toFirebaseRemoteMessage(message)); // String uuid,
// }, onError: (e) => print(e.toString())); // String callerId,
// ) {
// if (isTalking) {
// return;
// }
// //
// h_push.Push.onMessageReceivedStream.listen((message) { // print('🎈 example: onDidRejectIncomingCall $uuid, $callerId');
// newMessage(toFirebaseRemoteMessage(message)); // voIPKit.endCall();
// }, onError: (e) => print(e.toString())); // timeOutTimer?.cancel();
// //
// h_push.Push.getTokenStream.listen((token) { // // setState(() {
// onToken(token); // // isTalking = false;
// }, onError: (e) => print(e.toString())); // // });
// await h_push.Push.getToken(''); // };
// //
// h_push.Push.registerBackgroundMessageHandler(backgroundMessageHandler); // voIPKit.onDidAcceptIncomingCall = (
// } else { // String uuid,
// 'Android GMS or iOS' (Handle Firebase Messaging Streams // String callerId,
// ) {
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) async { // // print('🎈 example: isTalking $isTalking');
print("Firebase getInitialMessage!!!"); // // if (isTalking) {
// Utils.showPermissionConsentDialog(context, "getInitialMessage", (){}); // // return;
if (Platform.isIOS) // // }
await Future.delayed(Duration(milliseconds: 3000)).then((value) { //
if(message != null) // print('🎈 example: onDidAcceptIncomingCall $uuid, $callerId');
newMessage(message); //
}); // String sessionID = callerId.split("*")[0];
else // String token = callerId.split("*")[1];
// if(message != null) //
newMessage(message); // print("🎈 SessionID: $sessionID");
}); // print("🎈 Token: $token");
//
// voIPKit.acceptIncomingCall(callerState: CallStateType.calling);
// voIPKit.callConnected();
// timeOutTimer?.cancel();
//
// print("🎈 CALL ACCEPTED!!!");
//
// Future.delayed(new Duration(milliseconds: 1000)).then((value) async {
// print("🎈 Incoming Call!!!");
// callPage(sessionID, token);
// });
//
// // print("🎈 Identity: $identity");
// // print("🎈 Name: $name");
//
// // setState(() {
// // isTalking = true;
// // });
// };
FirebaseMessaging.onMessage.listen((RemoteMessage message) async { if (Platform.isAndroid && (!await FlutterHmsGmsAvailability.isHmsAvailable)) {
print("Firebase onMessage!!!"); final fcmToken = await FirebaseMessaging.instance.getToken();
// Utils.showPermissionConsentDialog(context, "onMessage", (){}); if (fcmToken != null) onToken(fcmToken);
// newMessage(message); }
if (Platform.isIOS)
await Future.delayed(Duration(milliseconds: 3000)).then((value) { if (Platform.isIOS) {
final permission = await FirebaseMessaging.instance.requestPermission();
if (permission.authorizationStatus == AuthorizationStatus.denied) return;
}
if (Platform.isAndroid && (await FlutterHmsGmsAvailability.isHmsAvailable)) {
// 'Android HMS' (Handle Huawei Push_Kit Streams)
h_push.Push.enableLogger();
final result = await h_push.Push.setAutoInitEnabled(true);
h_push.Push.onNotificationOpenedApp.listen((message) {
newMessage(toFirebaseRemoteMessage(message));
}, onError: (e) => print(e.toString()));
h_push.Push.onMessageReceivedStream.listen((message) {
newMessage(toFirebaseRemoteMessage(message));
}, onError: (e) => print(e.toString()));
h_push.Push.getTokenStream.listen((token) {
onToken(token);
}, onError: (e) => print(e.toString()));
await h_push.Push.getToken('');
h_push.Push.registerBackgroundMessageHandler(backgroundMessageHandler);
} else {
// 'Android GMS or iOS' (Handle Firebase Messaging Streams
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) async {
print("Firebase getInitialMessage!!!");
// Utils.showPermissionConsentDialog(context, "getInitialMessage", (){});
if (Platform.isIOS)
await Future.delayed(Duration(milliseconds: 3000)).then((value) {
if (message != null) newMessage(message);
});
else
// if(message != null)
newMessage(message); newMessage(message);
}); });
else
newMessage(message);
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async { FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
print("Firebase onMessageOpenedApp!!!"); print("Firebase onMessage!!!");
// Utils.showPermissionConsentDialog(context, "onMessageOpenedApp", (){}); // Utils.showPermissionConsentDialog(context, "onMessage", (){});
// newMessage(message); // newMessage(message);
if (Platform.isIOS) if (Platform.isIOS)
await Future.delayed(Duration(milliseconds: 3000)).then((value) { await Future.delayed(Duration(milliseconds: 3000)).then((value) {
newMessage(message);
});
else
newMessage(message); newMessage(message);
}); });
else
newMessage(message);
});
FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) { FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
onToken(fcm_token); print("Firebase onMessageOpenedApp!!!");
}); // Utils.showPermissionConsentDialog(context, "onMessageOpenedApp", (){});
// newMessage(message);
if (Platform.isIOS)
await Future.delayed(Duration(milliseconds: 3000)).then((value) {
newMessage(message);
});
else
newMessage(message);
});
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); FirebaseMessaging.instance.onTokenRefresh.listen((fcm_token) {
// } onToken(fcm_token);
});
FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler);
}
} }
newMessage(RemoteMessage remoteMessage) async { newMessage(RemoteMessage remoteMessage) async {

@ -32,13 +32,13 @@ class MyInAppBrowser extends InAppBrowser {
static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE
// static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWeb/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWeb/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT
static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
// static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT // static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT
// static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store
// static String PRESCRIPTION_PAYMENT_WITH_ORDERID = // static String PRESCRIPTION_PAYMENT_WITH_ORDERID =
// 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID='; // 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID=';

@ -1,18 +1,22 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/ambulanceRequest/locationDetails.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/app_map/google_huawei_map.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/others/close_back.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hms_gms_availability/flutter_hms_gms_availability.dart';
import 'package:geocoding/geocoding.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart'; import 'package:google_maps_place_picker/google_maps_place_picker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class PickupLocationFromMap extends StatelessWidget { class PickupLocationFromMap extends StatefulWidget {
final Function(PickResult) onPick; final Function(LocationDetails) onPick;
final double latitude; final double latitude;
final double longitude; final double longitude;
final bool isWithAppBar; final bool isWithAppBar;
@ -21,6 +25,54 @@ class PickupLocationFromMap extends StatelessWidget {
const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key); const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key);
@override
State<PickupLocationFromMap> createState() => _PickupLocationFromMapState();
}
class _PickupLocationFromMapState extends State<PickupLocationFromMap> {
bool isHuawei = false;
Placemark selectedPlace;
AppMap appMap;
LatLng currentPostion;
AppSharedPreferences sharedPref = AppSharedPreferences();
double latitude = 0;
double longitude = 0;
static CameraPosition kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
@override
void initState() {
checkIsHuawei();
appMap = AppMap(
kGooglePlex.toMap(),
onCameraMove: (camera) {
_updatePosition(camera);
},
onMapCreated: () {
currentPostion = LatLng(widget.latitude, widget.longitude);
latitude = widget.latitude;
longitude = widget.longitude;
setState(() {});
},
onCameraIdle: () async {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
selectedPlace = placemarks[0];
print(selectedPlace);
},
);
super.initState();
}
checkIsHuawei() async {
isHuawei = await FlutterHmsGmsAvailability.isHmsAvailable;
print(isHuawei);
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -29,58 +81,92 @@ class PickupLocationFromMap extends StatelessWidget {
showNewAppBarTitle: true, showNewAppBarTitle: true,
showNewAppBar: true, showNewAppBar: true,
appBarTitle: TranslationBase.of(context).selectLocation, appBarTitle: TranslationBase.of(context).selectLocation,
// appBar: isWithAppBar body: isHuawei
// ? AppBar( ? Column(
// elevation: 0, children: [
// textTheme: TextTheme( Expanded(
// headline6: child: Stack(
// TextStyle(color: Colors.white, fontWeight: FontWeight.bold), alignment: Alignment.center,
// ), children: [
// title: Text('Location'), if (appMap != null) appMap,
// leading: CloseBack(), Container(
// centerTitle: true, margin: EdgeInsets.only(bottom: 50.0),
// ) child: Icon(
// : null, Icons.place,
body: PlacePicker( color: CustomColors.accentColor,
apiKey: GOOGLE_API_KEY, size: 50,
enableMyLocationButton: true,
automaticallyImplyAppBarLeading: false,
autocompleteLanguage: projectViewModel.currentLanguage,
enableMapTypeButton: true,
selectInitialPosition: true,
region: "SA",
onPlacePicked: (PickResult result) {
print(result.adrAddress);
onPick(result);
Navigator.of(context).pop();
},
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: DefaultButton(
TranslationBase.of(context).next,
() {
onPick(selectedPlace);
Navigator.of(context).pop();
},
),
), ),
); ),
}, ],
initialPosition: LatLng(latitude, longitude), ),
useCurrentLocation: true, ),
), Container(
padding: const EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14),
child: DefaultButton(TranslationBase.of(context).next, () async {
LocationDetails locationDetails = new LocationDetails();
locationDetails.lat = latitude;
locationDetails.long = longitude;
locationDetails.formattedAddress = selectedPlace.street;
widget.onPick(locationDetails);
Navigator.of(context).pop();
}),
),
],
)
: PlacePicker(
apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true,
automaticallyImplyAppBarLeading: false,
autocompleteLanguage: projectViewModel.currentLanguage,
enableMapTypeButton: true,
selectInitialPosition: true,
region: "SA",
onPlacePicked: (PickResult result) {
LocationDetails locationDetails = new LocationDetails();
locationDetails.lat = latitude;
locationDetails.long = longitude;
locationDetails.formattedAddress = result.formattedAddress;
print(result.adrAddress);
widget.onPick(locationDetails);
Navigator.of(context).pop();
},
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: DefaultButton(
TranslationBase.of(context).next,
() {
LocationDetails locationDetails = new LocationDetails();
locationDetails.lat = latitude;
locationDetails.long = longitude;
locationDetails.formattedAddress = selectedPlace.formattedAddress;
widget.onPick(locationDetails);
Navigator.of(context).pop();
},
),
),
);
},
initialPosition: LatLng(widget.latitude, widget.longitude),
useCurrentLocation: true,
),
); );
} }
void _updatePosition(CameraPosition _position) {
print(_position);
latitude = _position.target.latitude;
longitude = _position.target.longitude;
}
} }

@ -1,8 +1,7 @@
name: diplomaticquarterapp name: diplomaticquarterapp
description: A new Flutter application. description: A new Flutter application.
version: 4.4.92+404092
version: 4.4.9+40409
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"

Loading…
Cancel
Save