Merge branch 'development' of https://gitlab.com/Cloud_Solution/diplomatic-quarter into my_tracker

 Conflicts:
	lib/config/localized_values.dart
merge-requests/248/head
Mohammad Aljammal 5 years ago
commit f883e1bd78

@ -76,13 +76,21 @@
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" /> <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<!-- Geofencing --> <!-- Geofencing -->
<service android:name=".geofence.GeofenceTransitionsJobIntentService" android:exported="true" android:permission="android.permission.BIND_JOB_SERVICE" /> <service android:name=".geofence.intent_receivers.GeofenceTransitionsJobIntentService" android:exported="true" android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver android:name=".geofence.GeofenceBroadcastReceiver" android:enabled="true" android:exported="true" /> <receiver android:name=".geofence.intent_receivers.GeofenceBroadcastReceiver" android:enabled="true" android:exported="true" />
<receiver android:name=".geofence.GeofencingRebootBroadcastReceiver" android:enabled="true"> <receiver android:name=".geofence.intent_receivers.GeofencingRebootBroadcastReceiver" android:enabled="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<receiver android:name=".geofence.intent_receivers.LocationProviderChangeReceiver">
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED"/>
</intent-filter>
</receiver>
<service android:name=".geofence.intent_receivers.ReregisterGeofenceJobService" android:permission="android.permission.BIND_JOB_SERVICE" />
<!-- Geofencing -->
<meta-data android:name="com.google.android.geo.API_KEY" <meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw"/> android:value="AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw"/>

@ -2,8 +2,7 @@ package com.cloud.diplomaticquarterapp
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.cloud.diplomaticquarterapp.utils.FlutterText import com.cloud.diplomaticquarterapp.utils.*
import com.cloud.diplomaticquarterapp.utils.PlatformBridge
import io.flutter.embedding.android.FlutterFragmentActivity import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
@ -15,6 +14,16 @@ class MainActivity: FlutterFragmentActivity() {
// Create Flutter Platform Bridge // Create Flutter Platform Bridge
PlatformBridge(flutterEngine.dartExecutor.binaryMessenger, this).create() PlatformBridge(flutterEngine.dartExecutor.binaryMessenger, this).create()
val time = timeToMillis("04:00:00", "HH:mm:ss")
print(time)
// val d1 = Logs.list(this)
// val d2 = Logs.raw(this)
// val d3 = Logs.RegisterGeofence.list(this)
// val d4 = Logs.RegisterGeofence.raw(this)
// val d5 = Logs.GeofenceEvent.list(this)
// val d6 = Logs.GeofenceEvent.raw(this)
print("")
} }
override fun onResume() { override fun onResume() {

@ -37,6 +37,7 @@ class GeoZoneModel {
val rad = Radius.toFloat() val rad = Radius.toFloat()
if(lat != null && long != null){ if(lat != null && long != null){
val loiteringDelayMinutes:Int = 2 // in Minutes
return Geofence.Builder() return Geofence.Builder()
.setRequestId(identifier()) .setRequestId(identifier())
.setCircularRegion( .setCircularRegion(
@ -45,7 +46,8 @@ class GeoZoneModel {
rad rad
) )
.setTransitionTypes(GeofenceTransition.ENTER_EXIT.value) .setTransitionTypes(GeofenceTransition.ENTER_EXIT.value)
// .setNotificationResponsiveness(0) .setNotificationResponsiveness(0)
.setLoiteringDelay(loiteringDelayMinutes * 60 * 1000)
.setExpirationDuration(Geofence.NEVER_EXPIRE) .setExpirationDuration(Geofence.NEVER_EXPIRE)
.build() .build()
} }

@ -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)
}
}

@ -6,7 +6,11 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.location.Location
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import com.cloud.diplomaticquarterapp.geofence.intent_receivers.GeofenceBroadcastReceiver
import com.cloud.diplomaticquarterapp.geofence.intent_receivers.ReregisterGeofenceJobService
import com.cloud.diplomaticquarterapp.utils.*
import com.google.android.gms.location.Geofence import com.google.android.gms.location.Geofence
import com.google.android.gms.location.GeofencingClient import com.google.android.gms.location.GeofencingClient
import com.google.android.gms.location.GeofencingRequest import com.google.android.gms.location.GeofencingRequest
@ -17,8 +21,10 @@ import com.google.gson.reflect.TypeToken
enum class GeofenceTransition(val value: Int) { enum class GeofenceTransition(val value: Int) {
ENTER(1), ENTER(1),
EXIT(2), EXIT(2),
DWELL(4),
ENTER_EXIT((ENTER.value or EXIT.value)), ENTER_EXIT((ENTER.value or EXIT.value)),
DWELL(4); DWELL_EXIT((DWELL.value or EXIT.value));
companion object { companion object {
fun fromInt(value: Int) = GeofenceTransition.values().first { it.value == value } fun fromInt(value: Int) = GeofenceTransition.values().first { it.value == value }
@ -27,17 +33,13 @@ enum class GeofenceTransition(val value: Int) {
fun named():String{ fun named():String{
if (value == 1)return "Enter" if (value == 1)return "Enter"
if (value == 2)return "Exit" if (value == 2)return "Exit"
if (value == (ENTER.value or EXIT.value))return "Enter or Exit"
if (value == 4)return "dWell" if (value == 4)return "dWell"
if (value == (ENTER.value or EXIT.value))return "Enter or Exit"
if (value == (DWELL.value or EXIT.value))return "DWell or Exit"
return "unknown" return "unknown"
} }
} }
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"
class HMG_Geofence { class HMG_Geofence {
// https://developer.android.com/training/location/geofencing#java // https://developer.android.com/training/location/geofencing#java
@ -69,13 +71,53 @@ class HMG_Geofence {
} }
} }
fun register(geoZones: List<GeoZoneModel>){ fun limitize(zones: List<GeoZoneModel>):List<GeoZoneModel>{
var geoZones_ = zones
if(zones.size > 100)
geoZones_ = zones.subList(0, 99)
return geoZones_
}
fun register(completion:((Boolean, java.lang.Exception?)->Unit)){
unRegisterAll { status, exception ->
val geoZones = getGeoZonesFromPreference(context)
doRegister(geoZones){ status_, error ->
completion.let { it(status_, error) }
}
}
}
fun unRegisterAll(completion: (status: Boolean, exception: Exception?) -> Unit){
getActiveGeofences({ success ->
removeActiveGeofences()
if(success.isNotEmpty())
geofencingClient
.removeGeofences(success)
.addOnSuccessListener {
completion(true, null)
}
.addOnFailureListener {
completion(false, it)
saveLog(context, "error:REMOVE_GEOFENCES", it.localizedMessage)
}
else
completion(true, null)
}, { failed ->
// Nothing to do with failed geofences.
})
}
private fun doRegister(geoZones: List<GeoZoneModel>, completion:((Boolean, java.lang.Exception?)->Unit)? = null){
if (geoZones.isEmpty()) if (geoZones.isEmpty())
return return
val geoZones_ = limitize(geoZones)
fun buildGeofencingRequest(geofences: List<Geofence>): GeofencingRequest { fun buildGeofencingRequest(geofences: List<Geofence>): GeofencingRequest {
return GeofencingRequest.Builder() return GeofencingRequest.Builder()
.setInitialTrigger(0) .setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_DWELL)
.addGeofences(geofences) .addGeofences(geofences)
.build() .build()
} }
@ -83,9 +125,9 @@ class HMG_Geofence {
getActiveGeofences({ active -> getActiveGeofences({ active ->
val geofences = mutableListOf<Geofence>() val geofences = mutableListOf<Geofence>()
geoZones.forEach { geoZones_.forEach {
it.toGeofence()?.let { geof -> it.toGeofence()?.let { geof ->
if(!active.contains(geof.requestId)){ // if not already registered then register if (!active.contains(geof.requestId)) { // if not already registered then register
geofences.add(geof) geofences.add(geof)
} }
} }
@ -95,31 +137,29 @@ class HMG_Geofence {
geofencingClient geofencingClient
.addGeofences(buildGeofencingRequest(geofences), geofencePendingIntent) .addGeofences(buildGeofencingRequest(geofences), geofencePendingIntent)
.addOnSuccessListener { .addOnSuccessListener {
Logs.RegisterGeofence.save(context,"SUCCESS", "Successfuly registered the geofences", Logs.STATUS.SUCCESS)
saveActiveGeofence(geofences.map { it.requestId }, listOf()) saveActiveGeofence(geofences.map { it.requestId }, listOf())
completion?.let { it(true,null) }
} }
.addOnFailureListener { .addOnFailureListener { exc ->
print(it.localizedMessage) Logs.RegisterGeofence.save(context,"FAILED_TO_REGISTER", "Failed to register geofence",Logs.STATUS.ERROR)
completion?.let { it(false,exc) }
} }
// Schedule the job to register after specified duration (due to: events not calling after long period.. days or days [Needs to register fences again])
HMGUtils.scheduleJob(context, ReregisterGeofenceJobService::class.java,ReregisterGeofenceJobService.JobID, ReregisterGeofenceJobService.TriggerIntervalDuration)
} }
},null)
}, null)
} }
fun unRegisterAll(completion: (status: Boolean, exception:Exception?) -> Unit){ fun getGeoZonesFromPreference(context: Context):List<GeoZoneModel>{
getActiveGeofences({ success -> val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
val mList = success.toMutableList() val json = pref.getString(PREF_KEY_HMG_ZONES, "[]")
mList.add("12345")
geofencingClient val geoZones = GeoZoneModel().listFrom(json!!)
.removeGeofences(success) return geoZones
.addOnSuccessListener {
completion(true, null)
}
.addOnFailureListener {
completion(false, it)
}
removeActiveGeofences()
}, { failed ->
// Nothing to do with failed geofences.
})
} }
fun saveActiveGeofence(success: List<String>, failed: List<String>){ fun saveActiveGeofence(success: List<String>, failed: List<String>){
@ -130,8 +170,8 @@ class HMG_Geofence {
} }
fun removeActiveGeofences(){ fun removeActiveGeofences(){
preferences.edit().putString(PREF_KEY_SUCCESS,"[]").apply() preferences.edit().putString(PREF_KEY_SUCCESS, "[]").apply()
preferences.edit().putString(PREF_KEY_FAILED,"[]").apply() preferences.edit().putString(PREF_KEY_FAILED, "[]").apply()
} }
fun getActiveGeofences(success: (success: List<String>) -> Unit, failure: ((failed: List<String>) -> Unit)?){ fun getActiveGeofences(success: (success: List<String>) -> Unit, failure: ((failed: List<String>) -> Unit)?){
@ -154,12 +194,48 @@ class HMG_Geofence {
} }
fun getPatientID():Int?{ fun getPatientID():Int?{
val profileJson = preferences.getString("flutter.imei-user-data", "{}") var profileJson = preferences.getString("flutter.imei-user-data", null)
if (profileJson == null)
profileJson = preferences.getString("flutter.user-profile", null)
val type = object : TypeToken<Map<String?, Any?>?>() {}.type val type = object : TypeToken<Map<String?, Any?>?>() {}.type
return gson.fromJson<Map<String?, Any?>?>(profileJson,type) return gson.fromJson<Map<String?, Any?>?>(profileJson, type)
?.get("PatientID") ?.get("PatientID")
.toString() .toString()
.toDoubleOrNull() .toDoubleOrNull()
?.toInt() ?.toInt()
} }
fun handleEvent(triggerGeofences: List<Geofence>, location: Location, transition: GeofenceTransition) {
getPatientID()?.let { patientId ->
getActiveGeofences({ activeGeofences ->
triggerGeofences.forEach { geofence ->
// Extract PointID from 'geofence.requestId' and find from active geofences
val pointID = activeGeofences.firstOrNull { it == geofence.requestId }?.split('_')?.first()
if (!pointID.isNullOrEmpty() && pointID.toIntOrNull() != null) {
val body = mutableMapOf<String, Any?>(
"PointsID" to pointID.toIntOrNull(),
"GeoType" to transition.value,
"PatientID" to patientId
)
body.putAll(HMGUtils.defaultHTTPParams(context))
httpPost<Map<String, Any>>(API.LOG_GEOFENCE, body, { response ->
saveLog(context, "HMG_GEOFENCE_NOTIFY", "Success: Notified to server\uD83D\uDE0E.")
sendNotification(context, transition.named(), geofence.requestId, "Notified to server.😎")
}, { exception ->
val errorMessage = "${transition.named()}, ${geofence.requestId}"
saveLog(context, "HMG_GEOFENCE_NOTIFY", "failed: $errorMessage | error: ${exception.localizedMessage}")
sendNotification(context, transition.named(), geofence.requestId, "Failed to notify server😔 -> ${exception.localizedMessage}")
})
}
}
}, null)
}
}
} }

@ -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,9 +1,10 @@
package com.cloud.diplomaticquarterapp.geofence package com.cloud.diplomaticquarterapp.geofence.intent_receivers
import android.content.Context import android.content.Context
import com.cloud.diplomaticquarterapp.R import com.cloud.diplomaticquarterapp.R
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
import com.google.android.gms.common.api.ApiException import com.google.android.gms.common.api.ApiException
import com.google.android.gms.location.GeofenceStatusCodes import com.google.android.gms.location.GeofenceStatusCodes
@ -18,7 +19,7 @@ object GeofenceErrorMessages {
fun getErrorString(context: Context, errorCode: Int): String { fun getErrorString(context: Context, errorCode: Int): String {
val resources = context.resources val resources = context.resources
return when (errorCode) { val errorMessage = when (errorCode) {
GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE -> GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE ->
resources.getString(R.string.geofence_not_available) resources.getString(R.string.geofence_not_available)
@ -28,7 +29,15 @@ object GeofenceErrorMessages {
GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS -> GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS ->
resources.getString(R.string.geofence_too_many_pending_intents) resources.getString(R.string.geofence_too_many_pending_intents)
GeofenceStatusCodes.GEOFENCE_INSUFFICIENT_LOCATION_PERMISSION ->
resources.getString(R.string.GEOFENCE_INSUFFICIENT_LOCATION_PERMISSION)
GeofenceStatusCodes.GEOFENCE_REQUEST_TOO_FREQUENT ->
resources.getString(R.string.GEOFENCE_REQUEST_TOO_FREQUENT)
else -> resources.getString(R.string.geofence_unknown_error) else -> resources.getString(R.string.geofence_unknown_error)
} }
return errorMessage
} }
} }

@ -29,31 +29,27 @@
*/ */
package com.cloud.diplomaticquarterapp.geofence package com.cloud.diplomaticquarterapp.geofence.intent_receivers
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.location.Location
import android.util.Log import android.util.Log
import androidx.core.app.JobIntentService import androidx.core.app.JobIntentService
import com.cloud.diplomaticquarterapp.utils.API import com.cloud.diplomaticquarterapp.geofence.GeofenceTransition
import com.cloud.diplomaticquarterapp.utils.httpPost import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
import com.cloud.diplomaticquarterapp.utils.sendNotification import com.cloud.diplomaticquarterapp.utils.saveLog
import com.github.kittinunf.fuel.core.extensions.jsonBody import com.google.android.gms.location.GeofenceStatusCodes
import com.github.kittinunf.fuel.core.isSuccessful
import com.github.kittinunf.fuel.httpPost
import com.google.android.gms.location.Geofence
import com.google.android.gms.location.GeofencingEvent import com.google.android.gms.location.GeofencingEvent
import com.google.gson.Gson
class GeofenceTransitionsJobIntentService : JobIntentService() { class GeofenceTransitionsJobIntentService : JobIntentService() {
companion object { companion object {
private const val LOG_TAG = "GeoTrIntentService" private const val LOG_TAG = "GeoTrIntentService"
private const val JOB_ID = 573 private const val JOB_ID = 95902
var context_: Context? = null
fun enqueueWork(context: Context, intent: Intent) { fun enqueueWork(context: Context, intent: Intent) {
context_ = context
enqueueWork( enqueueWork(
context, context,
GeofenceTransitionsJobIntentService::class.java, JOB_ID, GeofenceTransitionsJobIntentService::class.java, JOB_ID,
@ -64,43 +60,31 @@ class GeofenceTransitionsJobIntentService : JobIntentService() {
override fun onHandleWork(intent: Intent) { override fun onHandleWork(intent: Intent) {
val geofencingEvent = GeofencingEvent.fromIntent(intent) val geofencingEvent = GeofencingEvent.fromIntent(intent)
if (geofencingEvent.hasError()) { if (geofencingEvent.hasError()) {
val errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.errorCode) val errorMessage = GeofenceErrorMessages.getErrorString(context_!!, geofencingEvent.errorCode)
Log.e(LOG_TAG, errorMessage) Log.e(LOG_TAG, errorMessage)
return
}
if (geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofencingEvent.geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {
handleEvent(geofencingEvent.triggeringGeofences,geofencingEvent.triggeringLocation, GeofenceTransition.fromInt(geofencingEvent.geofenceTransition));
}
}
private fun handleEvent(triggerGeofences: List<Geofence>, location:Location, transition:GeofenceTransition) { saveLog(context_!!,LOG_TAG,errorMessage)
val hmg = HMG_Geofence.shared(this) doReRegisterIfRequired(context_!!, geofencingEvent.errorCode)
hmg.getPatientID()?.let { patientId ->
hmg.getActiveGeofences({ activeGeofences -> return
}
triggerGeofences.forEach { geofence -> HMG_Geofence.shared(context_!!).handleEvent(geofencingEvent.triggeringGeofences,geofencingEvent.triggeringLocation, GeofenceTransition.fromInt(geofencingEvent.geofenceTransition));
// Extract PointID from 'geofence.requestId' and find from active geofences
val pointID = activeGeofences.firstOrNull {it == geofence.requestId}?.split('_')?.first()
if(!pointID.isNullOrEmpty() && pointID.toIntOrNull() != null){
val body = mapOf( }
"PointsID" to pointID.toIntOrNull(),
"GeoType" to transition.value,
"PatientID" to patientId
)
httpPost<Map<String,Any>>(API.LOG_GEOFENCE, body, { response ->
sendNotification(this, transition.named(), geofence.requestId, "Notified to server.😎")
},{ exception ->
sendNotification(this, transition.named(), geofence.requestId, "Failed to notify server.😔")
})
} 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, exc -> }
},null)
}
} }
} }

@ -1,26 +1,22 @@
package com.cloud.diplomaticquarterapp.geofence package com.cloud.diplomaticquarterapp.geofence.intent_receivers
import android.content.BroadcastReceiver import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Handler
import android.os.Message
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
import com.cloud.diplomaticquarterapp.utils.HMGUtils import com.cloud.diplomaticquarterapp.utils.PREFS_STORAGE
class GeofencingRebootBroadcastReceiver : BroadcastReceiver(){ class GeofencingRebootBroadcastReceiver : BroadcastReceiver(){
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.action)) { 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) val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
pref.edit().putString("REBOOT_DETECTED","YES").apply() pref.edit().putString("REBOOT_DETECTED","YES").apply()
HMG_Geofence.shared(context).unRegisterAll { status, exception -> HMG_Geofence.shared(context).register(){ status, error -> }
val geoZones = HMGUtils.getGeoZonesFromPreference(context)
HMG_Geofence.shared(context).register(geoZones)
}
} }
} }

@ -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
}
}

@ -2,7 +2,7 @@ package com.cloud.diplomaticquarterapp.utils
class API { class API {
companion object{ companion object{
private val BASE = "https://uat.hmgwebservices.com" private val BASE = "https://hmgwebservices.com"
private val SERVICE = "Services/Patients.svc/REST" private val SERVICE = "Services/Patients.svc/REST"
val WIFI_CREDENTIALS = "$BASE/$SERVICE/Hmg_SMS_Get_By_ProjectID_And_PatientID" val WIFI_CREDENTIALS = "$BASE/$SERVICE/Hmg_SMS_Get_By_ProjectID_And_PatientID"

@ -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"

@ -3,6 +3,9 @@ package com.cloud.diplomaticquarterapp.utils
import android.app.NotificationChannel import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PendingIntent import android.app.PendingIntent
import android.app.job.JobInfo
import android.app.job.JobScheduler
import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
@ -14,17 +17,16 @@ import com.cloud.diplomaticquarterapp.BuildConfig
import com.cloud.diplomaticquarterapp.MainActivity import com.cloud.diplomaticquarterapp.MainActivity
import com.cloud.diplomaticquarterapp.R import com.cloud.diplomaticquarterapp.R
import com.cloud.diplomaticquarterapp.geofence.GeoZoneModel import com.cloud.diplomaticquarterapp.geofence.GeoZoneModel
import com.cloud.diplomaticquarterapp.geofence.PREFS_STORAGE
import com.cloud.diplomaticquarterapp.geofence.PREF_KEY_HMG_ZONES
import com.github.kittinunf.fuel.core.extensions.jsonBody import com.github.kittinunf.fuel.core.extensions.jsonBody
import com.github.kittinunf.fuel.httpPost import com.github.kittinunf.fuel.httpPost
import com.google.android.gms.location.Geofence
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import org.jetbrains.anko.doAsyncResult
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import java.text.SimpleDateFormat
import java.util.* import java.util.*
import kotlin.concurrent.timerTask import kotlin.concurrent.timerTask
@ -68,24 +70,65 @@ class HMGUtils {
} }
} }
fun getGeoZonesFromPreference(context: Context): List<GeoZoneModel> { fun getLanguageCode(context: Context) : Int {
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE) val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
val json = pref.getString(PREF_KEY_HMG_ZONES,"[]") val lang = pref.getString(PREF_KEY_LANGUAGE, "ar")
return if (lang == "ar") 2 else 1
}
val geoZones = json?.let { GeoZoneModel().listFrom(it) } fun defaultHTTPParams(context: Context) : Map<String, Any?>{
return geoZones!! return mapOf(
"ZipCode" to "966",
"VersionID" to 5.8,
"Channel" to 3,
"LanguageID" to getLanguageCode(context),
"IPAdress" to "10.20.10.20",
"generalid" to "Cs2020@2016$2958",
"PatientOutSA" to 0,
"SessionID" to null,
"isDentalAllowedBackend" to false,
"DeviceTypeID" to 2)
}
fun <T>scheduleJob(context: Context, pendingIntentClassType:Class<T>, jobId:Int, intervalDuration:String, deadlineMillis:Long = (30 * 1000)) { // default deadline: 30 Seconds
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
val jobScheduler: JobScheduler = context.getSystemService(JobScheduler::class.java)
val serviceComponent = ComponentName(context, pendingIntentClassType)
val builder = JobInfo.Builder(jobId, serviceComponent)
builder.setPersisted(true)
builder.setBackoffCriteria(30000, JobInfo.BACKOFF_POLICY_LINEAR)
val intervalMillis = timeToMillis(intervalDuration,"HH:mm:ss")
builder.setMinimumLatency(intervalMillis) // wait at least
builder.setOverrideDeadline((intervalMillis + deadlineMillis)) // maximum delay
if (jobScheduler.schedule(builder.build()) == JobScheduler.RESULT_SUCCESS){
Logs.save(context,"ScheduleJob", "${pendingIntentClassType.simpleName}: Job scheduled to trigger after duration $intervalDuration >> HH:mm:ss --('MinimumLatency:$intervalMillis Deadline:${(intervalMillis + deadlineMillis)}')--",Logs.STATUS.SUCCESS)
}else{
Logs.save(context,"ScheduleJob", "${pendingIntentClassType.simpleName}: Failed to scheduled Job",Logs.STATUS.ERROR)
}
} else {
Logs.save(context,"ScheduleJob", "${pendingIntentClassType.simpleName}: Failed to scheduled Job on VERSION.SDK_INT < ${android.os.Build.VERSION_CODES.M}",Logs.STATUS.ERROR)
}
} }
} }
} }
private fun Timer.schedule(timerTask: TimerTask) {
}
private const val NOTIFICATION_CHANNEL_ID = BuildConfig.APPLICATION_ID + ".channel" private const val NOTIFICATION_CHANNEL_ID = BuildConfig.APPLICATION_ID + ".channel"
fun sendNotification(context: Context, title:String, @Nullable subtitle:String?, message:String?) {
fun timeToMillis(time:String, format:String):Long{
val sdf = SimpleDateFormat(format, Locale.US)
val millis = sdf.parse(time).time + TimeZone.getDefault().rawOffset
return millis
}
fun sendNotification(context: Context, title: String, @Nullable subtitle: String?, message: String?) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
@ -117,8 +160,18 @@ fun sendNotification(context: Context, title:String, @Nullable subtitle:String?,
notificationManager.notify(getUniqueId(), notification.build()) notificationManager.notify(getUniqueId(), notification.build())
} }
//-------------------------
// Open Helper Methods
//-------------------------
fun getUniqueId() = ((System.currentTimeMillis() % 10000).toInt())
private fun getUniqueId() = ((System.currentTimeMillis() % 10000).toInt()) object DateUtils {
@JvmStatic
fun dateTimeNow() : String {
val format = SimpleDateFormat("dd-MMM-yyy hh:mm:ss")
return format.format(Date())
}
}
fun isJSONValid(jsonString: String?): Boolean { fun isJSONValid(jsonString: String?): Boolean {
try { JSONObject(jsonString) } catch (ex: JSONException) { try { JSONObject(jsonString) } catch (ex: JSONException) {
@ -129,31 +182,43 @@ fun isJSONValid(jsonString: String?): Boolean {
return true return true
} }
fun saveLog(context: Context, tag: String, message: String){
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
var logs = pref.getString("LOGS", "")
logs += "$tag -> $message \n"
pref.edit().putString("LOGS", logs).apply();
}
fun getLogs(context: Context) : String?{
val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
return pref.getString("LOGS", "")
}
class HTTPResponse<T>(data: T){ class HTTPResponse<T>(data: T){
final var data:T = data final var data:T = data
} }
fun <T>httpPost(url: String, body: Map<String, Any?>, onSuccess: (response: HTTPResponse<T>) -> Unit, onError: (error: Exception) -> Unit){
fun <T>httpPost(url: String, body: Map<String, Any?>, onSuccess: (response: HTTPResponse<T>) -> Unit, onError: (error: Exception) -> Unit){
val gson = Gson() val gson = Gson()
val type = object : TypeToken<T>() {}.type val type = object : TypeToken<T>() {}.type
val jsonBody = gson.toJson(body) val jsonBody = gson.toJson(body)
url.httpPost() url.httpPost()
.jsonBody(jsonBody, Charsets.UTF_8) .jsonBody(jsonBody, Charsets.UTF_8)
.timeout(10000) .timeout(10000)
.header("Content-Type","application/json") .header("Content-Type", "application/json")
.header("Allow","*/*") .header("Allow", "*/*")
.response { request, response, result -> .response { request, response, result ->
result.doAsyncResult { }
result.fold({ data -> result.fold({ data ->
val dataString = String(data) val dataString = String(data)
if(isJSONValid(dataString)){ if (isJSONValid(dataString)) {
val responseData = gson.fromJson<T>(dataString,type) val responseData = gson.fromJson<T>(dataString, type)
onSuccess(HTTPResponse(responseData)) onSuccess(HTTPResponse(responseData))
}else{ } else {
onError(Exception("Invalid response from server (Not a valid JSON)")) onError(Exception("Invalid response from server (Not a valid JSON)"))
} }
}, { }, {
onError(it) onError(it)
it.localizedMessage
}) })
} }

@ -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)
}
}
}

@ -105,7 +105,7 @@ class PlatformBridge(binaryMessenger: BinaryMessenger, flutterMainActivity: Main
override fun success(result: Any?) { override fun success(result: Any?) {
if(result is String) { if(result is String) {
val geoZones = GeoZoneModel().listFrom(result) val geoZones = GeoZoneModel().listFrom(result)
HMG_Geofence.shared(mainActivity).register(geoZones) HMG_Geofence.shared(mainActivity).register(){ s, e -> }
} }
} }

@ -13,4 +13,10 @@
<string name="geofence_too_many_pending_intents"> <string name="geofence_too_many_pending_intents">
You have provided too many PendingIntents to the addGeofences() call. You have provided too many PendingIntents to the addGeofences() call.
</string> </string>
<string name="GEOFENCE_INSUFFICIENT_LOCATION_PERMISSION">
App do not have permission to access location service.
</string>
<string name="GEOFENCE_REQUEST_TOO_FREQUENT">
Geofence requests happened too frequently.
</string>
</resources> </resources>

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

@ -3,21 +3,23 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CLIENT_ID</key> <key>CLIENT_ID</key>
<string>864393916058-ekeb4s8tgfo58dutv0l54399t7ivr06r.apps.googleusercontent.com</string> <string>815750722565-da8p56le8bd6apsbm9eft0jjl1rtpgkt.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key> <key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.864393916058-ekeb4s8tgfo58dutv0l54399t7ivr06r</string> <string>com.googleusercontent.apps.815750722565-da8p56le8bd6apsbm9eft0jjl1rtpgkt</string>
<key>ANDROID_CLIENT_ID</key>
<string>815750722565-m14h8mkosm7cnq6uh6rhqr54dn02d705.apps.googleusercontent.com</string>
<key>API_KEY</key> <key>API_KEY</key>
<string>AIzaSyA_6ayGCk4fly7o7eTVBrj9kuHBYHMAOfs</string> <string>AIzaSyDiXnCO00li4V7Ioa2YZ_M4ECxRsu_P9tA</string>
<key>GCM_SENDER_ID</key> <key>GCM_SENDER_ID</key>
<string>864393916058</string> <string>815750722565</string>
<key>PLIST_VERSION</key> <key>PLIST_VERSION</key>
<string>1</string> <string>1</string>
<key>BUNDLE_ID</key> <key>BUNDLE_ID</key>
<string>com.cloud.diplomaticquarterapp</string> <string>com.HMG.HMG-Smartphone</string>
<key>PROJECT_ID</key> <key>PROJECT_ID</key>
<string>diplomaticquarter-d2385</string> <string>api-project-815750722565</string>
<key>STORAGE_BUCKET</key> <key>STORAGE_BUCKET</key>
<string>diplomaticquarter-d2385.appspot.com</string> <string>api-project-815750722565.appspot.com</string>
<key>IS_ADS_ENABLED</key> <key>IS_ADS_ENABLED</key>
<false></false> <false></false>
<key>IS_ANALYTICS_ENABLED</key> <key>IS_ANALYTICS_ENABLED</key>
@ -29,8 +31,8 @@
<key>IS_SIGNIN_ENABLED</key> <key>IS_SIGNIN_ENABLED</key>
<true></true> <true></true>
<key>GOOGLE_APP_ID</key> <key>GOOGLE_APP_ID</key>
<string>1:864393916058:ios:13f787bbfe6051f8b97923</string> <string>1:815750722565:ios:328ec247a81a2ca23c186c</string>
<key>DATABASE_URL</key> <key>DATABASE_URL</key>
<string>https://diplomaticquarter-d2385.firebaseio.com</string> <string>https://api-project-815750722565.firebaseio.com</string>
</dict> </dict>
</plist> </plist>

@ -20,7 +20,7 @@ PODS:
- Firebase/Messaging (6.33.0): - Firebase/Messaging (6.33.0):
- Firebase/CoreOnly - Firebase/CoreOnly
- FirebaseMessaging (~> 4.7.0) - FirebaseMessaging (~> 4.7.0)
- firebase_core (0.5.3): - firebase_core (0.5.2):
- Firebase/CoreOnly (~> 6.33.0) - Firebase/CoreOnly (~> 6.33.0)
- Flutter - Flutter
- firebase_core_web (0.1.0): - firebase_core_web (0.1.0):
@ -70,7 +70,7 @@ PODS:
- Flutter - Flutter
- flutter_tts (0.0.1): - flutter_tts (0.0.1):
- Flutter - Flutter
- geolocator (6.1.9): - "geolocator (6.0.0+4)":
- Flutter - Flutter
- google_maps_flutter (0.0.1): - google_maps_flutter (0.0.1):
- Flutter - Flutter
@ -385,7 +385,7 @@ SPEC CHECKSUMS:
device_calendar: 23b28a5f1ab3bf77e34542fb1167e1b8b29a98f5 device_calendar: 23b28a5f1ab3bf77e34542fb1167e1b8b29a98f5
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5
firebase_core: 5d6a02f3d85acd5f8321c2d6d62877626a670659 firebase_core: 350ba329d1641211bc6183a3236893cafdacfea7
firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1
firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75 firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75
FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd
@ -400,7 +400,7 @@ SPEC CHECKSUMS:
flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186 flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186
flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35 flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35
flutter_tts: 0f492aab6accf87059b72354fcb4ba934304771d flutter_tts: 0f492aab6accf87059b72354fcb4ba934304771d
geolocator: 057a0c63a43e9c5296d8ad845a3ac8e6df23d899 geolocator: 1ae40084cc6c1586ce5ad12cfc3fd38c64d05f2f
google_maps_flutter: c7f9c73576de1fbe152a227bfd6e6c4ae8088619 google_maps_flutter: c7f9c73576de1fbe152a227bfd6e6c4ae8088619
GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833 GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833
GoogleMaps: 4b5346bddfe6911bb89155d43c903020170523ac GoogleMaps: 4b5346bddfe6911bb89155d43c903020170523ac

@ -28,8 +28,10 @@
E923EFD62587443800E3E751 /* HMGPlatformBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = E923EFD52587443800E3E751 /* HMGPlatformBridge.swift */; }; E923EFD62587443800E3E751 /* HMGPlatformBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = E923EFD52587443800E3E751 /* HMGPlatformBridge.swift */; };
E923EFD82588D17700E3E751 /* gpx.gpx in Resources */ = {isa = PBXBuildFile; fileRef = E923EFD72588D17700E3E751 /* gpx.gpx */; }; E923EFD82588D17700E3E751 /* gpx.gpx in Resources */ = {isa = PBXBuildFile; fileRef = E923EFD72588D17700E3E751 /* gpx.gpx */; };
E9620805255C2ED100D3A35D /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9620804255C2ED100D3A35D /* NetworkExtension.framework */; }; E9620805255C2ED100D3A35D /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9620804255C2ED100D3A35D /* NetworkExtension.framework */; };
E9A35329258B8E8F00CBA688 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9A35328258B8E8F00CBA688 /* GoogleService-Info.plist */; };
E9C8C136256BACDA00EFFB62 /* HMG_Guest.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9C8C135256BACDA00EFFB62 /* HMG_Guest.swift */; }; E9C8C136256BACDA00EFFB62 /* HMG_Guest.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9C8C135256BACDA00EFFB62 /* HMG_Guest.swift */; };
E9E27168256E3A4000F49B69 /* LocalizedFromFlutter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E27167256E3A4000F49B69 /* LocalizedFromFlutter.swift */; }; E9E27168256E3A4000F49B69 /* LocalizedFromFlutter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E27167256E3A4000F49B69 /* LocalizedFromFlutter.swift */; };
E9F7623B25922BCE00FB5CCF /* FlutterConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9F7623A25922BCE00FB5CCF /* FlutterConstants.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -78,8 +80,10 @@
E923EFD72588D17700E3E751 /* gpx.gpx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = gpx.gpx; sourceTree = "<group>"; }; E923EFD72588D17700E3E751 /* gpx.gpx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = gpx.gpx; sourceTree = "<group>"; };
E9620803255C2ED100D3A35D /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; }; E9620803255C2ED100D3A35D /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
E9620804255C2ED100D3A35D /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; E9620804255C2ED100D3A35D /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; };
E9A35328258B8E8F00CBA688 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
E9C8C135256BACDA00EFFB62 /* HMG_Guest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMG_Guest.swift; sourceTree = "<group>"; }; E9C8C135256BACDA00EFFB62 /* HMG_Guest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMG_Guest.swift; sourceTree = "<group>"; };
E9E27167256E3A4000F49B69 /* LocalizedFromFlutter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedFromFlutter.swift; sourceTree = "<group>"; }; E9E27167256E3A4000F49B69 /* LocalizedFromFlutter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedFromFlutter.swift; sourceTree = "<group>"; };
E9F7623A25922BCE00FB5CCF /* FlutterConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlutterConstants.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -128,6 +132,7 @@
97C146E51CF9000F007C117D = { 97C146E51CF9000F007C117D = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E9A35328258B8E8F00CBA688 /* GoogleService-Info.plist */,
E923EFD72588D17700E3E751 /* gpx.gpx */, E923EFD72588D17700E3E751 /* gpx.gpx */,
9740EEB11CF90186004384FC /* Flutter */, 9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */, 97C146F01CF9000F007C117D /* Runner */,
@ -177,6 +182,7 @@
E923EFD125863FDF00E3E751 /* GeoZoneModel.swift */, E923EFD125863FDF00E3E751 /* GeoZoneModel.swift */,
E923EFD3258645C100E3E751 /* HMG_Geofence.swift */, E923EFD3258645C100E3E751 /* HMG_Geofence.swift */,
E923EFD52587443800E3E751 /* HMGPlatformBridge.swift */, E923EFD52587443800E3E751 /* HMGPlatformBridge.swift */,
E9F7623A25922BCE00FB5CCF /* FlutterConstants.swift */,
); );
path = Helper; path = Helper;
sourceTree = "<group>"; sourceTree = "<group>";
@ -265,6 +271,7 @@
files = ( files = (
E91B53A0256AAC1400E96549 /* GuestPOC_Certificate.cer in Resources */, E91B53A0256AAC1400E96549 /* GuestPOC_Certificate.cer in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
E9A35329258B8E8F00CBA688 /* GoogleService-Info.plist in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
E923EFD82588D17700E3E751 /* gpx.gpx in Resources */, E923EFD82588D17700E3E751 /* gpx.gpx in Resources */,
E91B539F256AAC1400E96549 /* GuestPOC_Certificate.p12 in Resources */, E91B539F256AAC1400E96549 /* GuestPOC_Certificate.p12 in Resources */,
@ -374,6 +381,7 @@
E91B5396256AAA6500E96549 /* GlobalHelper.swift in Sources */, E91B5396256AAA6500E96549 /* GlobalHelper.swift in Sources */,
E923EFD4258645C100E3E751 /* HMG_Geofence.swift in Sources */, E923EFD4258645C100E3E751 /* HMG_Geofence.swift in Sources */,
E923EFD62587443800E3E751 /* HMGPlatformBridge.swift in Sources */, E923EFD62587443800E3E751 /* HMGPlatformBridge.swift in Sources */,
E9F7623B25922BCE00FB5CCF /* FlutterConstants.swift in Sources */,
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
E9E27168256E3A4000F49B69 /* LocalizedFromFlutter.swift in Sources */, E9E27168256E3A4000F49B69 /* LocalizedFromFlutter.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
@ -472,7 +480,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = 3A359E86ZF;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -611,7 +619,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = 3A359E86ZF;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -644,7 +652,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = 3A359E86ZF;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",

@ -2,46 +2,67 @@ import UIKit
import Flutter import Flutter
import GoogleMaps import GoogleMaps
var userNotificationCenterDelegate:UNUserNotificationCenterDelegate? = nil
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
let locationManager = CLLocationManager() let locationManager = CLLocationManager()
var flutterViewController:MainFlutterVC!
override func application( _ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { override func application( _ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// initLocationManager()
GMSServices.provideAPIKey("AIzaSyCiiJiHkocPbcziHt9O8rGWavDrxHRQys8") GMSServices.provideAPIKey("AIzaSyCiiJiHkocPbcziHt9O8rGWavDrxHRQys8")
GeneratedPluginRegistrant.register(with: self) GeneratedPluginRegistrant.register(with: self)
if let mainViewController = window.rootViewController as? MainFlutterVC{ initializePlatformChannel()
HMGPlatformBridge.initialize(flutterViewController: mainViewController)
}
if let _ = launchOptions?[.location] { if let _ = launchOptions?[.location] {
HMG_Geofence.initGeofencing() HMG_Geofence.initGeofencing()
} }
UNUserNotificationCenter.current().delegate = self
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }
}
extension AppDelegate: CLLocationManagerDelegate {
func initLocationManager(){ func initializePlatformChannel(){
locationManager.allowsBackgroundLocationUpdates = true if let mainViewController = window.rootViewController as? MainFlutterVC{ // platform initialization suppose to be in foreground
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters flutterViewController = mainViewController
locationManager.activityType = .other HMGPlatformBridge.initialize(flutterViewController: flutterViewController)
locationManager.delegate = self
locationManager.requestAlwaysAuthorization() }else if let mainViewController = initialViewController(){ // platform initialization suppose to be in background
flutterViewController = mainViewController
HMGPlatformBridge.initialize(flutterViewController: flutterViewController)
}
} }
func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
if region is CLCircularRegion { func initialViewController() -> MainFlutterVC?{
return nil //UIStoryboard(name: "Main", bundle: .main).instantiateInitialViewController() as? MainFlutterVC
} }
} }
func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { extension AppDelegate{
if region is CLCircularRegion { override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if (notification.request.content.categoryIdentifier == HmgLocalNotificationCategoryIdentifier){
completionHandler([.alert,.sound])
}else{
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
} }
}
} }
/*
let dart = FlutterDartProject(precompiledDartBundle: .main)
let engine = FlutterEngine(name: "com.hmg.cs", project: dart, allowHeadlessExecution: true)
if engine.run(){
flutterMethodChannel = FlutterMethodChannel(name: "HMG-Platform-Bridge", binaryMessenger: engine.binaryMessenger)
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false) { (timer) in
FlutterText.with(key: "alreadyConnectedHmgNetwork"){ localized in
print(localized)
}
}
}
*/

@ -13,5 +13,10 @@ fileprivate let BASE_URL = "\(DOMAIN)/\(SERVICE)"
struct API { struct API {
static let WIFI_CREDENTIALS = "\(BASE_URL)/Hmg_SMS_Get_By_ProjectID_And_PatientID" static let WIFI_CREDENTIALS = "\(BASE_URL)/Hmg_SMS_Get_By_ProjectID_And_PatientID"
} }
//struct API {
// static let WIFI_CREDENTIALS = FlutterConstants.WIFI_CREDENTIALS_URL
// static let LOG_GEOFENCE = FlutterConstants.LOG_GEOFENCE_URL
//}

@ -18,6 +18,24 @@ extension String{
} }
} }
extension Date{
func toString(format:String) -> String{
let df = DateFormatter()
df.dateFormat = format
return df.string(from: self)
}
}
extension Dictionary{
func merge(dict:[String:Any?]) -> [String:Any?]{
var self_ = self as! [String:Any?]
dict.forEach { (kv) in
self_.updateValue(kv.value, forKey: kv.key)
}
return self_
}
}
extension Bundle { extension Bundle {
func certificate(named name: String) -> SecCertificate { func certificate(named name: String) -> SecCertificate {

@ -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
}
}
}
}
}

@ -31,27 +31,59 @@ func dictionary(from:String) -> [String:Any]?{
} }
func showNotification(identifier:String? = nil, title:String?, subtitle:String?, message:String?, sound:UNNotificationSound = UNNotificationSound.default){ let HmgLocalNotificationCategoryIdentifier = "hmg.local.notification"
let notificationContent = UNMutableNotificationContent() func showNotification(identifier:String? = nil, title:String?, subtitle:String?, message:String?, sound:UNNotificationSound = UNNotificationSound.default, categoryIdentifier:String = HmgLocalNotificationCategoryIdentifier){
DispatchQueue.main.async {
if identifier != nil { notificationContent.categoryIdentifier = identifier! } let notificationContent = UNMutableNotificationContent()
if title != nil { notificationContent.title = title! } notificationContent.categoryIdentifier = categoryIdentifier
if subtitle != nil { notificationContent.body = message! }
if message != nil { notificationContent.subtitle = subtitle! } if identifier != nil { notificationContent.categoryIdentifier = identifier! }
if title != nil { notificationContent.title = title! }
notificationContent.sound = UNNotificationSound.default if subtitle != nil { notificationContent.body = message! }
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false) if message != nil { notificationContent.subtitle = subtitle! }
let request = UNNotificationRequest(identifier: "\(Date().timeIntervalSinceNow)", content: notificationContent, trigger: trigger)
UNUserNotificationCenter.current().add(request) { error in notificationContent.sound = UNNotificationSound.default
if let error = error { let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
print("Error: \(error)") let request = UNNotificationRequest(identifier: "\(Date().timeIntervalSinceNow)", content: notificationContent, trigger: trigger)
UNUserNotificationCenter.current().add(request) { error in
if let error = error {
print("Error: \(error)")
}
} }
} }
} }
func appLanguageCode() -> Int{
let lang = UserDefaults.standard.string(forKey: "language") ?? "ar"
return lang == "ar" ? 2 : 1
}
func userProfile() -> [String:Any?]?{
var userProf = UserDefaults.standard.string(forKey: "flutter.imei-user-data")
if(userProf == nil){
userProf = UserDefaults.standard.string(forKey: "flutter.user-profile")
}
return dictionary(from: userProf ?? "{}")
}
func httpPostRequest(urlString:String, jsonBody:[String:Any], completion:((Bool,[String:Any]?)->Void)?){ fileprivate let defaultHTTPParams:[String : Any?] = [
let json: [String: Any] = jsonBody "ZipCode" : "966",
"VersionID" : 5.8,
"Channel" : 3,
"LanguageID" : appLanguageCode(),
"IPAdress" : "10.20.10.20",
"generalid" : "Cs2020@2016$2958",
"PatientOutSA" : 0,
"SessionID" : nil,
"isDentalAllowedBackend" : false,
"DeviceTypeID" : 2
]
func httpPostRequest(urlString:String, jsonBody:[String:Any?], completion:((Bool,[String:Any]?)->Void)?){
var json: [String: Any?] = jsonBody
json = json.merge(dict: defaultHTTPParams)
let jsonData = try? JSONSerialization.data(withJSONObject: json) let jsonData = try? JSONSerialization.data(withJSONObject: json)
// create post request // create post request
@ -77,6 +109,8 @@ func httpPostRequest(urlString:String, jsonBody:[String:Any], completion:((Bool,
completion?(false,responseJSON) completion?(false,responseJSON)
} }
}else{
completion?(false,nil)
} }
} }

@ -49,6 +49,9 @@ class HMGPlatformBridge{
print("") print("")
} }
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: false) { (timer) in
FlutterConstants.set()
}
} }

@ -129,8 +129,10 @@ extension HMG_Geofence : CLLocationManagerDelegate{
extension HMG_Geofence{ extension HMG_Geofence{
func handleEvent(for region: CLRegion!, transition:Transition, location:CLLocation?) { func handleEvent(for region: CLRegion!, transition:Transition, location:CLLocation?) {
notifyUser(forRegion: region, transition: transition, location: locationManager.location) if let userProfile = userProfile(){
notifyServer(forRegion: region, transition: transition, location: locationManager.location) notifyUser(forRegion: region, transition: transition, location: locationManager.location, userProfile: userProfile)
notifyServer(forRegion: region, transition: transition, location: locationManager.location, userProfile: userProfile)
}
} }
func geoZone(by id: String) -> GeoZoneModel? { func geoZone(by id: String) -> GeoZoneModel? {
@ -144,20 +146,14 @@ extension HMG_Geofence{
} }
func notifyUser(forRegion:CLRegion, transition:Transition, location:CLLocation?){ func notifyUser(forRegion:CLRegion, transition:Transition, location:CLLocation?, userProfile:[String:Any?]){
if let zone = geoZone(by: forRegion.identifier){ if let patientId = userProfile["PatientID"] as? Int{
if UIApplication.shared.applicationState == .active {
mainViewController.showAlert(withTitle: transition.name(), message: zone.message())
}else{
}
} }
} }
func notifyServer(forRegion:CLRegion, transition:Transition, location:CLLocation?){ func notifyServer(forRegion:CLRegion, transition:Transition, location:CLLocation?, userProfile:[String:Any?]){
df.dateFormat = "MMM/dd/yyyy hh:mm:ss" if let patientId = userProfile["PatientID"] as? Int{
if let userProfileJson = UserDefaults.standard.string(forKey: "flutter.user-profile"),
let userProfile = dictionary(from: userProfileJson), let patientId = userProfile["PatientID"] as? Int{
if let idString = forRegion.identifier.split(separator: "_").first, let idInt = Int(idString){ if let idString = forRegion.identifier.split(separator: "_").first, let idInt = Int(idString){
let body:[String:Any] = [ let body:[String:Any] = [
@ -166,21 +162,19 @@ extension HMG_Geofence{
"PatientID":patientId "PatientID":patientId
] ]
var logs = UserDefaults.init(suiteName: "GeoFenceLog")?.dictionary(forKey: "GEOFENCE_LOGS") ?? [:]
var geo = (logs[forRegion.identifier] as? [String]) ?? []
let url = "https://hmgwebservices.com/Services/Patients.svc/REST/GeoF_InsertPatientFileInfo" let url = "https://hmgwebservices.com/Services/Patients.svc/REST/GeoF_InsertPatientFileInfo"
httpPostRequest(urlString: url, jsonBody: body){ (status,json) in httpPostRequest(urlString: url, jsonBody: body){ (status,json) in
let status_ = status ? "Notified" : "Not notified" let status_ = status ? "Notified successfully:" : "Failed to notify:"
showNotification(title: transition.name(), subtitle: forRegion.identifier, message: status_) showNotification(title: transition.name(), subtitle: forRegion.identifier, message: status_)
var logs = UserDefaults.init(suiteName: "GeoFenceLog")?.dictionary(forKey: "LOGS") ?? [:] geo.append("\(status_) \(transition.name()) at \(Date().toString(format: "dd/MMM/yyy hh:mm:ss"))")
if var geo = logs[forRegion.identifier] as? [String]{ logs.updateValue( geo, forKey: forRegion.identifier)
geo.append("\(status_) at \(df.string(from: Date()))")
}else{
logs.updateValue(["\(status_) at \(df.string(from: Date()))"], forKey: forRegion.identifier)
}
UserDefaults.init(suiteName: "GeoFenceLog")?.set(logs, forKey: "LOGS")
UserDefaults.init(suiteName: "GeoFenceLog")?.set(logs, forKey: "GEOFENCE_LOGS")
} }
} }
} }

File diff suppressed because one or more lines are too long

@ -32,6 +32,9 @@ const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo';
const GET_PRIVILEGE = 'Services/Patients.svc/REST/Service_Privilege'; const GET_PRIVILEGE = 'Services/Patients.svc/REST/Service_Privilege';
// Wifi Credentials
const WIFI_CREDENTIALS = "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID";
///Doctor ///Doctor
const GET_MY_DOCTOR = const GET_MY_DOCTOR =
'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult';
@ -429,7 +432,6 @@ class AppGlobal {
Request getPublicRequest() { Request getPublicRequest() {
Request request = new Request(); Request request = new Request();
request.VersionID = 5.6; //3.6;
request.Channel = 3; request.Channel = 3;
request.IPAdress = "10.20.10.20"; request.IPAdress = "10.20.10.20";
request.generalid = 'Cs2020@2016\$2958'; request.generalid = 'Cs2020@2016\$2958';

@ -242,6 +242,10 @@ const Map localizedValues = {
"en": "Email Sent Successfully", "en": "Email Sent Successfully",
"ar": "تم إرسال البريد الإلكتروني بنجاح" "ar": "تم إرسال البريد الإلكتروني بنجاح"
}, },
"EmailSentError": {
"en": "Error Sending Email",
"ar": "خطأ في إرسال البريد الإلكتروني"
},
"close": {"en": "Close", "ar": "مغلق"}, "close": {"en": "Close", "ar": "مغلق"},
"booked": {"en": "Booked", "ar": "محجوز"}, "booked": {"en": "Booked", "ar": "محجوز"},
"confirmed": {"en": "Confirmed", "ar": "مؤكد"}, "confirmed": {"en": "Confirmed", "ar": "مؤكد"},
@ -1218,6 +1222,10 @@ const Map localizedValues = {
"en": "Send a copy of this report to the email", "en": "Send a copy of this report to the email",
"ar": "أرسل نسخة من هذا التقرير إلى البريد الإلكتروني" "ar": "أرسل نسخة من هذا التقرير إلى البريد الإلكتروني"
}, },
"update-email-msg": {
"en": "Email updated",
"ar": "تم تحديث البريد الالكتروني"
},
"update-email": {"en": "Update Email", "ar": "تحديث البريد الالكتروني"}, "update-email": {"en": "Update Email", "ar": "تحديث البريد الالكتروني"},
"booked-success": { "booked-success": {
"en": "The appointment has been successfully booked.", "en": "The appointment has been successfully booked.",
@ -1449,6 +1457,10 @@ const Map localizedValues = {
"en": "View List of Children", "en": "View List of Children",
"ar": "عرض قائمة الأطفال" "ar": "عرض قائمة الأطفال"
}, },
"trackDeliveryDriver": {
"en": "Track Delivery Driver",
"ar": "trackDeliveryDriver"
},
"covidTest": { "covidTest": {
"en": "COVID-19 TEST", "en": "COVID-19 TEST",
"ar": "فحص كورونا" "ar": "فحص كورونا"
@ -1486,6 +1498,31 @@ const Map localizedValues = {
"ar": "سكر الدم" "ar": "سكر الدم"
}, },
"covid19_driveThrueTest": {
"en": "'Covid-19- Drive-Thru Test'",
"ar": "Covid-19- الفحص من خلال القيادة"
},
"E-Referral": {
"en": "'E-Referral'",
"ar": "الإحالة الإلكترونية"
},
"childName": {
"en": "'CHILD NAME'",
"ar": "إسم الطفل"
},
"recordDeleted": {
"en": "'Record Deleted'",
"ar": "تم حذف السجل"
},
"msg_email_address_up_to_date": {
"en": "Please ensure that the email address is up-to-date and process to view the schedule",
"ar": "يرجى التأكد من أن عنوان البريد الإلكتروني محدث وأن العملية لعرض الجدول الزمني"
},
"add-new-child": {"en" : "ADD NEW CHILD", "ar": "إضافة طفل جديد"},
"visit": {"en" : "Visit", "ar": "الزيارة"},
"send-child-email-msg": {"en" : "Send the child's schedule to the email", "ar": "أرسل جدول الطفل إلى البريد الإلكتروني"},
"vaccination-add-child-msg": {"en" : "Add the child's information below to receive the schedule of vaccinations.", "ar": "أضف معلومات الطفل أدناه للحصول على جدول التطعيمات."},
"child_added_successfully": {"en" : "Child added successfully", "ar": "تمت إضافة الطفل بنجاح"},
"my-tracker": { "my-tracker": {
"en": "My Tracker", "en": "My Tracker",
"ar": "قراءاتي" "ar": "قراءاتي"

@ -2,6 +2,7 @@
import 'dart:convert'; import 'dart:convert';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyImageObject.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyImageObject.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
List<OrderModel> orderModelFromJson(String str) => List<OrderModel>.from(json.decode(str).map((x) => OrderModel.fromJson(x))); List<OrderModel> orderModelFromJson(String str) => List<OrderModel>.from(json.decode(str).map((x) => OrderModel.fromJson(x)));
@ -306,7 +307,22 @@ class IngAddress {
String customerAttributes; String customerAttributes;
DateTime createdOnUtc; DateTime createdOnUtc;
dynamic province; dynamic province;
LatLong latLong; String latLong;
LatLng getLocation(){
if(latLong.contains(',')){
var parts = latLong.trim().split(',');
if(parts.length == 2){
var lat = double.tryParse(parts.first);
var lng = double.tryParse(parts.last);
if(lat != null || lng != null) {
var location = LatLng(lat, lng);
return location;
}
}
}
return null;
}
factory IngAddress.fromJson(Map<String, dynamic> json) => IngAddress( factory IngAddress.fromJson(Map<String, dynamic> json) => IngAddress(
id: json["id"], id: json["id"],
@ -326,7 +342,7 @@ class IngAddress {
customerAttributes: json["customer_attributes"], customerAttributes: json["customer_attributes"],
createdOnUtc: DateTime.parse(json["created_on_utc"]), createdOnUtc: DateTime.parse(json["created_on_utc"]),
province: json["province"], province: json["province"],
latLong: latLongValues.map[json["lat_long"]], latLong: json["lat_long"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@ -347,7 +363,7 @@ class IngAddress {
"customer_attributes": customerAttributes, "customer_attributes": customerAttributes,
"created_on_utc": createdOnUtc.toIso8601String(), "created_on_utc": createdOnUtc.toIso8601String(),
"province": province, "province": province,
"lat_long": latLongValues.reverse[latLong], "lat_long": latLong,
}; };
} }
@ -491,9 +507,9 @@ class OrderModelCustomer {
isSystemAccount: json["is_system_account"], isSystemAccount: json["is_system_account"],
systemName: json["system_name"], systemName: json["system_name"],
lastIpAddress: lastIpAddressValues.map[json["last_ip_address"]], lastIpAddress: lastIpAddressValues.map[json["last_ip_address"]],
createdOnUtc: DateTime.parse(json["created_on_utc"]), createdOnUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["created_on_utc"]) : null,
lastLoginDateUtc: DateTime.parse(json["last_login_date_utc"]), lastLoginDateUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["last_login_date_utc"]) : null,
lastActivityDateUtc: DateTime.parse(json["last_activity_date_utc"]), lastActivityDateUtc: (json["created_on_utc"] != null) ? DateTime.parse(json["last_activity_date_utc"]) : null,
registeredInStoreId: json["registered_in_store_id"], registeredInStoreId: json["registered_in_store_id"],
roleIds: List<int>.from(json["role_ids"].map((x) => x)), roleIds: List<int>.from(json["role_ids"].map((x) => x)),
); );

@ -1,7 +1,9 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import '../base_service.dart'; import '../base_service.dart';
class VaccinationTableService extends BaseService { class VaccinationTableService extends BaseService {
@ -10,19 +12,18 @@ class VaccinationTableService extends BaseService {
Future getCreateVaccinationTableOrders() async { Future getCreateVaccinationTableOrders(List_BabyInformationModel babyInfo, bool sendEmail) async {
String babyBDFormatted = "${DateUtil.convertDateToString(babyInfo.dOB)}/";
hasError = false; hasError = false;
await getUser(); await getUser();
body['BabyName']="fffffffffff eeeeeeeeeeeeee"; body['BabyName']= babyInfo.babyName;
body['DOB'] = "/Date(1585774800000+0300)/"; body['DOB'] = babyBDFormatted;
body['EmailAddress'] = user.emailAddress; body['EmailAddress'] = user.emailAddress;
body['isDentalAllowedBackend'] = false; body['isDentalAllowedBackend'] = false;
body['SendEmail'] = false; body['SendEmail'] = sendEmail;
body['IsLogin'] =true; body['IsLogin'] =true;
await baseAppClient.post(GET_TABLE_REQUEST, await baseAppClient.post(GET_TABLE_REQUEST,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
createVaccinationTableModelList.clear(); createVaccinationTableModelList.clear();

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart'; import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart';
import 'package:diplomaticquarterapp/core/service/childvaccines/add_new_child_service.dart'; import 'package:diplomaticquarterapp/core/service/childvaccines/add_new_child_service.dart';
@ -11,14 +12,12 @@ import '../base_view_model.dart';
class VaccinationTableViewModel extends BaseViewModel{ class VaccinationTableViewModel extends BaseViewModel{
VaccinationTableService _creteVaccinationTableService = locator<VaccinationTableService>(); VaccinationTableService _creteVaccinationTableService = locator<VaccinationTableService>();
List<CreateVaccinationTable> get creteVaccinationTableModelList=> _creteVaccinationTableService.createVaccinationTableModelList;
// String get creteVaccinationTableContent => _creteVaccinationTableService.userAgreementContent; getCreateVaccinationTable(List_BabyInformationModel babyInfo, bool sendEmail) async {
//String get userAgreementContent => _creteNewBabyService.v//_reportsService.userAgreementContent;
List<CreateVaccinationTable> get creteVaccinationTableModelList=> _creteVaccinationTableService.createVaccinationTableModelList;//.createNewBabyModelList;
getCreateVaccinationTable() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _creteVaccinationTableService.getCreateVaccinationTableOrders();//getCreateNewBabyOrders(); await _creteVaccinationTableService.getCreateVaccinationTableOrders(babyInfo, sendEmail);//getCreateNewBabyOrders();
if ( _creteVaccinationTableService.hasError) { if ( _creteVaccinationTableService.hasError) {
error = _creteVaccinationTableService.error; error = _creteVaccinationTableService.error;

@ -203,7 +203,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
imageLocation: imageLocation:
'assets/images/al-habib_online_payment_service_icon.png', 'assets/images/al-habib_online_payment_service_icon.png',
title: 'Covid-19- Drive-Thru Test', title: TranslationBase.of(context).covid19_driveThrueTest,
), ),
ServicesContainer( ServicesContainer(
onTap: () { onTap: () {
@ -227,7 +227,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
), ),
imageLocation: 'assets/images/pharmacy_logo.png', imageLocation: 'assets/images/pharmacy_logo.png',
title: 'Pharmacy'), title: TranslationBase.of(context).pharmacy),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
@ -248,7 +248,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
: EReferralPage()), : EReferralPage()),
), ),
imageLocation: 'assets/images/ereferral_service_icon.png', imageLocation: 'assets/images/ereferral_service_icon.png',
title: 'E-Referral', title: TranslationBase.of(context).ereferral,
), ),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
@ -259,7 +259,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
imageLocation: imageLocation:
'assets/images/new-design/family_menu_icon_red.png', 'assets/images/new-design/family_menu_icon_red.png',
title: 'My Family', title: TranslationBase.of(context).myFamily,
), ),
if(projectViewModel.havePrivilege(35)) if(projectViewModel.havePrivilege(35))
ServicesContainer( ServicesContainer(
@ -269,7 +269,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
imageLocation: imageLocation:
'assets/images/new-design/children_vaccines_icon.png', 'assets/images/new-design/children_vaccines_icon.png',
title: 'Child Vaccines', title: TranslationBase.of(context).childVaccine,
), ),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
@ -289,7 +289,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
FadePage(page: SymptomInfo()), FadePage(page: SymptomInfo()),
), ),
imageLocation: 'assets/images/new-design/body_icon.png', imageLocation: 'assets/images/new-design/body_icon.png',
title: 'Symptom Checker'), title: TranslationBase.of(context).symptomCheckerTitle),
if(projectViewModel.havePrivilege(36)) if(projectViewModel.havePrivilege(36))
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
@ -297,7 +297,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
FadePage(page: BloodDonationPage()), FadePage(page: BloodDonationPage()),
), ),
imageLocation: 'assets/images/new-design/blood_icon.png', imageLocation: 'assets/images/new-design/blood_icon.png',
title: 'Blood Donation', title: TranslationBase.of(context).bloodD,
), ),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
@ -308,7 +308,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
imageLocation: imageLocation:
'assets/images/new-design/health_calculator_icon.png', 'assets/images/new-design/health_calculator_icon.png',
title: 'Health Calculators', title: TranslationBase.of(context).calculators,
), ),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(
@ -319,7 +319,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
), ),
imageLocation: imageLocation:
'assets/images/new-design/health_convertor_icon.png', 'assets/images/new-design/health_convertor_icon.png',
title: 'Health Converter', title: TranslationBase.of(context).converters,
), ),
if(projectViewModel.havePrivilege(38)) if(projectViewModel.havePrivilege(38))
ServicesContainer( ServicesContainer(
@ -370,7 +370,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
}, },
imageLocation: imageLocation:
'assets/images/new-design/twitter_dashboard_icon.png', 'assets/images/new-design/twitter_dashboard_icon.png',
title: 'Latest News', title: TranslationBase.of(context).latestNews,
), ),
ServicesContainer( ServicesContainer(
onTap: () => Navigator.push( onTap: () => Navigator.push(

@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/DayCheckBoxDialog.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/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -84,10 +85,12 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return BaseView<AddNewChildViewModel>( return BaseView<AddNewChildViewModel>(
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarTitle: "Vaccintion", appBarTitle: TranslationBase.of(context).vaccination,
body: SingleChildScrollView( body: SingleChildScrollView(
physics: ScrollPhysics(), physics: ScrollPhysics(),
child: Container( child: Container(
@ -96,10 +99,10 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
// crossAxisAlignment: CrossAxisAlignment.center, // crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
height: 50, height: 20,
), ),
Texts( Texts(
"Add the child's information below to recieve the schedule of vaccinations.", TranslationBase.of(context).vaccinationAddChildMsg,
//+model.user.firstName, //+model.user.firstName,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
@ -107,14 +110,14 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
height: 12, height: 12,
), ),
NewTextFields( NewTextFields(
hintText: "First Name", hintText: TranslationBase.of(context).firstName,
controller: _firstTextController, controller: _firstTextController,
), ),
SizedBox( SizedBox(
height: 12, height: 12,
), ),
NewTextFields( NewTextFields(
hintText: "Second Name", hintText: TranslationBase.of(context).middleName,
controller: _secondTextController, controller: _secondTextController,
), ),
SizedBox( SizedBox(
@ -124,62 +127,57 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Gender:", TranslationBase.of(context).gender,
textAlign: TextAlign.end, textAlign: TextAlign.end,
), ),
], ],
), ),
Container( Container(
height: MediaQuery.of(context).size.height * 0.12,
width: double.infinity, width: double.infinity,
height: size.height * 0.12,
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Expanded(
height: MediaQuery.of(context).size.height * 0.12, child: Container(
width: 175, color: Colors.white,
color: Colors.white, child: SecondaryButton(
child: SecondaryButton( textColor:
textColor: checkedValue == 1 ? Colors.white : Colors.black,
checkedValue == 1 ? Colors.white : Colors.black, color: checkedValue == 1 ? Colors.red : Colors.white,
color: checkedValue == 1 ? Colors.red : Colors.white, label: TranslationBase.of(context).male,
onTap: () {
label: "Male", setState(() {
// checkedValue = 1;
onTap: () { print("checkedValue=" + checkedValue.toString());
});
setState(() { // bloodDetails.
checkedValue = 1; },
print("checkedValue=" + checkedValue.toString()); ),
});
// bloodDetails.
},
), ),
), ),
Container( Expanded(
height: MediaQuery.of(context).size.height * 0.12, child: Container(
width: 175, color: Colors.white,
color: Colors.white, child: SecondaryButton(
child: SecondaryButton( textColor:
textColor: checkedValue == 2 ? Colors.white : Colors.black,
checkedValue == 2 ? Colors.white : Colors.black, color: checkedValue == 2 ? Colors.red : Colors.white,
color: checkedValue == 2 ? Colors.red : Colors.white, label: TranslationBase.of(context).female,
label: "Female", //
// onTap: () {
onTap: () { setState(() {
setState(() { checkedValue = 2;
checkedValue = 2; print("checkedValue=" + checkedValue.toString());
print("checkedValue=" + checkedValue.toString()); });
}); // bloodDetails.city=_selectedHospital.toString();
// bloodDetails.city=_selectedHospital.toString();
// bloodDetails. // bloodDetails.
}, },
),
), ),
) )
], ],
@ -193,7 +191,7 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Date Of Birth::", TranslationBase.of(context).dob,
textAlign: TextAlign.end, textAlign: TextAlign.end,
), ),
], ],
@ -249,29 +247,29 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
color: checkedValue == false color: checkedValue == false
? Colors.white24 ? Colors.white24
: Color.fromRGBO( : Color.fromRGBO(
63, 63,
72, 72,
74, 74,
1, 1,
), ),
label: "Add", label: TranslationBase.of(context).add,
// //
onTap: () async{ onTap: () async {
newChild.babyName = _firstTextController.text + " " + _secondTextController.text; newChild.babyName = _firstTextController.text +
" " +
_secondTextController.text;
newChild.gender = checkedValue.toString(); newChild.gender = checkedValue.toString();
newChild.strDOB = getStartDay(); newChild.strDOB = getStartDay();
newChild.tempValue = true; newChild.tempValue = true;
newChild.isLogin = true; newChild.isLogin = true;
await model.createNewBabyOrders(newChild: newChild); await model.createNewBabyOrders(newChild: newChild);
if(model.isAdded){ if (model.isAdded) {
AppToast.showSuccessToast(message: "Record Added"); AppToast.showSuccessToast(message: TranslationBase.of(context).childAddedSuccessfully);
Navigator.pop(context,model.isAdded); Navigator.pop(context, model.isAdded);
}else{ } else {
//TODO handling error //TODO handling error
} }
}, },
), ),
), ),
@ -280,7 +278,7 @@ class _AddNewChildPageState extends State<AddNewChildPage> {
), ),
), ),
), ),
// bottomSheet: // bottomSheet:
), ),
); );
} }

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/ChildVaccines/add_newchild_page.dart'
import 'package:diplomaticquarterapp/pages/ChildVaccines/vaccinationtable_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/vaccinationtable_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -22,30 +23,51 @@ class ChildPage extends StatefulWidget {
class _ChildPageState extends State<ChildPage> class _ChildPageState extends State<ChildPage>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
DeleteBaby deleteBaby = DeleteBaby(); DeleteBaby deleteBaby = DeleteBaby();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
final double height = (size.height - kToolbarHeight - 60);
final double itemWidth = size.width / 2;
final double itemHeight = height / 2 + 40;
var checkedValue = true; var checkedValue = true;
return BaseView<ChildVaccinesViewModel>( return BaseView<ChildVaccinesViewModel>(
onModelReady: (model) => model.getNewUserOrders(), onModelReady: (model) => model.getNewUserOrders(),
builder: (_, model, widget) => AppScaffold( builder: (_, model, widget) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
appBarTitle: " Vaccination", appBarTitle: TranslationBase.of(context).vaccination,
baseViewModel: model, baseViewModel: model,
body: SingleChildScrollView( body: Container(
child: Container( height: height * 0.85,
margin: EdgeInsets.only(left: 15, right: 15, top: 70), child: SingleChildScrollView(
child: Column( child: Container(
children: [ margin: EdgeInsets.only(left: 8, right: 8, top: 16),
...List.generate( child: GridView.count(
crossAxisCount: 2,
childAspectRatio: (itemWidth / (itemHeight + 0)),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
controller: ScrollController(keepScrollOffset: true),
shrinkWrap: true,
padding: const EdgeInsets.all(4.0),
children: [
...List.generate(
model.babyInformationModelList.length, model.babyInformationModelList.length,
(index) => Container( (index) => InkWell(
margin: EdgeInsets.only( onTap: () {
left: 0, right: 0, bottom: 20), Navigator.push(
context,
decoration: BoxDecoration( FadePage(
page: VaccinationTablePage(model.babyInformationModelList[index]),
),
);
},
child: Container(
margin: EdgeInsets.only(
left: 0, right: 0, bottom: 20),
decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
border: Border.all( border: Border.all(
color: Colors.white, width: 0.5), color: Colors.white, width: 0.5),
@ -54,11 +76,12 @@ class _ChildPageState extends State<ChildPage>
color: Colors.white, color: Colors.white,
), ),
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
width: 200,//double.infinity, //double.infinity,
child: Column( child: Column(
children: [ children: [
Row(children: [ Row(children: [
Texts("CHILD NAME"), Texts(TranslationBase.of(context)
.childName),
]), ]),
Row(children: [ Row(children: [
Texts(model Texts(model
@ -96,19 +119,14 @@ class _ChildPageState extends State<ChildPage>
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
page: VaccinationTablePage(model.babyInformationModelList[index]),
page: VaccinationTablePage(),
), ),
); );
}, },
) )
]), ]),
Row(children: [ Row(children: [
Texts("Birthday"), Texts(TranslationBase.of(context).dob),
]), ]),
Row(children: [ Row(children: [
IconButton( IconButton(
@ -116,9 +134,7 @@ class _ChildPageState extends State<ChildPage>
'assets/images/new-design/calender-secondary.png'), 'assets/images/new-design/calender-secondary.png'),
tooltip: '', tooltip: '',
onPressed: () { onPressed: () {
setState(() { setState(() {});
});
}, },
), ),
Texts(DateUtil.yearMonthDay(model Texts(DateUtil.yearMonthDay(model
@ -130,73 +146,71 @@ class _ChildPageState extends State<ChildPage>
icon: new Image.asset( icon: new Image.asset(
'assets/images/new-design/garbage.png'), 'assets/images/new-design/garbage.png'),
tooltip: '', tooltip: '',
onPressed: ()async { onPressed: () async {
//===================== //=====================
await model.deleteBabyOrders(newChild:deleteBaby ); await model.deleteBabyOrders(
newChild: deleteBaby);
deleteBaby.babyID=model.babyInformationModelList[index] deleteBaby.babyID = model
.babyInformationModelList[index]
.babyID; .babyID;
await model.deleteBabyOrders(newChild:deleteBaby ); await model.deleteBabyOrders(
if(model.isDeleted){ newChild: deleteBaby);
AppToast.showSuccessToast(message: "Record Deleted"); if (model.isDeleted) {
Navigator.pop(context,model.isDeleted); AppToast.showSuccessToast(
}else{ message:
TranslationBase.of(context)
//TODO handling error .recordDeleted);
} Navigator.pop(
context, model.isDeleted);
} else {
//TODO handling error
}
}, },
), ),
Texts("Delete"), Texts(TranslationBase.of(context)
.deleteView),
]), ]),
SizedBox( SizedBox(
height: 12, height: 12,
), ),
], ],
), ),
),
), ),
)
],
) ))),
],
))
), ),
bottomSheet: Container( bottomSheet: Container(
height: MediaQuery.of(context).size.height * 0.12, height: height * 0.15,
width: double.infinity, width: double.infinity,
padding: EdgeInsets.all(15), padding: EdgeInsets.all(16),
child: SecondaryButton( child: SecondaryButton(
textColor: Colors.white, textColor: Colors.white,
color: checkedValue == false color: checkedValue == false
? Colors.white24 ? Colors.white24
: Color.fromRGBO( : Color.fromRGBO(
63, 63,
72, 72,
74, 74,
1, 1,
),
label: "ADD NEW CHILD ",
//
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddNewChildPage(),
),
).then((value) {
if (value) model.getNewUserOrders();
});
},
),
), ),
label: TranslationBase.of(context).addNewChild,
//
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddNewChildPage(),
),
).then((value) {
if (value) model.getNewUserOrders();
});
},
),
),
)); ));
} }
} }

@ -1,10 +1,10 @@
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/child_vaccines_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart';
import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/child_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
@ -13,214 +13,218 @@ 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';
class ChildVaccinesPage extends StatefulWidget { class ChildVaccinesPage extends StatefulWidget {
@override @override
_ChildVaccinesPageState createState() => _ChildVaccinesPageState(); _ChildVaccinesPageState createState() => _ChildVaccinesPageState();
} }
class _ChildVaccinesPageState extends State<ChildVaccinesPage> class _ChildVaccinesPageState extends State<ChildVaccinesPage>
with SingleTickerProviderStateMixin{ with SingleTickerProviderStateMixin {
TextEditingController titleController = TextEditingController(); TextEditingController titleController = TextEditingController();
var checkedValue=false; var checkedValue = false;
String addEmail=""; String addEmail = "";
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<UserInformationViewModel>( return BaseView<UserInformationViewModel>(
onModelReady: (model) => model.getUserInformationRequestOrders(), onModelReady: (model) => model.getUserInformationRequestOrders(),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
baseViewModel: model, baseViewModel: model,
appBarTitle: " Vaccination",//TranslationBase.of(context).advancePayment, appBarTitle: TranslationBase.of(context).vaccination,
body: SingleChildScrollView( //TranslationBase.of(context).advancePayment,
physics: ScrollPhysics(), body: SingleChildScrollView(
child: Column( physics: ScrollPhysics(),
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start,
children: [ mainAxisAlignment: MainAxisAlignment.spaceAround,
SizedBox( children: [
height: 20, SizedBox(
), height: 20,
),
Padding( Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child:Container( child: Container(
child: Texts("Welcome back",fontSize: 20,), child: Texts(
) , TranslationBase.of(context).welcomeBack,
), fontSize: 20,
Divider(color:Colors.black , indent: 10,
endIndent: 10,),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.all(10.0),
child:Container(
child: Texts("Please ensure that the email address is up-to-date and process to view the schedule",fontSize: 20,),
) ,
), ),
),
Divider(color:Colors.black , indent: 10, ),
endIndent: 10,), Divider(
Padding( color: Colors.black,
padding: const EdgeInsets.all(10.0), indent: 10,
child:Container( endIndent: 10,
),
margin: EdgeInsets.only(left: 10, right: 10, top: 15), SizedBox(
child: TextFields( height: 20,
fillColor: Colors.red, ),
Padding(
hintText: model.user.emailAddress, padding: const EdgeInsets.all(10.0),
controller: titleController, child: Container(
fontSize: 20, child: Texts(
hintColor: Colors.black, TranslationBase.of(context).msg_email_address_up_to_date,
fontWeight: FontWeight.w600, fontSize: 20,
onChanged: (text) {
addEmail=text;
model.user.emailAddress==addEmail?checkedValue=false:checkedValue=true;
},
validator: (value) {
if (value == null)
{
return model.user.emailAddress;
}
else
{
return model.user.emailAddress;}
},
),
),
), ),
Container( ),
height: MediaQuery.of(context).size.height * 0.12, ),
width: double.infinity,
padding: EdgeInsets.all(15),
child: SecondaryButton(
textColor: Colors.white,
color: checkedValue== false ?Colors.white24:Color.fromRGBO(63, 72, 74, 1,),
label: "UPDATE EMAIL",
//
onTap: (){
model.user.emailAddress=addEmail.toString();
AppToast.showSuccessToast(
message: "Email updated");
// bloodDetails.city=_selectedHospital.toString();
// bloodDetails.
},
), Divider(
color: Colors.black,
indent: 10,
endIndent: 10,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
margin: EdgeInsets.only(left: 10, right: 10, top: 15),
child: TextFields(
fillColor: Colors.red,
hintText: model.user.emailAddress,
controller: titleController,
fontSize: 20,
hintColor: Colors.black,
fontWeight: FontWeight.w600,
onChanged: (text) {
addEmail = text;
model.user.emailAddress == addEmail
? checkedValue = false
: checkedValue = true;
},
validator: (value) {
if (value == null) {
return model.user.emailAddress;
} else {
return model.user.emailAddress;
}
},
), ),
Container( ),
height: MediaQuery.of(context).size.height * 0.12, ),
width: double.infinity, Container(
height: MediaQuery.of(context).size.height * 0.12,
padding: EdgeInsets.all(15), width: double.infinity,
child: SecondaryButton( padding: EdgeInsets.all(15),
textColor: Colors.white, child: SecondaryButton(
color: Color.fromRGBO(63, 72, 74, 1,), textColor: Colors.white,
label: " VIEW LIST OF CHILDREN", color: checkedValue == false
// ? Colors.white24
onTap: () => Navigator.push( : Color.fromRGBO(
context, 63,
FadePage( 72,
page: ChildPage(), 74,
1,
),
), ),
label: TranslationBase.of(context).updateEmail,
//
), onTap: () {
), model.user.emailAddress = addEmail.toString();
AppToast.showSuccessToast(
// Texts( message: TranslationBase.of(context).updateEmailMsg);
// // TranslationBase.of(context).advancePaymentLabel, // bloodDetails.city=_selectedHospital.toString();
// model.user.emailAddress,
// textAlign: TextAlign.center, // bloodDetails.
// ), },
SizedBox( ),
height: 12, ),
), Container(
SizedBox( height: MediaQuery.of(context).size.height * 0.12,
height: 12, width: double.infinity,
), padding: EdgeInsets.all(15),
SizedBox( child: SecondaryButton(
height: 12, textColor: Colors.white,
color: Color.fromRGBO(
63,
72,
74,
1,
), ),
label: TranslationBase.of(context).viewListChildren,
SizedBox( //
height: 12, onTap: () => Navigator.push(
context,
FadePage(
page: ChildPage(),
),
), ),
),
),
SizedBox( // Texts(
height: 12, // // TranslationBase.of(context).advancePaymentLabel,
), // model.user.emailAddress,
// textAlign: TextAlign.center,
// ),
SizedBox(
height: 12,
),
SizedBox(
height: 12,
),
SizedBox(
height: 12,
),
SizedBox( SizedBox(
height: 10, height: 12,
), ),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Center(
// child: Container(
// color: Colors.white,
// width: 350,
// child: InkWell(
// onTap: () {
// showDialog(
// context: context,
// builder: (_) =>
// AssetGiffyDialog(
// title: Text(
// "",
// style: TextStyle(
// fontSize: 22.0,
// fontWeight:
// FontWeight
// .w600),
// ),
// image: Image.asset(
// 'assets/images/BloodChrt_EN.png'),
// buttonCancelText:
// Text('cancel'),
// buttonCancelColor:
// Colors.grey,
// onlyCancelButton: true,
// ));
// },
// child: Container(
// width: 250,
// height: 200,
// child:Image.asset(
// 'assets/images/BloodChrt_EN.png')),
// ),
// ),
// ),
// ],
// ),
SizedBox( SizedBox(
height: MediaQuery.of(context).size.height * 0.15, height: 12,
)
],
), ),
SizedBox(
height: 10,
),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Center(
// child: Container(
// color: Colors.white,
// width: 350,
// child: InkWell(
// onTap: () {
// showDialog(
// context: context,
// builder: (_) =>
// AssetGiffyDialog(
// title: Text(
// "",
// style: TextStyle(
// fontSize: 22.0,
// fontWeight:
// FontWeight
// .w600),
// ),
// image: Image.asset(
// 'assets/images/BloodChrt_EN.png'),
// buttonCancelText:
// Text('cancel'),
// buttonCancelColor:
// Colors.grey,
// onlyCancelButton: true,
// ));
// },
// child: Container(
// width: 250,
// height: 200,
// child:Image.asset(
// 'assets/images/BloodChrt_EN.png')),
// ),
// ),
// ),
// ],
// ),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
)
],
), ),
), ),
),
); );
} }
} }

@ -7,8 +7,11 @@ import 'package:flutter/material.dart';
class SelectGenderDialog extends StatefulWidget { class SelectGenderDialog extends StatefulWidget {
final Email; final Email;
final Function okFunction;
const SelectGenderDialog({Key key, this.Email, this.okFunction})
: super(key: key);
const SelectGenderDialog({Key key, this.Email}) : super(key: key);
@override @override
_SelectGenderDialogState createState() => _SelectGenderDialogState(); _SelectGenderDialogState createState() => _SelectGenderDialogState();
} }
@ -33,9 +36,8 @@ class _SelectGenderDialogState extends State<SelectGenderDialog> {
}); });
}, },
child: ListTile( child: ListTile(
title: Text("Send the child's schedule to the email\n Tamer.dasdasdas@gmail.com "), title: Text(
"${TranslationBase.of(context).sendChildEmailMsg}\n Tamer.dasdasdas@gmail.com "),
), ),
), ),
) )
@ -44,7 +46,6 @@ class _SelectGenderDialogState extends State<SelectGenderDialog> {
SizedBox( SizedBox(
height: 5.0, height: 5.0,
), ),
SizedBox( SizedBox(
height: 5.0, height: 5.0,
), ),
@ -82,7 +83,7 @@ class _SelectGenderDialogState extends State<SelectGenderDialog> {
flex: 1, flex: 1,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
AppToast.showSuccessToast(message: "Email Sended"); widget.okFunction();
// widget.onValueSelected(beneficiaryType); // widget.onValueSelected(beneficiaryType);
Navigator.pop(context); Navigator.pop(context);
}, },
@ -105,7 +106,4 @@ class _SelectGenderDialogState extends State<SelectGenderDialog> {
], ],
); );
} }
} }

@ -1,8 +1,13 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/vaccination_table_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/vaccination_table_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/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';
@ -12,91 +17,161 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'dialogs/SelectGenderDialog.dart'; import 'dialogs/SelectGenderDialog.dart';
class VaccinationTablePage extends StatelessWidget { class VaccinationTablePage extends StatelessWidget {
final List_BabyInformationModel babyInfo;
VaccinationTablePage(this.babyInfo);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
final double height = (size.height - kToolbarHeight - 60);
var checkedValue; var checkedValue;
return BaseView<VaccinationTableViewModel>( return BaseView<VaccinationTableViewModel>(
onModelReady: (model) => model.getCreateVaccinationTable(),//getUserTermsAndConditions(), onModelReady: (model) => model.getCreateVaccinationTable(babyInfo, false),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
baseViewModel: model, baseViewModel: model,
appBarTitle: "Vaccination", appBarTitle: TranslationBase.of(context).vaccination,
body: SingleChildScrollView( body: Container(
child:Container( height: height * 0.85,
margin: EdgeInsets.only(left: 15,right: 15,top: 70), child: SingleChildScrollView(
child: Column( child: Container(
children: [//babyInformationModelList.length margin: EdgeInsets.only(left: 16, right: 16, top: 16),
...List.generate(model.creteVaccinationTableModelList.length, (index) => child: Column(
Container( children: [
decoration: BoxDecoration( Row(
shape: BoxShape.rectangle, children: [
border: Border.all(color: Colors.white, width: 0.5), Expanded(
borderRadius: BorderRadius.all(Radius.circular(5)), child: Texts(TranslationBase.of(context).childName),
color: Colors.white, ),
Expanded(
), child: Texts(TranslationBase.of(context).dob),
padding: EdgeInsets.all(12), ),
width: double.infinity, ],
child: Column( ),
SizedBox(
children: [ height: 10,
Row(children: [ ),
Text(model.creteVaccinationTableModelList[index].visit), Row(
SizedBox(width: 10,), children: [
Expanded(
Expanded( child: Texts(babyInfo.babyName),
child: Column( ),
mainAxisAlignment: MainAxisAlignment.start, Expanded(
crossAxisAlignment: CrossAxisAlignment.start, child: Texts(DateUtil.getFormattedDate(
children: [ babyInfo.dOB, "MMM dd,yyyy")),
Html( ),
// data:"<html><head><style type='text/css'>.Test {list-style-image:url('http://10.50.100.198:4444/Images/Bullet_List_Small.png');}</style></head><body><table><tr align='left'><td align='left'>BCG</td></tr><tr align='left'><td align='left'>HEPATITIS B</td></tr></table></body></html>"//model.creteVaccinationTableModelList[index].vaccinesDescription ],
data:model.creteVaccinationTableModelList[index].vaccinesDescription, ),
SizedBox(
), height: 10,
],), ),
), Divider(
Text(model.creteVaccinationTableModelList[index].givenAt), color: Colors.black,
),
Row(
],), children: [
Divider(color:Colors.black ,), Text(TranslationBase.of(context).visit),
SizedBox(
], width: 25,
) ),
Expanded(
child: Text(TranslationBase.of(context).description)),
) Text(TranslationBase.of(context).dueDate),
],
) ),
], ...List.generate(
model.creteVaccinationTableModelList.length,
(index) => Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
// border: Border.all(color: Colors.white, width: 0.5),
borderRadius: BorderRadius.all(Radius.circular(5)),
// color: Colors.white,
),
padding: EdgeInsets.all(12),
width: double.infinity,
child: Column(
children: [
Row(
children: [
Text(model
.creteVaccinationTableModelList[index]
.visit),
SizedBox(
width: 10,
),
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Html(
// data:"<html><head><style type='text/css'>.Test {list-style-image:url('http://10.50.100.198:4444/Images/Bullet_List_Small.png');}</style></head><body><table><tr align='left'><td align='left'>BCG</td></tr><tr align='left'><td align='left'>HEPATITIS B</td></tr></table></body></html>"//model.creteVaccinationTableModelList[index].vaccinesDescription
data: model
.creteVaccinationTableModelList[
index]
.vaccinesDescription,
),
],
),
),
Text(model
.creteVaccinationTableModelList[index]
.givenAt),
],
),
Divider(
color: Colors.black,
),
],
)))
],
),
), ),
),
), ),
),
bottomSheet: Container( bottomSheet: Container(
height: MediaQuery.of(context).size.height * 0.12, height: height * 0.15,
width: double.infinity, width: double.infinity,
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
child: SecondaryButton( child: SecondaryButton(
textColor: Colors.white, textColor: Colors.white,
color: checkedValue== false ?Colors.white24:Color.fromRGBO(63, 72, 74, 1,), color: checkedValue == false
label: "Send Email ", ? Colors.white24
// : Color.fromRGBO(
onTap: () { 63,
//SelectGenderDialog(); 72,
74,
1,
),
label: TranslationBase.of(context).sendEmail,
//
onTap: () {
//SelectGenderDialog();
//=============== //===============
showDialog( showDialog(
context: context, context: context,
child: SelectGenderDialog( child: SelectGenderDialog(
), okFunction: () async {
); await model.getCreateVaccinationTable(babyInfo, true);
//========= if (model.state == ViewState.Idle) {
} AppToast.showSuccessToast(
message: TranslationBase.of(context)
.emailSentSuccessfully);
), } else {
AppToast.showErrorToast(
message: TranslationBase.of(context)
.EmailSentError);
}
},
),
);
//=========
}),
), ),
), ),
); );

@ -158,12 +158,14 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
}); });
}).checkAndConnectIfNoInternet(); }).checkAndConnectIfNoInternet();
if (Platform.isIOS) { if (Platform.isIOS) {
_firebaseMessaging.requestNotificationPermissions(); _firebaseMessaging.requestNotificationPermissions();
} }
// Flip Permission Checks [Zohaib Kambrani]
requestPermissions().then((results) { requestPermissions().then((results) {
registerGeofences();
if (results[Permission.notification].isGranted) if (results[Permission.notification].isGranted)
_firebaseMessaging.getToken().then((String token) { _firebaseMessaging.getToken().then((String token) {
sharedPref.setString(PUSH_TOKEN, token); sharedPref.setString(PUSH_TOKEN, token);
@ -172,7 +174,6 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
checkUserStatus(token); checkUserStatus(token);
} }
}); });
if (results[Permission.location].isGranted); if (results[Permission.location].isGranted);
if (results[Permission.storage].isGranted); if (results[Permission.storage].isGranted);
if (results[Permission.camera].isGranted); if (results[Permission.camera].isGranted);
@ -376,17 +377,6 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
// themeNotifier.setTheme(defaultTheme); // themeNotifier.setTheme(defaultTheme);
} }
void checkUserStatus(token, {isLoader = true}) async {
if (isLoader)
//GifLoaderDialogUtils.showMyDialog(context);
authService
.selectDeviceImei(token)
.then((SelectDeviceIMEIRES value) => setUserValues(value))
.catchError((err) {
//GifLoaderDialogUtils.hideDialog(context);
});
}
static Future<dynamic> myBackgroundMessageHandler( static Future<dynamic> myBackgroundMessageHandler(
Map<String, dynamic> message) async { Map<String, dynamic> message) async {
Map<String, dynamic> myMap = new Map<String, dynamic>.from(message['data']); Map<String, dynamic> myMap = new Map<String, dynamic>.from(message['data']);
@ -438,7 +428,6 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
}); });
} }
requestPermissions().then((results) {});
} }
login() async { login() async {
@ -620,11 +609,31 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
case 3: case 3:
return TranslationBase.of(context).services; return TranslationBase.of(context).services;
case 4: case 4:
return TranslationBase return TranslationBase.of(context).bookAppo;
.of(context)
.bookAppo;
} }
} }
}
void checkUserStatus(token, {isLoader = true}) async {
if (isLoader)
//GifLoaderDialogUtils.showMyDialog(context);
authService
.selectDeviceImei(token)
.then((SelectDeviceIMEIRES value) => setUserValues(value))
.catchError((err) {
//GifLoaderDialogUtils.hideDialog(context);
});
// if (await sharedPref.getObject(USER_PROFILE) != null) {
// var data = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
// if (data != null) {
// authService.registeredAuthenticatedUser(data, token, 0, 0).then((res) => {print(res)});
// authService.getDashboard().then((value) => {
// setState(() {
// notificationCount = value['List_PatientDashboard'][0]['UnreadPatientNotificationCount'].toString();
// })
// });
// }
// }
}
}

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/core/model/vital_sign/vital_sign_res_model.dart'; import 'package:diplomaticquarterapp/core/model/vital_sign/vital_sign_res_model.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_wideget.dart'; import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_wideget.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

@ -924,6 +924,7 @@ class _OrderPageState extends State<OrderPage> with SingleTickerProviderStateMix
} }
Widget getCancelledOrder(OrderModelViewModel model){ Widget getCancelledOrder(OrderModelViewModel model){
for(int i=0 ; i< model.order.length; i++){ for(int i=0 ; i< model.order.length; i++){
if( model.order[i].orderStatusId == 40 || model.order[i].orderStatusId == 996 if( model.order[i].orderStatusId == 40 || model.order[i].orderStatusId == 996
|| model.order[i].orderStatusId == 200){ || model.order[i].orderStatusId == 200){
@ -1136,13 +1137,17 @@ class _OrderPageState extends State<OrderPage> with SingleTickerProviderStateMix
), ),
), ),
); );
}
int test = Test()["1"];
}
} }
class Test<T extends String>{
static const values = {
"1":1,
"2":2,
"3":3
};
int operator [](String key) => values[key];
}

@ -1,6 +1,7 @@
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/order/TrackDriver.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -46,6 +47,7 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
var model; var model;
var isCancel = false; var isCancel = false;
var isRefund = false; var isRefund = false;
var isActiveDelivery = true;
var dataIsCancel; var dataIsCancel;
var dataIsRefund; var dataIsRefund;
@ -105,9 +107,9 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
color: getStatusBackgroundColor(), color: getStatusBackgroundColor(),
borderRadius: BorderRadius.circular(30.0)), borderRadius: BorderRadius.circular(30.0)),
child: Text( child: Text(
languageID == "ar" languageID == "ar"
? widget.orderModel.orderStatusn.toString(): ? widget.orderModel.orderStatusn.toString():
widget.orderModel.orderStatus.toString().substring(12) , widget.orderModel.orderStatus.toString().substring(12) ,
// TranslationBase.of(context).delivered, // TranslationBase.of(context).delivered,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
@ -125,8 +127,8 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
children: <Widget>[ children: <Widget>[
Text( Text(
widget.orderModel.shippingAddress.firstName widget.orderModel.shippingAddress.firstName
.toString() .toString()
.substring(10) + .substring(10) +
' ' + ' ' +
widget.orderModel.shippingAddress.lastName widget.orderModel.shippingAddress.lastName
.toString() .toString()
@ -141,18 +143,18 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
Container( Container(
margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
widget.orderModel.shippingAddress.address1 widget.orderModel.shippingAddress.address1
.toString() .toString()
.substring(9), .substring(9),
style: TextStyle( style: TextStyle(
fontSize: 10.0, fontSize: 10.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.grey, color: Colors.grey,
), ),
),] ),]
), ),
), ),
Container( Container(
@ -162,8 +164,8 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
children: <Widget>[ children: <Widget>[
Text( Text(
widget.orderModel.shippingAddress.address2 widget.orderModel.shippingAddress.address2
.toString() .toString()
.substring(9) + .substring(9) +
' ' + ' ' +
widget.orderModel.shippingAddress.country widget.orderModel.shippingAddress.country
.toString() + .toString() +
@ -231,7 +233,7 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
Container( Container(
child: flutterImage.Image.asset( child: flutterImage.Image.asset(
widget.orderModel.shippingRateComputationMethodSystemName != widget.orderModel.shippingRateComputationMethodSystemName !=
"Shipping.Aramex" "Shipping.Aramex"
? "assets/images/pharmacy_module/payment/LogoParmacyGreen.png" ? "assets/images/pharmacy_module/payment/LogoParmacyGreen.png"
: "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png",
fit: BoxFit.contain, fit: BoxFit.contain,
@ -320,19 +322,19 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
physics: ScrollPhysics(), physics: ScrollPhysics(),
itemCount:widget.orderModel.orderItems.length, itemCount:widget.orderModel.orderItems.length,
itemBuilder: (context, index){ itemBuilder: (context, index){
return Container( return Container(
child: productTile(productName: widget.orderModel.orderItems[index].product.name.toString(), child: productTile(productName: widget.orderModel.orderItems[index].product.name.toString(),
productPrice: widget.orderModel.orderItems[index].product.price.toString(), productPrice: widget.orderModel.orderItems[index].product.price.toString(),
productRate: widget.orderModel.orderItems[index].product.approvedRatingSum.toDouble(), productRate: widget.orderModel.orderItems[index].product.approvedRatingSum.toDouble(),
productReviews:widget.orderModel.orderItems[index].product.approvedTotalReviews, productReviews:widget.orderModel.orderItems[index].product.approvedTotalReviews,
totalPrice: "${(widget.orderModel.orderItems[index].product.price totalPrice: "${(widget.orderModel.orderItems[index].product.price
* widget.orderModel.orderItems[index].quantity).toStringAsFixed(2)}", * widget.orderModel.orderItems[index].quantity).toStringAsFixed(2)}",
qyt: widget.orderModel.orderItems[index].quantity.toString(), qyt: widget.orderModel.orderItems[index].quantity.toString(),
isOrderDetails:true, isOrderDetails:true,
imgs: widget.orderModel.orderItems[index].product.images != null && imgs: widget.orderModel.orderItems[index].product.images != null &&
widget.orderModel.orderItems[index].product.images.length != 0 widget.orderModel.orderItems[index].product.images.length != 0
? widget.orderModel.orderItems[index].product.images [0].src.toString() ? widget.orderModel.orderItems[index].product.images [0].src.toString()
: null, : null,
status: widget.orderModel.orderStatusId, status: widget.orderModel.orderStatusId,
product: widget.orderModel.orderItems[index].product, product: widget.orderModel.orderItems[index].product,
), ),
@ -510,58 +512,81 @@ class _OrderDetailsPageState extends State<OrderDetailsPage> {
), ),
widget.orderModel.orderStatusId == 10 widget.orderModel.orderStatusId == 10
? InkWell( ? InkWell(
onTap: () { onTap: () {
model.makeOrder(); model.makeOrder();
}, },
child: Container( child: Container(
// margin: EdgeInsets.only(top: 20.0), // margin: EdgeInsets.only(top: 20.0),
height: 50.0, height: 50.0,
color: Colors.transparent, color: Colors.transparent,
child: Container( child: Container(
padding: EdgeInsets.only(left: 130.0, right: 130.0), padding: EdgeInsets.only(left: 130.0, right: 130.0),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: Colors.green, color: Colors.green,
style: BorderStyle.solid, style: BorderStyle.solid,
width: 4.0), width: 4.0),
color: Colors.green, color: Colors.green,
borderRadius: BorderRadius.circular(5.0)), borderRadius: BorderRadius.circular(5.0)),
child: Center( child: Center(
child: Text( child: Text(
TranslationBase.of(context).payOnline, TranslationBase.of(context).payOnline,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
),
),
),
), ),
), ),
) ),
),
),
)
: Container(), : Container(),
// getCancelOrder(canCancel, canRefund), // getCancelOrder(canCancel, canRefund),
isCancel isCancel
? InkWell( ? InkWell(
onTap: () { onTap: () {
presentConfirmDialog(model, presentConfirmDialog(model,
widget.orderModel.id); //(widget.orderModel.id)); widget.orderModel.id); //(widget.orderModel.id));
// //
}, },
child: Container( child: Container(
// padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), // padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0),
height: 50.0, height: 50.0,
color: Colors.transparent, color: Colors.transparent,
child: Center( child: Center(
child: Text( child: Text(
TranslationBase.of(context).cancelOrder, TranslationBase.of(context).cancelOrder,
style: TextStyle( style: TextStyle(
color: Colors.red[900], color: Colors.red[900],
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
decoration: TextDecoration.underline), decoration: TextDecoration.underline),
), ),
), ),
), ),
) )
: Container(),
isActiveDelivery
? InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TrackDriver(order: widget.orderModel),
));
},
child: Container(
height: 50.0,
color: Colors.transparent,
child: Center(
child: Text(
TranslationBase.of(context).trackDeliveryDriver,
style: TextStyle(
color: Colors.green[900],
fontWeight: FontWeight.normal,
decoration: TextDecoration.none),
),
),
),
)
: Container(), : Container(),
], ],
), ),

@ -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
));
});
}
}
}

@ -47,18 +47,28 @@ class HMGNetworkConnectivity {
void confirmFromUser() { void confirmFromUser() {
TranslationBase translator = TranslationBase.of(context); TranslationBase translator = TranslationBase.of(context);
ConfirmDialog(
context: context, void doIt() {
confirmMessage: translator.wantToConnectWithHmgNetwork, ConfirmDialog(
okText: translator.yes, context: context,
okFunction: () { confirmMessage: translator.wantToConnectWithHmgNetwork,
ConfirmDialog.closeAlertDialog(context); okText: translator.yes,
callBack(); okFunction: () {
}, ConfirmDialog.closeAlertDialog(context);
cancelText: translator.no, callBack();
cancelFunction: () { },
ConfirmDialog.closeAlertDialog(context); cancelText: translator.no,
}).showAlertDialog(context); cancelFunction: () {
ConfirmDialog.closeAlertDialog(context);
}).showAlertDialog(context);
}
if (Platform.isAndroid)
Wifi.list(SSID).then((value) {
if (!value.indexWhere((element) => element.ssid == SSID).isNegative) doIt();
});
else
doIt();
} }
void showFailDailog(String message) { void showFailDailog(String message) {

@ -4,7 +4,7 @@ import 'package:intl/intl.dart';
class DateUtil { 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)";

@ -550,6 +550,7 @@ class TranslationBase {
localizedValues['Prescriptions'][locale.languageCode]; localizedValues['Prescriptions'][locale.languageCode];
String get history => localizedValues['History'][locale.languageCode]; String get history => localizedValues['History'][locale.languageCode];
String get orderNo => localizedValues['OrderNo'][locale.languageCode]; String get orderNo => localizedValues['OrderNo'][locale.languageCode];
String get trackDeliveryDriver => localizedValues['trackDeliveryDriver'][locale.languageCode];
String get orderDetails => String get orderDetails =>
localizedValues['OrderDetails'][locale.languageCode]; localizedValues['OrderDetails'][locale.languageCode];
String get vitalSign => localizedValues['VitalSign'][locale.languageCode]; String get vitalSign => localizedValues['VitalSign'][locale.languageCode];
@ -581,6 +582,8 @@ class TranslationBase {
localizedValues['UpdateSuccessfully'][locale.languageCode]; localizedValues['UpdateSuccessfully'][locale.languageCode];
String get emailSentSuccessfully => String get emailSentSuccessfully =>
localizedValues['EmailSentSuccessfully'][locale.languageCode]; localizedValues['EmailSentSuccessfully'][locale.languageCode];
String get EmailSentError =>
localizedValues['EmailSentError'][locale.languageCode];
String get checkVaccineAvailability => String get checkVaccineAvailability =>
localizedValues['CHECK_VACCINE_AVAILABILITY'][locale.languageCode]; localizedValues['CHECK_VACCINE_AVAILABILITY'][locale.languageCode];
String get myVaccinesAvailability => String get myVaccinesAvailability =>
@ -1172,6 +1175,7 @@ class TranslationBase {
String get infoInsurCards => localizedValues['info-insur-cards'][locale.languageCode]; String get infoInsurCards => localizedValues['info-insur-cards'][locale.languageCode];
String get scanNow => localizedValues['scan-now'][locale.languageCode]; String get scanNow => localizedValues['scan-now'][locale.languageCode];
String get pharmacyServiceTermsCondition => localizedValues['pharmacyServiceTermsCondition'][locale.languageCode]; String get pharmacyServiceTermsCondition => localizedValues['pharmacyServiceTermsCondition'][locale.languageCode];
String get recordDeleted => localizedValues['recordDeleted'][locale.languageCode];
String get referralStatus => String get referralStatus =>
localizedValues['referralStatus'][locale.languageCode]; localizedValues['referralStatus'][locale.languageCode];
@ -1214,7 +1218,6 @@ class TranslationBase {
String get viewListChildren => String get viewListChildren =>
localizedValues['view-list-children'][locale.languageCode]; localizedValues['view-list-children'][locale.languageCode];
String get addChild => localizedValues['add-child'][locale.languageCode]; String get addChild => localizedValues['add-child'][locale.languageCode];
String get childName => localizedValues['child-name'][locale.languageCode];
String get childDob => localizedValues['childDob'][locale.languageCode]; String get childDob => localizedValues['childDob'][locale.languageCode];
String get deletedChildMes => String get deletedChildMes =>
localizedValues['deleted-child-mes'][locale.languageCode]; localizedValues['deleted-child-mes'][locale.languageCode];
@ -1263,6 +1266,16 @@ class TranslationBase {
String get measureTime => localizedValues['measure-time'][locale.languageCode]; String get measureTime => localizedValues['measure-time'][locale.languageCode];
String get update => localizedValues['update'][locale.languageCode]; String get update => localizedValues['update'][locale.languageCode];
String get covid19_driveThrueTest => localizedValues['covid19_driveThrueTest'][locale.languageCode];
String get eReferral => localizedValues['E-Referral'][locale.languageCode];
String get vaccination => localizedValues["vaccination"][locale.languageCode];
String get msg_email_address_up_to_date => localizedValues["msg_email_address_up_to_date"][locale.languageCode];
String get updateEmailMsg => localizedValues["update-email-msg"][locale.languageCode];
String get childName => localizedValues["childName"][locale.languageCode];
String get addNewChild => localizedValues["add-new-child"][locale.languageCode];
String get sendChildEmailMsg => localizedValues["send-child-email-msg"][locale.languageCode];
String get vaccinationAddChildMsg => localizedValues["vaccination-add-child-msg"][locale.languageCode];
String get childAddedSuccessfully => localizedValues["child_added_successfully"][locale.languageCode];
} }

@ -4,7 +4,9 @@ import 'dart:typed_data';
import 'package:badges/badges.dart'; import 'package:badges/badges.dart';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/pages/Blood/my_balance_page.dart'; import 'package:diplomaticquarterapp/pages/Blood/my_balance_page.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart';
import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart';
@ -26,15 +28,19 @@ import 'package:diplomaticquarterapp/pages/medical/reports/report_home_page.dart
import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/smart_watch_instructions.dart'; import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/smart_watch_instructions.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart';
import 'package:diplomaticquarterapp/pages/vaccine/my_vaccines_screen.dart'; import 'package:diplomaticquarterapp/pages/vaccine/my_vaccines_screen.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/alert_dialog.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; 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:shared_preferences/shared_preferences.dart';
import '../Constants.dart'; import '../Constants.dart';
import 'app_shared_preferences.dart'; import 'app_shared_preferences.dart';
import 'app_toast.dart'; import 'app_toast.dart';
import 'gif_loader_dialog_utils.dart';
AppSharedPreferences sharedPref = new AppSharedPreferences(); AppSharedPreferences sharedPref = new AppSharedPreferences();
@ -488,13 +494,25 @@ class Utils {
), ),
)); ));
} }
if (projectViewModel.havePrivilege(32)) { if (projectViewModel.havePrivilege(32) || true) {
medical.add(InkWell( medical.add(InkWell(
//TODO onTap: () {
// onTap: () { userData().then((userData_){
// Navigator.push( if (projectViewModel.isLogin && userData_ != null) {
// context, FadePage(page: DoctorHomePage())); String patientID = userData_.patientID.toString();
// }, GifLoaderDialogUtils.showMyDialog(context);
projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)});
} else {
AlertDialogBox(
context: context,
confirmMessage: "Please login with your account first to use this feature",
okText: "OK",
okFunction: () {
AlertDialogBox.closeAlertDialog(context);
}).showAlertDialog(context);
}
});
},
child: MedicalProfileItem( child: MedicalProfileItem(
title: TranslationBase.of(context).internet, title: TranslationBase.of(context).internet,
imagePath: 'insurance_card_icon.png', imagePath: 'insurance_card_icon.png',
@ -521,6 +539,11 @@ class Utils {
} }
} }
Future<AuthenticatedUser> userData() async {
var userData = AuthenticatedUser.fromJson(await AppSharedPreferences().getObject(MAIN_USER));
return userData;
}
// extension function that use in iterations(list.. etc) to iterate items and get index and item it self // extension function that use in iterations(list.. etc) to iterate items and get index and item it self
extension IndexedIterable<E> on Iterable<E> { extension IndexedIterable<E> on Iterable<E> {
Iterable<T> mapIndexed<T>(T Function(E e, int i) f) { Iterable<T> mapIndexed<T>(T Function(E e, int i) f) {

@ -523,6 +523,7 @@ class _AppDrawerState extends State<AppDrawer> {
this.user = null; this.user = null;
toDoProvider.setState(0, false); toDoProvider.setState(0, false);
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);
// projectProvider.platformBridge().unRegisterHmgGeofences();
} }
login() async { login() async {

@ -82,7 +82,8 @@ dependencies:
google_maps_flutter: ^1.0.3 google_maps_flutter: ^1.0.3
flutter_polyline_points: ^0.1.0
location: ^2.3.5
# Qr code Scanner # Qr code Scanner
barcode_scan_fix: ^1.0.2 barcode_scan_fix: ^1.0.2
@ -183,6 +184,7 @@ flutter:
# assets: # assets:
assets: assets:
- assets/images/ - assets/images/
- assets/images/map_markers/
- assets/images/pharmacy/ - assets/images/pharmacy/
- assets/images/medical/ - assets/images/medical/
- assets/images/new-design/ - assets/images/new-design/

Loading…
Cancel
Save