no message

geofencing_wifi
Zohaib Kambrani 5 years ago
parent 0c71fbad5f
commit 69d1e4bb0b

@ -27,7 +27,7 @@ apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@ -41,7 +41,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.cloud.diplomaticquarterapp"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
@ -78,6 +78,12 @@ dependencies {
implementation 'com.google.guava:guava:27.0.1-android'
// Dependency on local binaries
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "org.jetbrains.anko:anko-commons:0.10.4"
implementation 'com.github.kittinunf.fuel:fuel:2.3.0' //for JVM
implementation 'com.github.kittinunf.fuel:fuel-android:2.3.0' //for Android
// Dependency on a remote binary
// implementation 'com.example.android:app-magic:12.3'

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cloud.diplomaticquarterapp">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
<!--
io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
FlutterApplication and put your custom class here.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
@ -17,33 +20,72 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<!-- Wifi Permissions-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:label="diplomaticquarterapp">
android:label="diplomaticquarterapp"
android:usesCleartextTraffic="true">
<!-- <activity android:name=".FlutterMainActivity"-->
<!-- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"-->
<!-- android:hardwareAccelerated="true"-->
<!-- android:launchMode="singleTop"-->
<!-- android:theme="@style/Theme.AppCompat.NoActionBar"-->
<!-- android:windowSoftInputMode="adjustResize">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- </activity>-->
<activity
android:name=".MainActivity"
android:name=".FlutterMainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
<!--
Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
to determine the Window background behind the Flutter UI.
-->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
<!--
Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
Flutter's first frame.
-->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
@ -52,18 +94,20 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<!--
Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java
-->
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
@ -71,14 +115,9 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCmevVlr2Bh-c8W1VUzo8gt8JRY7n5PANw" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
</manifest>
</manifest>

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

@ -0,0 +1,91 @@
package com.cloud.diplomaticquarterapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.cloud.diplomaticquarterapp.utils.PlatformBridge
import io.flutter.embedding.android.FlutterView
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.dart.DartExecutor
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterMain
import java.util.ArrayList
class FlutterMainActivity : AppCompatActivity() {
private lateinit var channel: MethodChannel
private var flutterView: FlutterView? = null
companion object {
private var flutterEngine: FlutterEngine? = null
private const val CHANNEL = "HMG-Platform-Bridge"
private const val METHOD_CONNECT_WIFI = "connectHMGGuestWifi"
private const val METHOD_SHOW_LOADING = "loading"
}
// to get and check returned intent
private fun getArgsFromIntent(intent: Intent): Array<String>? {
// Before adding more entries to this list, consider that arbitrary
// Android applications can generate intents with extra data and that
// there are many security-sensitive args in the binary.
val args = ArrayList<String>()
if (intent.getBooleanExtra("trace-startup", false)) {
args.add("--trace-startup")
}
if (intent.getBooleanExtra("start-paused", false)) {
args.add("--start-paused")
}
if (intent.getBooleanExtra("enable-dart-profiling", false)) {
args.add("--enable-dart-profiling")
}
if (!args.isEmpty()) {
return args.toTypedArray()
}
return null
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val args = getArgsFromIntent(intent)
// check if flutterEngine is null
if (flutterEngine == null) {
println(args)
flutterEngine = FlutterEngine(this, args)
flutterEngine!!.dartExecutor.executeDartEntrypoint(
// set which of dart methode will be used here
DartExecutor.DartEntrypoint(FlutterMain.findAppBundlePath(), "main")
)
}
setContentView(R.layout.activity_flutter_main)
flutterView = findViewById(R.id.flutterView)
flutterView!!.attachToFlutterEngine(flutterEngine!!)
PlatformBridge(flutterEngine!!.dartExecutor.binaryMessenger, this).create()
}
override fun onResume() {
super.onResume()
flutterEngine!!.lifecycleChannel.appIsResumed()
}
override fun onPause() {
super.onPause()
flutterEngine!!.lifecycleChannel.appIsInactive()
}
override fun onStop() {
super.onStop()
flutterEngine!!.lifecycleChannel.appIsPaused()
}
override fun onDestroy() {
flutterView!!.detachFromFlutterEngine()
super.onDestroy()
}
}

@ -0,0 +1,316 @@
package com.cloud.diplomaticquarterapp.utils
import android.annotation.SuppressLint
import android.content.Context
import android.net.ConnectivityManager
import android.net.wifi.ScanResult
import android.net.wifi.WifiConfiguration
import android.net.wifi.WifiManager
import android.util.Log
import com.cloud.diplomaticquarterapp.API
import com.cloud.diplomaticquarterapp.FlutterMainActivity
import com.github.kittinunf.fuel.core.extensions.jsonBody
import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.fuel.httpPost
import org.json.JSONObject
import java.util.*
@SuppressLint("MissingPermission")
class HMG_Wifi(flutterMainActivity: FlutterMainActivity) {
val TAG = "WIFI"
var context = flutterMainActivity;
var completionListener: ((status:Boolean, message:String) -> Unit)? = null
private var SSID = "HMG-GUEST"
private var USER_NAME = ""
private var PASSWORD = ""
private lateinit var PATIENT_ID:String
/*
* Helpful:
* http://stackoverflow.com/questions/5452940/how-can-i-get-android-wifi-scan-results-into-a-list
*/
fun triggerWifiScan(context: Context) {
val wifi = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
wifi.startScan()
}
/*
* Helpful:
* http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically
*/
fun connectToWifiNetworkWith(patientId:String): HMG_Wifi {
PATIENT_ID = patientId
val security = "OPEN"
val networkPass = ""
Log.d(TAG, "Connecting to SSID \"$SSID\" with password \"$networkPass\" and with security \"$security\" ...")
// You need to create WifiConfiguration instance like this:
val conf = WifiConfiguration()
conf.SSID = "\"" + SSID + "\""
if (security == "OPEN") {
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
} else if (security == "WEP") {
conf.wepKeys[0] = "\"" + networkPass + "\""
conf.wepTxKeyIndex = 0
conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE)
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40)
} else {
conf.preSharedKey = "\"" + networkPass + "\""
}
// Then, you need to add it to Android wifi manager settings:
val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
val networkId = wifiManager.addNetwork(conf)
Log.d(TAG, "Network ID: $networkId")
//wifiManager.disconnect();
val result = wifiManager.enableNetwork(networkId, true)
//wifiManager.reconnect();
wifiManager.saveConfiguration()
if(result == true){
authNetworkConnection(networkId);
}else{
completionListener?.let { it(false, "Error connecting to HMG network") }
}
return this
}
private var authTimer:Timer? = null
fun authNetworkConnection(networkId:Int){
authTimer = Timer()
authTimer?.scheduleAtFixedRate( object : TimerTask(){
override fun run() {
if (connectedNetworkId() == networkId && connectedNetworkIPAddress() > 0){
authServerCall()
authTimer?.cancel()
}
}
},2000,1000)
// If wifi not connected in 5 sec terminate with fail status
Timer().schedule(object : TimerTask(){
override fun run() {
if (null != authTimer) {
authTimer?.cancel()
completionListener?.let { it(false, "Error connecting to HMG network") }
}
}
},5000)
}
fun authServerCall(){
fun forceCallOverWifi(){
val connectivityManager = context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
connectivityManager.networkPreference = ConnectivityManager.TYPE_WIFI
}
fun call(){
forceCallOverWifi()
val params = listOf("cmd" to "authenticate", "password" to PASSWORD, "user" to USER_NAME)
val serverUrl = "https://captiveportal-login.hmg.com/cgi-bin/login"
// val serverUrl = "http://192.168.102.223/cgi-bin/login"
serverUrl
.httpPost(params)
.timeout(10000)
.response { request, response, result ->
Log.v(TAG,response.statusCode.toString())
haveInternet { have ->
if(have){
Log.v(TAG,"Connected to internet via $SSID network at HMG")
completionListener?.let { it(true, "Successfully connected to the internet") }
}else{
Log.e(TAG,"failed to connect to internet via $SSID network at HMG")
completionListener?.let { it(false, "Authentication failed or you are already using your credentials on another device") }
}
}
}
}
haveInternet { has ->
if (has){
getAuthCredentials {
call()
}
}else{
completionListener?.let { it(false,"You must have active internet connection to connect with HMG Network") }
}
}
}
fun haveInternet(completion:((status:Boolean)->Unit)){
"https://captive.apple.com".httpGet().response {request, response, result ->
val have = response.statusCode == 200 && String(response.data).contains("<TITLE>Success</TITLE>",true)
completion(have)
}
}
fun getAuthCredentials(completion:(() -> Unit)){
val test = true
if (test){
USER_NAME = "2300"
PASSWORD = "1820"
completion()
return
}
val jsonBody = """{"PatientID":$PATIENT_ID}"""
API.WIFI_CREDENTIALS
.httpPost()
.jsonBody(jsonBody,Charsets.UTF_8)
.response { request, response, result ->
val jsonString = String(response.data)
Log.d(TAG, "JSON $jsonString")
if (response.statusCode == 200){
val jsonObject = JSONObject(jsonString)
if(!jsonObject.getString("ErrorMessage").equals("null")){
val errorMsg = jsonObject.getString("ErrorMessage")
completionListener?.let { it(false,errorMsg) }
}else{
jsonObject.getJSONArray("Hmg_SMS_Get_By_ProjectID_And_PatientIDList").let { array ->
array.getJSONObject(0).let { object_ ->
if (object_.has("UserName") && object_.has("UserName")){
USER_NAME = object_.getString("UserName")
PASSWORD = object_.getString("Password")
completion()
}else{
completionListener?.let { it(false,"Failed to get your internet credentials") }
}
}
}
}
}else{
completionListener?.let { it(false,"Failed to get your internet credentials") }
}
}
}
/*
* Helpful:
* http://stackoverflow.com/questions/6517314/android-wifi-connection-programmatically
*/
fun getScanResultSecurity(result: ScanResult): String? {
val capabilities: String = result.capabilities
val securityModes = arrayOf("WEP", "PSK", "EAP")
for (securityMode in securityModes) {
if (capabilities.contains(securityMode)) {
return securityMode
}
}
return "OPEN"
}
//connects to the given ssid
fun connectToWPAWiFi(ssid: String, password: String){
// WifiUtils.withContext(context)
// .connectWith(ssid, "")
// .setTimeout(40000)
// .onConnectionResult(object : ConnectionSuccessListener {
// override fun success() {
// Log.v(TAG,"Success")
// }
//
// override fun failed(@NonNull errorCode: ConnectionErrorCode) {
// Log.v(TAG,"Failed")
// }
// })
// .start()
// if(isConnectedTo(ssid)){ //see if we are already connected to the given ssid
// return
// }
//
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Log.e(TAG, "connection wifi Q")
//
// val wifiNetworkSpecifier: WifiNetworkSpecifier = WifiNetworkSpecifier.Builder()
// .setSsid(ssid)
// .setWpa2Passphrase(password)
// .build()
//
// val networkRequest: NetworkRequest = NetworkRequest.Builder()
// .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
// .setNetworkSpecifier(wifiNetworkSpecifier)
// .build()
//
// var connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
// var networkCallback = object : ConnectivityManager.NetworkCallback() {
// override fun onAvailable(network: Network) {
// super.onAvailable(network)
// connectivityManager.bindProcessToNetwork(network)
// Log.e(TAG, "onAvailable")
// }
//
// override fun onLosing(network: Network, maxMsToLive: Int) {
// super.onLosing(network, maxMsToLive)
// Log.e(TAG, "onLosing")
// }
//
// override fun onLost(network: Network) {
// super.onLost(network)
// Log.e(TAG, "onLosing")
// Log.e(TAG, "losing active connection")
// }
//
// override fun onUnavailable() {
// super.onUnavailable()
// Log.e(TAG, "onUnavailable")
// }
// }
// connectivityManager.requestNetwork(networkRequest, networkCallback)
//
// }else{
//
// try {
// val wm:WifiManager= context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
//
// Log.e(TAG, "connection wifi pre Q")
//
// var netId: Int = wm.addNetwork(getWifiConfig(ssid))
// if (netId == -1) netId = getExistingNetworkId(ssid);
// wm.saveConfiguration()
// if(wm.enableNetwork(netId, true)){
// Log.v(TAG,"HMG-GUEST Connected")
// }else{
// Log.v(TAG,"HMG-GUEST failed to connect")
// }
// } catch (e: Exception) {
// e.printStackTrace()
// Log.v(TAG,"HMG-GUEST failed to connect")
// }
// }
}
fun connectedNetworkId():Int{
val wm:WifiManager= context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
return wm.connectionInfo.networkId
}
fun connectedNetworkIPAddress():Int{
val wm:WifiManager= context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
return wm.connectionInfo.ipAddress
}
fun isConnectedTo(bssid: String):Boolean{
val wm:WifiManager= context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
if(wm.connectionInfo.bssid == bssid){
return true
}
return false
}
}

@ -0,0 +1,49 @@
package com.cloud.diplomaticquarterapp.utils
import android.os.AsyncTask
import android.os.Parcel
import android.os.Parcelable
import android.util.Log
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.OutputStreamWriter
import java.net.HttpURLConnection
import java.net.URL
import java.net.URLEncoder
class HTTPRequest {
val TAG = "HTTPRequest"
fun post(serverURL:String, params:Map<String,String>){
var encodedParamsList = params.map {
URLEncoder.encode(it.key, "UTF-8") + "=" + URLEncoder.encode(it.value,"UTF-8")
}
val postParam = encodedParamsList.joinToString (separator = "&")
val url = URL(serverURL)
with(url.openConnection() as HttpURLConnection) {
requestMethod = "POST"
val wr = OutputStreamWriter(outputStream)
wr.write(postParam)
wr.flush()
BufferedReader(InputStreamReader(inputStream)).use {
val response = StringBuffer()
var inputLIne = it.readLine()
while(inputLIne != null) {
response.append(inputLIne)
inputLIne = it.readLine()
}
it.close()
Log.v(TAG,response.toString())
}
}
}
}

@ -0,0 +1,47 @@
package com.cloud.diplomaticquarterapp.utils
import android.util.Log
import com.cloud.diplomaticquarterapp.FlutterMainActivity
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
class PlatformBridge(binaryMessenger: BinaryMessenger, flutterMainActivity: FlutterMainActivity) {
private var binaryMessenger = binaryMessenger
private var mainActivity = flutterMainActivity
private lateinit var channel: MethodChannel
companion object {
private const val CHANNEL = "HMG-Platform-Bridge"
private const val METHOD_CONNECT_WIFI = "connectHMGGuestWifi"
private const val METHOD_SHOW_LOADING = "loading"
}
fun create(){
channel = MethodChannel(binaryMessenger, CHANNEL)
channel.setMethodCallHandler { methodCall: MethodCall, result: MethodChannel.Result ->
if (methodCall.method == METHOD_CONNECT_WIFI) {
(methodCall.arguments as ArrayList<*>).let {
require(it.size > 0 && (it.get(0) is String),lazyMessage = {
"Missing or invalid arguments (Must have one argument 'String at 0'"
})
val patientId = it.get(0).toString()
HMG_Wifi(mainActivity)
.connectToWifiNetworkWith(patientId)
.completionListener = { status, message ->
Log.v(this.javaClass.simpleName, "$status | $message")
}
}
}else if (methodCall.method == METHOD_CONNECT_WIFI) {
}else {
result.notImplemented()
}
}
}
}

@ -1,11 +1,21 @@
package com.cloud.diplomaticquarterapp
import android.os.Bundle
import android.os.PersistableBundle
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodCall
class MainActivity: FlutterFragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FlutterMainActivity">
<io.flutter.embedding.android.FlutterView
android:background="#FFFFFF"
android:id="@+id/flutterView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:text="Zohaib"
android:textSize="50dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>

@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()

@ -1 +1 @@
5c29d18b2483146f4513132fbdc2a003
c948a9de8d5fb4b791dcd366c30ba789

@ -12,6 +12,7 @@ project 'Runner', {
# pod 'FBSDKCoreKit'
# pod 'FBSDKLoginKit'
pod 'NVActivityIndicatorView'
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
@ -87,4 +88,4 @@ post_install do |installer|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end

@ -120,6 +120,9 @@ PODS:
- Flutter
- native_progress_hud (0.0.1):
- Flutter
- NVActivityIndicatorView (5.1.1):
- NVActivityIndicatorView/Base (= 5.1.1)
- NVActivityIndicatorView/Base (5.1.1)
- path_provider (0.0.1):
- Flutter
- path_provider_linux (0.0.1):
@ -201,6 +204,7 @@ DEPENDENCIES:
- maps_launcher (from `.symlinks/plugins/maps_launcher/ios`)
- native_device_orientation (from `.symlinks/plugins/native_device_orientation/ios`)
- native_progress_hud (from `.symlinks/plugins/native_progress_hud/ios`)
- NVActivityIndicatorView
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
@ -236,6 +240,7 @@ SPEC REPOS:
- GoogleMaps
- GoogleUtilities
- nanopb
- NVActivityIndicatorView
- PromisesObjC
- Protobuf
- Reachability
@ -381,6 +386,7 @@ SPEC CHECKSUMS:
nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc
native_device_orientation: e24d00be281de72996640885d80e706142707660
native_progress_hud: f95f5529742b36a3c7fdecfa88dc018319e39bf9
NVActivityIndicatorView: 1f6c5687f1171810aa27a3296814dc2d7dec3667
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
@ -410,6 +416,6 @@ SPEC CHECKSUMS:
wakelock: 0d4a70faf8950410735e3f61fb15d517c8a6efc4
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
PODFILE CHECKSUM: 8e8c706676125c48908ca559e285c906e5d20397
PODFILE CHECKSUM: fd41bba6db38332890981ce38f0747bdb94c61f2
COCOAPODS: 1.10.0

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
<!--Main View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="MainViewController" customModule="Runner" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@ -18,12 +18,85 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iiB-nC-lWt">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<connections>
<segue destination="07U-8g-TSJ" kind="embed" id="0mo-Dk-ROY"/>
</connections>
</containerView>
<view hidden="YES" alpha="0.90000000000000002" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zXb-Rz-9uK">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BSu-be-Z1V" customClass="NVActivityIndicatorView" customModule="NVActivityIndicatorView">
<rect key="frame" x="30" y="271" width="354" height="354"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="width" secondItem="BSu-be-Z1V" secondAttribute="height" id="xGa-6d-w1R"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="typeName" value="ballGridBeat"/>
<userDefinedRuntimeAttribute type="color" keyPath="color">
<color key="value" red="0.34742879999999998" green="0.67916901529999996" blue="0.35416535329999999" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Wd-a2-Mgt">
<rect key="frame" x="207" y="448" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="5Wd-a2-Mgt" firstAttribute="centerX" secondItem="BSu-be-Z1V" secondAttribute="centerX" id="4kE-50-iBD"/>
<constraint firstItem="BSu-be-Z1V" firstAttribute="centerY" secondItem="zXb-Rz-9uK" secondAttribute="centerY" id="Ek3-H4-Tks"/>
<constraint firstItem="5Wd-a2-Mgt" firstAttribute="centerY" secondItem="BSu-be-Z1V" secondAttribute="centerY" id="HTw-sL-a5g"/>
<constraint firstItem="BSu-be-Z1V" firstAttribute="leading" secondItem="zXb-Rz-9uK" secondAttribute="leading" constant="30" id="Xas-Sl-2GU"/>
<constraint firstAttribute="trailing" secondItem="BSu-be-Z1V" secondAttribute="trailing" constant="30" id="jEB-tN-wf8"/>
<constraint firstItem="BSu-be-Z1V" firstAttribute="centerX" secondItem="zXb-Rz-9uK" secondAttribute="centerX" id="yie-B7-m91"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="zXb-Rz-9uK" secondAttribute="trailing" id="DK6-ZR-0qc"/>
<constraint firstItem="zXb-Rz-9uK" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="Msu-br-SZp"/>
<constraint firstItem="zXb-Rz-9uK" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="W9Y-rE-AmS"/>
<constraint firstAttribute="bottom" secondItem="zXb-Rz-9uK" secondAttribute="bottom" id="Zjo-yK-nHj"/>
<constraint firstAttribute="trailing" secondItem="iiB-nC-lWt" secondAttribute="trailing" id="fcK-dc-bwG"/>
<constraint firstItem="iiB-nC-lWt" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="idX-Jw-Ma9"/>
<constraint firstItem="iiB-nC-lWt" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="uKn-QU-Ka7"/>
<constraint firstAttribute="bottom" secondItem="iiB-nC-lWt" secondAttribute="bottom" id="zPu-2M-aXt"/>
</constraints>
</view>
<connections>
<outlet property="lblLoadingText" destination="5Wd-a2-Mgt" id="hGl-tJ-FUV"/>
<outlet property="loading" destination="BSu-be-Z1V" id="4Nx-DH-P42"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="96" y="-21"/>
<point key="canvasLocation" x="95.652173913043484" y="-21.428571428571427"/>
</scene>
<!--Main FlutterVC-->
<scene sceneID="J1x-mD-FM4">
<objects>
<viewController id="07U-8g-TSJ" customClass="MainFlutterVC" customModule="Runner" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="dzx-FI-nKH"/>
<viewControllerLayoutGuide type="bottom" id="q3b-GI-trV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="y53-TK-Smi">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jK2-7S-ThF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1022" y="-21"/>
</scene>
</scenes>
</document>

@ -0,0 +1,31 @@
//
// MainFlutterVC.swift
// Runner
//
// Created by ZiKambrani on 25/03/1442 AH.
//
import UIKit
import Flutter
class MainFlutterVC: FlutterViewController {
var root_view:MainViewController?
override func viewDidLoad() {
super.viewDidLoad()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}

@ -0,0 +1,96 @@
//
// MainViewController.swift
// Runner
//
// Created by ZiKambrani on 26/03/1442 AH.
//
import UIKit
import NVActivityIndicatorView
class MainViewController: UIViewController {
@IBOutlet weak var lblLoadingText: UILabel!
@IBOutlet weak var loading: NVActivityIndicatorView!
override func viewDidLoad() {
super.viewDidLoad()
print(loading)
}
func createBridge(flutterViewController:FlutterViewController){
let connectHMGGuestWifi = FlutterMethodChannel(name: "HMG-Platform-Bridge",binaryMessenger: flutterViewController.binaryMessenger)
connectHMGGuestWifi.setMethodCallHandler { (methodCall, result) in
if methodCall.method == "connectHMGGuestWifi"{
self.connectWifi(result: result)
}else if methodCall.method == "loading"{
self.showLoading(flutterMethodCall: methodCall)
}else{
}
print("")
}
}
// Connect HMG-Guest Wifi and Internet
func connectWifi(result: @escaping FlutterResult){
showLoading(message: "Connecting...")
HMG_GUEST.shared.connect { (status, message) in
result(status ? 1 : 0)
self.showLoading(false);
if status{
self.showMessage(title:"Congratulations", message:message)
}else{
self.showMessage(title:"Ooops,", message:message)
}
}
}
// Loading/Progress
private func showLoading(flutterMethodCall:FlutterMethodCall){
if let args = flutterMethodCall.arguments as? [Any],
let message = args.first as? String, let show = args.last as? Bool{
showLoading(message: message, show)
}else{
assert(true, "Missing or invalid arguments (Must have two argument 'String at 0' and Boolean at 1)")
}
}
func showLoading(message:String = "Please wait...", _ show:Bool = true){
DispatchQueue.main.async {
if show{
self.lblLoadingText.text = message
self.loading.superview?.isHidden = false
self.loading.startAnimating()
}else{
self.lblLoadingText.text = ""
self.loading.superview?.isHidden = true
self.loading.stopAnimating()
}
}
}
// Message Dailog
func showMessage(title:String, message:String){
DispatchQueue.main.async {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert )
alert.addAction(UIAlertAction(title: "OK", style: .destructive, handler: nil))
self.present(alert, animated: true) {
}
}
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let flutterVC = segue.destination as? MainFlutterVC{
flutterVC.root_view = self
createBridge(flutterViewController: flutterVC)
}
}
}

@ -0,0 +1,9 @@
//
// GlobalHelper.swift
// Runner
//
// Created by ZiKambrani on 29/03/1442 AH.
//
import UIKit

@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
@ -22,22 +27,22 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need microphone access for uploading videos</string>
<key>NSCameraUsageDescription</key>
<string>Need camera access for uploading images</string>
<key>NSLocationUsageDescription</key>
<string>Need location access for updating nearby friends</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app will use your location to show cool stuffs near you.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need photo library access for uploading images</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need microphone access for uploading videos</string>
<key>NSCameraUsageDescription</key>
<string>Need camera access for uploading images</string>
<key>NSLocationUsageDescription</key>
<string>Need location access for updating nearby friends</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app will use your location to show cool stuffs near you.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need photo library access for uploading images</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>

@ -4,5 +4,9 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.networking.HotspotConfiguration</key>
<true/>
<key>com.apple.developer.networking.wifi-info</key>
<true/>
</dict>
</plist>

@ -0,0 +1,129 @@
//
// HMG_GUEST.swift
// HMG-iOS-Wifi
//
// Created by ZiKambrani on 23/03/1442 AH.
// Copyright © 1442 ZiKambrani. All rights reserved.
//
import UIKit
import NetworkExtension
import SystemConfiguration.CaptiveNetwork
class HMG_GUEST{
static let shared = HMG_GUEST()
private let SSID = "HMG-GUEST"
private let USER = "1301"
private let PASS = "8928"
var complete:((_ status:Bool, _ message:String) -> Void)!
func connect(completion:@escaping ((_ status:Bool, _ message:String) -> Void)){
complete = completion
if isAlreadyConnected() {
hasInternet { (has) in
if has == true{
self.complete(true, "You already connected to internet")
return
}else{
self.authenticate()
}
}
}else{
connect()
}
}
private func connect() {
let hotspotConfig = NEHotspotConfiguration(ssid: SSID)
hotspotConfig.joinOnce = true
NEHotspotConfigurationManager.shared.apply(hotspotConfig) {[weak self] (error) in
guard let self = self else { return; }
if let error = error {
self.complete(false, error.localizedDescription ?? "Error connecting to HMG wifi network" )
}else{
_ = Timer.scheduledTimer(withTimeInterval: 2, repeats: false) { (timer) in
self.authenticate()
}
}
}
}
func authenticate(){
func callLogin(){
let parameters = "Login=Log%20In&cmd=authenticate&password=1820&user=2300"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://captiveportal-login.hmg.com/cgi-bin/login")!,timeoutInterval: 5)
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
// guard let data = data else {
// self.complete(false, "Error at authentication")
// return
// }
self.hasInternet { (has) in
self.complete(has, has ? "Successfully connected to the internet" : "Authentication failed or you are already using your credentials on another device")
}
}
task.resume()
}
self.hasInternet { (has) in
if has == true{
self.complete(true, "Your internet account is already authenticated")
}else{
callLogin()
}
}
}
private func isAlreadyConnected() -> Bool{
var currentSSID: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
currentSSID = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
}
}
}
print("CurrentConnectedSSID: \(currentSSID)")
return currentSSID == SSID
}
func hasInternet( completion:@escaping ((Bool)->Void)){
let testUrl = "https://captive.apple.com"
var request = URLRequest(url: URL(string: testUrl)!,timeoutInterval: 5)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
completion(false)
return
}
let resp = String(data: data, encoding: .utf8)!
if resp.contains("<TITLE>Success</TITLE>"){
completion(true)
}else{
completion(false)
}
}
task.resume()
}
}

@ -4,11 +4,17 @@ import 'package:connectivity/connectivity.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
class ProjectViewModel extends BaseViewModel {
// Platform Bridge
PlatformBridge platformBridge() {
return PlatformBridge();
}
AppSharedPreferences sharedPref = AppSharedPreferences();
Locale _appLocale;
String currentLanguage = 'en';
@ -21,7 +27,7 @@ class ProjectViewModel extends BaseViewModel {
dynamic get searchValue => searchvalue;
Locale get appLocal => _appLocale;
LocaleType get localeType => isArabic? LocaleType.en:LocaleType.ar;
LocaleType get localeType => isArabic ? LocaleType.en : LocaleType.ar;
bool get isArabic => _isArabic;
// BaseViewModel baseViewModel = locator<BaseViewModel>()
StreamSubscription subscription;
@ -51,7 +57,9 @@ class ProjectViewModel extends BaseViewModel {
currentLanguage = await sharedPref.getString(APP_LANGUAGE);
_appLocale = Locale(currentLanguage ?? 'en');
_isArabic = currentLanguage != null
? currentLanguage == 'ar' ? true : false
? currentLanguage == 'ar'
? true
: false
: true;
notifyListeners();
}

@ -10,6 +10,12 @@ import 'core/viewModels/project_view_model.dart';
import 'locator.dart';
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
@pragma('vm:entry-point')
void customMainDartMethod() {
setupLocator();
runApp(MyApp());
}
void main() async {
setupLocator();
runApp(MyApp());
@ -67,7 +73,8 @@ class MyApp extends StatelessWidget {
hintColor: Colors.grey[400],
disabledColor: Colors.grey[300],
errorColor: Color.fromRGBO(235, 80, 60, 1.0),
scaffoldBackgroundColor: HexColor('#E9E9E9'), // Colors.grey[100],
scaffoldBackgroundColor:
HexColor('#E9E9E9'), // Colors.grey[100],
textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5),
textSelectionHandleColor: Colors.grey,
canvasColor: Colors.white,

@ -12,21 +12,19 @@ import 'package:flutter/material.dart';
import '../add_custom_amount.dart';
class H20FloatingActionButton extends StatefulWidget {
const H20FloatingActionButton({
Key key,
@required AnimationController controller,
@required this.model
}) :
super(key: key);
const H20FloatingActionButton(
{Key key, @required AnimationController controller, @required this.model})
: super(key: key);
final H2OViewModel model;
@override
_H20FloatingActionButtonState createState() => _H20FloatingActionButtonState();
_H20FloatingActionButtonState createState() =>
_H20FloatingActionButtonState();
}
class _H20FloatingActionButtonState extends State<H20FloatingActionButton> with TickerProviderStateMixin {
class _H20FloatingActionButtonState extends State<H20FloatingActionButton>
with TickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
@ -39,9 +37,13 @@ class _H20FloatingActionButtonState extends State<H20FloatingActionButton> with
@override
Widget build(BuildContext context) {
void showConfirmMessage(int amount, H2OViewModel model) {
showDialog(context: context, child: ConfirmAddAmountDialog(model: model,amount:amount,));
showDialog(
context: context,
child: ConfirmAddAmountDialog(
model: model,
amount: amount,
));
}
return Container(
@ -184,16 +186,15 @@ class ActionButton extends StatelessWidget {
curve: new Interval(0.0, 1.0 - 0 / 6 / 2.0, curve: Curves.easeOut),
),
child: new FloatingActionButton(
heroTag: null,
backgroundColor: Colors.white,
mini: true,
child: Text(
text,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14.0, color: Colors.grey),
),
onPressed: onTap
),
heroTag: null,
backgroundColor: Colors.white,
mini: true,
child: Text(
text,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14.0, color: Colors.grey),
),
onPressed: onTap),
),
);
}

@ -123,7 +123,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
AppGlobal.context = context;
});
_requestIOSPermissions();
pageController = PageController(keepPage: true);
pageController = PageController(keepPage: true);
// _firebaseMessaging.setAutoInitEnabled(true);
//
// if (Platform.isIOS) {
@ -359,20 +359,22 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
),
drawer: SafeArea(child: AppDrawer()),
extendBody: true,
body: PageView(
physics: NeverScrollableScrollPhysics(),
controller: pageController,
children: [
HomePage(
goToMyProfile: () {
_changeCurrentTab(1);
},
),
MedicalProfilePage(),
MyAdmissionsPage(),
ToDo(),
BookingOptions()
], // Please do not remove the BookingOptions from this array
body: SafeArea(
child: PageView(
physics: NeverScrollableScrollPhysics(),
controller: pageController,
children: [
HomePage(
goToMyProfile: () {
_changeCurrentTab(1);
},
),
MedicalProfilePage(),
MyAdmissionsPage(),
ToDo(),
BookingOptions()
], // Please do not remove the BookingOptions from this array
),
),
bottomNavigationBar: BottomNavBar(
changeIndex: _changeCurrentTab,

@ -75,18 +75,19 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
fit: BoxFit.cover,
width: double.infinity,
),
if(model.authenticatedUserObject.isLogin)
ListView.builder(
itemBuilder: (context, index) => TimeLineWidget(
isUp: index % 2 == 1,
appoitmentAllHistoryResul: model
.appoitmentAllHistoryResultList[index],
if (model.authenticatedUserObject.isLogin)
ListView.builder(
itemBuilder: (context, index) =>
TimeLineWidget(
isUp: index % 2 == 1,
appoitmentAllHistoryResul: model
.appoitmentAllHistoryResultList[index],
),
itemCount: model
.appoitmentAllHistoryResultList.length,
scrollDirection: Axis.horizontal,
reverse: !projectViewModel.isArabic,
),
itemCount:
model.appoitmentAllHistoryResultList.length,
scrollDirection: Axis.horizontal,
reverse: !projectViewModel.isArabic,
),
],
),
),
@ -192,8 +193,10 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
Expanded(
flex: 1,
child: InkWell(
onTap: () => Navigator.push(context,
FadePage(page: ActiveMedicationsPage())),
onTap: () => Navigator.push(
context,
FadePage(
page: ActiveMedicationsPage())),
child: MedicalProfileItem(
title: TranslationBase.of(context)
.myMedical,
@ -298,9 +301,11 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
Expanded(
flex: 1,
child: InkWell(
onTap:()=> Navigator.push(context, FadePage(page: AllergiesPage())) ,
onTap: () => Navigator.push(context,
FadePage(page: AllergiesPage())),
child: MedicalProfileItem(
title: TranslationBase.of(context).allergies,
title:
TranslationBase.of(context).allergies,
imagePath: 'my_allergies_icon.png',
subTitle: TranslationBase.of(context)
.allergiesSubtitle,
@ -408,10 +413,12 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
flex: 1,
child: InkWell(
//TODO
onTap: () {
Navigator.push(
context, FadePage(page: SmartWatchInstructions()));
},
onTap: () {
Navigator.push(
context,
FadePage(
page: SmartWatchInstructions()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context)
.smartWatches,
@ -440,12 +447,13 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
Expanded(
flex: 1,
child: InkWell(
onTap: (){
onTap: () {
Navigator.push(context,
FadePage(page: AskDoctorHomPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).askYour,
title:
TranslationBase.of(context).askYour,
imagePath: 'ask_doctor_icon.png',
subTitle: TranslationBase.of(context)
.askYourSubtitle,
@ -457,11 +465,16 @@ class _MedicalProfilePageState extends State<MedicalProfilePage> {
Expanded(
flex: 1,
child: InkWell(
//TODO
// onTap: () {
// Navigator.push(
// context, FadePage(page: DoctorHomePage()));
// },
onTap: () {
if (projectViewModel.user == null) {
projectViewModel
.platformBridge()
.connectHMGGuestWifi("1231755");
} else {
Navigator.push(context,
FadePage(page: DoctorHomePage()));
}
},
child: MedicalProfileItem(
title:
TranslationBase.of(context).internet,

@ -0,0 +1,29 @@
import 'package:flutter/services.dart';
class PlatformBridge {
static const platform = const MethodChannel("HMG-Platform-Bridge");
// Method Names
static const wifi_connect_method = "connectHMGGuestWifi";
static const show_loading_method = "loading";
Future<Object> connectHMGGuestWifi(String patientId) {
print("Invoking platform method: $wifi_connect_method");
try {
return platform.invokeMethod(wifi_connect_method, [patientId]);
} on PlatformException catch (e) {
print(e);
return Future.error(e);
}
}
void showLoading(String message, bool show) async {
print("Invoking platform method: $show_loading_method");
try {
final int result =
await platform.invokeMethod(show_loading_method, [message, show]);
} on PlatformException catch (e) {
print(e);
}
}
}

@ -5,7 +5,8 @@ description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
sdk: ">=2.8.0 <3.0.0" #">=2.6.0 <3.0.0"
dependencies:
flutter:

Loading…
Cancel
Save