Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into sultan-patientapp
commit
ccd2fc5068
@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
package com.cloud.diplomaticquarterapp.geofence
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
class GeofenceBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.cloud.diplomaticquarterapp.geofence.GeofenceTransition
|
||||
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||
import com.cloud.diplomaticquarterapp.utils.Logs
|
||||
import com.google.android.gms.location.GeofenceStatusCodes
|
||||
import com.google.android.gms.location.GeofencingEvent
|
||||
|
||||
class GeofenceBroadcastReceiver : BroadcastReceiver() {
|
||||
private val LOG_TAG = "GeofenceBroadcastReceiver"
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
|
||||
val geofencingEvent = GeofencingEvent.fromIntent(intent)
|
||||
if (geofencingEvent.hasError()) {
|
||||
val errorMessage = GeofenceErrorMessages.getErrorString(context, geofencingEvent.errorCode)
|
||||
Log.e(LOG_TAG, errorMessage)
|
||||
|
||||
Logs.GeofenceEvent.save(context,LOG_TAG,"Error while triggering geofence event",Logs.STATUS.ERROR)
|
||||
doReRegisterIfRequired(context,geofencingEvent.errorCode)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Logs.GeofenceEvent.save(context,LOG_TAG,"Geofence event triggered: ${GeofenceTransition.fromInt(geofencingEvent.geofenceTransition).value} for ${geofencingEvent.triggeringGeofences.map {it.requestId}}",Logs.STATUS.SUCCESS)
|
||||
HMG_Geofence.shared(context).handleEvent(geofencingEvent.triggeringGeofences,geofencingEvent.triggeringLocation, GeofenceTransition.fromInt(geofencingEvent.geofenceTransition));
|
||||
|
||||
}
|
||||
|
||||
fun doReRegisterIfRequired(context: Context, errorCode: Int){
|
||||
val errorRequiredReregister = listOf(
|
||||
GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE,
|
||||
GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES,
|
||||
GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS,
|
||||
GeofenceStatusCodes.GEOFENCE_REQUEST_TOO_FREQUENT
|
||||
)
|
||||
|
||||
if(errorRequiredReregister.contains(errorCode))
|
||||
HMG_Geofence.shared(context).register(){ status, error ->
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||
import com.google.android.gms.location.GeofenceStatusCodes
|
||||
|
||||
class GeofenceBroadcastReceiverWithJobService : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
GeofenceTransitionsJobIntentService.enqueueWork(context, intent)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,26 +1,22 @@
|
||||
|
||||
|
||||
package com.cloud.diplomaticquarterapp.geofence
|
||||
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||
import com.cloud.diplomaticquarterapp.utils.HMGUtils
|
||||
import com.cloud.diplomaticquarterapp.utils.PREFS_STORAGE
|
||||
|
||||
class GeofencingRebootBroadcastReceiver : BroadcastReceiver(){
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.action)) {
|
||||
// if (intent.action.equals("android.intent.action.BOOT_COMPLETE")) {
|
||||
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
|
||||
pref.edit().putString("REBOOT_DETECTED","YES").apply()
|
||||
|
||||
HMG_Geofence.shared(context).unRegisterAll { status, exception ->
|
||||
val geoZones = HMGUtils.getGeoZonesFromPreference(context)
|
||||
HMG_Geofence.shared(context).register(geoZones)
|
||||
}
|
||||
HMG_Geofence.shared(context).register(){ status, error -> }
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.location.LocationManager
|
||||
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||
import com.cloud.diplomaticquarterapp.utils.HMGUtils
|
||||
import com.cloud.diplomaticquarterapp.utils.PREFS_STORAGE
|
||||
|
||||
class LocationProviderChangeReceiver : BroadcastReceiver() {
|
||||
private val LOG_TAG = "LocationProviderChangeReceiver"
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
|
||||
if (LocationManager.PROVIDERS_CHANGED_ACTION.equals(intent.action)) {
|
||||
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
|
||||
pref.edit().putString("LOCATION_PROVIDER_CHANGE","YES").apply()
|
||||
|
||||
HMG_Geofence.shared(context).register(){ s, e -> }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.cloud.diplomaticquarterapp.geofence.intent_receivers
|
||||
|
||||
import android.app.job.JobParameters
|
||||
import android.app.job.JobService
|
||||
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
|
||||
import com.cloud.diplomaticquarterapp.utils.Logs
|
||||
|
||||
class ReregisterGeofenceJobService : JobService(){
|
||||
companion object{
|
||||
val TriggerIntervalDuration:String = "06:00:00"
|
||||
val JobID = 918273
|
||||
}
|
||||
override fun onStartJob(params: JobParameters?): Boolean {
|
||||
Logs.save(applicationContext,"ReregisterGeofenceJobService.onStartJob", "triggered to re-register the geofences after $TriggerIntervalDuration >> [HH:mm:ss]")
|
||||
HMG_Geofence.shared(applicationContext).register(){ status, error ->
|
||||
jobFinished(params, true)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onStopJob(params: JobParameters?): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package com.cloud.diplomaticquarterapp.utils
|
||||
|
||||
|
||||
const val PREFS_STORAGE = "FlutterSharedPreferences"
|
||||
const val PREF_KEY_SUCCESS = "HMG_GEOFENCE_SUCCESS"
|
||||
const val PREF_KEY_FAILED = "HMG_GEOFENCE_FAILED"
|
||||
const val PREF_KEY_HMG_ZONES = "flutter.hmg-geo-fences"
|
||||
const val PREF_KEY_LANGUAGE = "flutter.language"
|
||||
@ -0,0 +1,145 @@
|
||||
package com.cloud.diplomaticquarterapp.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import com.cloud.diplomaticquarterapp.BuildConfig
|
||||
import com.google.gson.Gson
|
||||
|
||||
class Logs {
|
||||
|
||||
enum class STATUS{
|
||||
SUCCESS,
|
||||
ERROR;
|
||||
}
|
||||
class GeofenceEvent{
|
||||
companion object{
|
||||
fun save(context: Context, tag:String, message:String, status:Logs.STATUS = STATUS.SUCCESS){
|
||||
Logs.Common.save(context,"GeofenceEvent", tag, message, status)
|
||||
}
|
||||
|
||||
fun list(context: Context, tag:String? = null, status:Logs.STATUS? = null):List<LogModel>{
|
||||
return Logs.Common.list(context,"GeofenceEvent", tag, status)
|
||||
}
|
||||
|
||||
fun raw(context: Context):String{
|
||||
return Logs.Common.raw(context,"GeofenceEvent")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class RegisterGeofence{
|
||||
companion object{
|
||||
fun save(context: Context, tag:String, message:String, status:Logs.STATUS = STATUS.SUCCESS){
|
||||
Logs.Common.save(context,"RegisterGeofence", tag, message, status)
|
||||
}
|
||||
|
||||
fun list(context: Context, tag:String? = null, status:Logs.STATUS? = null):List<LogModel>{
|
||||
return Logs.Common.list(context,"RegisterGeofence", tag, status)
|
||||
}
|
||||
|
||||
fun raw(context: Context):String{
|
||||
return Logs.Common.raw(context,"RegisterGeofence");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object{
|
||||
private var pref:SharedPreferences? = null
|
||||
fun save(context: Context, tag:String, message:String, status:Logs.STATUS = STATUS.SUCCESS){
|
||||
Logs.Common.save(context,"Logs", tag, message, status)
|
||||
}
|
||||
|
||||
fun list(context: Context, tag:String? = null, status:Logs.STATUS? = null):List<LogModel>{
|
||||
return Logs.Common.list(context,"Logs", tag, status)
|
||||
}
|
||||
|
||||
fun raw(context: Context):String{
|
||||
return Logs.Common.raw(context,"Logs");
|
||||
}
|
||||
|
||||
private fun storage(context: Context):SharedPreferences{
|
||||
if(pref == null) {
|
||||
pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
|
||||
}
|
||||
return pref!!
|
||||
}
|
||||
}
|
||||
|
||||
private class Common{
|
||||
companion object{
|
||||
private val gson = Gson()
|
||||
|
||||
fun save(context: Context, key:String, tag:String, message:String, status:Logs.STATUS = STATUS.SUCCESS){
|
||||
if(!BuildConfig.DEBUG)
|
||||
return
|
||||
|
||||
val pref = Logs.storage(context)
|
||||
|
||||
val string = pref.getString(key,"{}")
|
||||
val json = gson.fromJson<LogsContainerModel>(string,LogsContainerModel::class.java)
|
||||
json.add(
|
||||
LogModel().apply {
|
||||
this.TAG = tag
|
||||
this.MESSAGE = message
|
||||
this.STATUS = status.name
|
||||
this.DATE = DateUtils.dateTimeNow()
|
||||
}
|
||||
)
|
||||
|
||||
pref.edit().putString(key,gson.toJson(json)).apply()
|
||||
}
|
||||
|
||||
fun list(context: Context, key:String, tag:String? = null, status:Logs.STATUS? = null):List<LogModel>{
|
||||
val pref = Logs.storage(context)
|
||||
val string = pref.getString(key,"{}")
|
||||
val json = gson.fromJson<LogsContainerModel>(string,LogsContainerModel::class.java)
|
||||
if(tag == null && status == null) {
|
||||
return json.LOGS
|
||||
}else if(tag != null && status != null){
|
||||
return json.LOGS.filter { (it.TAG == tag && it.STATUS == status.name) }
|
||||
}else if(tag != null){
|
||||
return json.LOGS.filter { (it.TAG == tag) }
|
||||
}else if(status != null){
|
||||
return json.LOGS.filter { (it.STATUS == status.name) }
|
||||
}
|
||||
return listOf()
|
||||
}
|
||||
|
||||
fun raw(context: Context, key:String):String{
|
||||
val pref = Logs.storage(context)
|
||||
val string = pref.getString(key,"{}")
|
||||
return string!!
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class LogModel{
|
||||
lateinit var TAG:String
|
||||
lateinit var MESSAGE:String
|
||||
lateinit var STATUS:String
|
||||
lateinit var DATE:String
|
||||
|
||||
companion object{
|
||||
fun with(tag:String, message:String, status:String):LogModel{
|
||||
return LogModel().apply {
|
||||
this.TAG = tag
|
||||
this.MESSAGE = message
|
||||
this.STATUS = status
|
||||
this.DATE = DateUtils.dateTimeNow()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LogsContainerModel{
|
||||
var LOGS = mutableListOf<LogModel>()
|
||||
fun add(log:LogModel){
|
||||
LOGS.add(log)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@ -0,0 +1,36 @@
|
||||
//
|
||||
// FlutterConstants.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by ZiKambrani on 22/12/2020.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class FlutterConstants{
|
||||
static var LOG_GEOFENCE_URL:String?
|
||||
static var WIFI_CREDENTIALS_URL:String?
|
||||
static var DEFAULT_HTTP_PARAMS:[String:Any?]?
|
||||
|
||||
class func set(){
|
||||
|
||||
// (FiX) Take a start with FlutterMethodChannel (kikstart)
|
||||
/* First call to flutter method is not returning the correct value (Always returning 'NSObject') then after it wroking fine and returning correct value*/
|
||||
FlutterText.with(key: "test") { (test) in
|
||||
|
||||
flutterMethodChannel?.invokeMethod("getDefaultHttpParameters", arguments: nil){ (response) in
|
||||
if let defaultHTTPParams = response as? [String:Any?]{
|
||||
DEFAULT_HTTP_PARAMS = defaultHTTPParams
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
flutterMethodChannel?.invokeMethod("getLogGeofenceFullUrl", arguments:nil){ (response) in
|
||||
if let url = response as? String{
|
||||
LOG_GEOFENCE_URL = url
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,157 @@
|
||||
|
||||
|
||||
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||
|
||||
class Prescriptions {
|
||||
String setupID;
|
||||
int projectID;
|
||||
int patientID;
|
||||
int appointmentNo;
|
||||
String appointmentDate;
|
||||
String doctorName;
|
||||
String clinicDescription;
|
||||
String name;
|
||||
int episodeID;
|
||||
int actualDoctorRate;
|
||||
int admission;
|
||||
int clinicID;
|
||||
String companyName;
|
||||
String despensedStatus;
|
||||
DateTime dischargeDate;
|
||||
int dischargeNo;
|
||||
int doctorID;
|
||||
String doctorImageURL;
|
||||
int doctorRate;
|
||||
String doctorTitle;
|
||||
int gender;
|
||||
String genderDescription;
|
||||
bool isActiveDoctorProfile;
|
||||
bool isDoctorAllowVedioCall;
|
||||
bool isExecludeDoctor;
|
||||
bool isInOutPatient;
|
||||
String isInOutPatientDescription;
|
||||
String isInOutPatientDescriptionN;
|
||||
bool isInsurancePatient;
|
||||
String nationalityFlagURL;
|
||||
int noOfPatientsRate;
|
||||
String qR;
|
||||
List<String> speciality;
|
||||
|
||||
Prescriptions(
|
||||
{this.setupID,
|
||||
this.projectID,
|
||||
this.patientID,
|
||||
this.appointmentNo,
|
||||
this.appointmentDate,
|
||||
this.doctorName,
|
||||
this.clinicDescription,
|
||||
this.name,
|
||||
this.episodeID,
|
||||
this.actualDoctorRate,
|
||||
this.admission,
|
||||
this.clinicID,
|
||||
this.companyName,
|
||||
this.despensedStatus,
|
||||
this.dischargeDate,
|
||||
this.dischargeNo,
|
||||
this.doctorID,
|
||||
this.doctorImageURL,
|
||||
this.doctorRate,
|
||||
this.doctorTitle,
|
||||
this.gender,
|
||||
this.genderDescription,
|
||||
this.isActiveDoctorProfile,
|
||||
this.isDoctorAllowVedioCall,
|
||||
this.isExecludeDoctor,
|
||||
this.isInOutPatient,
|
||||
this.isInOutPatientDescription,
|
||||
this.isInOutPatientDescriptionN,
|
||||
this.isInsurancePatient,
|
||||
this.nationalityFlagURL,
|
||||
this.noOfPatientsRate,
|
||||
this.qR,
|
||||
this.speciality});
|
||||
|
||||
Prescriptions.fromJson(Map<String, dynamic> json) {
|
||||
setupID = json['SetupID'];
|
||||
projectID = json['ProjectID'];
|
||||
patientID = json['PatientID'];
|
||||
appointmentNo = json['AppointmentNo'];
|
||||
appointmentDate = json['AppointmentDate'];
|
||||
doctorName = json['DoctorName'];
|
||||
clinicDescription = json['ClinicDescription'];
|
||||
name = json['Name'];
|
||||
episodeID = json['EpisodeID'];
|
||||
actualDoctorRate = json['ActualDoctorRate'];
|
||||
admission = json['Admission'];
|
||||
clinicID = json['ClinicID'];
|
||||
companyName = json['CompanyName'];
|
||||
despensedStatus = json['Despensed_Status'];
|
||||
dischargeDate = DateUtil.convertStringToDate(json['DischargeDate']);
|
||||
dischargeNo = json['DischargeNo'];
|
||||
doctorID = json['DoctorID'];
|
||||
doctorImageURL = json['DoctorImageURL'];
|
||||
doctorRate = json['DoctorRate'];
|
||||
doctorTitle = json['DoctorTitle'];
|
||||
gender = json['Gender'];
|
||||
genderDescription = json['GenderDescription'];
|
||||
isActiveDoctorProfile = json['IsActiveDoctorProfile'];
|
||||
isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall'];
|
||||
isExecludeDoctor = json['IsExecludeDoctor'];
|
||||
isInOutPatient = json['IsInOutPatient'];
|
||||
isInOutPatientDescription = json['IsInOutPatientDescription'];
|
||||
isInOutPatientDescriptionN = json['IsInOutPatientDescriptionN'];
|
||||
isInsurancePatient = json['IsInsurancePatient'];
|
||||
nationalityFlagURL = json['NationalityFlagURL'];
|
||||
noOfPatientsRate = json['NoOfPatientsRate'];
|
||||
qR = json['QR'];
|
||||
// speciality = json['Speciality'].cast<String>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['SetupID'] = this.setupID;
|
||||
data['ProjectID'] = this.projectID;
|
||||
data['PatientID'] = this.patientID;
|
||||
data['AppointmentNo'] = this.appointmentNo;
|
||||
data['AppointmentDate'] = this.appointmentDate;
|
||||
data['DoctorName'] = this.doctorName;
|
||||
data['ClinicDescription'] = this.clinicDescription;
|
||||
data['Name'] = this.name;
|
||||
data['EpisodeID'] = this.episodeID;
|
||||
data['ActualDoctorRate'] = this.actualDoctorRate;
|
||||
data['Admission'] = this.admission;
|
||||
data['ClinicID'] = this.clinicID;
|
||||
data['CompanyName'] = this.companyName;
|
||||
data['Despensed_Status'] = this.despensedStatus;
|
||||
data['DischargeDate'] = this.dischargeDate;
|
||||
data['DischargeNo'] = this.dischargeNo;
|
||||
data['DoctorID'] = this.doctorID;
|
||||
data['DoctorImageURL'] = this.doctorImageURL;
|
||||
data['DoctorRate'] = this.doctorRate;
|
||||
data['DoctorTitle'] = this.doctorTitle;
|
||||
data['Gender'] = this.gender;
|
||||
data['GenderDescription'] = this.genderDescription;
|
||||
data['IsActiveDoctorProfile'] = this.isActiveDoctorProfile;
|
||||
data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall;
|
||||
data['IsExecludeDoctor'] = this.isExecludeDoctor;
|
||||
data['IsInOutPatient'] = this.isInOutPatient;
|
||||
data['IsInOutPatientDescription'] = this.isInOutPatientDescription;
|
||||
data['IsInOutPatientDescriptionN'] = this.isInOutPatientDescriptionN;
|
||||
data['IsInsurancePatient'] = this.isInsurancePatient;
|
||||
data['NationalityFlagURL'] = this.nationalityFlagURL;
|
||||
data['NoOfPatientsRate'] = this.noOfPatientsRate;
|
||||
data['QR'] = this.qR;
|
||||
data['Speciality'] = this.speciality;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
//class PrescriptionsList {
|
||||
// String filterName = "";
|
||||
// List<Prescriptions> prescriptionsList = List();
|
||||
//
|
||||
// PrescriptionsList({this.filterName, Prescriptions prescriptions}) {
|
||||
// prescriptionsList.add(prescriptions);
|
||||
// }
|
||||
//}
|
||||
@ -0,0 +1,77 @@
|
||||
class OrdersModel {
|
||||
List<Orders> orders;
|
||||
|
||||
OrdersModel({this.orders});
|
||||
|
||||
OrdersModel.fromJson(Map<String, dynamic> json) {
|
||||
if (json['orders'] != null) {
|
||||
orders = new List<Orders>();
|
||||
json['orders'].forEach((v) {
|
||||
orders.add(new Orders.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
if (this.orders != null) {
|
||||
data['orders'] = this.orders.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Orders {
|
||||
String id;
|
||||
int productCount;
|
||||
double orderTotal;
|
||||
String createdOnUtc;
|
||||
int orderStatusId;
|
||||
String orderStatus;
|
||||
String orderStatusn;
|
||||
bool canCancel;
|
||||
bool canRefund;
|
||||
dynamic customerId;
|
||||
|
||||
Orders(
|
||||
{this.id,
|
||||
this.productCount,
|
||||
this.orderTotal,
|
||||
this.createdOnUtc,
|
||||
this.orderStatusId,
|
||||
this.orderStatus,
|
||||
this.orderStatusn,
|
||||
this.canCancel,
|
||||
this.canRefund,
|
||||
this.customerId,});
|
||||
|
||||
Orders.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
id = json['id'];
|
||||
productCount = json['product_count'];
|
||||
orderTotal = json['order_total'];
|
||||
createdOnUtc = json['created_on_utc'];
|
||||
orderStatusId = json['order_status_id'];
|
||||
orderStatus = json['order_status'];
|
||||
orderStatusn = json['order_statusn'];
|
||||
canCancel = json['can_cancel'];
|
||||
canRefund = json['can_refund'];
|
||||
customerId = json['customer_id'];
|
||||
}catch(e){
|
||||
print(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['product_count'] = this.productCount;
|
||||
data['order_total'] = this.orderTotal;
|
||||
data['created_on_utc'] = this.createdOnUtc;
|
||||
data['order_status_id'] = this.orderStatusId;
|
||||
data['order_status'] = this.orderStatus;
|
||||
data['order_statusn'] = this.orderStatusn;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart';
|
||||
|
||||
|
||||
class PrescriptionService extends BaseService {
|
||||
final AppSharedPreferences sharedPref = AppSharedPreferences();
|
||||
bool isFinished = true;
|
||||
bool hasError = false;
|
||||
String errorMsg = '';
|
||||
String url = "";
|
||||
|
||||
List<Prescriptions> _prescriptionsList = List();
|
||||
List<Prescriptions> get prescriptionsList => _prescriptionsList;
|
||||
|
||||
|
||||
Future getPrescription() async {
|
||||
hasError = false;
|
||||
url = PRESCRIPTION;
|
||||
print("Print PRESCRIPTION url" + url);
|
||||
await baseAppClient.get(url,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
_prescriptionsList.clear();
|
||||
response['PatientPrescriptionList'].forEach((item) {
|
||||
_prescriptionsList.add(Prescriptions.fromJson(item));
|
||||
});
|
||||
print(_prescriptionsList.length);
|
||||
print(response);
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
});
|
||||
}
|
||||
// Future getPrescription() async {
|
||||
// hasError = false;
|
||||
// Map<String, dynamic> body = Map();
|
||||
// body['isDentalAllowedBackend'] = false;
|
||||
// await baseAppClient.post(PRESCRIPTION,
|
||||
// onSuccess: (dynamic response, int statusCode) {
|
||||
// prescriptionsList.clear();
|
||||
// response['PatientPrescriptionList'].forEach((prescriptions) {
|
||||
// prescriptionsList.add(Prescriptions.fromJson(prescriptions));
|
||||
// });
|
||||
// }, onFailure: (String error, int statusCode) {
|
||||
// hasError = true;
|
||||
// super.error = error;
|
||||
// }, body: body);
|
||||
// }
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||
|
||||
class TermsConditionsService extends BaseService {
|
||||
|
||||
String userAgreementContent = "";
|
||||
|
||||
Future getUserTermsAndConditions() async {
|
||||
hasError = false;
|
||||
await baseAppClient.post(GET_USER_TERMS,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
userAgreementContent = response['UserAgreementContent'];
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
}, body: Map<String, dynamic>());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/termsConditionsService.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../locator.dart';
|
||||
|
||||
class TermsConditionsViewModel extends BaseViewModel{
|
||||
|
||||
TermsConditionsService _service = locator<TermsConditionsService>();
|
||||
|
||||
String get userAgreementContent => _service.userAgreementContent;
|
||||
|
||||
getUserTermsAndConditions() async {
|
||||
setState(ViewState.Busy);
|
||||
await _service.getUserTermsAndConditions();
|
||||
if (_service.hasError) {
|
||||
error = _service.error;
|
||||
setState(ViewState.Error);
|
||||
} else {
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,211 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:location/location.dart';
|
||||
|
||||
|
||||
class TrackDriver extends StatefulWidget {
|
||||
final OrderModel order;
|
||||
TrackDriver({this.order});
|
||||
|
||||
@override
|
||||
State<TrackDriver> createState() => _TrackDriverState();
|
||||
}
|
||||
|
||||
class _TrackDriverState extends State<TrackDriver> {
|
||||
OrderModel _order;
|
||||
|
||||
Completer<GoogleMapController> _controller = Completer();
|
||||
|
||||
|
||||
double CAMERA_ZOOM = 16;
|
||||
double CAMERA_TILT = 0;
|
||||
double CAMERA_BEARING = 30;
|
||||
LatLng SOURCE_LOCATION = null;
|
||||
LatLng DEST_LOCATION = null;
|
||||
|
||||
// for my drawn routes on the map
|
||||
Set<Polyline> _polylines = Set<Polyline>();
|
||||
List<LatLng> polylineCoordinates = [];
|
||||
PolylinePoints polylinePoints;
|
||||
|
||||
Set<Marker> _markers = Set<Marker>();
|
||||
|
||||
BitmapDescriptor sourceIcon; // for my custom marker pins
|
||||
BitmapDescriptor destinationIcon; // for my custom marker pins
|
||||
Location location;// wrapper around the location API
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_order = widget.order;
|
||||
DEST_LOCATION = _order.shippingAddress.getLocation();
|
||||
location = new Location();
|
||||
polylinePoints = PolylinePoints();
|
||||
setSourceAndDestinationIcons();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
body: GoogleMap(
|
||||
myLocationEnabled: true,
|
||||
compassEnabled: true,
|
||||
markers: _markers,
|
||||
polylines: _polylines,
|
||||
mapType: MapType.normal,
|
||||
initialCameraPosition: _orderDeliveryLocationCamera(),
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_controller.complete(controller);
|
||||
showPinsOnMap();
|
||||
},
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: _goToDriver,
|
||||
label: Text('To the lake!'),
|
||||
icon: Icon(Icons.directions_boat),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void setSourceAndDestinationIcons() async {
|
||||
sourceIcon = await BitmapDescriptor.fromAssetImage(
|
||||
ImageConfiguration(devicePixelRatio: 2.5),
|
||||
'assets/images/map_markers/source_map_marker.png');
|
||||
|
||||
destinationIcon = await BitmapDescriptor.fromAssetImage(
|
||||
ImageConfiguration(devicePixelRatio: 2.5),
|
||||
'assets/images/map_markers/destination_map_marker.png');
|
||||
}
|
||||
|
||||
CameraPosition _orderDeliveryLocationCamera(){
|
||||
|
||||
final CameraPosition orderDeliveryLocCamera = CameraPosition(
|
||||
bearing: CAMERA_BEARING,
|
||||
target: DEST_LOCATION,
|
||||
tilt: CAMERA_TILT,
|
||||
zoom: CAMERA_ZOOM);
|
||||
return orderDeliveryLocCamera;
|
||||
}
|
||||
|
||||
CameraPosition _driverLocationCamera(){
|
||||
final CameraPosition driverLocCamera = CameraPosition(
|
||||
bearing: CAMERA_BEARING,
|
||||
target: SOURCE_LOCATION,
|
||||
tilt: CAMERA_TILT,
|
||||
zoom: CAMERA_ZOOM);
|
||||
return driverLocCamera;
|
||||
}
|
||||
|
||||
|
||||
Future<void> _goToOrderDeliveryLocation() async {
|
||||
final GoogleMapController controller = await _controller.future;
|
||||
final CameraPosition orderDeliveryLocCamera = _orderDeliveryLocationCamera();
|
||||
controller.animateCamera(CameraUpdate.newCameraPosition(orderDeliveryLocCamera));
|
||||
}
|
||||
|
||||
Future<void> _goToDriver() async {
|
||||
final GoogleMapController controller = await _controller.future;
|
||||
final CameraPosition driverLocCamera = _driverLocationCamera();
|
||||
controller.animateCamera(CameraUpdate.newCameraPosition(driverLocCamera));
|
||||
}
|
||||
|
||||
|
||||
Future<void> _fitCameraBetweenBothPoints() async {
|
||||
final GoogleMapController controller = await _controller.future;
|
||||
final CameraPosition driverLocCamera = CameraPosition(
|
||||
bearing: CAMERA_BEARING,
|
||||
target: SOURCE_LOCATION,
|
||||
tilt: CAMERA_TILT,
|
||||
zoom: CAMERA_ZOOM);
|
||||
controller.animateCamera(CameraUpdate.newCameraPosition(driverLocCamera));
|
||||
}
|
||||
|
||||
void showPinsOnMap() {
|
||||
// source pin
|
||||
if(SOURCE_LOCATION != null){
|
||||
setState(() {
|
||||
var pinPosition = SOURCE_LOCATION;
|
||||
_markers.add(Marker(
|
||||
markerId: MarkerId('sourcePin'),
|
||||
position: pinPosition,
|
||||
icon: sourceIcon
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// destination pin
|
||||
if(DEST_LOCATION != null){
|
||||
setState(() {
|
||||
var destPosition = DEST_LOCATION;
|
||||
_markers.add(Marker(
|
||||
markerId: MarkerId('destPin'),
|
||||
position: destPosition,
|
||||
icon: destinationIcon
|
||||
));
|
||||
});
|
||||
}
|
||||
// set the route lines on the map from source to destination
|
||||
// for more info follow this tutorial
|
||||
// drawRoute();
|
||||
}
|
||||
|
||||
void updatePinOnMap() async {
|
||||
// create a new CameraPosition instance
|
||||
// every time the location changes, so the camera
|
||||
// follows the pin as it moves with an animation
|
||||
CameraPosition cPosition = CameraPosition(
|
||||
zoom: CAMERA_ZOOM,
|
||||
tilt: CAMERA_TILT,
|
||||
bearing: CAMERA_BEARING,
|
||||
target: SOURCE_LOCATION,
|
||||
);
|
||||
final GoogleMapController controller = await _controller.future;
|
||||
controller.animateCamera(CameraUpdate.newCameraPosition(cPosition));
|
||||
// do this inside the setState() so Flutter gets notified
|
||||
// that a widget update is due
|
||||
setState(() {
|
||||
// updated position
|
||||
var pinPosition = SOURCE_LOCATION;
|
||||
|
||||
// the trick is to remove the marker (by id)
|
||||
// and add it again at the updated location
|
||||
_markers.removeWhere((m) => m.markerId.value == 'sourcePin');
|
||||
_markers.add(Marker(
|
||||
markerId: MarkerId('sourcePin'),
|
||||
position: pinPosition, // updated position
|
||||
icon: sourceIcon
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
void drawRoute() async {
|
||||
return; // Ignore draw Route
|
||||
|
||||
List<PointLatLng> result = await polylinePoints.getRouteBetweenCoordinates(
|
||||
GOOGLE_API_KEY,
|
||||
SOURCE_LOCATION.latitude,
|
||||
SOURCE_LOCATION.longitude,
|
||||
DEST_LOCATION.latitude,
|
||||
DEST_LOCATION.longitude);
|
||||
if(result.isNotEmpty){
|
||||
result.forEach((PointLatLng point){
|
||||
polylineCoordinates.add(
|
||||
LatLng(point.latitude,point.longitude)
|
||||
);
|
||||
});
|
||||
setState(() {
|
||||
_polylines.add(Polyline(
|
||||
width: 5, // set the width of the polylines
|
||||
polylineId: PolylineId('poly'),
|
||||
color: Color.fromARGB(255, 40, 122, 198),
|
||||
points: polylineCoordinates
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue