diff --git a/.gitignore b/.gitignore index 2ddde2a..3de90ab 100644 --- a/.gitignore +++ b/.gitignore @@ -18,56 +18,21 @@ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line # is commented out by default. -#.vscode/ +.vscode/ # Flutter/Dart/Pub related **/doc/api/ .dart_tool/ .flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ /build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Web related +lib/generated_plugin_registrant.dart # Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +.gradle \ No newline at end of file diff --git a/.metadata b/.metadata deleted file mode 100644 index fea404f..0000000 --- a/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: 68587a0916366e9512a78df22c44163d041dd5f3 - channel: stable - -project_type: app diff --git a/README.md b/README.md index d502d99..a3d9d76 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,15 @@ -# GEO Smart App +![Show Case](https://i.ibb.co/4ZBZCFj/Whats-App-Image-2020-07-08-at-8-08-55-PM.jpg) + This is the Mobile Application for [Geo Smart System](https://github.com/supanadit/geosmartsystem) and [Geo Smart Map](https://github.com/supanadit/geosmartmap) ## Requirements - Flutter +- Android 6.0.1+ + +## Quick Start +- Clone this repository +- `flutter pub get` +- `flutter run` ## Todo - Integration With Geo Smart System ( OK ) diff --git a/android/app/build.gradle b/android/app/build.gradle index 144136c..d2a4376 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -23,7 +23,6 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { @@ -39,12 +38,11 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.supanadit.geo_app" + applicationId "com.example.geosmart" minSdkVersion 16 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -62,10 +60,4 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.google.firebase:firebase-analytics:17.2.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } - -apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/android/app/google-services.json b/android/app/google-services.json deleted file mode 100644 index 293e156..0000000 --- a/android/app/google-services.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "project_info": { - "project_number": "908118791305", - "firebase_url": "https://geo-app-supanadit.firebaseio.com", - "project_id": "geo-app-supanadit", - "storage_bucket": "geo-app-supanadit.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:908118791305:android:d230276ba7f053e3e9e258", - "android_client_info": { - "package_name": "com.supanadit.geo_app" - } - }, - "oauth_client": [ - { - "client_id": "908118791305-pif2888l3d7qs7hjqs4pkcbcc74ga10h.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyDqOWFq6PaPeSIn14jcXSaTovDYU9S1tYU" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "908118791305-pif2888l3d7qs7hjqs4pkcbcc74ga10h.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index a4c05d2..2fe97d8 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.geosmart"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 687ca3f..a5ebca3 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.geosmart"> @@ -12,29 +12,42 @@ - + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" /> + + + + diff --git a/android/app/src/main/ic_launcher-playstore.png b/android/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..3fcc8f5 Binary files /dev/null and b/android/app/src/main/ic_launcher-playstore.png differ diff --git a/android/app/src/main/ic_launcher-web.png b/android/app/src/main/ic_launcher-web.png deleted file mode 100644 index 5e28fd4..0000000 Binary files a/android/app/src/main/ic_launcher-web.png and /dev/null differ diff --git a/android/app/src/main/kotlin/com/supanadit/geo_app/MainActivity.kt b/android/app/src/main/kotlin/com/supanadit/geo_app/MainActivity.kt deleted file mode 100644 index f61c546..0000000 --- a/android/app/src/main/kotlin/com/supanadit/geo_app/MainActivity.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.supanadit.geo_app - -import android.os.Bundle - -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant - -class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } -} diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index b600ab6..4dce60c 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index eddccd6..373a82c 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index b600ab6..4dce60c 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index cb987aa..ed03bea 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index bb2d4f3..fce60bc 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index cb987aa..ed03bea 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 41f9905..a010015 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index cc68fb4..cc0ee58 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index 41f9905..a010015 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 28e2d78..93115b7 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 37bf64c..d070b4c 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index 28e2d78..93115b7 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index fe90e1c..2b63a08 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 212eea6..c2b1f4f 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index fe90e1c..2b63a08 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 00fa441..1f83a33 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index a4c05d2..2fe97d8 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.example.geosmart"> diff --git a/android/build.gradle b/android/build.gradle index 3b11d01..3100ad2 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,14 +1,13 @@ buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.google.gms:google-services:4.3.2' } } @@ -26,16 +25,6 @@ subprojects { subprojects { project.evaluationDependsOn(':app') } -subprojects { - project.configurations.all { - resolutionStrategy.eachDependency { details -> - if (details.requested.group == 'androidx.core' && - !details.requested.name.contains('androidx')) { - details.useVersion "1.0.1" - } - } - } -} task clean(type: Delete) { delete rootProject.buildDir diff --git a/android/gradle.properties b/android/gradle.properties index 2324ab5..38c8d45 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,4 @@ org.gradle.jvmargs=-Xmx1536M - android.enableR8=true android.useAndroidX=true android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 2819f02..296b146 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index 5a2f14f..d3b6a40 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,15 +1,15 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index e0dd47f..fc902a9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,12 +9,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -27,8 +22,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -39,13 +32,11 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -58,8 +49,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -69,9 +58,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -149,16 +136,16 @@ isa = PBXProject; attributes = { LastUpgradeCheck = 1020; - ORGANIZATIONNAME = "The Chromium Authors"; + ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0910; + LastSwiftMigration = 1100; }; }; }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 3.2"; + compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -182,7 +169,6 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); @@ -203,7 +189,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -298,6 +284,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -321,10 +308,10 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.supanadit.geoApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.geosmart; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -430,6 +417,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -454,11 +442,11 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.supanadit.geoApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.geosmart; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -481,10 +469,10 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.supanadit.geoApp; + PRODUCT_BUNDLE_IDENTIFIER = com.example.geosmart; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -513,7 +501,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..552e5d0 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,6 +7,7 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + GMSServices.provideAPIKey("AIzaSyCjhBV5aq1gsTCYsr6QCCxYusFlBa3DEMs") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index d539269..bd03ec9 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - geo_app + geosmart CFBundlePackageType APPL CFBundleShortVersionString diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h index 7335fdf..308a2a5 100644 --- a/ios/Runner/Runner-Bridging-Header.h +++ b/ios/Runner/Runner-Bridging-Header.h @@ -1 +1 @@ -#import "GeneratedPluginRegistrant.h" \ No newline at end of file +#import "GeneratedPluginRegistrant.h" diff --git a/lib/bloc/position_bloc.dart b/lib/bloc/position_bloc.dart deleted file mode 100644 index c010809..0000000 --- a/lib/bloc/position_bloc.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:geo_app/model/response.dart'; -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/repository/position_repository.dart'; -import 'package:rxdart/rxdart.dart'; - -class PositionBloc { - PositionRepository _repository; - final PublishSubject _subject = - PublishSubject(); - - SettingModel _settingModel; - - PositionBloc(this._settingModel) { - this._repository = PositionRepository(this._settingModel); - } - - dispose() { - _subject.close(); - } - - sendPosition(String lat, String lng) async { - ResponseModel response = await _repository.sendPosition(lat, lng); - _subject.sink.add(response); - } - - stopTracking() async { - ResponseModel response = await _repository.stopTracking(); - _subject.sink.add(response); - } - - PublishSubject get subject => _subject; -} diff --git a/lib/bloc/unique_id_bloc.dart b/lib/bloc/unique_id_bloc.dart deleted file mode 100644 index 86fa91a..0000000 --- a/lib/bloc/unique_id_bloc.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/model/unique_id_model.dart'; -import 'package:geo_app/repository/unique_id_repository.dart'; -import 'package:rxdart/rxdart.dart'; - -class UniqueIDBloc { - UniqueIDRepository _repository; - final PublishSubject _subject = - PublishSubject(); - - SettingModel _settingModel; - - UniqueIDBloc(this._settingModel) { - this._repository = UniqueIDRepository(this._settingModel); - } - - dispose() { - _subject.close(); - } - - getUniqueID() async { - UniqueIDModel response = await _repository.getUniqueID(); - _subject.sink.add(response); - } - - PublishSubject get subject => _subject; -} diff --git a/lib/main.dart b/lib/main.dart index b68c3ed..8872fda 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:geo_app/page/startup.dart'; +import 'package:geosmart/page/startup.dart'; void main() => runApp(MyApp()); diff --git a/lib/model/position.dart b/lib/model/position.dart index 39afe44..3cf223f 100644 --- a/lib/model/position.dart +++ b/lib/model/position.dart @@ -1,8 +1,8 @@ import 'dart:convert'; -import 'package:geo_app/config.dart'; -import 'package:geo_app/model/response.dart'; -import 'package:geo_app/model/unique_id_model.dart'; +import 'package:geosmart/config.dart'; +import 'package:geosmart/model/response.dart'; +import 'package:geosmart/model/unique_id_model.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; diff --git a/lib/page/map.dart b/lib/page/map.dart index 5aa8c3b..beddc79 100644 --- a/lib/page/map.dart +++ b/lib/page/map.dart @@ -1,19 +1,14 @@ import 'dart:async'; -import 'dart:io'; -import 'package:background_location/background_location.dart'; -import 'package:device_info/device_info.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:geo_app/bloc/position_bloc.dart'; -import 'package:geo_app/bloc/setting.dart'; -import 'package:geo_app/model/position.dart'; -import 'package:geo_app/page/setting.dart'; +import 'package:geolocator/geolocator.dart' as geo; +import 'package:geosmart/model/position.dart'; +import 'package:geosmart/model/setting.dart'; +import 'package:geosmart/page/setting.dart'; +import 'package:geosmart/service/position_service.dart'; +import 'package:geosmart/service/setting_service.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' - as bg; -import 'package:permission_handler/permission_handler.dart'; -import 'package:rxdart/rxdart.dart'; class Map extends StatefulWidget { Map({Key key, this.title}) : super(key: key); @@ -32,172 +27,74 @@ class _MapState extends State { double accuracy = 0.0; double bearing = 0.0; double speed = 0.0; - Position _position; - PositionBloc _positionBloc; - SettingBloc _settingBloc; - PublishSubject _checkDevice; + PositionService _positionService; + SettingService _settingService; bool isChecking = true; + Position _position; String id; String host; bool isGranted = false; bool isTracking = false; - int androidSDKVersion = 0; - - _MapState() { - _checkDevice = PublishSubject(); - } - - getPermission() { - BackgroundLocation.getPermissions( - onDenied: () { - isGranted = false; - print("Denied"); - }, - onGranted: () { - isGranted = true; - print("Granted"); - }, - ); - } @override void initState() { super.initState(); - PermissionHandler() - .requestPermissions([PermissionGroup.location]).then((permissions) { - permissions.forEach((group, status) { - print("$group With Status $status"); - }); + setState(() { + isChecking = true; }); - if (Platform.isAndroid) { - PermissionHandler() - .shouldShowRequestPermissionRationale(PermissionGroup.location) - .then((isShow) { - print("Is Show $isShow"); - }); - DeviceInfoPlugin().androidInfo.then((androidInfo) { - var release = androidInfo.version.release; - var sdkInt = androidInfo.version.sdkInt; - var manufacturer = androidInfo.manufacturer; - var model = androidInfo.model; - print('Android $release (SDK $sdkInt), $manufacturer $model'); - androidSDKVersion = sdkInt; - if (sdkInt > 21) { - getPermission(); - BackgroundLocation.getLocationUpdates((location) async { - print("Location Updated"); - if (!isTracking) { - this.isTracking = true; - } - if (!isGranted) { - this.isGranted = true; - } - this.latitude = location.latitude; - this.longitude = location.longitude; - this.accuracy = location.accuracy; - this.altitude = location.altitude; - this.bearing = location.bearing; - this.speed = location.speed; + _settingService = new SettingService(); + _positionService = new PositionService(); + // geo.Geolocator()..forceAndroidLocationManager = true; + geo.Geolocator().checkGeolocationPermissionStatus().then( + (v) { + setState(() { + isGranted = true; + }); + var geolocator = geo.Geolocator(); + var locationOptions = geo.LocationOptions( + accuracy: geo.LocationAccuracy.high, + ); - if (this.id != null) { + geolocator + .getPositionStream(locationOptions) + .listen((geo.Position position) { + if (this.id != null) { + setState(() { this._position = Position( id: this.id, - lat: this.latitude.toString(), - lng: this.longitude.toString(), + lat: position.latitude.toString(), + lng: position.longitude.toString(), type: "user", ); - } else { - stopLocationService(); - settingPage(); - } + }); + } else { + stopLocationService(); + settingPage(); + } + print( + "New position detected with lat ${position.latitude} and lng ${position.longitude}"); + sendLastPosition(); + }); - if (this._position != null) { - if (this._position.isValid()) { - if (_positionBloc != null) { - _positionBloc.sendPosition( - this._position.lat.toString(), - this._position.lng.toString(), - ); - } else { - Fluttertoast.showToast( - msg: "Failed to start position service", - ); - settingPage(); - } - } else { - print("Invalid Position"); - } - } - }); - setState(() { - isChecking = false; - }); - } - if (sdkInt <= 21) { - bg.BackgroundGeolocation.onLocation((bg.Location location) { - print('[location] - $location'); - }); + _settingService.getSetting().then((v) { + this.id = v.id; + this.host = v.host; - bg.BackgroundGeolocation.onMotionChange((bg.Location location) { - print('[motionchange] - $location'); - }); - - bg.BackgroundGeolocation.onProviderChange( - (bg.ProviderChangeEvent event) { - print('[providerchange] - $event'); - }); - - bg.BackgroundGeolocation.ready( - bg.Config( - desiredAccuracy: bg.Config.DESIRED_ACCURACY_HIGH, - distanceFilter: 10.0, - stopOnTerminate: false, - startOnBoot: true, - debug: true, - logLevel: bg.Config.LOG_LEVEL_VERBOSE, - ), - ).then( - (bg.State state) { - if (!state.enabled) { - isGranted = true; - isChecking = false; - } - }, - ); - } + if (v.isNullId()) { + settingPage(); + } + }); + }, + ).catchError((e) { + setState(() { + isGranted = false; }); - } else { - getPermission(); + }).whenComplete(() { setState(() { isChecking = false; }); - } - - _settingBloc = new SettingBloc(); - - _settingBloc.getSetting(); - - _settingBloc.subject.listen((settingModel) { - this.id = settingModel.id; - this.host = settingModel.host; - - if (settingModel.isNullId()) { - settingPage(); - } - - if (this.host != null && this.host != "") { - setState(() { - _positionBloc = new PositionBloc(settingModel); - _positionBloc.subject.listen((position) { - if (position.isError()) { - stopLocationService(); - settingPage(); - } - }); - }); - } }); } @@ -233,7 +130,7 @@ class _MapState extends State { onPressed: toggleTracking, child: Text( (isChecking) - ? "Pleasewait" + ? "Please wait" : ((isTracking) ? "Stop Tracking" : "Start Tracking"), style: TextStyle(color: Colors.white), ), @@ -246,55 +143,65 @@ class _MapState extends State { ); } - stopLocationService() { - if (androidSDKVersion > 21 || !Platform.isAndroid) { - BackgroundLocation.stopLocationService(); - } - if (androidSDKVersion <= 21) { - bg.BackgroundGeolocation.stop(); - } - if (_positionBloc != null) { - _positionBloc.stopTracking(); - } - } - - startLocationService() { - if (androidSDKVersion > 21 || !Platform.isAndroid) { - BackgroundLocation.startLocationService(); - } - if (androidSDKVersion <= 21) { - bg.BackgroundGeolocation.start(); - } - } - toggleTracking() { if (!isChecking) { if (isGranted) { if (isTracking) { stopLocationService(); } else { - startLocationService(); + sendLastPosition(); } setState(() { isTracking = !isTracking; }); } else { - Fluttertoast.showToast( + FlutterToast.showToast( msg: "Make sure you have turn on location services", ); } } } + stopLocationService() { + if (_positionService != null) { + _positionService.stopTracking(); + } + } + settingPage() { Navigator.of(context).pushReplacement(new MaterialPageRoute( builder: (BuildContext context) => Setting(), )); } + sendLastPosition() async { + SettingModel m = await _settingService.getSetting(); + print("Prepare to Send last location with ID : ${m.id} to ${m.host}"); + if (this._position != null) { + if (this._position.isValid()) { + if (_positionService != null) { + print("Lat ${_position.lat}, Lng ${_position.lng}"); + if (isTracking) { + print("Send tracking location"); + _positionService.sendPosition( + this._position.lat.toString(), + this._position.lng.toString(), + ); + } + } else { + FlutterToast.showToast( + msg: "Failed to start position service", + ); + settingPage(); + } + } else { + print("Invalid Position"); + } + } + } + @override void dispose() { - print("Disposed"); super.dispose(); stopLocationService(); } diff --git a/lib/page/setting.dart b/lib/page/setting.dart index 9605468..7c530c6 100644 --- a/lib/page/setting.dart +++ b/lib/page/setting.dart @@ -1,11 +1,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; -import 'package:geo_app/bloc/setting.dart'; -import 'package:geo_app/bloc/unique_id_bloc.dart'; -import 'package:geo_app/config.dart'; -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/page/map.dart'; +import 'package:geosmart/config.dart'; +import 'package:geosmart/model/setting.dart'; +import 'package:geosmart/page/map.dart'; +import 'package:geosmart/service/setting_service.dart'; +import 'package:geosmart/service/unique_id_service.dart'; class Setting extends StatefulWidget { @override @@ -16,22 +16,20 @@ class Setting extends StatefulWidget { class _SettingState extends State { final _hostController = TextEditingController(); - SettingBloc _settingBloc; - UniqueIDBloc _uniqueIDBloc; + SettingService _settingBloc; + UniqueIDService _uniqueIDBloc; String id; String host; @override void initState() { - _settingBloc = new SettingBloc(); - - _settingBloc.getSetting(); + _settingBloc = new SettingService(); if (!Config.dynamicHostSetting) { _settingBloc.setSetting(new SettingModel(Config.api, null)); } - _settingBloc.subject.listen((settingModel) { + _settingBloc.getSetting().then((settingModel) { if (!settingModel.isNullId()) { this.id = settingModel.id; } @@ -42,11 +40,10 @@ class _SettingState extends State { _hostController.text = this.host; if (!settingModel.isNullHost()) { - _uniqueIDBloc = new UniqueIDBloc(settingModel); - _uniqueIDBloc.getUniqueID(); + _uniqueIDBloc = new UniqueIDService(settingModel); if (_uniqueIDBloc != null) { - this._uniqueIDBloc.subject.listen((uniqueId) { + this._uniqueIDBloc.getUniqueID().then((uniqueId) { print("Your Unique ID " + uniqueId.id.toString()); if (uniqueId.id != null && uniqueId.id != "") { if (!settingModel.isNullId()) { @@ -58,7 +55,7 @@ class _SettingState extends State { mapPage(); } } else { - Fluttertoast.showToast(msg: "Invalid host address"); + FlutterToast.showToast(msg: "Invalid host address"); } }); } @@ -107,9 +104,48 @@ class _SettingState extends State { child: FlatButton( color: Colors.blueAccent, onPressed: () { - this._settingBloc.setSetting( + this + ._settingBloc + .setSetting( new SettingModel(this._hostController.text, null), - ); + ) + .then((settingModel) { + if (!settingModel.isNullId()) { + this.id = settingModel.id; + } + if (!settingModel.isNullHost()) { + this.host = settingModel.host; + } + + _hostController.text = this.host; + + if (!settingModel.isNullHost()) { + _uniqueIDBloc = new UniqueIDService(settingModel); + + if (_uniqueIDBloc != null) { + this._uniqueIDBloc.getUniqueID().then((uniqueId) { + print("Your Unique ID " + uniqueId.id.toString()); + if (uniqueId.id != null && uniqueId.id != "") { + if (!settingModel.isNullId()) { + mapPage(); + } else { + this._settingBloc.setSetting( + new SettingModel( + this._hostController.text, + uniqueId.id, + ), + ); + mapPage(); + } + } else { + FlutterToast.showToast( + msg: "Invalid host address", + ); + } + }); + } + } + }); }, child: Text( "Save", diff --git a/lib/page/startup.dart b/lib/page/startup.dart index e4ff4c5..1fdd7c0 100644 --- a/lib/page/startup.dart +++ b/lib/page/startup.dart @@ -1,9 +1,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:geo_app/bloc/setting.dart'; -import 'package:geo_app/component/loader.dart'; -import 'package:geo_app/page/map.dart'; -import 'package:geo_app/page/setting.dart'; +import 'package:geosmart/component/loader.dart'; +import 'package:geosmart/page/map.dart'; +import 'package:geosmart/page/setting.dart'; +import 'package:geosmart/service/setting_service.dart'; class Startup extends StatefulWidget { @override @@ -13,15 +13,13 @@ class Startup extends StatefulWidget { } class _StartupState extends State { - SettingBloc _settingBloc; + SettingService _settingService; @override void initState() { - _settingBloc = new SettingBloc(); + _settingService = new SettingService(); - _settingBloc.getSetting(); - - _settingBloc.subject.listen((settingModel) { + _settingService.getSetting().then((settingModel) { if (settingModel.isNullHost() && settingModel.isNullId()) { Navigator.of(context).pushReplacement(new MaterialPageRoute( builder: (BuildContext context) => Setting(), @@ -32,7 +30,6 @@ class _StartupState extends State { )); } }); - super.initState(); } @@ -58,7 +55,6 @@ class _StartupState extends State { @override void dispose() { - _settingBloc.dispose(); super.dispose(); } } diff --git a/lib/repository/position_repository.dart b/lib/repository/position_repository.dart deleted file mode 100644 index 6379a10..0000000 --- a/lib/repository/position_repository.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:geo_app/model/response.dart'; -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/provider/position_provider.dart'; - -class PositionRepository { - PositionProvider _provider; - SettingModel _settingModel; - - PositionRepository(this._settingModel) { - this._provider = PositionProvider(this._settingModel); - } - - Future sendPosition(String lat, String lng) { - return this._provider.sendPosition(lat, lng); - } - - Future stopTracking() { - return this._provider.stopTracking(); - } -} diff --git a/lib/repository/unique_id_repository.dart b/lib/repository/unique_id_repository.dart deleted file mode 100644 index 4c223fe..0000000 --- a/lib/repository/unique_id_repository.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/provider/unique_id_provider.dart'; -import 'package:geo_app/model/unique_id_model.dart'; - -class UniqueIDRepository { - UniqueIDProvider _uniqueIDProvider; - SettingModel _settingModel; - - UniqueIDRepository(this._settingModel) { - this._uniqueIDProvider = UniqueIDProvider(this._settingModel); - } - - Future getUniqueID() { - return this._uniqueIDProvider.getUniqueID(); - } -} diff --git a/lib/provider/position_provider.dart b/lib/service/position_service.dart similarity index 67% rename from lib/provider/position_provider.dart rename to lib/service/position_service.dart index 611deed..90e7e5c 100644 --- a/lib/provider/position_provider.dart +++ b/lib/service/position_service.dart @@ -1,24 +1,25 @@ import 'package:dio/dio.dart'; -import 'package:geo_app/model/position.dart'; -import 'package:geo_app/model/response.dart'; -import 'package:geo_app/model/setting.dart'; +import 'package:geosmart/model/position.dart'; +import 'package:geosmart/model/response.dart'; +import 'package:geosmart/service/setting_service.dart'; -class PositionProvider { +class PositionService { final Dio _dio = Dio(); - SettingModel _settingModel; + final SettingService _settingBloc = SettingService(); - PositionProvider(this._settingModel); + PositionService(); Future sendPosition(String lat, String lng) async { + var m = await _settingBloc.getSetting(); Position position = new Position( - id: this._settingModel.id, + id: m.id, type: "user", lat: lat, lng: lng, ); try { Response response = await _dio.post( - this._settingModel.host + "/point/set", + m.host + "/point/set", data: position.toJson(), ); return ResponseModel.fromJson(response.data); @@ -33,11 +34,12 @@ class PositionProvider { } Future stopTracking() async { + var m = await _settingBloc.getSetting(); try { Response response = await _dio.post( - this._settingModel.host + "/point/unset", + m.host + "/point/unset", data: { - "id": this._settingModel.id, + "id": m.id, "type": "user", }, ); diff --git a/lib/bloc/setting.dart b/lib/service/setting_service.dart similarity index 56% rename from lib/bloc/setting.dart rename to lib/service/setting_service.dart index 523e24b..fcf0b7c 100644 --- a/lib/bloc/setting.dart +++ b/lib/service/setting_service.dart @@ -1,39 +1,26 @@ -import 'package:rxdart/rxdart.dart'; +import 'package:geosmart/model/setting.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:geo_app/model/setting.dart'; - -class SettingBloc { - PublishSubject _subject; +class SettingService { final String _host = "host"; final String _id = "id"; - SettingBloc() { - this._subject = PublishSubject(); - } - Future getSharedPreferences() async { return await SharedPreferences.getInstance(); } - setSetting(SettingModel setting) async { + Future setSetting(SettingModel setting) async { SharedPreferences sharedPreferences = await this.getSharedPreferences(); sharedPreferences.setString(_host, setting.host); sharedPreferences.setString(_id, setting.id); - this.getSetting(); + return await getSetting(); } - getSetting() async { + Future getSetting() async { SharedPreferences sharedPreferences = await this.getSharedPreferences(); - _subject.sink.add(new SettingModel( + return new SettingModel( sharedPreferences.getString(_host), sharedPreferences.getString(_id), - )); + ); } - - dispose() { - _subject.close(); - } - - PublishSubject get subject => _subject; } diff --git a/lib/provider/unique_id_provider.dart b/lib/service/unique_id_service.dart similarity index 71% rename from lib/provider/unique_id_provider.dart rename to lib/service/unique_id_service.dart index 3324899..09ac0ff 100644 --- a/lib/provider/unique_id_provider.dart +++ b/lib/service/unique_id_service.dart @@ -1,13 +1,13 @@ import 'package:dio/dio.dart'; -import 'package:geo_app/model/setting.dart'; -import 'package:geo_app/model/unique_id_model.dart'; +import 'package:geosmart/model/setting.dart'; +import 'package:geosmart/model/unique_id_model.dart'; -class UniqueIDProvider { +class UniqueIDService { final String _endpoint = "/id/get/unique"; final Dio _dio = Dio(); SettingModel _settingModel; - UniqueIDProvider(this._settingModel); + UniqueIDService(this._settingModel); Future getUniqueID() async { try { diff --git a/pubspec.lock b/pubspec.lock index f2814e9..a18a715 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,97 +1,48 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - analyzer: - dependency: transitive - description: - name: analyzer - url: "https://pub.dartlang.org" - source: hosted - version: "0.39.2+1" archive: dependency: transitive description: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - background_fetch: - dependency: transitive - description: - name: background_fetch - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.0" - background_location: - dependency: "direct main" - description: - name: background_location - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.9+1" + version: "2.4.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - build: - dependency: transitive - description: - name: build - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.2" - build_config: - dependency: transitive - description: - name: build_config - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.1+1" + version: "2.0.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - checked_yaml: - dependency: transitive - description: - name: checked_yaml - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" + version: "1.1.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.12" convert: dependency: transitive description: @@ -105,14 +56,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" + version: "2.1.4" cupertino_icons: dependency: "direct main" description: @@ -120,39 +64,32 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" - dart_style: - dependency: transitive - description: - name: dart_style - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.3" - device_info: - dependency: "direct main" - description: - name: device_info - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.1+4" dio: dependency: "direct main" description: name: dio url: "https://pub.dartlang.org" source: hosted - version: "3.0.8" + version: "3.0.9" + equatable: + dependency: transitive + description: + name: equatable + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_background_geolocation: - dependency: "direct main" + flutter_plugin_android_lifecycle: + dependency: transitive description: - name: flutter_background_geolocation + name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.0.8" flutter_test: dependency: "direct dev" description: flutter @@ -169,77 +106,63 @@ packages: name: fluttertoast url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" - glob: - dependency: transitive + version: "5.0.1" + geolocator: + dependency: "direct main" description: - name: glob + name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "5.3.2+2" + google_api_availability: + dependency: transitive + description: + name: google_api_availability + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "0.5.21+15" - html: + version: "0.5.28+1" + google_maps_flutter_platform_interface: dependency: transitive description: - name: html + name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "0.14.0+3" + version: "1.0.2" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0+3" + version: "0.12.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.3" + version: "3.1.4" image: dependency: transitive description: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" - js: + version: "2.1.12" + location_permissions: dependency: transitive description: - name: js + name: location_permissions url: "https://pub.dartlang.org" source: hosted - version: "0.6.1+1" - json_annotation: - dependency: transitive - description: - name: json_annotation - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.1" - json_serializable: - dependency: "direct main" - description: - name: json_serializable - url: "https://pub.dartlang.org" - source: hosted - version: "3.2.5" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "0.11.3+2" + version: "3.0.0+1" matcher: dependency: transitive description: @@ -254,27 +177,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.8" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1+2" - package_config: - dependency: transitive - description: - name: package_config - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" path: dependency: transitive description: @@ -288,14 +190,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" - permission_handler: - dependency: "direct main" - description: - name: permission_handler - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" + version: "1.9.0" petitparser: dependency: transitive description: @@ -303,81 +198,67 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.0" - pub_semver: + plugin_platform_interface: dependency: transitive description: - name: pub_semver + name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.4.2" - pubspec_parse: - dependency: transitive - description: - name: pubspec_parse - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.5" + version: "1.0.2" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.3" rxdart: dependency: "direct main" description: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.23.1" + version: "0.24.1" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.6" + version: "0.5.7+3" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+3" + version: "0.0.1+10" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.4" shared_preferences_web: dependency: transitive description: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "0.1.2+2" + version: "0.1.2+7" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" - source_gen: - dependency: transitive - description: - name: source_gen - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.4+7" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: @@ -392,6 +273,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" string_scanner: dependency: transitive description: @@ -412,7 +300,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.15" typed_data: dependency: transitive description: @@ -427,27 +315,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" - watcher: - dependency: transitive - description: - name: watcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.9.7+13" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.0" + version: "3.6.1" sdks: - dart: ">=2.6.0 <3.0.0" - flutter: ">=1.12.13+hotfix.4 <2.0.0" + dart: ">=2.7.0 <3.0.0" + flutter: ">=1.16.3 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 016a95c..6846b06 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,9 @@ -name: geo_app -description: GEO Smart App +name: geosmart +description: A new Flutter project. + +# The following line prevents the package from being accidentally published to +# pub.dev using `pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -14,32 +18,28 @@ description: GEO Smart App version: 1.0.0+1 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 - google_maps_flutter: ^0.5.21+15 - background_location: ^0.0.9 - http: ^0.12.0+2 - json_serializable: ^3.2.3 - shared_preferences: ^0.5.6 - rxdart: ^0.23.1 - dio: ^3.0.7 - fluttertoast: ^3.1.3 - device_info: ^0.4.1+4 - flutter_background_geolocation: ^1.5.0 - permission_handler: ^4.0.0 + cupertino_icons: ^0.1.3 + geolocator: ^5.3.2+2 + http: ^0.12.1 + google_maps_flutter: ^0.5.28+1 + shared_preferences: ^0.5.7+3 + rxdart: ^0.24.1 + dio: ^3.0.9 + fluttertoast: ^5.0.1 dev_dependencies: flutter_test: sdk: flutter - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/test/widget_test.dart b/test/widget_test.dart index ddc68e3..456bc15 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:geo_app/main.dart'; +import 'package:geosmart/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async {