first commit
|
@ -0,0 +1,43 @@
|
|||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# 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/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
**/ios/Flutter/.last_build_id
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
.pub-cache/
|
||||
.pub/
|
||||
/build/
|
||||
|
||||
# Symbolication related
|
||||
app.*.symbols
|
||||
|
||||
# Obfuscation related
|
||||
app.*.map.json
|
||||
|
||||
# Android Studio will place build artifacts here
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
|
@ -0,0 +1,45 @@
|
|||
# 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: "54e66469a933b60ddf175f858f82eaeb97e48c8d"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: android
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: ios
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: linux
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: macos
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: web
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
- platform: windows
|
||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
|
@ -0,0 +1,28 @@
|
|||
# This file configures the analyzer, which statically analyzes Dart code to
|
||||
# check for errors, warnings, and lints.
|
||||
#
|
||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||
# invoked from the command line by running `flutter analyze`.
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
# The lint rules applied to this project can be customized in the
|
||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||
# included above or to enable additional rules. A list of all available lints
|
||||
# and their documentation is published at https://dart.dev/lints.
|
||||
#
|
||||
# Instead of disabling a lint rule for the entire project in the
|
||||
# section below, it can also be suppressed for a single line of code
|
||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||
# producing the lint.
|
||||
rules:
|
||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
|
@ -0,0 +1,13 @@
|
|||
gradle-wrapper.jar
|
||||
/.gradle
|
||||
/captures/
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/local.properties
|
||||
GeneratedPluginRegistrant.java
|
||||
|
||||
# Remember to never publicly share your keystore.
|
||||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
|
||||
key.properties
|
||||
**/*.keystore
|
||||
**/*.jks
|
|
@ -0,0 +1,69 @@
|
|||
plugins {
|
||||
id "com.android.application"
|
||||
id "kotlin-android"
|
||||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
}
|
||||
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace "com.example.beta_app1"
|
||||
compileSdk flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
applicationId "com.example.beta_app1"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutter {
|
||||
source '../..'
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
|
@ -0,0 +1,48 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<application
|
||||
android:label="Nutrify"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<!-- 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. -->
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility?hl=en and
|
||||
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
|
||||
|
||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
|
@ -0,0 +1,5 @@
|
|||
package com.example.beta_app1
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
class MainActivity: FlutterActivity()
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="?android:colorBackground" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Modify this file to customize your launch splash screen -->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@android:color/white" />
|
||||
|
||||
<!-- You can insert your own image assets here -->
|
||||
<!-- <item>
|
||||
<bitmap
|
||||
android:gravity="center"
|
||||
android:src="@mipmap/launch_image" />
|
||||
</item> -->
|
||||
</layer-list>
|
After Width: | Height: | Size: 544 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 721 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<!-- Show a splash screen on the activity. Automatically removed when
|
||||
the Flutter engine draws its first frame -->
|
||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||
</style>
|
||||
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||
This theme determines the color of the Android Window while your
|
||||
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||
running.
|
||||
|
||||
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||
<item name="android:windowBackground">?android:colorBackground</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- The INTERNET permission is required for development. Specifically,
|
||||
the Flutter tool needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
</manifest>
|
|
@ -0,0 +1,18 @@
|
|||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.buildDir = '../build'
|
||||
subprojects {
|
||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||
}
|
||||
subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
org.gradle.jvmargs=-Xmx4G
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
|
|
@ -0,0 +1,26 @@
|
|||
pluginManagement {
|
||||
def flutterSdkPath = {
|
||||
def properties = new Properties()
|
||||
file("local.properties").withInputStream { properties.load(it) }
|
||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||
return flutterSdkPath
|
||||
}
|
||||
settings.ext.flutterSdkPath = flutterSdkPath()
|
||||
|
||||
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||
id "com.android.application" version "7.3.0" apply false
|
||||
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
|
||||
}
|
||||
|
||||
include ":app"
|
After Width: | Height: | Size: 2.9 MiB |
After Width: | Height: | Size: 895 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 731 KiB |
After Width: | Height: | Size: 419 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 63 KiB |
|
@ -0,0 +1,34 @@
|
|||
**/dgph
|
||||
*.mode1v3
|
||||
*.mode2v3
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
*.perspectivev3
|
||||
**/*sync/
|
||||
.sconsign.dblite
|
||||
.tags*
|
||||
**/.vagrant/
|
||||
**/DerivedData/
|
||||
Icon?
|
||||
**/Pods/
|
||||
**/.symlinks/
|
||||
profile
|
||||
xcuserdata
|
||||
**/.generated/
|
||||
Flutter/App.framework
|
||||
Flutter/Flutter.framework
|
||||
Flutter/Flutter.podspec
|
||||
Flutter/Generated.xcconfig
|
||||
Flutter/ephemeral/
|
||||
Flutter/app.flx
|
||||
Flutter/app.zip
|
||||
Flutter/flutter_assets/
|
||||
Flutter/flutter_export_environment.sh
|
||||
ServiceDefinitions.json
|
||||
Runner/GeneratedPluginRegistrant.*
|
||||
|
||||
# Exceptions to above rules.
|
||||
!default.mode1v3
|
||||
!default.mode2v3
|
||||
!default.pbxuser
|
||||
!default.perspectivev3
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>App</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.flutter.flutter.app</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>App</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>12.0</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1 @@
|
|||
#include "Generated.xcconfig"
|
|
@ -0,0 +1 @@
|
|||
#include "Generated.xcconfig"
|
|
@ -0,0 +1,616 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
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 */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
|
||||
remoteInfo = Runner;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
|
||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
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 = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
97C146EB1CF9000F007C117D /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
331C8082294A63A400263BE5 /* RunnerTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
331C807B294A618700263BE5 /* RunnerTests.swift */,
|
||||
);
|
||||
path = RunnerTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
);
|
||||
name = Flutter;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146E51CF9000F007C117D = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
331C8082294A63A400263BE5 /* RunnerTests */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146EF1CF9000F007C117D /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146EE1CF9000F007C117D /* Runner.app */,
|
||||
331C8081294A63A400263BE5 /* RunnerTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146F01CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||
97C147021CF9000F007C117D /* Info.plist */,
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||
);
|
||||
path = Runner;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
331C8080294A63A400263BE5 /* RunnerTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
|
||||
buildPhases = (
|
||||
331C807D294A63A400263BE5 /* Sources */,
|
||||
331C807F294A63A400263BE5 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
331C8086294A63A400263BE5 /* PBXTargetDependency */,
|
||||
);
|
||||
name = RunnerTests;
|
||||
productName = RunnerTests;
|
||||
productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
97C146ED1CF9000F007C117D /* Runner */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||
buildPhases = (
|
||||
9740EEB61CF901F6004384FC /* Run Script */,
|
||||
97C146EA1CF9000F007C117D /* Sources */,
|
||||
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||
97C146EC1CF9000F007C117D /* Resources */,
|
||||
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Runner;
|
||||
productName = Runner;
|
||||
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
97C146E61CF9000F007C117D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastUpgradeCheck = 1510;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
331C8080294A63A400263BE5 = {
|
||||
CreatedOnToolsVersion = 14.0;
|
||||
TestTargetID = 97C146ED1CF9000F007C117D;
|
||||
};
|
||||
97C146ED1CF9000F007C117D = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
LastSwiftMigration = 1100;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 97C146E51CF9000F007C117D;
|
||||
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
97C146ED1CF9000F007C117D /* Runner */,
|
||||
331C8080294A63A400263BE5 /* RunnerTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
331C807F294A63A400263BE5 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97C146EC1CF9000F007C117D /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
|
||||
);
|
||||
name = "Thin Binary";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Run Script";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
331C807D294A63A400263BE5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
97C146EA1CF9000F007C117D /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
331C8086294A63A400263BE5 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 97C146ED1CF9000F007C117D /* Runner */;
|
||||
targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C146FB1CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
97C147001CF9000F007C117D /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
249021D4217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
331C8088294A63A400263BE5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
331C8089294A63A400263BE5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
331C808A294A63A400263BE5 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
97C147031CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147041CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SUPPORTED_PLATFORMS = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
97C147061CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
97C147071CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.betaApp1;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
331C8088294A63A400263BE5 /* Debug */,
|
||||
331C8089294A63A400263BE5 /* Release */,
|
||||
331C808A294A63A400263BE5 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147031CF9000F007C117D /* Debug */,
|
||||
97C147041CF9000F007C117D /* Release */,
|
||||
249021D3217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
97C147061CF9000F007C117D /* Debug */,
|
||||
97C147071CF9000F007C117D /* Release */,
|
||||
249021D4217E4FDB00AE95B9 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1510"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO"
|
||||
parallelizable = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "331C8080294A63A400263BE5"
|
||||
BuildableName = "RunnerTests.xctest"
|
||||
BlueprintName = "RunnerTests"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Profile"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreviewsEnabled</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,13 @@
|
|||
import UIKit
|
||||
import Flutter
|
||||
|
||||
@UIApplicationMain
|
||||
@objc class AppDelegate: FlutterAppDelegate {
|
||||
override func application(
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "Icon-App-1024x1024@1x.png",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 295 B |
After Width: | Height: | Size: 406 B |
After Width: | Height: | Size: 450 B |
After Width: | Height: | Size: 282 B |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 704 B |
After Width: | Height: | Size: 406 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 862 B |
After Width: | Height: | Size: 862 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 762 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "LaunchImage.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "LaunchImage@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "LaunchImage@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 68 B |
After Width: | Height: | Size: 68 B |
After Width: | Height: | Size: 68 B |
|
@ -0,0 +1,5 @@
|
|||
# Launch Screen Assets
|
||||
|
||||
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
|
||||
|
||||
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
|
||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="LaunchImage" width="168" height="185"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Flutter View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Beta App1</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>beta_app1</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1 @@
|
|||
#import "GeneratedPluginRegistrant.h"
|
|
@ -0,0 +1,12 @@
|
|||
import Flutter
|
||||
import UIKit
|
||||
import XCTest
|
||||
|
||||
class RunnerTests: XCTestCase {
|
||||
|
||||
func testExample() {
|
||||
// If you add code to the Runner application, consider adding tests here.
|
||||
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,474 @@
|
|||
// import 'package:flutter/material.dart';
|
||||
// import 'package:shared_preferences/shared_preferences.dart';
|
||||
// import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
// import 'package:mqtt_client/mqtt_client.dart';
|
||||
|
||||
// import 'package:beta_app1/login/api_service.dart';
|
||||
// import 'package:beta_app1/login/user.dart';
|
||||
// import 'package:beta_app1/login/login.dart';
|
||||
// import 'package:beta_app1/page/control.dart';
|
||||
// import 'package:beta_app1/page/monitoring.dart';
|
||||
// import 'package:beta_app1/page/info.dart';
|
||||
// import 'package:beta_app1/page/homecontent.dart';
|
||||
|
||||
// class HomePage extends StatefulWidget {
|
||||
// @override
|
||||
// _HomePageState createState() => _HomePageState();
|
||||
// }
|
||||
|
||||
// class _HomePageState extends State<HomePage> {
|
||||
// int _currentIndex = 0;
|
||||
// bool _isConnected = false;
|
||||
// late MqttServerClient _client;
|
||||
// final ApiService apiService = ApiService();
|
||||
|
||||
// List<Widget> _children = [];
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _initializeClient();
|
||||
// }
|
||||
|
||||
// void _initializeClient() async {
|
||||
// final broker = '192.168.0.111';
|
||||
// final port = 1883; // MQTT default port
|
||||
// final clientId = 'Mqqt_Flutter';
|
||||
|
||||
// _client = MqttServerClient(broker, clientId);
|
||||
// _client.port = port;
|
||||
// _client.keepAlivePeriod = 20;
|
||||
// _client.connectTimeoutPeriod = 2000;
|
||||
// _client.onConnected = _onConnected;
|
||||
|
||||
// // Membuat objek MqttConnectMessage dengan autentikasi
|
||||
// final connMess = MqttConnectMessage()
|
||||
// .withClientIdentifier(clientId)
|
||||
// .withWillTopic('willtopic')
|
||||
// .withWillMessage('My Will message')
|
||||
// .startClean()
|
||||
// .withWillQos(MqttQos.atLeastOnce);
|
||||
// print('EXAMPLE::Mosquitto client Connecting....');
|
||||
// _client.connectionMessage = connMess;
|
||||
|
||||
// try {
|
||||
// await _client.connect();
|
||||
// setState(() {
|
||||
// _isConnected = true;
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('Exception: $e');
|
||||
// _showErrorDialog('Failed to connect to MQTT broker');
|
||||
// }
|
||||
|
||||
// _children = [
|
||||
// HomeContent(),
|
||||
// SensorMonitoringScreen(),
|
||||
// ControlScreen(
|
||||
// client: _client,
|
||||
// ),
|
||||
// InfoScreen(),
|
||||
// ];
|
||||
// }
|
||||
|
||||
// void onTabTapped(int index) {
|
||||
// setState(() {
|
||||
// _currentIndex = index;
|
||||
// });
|
||||
// }
|
||||
|
||||
// Future<void> removeAuthToken() async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.remove('auth_token');
|
||||
// }
|
||||
|
||||
// void _logout() async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// final token = prefs.getString('auth_token');
|
||||
|
||||
// if (token != null) {
|
||||
// try {
|
||||
// await apiService.logout(token);
|
||||
// await removeAuthToken();
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => LoginPage()),
|
||||
// );
|
||||
// } catch (e) {
|
||||
// _showErrorDialog('Failed to logout. Please try again');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void _showErrorDialog(String message) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return AlertDialog(
|
||||
// title: Text('Error'),
|
||||
// content: Text(message),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: Text('Ok'),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// void _toggleConnection() async {
|
||||
// if (_isConnected) {
|
||||
// _client.disconnect();
|
||||
// setState(() {
|
||||
// _isConnected = false;
|
||||
// });
|
||||
// } else {
|
||||
// final broker = '192.168.0.111';
|
||||
// final port = 1883; // MQTT default port
|
||||
// final clientId = 'Mqqt_Flutter';
|
||||
|
||||
// _client = MqttServerClient(broker, clientId);
|
||||
// _client.port = port;
|
||||
// _client.keepAlivePeriod = 20;
|
||||
// _client.connectTimeoutPeriod = 2000;
|
||||
// _client.onConnected = _onConnected;
|
||||
|
||||
// // Membuat objek MqttConnectMessage dengan autentikasi
|
||||
// final connMess = MqttConnectMessage()
|
||||
// .withClientIdentifier(clientId)
|
||||
// .withWillTopic('willtopic')
|
||||
// .withWillMessage('My Will message')
|
||||
// .startClean()
|
||||
// .withWillQos(MqttQos.atLeastOnce);
|
||||
// print('EXAMPLE::Mosquitto client Connecting....');
|
||||
// _client.connectionMessage = connMess;
|
||||
|
||||
// try {
|
||||
// await _client.connect();
|
||||
// setState(() {
|
||||
// _isConnected = true;
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('Exception: $e');
|
||||
// _showErrorDialog('Failed to connect to MQTT broker');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void _onConnected() {
|
||||
// print('Connected');
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text(
|
||||
// ['Dashboard', 'Monitoring', 'Control', 'Info'][_currentIndex],
|
||||
// style: TextStyle(fontWeight: FontWeight.bold),
|
||||
// ),
|
||||
// centerTitle: true,
|
||||
// ),
|
||||
// drawer: Drawer(
|
||||
// child: FutureBuilder<List<User>>(
|
||||
// future: apiService.fetchUsers(),
|
||||
// builder: (context, snapshot) {
|
||||
// if (snapshot.hasData) {
|
||||
// List<User>? users = snapshot.data;
|
||||
// return ListView(
|
||||
// padding: EdgeInsets.zero,
|
||||
// children: <Widget>[
|
||||
// UserAccountsDrawerHeader(
|
||||
// accountName: Text(users!.first.fullname),
|
||||
// accountEmail: Text(users.first.username),
|
||||
// currentAccountPicture: CircleAvatar(
|
||||
// backgroundImage: AssetImage('images/ahri_icon.jpg'),
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.green,
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// leading: Icon(Icons.logout),
|
||||
// title: Text('Logout'),
|
||||
// onTap: _logout,
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Text('${snapshot.error}');
|
||||
// }
|
||||
// return Center(child: CircularProgressIndicator());
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// body: Stack(
|
||||
// children: [
|
||||
// AnimatedSwitcher(
|
||||
// duration: Duration(milliseconds: 300),
|
||||
// child: _children[_currentIndex],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// bottomNavigationBar: BottomNavigationBar(
|
||||
// currentIndex: _currentIndex,
|
||||
// onTap: onTabTapped,
|
||||
// items: const [
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(Icons.home_filled),
|
||||
// label: 'Home',
|
||||
// ),
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(Icons.monitor),
|
||||
// label: 'Monitor',
|
||||
// ),
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(Icons.settings),
|
||||
// label: 'Control',
|
||||
// ),
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(Icons.info),
|
||||
// label: 'Info',
|
||||
// ),
|
||||
// ],
|
||||
// type: BottomNavigationBarType.fixed,
|
||||
// selectedItemColor: Colors.green,
|
||||
// unselectedItemColor: Colors.grey,
|
||||
// showSelectedLabels: true,
|
||||
// showUnselectedLabels: false,
|
||||
// selectedLabelStyle: TextStyle(
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// floatingActionButton: FloatingActionButton(
|
||||
// onPressed: _toggleConnection,
|
||||
// child: Icon(_isConnected ? Icons.wifi : Icons.wifi_off),
|
||||
// backgroundColor: _isConnected ? Colors.green : Colors.red,
|
||||
// ),
|
||||
// floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// <?php
|
||||
// $servername = "localhost";
|
||||
// $username = "username";
|
||||
// $password = "password";
|
||||
// $dbname = "database_name";
|
||||
|
||||
// // Create connection
|
||||
// $conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// // Check connection
|
||||
// if ($conn->connect_error) {
|
||||
// die("Connection failed: " . $conn->connect_error);
|
||||
// }
|
||||
|
||||
// // Query to get data from the first table
|
||||
// $sql1 = "SELECT x, y1, y2 FROM table1";
|
||||
// $result1 = $conn->query($sql1);
|
||||
|
||||
// $data1 = array();
|
||||
// if ($result1->num_rows > 0) {
|
||||
// while($row = $result1->fetch_assoc()) {
|
||||
// $data1[] = $row;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Query to get data from the second table
|
||||
// $sql2 = "SELECT x, y FROM table2";
|
||||
// $result2 = $conn->query($sql2);
|
||||
|
||||
// $data2 = array();
|
||||
// if ($result2->num_rows > 0) {
|
||||
// while($row = $result2->fetch_assoc()) {
|
||||
// $data2[] = $row;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $conn->close();
|
||||
|
||||
// header('Content-Type: application/json');
|
||||
// echo json_encode(array('table1' => $data1, 'table2' => $data2));
|
||||
// ?>
|
||||
|
||||
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:mqtt_client/mqtt_client.dart';
|
||||
// import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
|
||||
// import 'package:beta_app1/widget/monitoring/TdsMonitor.dart';
|
||||
// import 'package:beta_app1/widget/monitoring/WaterflowMonitoring.dart';
|
||||
// import 'package:beta_app1/widget/monitoring/Ultrasonik.dart';
|
||||
|
||||
// class SensorMonitoringScreen extends StatefulWidget {
|
||||
// final MqttServerClient client;
|
||||
|
||||
// SensorMonitoringScreen({required this.client});
|
||||
|
||||
// @override
|
||||
// _SensorMonitoringScreenState createState() => _SensorMonitoringScreenState();
|
||||
// }
|
||||
|
||||
// class _SensorMonitoringScreenState extends State<SensorMonitoringScreen> {
|
||||
// double? tdsValue;
|
||||
// double? waterflow1Value;
|
||||
// double? waterflow2Value;
|
||||
// double? ultrasonicValue;
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// _subscribeToTopics();
|
||||
// }
|
||||
|
||||
// void _subscribeToTopics() {
|
||||
// if (widget.client.connectionStatus!.state ==
|
||||
// MqttConnectionState.connected) {
|
||||
// widget.client.subscribe('tds_topic', MqttQos.atMostOnce);
|
||||
// widget.client.subscribe('waterflow1_topic', MqttQos.atLeastOnce);
|
||||
// widget.client.subscribe('waterflow2_topic', MqttQos.atLeastOnce);
|
||||
// widget.client.subscribe('ultrasonic_topic', MqttQos.atLeastOnce);
|
||||
|
||||
// widget.client.updates!.listen(
|
||||
// (List<MqttReceivedMessage<MqttMessage?>> messages) {
|
||||
// final message = messages[0].payload as MqttPublishMessage;
|
||||
// final payload =
|
||||
// MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||
|
||||
// double? value;
|
||||
// try {
|
||||
// value = double.parse(payload);
|
||||
// } catch (e) {
|
||||
// print('Error parsing payload: $e');
|
||||
// }
|
||||
|
||||
// setState(() {
|
||||
// switch (messages[0].topic) {
|
||||
// case 'tds_topic':
|
||||
// tdsValue = value;
|
||||
// break;
|
||||
// case 'waterflow1_topic':
|
||||
// waterflow1Value = value;
|
||||
// break;
|
||||
// case 'waterflow2_topic':
|
||||
// waterflow2Value = value;
|
||||
// break;
|
||||
// case 'ultrasonic_topic':
|
||||
// ultrasonicValue = value;
|
||||
// break;
|
||||
// default:
|
||||
// print('Unknown topic: ${messages[0].topic}');
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// );
|
||||
// } else {
|
||||
// print('MQTT Client is not connected');
|
||||
// }
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// toolbarHeight: 0,
|
||||
// titleSpacing: 0,
|
||||
// ),
|
||||
// body: SingleChildScrollView(
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.all(16.0),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
// children: [
|
||||
// TDSMonitor(value: tdsValue ?? 0.0),
|
||||
// SizedBox(height: 16.0),
|
||||
// WaterflowMonitor(
|
||||
// waterflow1Value: waterflow1Value ?? 0.0,
|
||||
// waterflow2Value: waterflow2Value ?? 0.0,
|
||||
// ),
|
||||
// SizedBox(height: 16.0),
|
||||
// UltrasonicMonitor(
|
||||
// ultrasonicValue: ultrasonicValue ?? 0.0,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// import 'package:flutter/material.dart';
|
||||
|
||||
// class UltrasonicMonitor extends StatelessWidget {
|
||||
// final double value;
|
||||
|
||||
// UltrasonicMonitor({required this.value});
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Container(
|
||||
// padding: EdgeInsets.all(16.0),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.grey.withOpacity(0.2),
|
||||
// borderRadius: BorderRadius.circular(8.0),
|
||||
// ),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Text(
|
||||
// 'Ultrasonic',
|
||||
// style: TextStyle(
|
||||
// fontSize: 18.0,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 200.0, // Tinggi maksimum container
|
||||
// child: Stack(
|
||||
// alignment: Alignment.bottomCenter,
|
||||
// children: [
|
||||
// Container(
|
||||
// width: 50.0,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.blue.withOpacity(0.2),
|
||||
// borderRadius: BorderRadius.circular(8.0),
|
||||
// ),
|
||||
// ),
|
||||
// ConstrainedBox(
|
||||
// constraints: BoxConstraints(
|
||||
// maxHeight: 200.0), // Batasi tinggi maksimum
|
||||
// child: AnimatedContainer(
|
||||
// duration: Duration(milliseconds: 500),
|
||||
// width: 50.0,
|
||||
// height: value * 2, // Ubah menjadi nilai yang sesuai
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.blue,
|
||||
// borderRadius: BorderRadius.circular(8.0),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// bottom: value * 2 + 8.0, // Ubah menjadi nilai yang sesuai
|
||||
// child: Text(
|
||||
// '${value.toStringAsFixed(2)} cm',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16.0,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
|
@ -0,0 +1,48 @@
|
|||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'user.dart';
|
||||
|
||||
class ApiService {
|
||||
static String baseUrl = '';
|
||||
|
||||
static Future<void> initializeBaseUrl() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final mqttServerIp = prefs.getString('mqtt_server_ip') ?? '192.168.48.153';
|
||||
baseUrl = 'http://$mqttServerIp/test_api/';
|
||||
}
|
||||
|
||||
Future<List<User>> fetchUsers() async {
|
||||
if (baseUrl.isEmpty) {
|
||||
await initializeBaseUrl();
|
||||
}
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final username = prefs.getString('auth_username');
|
||||
|
||||
final url = username != null
|
||||
? Uri.parse('$baseUrl/get_data.php?username=$username')
|
||||
: Uri.parse('$baseUrl/get_data.php');
|
||||
|
||||
final response = await http.get(url);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final List<dynamic> jsonList = jsonDecode(response.body);
|
||||
return jsonList.map((json) => User.fromJson(json)).toList();
|
||||
} else {
|
||||
throw Exception('Failed to fetch users');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logout(String token) async {
|
||||
final url = Uri.parse('$baseUrl/logout.php');
|
||||
final response = await http.post(
|
||||
url,
|
||||
body: {'token': token},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Failed to logout');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'register.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:beta_app1/page/dashboard.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
TextEditingController usernameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
bool _obscureText = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cekLogin();
|
||||
}
|
||||
|
||||
Future<void> _prosesLogin() async {
|
||||
if (usernameController.text.isEmpty || passwordController.text.isEmpty) {
|
||||
_showDialog('Login Gagal', 'Harap isi semua field.', false);
|
||||
return;
|
||||
}
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp =
|
||||
prefs.getString('mqtt_server_ip') ?? '192.168.183.153';
|
||||
String url = 'http://$mqttServerIp/test_api/login.php';
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(url),
|
||||
body: {
|
||||
"username": usernameController.text,
|
||||
"password": passwordController.text,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final responseBody = json.decode(response.body);
|
||||
|
||||
if (responseBody['success']) {
|
||||
final datauser = responseBody['data'];
|
||||
final token = datauser['token'];
|
||||
final username = datauser['username'];
|
||||
|
||||
await saveAuthToken(
|
||||
token, username); // Simpan token ke SharedPreferences
|
||||
|
||||
_showDialog(
|
||||
'Login Berhasil', 'Selamat datang, ${datauser['fullname']}!', true);
|
||||
} else {
|
||||
_showDialog('Login Gagal', responseBody['message'], false);
|
||||
}
|
||||
} else {
|
||||
_showDialog('Login Gagal', 'Terjadi kesalahan pada server.', false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveAuthToken(String token, String username) async {
|
||||
if (token.isNotEmpty && username.isNotEmpty) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('auth_username', username);
|
||||
await prefs.setString('auth_token', token);
|
||||
} else {
|
||||
_showDialog(
|
||||
'Upaya Login Gagal', 'Cek Kembali Username dan Password', false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> getAuthToken() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString('auth_token');
|
||||
}
|
||||
|
||||
Future<void> _cekLogin() async {
|
||||
final authToken = await getAuthToken();
|
||||
if (authToken != null) {
|
||||
Navigator.pushReplacement(
|
||||
context, MaterialPageRoute(builder: (context) => HomePage()));
|
||||
}
|
||||
}
|
||||
|
||||
void _showDialog(String title, String content, bool isSuccess) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
if (isSuccess) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HomePage()),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
"images/nature.gif",
|
||||
height: 200,
|
||||
width: 200,
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
elevation: 8,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Login',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color.fromARGB(150, 0, 0, 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: usernameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Username',
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
hintText: 'Please input your username',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: passwordController,
|
||||
obscureText: _obscureText,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
prefixIcon: const Icon(Icons.password),
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
hintText: "Please input your password",
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscureText
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: _prosesLogin,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
const Color.fromARGB(255, 41, 221, 47),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
minimumSize: const Size(double.infinity, 50),
|
||||
),
|
||||
child: const Text(
|
||||
'Login',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => RegisterPage()),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
const Color.fromARGB(255, 255, 255, 255),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
minimumSize: const Size(double.infinity, 50),
|
||||
),
|
||||
child: const Text(
|
||||
'Register',
|
||||
style: TextStyle(
|
||||
color: Color.fromARGB(166, 26, 21, 21)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"Apps Made For",
|
||||
style: TextStyle(color: Colors.black, fontSize: 10),
|
||||
),
|
||||
const Text(
|
||||
"Nutrient Hydroponic Control",
|
||||
style: TextStyle(color: Colors.black, fontSize: 10.0),
|
||||
),
|
||||
const Text(
|
||||
"@2024",
|
||||
style: TextStyle(color: Colors.black, fontSize: 10.0),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'login.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
RegisterPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _RegisterPageState();
|
||||
}
|
||||
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
TextEditingController usernameController = TextEditingController();
|
||||
TextEditingController passwordController = TextEditingController();
|
||||
TextEditingController fullnameController = TextEditingController();
|
||||
bool _obscureText = true;
|
||||
|
||||
String usernameError = '';
|
||||
String passwordError = '';
|
||||
|
||||
Future<void> registerUser() async {
|
||||
String username = usernameController.text.trim();
|
||||
String password = passwordController.text.trim();
|
||||
String fullname = fullnameController.text.trim();
|
||||
|
||||
// Validasi username
|
||||
if (username.length < 6 ||
|
||||
!RegExp(r'^(?=.*[A-Z])(?=.*[0-9])[A-Za-z0-9]+$').hasMatch(username)) {
|
||||
setState(() {
|
||||
usernameError =
|
||||
'Username harus minimal 6 karakter, mengandung huruf kapital dan angka.';
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
setState(() {
|
||||
usernameError = '';
|
||||
});
|
||||
}
|
||||
|
||||
// Validasi password
|
||||
if (password.length < 6 ||
|
||||
!RegExp(r'^(?=.*?[a-zA-Z])(?=.*?[0-9])(?=.*?[!@#$%^&*()_+{}|:"<>?~`]).{6,}$')
|
||||
.hasMatch(password)) {
|
||||
setState(() {
|
||||
passwordError =
|
||||
'Password harus minimal 6 karakter, mengandung angka dan simbol.';
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
setState(() {
|
||||
passwordError = '';
|
||||
});
|
||||
}
|
||||
|
||||
// Validasi fullname (opsional)
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp = prefs.getString('mqtt_server_ip') ?? '192.168.0.1';
|
||||
String url = 'http://$mqttServerIp/test_api/register.php';
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(url),
|
||||
body: {
|
||||
"username": username,
|
||||
"password": password,
|
||||
"fullname": fullname,
|
||||
},
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Akun berhasil dibuat'),
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const LoginPage()),
|
||||
);
|
||||
} else {
|
||||
setState(() {
|
||||
// Handle error
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Halaman Registrasi'),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child:
|
||||
Image.asset("images/nature.gif", height: 200, width: 200),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
elevation: 8,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Center(
|
||||
child: Text(
|
||||
'Register',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color.fromARGB(150, 0, 0, 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: usernameController,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.person),
|
||||
labelText: 'Username',
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
hintText: 'Username',
|
||||
hintStyle: TextStyle(
|
||||
color: const Color.fromARGB(92, 0, 0, 0)
|
||||
.withOpacity(0.25),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (usernameError.isNotEmpty)
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 8.0, left: 12.0),
|
||||
child: Text(
|
||||
usernameError,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: fullnameController,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.perm_identity),
|
||||
labelText: 'Fullname',
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
hintText: 'Fullname',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: passwordController,
|
||||
obscureText: _obscureText,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.password),
|
||||
labelText: 'Password',
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
hintText: 'Password',
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscureText
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
if (passwordError.isNotEmpty)
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 8.0, left: 12.0),
|
||||
child: Text(
|
||||
passwordError,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 12.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: registerUser,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
minimumSize: const Size(double.infinity, 50),
|
||||
),
|
||||
child: const Text('Daftar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
class User {
|
||||
final String username;
|
||||
final String fullname;
|
||||
|
||||
User({required this.username, required this.fullname});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
username: json['username'],
|
||||
fullname: json['fullname'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'username': username,
|
||||
'fullname': fullname,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:beta_app1/login/register.dart';
|
||||
import 'package:beta_app1/login/login.dart';
|
||||
import 'package:beta_app1/page/dashboard.dart';
|
||||
import 'package:beta_app1/splash_screen.dart'; // Pastikan ini mengarah ke splash_screen.dart
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Nutrify Apps',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.green,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
home: SplashScreen(),
|
||||
routes: {
|
||||
'/login': (context) => const LoginPage(),
|
||||
'/register': (context) => RegisterPage(),
|
||||
'/home': (context) => HomePage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,310 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
import 'package:beta_app1/widget/control/config.dart';
|
||||
import 'package:beta_app1/widget/control/ui_component.dart';
|
||||
import 'package:beta_app1/widget/control/logic_function.dart';
|
||||
|
||||
class ControlScreen extends StatefulWidget {
|
||||
final MqttServerClient client;
|
||||
|
||||
ControlScreen({required this.client});
|
||||
|
||||
@override
|
||||
_ControlScreenState createState() => _ControlScreenState();
|
||||
}
|
||||
|
||||
class _ControlScreenState extends State<ControlScreen>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
bool isManualMode = true;
|
||||
bool _switchPump1 = false;
|
||||
bool _switchPump2 = false;
|
||||
bool _switchPump3 = false;
|
||||
bool _switchUltrasonic = false;
|
||||
bool _autoCycleNutrisi = false;
|
||||
|
||||
double tdsMin = 0.0;
|
||||
double tdsMax = 0.0;
|
||||
double currentTDS = 0.0;
|
||||
double ultrasonicLevel = 0.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
BusinessLogic.loadPreferences().then((prefs) {
|
||||
setState(() {
|
||||
_switchPump1 = prefs.getBool('switchPump1') ?? false;
|
||||
_switchPump2 = prefs.getBool('switchPump2') ?? false;
|
||||
_switchPump3 = prefs.getBool('switchPump3') ?? false;
|
||||
_switchUltrasonic = prefs.getBool('switchUltrasonic') ?? false;
|
||||
_autoCycleNutrisi = prefs.getBool('autoCycleNutrisi') ?? false;
|
||||
});
|
||||
});
|
||||
|
||||
BusinessLogic.getTDSValues().then((values) {
|
||||
setState(() {
|
||||
tdsMin = values['initialTDS'] ?? 0.0;
|
||||
tdsMax = values['finalTDS'] ?? 0.0;
|
||||
});
|
||||
});
|
||||
|
||||
if (widget.client.connectionStatus!.state ==
|
||||
MqttConnectionState.connected) {
|
||||
widget.client.updates!.listen((List<MqttReceivedMessage<MqttMessage>> c) {
|
||||
final MqttPublishMessage message = c[0].payload as MqttPublishMessage;
|
||||
final payload =
|
||||
MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||
|
||||
switch (c[0].topic) {
|
||||
case 'tds_topic':
|
||||
setState(() {
|
||||
currentTDS = double.parse(payload);
|
||||
});
|
||||
break;
|
||||
case 'ultrasonic_topic':
|
||||
setState(() {
|
||||
ultrasonicLevel = double.parse(payload);
|
||||
});
|
||||
break;
|
||||
case 'control':
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
|
||||
widget.client.subscribe('tds_topic', MqttQos.atMostOnce);
|
||||
widget.client.subscribe('ultrasonic_topic', MqttQos.atMostOnce);
|
||||
widget.client.subscribe('control', MqttQos.atMostOnce);
|
||||
} else {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Koneksi MQTT'),
|
||||
content: Text('Tolong hubungkan dengan MQTT terlebih dahulu'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void handleManualSwitchChange(int pumpNumber, bool value) {
|
||||
if (widget.client.connectionStatus!.state ==
|
||||
MqttConnectionState.connected) {
|
||||
setState(() {
|
||||
switch (pumpNumber) {
|
||||
case 1:
|
||||
_switchPump1 = value;
|
||||
break;
|
||||
case 2:
|
||||
_switchPump2 = value;
|
||||
break;
|
||||
case 3:
|
||||
_switchPump3 = value;
|
||||
break;
|
||||
case 4:
|
||||
_switchUltrasonic = value;
|
||||
break;
|
||||
}
|
||||
});
|
||||
BusinessLogic.publishMessage(widget.client, Config.manualControlTopic,
|
||||
value ? 'on$pumpNumber' : 'off$pumpNumber');
|
||||
BusinessLogic.savePreferences({
|
||||
'switchPump1': _switchPump1,
|
||||
'switchPump2': _switchPump2,
|
||||
'switchPump3': _switchPump3,
|
||||
'switchUltrasonic': _switchUltrasonic,
|
||||
'autoCycleNutrisi': _autoCycleNutrisi,
|
||||
});
|
||||
} else {
|
||||
_showMQTTDisconnectedDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void handleAutoSwitchChange(bool value) {
|
||||
if (widget.client.connectionStatus!.state ==
|
||||
MqttConnectionState.connected) {
|
||||
setState(() {
|
||||
_autoCycleNutrisi = value;
|
||||
});
|
||||
BusinessLogic.publishMessage(widget.client, Config.manualControlTopic,
|
||||
value ? 'onAuto' : 'offAuto');
|
||||
BusinessLogic.savePreferences({
|
||||
'autoCycleNutrisi': _autoCycleNutrisi,
|
||||
});
|
||||
} else {
|
||||
_showMQTTDisconnectedDialog();
|
||||
}
|
||||
}
|
||||
|
||||
void _showMQTTDisconnectedDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Koneksi MQTT'),
|
||||
content: Text('Tolong hubungkan dengan MQTT terlebih dahulu'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void showCalibrationDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CalibrationDialog(
|
||||
initialTDS: tdsMin,
|
||||
finalTDS: tdsMax,
|
||||
onSave: (initialTDS, finalTDS) {
|
||||
setState(() {
|
||||
tdsMin = initialTDS;
|
||||
tdsMax = finalTDS;
|
||||
});
|
||||
BusinessLogic.saveTDSValues(initialTDS, finalTDS);
|
||||
},
|
||||
mqttClient: widget.client,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
toolbarHeight: 0,
|
||||
titleSpacing: 0,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
ModeSwitch(
|
||||
isManualMode: isManualMode,
|
||||
onModeChanged: (mode) {
|
||||
setState(() {
|
||||
isManualMode = mode;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (isManualMode) ...[
|
||||
ControlButton(
|
||||
title: 'Pompa 1',
|
||||
subtitle: 'Pompa mengarah ke sensor TDS',
|
||||
isActive: _switchPump1,
|
||||
onPressed: () {
|
||||
handleManualSwitchChange(1, !_switchPump1);
|
||||
},
|
||||
activeIcon: Icons.power,
|
||||
inactiveIcon: Icons.power_off,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
ControlButton(
|
||||
title: 'Pompa 2',
|
||||
subtitle: 'Pompa Nutrisi A dan sensor waterflow 1',
|
||||
isActive: _switchPump2,
|
||||
onPressed: () {
|
||||
handleManualSwitchChange(2, !_switchPump2);
|
||||
},
|
||||
activeIcon: Icons.power,
|
||||
inactiveIcon: Icons.power_off,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
ControlButton(
|
||||
title: 'Pompa 3',
|
||||
subtitle: 'Pompa Nutrisi B dan sensor waterflow 2',
|
||||
isActive: _switchPump3,
|
||||
onPressed: () {
|
||||
handleManualSwitchChange(3, !_switchPump3);
|
||||
},
|
||||
activeIcon: Icons.power,
|
||||
inactiveIcon: Icons.power_off,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
ControlButton(
|
||||
title: 'Sensor Ultrasonic',
|
||||
subtitle: 'Sensor untuk mendeteksi level air',
|
||||
isActive: _switchUltrasonic,
|
||||
onPressed: () {
|
||||
handleManualSwitchChange(4, !_switchUltrasonic);
|
||||
},
|
||||
activeIcon: Icons.sensors,
|
||||
inactiveIcon: Icons.sensors_off,
|
||||
),
|
||||
] else ...[
|
||||
ControlButton(
|
||||
title: 'Siklus Nutrisi Otomatis',
|
||||
subtitle: 'Mengatur siklus nutrisi secara otomatis',
|
||||
isActive: _autoCycleNutrisi,
|
||||
onPressed: () {
|
||||
handleAutoSwitchChange(!_autoCycleNutrisi);
|
||||
},
|
||||
activeIcon: Icons.autorenew,
|
||||
inactiveIcon: Icons.autorenew,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
showCalibrationDialog();
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.green.shade600,
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
),
|
||||
elevation: 10.0,
|
||||
shadowColor: Colors.green.shade200,
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.science, color: Colors.white, size: 24.0),
|
||||
SizedBox(width: 10.0),
|
||||
Text(
|
||||
'Kalibrasi TDS',
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
letterSpacing: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,548 @@
|
|||
import 'dart:typed_data';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:beta_app1/login/api_service.dart';
|
||||
import 'package:beta_app1/login/user.dart';
|
||||
import 'package:beta_app1/login/login.dart';
|
||||
import 'package:beta_app1/page/control.dart';
|
||||
import 'package:beta_app1/page/monitoring.dart';
|
||||
import 'package:beta_app1/page/info.dart';
|
||||
import 'package:beta_app1/page/homecontent.dart';
|
||||
|
||||
final sensorData = SensorData();
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
int _currentIndex = 0;
|
||||
bool _isConnected = false;
|
||||
late MqttServerClient _client;
|
||||
late StreamSubscription<List<MqttReceivedMessage<MqttMessage?>>>?
|
||||
subscription;
|
||||
final ApiService apiService = ApiService();
|
||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
|
||||
List<Widget> _children = [];
|
||||
|
||||
double? tdsmin;
|
||||
double? tdsmax;
|
||||
double? tdsnow;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initializeClient();
|
||||
|
||||
var initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
var initializationSettings =
|
||||
InitializationSettings(android: initializationSettingsAndroid);
|
||||
flutterLocalNotificationsPlugin
|
||||
.initialize(initializationSettings)
|
||||
.then((_) {
|
||||
print('Notification plugin initialized');
|
||||
});
|
||||
}
|
||||
|
||||
void _initializeClient() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp = prefs.getString('mqtt_server_ip') ?? '192.168.1.100';
|
||||
String baseUrl = 'http://$mqttServerIp';
|
||||
|
||||
_client = MqttServerClient(mqttServerIp, 'Mqtt_Flutter');
|
||||
_client.port = 1883;
|
||||
_client.keepAlivePeriod = 20;
|
||||
_client.connectTimeoutPeriod = 2000;
|
||||
_client.onConnected = _onConnected;
|
||||
_client.onDisconnected = _onDisconnected;
|
||||
_client.autoReconnect = true;
|
||||
_client.onAutoReconnect = _onAutoReconnect;
|
||||
_client.onAutoReconnected = _onAutoReconnected;
|
||||
|
||||
final connMess = MqttConnectMessage()
|
||||
.withClientIdentifier('Mqtt_Flutter')
|
||||
.withWillTopic('willtopic')
|
||||
.withWillMessage('My Will message')
|
||||
.startClean()
|
||||
.withWillQos(MqttQos.atLeastOnce);
|
||||
print('Connecting to Mosquitto client...');
|
||||
_client.connectionMessage = connMess;
|
||||
|
||||
try {
|
||||
await _client.connect().timeout(Duration(seconds: 1));
|
||||
setState(() {
|
||||
_isConnected = true;
|
||||
});
|
||||
_subscribeToTopics();
|
||||
} catch (e) {
|
||||
print('Exception: $e');
|
||||
_showErrorDialog('Failed to connect to MQTT broker');
|
||||
}
|
||||
|
||||
_children = [
|
||||
HomeContent(),
|
||||
SensorMonitoringScreen(client: _client),
|
||||
ControlScreen(client: _client),
|
||||
InfoPage(),
|
||||
];
|
||||
}
|
||||
|
||||
void _onConnected() {
|
||||
print('Connected');
|
||||
setState(() {
|
||||
_isConnected = true;
|
||||
});
|
||||
}
|
||||
|
||||
void _onDisconnected() {
|
||||
print('Disconnected');
|
||||
setState(() {
|
||||
_isConnected = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _onAutoReconnect() {
|
||||
print('Attempting to reconnect...');
|
||||
setState(() {
|
||||
_isConnected = false;
|
||||
});
|
||||
}
|
||||
|
||||
void _onAutoReconnected() {
|
||||
print('Successfully reconnected');
|
||||
setState(() {
|
||||
_isConnected = true;
|
||||
});
|
||||
}
|
||||
|
||||
//Fungsi untuk subscribe Topic MQTT sensor
|
||||
void _subscribeToTopics() {
|
||||
_client.subscribe('sensor/tds', MqttQos.atMostOnce);
|
||||
_client.subscribe('sensor/waterflow1', MqttQos.atLeastOnce);
|
||||
_client.subscribe('sensor/waterflow2', MqttQos.atLeastOnce);
|
||||
_client.subscribe('sensor/ultrasonic', MqttQos.atLeastOnce);
|
||||
_client.subscribe(
|
||||
'parameter', MqttQos.atLeastOnce); // Subscribe to parameter topic
|
||||
|
||||
subscription = _client.updates!.listen(
|
||||
(List<MqttReceivedMessage<MqttMessage?>> messages) async {
|
||||
final message = messages[0].payload as MqttPublishMessage;
|
||||
final payload =
|
||||
MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||
print('Received message: $payload from topic: ${messages[0].topic}');
|
||||
|
||||
try {
|
||||
if (messages[0].topic == 'sensor/waterflow1' ||
|
||||
messages[0].topic == 'sensor/waterflow2') {
|
||||
Map<String, dynamic> data = jsonDecode(payload);
|
||||
|
||||
if (data.containsKey('speed_waterflow') &&
|
||||
data['speed_waterflow'] != null &&
|
||||
data.containsKey('total_cairan') &&
|
||||
data['total_cairan'] != null) {
|
||||
double flowRatePerSecond =
|
||||
(data['speed_waterflow'] as num).toDouble();
|
||||
double totalFlow = (data['total_cairan'] as num).toDouble();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (messages[0].topic == 'sensor/waterflow1') {
|
||||
sensorData.waterflow1Value = totalFlow;
|
||||
sensorData.waterflow1speed = flowRatePerSecond;
|
||||
} else if (messages[0].topic == 'sensor/waterflow2') {
|
||||
sensorData.waterflow2Value = totalFlow;
|
||||
sensorData.waterflow2speed = flowRatePerSecond;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Simpan data ke database
|
||||
await saveDataToDatabase(
|
||||
messages[0].topic, totalFlow, flowRatePerSecond);
|
||||
} else {
|
||||
print('Invalid data format in ${messages[0].topic}: $data');
|
||||
}
|
||||
} else if (messages[0].topic == 'parameter') {
|
||||
Map<String, dynamic> data = jsonDecode(payload);
|
||||
|
||||
if (data.containsKey('tdsmin') && data['tdsmin'] != null) {
|
||||
setState(() {
|
||||
tdsmin = (data['tdsmin'] as num).toDouble();
|
||||
});
|
||||
print('Updated tdsmin: $tdsmin');
|
||||
}
|
||||
|
||||
if (data.containsKey('tdsmax') && data['tdsmax'] != null) {
|
||||
setState(() {
|
||||
tdsmax = (data['tdsmax'] as num).toDouble();
|
||||
});
|
||||
print('Updated tdsmax: $tdsmax');
|
||||
}
|
||||
} else {
|
||||
double? value;
|
||||
try {
|
||||
value = double.parse(payload);
|
||||
} catch (e) {
|
||||
print('Error parsing payload: $e');
|
||||
return;
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
switch (messages[0].topic) {
|
||||
case 'sensor/tds':
|
||||
sensorData.tdsValue = value;
|
||||
tdsnow = value;
|
||||
if (tdsnow != null && tdsmax != null && tdsnow! > tdsmax!) {
|
||||
_showNotification(
|
||||
'TDS Alert',
|
||||
'Nilai TDS ($tdsnow) melebihi batas maksimum ($tdsmax). Mohon segera tambahkan air',
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'sensor/ultrasonic':
|
||||
sensorData.ultrasonicValue = value;
|
||||
break;
|
||||
default:
|
||||
print('Unknown topic: ${messages[0].topic}');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Simpan data ke database
|
||||
await saveDataToDatabase(messages[0].topic, value, null);
|
||||
}
|
||||
} catch (e) {
|
||||
print('Exception in _subscribeToTopics: $e');
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showNotification(String title, String body) async {
|
||||
print('Attempting to show notification');
|
||||
|
||||
final Int64List vibrationPattern = Int64List(4);
|
||||
vibrationPattern[0] = 0;
|
||||
vibrationPattern[1] = 1000;
|
||||
vibrationPattern[2] = 5000;
|
||||
vibrationPattern[3] = 2000;
|
||||
|
||||
final AndroidNotificationDetails androidNotificationDetails =
|
||||
AndroidNotificationDetails(
|
||||
'alerts_channel',
|
||||
'Alerts',
|
||||
channelDescription: 'Channel for important alerts',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: 'ticker',
|
||||
vibrationPattern: vibrationPattern,
|
||||
enableVibration: true,
|
||||
enableLights: true,
|
||||
color: const Color.fromARGB(255, 255, 0, 0),
|
||||
ledColor: const Color.fromARGB(255, 255, 0, 0),
|
||||
ledOnMs: 1000,
|
||||
ledOffMs: 500,
|
||||
);
|
||||
|
||||
final NotificationDetails notificationDetails =
|
||||
NotificationDetails(android: androidNotificationDetails);
|
||||
|
||||
try {
|
||||
await flutterLocalNotificationsPlugin.show(
|
||||
0,
|
||||
title,
|
||||
body,
|
||||
notificationDetails,
|
||||
);
|
||||
print('Notification shown successfully');
|
||||
} catch (e) {
|
||||
print('Error showing notification: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveTdsValues(double tdsmin, double tdsmax) async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setDouble('tdsmin', tdsmin);
|
||||
await prefs.setDouble('tdsmax', tdsmax);
|
||||
}
|
||||
|
||||
Future<Map<String, double?>> loadTdsValues() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
double? tdsmin = prefs.getDouble('tdsmin');
|
||||
double? tdsmax = prefs.getDouble('tdsmax');
|
||||
return {'tdsmin': tdsmin, 'tdsmax': tdsmax};
|
||||
}
|
||||
|
||||
// Fungsi untuk menyimpan data ke database
|
||||
Future<void> saveDataToDatabase(
|
||||
String topic, double value, double? speed) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp = prefs.getString('mqtt_server_ip') ?? '192.168.1.100';
|
||||
String url = 'http://$mqttServerIp/test_api/save_msg.php';
|
||||
|
||||
final response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(
|
||||
<String, dynamic>{'topic': topic, 'value': value, 'speed': speed}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print('Data berhasil disimpan ke database');
|
||||
} else {
|
||||
print('Gagal menyimpan data ke database: ${response.body}');
|
||||
}
|
||||
}
|
||||
|
||||
void onTabTapped(int index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> removeAuthToken() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('auth_token');
|
||||
}
|
||||
|
||||
void _logout() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final token = prefs.getString('auth_token');
|
||||
|
||||
if (token != null) {
|
||||
try {
|
||||
await apiService.logout(token);
|
||||
await removeAuthToken();
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||
);
|
||||
} catch (e) {
|
||||
_showErrorDialog('Failed to logout. Please try again');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _showErrorDialog(String message) {
|
||||
TextEditingController _controller = TextEditingController();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Error'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(message),
|
||||
SizedBox(height: 20),
|
||||
Text('Masukkan IP Server:'),
|
||||
TextField(
|
||||
controller: _controller,
|
||||
decoration: InputDecoration(hintText: 'Contoh: 192.168.1.100'),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
String ipServer = _controller.text.trim();
|
||||
if (ipServer.isNotEmpty) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('mqtt_server_ip', ipServer);
|
||||
|
||||
try {
|
||||
_client.disconnect();
|
||||
_initializeClient();
|
||||
} catch (e) {
|
||||
print('Exception: $e');
|
||||
_showErrorDialog('failed to reconnect to MQTT Broker');
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Text('Simpan'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _toggleConnection() async {
|
||||
if (_isConnected) {
|
||||
_client.disconnect();
|
||||
} else {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String ipServer =
|
||||
prefs.getString('mqtt_server_ip') ?? '192.168.65.153'; // Default IP
|
||||
try {
|
||||
await _client.connect(ipServer);
|
||||
} catch (e) {
|
||||
print('Exception: $e');
|
||||
_showErrorDialog('Failed to connect to MQTT broker');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
subscription?.cancel();
|
||||
_client.disconnect();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
['Dashboard', 'Monitoring', 'Control', 'Info'][_currentIndex],
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color.fromARGB(255, 66, 66, 66)),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: FutureBuilder<List<User>>(
|
||||
future: apiService.fetchUsers(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {
|
||||
return Center(child: Text('No data available'));
|
||||
}
|
||||
|
||||
User user = snapshot.data!.first;
|
||||
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
UserAccountsDrawerHeader(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.green, Colors.teal],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
accountName: Text(
|
||||
user.fullname,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 22,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
accountEmail: Text(
|
||||
user.username,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
currentAccountPicture: const CircleAvatar(
|
||||
backgroundImage: AssetImage('images/ahri_icon.jpg'),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout, color: Colors.red),
|
||||
title: Text(
|
||||
'Logout',
|
||||
style: TextStyle(fontSize: 16, color: Colors.red),
|
||||
),
|
||||
onTap: _logout,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: _currentIndex >= 0 && _currentIndex < _children.length
|
||||
? _children[_currentIndex]
|
||||
: Container(),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: onTabTapped,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home_filled),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.monitor),
|
||||
label: 'Monitor',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings),
|
||||
label: 'Control',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.bookmark),
|
||||
label: 'Info',
|
||||
),
|
||||
],
|
||||
type: BottomNavigationBarType.fixed,
|
||||
selectedItemColor: Colors.green,
|
||||
unselectedItemColor: Colors.grey,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: false,
|
||||
selectedLabelStyle: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: _isConnected ? Colors.green : Colors.red,
|
||||
onPressed: _toggleConnection,
|
||||
child: Icon(
|
||||
_isConnected ? Icons.wifi : Icons.wifi_off,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SensorData {
|
||||
double? tdsValue;
|
||||
double? waterflow1Value;
|
||||
double? waterflow1speed;
|
||||
double? waterflow2Value;
|
||||
double? waterflow2speed;
|
||||
double? ultrasonicValue;
|
||||
}
|
|
@ -0,0 +1,391 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:syncfusion_flutter_charts/charts.dart';
|
||||
|
||||
class HomeContent extends StatefulWidget {
|
||||
@override
|
||||
_HomeContentState createState() => _HomeContentState();
|
||||
}
|
||||
|
||||
class _HomeContentState extends State<HomeContent> {
|
||||
bool _showHistory = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_showHistory = false;
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'Charts',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: !_showHistory ? Colors.white : Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
!_showHistory ? Colors.green[800] : Colors.grey[300],
|
||||
elevation: 0,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 500),
|
||||
child: _showHistory ? HistorySection() : ChartsSection(),
|
||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChartsSection extends StatefulWidget {
|
||||
@override
|
||||
_ChartsSectionState createState() => _ChartsSectionState();
|
||||
}
|
||||
|
||||
class _ChartsSectionState extends State<ChartsSection> {
|
||||
List<_ChartData> waterflow1Data = [];
|
||||
List<_ChartData> waterflow2Data = [];
|
||||
List<_ChartData> tdsSensorData = [];
|
||||
List<_ChartData> ultrasonikData = [];
|
||||
bool isLoading = true;
|
||||
String errorMessage = '';
|
||||
|
||||
DateTime startDate = DateTime.now().subtract(const Duration(days: 7));
|
||||
DateTime endDate = DateTime.now();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
fetchChartData();
|
||||
}
|
||||
|
||||
Future<void> fetchChartData() async {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
errorMessage = '';
|
||||
});
|
||||
|
||||
String start = "${startDate.toIso8601String().split('T')[0]} 00:00:00";
|
||||
String end = "${endDate.toIso8601String().split('T')[0]} 23:59:59";
|
||||
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp =
|
||||
prefs.getString('mqtt_server_ip') ?? '192.168.48.153';
|
||||
String url =
|
||||
'http://$mqttServerIp/test_api/data_chart.php?start_date=$start&end_date=$end';
|
||||
|
||||
final response = await http.get(Uri.parse(url));
|
||||
if (response.statusCode == 200) {
|
||||
Map<String, dynamic> responseData = jsonDecode(response.body);
|
||||
List<dynamic> data = responseData['tb_waterflow1'] ?? [];
|
||||
List<dynamic> data1 = responseData['tb_waterflow2'] ?? [];
|
||||
List<dynamic> data2 = responseData['tb_ppm'] ?? [];
|
||||
List<dynamic> data3 = responseData['tb_waterlevel'] ?? [];
|
||||
setState(() {
|
||||
waterflow1Data = data
|
||||
.map((item) =>
|
||||
_ChartData(int.parse(item['x']), double.parse(item['y1'])))
|
||||
.toList();
|
||||
waterflow2Data = data1
|
||||
.map((item) =>
|
||||
_ChartData(int.parse(item['x']), double.parse(item['y2'])))
|
||||
.toList();
|
||||
tdsSensorData = data2
|
||||
.map((item) =>
|
||||
_ChartData(int.parse(item['x']), double.parse(item['y3'])))
|
||||
.toList();
|
||||
ultrasonikData = data3
|
||||
.map((item) =>
|
||||
_ChartData(int.parse(item['x']), double.parse(item['y'])))
|
||||
.toList();
|
||||
isLoading = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
errorMessage = 'Failed to load data';
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
errorMessage = 'Failed to load data: $e';
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _selectDateRange(BuildContext context) async {
|
||||
final DateTimeRange? picked = await showDateRangePicker(
|
||||
context: context,
|
||||
initialDateRange: DateTimeRange(start: startDate, end: endDate),
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
if (picked != null &&
|
||||
picked != DateTimeRange(start: startDate, end: endDate)) {
|
||||
setState(() {
|
||||
startDate = picked.start;
|
||||
endDate = picked.end;
|
||||
fetchChartData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => _selectDateRange(context),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.filter_list, color: Colors.green[800]),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
"Select Date Range",
|
||||
style: TextStyle(
|
||||
color: Colors.green[800],
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (isLoading)
|
||||
Center(child: CircularProgressIndicator())
|
||||
else if (errorMessage.isNotEmpty)
|
||||
Center(child: Text(errorMessage))
|
||||
else ...[
|
||||
buildChartSection(
|
||||
title: 'Waterflow Charts',
|
||||
chart: buildWaterflowChart(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
buildChartSection(
|
||||
title: 'TDS Charts',
|
||||
chart: buildTDSChart(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
buildChartSection(
|
||||
title: 'Ultrasonic Charts',
|
||||
chart: buildUltrasonicChart(),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildChartSection({required String title, required Widget chart}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
height: 300,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey[300]!),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: chart,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildWaterflowChart() {
|
||||
return SfCartesianChart(
|
||||
legend: Legend(isVisible: true, position: LegendPosition.bottom),
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
zoomPanBehavior: ZoomPanBehavior(
|
||||
enablePinching: true,
|
||||
enableDoubleTapZooming: true,
|
||||
enablePanning: true,
|
||||
),
|
||||
primaryXAxis: NumericAxis(
|
||||
majorGridLines: MajorGridLines(width: 0),
|
||||
axisLine: AxisLine(width: 2, color: Colors.grey[700]),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
primaryYAxis: NumericAxis(
|
||||
minimum: 0,
|
||||
maximum: 20,
|
||||
interval: 5,
|
||||
majorGridLines: MajorGridLines(width: 0.5, color: Colors.grey[300]),
|
||||
axisLine: AxisLine(width: 0),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
series: <ChartSeries>[
|
||||
AreaSeries<_ChartData, int>(
|
||||
name: 'Waterflow 1',
|
||||
dataSource: waterflow1Data,
|
||||
xValueMapper: (_ChartData data, _) => data.x,
|
||||
yValueMapper: (_ChartData data, _) => data.y,
|
||||
color: Colors.purple.withOpacity(0.3),
|
||||
borderColor: Colors.purple,
|
||||
borderWidth: 2,
|
||||
),
|
||||
AreaSeries<_ChartData, int>(
|
||||
name: 'Waterflow 2',
|
||||
dataSource: waterflow2Data,
|
||||
xValueMapper: (_ChartData data, _) => data.x,
|
||||
yValueMapper: (_ChartData data, _) => data.y,
|
||||
color: Colors.orange.withOpacity(0.3),
|
||||
borderColor: Colors.orange,
|
||||
borderWidth: 2,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTDSChart() {
|
||||
return SfCartesianChart(
|
||||
legend: Legend(isVisible: true, position: LegendPosition.bottom),
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
zoomPanBehavior: ZoomPanBehavior(
|
||||
enablePinching: true,
|
||||
enableDoubleTapZooming: true,
|
||||
enablePanning: true,
|
||||
),
|
||||
primaryXAxis: NumericAxis(
|
||||
majorGridLines: MajorGridLines(width: 0),
|
||||
axisLine: AxisLine(width: 2, color: Colors.grey[700]),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
primaryYAxis: NumericAxis(
|
||||
minimum: 0,
|
||||
maximum: 1500,
|
||||
interval: 200,
|
||||
majorGridLines: MajorGridLines(width: 0.5, color: Colors.grey[300]),
|
||||
axisLine: AxisLine(width: 0),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
series: <ChartSeries>[
|
||||
AreaSeries<_ChartData, int>(
|
||||
name: 'TDS Sensor',
|
||||
dataSource: tdsSensorData,
|
||||
xValueMapper: (_ChartData data, _) => data.x,
|
||||
yValueMapper: (_ChartData data, _) => data.y,
|
||||
color: Colors.blue.withOpacity(0.3),
|
||||
borderColor: Colors.blue,
|
||||
borderWidth: 2,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildUltrasonicChart() {
|
||||
return SfCartesianChart(
|
||||
legend: Legend(isVisible: true, position: LegendPosition.bottom),
|
||||
tooltipBehavior: TooltipBehavior(enable: true),
|
||||
zoomPanBehavior: ZoomPanBehavior(
|
||||
enablePinching: true,
|
||||
enableDoubleTapZooming: true,
|
||||
enablePanning: true,
|
||||
),
|
||||
primaryXAxis: NumericAxis(
|
||||
majorGridLines: MajorGridLines(width: 0),
|
||||
axisLine: AxisLine(width: 2, color: Colors.grey[700]),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
primaryYAxis: NumericAxis(
|
||||
minimum: 0,
|
||||
maximum: 100,
|
||||
interval: 10,
|
||||
majorGridLines: MajorGridLines(width: 0.5, color: Colors.grey[300]),
|
||||
axisLine: AxisLine(width: 0),
|
||||
labelStyle: TextStyle(color: Colors.grey[700], fontSize: 12),
|
||||
),
|
||||
series: <ChartSeries>[
|
||||
AreaSeries<_ChartData, int>(
|
||||
name: 'Ultrasonic',
|
||||
dataSource: ultrasonikData,
|
||||
xValueMapper: (_ChartData data, _) => data.x,
|
||||
yValueMapper: (_ChartData data, _) => data.y,
|
||||
color: Colors.green.withOpacity(0.3),
|
||||
borderColor: Colors.green,
|
||||
borderWidth: 2,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HistorySection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'History',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
'Feature in development...',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ChartData {
|
||||
final int x;
|
||||
final double y;
|
||||
|
||||
_ChartData(this.x, this.y);
|
||||
}
|
|
@ -0,0 +1,317 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
|
||||
class InfoPage extends StatefulWidget {
|
||||
@override
|
||||
_InfoPageState createState() => _InfoPageState();
|
||||
}
|
||||
|
||||
class _InfoPageState extends State<InfoPage> {
|
||||
TextEditingController _searchController = TextEditingController();
|
||||
List<Map<String, dynamic>> _infoList = [];
|
||||
List<Map<String, dynamic>> _filteredInfoList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchPlants();
|
||||
}
|
||||
|
||||
Future<void> _fetchPlants() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
String mqttServerIp = prefs.getString('mqtt_server_ip') ?? '192.168.1.100';
|
||||
String url = 'http://$mqttServerIp/test_api/data_plant.php';
|
||||
|
||||
try {
|
||||
final response = await http.get(Uri.parse(url));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
List<dynamic> data = jsonDecode(response.body);
|
||||
setState(() {
|
||||
_infoList = data.map((item) => item as Map<String, dynamic>).toList();
|
||||
_filteredInfoList = List<Map<String, dynamic>>.from(_infoList);
|
||||
});
|
||||
} else {
|
||||
print('Gagal mengambil data tanaman: ${response.statusCode}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void _searchInfo(String query) {
|
||||
final filteredList = _infoList.where((info) {
|
||||
final titleLower = info['title']?.toLowerCase() ?? '';
|
||||
final searchLower = query.toLowerCase();
|
||||
return titleLower.contains(searchLower);
|
||||
}).toList();
|
||||
|
||||
setState(() {
|
||||
_filteredInfoList = filteredList;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Container(
|
||||
height: 40,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: _searchInfo,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Cari tanaman...',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 0.0, horizontal: 20.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
itemCount: _filteredInfoList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final info = _filteredInfoList[index];
|
||||
IconData icon;
|
||||
Color color;
|
||||
switch (info['kategori']) {
|
||||
case 'Sayur':
|
||||
icon = Icons.eco;
|
||||
color = Colors.green;
|
||||
break;
|
||||
case 'Bunga':
|
||||
icon = Icons.filter_vintage;
|
||||
color = Colors.red;
|
||||
break;
|
||||
case 'Herb':
|
||||
icon = Icons.emoji_nature;
|
||||
color = Colors.blue;
|
||||
break;
|
||||
default:
|
||||
icon = Icons.category;
|
||||
color = Colors.black;
|
||||
}
|
||||
|
||||
return InfoCard(
|
||||
title: info['title'] ?? 'No Title',
|
||||
icon: icon,
|
||||
color: color,
|
||||
imageUrl: info['img'] ?? 'assets/placeholder.jpg',
|
||||
info: info,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final String imageUrl;
|
||||
final Map<String, dynamic> info;
|
||||
|
||||
const InfoCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.imageUrl,
|
||||
required this.info,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailPage(
|
||||
title: info['title'] ?? 'No Title',
|
||||
description: info['desk'] ?? 'No Description',
|
||||
imageUrl: info['img'] ?? 'assets/placeholder.jpg',
|
||||
category: info['kategori'] ?? 'Unknown',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
elevation: 8,
|
||||
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
height: 200,
|
||||
width: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => Container(
|
||||
color: Colors.grey[300],
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
color: Colors.grey[300],
|
||||
child: Center(child: Icon(Icons.error, color: Colors.red)),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 200,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
Colors.black54,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: color),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailPage extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
final String imageUrl;
|
||||
final String category;
|
||||
|
||||
const DetailPage({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.imageUrl,
|
||||
required this.category,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: imageUrl,
|
||||
placeholder: (context, url) => Container(
|
||||
height: 200,
|
||||
color: Colors.grey[300],
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
errorWidget: (context, url, error) => Container(
|
||||
height: 200,
|
||||
color: Colors.grey[300],
|
||||
child: Center(child: Icon(Icons.error, color: Colors.red)),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
'Category: $category',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
buildDescriptionText(description),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildDescriptionText(String description) {
|
||||
List<String> paragraphs = description.split('\n\n');
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: paragraphs.map((paragraph) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: ' ', // Add indentation (5 spaces) at the start
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.black87,
|
||||
height: 1.5, // Line height
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: paragraph,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.black87,
|
||||
height: 1.5, // Line height
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:beta_app1/widget/monitoring/Ultrasonik.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
import 'package:beta_app1/widget/monitoring/TdsMonitor.dart';
|
||||
import 'package:beta_app1/widget/monitoring/WaterflowMonitoring.dart';
|
||||
|
||||
// Instance global dari SensorData
|
||||
final sensorData = SensorData();
|
||||
|
||||
class SensorMonitoringScreen extends StatefulWidget {
|
||||
final MqttServerClient client;
|
||||
|
||||
SensorMonitoringScreen({required this.client});
|
||||
|
||||
@override
|
||||
_SensorMonitoringScreenState createState() => _SensorMonitoringScreenState();
|
||||
}
|
||||
|
||||
class _SensorMonitoringScreenState extends State<SensorMonitoringScreen> {
|
||||
late StreamSubscription<List<MqttReceivedMessage<MqttMessage?>>>?
|
||||
subscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_subscribeToTopics();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
subscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _subscribeToTopics() {
|
||||
if (widget.client.connectionStatus!.state ==
|
||||
MqttConnectionState.connected) {
|
||||
widget.client.subscribe('sensor/tds', MqttQos.atMostOnce);
|
||||
widget.client.subscribe('sensor/waterflow1', MqttQos.atLeastOnce);
|
||||
widget.client.subscribe('sensor/waterflow2', MqttQos.atLeastOnce);
|
||||
widget.client.subscribe('sensor/ultrasonic', MqttQos.atLeastOnce);
|
||||
|
||||
subscription = widget.client.updates!.listen(
|
||||
(List<MqttReceivedMessage<MqttMessage?>> messages) async {
|
||||
final message = messages[0].payload as MqttPublishMessage;
|
||||
final payload =
|
||||
MqttPublishPayload.bytesToStringAsString(message.payload.message);
|
||||
|
||||
if (messages[0].topic == 'sensor/waterflow1' ||
|
||||
messages[0].topic == 'sensor/waterflow2') {
|
||||
// Parsing JSON payload untuk waterflow1_topic atau waterflow2_topic
|
||||
try {
|
||||
Map<String, dynamic> data = jsonDecode(payload);
|
||||
double? flowRatePerSecond =
|
||||
(data['speed_waterflow'] as num?)?.toDouble();
|
||||
double? totalFlow = (data['total_cairan'] as num?)?.toDouble();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
if (messages[0].topic == 'sensor/waterflow1') {
|
||||
sensorData.waterflow1Value = totalFlow;
|
||||
sensorData.waterflow1speed = flowRatePerSecond;
|
||||
} else if (messages[0].topic == 'sensor/waterflow2') {
|
||||
sensorData.waterflow2Value = totalFlow;
|
||||
sensorData.waterflow2speed = flowRatePerSecond;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error parsing JSON payload for ${messages[0].topic}: $e');
|
||||
}
|
||||
} else {
|
||||
// Parsing string payload untuk topik lainnya
|
||||
try {
|
||||
double? value = double.parse(payload);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
switch (messages[0].topic) {
|
||||
case 'sensor/tds':
|
||||
sensorData.tdsValue = value;
|
||||
break;
|
||||
case 'sensor/ultrasonic':
|
||||
sensorData.ultrasonicValue = value;
|
||||
break;
|
||||
default:
|
||||
print('Unknown topic: ${messages[0].topic}');
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print(
|
||||
'Error parsing string payload for ${messages[0].topic}: $e');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
print('MQTT Client is not connected');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: 0,
|
||||
titleSpacing: 0,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TDSMonitor(value: sensorData.tdsValue ?? 0.0),
|
||||
SizedBox(height: 16.0),
|
||||
WaterflowMonitor(
|
||||
waterflow1Value: sensorData.waterflow1Value ?? 0.0,
|
||||
waterflow2Value: sensorData.waterflow2Value ?? 0.0,
|
||||
waterflow1Speed: sensorData.waterflow1speed ?? 0.0,
|
||||
waterflow2Speed: sensorData.waterflow2speed ?? 0.0,
|
||||
),
|
||||
SizedBox(height: 16.0),
|
||||
UltrasonicMonitor(
|
||||
ultrasonicValue: sensorData.ultrasonicValue ?? 0.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SensorData {
|
||||
double? tdsValue;
|
||||
double? waterflow1Value;
|
||||
double? waterflow2Value;
|
||||
double? ultrasonicValue;
|
||||
double? waterflow1speed;
|
||||
double? waterflow2speed;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
@override
|
||||
_SplashScreenState createState() => _SplashScreenState();
|
||||
}
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkAuthToken();
|
||||
}
|
||||
|
||||
_checkAuthToken() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? authToken = prefs.getString('auth_token');
|
||||
|
||||
await Future.delayed(
|
||||
Duration(milliseconds: 3000), () {}); // Durasi splash screen
|
||||
|
||||
if (authToken != null) {
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
} else {
|
||||
Navigator.pushReplacementNamed(context, '/login');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor:
|
||||
Colors.white, // Ubah sesuai warna latar belakang yang diinginkan
|
||||
body: Center(
|
||||
child: Image.asset('images/nature.gif',
|
||||
width: 200,
|
||||
height:
|
||||
200), // Pastikan untuk menambahkan logo Anda di folder assets
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
class Config {
|
||||
static const String manualControlTopic = 'control';
|
||||
static const String autoControlTopic = 'control/auto';
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
|
||||
class BusinessLogic {
|
||||
static Future<SharedPreferences> loadPreferences() async {
|
||||
return await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
static Future<void> savePreferences(Map<String, bool> prefs) async {
|
||||
final SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
||||
prefs.forEach((key, value) async {
|
||||
await sharedPrefs.setBool(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
static void publishMessage(
|
||||
MqttServerClient client, String topic, String message) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString(message);
|
||||
client.publishMessage(topic, MqttQos.atLeastOnce, builder.payload!);
|
||||
}
|
||||
|
||||
static Future<void> saveTDSValues(double initialTDS, double finalTDS) async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setDouble('initialTDS', initialTDS);
|
||||
await prefs.setDouble('finalTDS', finalTDS);
|
||||
}
|
||||
|
||||
static Future<Map<String, double>> getTDSValues() async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
final initialTDS = prefs.getDouble('initialTDS') ?? 0.0;
|
||||
final finalTDS = prefs.getDouble('finalTDS') ?? 0.0;
|
||||
return {
|
||||
'initialTDS': initialTDS,
|
||||
'finalTDS': finalTDS,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,379 @@
|
|||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
|
||||
class SwitchTileWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const SwitchTileWidget({
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
required IconData icon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 16.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: value,
|
||||
onChanged: onChanged,
|
||||
activeColor: Colors.green,
|
||||
inactiveThumbColor: Colors.white,
|
||||
inactiveTrackColor: Colors.grey,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ModeSwitch extends StatelessWidget {
|
||||
final bool isManualMode;
|
||||
final ValueChanged<bool> onModeChanged;
|
||||
|
||||
const ModeSwitch({
|
||||
required this.isManualMode,
|
||||
required this.onModeChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
onModeChanged(true);
|
||||
},
|
||||
child: Text(
|
||||
'Mode Manual',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isManualMode ? Colors.white : Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isManualMode ? Colors.green[800] : Colors.grey[300],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
onModeChanged(false);
|
||||
},
|
||||
child: Text(
|
||||
'Mode Otomatis',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isManualMode ? Colors.black : Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
isManualMode ? Colors.grey[300] : Colors.green[800],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CalibrationDialog extends StatefulWidget {
|
||||
final double initialTDS;
|
||||
final double finalTDS;
|
||||
final Function(double, double) onSave;
|
||||
final MqttServerClient mqttClient;
|
||||
|
||||
CalibrationDialog({
|
||||
required this.initialTDS,
|
||||
required this.finalTDS,
|
||||
required this.onSave,
|
||||
required this.mqttClient,
|
||||
});
|
||||
|
||||
@override
|
||||
_CalibrationDialogState createState() => _CalibrationDialogState();
|
||||
}
|
||||
|
||||
class _CalibrationDialogState extends State<CalibrationDialog> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late TextEditingController initialTDSController;
|
||||
late TextEditingController finalTDSController;
|
||||
late MqttServerClient mqttClient;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
initialTDSController = TextEditingController(
|
||||
text: widget.initialTDS.toString(),
|
||||
);
|
||||
finalTDSController = TextEditingController(
|
||||
text: widget.finalTDS.toString(),
|
||||
);
|
||||
mqttClient = widget.mqttClient;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: contentBox(context),
|
||||
);
|
||||
}
|
||||
|
||||
contentBox(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black,
|
||||
offset: Offset(0, 10),
|
||||
blurRadius: 10,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Kalibrasi Parameter',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: initialTDSController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'TDS min',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Masukkan TDS minimal';
|
||||
}
|
||||
double? initialTDS = double.tryParse(value);
|
||||
double? finalTDS =
|
||||
double.tryParse(finalTDSController.text);
|
||||
if (initialTDS == null) {
|
||||
return 'Masukkan angka yang valid';
|
||||
}
|
||||
if (finalTDS != null && initialTDS > finalTDS) {
|
||||
return 'TDS min tidak boleh lebih besar dari TDS max';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
controller: finalTDSController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'TDS max',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Masukkan TDS maximum';
|
||||
}
|
||||
double? finalTDS = double.tryParse(value);
|
||||
double? initialTDS =
|
||||
double.tryParse(initialTDSController.text);
|
||||
if (finalTDS == null) {
|
||||
return 'Masukkan angka yang valid';
|
||||
}
|
||||
if (initialTDS != null && finalTDS < initialTDS) {
|
||||
return 'TDS max tidak boleh lebih kecil dari TDS min';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final initialTDS =
|
||||
double.parse(initialTDSController.text);
|
||||
final finalTDS = double.parse(finalTDSController.text);
|
||||
|
||||
sendToMQTT(initialTDS, finalTDS);
|
||||
|
||||
widget.onSave(initialTDS, finalTDS);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Text('Simpan'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void sendToMQTT(double initialTDS, double finalTDS) {
|
||||
final payload = jsonEncode({"tdsmin": initialTDS, "tdsmax": finalTDS});
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString(payload);
|
||||
mqttClient.publishMessage(
|
||||
'parameter', MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
class ControlButton extends StatelessWidget {
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final bool isActive;
|
||||
final VoidCallback onPressed;
|
||||
final IconData activeIcon;
|
||||
final IconData inactiveIcon;
|
||||
|
||||
const ControlButton({
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.isActive,
|
||||
required this.onPressed,
|
||||
required this.activeIcon,
|
||||
required this.inactiveIcon,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(bottom: 16.0),
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[900],
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: isActive
|
||||
? Colors.green.withOpacity(0.3)
|
||||
: Colors.red.withOpacity(0.3),
|
||||
blurRadius: 10,
|
||||
spreadRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? Colors.green : Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
isActive ? activeIcon : inactiveIcon,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: isActive,
|
||||
onChanged: (_) => onPressed(),
|
||||
activeColor: Colors.green,
|
||||
inactiveThumbColor: Colors.red,
|
||||
inactiveTrackColor: Colors.red.withOpacity(0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
class InfoPage extends StatefulWidget {
|
||||
@override
|
||||
_InfoPageState createState() => _InfoPageState();
|
||||
}
|
||||
|
||||
class _InfoPageState extends State<InfoPage> {
|
||||
TextEditingController _searchController = TextEditingController();
|
||||
List<dynamic> _infoList = []; // Gunakan dynamic untuk data dinamis
|
||||
List<dynamic> _filteredInfoList = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchInfoFromApi();
|
||||
}
|
||||
|
||||
Future<void> _fetchInfoFromApi() async {
|
||||
final url = Uri.parse(
|
||||
'http://your_api_endpoint/plants'); // Ganti dengan endpoint API Anda
|
||||
final response = await http.get(url);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
// Jika koneksi berhasil
|
||||
setState(() {
|
||||
_infoList = jsonDecode(response.body);
|
||||
_filteredInfoList = _infoList;
|
||||
});
|
||||
} else {
|
||||
// Jika terjadi kesalahan koneksi
|
||||
print('Failed to load data: ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
void _searchInfo(String query) {
|
||||
final filteredList = _infoList.where((info) {
|
||||
final titleLower = info['title']?.toLowerCase() ?? '';
|
||||
final descriptionLower = info['description']?.toLowerCase() ?? '';
|
||||
final searchLower = query.toLowerCase();
|
||||
|
||||
return titleLower.contains(searchLower) ||
|
||||
descriptionLower.contains(searchLower);
|
||||
}).toList();
|
||||
|
||||
setState(() {
|
||||
_filteredInfoList = filteredList;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Container(
|
||||
height: 40,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: _searchInfo,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Cari tanaman...',
|
||||
prefixIcon: Icon(Icons.search),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 0.0, horizontal: 20.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: ListView.builder(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
itemCount: _filteredInfoList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final info = _filteredInfoList[index];
|
||||
|
||||
// Customize sesuai data API Anda
|
||||
IconData icon;
|
||||
Color color;
|
||||
switch (info['category']) {
|
||||
case 'Sayur':
|
||||
icon = Icons.eco;
|
||||
color = Colors.green;
|
||||
break;
|
||||
case 'Bunga':
|
||||
icon = Icons.filter_vintage;
|
||||
color = Colors.red;
|
||||
break;
|
||||
case 'Herb':
|
||||
icon = Icons.emoji_nature;
|
||||
color = Colors.blue;
|
||||
break;
|
||||
default:
|
||||
icon = Icons.category;
|
||||
color = Colors.black;
|
||||
}
|
||||
|
||||
return InfoCard(
|
||||
title: info['title'] ?? 'No Title',
|
||||
description: info['description'] ?? 'No Description',
|
||||
icon: icon,
|
||||
color: color,
|
||||
image: info['image'] ?? 'assets/placeholder.jpg',
|
||||
info: info,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final String image;
|
||||
final dynamic info;
|
||||
|
||||
const InfoCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
required this.image,
|
||||
required this.info,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DetailPage(
|
||||
title: info['title'] ?? 'No Title',
|
||||
description: info['description'] ?? 'No Description',
|
||||
image: info['image'] ?? 'assets/placeholder.jpg',
|
||||
category: info['category'] ?? 'Unknown',
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
),
|
||||
elevation: 8,
|
||||
margin: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: color,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailPage extends StatelessWidget {
|
||||
final String title;
|
||||
final String description;
|
||||
final String image;
|
||||
final String category;
|
||||
|
||||
const DetailPage({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.image,
|
||||
required this.category,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(image),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
'Category: $category',
|
||||
style: TextStyle(fontSize: 16, fontStyle: FontStyle.italic),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
description,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_gauges/gauges.dart';
|
||||
|
||||
class TDSMonitor extends StatefulWidget {
|
||||
final double value;
|
||||
|
||||
TDSMonitor({required this.value});
|
||||
|
||||
@override
|
||||
_TDSMonitorState createState() => _TDSMonitorState();
|
||||
}
|
||||
|
||||
class _TDSMonitorState extends State<TDSMonitor>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
bool _showGauge = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
vsync: this,
|
||||
);
|
||||
_animation = Tween<double>(begin: 0, end: widget.value).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
);
|
||||
_controller.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant TDSMonitor oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.value != oldWidget.value) {
|
||||
_animation = Tween<double>(begin: oldWidget.value, end: widget.value)
|
||||
.animate(CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: Curves.easeInOut,
|
||||
));
|
||||
_controller.reset();
|
||||
_controller.forward();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String getWaterQuality(double tds) {
|
||||
if (tds < 300) return 'Excellent';
|
||||
if (tds < 600) return 'Good';
|
||||
if (tds < 900) return 'Fair';
|
||||
if (tds < 1200) return 'Poor';
|
||||
return 'Unacceptable';
|
||||
}
|
||||
|
||||
Color getQualityColor(double tds) {
|
||||
if (tds < 300) return Colors.blue;
|
||||
if (tds < 600) return Colors.green;
|
||||
if (tds < 900) return Colors.yellow;
|
||||
if (tds < 1200) return Colors.orange;
|
||||
return Colors.red;
|
||||
}
|
||||
|
||||
Widget _buildGauge(double value) {
|
||||
return SfRadialGauge(
|
||||
axes: <RadialAxis>[
|
||||
RadialAxis(
|
||||
minimum: 0,
|
||||
maximum: 1500,
|
||||
startAngle: 150,
|
||||
endAngle: 30,
|
||||
interval: 300,
|
||||
labelFormat: '{value}',
|
||||
axisLineStyle: AxisLineStyle(
|
||||
thickness: 0.2,
|
||||
thicknessUnit: GaugeSizeUnit.factor,
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
),
|
||||
majorTickStyle: MajorTickStyle(length: 6, thickness: 2),
|
||||
minorTickStyle: MinorTickStyle(length: 3, thickness: 1),
|
||||
axisLabelStyle: GaugeTextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
pointers: <GaugePointer>[
|
||||
RangePointer(
|
||||
value: value,
|
||||
width: 0.2,
|
||||
sizeUnit: GaugeSizeUnit.factor,
|
||||
gradient: SweepGradient(
|
||||
colors: [Colors.green, getQualityColor(value)],
|
||||
stops: [0.0, 1.0],
|
||||
),
|
||||
cornerStyle: CornerStyle.bothCurve,
|
||||
),
|
||||
MarkerPointer(
|
||||
value: value,
|
||||
markerType: MarkerType.triangle,
|
||||
color: Colors.white,
|
||||
markerHeight: 15,
|
||||
markerWidth: 15,
|
||||
markerOffset: -7,
|
||||
),
|
||||
],
|
||||
annotations: <GaugeAnnotation>[
|
||||
GaugeAnnotation(
|
||||
widget: Text(
|
||||
'${value.toStringAsFixed(0)} PPM',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: getQualityColor(value),
|
||||
),
|
||||
),
|
||||
positionFactor: 0.1,
|
||||
angle: 90,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSimpleDisplay(double value) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'${value.toStringAsFixed(0)}',
|
||||
style: TextStyle(
|
||||
fontSize: 48,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: getQualityColor(value),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
getWaterQuality(value),
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: getQualityColor(value),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showGauge = !_showGauge;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.3),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.science,
|
||||
size: 30,
|
||||
color: Colors.blue,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'TDS Monitor',
|
||||
style: TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 24.0),
|
||||
AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return AnimatedCrossFade(
|
||||
duration: Duration(milliseconds: 300),
|
||||
firstChild: Container(
|
||||
height: 250,
|
||||
width: 250,
|
||||
child: _buildGauge(_animation.value),
|
||||
),
|
||||
secondChild: Container(
|
||||
height: 250,
|
||||
width: 250,
|
||||
child: Center(
|
||||
child: _buildSimpleDisplay(_animation.value),
|
||||
),
|
||||
),
|
||||
crossFadeState: _showGauge
|
||||
? CrossFadeState.showFirst
|
||||
: CrossFadeState.showSecond,
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Tap to toggle view',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:liquid_progress_indicator_v2/liquid_progress_indicator.dart';
|
||||
|
||||
class UltrasonicMonitor extends StatelessWidget {
|
||||
final double ultrasonicValue;
|
||||
|
||||
const UltrasonicMonitor({required this.ultrasonicValue, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double percentage = calculatePercentage(ultrasonicValue);
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Water Level Monitor',
|
||||
style: TextStyle(
|
||||
fontSize: 28.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue[800],
|
||||
shadows: [
|
||||
Shadow(
|
||||
blurRadius: 10.0,
|
||||
color: Colors.blue.withOpacity(0.3),
|
||||
offset: Offset(2.0, 2.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 180,
|
||||
width: 300,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
child: LiquidLinearProgressIndicator(
|
||||
value: percentage / 100,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.blue.withOpacity(0.7),
|
||||
),
|
||||
backgroundColor: Colors.blue[50],
|
||||
borderRadius: 30,
|
||||
direction: Axis.vertical,
|
||||
center: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.water_drop,
|
||||
color: Colors.white,
|
||||
size: 40,
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
'${ultrasonicValue.toStringAsFixed(1)} cm',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 10,
|
||||
right: 10,
|
||||
bottom: 190,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: List.generate(
|
||||
8,
|
||||
(index) => Expanded(
|
||||
child: Text(
|
||||
'${(35 - index * 5).toString()} cm',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.blue[800],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.blue.withOpacity(0.1),
|
||||
spreadRadius: 3,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
'Water Level: ${percentage.toStringAsFixed(1)}%',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue[800],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
double calculatePercentage(double distance) {
|
||||
if (distance <= 2) {
|
||||
return 100;
|
||||
} else if (distance >= 35) {
|
||||
return 0;
|
||||
} else {
|
||||
return 100 - ((distance - 2) / (35 - 2)) * 100;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class WaterflowMonitor extends StatelessWidget {
|
||||
final double waterflow1Value;
|
||||
final double waterflow2Value;
|
||||
final double waterflow1Speed;
|
||||
final double waterflow2Speed;
|
||||
|
||||
WaterflowMonitor({
|
||||
required this.waterflow1Value,
|
||||
required this.waterflow2Value,
|
||||
required this.waterflow1Speed,
|
||||
required this.waterflow2Speed,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.water_drop,
|
||||
color: Colors.blueAccent,
|
||||
size: 24,
|
||||
),
|
||||
SizedBox(width: 8.0),
|
||||
Text(
|
||||
'Waterflow 1',
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blueAccent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
LinearProgressIndicator(
|
||||
value: waterflow1Value / 500,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
|
||||
backgroundColor: Colors.blue[100],
|
||||
),
|
||||
SizedBox(height: 4.0),
|
||||
Text(
|
||||
'${waterflow1Value.toStringAsFixed(1)} mL',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
'Speed: ${waterflow1Speed.toStringAsFixed(1)} mL/s',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16.0),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.water_drop,
|
||||
color: Colors.orangeAccent,
|
||||
size: 24,
|
||||
),
|
||||
SizedBox(width: 8.0),
|
||||
Text(
|
||||
'Waterflow 2',
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.orangeAccent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
LinearProgressIndicator(
|
||||
value: waterflow2Value / 500,
|
||||
valueColor:
|
||||
AlwaysStoppedAnimation<Color>(Colors.orangeAccent),
|
||||
backgroundColor: Colors.orange[100],
|
||||
),
|
||||
SizedBox(height: 4.0),
|
||||
Text(
|
||||
'${waterflow2Value.toStringAsFixed(1)} mL',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0),
|
||||
Text(
|
||||
'Speed: ${waterflow2Speed.toStringAsFixed(1)} mL/s',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
flutter/ephemeral
|
|
@ -0,0 +1,145 @@
|
|||
# Project-level configuration.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(runner LANGUAGES CXX)
|
||||
|
||||
# The name of the executable created for the application. Change this to change
|
||||
# the on-disk name of your application.
|
||||
set(BINARY_NAME "beta_app1")
|
||||
# The unique GTK application identifier for this application. See:
|
||||
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
||||
set(APPLICATION_ID "com.example.beta_app1")
|
||||
|
||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||
# versions of CMake.
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
|
||||
# Load bundled libraries from the lib/ directory relative to the binary.
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||
|
||||
# Root filesystem for cross-building.
|
||||
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
||||
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endif()
|
||||
|
||||
# Define build configuration options.
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||
STRING "Flutter build mode" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Profile" "Release")
|
||||
endif()
|
||||
|
||||
# Compilation settings that should be applied to most targets.
|
||||
#
|
||||
# Be cautious about adding new options here, as plugins use this function by
|
||||
# default. In most cases, you should add new options to specific targets instead
|
||||
# of modifying this function.
|
||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||
endfunction()
|
||||
|
||||
# Flutter library and tool build rules.
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
|
||||
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
|
||||
|
||||
# Define the application target. To change its name, change BINARY_NAME above,
|
||||
# not the value here, or `flutter run` will no longer work.
|
||||
#
|
||||
# Any new source files that you add to the application should be added here.
|
||||
add_executable(${BINARY_NAME}
|
||||
"main.cc"
|
||||
"my_application.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
|
||||
# Apply the standard set of build settings. This can be removed for applications
|
||||
# that need different build settings.
|
||||
apply_standard_settings(${BINARY_NAME})
|
||||
|
||||
# Add dependency libraries. Add any application-specific dependencies here.
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||
|
||||
# Run the Flutter tool portions of the build. This must not be removed.
|
||||
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||
|
||||
# Only the install-generated bundle's copy of the executable will launch
|
||||
# correctly, since the resources must in the right relative locations. To avoid
|
||||
# people trying to run the unbundled copy, put it in a subdirectory instead of
|
||||
# the default top-level location.
|
||||
set_target_properties(${BINARY_NAME}
|
||||
PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
|
||||
)
|
||||
|
||||
|
||||
# Generated plugin build rules, which manage building the plugins and adding
|
||||
# them to the application.
|
||||
include(flutter/generated_plugins.cmake)
|
||||
|
||||
|
||||
# === Installation ===
|
||||
# By default, "installing" just makes a relocatable bundle in the build
|
||||
# directory.
|
||||
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
|
||||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||
endif()
|
||||
|
||||
# Start with a clean build bundle directory every time.
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
|
||||
" COMPONENT Runtime)
|
||||
|
||||
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
|
||||
install(FILES "${bundled_library}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endforeach(bundled_library)
|
||||
|
||||
# Copy the native assets provided by the build.dart from all packages.
|
||||
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
|
||||
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
|
||||
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||
# from a previous install.
|
||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||
install(CODE "
|
||||
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||
" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||
|
||||
# Install the AOT library on non-Debug builds only.
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
endif()
|
|
@ -0,0 +1,88 @@
|
|||
# This file controls Flutter-level build steps. It should not be edited.
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
|
||||
|
||||
# Configuration provided via flutter tool.
|
||||
include(${EPHEMERAL_DIR}/generated_config.cmake)
|
||||
|
||||
# TODO: Move the rest of this into files in ephemeral. See
|
||||
# https://github.com/flutter/flutter/issues/57146.
|
||||
|
||||
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
|
||||
# which isn't available in 3.10.
|
||||
function(list_prepend LIST_NAME PREFIX)
|
||||
set(NEW_LIST "")
|
||||
foreach(element ${${LIST_NAME}})
|
||||
list(APPEND NEW_LIST "${PREFIX}${element}")
|
||||
endforeach(element)
|
||||
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# === Flutter Library ===
|
||||
# System-level dependencies.
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||
|
||||
# Published to parent scope for install step.
|
||||
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
|
||||
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
|
||||
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
|
||||
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
|
||||
|
||||
list(APPEND FLUTTER_LIBRARY_HEADERS
|
||||
"fl_basic_message_channel.h"
|
||||
"fl_binary_codec.h"
|
||||
"fl_binary_messenger.h"
|
||||
"fl_dart_project.h"
|
||||
"fl_engine.h"
|
||||
"fl_json_message_codec.h"
|
||||
"fl_json_method_codec.h"
|
||||
"fl_message_codec.h"
|
||||
"fl_method_call.h"
|
||||
"fl_method_channel.h"
|
||||
"fl_method_codec.h"
|
||||
"fl_method_response.h"
|
||||
"fl_plugin_registrar.h"
|
||||
"fl_plugin_registry.h"
|
||||
"fl_standard_message_codec.h"
|
||||
"fl_standard_method_codec.h"
|
||||
"fl_string_codec.h"
|
||||
"fl_value.h"
|
||||
"fl_view.h"
|
||||
"flutter_linux.h"
|
||||
)
|
||||
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
|
||||
add_library(flutter INTERFACE)
|
||||
target_include_directories(flutter INTERFACE
|
||||
"${EPHEMERAL_DIR}"
|
||||
)
|
||||
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
|
||||
target_link_libraries(flutter INTERFACE
|
||||
PkgConfig::GTK
|
||||
PkgConfig::GLIB
|
||||
PkgConfig::GIO
|
||||
)
|
||||
add_dependencies(flutter flutter_assemble)
|
||||
|
||||
# === Flutter tool backend ===
|
||||
# _phony_ is a non-existent file to force this command to run every time,
|
||||
# since currently there's no way to get a full input/output list from the
|
||||
# flutter tool.
|
||||
add_custom_command(
|
||||
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_phony_
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
${FLUTTER_TOOL_ENVIRONMENT}
|
||||
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
|
||||
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(flutter_assemble DEPENDS
|
||||
"${FLUTTER_LIBRARY}"
|
||||
${FLUTTER_LIBRARY_HEADERS}
|
||||
)
|
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Generated file. Do not edit.
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
|
||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||
#define GENERATED_PLUGIN_REGISTRANT_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Registers Flutter plugins.
|
||||
void fl_register_plugins(FlPluginRegistry* registry);
|
||||
|
||||
#endif // GENERATED_PLUGIN_REGISTRANT_
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# Generated file, do not edit.
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||
endforeach(plugin)
|
||||
|
||||
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
|
||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||
endforeach(ffi_plugin)
|
|
@ -0,0 +1,6 @@
|
|||
#include "my_application.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
g_autoptr(MyApplication) app = my_application_new();
|
||||
return g_application_run(G_APPLICATION(app), argc, argv);
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
struct _MyApplication {
|
||||
GtkApplication parent_instance;
|
||||
char** dart_entrypoint_arguments;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
GtkWindow* window =
|
||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
if (GDK_IS_X11_SCREEN(screen)) {
|
||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||
use_header_bar = FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "beta_app1");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "beta_app1");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
gtk_widget_show(GTK_WIDGET(window));
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
// Implements GApplication::local_command_line.
|
||||
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
// Strip out the first argument as it is the binary name.
|
||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!g_application_register(application, nullptr, &error)) {
|
||||
g_warning("Failed to register: %s", error->message);
|
||||
*exit_status = 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_application_activate(application);
|
||||
*exit_status = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GApplication::startup.
|
||||
static void my_application_startup(GApplication* application) {
|
||||
//MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application startup.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
|
||||
}
|
||||
|
||||
// Implements GApplication::shutdown.
|
||||
static void my_application_shutdown(GApplication* application) {
|
||||
//MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application shutdown.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
|
||||
}
|
||||
|
||||
// Implements GObject::dispose.
|
||||
static void my_application_dispose(GObject* object) {
|
||||
MyApplication* self = MY_APPLICATION(object);
|
||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void my_application_class_init(MyApplicationClass* klass) {
|
||||
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
|
||||
G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
|
||||
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
|
||||
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
|
||||
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
|
||||
}
|
||||
|
||||
static void my_application_init(MyApplication* self) {}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
"application-id", APPLICATION_ID,
|
||||
"flags", G_APPLICATION_NON_UNIQUE,
|
||||
nullptr));
|
||||
}
|