commit 5d7d233d2ecb4b9ac8225c3d5d904d388c7751db Author: zhutao <1812073942@qq.com> Date: Thu Aug 28 16:27:56 2025 +0800 基本完成 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79c113f --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +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 diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..652684f --- /dev/null +++ b/.metadata @@ -0,0 +1,33 @@ +# 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: "077b4a4ce10a07b82caa6897f0c626f9c0a3ac90" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + base_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + - platform: android + create_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + base_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + - platform: ios + create_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + base_revision: 077b4a4ce10a07b82caa6897f0c626f9c0a3ac90 + + # 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' diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd17729 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# food_health + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..88942d3 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,30 @@ +# 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 +formatter: + trailing_commas: preserve \ No newline at end of file diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..be3943c --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..cff86a5 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.curainhealth.food" + compileSdk = flutter.compileSdkVersion + ndkVersion = "27.0.12077973" + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.curainhealth.food" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + 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.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..4d95910 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..280ea9f --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/xx/x/food_health/MainActivity.kt b/android/app/src/main/kotlin/com/xx/x/food_health/MainActivity.kt new file mode 100644 index 0000000..d077f79 --- /dev/null +++ b/android/app/src/main/kotlin/com/xx/x/food_health/MainActivity.kt @@ -0,0 +1,5 @@ +package com.curainhealth.food + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..c03a191 --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..0db4a83 --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..28ba998 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-ldpi/ic_launcher.png b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png new file mode 100644 index 0000000..9fe67fe Binary files /dev/null and b/android/app/src/main/res/mipmap-ldpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..97d65b6 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..7124ac1 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b19b6fc Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..ed20afb Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..4d95910 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..89176ef --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,21 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..f018a61 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1ca3856 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.12-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..ab39a10 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + val flutterSdkPath = run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$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 "8.7.3" apply false + id("org.jetbrains.kotlin.android") version "2.1.0" apply false +} + +include(":app") diff --git a/assets/image/apple.png b/assets/image/apple.png new file mode 100644 index 0000000..26bec26 Binary files /dev/null and b/assets/image/apple.png differ diff --git a/assets/image/bg_hushi.png b/assets/image/bg_hushi.png new file mode 100644 index 0000000..144c66c Binary files /dev/null and b/assets/image/bg_hushi.png differ diff --git a/assets/image/empty_data.png b/assets/image/empty_data.png new file mode 100644 index 0000000..3d3f30a Binary files /dev/null and b/assets/image/empty_data.png differ diff --git a/assets/image/google.png b/assets/image/google.png new file mode 100644 index 0000000..4f94d6d Binary files /dev/null and b/assets/image/google.png differ diff --git a/assets/image/logo.png b/assets/image/logo.png new file mode 100644 index 0000000..1df5e32 Binary files /dev/null and b/assets/image/logo.png differ diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..fa0b357 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/ios/.gitignore @@ -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 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..7c56964 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..958851f --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -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 = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 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 = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* 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 = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 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 = ""; + }; +/* 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 = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* 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.curainhealth.food; + 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.curainhealth.food.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.curainhealth.food.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.curainhealth.food.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.curainhealth.food; + 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.curainhealth.food; + 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 */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..e3773d4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..6266644 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@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) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..aebd912 --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,120 @@ +{ + "images": [ + { + "size": "20x20", + "idiom": "universal", + "filename": "icon-20@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "20x20", + "idiom": "universal", + "filename": "icon-20@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "29x29", + "idiom": "universal", + "filename": "icon-29@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "29x29", + "idiom": "universal", + "filename": "icon-29@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "38x38", + "idiom": "universal", + "filename": "icon-38@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "38x38", + "idiom": "universal", + "filename": "icon-38@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "40x40", + "idiom": "universal", + "filename": "icon-40@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "40x40", + "idiom": "universal", + "filename": "icon-40@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "60x60", + "idiom": "universal", + "filename": "icon-60@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "60x60", + "idiom": "universal", + "filename": "icon-60@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "64x64", + "idiom": "universal", + "filename": "icon-64@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "64x64", + "idiom": "universal", + "filename": "icon-64@3x.png", + "scale": "3x", + "platform": "ios" + }, + { + "size": "68x68", + "idiom": "universal", + "filename": "icon-68@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "76x76", + "idiom": "universal", + "filename": "icon-76@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "83.5x83.5", + "idiom": "universal", + "filename": "icon-83.5@2x.png", + "scale": "2x", + "platform": "ios" + }, + { + "size": "1024x1024", + "idiom": "universal", + "filename": "icon-1024.png", + "scale": "1x", + "platform": "ios" + } + ], + "info": { + "version": 1, + "author": "icon.wuruihong.com" + } +} \ No newline at end of file diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-1024.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-1024.png new file mode 100644 index 0000000..55f3c7e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-1024.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png new file mode 100644 index 0000000..26c8f69 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png new file mode 100644 index 0000000..3dc2e87 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png new file mode 100644 index 0000000..bac1346 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png new file mode 100644 index 0000000..3d34983 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@2x.png new file mode 100644 index 0000000..f403311 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@3x.png new file mode 100644 index 0000000..2ffc817 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-38@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png new file mode 100644 index 0000000..f2f3cce Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png new file mode 100644 index 0000000..02e2c08 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png new file mode 100644 index 0000000..02e2c08 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png new file mode 100644 index 0000000..8820ee4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@2x.png new file mode 100644 index 0000000..07c8fe8 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@3x.png new file mode 100644 index 0000000..ba25f33 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-64@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-68@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-68@2x.png new file mode 100644 index 0000000..673f2c0 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-68@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png new file mode 100644 index 0000000..9a69c4a Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png new file mode 100644 index 0000000..31f0754 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..781d7cd --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -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" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..9236d03 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,8 @@ +# 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. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..1ac095f --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Demacare + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + derma_flutter + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + + NSPhotoLibraryUsageDescription + We need access to your photo library so you can upload photos for skin analysis. + + + NSCameraUsageDescription + We need access to your camera so you can take photos for skin analysis. + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + CFBundleURLTypes + + + CFBundleURLSchemes + + com.googleusercontent.apps.512878764950-u703jdn6imu33rthp94dg7cl5vmrc7rf + + + + + + diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -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. + } + +} diff --git a/lib/api/dto/base_dto.dart b/lib/api/dto/base_dto.dart new file mode 100644 index 0000000..4fc7555 --- /dev/null +++ b/lib/api/dto/base_dto.dart @@ -0,0 +1,15 @@ +class ApiDto { + final int code; + final String message; + final T data; + + ApiDto({required this.code, required this.message, required this.data}); + + factory ApiDto.fromJson(Map json) { + return ApiDto( + code: json['code'], + message: json['message'], + data: json['data'], + ); + } +} diff --git a/lib/api/dto/food_scan_dto.dart b/lib/api/dto/food_scan_dto.dart new file mode 100644 index 0000000..2ea82c1 --- /dev/null +++ b/lib/api/dto/food_scan_dto.dart @@ -0,0 +1,49 @@ +class FoodScanDto { + int? id; + String? foodName; + String? foodDesc; + List? ingredientsList; + String? explanation; + String? suggestions; + List? healthConcernsList; + int? foodType; + String? imageUrl; + + FoodScanDto({ + this.id, + this.foodName, + this.foodDesc, + this.ingredientsList, + this.explanation, + this.suggestions, + this.healthConcernsList, + this.foodType, + this.imageUrl, + }); + + Map toJson() { + final map = {}; + map["id"] = id; + map["food_name"] = foodName; + map["food_desc"] = foodDesc; + map["ingredients"] = ingredientsList; + map["explanation"] = explanation; + map["suggestions"] = suggestions; + map["health_concerns"] = healthConcernsList; + map["food_type"] = foodType; + map["image_url"] = imageUrl; + return map; + } + + FoodScanDto.fromJson(dynamic json) { + id = json["id"] ?? 0; + foodName = json["food_name"] ?? ""; + foodDesc = json["food_desc"] ?? ""; + ingredientsList = json["ingredients"] != null ? json["ingredients"].cast() : []; + explanation = json["explanation"] ?? ""; + suggestions = json["suggestions"] ?? ""; + healthConcernsList = json["health_concerns"] != null ? json["health_concerns"].cast() : []; + foodType = json["food_type"] ?? 0; + imageUrl = json["image_url"] ?? ""; + } +} diff --git a/lib/api/dto/login_dto.dart b/lib/api/dto/login_dto.dart new file mode 100644 index 0000000..d149181 --- /dev/null +++ b/lib/api/dto/login_dto.dart @@ -0,0 +1,86 @@ +class UserInfo { + int? id; + String? name; + dynamic avatar; + String? email; + dynamic emailVerifiedAt; + dynamic googleId; + dynamic appleId; + String? lastLoginIp; + String? lastLoginTime; + dynamic lastUsedTime; + int? status; + String? createdAt; + String? updatedAt; + + UserInfo({ + this.id, + this.name, + this.avatar, + this.email, + this.emailVerifiedAt, + this.googleId, + this.appleId, + this.lastLoginIp, + this.lastLoginTime, + this.lastUsedTime, + this.status, + this.createdAt, + this.updatedAt, + }); + + Map toJson() { + final map = {}; + map["id"] = id; + map["name"] = name; + map["avatar"] = avatar; + map["email"] = email; + map["email_verified_at"] = emailVerifiedAt; + map["google_id"] = googleId; + map["apple_id"] = appleId; + map["last_login_ip"] = lastLoginIp; + map["last_login_time"] = lastLoginTime; + map["last_used_time"] = lastUsedTime; + map["status"] = status; + map["created_at"] = createdAt; + map["updated_at"] = updatedAt; + return map; + } + + UserInfo.fromJson(dynamic json) { + id = json["id"] ?? 0; + name = json["name"] ?? ""; + avatar = json["avatar"]; + email = json["email"] ?? ""; + emailVerifiedAt = json["email_verified_at"]; + googleId = json["google_id"]; + appleId = json["apple_id"]; + lastLoginIp = json["last_login_ip"] ?? ""; + lastLoginTime = json["last_login_time"] ?? ""; + lastUsedTime = json["last_used_time"]; + status = json["status"] ?? 0; + createdAt = json["created_at"] ?? ""; + updatedAt = json["updated_at"] ?? ""; + } +} + +class LoginDto { + String? accessToken; + UserInfo? userInfo; + + LoginDto({this.accessToken, this.userInfo}); + + Map toJson() { + final map = {}; + map["accessToken"] = accessToken; + if (userInfo != null) { + map["userInfo"] = userInfo?.toJson(); + } + return map; + } + + LoginDto.fromJson(dynamic json) { + accessToken = json["accessToken"] ?? ""; + userInfo = json["userInfo"] != null ? UserInfo.fromJson(json["userInfo"]) : null; + } +} diff --git a/lib/api/dto/profile_options_dto.dart b/lib/api/dto/profile_options_dto.dart new file mode 100644 index 0000000..e8938b9 --- /dev/null +++ b/lib/api/dto/profile_options_dto.dart @@ -0,0 +1,18 @@ +class ProfileOptionDto { + String? key; + List? valuesList; + + ProfileOptionDto({this.key, this.valuesList}); + + Map toJson() { + final map = {}; + map["key"] = key; + map["values"] = valuesList; + return map; + } + + ProfileOptionDto.fromJson(dynamic json) { + key = json["key"] ?? ""; + valuesList = json["values"] != null ? json["values"].cast() : []; + } +} diff --git a/lib/api/dto/user_profile_dto.dart b/lib/api/dto/user_profile_dto.dart new file mode 100644 index 0000000..bd2608e --- /dev/null +++ b/lib/api/dto/user_profile_dto.dart @@ -0,0 +1,58 @@ +class UserProfileDto { + num id; + String name; + String email; + String avatar; + String ageRange; + List foodAllergiesList; + List dietaryPreferencesList; + List medicalInformationList; + List currentMedicationsList; + String activityLevel; + + UserProfileDto({ + this.id = 0, + this.name = "", + this.email = "", + this.avatar = "", + this.ageRange = "", + List? foodAllergiesList, + List? dietaryPreferencesList, + List? medicalInformationList, + List? currentMedicationsList, + this.activityLevel = "", + }) : foodAllergiesList = foodAllergiesList ?? [], + dietaryPreferencesList = dietaryPreferencesList ?? [], + medicalInformationList = medicalInformationList ?? [], + currentMedicationsList = currentMedicationsList ?? []; + + Map toJson() { + return { + "id": id, + "name": name, + "email": email, + "avatar": avatar, + "age_range": ageRange, + "food_allergies": foodAllergiesList, + "dietary_preferences": dietaryPreferencesList, + "medical_information": medicalInformationList, + "current_medications": currentMedicationsList, + "activity_level": activityLevel, + }; + } + + factory UserProfileDto.fromJson(Map json) { + return UserProfileDto( + id: json["id"] ?? 0, + name: json["name"] ?? "", + email: json["email"] ?? "", + avatar: json["avatar"] ?? "", + ageRange: json["age_range"] ?? "", + foodAllergiesList: (json["food_allergies"] as List?)?.cast() ?? [], + dietaryPreferencesList: (json["dietary_preferences"] as List?)?.cast() ?? [], + medicalInformationList: (json["medical_information"] as List?)?.cast() ?? [], + currentMedicationsList: (json["current_medications"] as List?)?.cast() ?? [], + activityLevel: json["activity_level"] ?? "", + ); + } +} diff --git a/lib/api/endpoints/food_api.dart b/lib/api/endpoints/food_api.dart new file mode 100644 index 0000000..61dc2d6 --- /dev/null +++ b/lib/api/endpoints/food_api.dart @@ -0,0 +1,23 @@ +import 'package:dio/dio.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; + +import '../network/request.dart'; + +///食物检测 +Future foodScanApi(List bytes) async { + FormData formData = FormData.fromMap({ + "food_image": MultipartFile.fromBytes( + bytes, + filename: "upload.jpg", + contentType: DioMediaType("image", "jpeg"), + ), + }); + var res = await Request().post("/food/scan", formData); + return FoodScanDto.fromJson(res); +} + +///食物检测列表 +Future> foodScanListApi() async { + var res = await Request().get("/food/records"); + return res['list'].map((e) => FoodScanDto.fromJson(e)).toList(); +} diff --git a/lib/api/endpoints/profile_api.dart b/lib/api/endpoints/profile_api.dart new file mode 100644 index 0000000..cc0ee78 --- /dev/null +++ b/lib/api/endpoints/profile_api.dart @@ -0,0 +1,27 @@ +import 'package:food_health/api/dto/profile_options_dto.dart'; +import 'package:food_health/api/dto/user_profile_dto.dart'; +import 'package:food_health/api/network/request.dart'; + +///获取用户档案 +Future getUserProfileApi() async { + var res = await Request().get("/user/profile"); + return UserProfileDto.fromJson(res); +} + +///获取档案选项 +Future> getProfileOptionsApi() async { + var res = await Request().get("/user/get_user_profile_options"); + return (res as List).map((e) => ProfileOptionDto.fromJson(e)).toList(); +} + +///更新档案 +Future updateProfileApi(UserProfileDto userProfile) async { + await Request().post("/user/update_profile", { + "age_range": userProfile.ageRange, + "food_allergies": userProfile.foodAllergiesList, + "dietary_preferences": userProfile.dietaryPreferencesList, + "medical_information": userProfile.medicalInformationList, + "current_medications": userProfile.currentMedicationsList, + "activity_level": userProfile.activityLevel, + }); +} diff --git a/lib/api/endpoints/user_api.dart b/lib/api/endpoints/user_api.dart new file mode 100644 index 0000000..a013d73 --- /dev/null +++ b/lib/api/endpoints/user_api.dart @@ -0,0 +1,49 @@ +import 'package:food_health/api/dto/login_dto.dart'; +import 'package:food_health/api/network/request.dart'; +import 'package:food_health/data/models/other_login_type.dart'; + +///检查是否注册 +Future checkRegisterApi(String email) async { + var res = await Request().post("/auth/email_check", { + "email": email, + }); + if (res["next"] == "login") { + return true; + } + return false; +} + +///邮箱密码登陆 +Future loginApi(String email, String password) async { + var res = await Request().post("/auth/login/account", { + "email": email, + "password": password, + }); + return LoginDto.fromJson(res); +} + +///注册处 +Future registerApi(String email, String password, String code) async { + var res = await Request().post("/auth/register", { + "email": email, + "password": password, + "email_code": code, + }); + return LoginDto.fromJson(res); +} + +///发送邮箱验证码 +Future sendEmailCodeApi(String email) async { + return Request().post("/send_email_code", { + "email": email, + }); +} + +///三方登录 +Future thirdLoginApi(String token, OtherLoginType type) async { + var res = await Request().post("/auth/login/oauth", { + "login_token": token, + "login_type": type.value, + }); + return LoginDto.fromJson(res); +} diff --git a/lib/api/network/interceptor.dart b/lib/api/network/interceptor.dart new file mode 100644 index 0000000..30aee7e --- /dev/null +++ b/lib/api/network/interceptor.dart @@ -0,0 +1,64 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; + +import '../../providers/app_store.dart'; +import '../dto/base_dto.dart'; + +///请求拦截器 +void onRequest( + RequestOptions options, + RequestInterceptorHandler handler, +) async { + String token = await AppStore.getToken(); + options.headers['Authorization'] = 'Bearer $token'; + return handler.next(options); +} + +///响应拦截器 +void onResponse( + Response response, + ResponseInterceptorHandler handler, +) { + var apiResponse = ApiDto.fromJson(response.data); + if (apiResponse.code == 1) { + response.data = apiResponse.data; + return handler.next(response); + } else { + showError(apiResponse.message); + handler.reject( + DioException( + requestOptions: response.requestOptions, + response: response, + error: {'code': 0, 'message': apiResponse.message}, + ), + ); + } +} + +///错误响应 +void onError( + DioException e, + ErrorInterceptorHandler handler, +) { + var title = ""; + if (e.type == DioExceptionType.connectionTimeout) { + title = "请求超时"; + } else if (e.type == DioExceptionType.badResponse) { + if (e.response?.statusCode == 404) { + title = "接口404不存在"; + } else { + title = "500"; + } + } else if (e.type == DioExceptionType.connectionError) { + title = "网络连接失败"; + } else { + title = "异常其他错误"; + } + showError(title); + handler.next(e); +} + +///显示错误信息 +void showError(String message) { + EasyLoading.showError(message); +} diff --git a/lib/api/network/request.dart b/lib/api/network/request.dart new file mode 100644 index 0000000..d3a23e0 --- /dev/null +++ b/lib/api/network/request.dart @@ -0,0 +1,46 @@ +import 'package:dio/dio.dart'; + +import '../../config/env.dart'; +import 'interceptor.dart'; + +class Request { + static final Request _instance = Request._internal(); + static Dio _dio = Dio(); + + //返回单例 + factory Request() { + return _instance; + } + + //初始化 + Request._internal() { + //创建基本配置 + final BaseOptions options = BaseOptions( + baseUrl: Config.baseUrl(), + connectTimeout: const Duration(seconds: 30), + receiveTimeout: const Duration(seconds: 30), + ); + + _dio = Dio(options); + + _dio.interceptors.add( + InterceptorsWrapper( + onRequest: onRequest, + onResponse: onResponse, + onError: onError, + ), + ); + } + + ///get请求 + Future get(String path, [Map? params]) async { + var res = await _dio.get(path, queryParameters: params); + return res.data; + } + + ///post请求 + Future post(String path, Object? data) async { + var res = await _dio.post(path, data: data); + return res.data; + } +} diff --git a/lib/api/network/safe.dart b/lib/api/network/safe.dart new file mode 100644 index 0000000..a52f424 --- /dev/null +++ b/lib/api/network/safe.dart @@ -0,0 +1,14 @@ +import 'package:dio/dio.dart'; + +/// 网络请求的错误处理封装 +Future safeRequest( + Future request, { + void Function(DioException error)? onError, +}) async { + try { + return await request; + } on DioException catch (e) { + onError?.call(e); // 额外 hook + rethrow; // 继续往上传 + } +} diff --git a/lib/config/app_context.dart b/lib/config/app_context.dart new file mode 100644 index 0000000..1f72ef7 --- /dev/null +++ b/lib/config/app_context.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class AppContext { + static late BuildContext _context; + + AppContext._(); + + ///私有构造函数,防止外部实例化 + static void setContent(BuildContext context) { + _context = context; + } + + ///获取全局上下文 + static BuildContext get context => _context; + + ///获取主题 + static TextTheme get textTheme => Theme.of(_context).textTheme; + + static ColorScheme get colorScheme => Theme.of(_context).colorScheme; + + ///页面内间距 + static double get pagePadding => 15; +} diff --git a/lib/config/env.dart b/lib/config/env.dart new file mode 100644 index 0000000..d4a38cf --- /dev/null +++ b/lib/config/env.dart @@ -0,0 +1,19 @@ +///环境配置 +class Config { + Config._(); + + ///获取环境 + static String getEnv() { + const env = String.fromEnvironment('ENV', defaultValue: 'dev'); + return env; + } + + ///获取接口地址 + static String baseUrl() { + if (getEnv() == 'dev') { + return 'https://food-api.curain.ai/api'; + } else { + return 'https://food-api.curain.ai/api'; + } + } +} diff --git a/lib/config/theme/custom_colors.dart b/lib/config/theme/custom_colors.dart new file mode 100644 index 0000000..b34b74b --- /dev/null +++ b/lib/config/theme/custom_colors.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +///扩展颜色 +extension CustomColors on ColorScheme { + Color get success => const Color(0xff57be80); + + Color get warning => const Color(0xffff9800); + + Color get info => const Color(0xff909399); + + Color get danger => const Color(0xfff44545); + + Color get primaryEnd => const Color(0xff06b6d4); +} diff --git a/lib/config/theme/theme.dart b/lib/config/theme/theme.dart new file mode 100644 index 0000000..55f57bf --- /dev/null +++ b/lib/config/theme/theme.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +///颜色 +final scheme = ColorScheme.fromSeed( + primary: Color(0xff3784f1), + seedColor: Color(0xff3885f2), + brightness: Brightness.light, + //卡片色 + surface: Colors.white, + surfaceContainerLow: Color(0xFFF4F8FB), + surfaceContainer: Color(0xFFE9ECF3), + surfaceContainerHigh: Color(0xFFDDE2EA), + //颜色 + onSurfaceVariant: Color(0xFF828282), + + shadow: Color.fromRGBO(0, 0, 0, 0.1), +); + +///字体 +final textTheme = TextTheme( + titleLarge: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: scheme.onSurface), + titleMedium: TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: scheme.onSurface), + titleSmall: TextStyle(fontSize: 16, fontWeight: FontWeight.w700, color: scheme.onSurface), + bodyLarge: TextStyle(fontSize: 18), + bodyMedium: TextStyle(fontSize: 16), + bodySmall: TextStyle(fontSize: 14), + labelLarge: TextStyle(fontSize: 16, color: scheme.onSurfaceVariant), + labelMedium: TextStyle(fontSize: 14, color: scheme.onSurfaceVariant), + labelSmall: TextStyle(fontSize: 12, color: scheme.onSurfaceVariant), +); diff --git a/lib/data/local/storage.dart b/lib/data/local/storage.dart new file mode 100644 index 0000000..5e3916f --- /dev/null +++ b/lib/data/local/storage.dart @@ -0,0 +1,48 @@ +import 'dart:convert'; + +import 'package:shared_preferences/shared_preferences.dart'; + +class Storage { + //存储数据 + static Future set(String key, dynamic value) async { + SharedPreferences sp = await SharedPreferences.getInstance(); + if (value is String) { + sp.setString(key, value); + } else if (value is int) { + sp.setInt(key, value); + } else if (value is bool) { + sp.setBool(key, value); + } else if (value is double) { + sp.setDouble(key, value); + } else if (value is Map) { + String jsonStr = jsonEncode(value); + sp.setString(key, jsonStr); + } + } + + //获取数据 + static Future get(String key) async { + SharedPreferences sp = await SharedPreferences.getInstance(); + var value = sp.get(key); + if (value is String) { + try { + return jsonDecode(value); + } catch (e) { + return value; + } + } + return value; + } + + //删除数据 + static Future remove(key) async { + SharedPreferences sp = await SharedPreferences.getInstance(); + sp.remove(key); + } + + //判断键是否存在 + static Future hasKey(String key) async { + SharedPreferences sp = await SharedPreferences.getInstance(); + return sp.containsKey(key); + } +} diff --git a/lib/data/models/other_login_type.dart b/lib/data/models/other_login_type.dart new file mode 100644 index 0000000..299d316 --- /dev/null +++ b/lib/data/models/other_login_type.dart @@ -0,0 +1,8 @@ +enum OtherLoginType { + google('google'), + apple('apple'); + + const OtherLoginType(this.value); + + final String value; +} diff --git a/lib/data/models/skin_check_status.dart b/lib/data/models/skin_check_status.dart new file mode 100644 index 0000000..6d0738f --- /dev/null +++ b/lib/data/models/skin_check_status.dart @@ -0,0 +1,22 @@ +enum SkinCheckStatus { + /// 正常 + normal(1), + + /// 警告 + warning(2), + + /// 危险 + danger(3), + + /// 未知 + unknown(0); + + final int value; + + const SkinCheckStatus(this.value); + + /// 根据 int 值返回对应的枚举,默认返回 online + static SkinCheckStatus fromValue(int value) { + return SkinCheckStatus.values.firstWhere((e) => e.value == value, orElse: () => SkinCheckStatus.unknown); + } +} diff --git a/lib/layout/layout_page.dart b/lib/layout/layout_page.dart new file mode 100644 index 0000000..c8a1256 --- /dev/null +++ b/lib/layout/layout_page.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; +import 'package:remixicon/remixicon.dart'; + +import '../page/home/home_page.dart'; +import '../page/profile/my/my_page.dart'; +import '../page/record/list/record_list_page.dart'; +import 'tabbar.dart'; + +class LayoutPage extends StatefulWidget { + const LayoutPage({super.key}); + + @override + State createState() => _LayoutPageState(); +} + +class _LayoutPageState extends State { + ///分页 + final PageController _pageController = PageController(initialPage: 0); + + int get currentPage { + if (!_pageController.hasClients) return 1; // 没 attach 直接 0 + return _pageController.page?.round() ?? 1; + } + + //TabBar列表 + final List _pages = [ + PageItem( + name: "Home", + icon: RemixIcons.home_2_line, + page: HomePage(), + ), + PageItem(name: "record", icon: RemixIcons.history_line, page: RecordListPage()), + PageItem( + name: "Home", + icon: RemixIcons.book_open_line, + page: MyPage(), + ), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: PageView( + controller: _pageController, + physics: const NeverScrollableScrollPhysics(), + children: _pages.map((item) => item.page).toList(), + ), + bottomNavigationBar: BottomNavigationBar( + currentIndex: currentPage, + onTap: (index) { + _pageController.jumpToPage(index); + setState(() {}); + }, + items: _pages.map((item) { + return BottomNavigationBarItem( + icon: Icon(item.icon), + label: item.name, + ); + }).toList(), + showSelectedLabels: false, + showUnselectedLabels: false, + ), + ); + } +} diff --git a/lib/layout/tabbar.dart b/lib/layout/tabbar.dart new file mode 100644 index 0000000..7c0ab69 --- /dev/null +++ b/lib/layout/tabbar.dart @@ -0,0 +1,9 @@ +import 'package:flutter/material.dart'; + +class PageItem { + final String name; + final IconData icon; + final Widget page; + + PageItem({required this.name, required this.icon, required this.page}); +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..824360a --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,55 @@ +import 'package:food_health/router/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:provider/provider.dart'; + +import 'config/theme/theme.dart'; +import 'providers/app_store.dart'; + +void main() { + runApp( + MultiProvider( + providers: [ + ChangeNotifierProvider(create: (context) => AppStore()), + ], + child: MyApp(), + ), + ); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return ScreenUtilInit( + designSize: const Size(375, 694), + useInheritedMediaQuery: true, + child: MaterialApp.router( + debugShowCheckedModeBanner: false, + routerConfig: goRouter, + localizationsDelegates: [], + themeMode: ThemeMode.light, + theme: ThemeData( + useMaterial3: true, + colorScheme: scheme, + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + backgroundColor: scheme.primary, + foregroundColor: scheme.onPrimary, + ), + ), + textTheme: textTheme, + scaffoldBackgroundColor: Color(0xffFAFAFE), + appBarTheme: AppBarTheme( + backgroundColor: scheme.surface, + scrolledUnderElevation: 0, + titleTextStyle: textTheme.titleMedium, + ), + ), + builder: EasyLoading.init(), + ), + ); + } +} diff --git a/lib/page/home/home_page.dart b/lib/page/home/home_page.dart new file mode 100644 index 0000000..705c59d --- /dev/null +++ b/lib/page/home/home_page.dart @@ -0,0 +1,30 @@ +import 'package:food_health/page/home/widget/home_header.dart'; +import 'package:flutter/material.dart'; +import '../../widgets/common/app_backend.dart'; +import '../../widgets/common/app_header.dart'; +import 'widget/upload_panel.dart'; + +class HomePage extends StatefulWidget { + const HomePage({super.key}); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State with AutomaticKeepAliveClientMixin { + @override + Widget build(BuildContext context) { + super.build(context); + return Scaffold( + resizeToAvoidBottomInset: false, + body: AppBackend( + child: ListView( + children: [AppHeader(), HomeHeader(), UploadPanel()], + ), + ), + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/page/home/widget/home_header.dart b/lib/page/home/widget/home_header.dart new file mode 100644 index 0000000..5556cd1 --- /dev/null +++ b/lib/page/home/widget/home_header.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class HomeHeader extends StatelessWidget { + const HomeHeader({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(top: 30, bottom: 40), + child: Column( + children: [ + Text( + "Food Safety Scanner", + style: Theme.of(context).textTheme.titleLarge, + ), + Container( + margin: EdgeInsets.only(top: 10), + child: Text( + "Upload a photo to check if this food is safe for you", + style: Theme.of(context).textTheme.labelMedium, + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } +} diff --git a/lib/page/home/widget/upload_panel.dart b/lib/page/home/widget/upload_panel.dart new file mode 100644 index 0000000..7d0f2ab --- /dev/null +++ b/lib/page/home/widget/upload_panel.dart @@ -0,0 +1,193 @@ +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_image_compress/flutter_image_compress.dart'; +import 'package:food_health/api/endpoints/food_api.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:food_health/router/config/route_paths.dart'; +import 'package:go_router/go_router.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:remixicon/remixicon.dart'; + +class UploadPanel extends StatefulWidget { + const UploadPanel({super.key}); + + @override + State createState() => _UploadPanelState(); +} + +class _UploadPanelState extends State { + final ImagePicker _picker = ImagePicker(); + + ///打开相机拍照 + void _handTakePhoto() async { + var photo = await _picker.pickImage(source: ImageSource.camera); + if (photo != null) { + _startDetect(photo.path); + } + } + + ///选择图片 + void _handPickImage() async { + var result = await FilePicker.platform.pickFiles( + type: FileType.image, + allowMultiple: false, + ); + if (result != null) { + _startDetect(result.files[0].path!); + } + } + + ///开始检测 + void _startDetect(String path) async { + //压缩 + final result = await FlutterImageCompress.compressWithFile( + path, + minWidth: 1080, + minHeight: 1920, + quality: 85, + rotate: 0, + ); + EasyLoading.show( + status: 'Checking, please wait...', + maskType: EasyLoadingMaskType.clear, + ); + var res = await foodScanApi(result!); + EasyLoading.dismiss(); + context.push(RoutePaths.detail, extra: res); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + color: Theme.of(context).cardColor, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: Color(0x1A000000), + spreadRadius: 2, + blurRadius: 5, + offset: Offset(1, 2), + ), + ], + ), + child: Container( + padding: EdgeInsets.all(30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + border: Border.all( + color: Theme.of(context).colorScheme.surfaceContainer, + width: 1, + ), + ), + child: Column( + children: [ + Container( + width: 70, + height: 70, + margin: EdgeInsets.only(bottom: 20), + decoration: BoxDecoration( + shape: BoxShape.circle, + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryEnd, + ], + ), + ), + child: Icon( + RemixIcons.image_line, + color: Colors.white, + size: 26, + ), + ), + Text( + "Upload Food Photo", + style: Theme.of(context).textTheme.titleMedium, + ), + Container( + margin: EdgeInsets.only(top: 5), + child: Text( + "Take a clear photo of your food and we'll analyze it for safety based on your health profile", + style: Theme.of(context).textTheme.bodySmall, + textAlign: TextAlign.center, + ), + ), + Container( + margin: EdgeInsets.only(top: 40, bottom: 20), + child: Column( + spacing: 20, + children: [ + _buttonItem( + title: "Take Photo", + icon: RemixIcons.camera_line, + style: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryEnd, + ], + ), + ), + onTap: () { + _handTakePhoto(); + }, + ), + _buttonItem( + title: "Upload File", + icon: RemixIcons.upload_2_line, + color: Colors.black, + style: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + ), + onTap: () { + _handPickImage(); + }, + ), + ], + ), + ), + Text( + "Supports JPG, PNG, HEIC formats • Max 10MB", + style: Theme.of(context).textTheme.labelSmall, + textAlign: TextAlign.center, + ), + ], + ), + ), + ); + } + + Widget _buttonItem({ + required String title, + required IconData icon, + Color color = Colors.white, + required BoxDecoration style, + required VoidCallback onTap, + }) { + return InkWell( + onTap: onTap, + child: Container( + width: 170, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 15), + decoration: style.copyWith( + borderRadius: BorderRadius.circular(10), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + spacing: 10, + children: [ + Icon(icon, color: color, size: 20), + Text( + title, + style: TextStyle(color: color), + ), + ], + ), + ), + ); + } +} diff --git a/lib/page/profile/edit/data/state.dart b/lib/page/profile/edit/data/state.dart new file mode 100644 index 0000000..0e5c577 --- /dev/null +++ b/lib/page/profile/edit/data/state.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/user_profile_dto.dart'; + +class SelectionState extends ChangeNotifier { + UserProfileDto userProfile = UserProfileDto(); + + SelectionState(this.userProfile); + + void update(void Function(UserProfileDto) updater) { + updater(userProfile); + notifyListeners(); + } +} + +class SelectionProvider extends InheritedNotifier { + const SelectionProvider({ + super.key, + required SelectionState super.notifier, + required super.child, + }); + + static SelectionState of(BuildContext context) { + return context.dependOnInheritedWidgetOfExactType()!.notifier!; + } +} diff --git a/lib/page/profile/edit/my_edit_page.dart b/lib/page/profile/edit/my_edit_page.dart new file mode 100644 index 0000000..9584a98 --- /dev/null +++ b/lib/page/profile/edit/my_edit_page.dart @@ -0,0 +1,292 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:food_health/api/dto/profile_options_dto.dart'; +import 'package:food_health/api/dto/user_profile_dto.dart'; +import 'package:food_health/api/endpoints/profile_api.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:food_health/page/profile/edit/widget/food_allergies.dart'; +import 'package:food_health/widgets/common/app_backend.dart'; +import 'package:go_router/go_router.dart'; +import 'package:remixicon/remixicon.dart'; + +import 'data/state.dart'; +import 'widget/dietary_preferences.dart'; +import 'widget/health_profile.dart'; + +class MyEditPage extends StatefulWidget { + final UserProfileDto userProfile; + + const MyEditPage({super.key, required this.userProfile}); + + @override + State createState() => _MyEditPageState(); +} + +class _MyEditPageState extends State { + late SelectionState selectionState; + + List _options = []; + + var _loading = true; + + ///步骤 + var _step = 0; + + var stepList = [ + StepItem( + title: "Food Allergies", + icon: RemixIcons.shield_line, + subTitle: "Help us keep you safe by telling us about your allergies", + ), + StepItem( + title: "Dietary Preferences", + icon: RemixIcons.heart_line, + subTitle: "What dietary restrictions or preferences do you follow?", + ), + StepItem( + title: "Health Profile", + icon: RemixIcons.user_line, + subTitle: "Share relevant health information for personalized recommendations", + ), + ]; + + @override + void initState() { + super.initState(); + _init(); + } + + void _init() async { + selectionState = SelectionState(widget.userProfile); + var res = await getProfileOptionsApi(); + setState(() { + _options = res; + _loading = false; + }); + } + + ///设置步骤 + void _handStep(bool isNext) { + if (_step == 2 && isNext) { + _submit(); + return; + } + setState(() { + _step = (_step + (isNext ? 1 : -1)).clamp(0, 2); + }); + } + + void _submit() async { + EasyLoading.show( + status: 'Saving…', + maskType: EasyLoadingMaskType.clear, + ); + await updateProfileApi(selectionState.userProfile); + EasyLoading.dismiss(); + context.pop(); + } + + @override + Widget build(BuildContext context) { + if (_loading) { + return Center(child: CircularProgressIndicator()); + } + return Scaffold( + body: AppBackend( + child: ListView( + padding: EdgeInsets.only(top: 30), + children: [ + buildHeader(), + buildStep(), + buildStepInfo(), + SelectionProvider( + notifier: selectionState, + child: Builder( + builder: (context) { + if (_step == 0) { + return FoodAllergies( + options: _options, + ); + } else if (_step == 1) { + return DietaryPreferences( + options: _options, + ); + } else if (_step == 2) { + return HealthProfile( + options: _options, + ); + } + return SizedBox(); + }, + ), + ), + Container( + margin: EdgeInsets.only(top: 30), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Opacity( + opacity: _step == 0 ? 0.4 : 1, + child: buildItemButton( + title: "Previous", + color: Colors.black, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + ), + onTap: () { + _handStep(false); + }, + ), + ), + buildItemButton( + title: _step == 2 ? "Complete Setup" : "Continue", + decoration: BoxDecoration( + color: _step == 2 ? Theme.of(context).colorScheme.success : null, + gradient: _step == 2 + ? null + : LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryEnd, + ], + ), + ), + onTap: () { + _handStep(true); + }, + ), + ], + ), + ), + ], + ), + ), + ); + } + + ///构建顶部 + Widget buildHeader() { + return Column( + children: [ + Text( + "Welcome to FoodSafe", + style: Theme.of(context).textTheme.titleLarge, + ), + Container( + margin: EdgeInsets.only(top: 5), + child: Text( + "Let's personalize your food safety experience", + style: Theme.of(context).textTheme.labelMedium, + ), + ), + ], + ); + } + + ///步骤条 + Widget buildStep() { + return Container( + margin: EdgeInsets.only(top: 20), + child: Row( + spacing: 10, + children: stepList.asMap().entries.map((entre) { + //数据 + var item = entre.value; + var index = entre.key; + var isLast = index == stepList.length - 1; + //颜色 + var selectColor = Theme.of(context).colorScheme.primary; + var unselectedColor = Theme.of(context).colorScheme.surfaceContainerHigh; + return Expanded( + flex: isLast ? 0 : 1, + child: Row( + spacing: 10, + children: [ + Container( + width: 50, + height: 50, + decoration: BoxDecoration( + color: _step >= index ? selectColor : unselectedColor, + shape: BoxShape.circle, + ), + child: Icon( + item.icon, + color: _step >= index ? Colors.white : Color(0xff9ca3af), + ), + ), + + Visibility( + visible: !isLast, + child: Expanded( + child: Container( + height: 3, + color: _step > index ? selectColor : unselectedColor, + ), + ), + ), + ], + ), + ); + }).toList(), + ), + ); + } + + ///步骤条信息 + Widget buildStepInfo() { + var stepInfo = stepList[_step]; + return Container( + margin: EdgeInsets.only(top: 20, bottom: 30), + child: Column( + children: [ + Text( + stepInfo.title, + style: Theme.of(context).textTheme.titleMedium, + ), + Container( + margin: EdgeInsets.only(top: 5), + child: Text( + stepInfo.subTitle, + style: Theme.of(context).textTheme.labelMedium, + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } + + ///item按钮 + Widget buildItemButton({ + required String title, + Color color = Colors.white, + required BoxDecoration decoration, + required Function() onTap, + }) { + return InkWell( + onTap: onTap, + child: Container( + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + decoration: decoration.copyWith( + borderRadius: BorderRadius.circular(8), + ), + child: Text( + title, + style: TextStyle(color: color), + ), + ), + ); + } +} + +class StepItem { + final IconData icon; + final String title; + final String subTitle; + + StepItem({ + required this.icon, + required this.title, + required this.subTitle, + }); +} diff --git a/lib/page/profile/edit/util/common.dart b/lib/page/profile/edit/util/common.dart new file mode 100644 index 0000000..08f314f --- /dev/null +++ b/lib/page/profile/edit/util/common.dart @@ -0,0 +1,9 @@ +import 'package:food_health/api/dto/profile_options_dto.dart'; + +List getOptions(List options, String key) { + var data = options.firstWhere((item) { + return item.key == key; + }); + // + return data.valuesList ?? []; +} diff --git a/lib/page/profile/edit/widget/common.dart b/lib/page/profile/edit/widget/common.dart new file mode 100644 index 0000000..3f8a24c --- /dev/null +++ b/lib/page/profile/edit/widget/common.dart @@ -0,0 +1,100 @@ +import 'dart:ffi'; + +import 'package:flutter/material.dart'; + +///步骤内容卡片 +class StepContentCard extends StatelessWidget { + final List children; + + const StepContentCard({super.key, required this.children}); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow, + blurRadius: 7, + offset: const Offset(0, 4), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: children, + ), + ); + } +} + +///卡片标题 +class CardTitle extends StatelessWidget { + final String title; + + const CardTitle({super.key, required this.title}); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(bottom: 15), + child: Text( + title, + style: Theme.of(context).textTheme.titleSmall, + ), + ); + } +} + +///配置列表 +class OptionList extends StatelessWidget { + final List options; + final List selects; + final double widthFactor; + final Function(String) onTap; + + const OptionList({ + super.key, + required this.options, + required this.selects, + this.widthFactor = 0.5, + required this.onTap, + }); + + @override + Widget build(BuildContext context) { + return Wrap( + runSpacing: 20, + children: options.map((item) { + return FractionallySizedBox( + widthFactor: widthFactor, + child: InkWell( + onTap: () { + onTap(item); + }, + child: Row( + spacing: 5, + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + width: 20, + height: 20, + child: Checkbox( + value: selects.contains(item), + onChanged: (_) { + onTap(item); + }, + ), + ), + Text(item), + ], + ), + ), + ); + }).toList(), + ); + } +} diff --git a/lib/page/profile/edit/widget/dietary_preferences.dart b/lib/page/profile/edit/widget/dietary_preferences.dart new file mode 100644 index 0000000..4ad5bbe --- /dev/null +++ b/lib/page/profile/edit/widget/dietary_preferences.dart @@ -0,0 +1,127 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/profile_options_dto.dart'; + +import '../data/state.dart'; +import '../util/common.dart'; +import 'common.dart'; + +class DietaryPreferences extends StatefulWidget { + final List options; + + const DietaryPreferences({super.key, required this.options}); + + @override + State createState() => _DietaryPreferencesState(); +} + +class _DietaryPreferencesState extends State { + ///切换标签 + void _handToggle(String tag) { + var state = SelectionProvider.of(context); + if (getIsSelect(tag)) { + state.update((p) => p.dietaryPreferencesList.remove(tag)); + } else { + state.update((p) => p.dietaryPreferencesList.add(tag)); + } + } + + ///选中年龄 + void _handAgeRange(String tag) { + var state = SelectionProvider.of(context); + state.update((p) => p.ageRange = tag); + } + + ///等级 + void _handActivityLevel(String tag) { + var state = SelectionProvider.of(context); + state.update((p) => p.activityLevel = tag); + } + + ///是否标签选中 + bool getIsSelect(String tag) { + var state = SelectionProvider.of(context); + return state.userProfile.dietaryPreferencesList.contains(tag); + } + + @override + Widget build(BuildContext context) { + var state = SelectionProvider.of(context); + return StepContentCard( + children: [ + CardTitle(title: "Dietary Restrictions & Preferences"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: OptionList( + options: getOptions(widget.options, "dietary_restrictions"), + selects: state.userProfile.dietaryPreferencesList, + onTap: _handToggle, + ), + ), + CardTitle(title: "Age Range"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: RadioGroup( + options: getOptions(widget.options, "age_ranges"), + value: state.userProfile.ageRange, + onChanged: _handAgeRange, + ), + ), + CardTitle(title: "Activity Level"), + RadioGroup( + options: getOptions(widget.options, "activity_levels"), + value: state.userProfile.activityLevel, + onChanged: _handActivityLevel, + ), + ], + ); + } +} + +///单选列表 +class RadioGroup extends StatelessWidget { + final List options; + final String value; + final int crossAxisCount; + final Function(String) onChanged; + + const RadioGroup({ + super.key, + required this.options, + required this.value, + this.crossAxisCount = 3, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + return GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisSpacing: 10, + mainAxisSpacing: 10, + crossAxisCount: crossAxisCount, + mainAxisExtent: 40, + ), + itemBuilder: (context, index) { + var data = options[index]; + var isSelected = value == data; + return InkWell( + onTap: () { + onChanged(data); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + color: isSelected ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.surfaceContainerLow, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: isSelected ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.surfaceContainer), + ), + child: Text(data, style: TextStyle(color: isSelected ? Colors.white : Colors.black)), + ), + ); + }, + itemCount: options.length, + ); + } +} diff --git a/lib/page/profile/edit/widget/food_allergies.dart b/lib/page/profile/edit/widget/food_allergies.dart new file mode 100644 index 0000000..e3d5e2b --- /dev/null +++ b/lib/page/profile/edit/widget/food_allergies.dart @@ -0,0 +1,144 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/profile_options_dto.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:remixicon/remixicon.dart'; + +import '../data/state.dart'; +import '../util/common.dart'; +import 'common.dart'; + +class FoodAllergies extends StatefulWidget { + final List options; + + const FoodAllergies({super.key, required this.options}); + + @override + State createState() => _FoodAllergiesState(); +} + +class _FoodAllergiesState extends State { + final TextEditingController _otherController = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + ///切换标签 + void _handToggle(String tag) { + var state = SelectionProvider.of(context); + if (getIsSelect(tag)) { + state.update((p) => p.foodAllergiesList.remove(tag)); + } else { + state.update((p) => p.foodAllergiesList.add(tag)); + } + } + + void _handConfirmCustom() { + var state = SelectionProvider.of(context); + if (!getIsSelect(_otherController.text)) { + state.update((p) => p.foodAllergiesList.add(_otherController.text)); + _otherController.text = ""; + } + } + + ///是否标签选中 + bool getIsSelect(String tag) { + var state = SelectionProvider.of(context); + return state.userProfile.foodAllergiesList.contains(tag); + } + + @override + Widget build(BuildContext context) { + var state = SelectionProvider.of(context); + return StepContentCard( + children: [ + CardTitle(title: "Common Food Allergies"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: OptionList( + options: getOptions(widget.options, "common_food_allergies"), + selects: state.userProfile.foodAllergiesList, + onTap: _handToggle, + ), + ), + CardTitle(title: "Other Allergies"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: Row( + spacing: 15, + children: [ + Expanded( + child: TextField( + controller: _otherController, + style: Theme.of(context).textTheme.bodyMedium, + decoration: InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + hintText: "Add custom allergy...", + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerLow, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.surfaceContainer), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.surfaceContainer), + ), + ), + ), + ), + InkWell( + onTap: _handConfirmCustom, + child: Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + borderRadius: BorderRadius.circular(8), + ), + child: Icon(RemixIcons.add_fill), + ), + ), + ], + ), + ), + CardTitle(title: "Your Allergies"), + Wrap( + runSpacing: 10, + spacing: 10, + children: state.userProfile.foodAllergiesList.map((item) { + return InkWell( + onTap: () { + _handToggle(item); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.danger, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + spacing: 5, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + item, + style: TextStyle(color: Colors.white, fontSize: 12), + ), + Icon( + RemixIcons.close_fill, + color: Colors.white, + size: 20, + ), + ], + ), + ), + ); + }).toList(), + ), + ], + ); + } +} diff --git a/lib/page/profile/edit/widget/health_profile.dart b/lib/page/profile/edit/widget/health_profile.dart new file mode 100644 index 0000000..851f988 --- /dev/null +++ b/lib/page/profile/edit/widget/health_profile.dart @@ -0,0 +1,151 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/profile_options_dto.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:remixicon/remixicon.dart'; + +import '../data/state.dart'; +import '../util/common.dart'; +import 'common.dart'; + +class HealthProfile extends StatefulWidget { + final List options; + + const HealthProfile({super.key, required this.options}); + + @override + State createState() => _HealthProfileState(); +} + +class _HealthProfileState extends State { + final TextEditingController _otherController = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + ///切换标签 + void _handToggle(String tag) { + var state = SelectionProvider.of(context); + if (getIsSelect(tag)) { + state.update((p) => p.medicalInformationList.remove(tag)); + } else { + state.update((p) => p.medicalInformationList.add(tag)); + } + } + + ///确认搜索内容 + void _handConfirmCustom() { + var state = SelectionProvider.of(context); + if (!getIsSelect(_otherController.text)) { + state.update((p) => p.currentMedicationsList.add(_otherController.text)); + _otherController.text = ""; + } + } + + ///移除搜索标签 + void _handRemoveCustom(String tag) { + var state = SelectionProvider.of(context); + state.update((p) => p.currentMedicationsList.remove(tag)); + } + + ///是否标签选中 + bool getIsSelect(String tag) { + var state = SelectionProvider.of(context); + return state.userProfile.medicalInformationList.contains(tag); + } + + @override + Widget build(BuildContext context) { + var state = SelectionProvider.of(context); + return StepContentCard( + children: [ + CardTitle(title: "Medical Conditions"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: OptionList( + widthFactor: 1, + options: getOptions(widget.options, "medical_conditions"), + selects: state.userProfile.medicalInformationList, + onTap: _handToggle, + ), + ), + CardTitle(title: "Current Medications"), + Container( + margin: EdgeInsets.only(bottom: 15), + child: Row( + spacing: 15, + children: [ + Expanded( + child: TextField( + controller: _otherController, + style: Theme.of(context).textTheme.bodyMedium, + decoration: InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + hintText: "Add medication...", + filled: true, + fillColor: Theme.of(context).colorScheme.surfaceContainerLow, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.surfaceContainer), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.surfaceContainer), + ), + ), + ), + ), + InkWell( + onTap: _handConfirmCustom, + child: Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainer, + borderRadius: BorderRadius.circular(8), + ), + child: Icon(RemixIcons.add_fill), + ), + ), + ], + ), + ), + Wrap( + runSpacing: 10, + spacing: 10, + children: state.userProfile.currentMedicationsList.map((item) { + return InkWell( + onTap: () { + _handRemoveCustom(item); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 3, horizontal: 10), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.danger, + borderRadius: BorderRadius.circular(8), + ), + child: Row( + spacing: 5, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + item, + style: TextStyle(color: Colors.white, fontSize: 12), + ), + Icon( + RemixIcons.close_fill, + color: Colors.white, + size: 20, + ), + ], + ), + ), + ); + }).toList(), + ), + ], + ); + } +} diff --git a/lib/page/profile/my/my_page.dart b/lib/page/profile/my/my_page.dart new file mode 100644 index 0000000..54f9745 --- /dev/null +++ b/lib/page/profile/my/my_page.dart @@ -0,0 +1,155 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/user_profile_dto.dart'; +import 'package:food_health/api/endpoints/profile_api.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:go_router/go_router.dart'; +import 'package:remixicon/remixicon.dart'; + +import '../../../router/config/route_paths.dart'; +import 'widget/title_card.dart'; +import 'widget/user_card.dart'; + +class MyPage extends StatefulWidget { + const MyPage({super.key}); + + @override + State createState() => _MyPageState(); +} + +class _MyPageState extends State with AutomaticKeepAliveClientMixin { + UserProfileDto _userProfile = UserProfileDto(); + + @override + void initState() { + super.initState(); + _init(); + } + + void _init() async { + var res = await getUserProfileApi(); + setState(() { + _userProfile = res; + }); + } + + void _goEdit() async { + await context.push(RoutePaths.myEdit, extra: _userProfile); + _init(); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: ListView( + padding: EdgeInsets.all(15), + children: [ + UserCard( + detail: _userProfile, + onEdit: _goEdit, + ), + Column( + children: [ + TitleCard( + title: "Food Allergies", + icon: Icon( + RemixIcons.shield_line, + color: Theme.of(context).colorScheme.danger, + ), + child: buildTagList( + emptyText: "No food allergies reported", + tags: _userProfile.foodAllergiesList, + color: Theme.of(context).colorScheme.danger, + ), + ), + TitleCard( + title: "No preferences", + icon: Icon( + RemixIcons.heart_line, + color: Theme.of(context).colorScheme.success, + ), + child: buildTagList( + emptyText: "No dietary preferences reported", + tags: _userProfile.dietaryPreferencesList, + color: Theme.of(context).colorScheme.success, + ), + ), + TitleCard( + title: "Medical Information", + icon: Icon( + RemixIcons.user_line, + color: Theme.of(context).colorScheme.primary, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(bottom: 10), + child: Text("Medical Conditions"), + ), + Container( + margin: EdgeInsets.only(bottom: 10), + child: buildTagList( + emptyText: "No medical conditions reported", + tags: _userProfile.medicalInformationList, + color: Theme.of(context).colorScheme.primary, + ), + ), + Container( + margin: EdgeInsets.only(bottom: 10), + child: Text("Current Medications"), + ), + buildTagList( + emptyText: "No medications reported", + tags: _userProfile.currentMedicationsList, + color: Theme.of(context).colorScheme.primary, + ), + ], + ), + ), + ], + ), + ], + ), + ); + } + + Widget buildTagList({ + required String emptyText, + required List tags, + required Color color, + }) { + if (tags.isEmpty) { + return Text( + emptyText, + style: TextStyle( + color: Theme.of(context).colorScheme.success, + ), + ); + } else { + return Wrap( + spacing: 15, + runSpacing: 15, + children: tags.map((item) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + color: color.withValues(alpha: 0.2), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + item, + style: TextStyle( + color: color, + fontSize: 14, + fontWeight: FontWeight.w700, + ), + ), + ); + }).toList(), + ); + } + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/page/profile/my/widget/title_card.dart b/lib/page/profile/my/widget/title_card.dart new file mode 100644 index 0000000..ad2ce3c --- /dev/null +++ b/lib/page/profile/my/widget/title_card.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; + +class TitleCard extends StatelessWidget { + final String title; + final Widget icon; + final Widget child; + + const TitleCard({ + super.key, + required this.title, + required this.icon, + required this.child, + }); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: EdgeInsets.all(15), + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow(color: Theme.of(context).colorScheme.shadow, blurRadius: 7), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 10, + children: [ + icon, + Text( + title, + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + ), + child, + ], + ), + ); + } +} diff --git a/lib/page/profile/my/widget/user_card.dart b/lib/page/profile/my/widget/user_card.dart new file mode 100644 index 0000000..36b65cc --- /dev/null +++ b/lib/page/profile/my/widget/user_card.dart @@ -0,0 +1,180 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/user_profile_dto.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:food_health/providers/app_store.dart'; +import 'package:food_health/router/config/route_paths.dart'; +import 'package:food_health/utils/common.dart'; +import 'package:go_router/go_router.dart'; +import 'package:provider/provider.dart'; +import 'package:remixicon/remixicon.dart'; + +class UserCard extends StatefulWidget { + final UserProfileDto detail; + final Function() onEdit; + + const UserCard({ + super.key, + required this.detail, + required this.onEdit, + }); + + @override + State createState() => _UserCardState(); +} + +class _UserCardState extends State { + void _goEdit() { + widget.onEdit(); + } + + void _handLogout() { + var appStore = context.read(); + appStore.logout(); + context.go(RoutePaths.login); + } + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow, + blurRadius: 7, + offset: const Offset(0, 4), + ), + ], + ), + child: Column( + children: [ + avatarWidget(), + Container( + margin: const EdgeInsets.only(top: 12), + child: Text(getNotEmpty(widget.detail.name) ?? "user", style: Theme.of(context).textTheme.titleMedium), + ), + Container( + margin: const EdgeInsets.only(top: 5), + child: Text(widget.detail.email ?? "", style: Theme.of(context).textTheme.labelMedium), + ), + buildTitledTags( + title: "Age Range", + tag: getNotEmpty(widget.detail.ageRange), + ), + buildTitledTags( + title: "Activity Level", + tag: getNotEmpty(widget.detail.activityLevel), + ), + SizedBox(height: 20), + btnItem( + title: "Edit Profile", + icon: RemixIcons.edit_box_line, + color: Colors.white, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryEnd, + ], + ), + ), + onTap: _goEdit, + ), + btnItem( + title: "Logout", + icon: RemixIcons.logout_circle_line, + decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer), + onTap: _handLogout, + ), + ], + ), + ); + } + + ///头像 + Widget avatarWidget() { + return Container( + width: 70, + height: 70, + decoration: BoxDecoration( + shape: BoxShape.circle, + gradient: LinearGradient( + colors: [ + Theme.of(context).colorScheme.primary, + Theme.of(context).colorScheme.primaryEnd, + ], + ), + ), + child: Icon( + RemixIcons.user_3_line, + color: Colors.white, + size: 30, + ), + ); + } + + ///标题标签 + Widget buildTitledTags({ + required String title, + String? tag, + }) { + return Container( + margin: const EdgeInsets.only(top: 20), + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, style: Theme.of(context).textTheme.bodyMedium), + Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 3), + margin: const EdgeInsets.only(top: 5), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerLow, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + tag ?? "Untitled", + style: Theme.of(context).textTheme.labelMedium?.copyWith( + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ); + } + + ///按钮 + Widget btnItem({ + required String title, + required IconData icon, + required BoxDecoration decoration, + Color color = Colors.black, + required Function() onTap, + }) { + return InkWell( + onTap: onTap, + child: Container( + margin: const EdgeInsets.only(top: 15), + padding: const EdgeInsets.symmetric(vertical: 12), + decoration: decoration.copyWith( + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(icon, size: 20, color: color), + SizedBox(width: 10), + Text( + title, + style: TextStyle(color: color, fontWeight: FontWeight.w500), + ), + ], + ), + ), + ); + } +} diff --git a/lib/page/record/detail/record_detail_page.dart b/lib/page/record/detail/record_detail_page.dart new file mode 100644 index 0000000..eda4654 --- /dev/null +++ b/lib/page/record/detail/record_detail_page.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; + +import 'widget/detailed_analysis.dart'; +import 'widget/health_recommend.dart'; +import 'widget/result_chip.dart'; + +class RecordDetailPage extends StatefulWidget { + final FoodScanDto detail; + + const RecordDetailPage({super.key, required this.detail}); + + @override + State createState() => _RecordDetailPageState(); +} + +class _RecordDetailPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + systemOverlayStyle: SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.dark, // 状态栏图标深色 + statusBarBrightness: Brightness.light, // iOS + ), + ), + body: ListView( + padding: const EdgeInsets.only(left: 15, right: 15, bottom: 15), + children: [ + ResultChip(detail: widget.detail), + DetailedAnalysis(detail: widget.detail), + HealthRecommend( + detail: widget.detail, + ), + ], + ), + ); + } +} diff --git a/lib/page/record/detail/widget/detailed_analysis.dart b/lib/page/record/detail/widget/detailed_analysis.dart new file mode 100644 index 0000000..6c7e9d8 --- /dev/null +++ b/lib/page/record/detail/widget/detailed_analysis.dart @@ -0,0 +1,76 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; +import 'package:markdown_widget/widget/markdown.dart'; +import 'package:remixicon/remixicon.dart'; + +class DetailedAnalysis extends StatelessWidget { + final FoodScanDto detail; + + const DetailedAnalysis({super.key, required this.detail}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(top: 20), + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow, + blurRadius: 10, + offset: Offset(0, 4), + ), + ], + ), + child: Column( + spacing: 10, + children: [ + Row( + spacing: 10, + children: [ + Icon( + RemixIcons.eye_line, + color: Theme.of(context).primaryColor, + ), + Text( + "Detailed Analysis", + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + MarkdownWidget( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + data: detail.explanation ?? "", + ), + Row( + spacing: 10, + children: [ + Icon(RemixIcons.menu_2_line), + Text( + "Detected Ingredients", + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + Wrap( + spacing: 10, + runSpacing: 10, + children: detail.ingredientsList!.map((item) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerLow, + borderRadius: BorderRadius.circular(8), + ), + child: Text(item, style: Theme.of(context).textTheme.labelMedium), + ); + }).toList(), + ), + ], + ), + ); + } +} diff --git a/lib/page/record/detail/widget/health_recommend.dart b/lib/page/record/detail/widget/health_recommend.dart new file mode 100644 index 0000000..9b858f9 --- /dev/null +++ b/lib/page/record/detail/widget/health_recommend.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:markdown_widget/widget/markdown.dart'; +import 'package:remixicon/remixicon.dart'; + +import '../../../../api/dto/food_scan_dto.dart'; + +class HealthRecommend extends StatelessWidget { + final FoodScanDto detail; + + const HealthRecommend({super.key, required this.detail}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(top: 20), + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow, + blurRadius: 10, + offset: Offset(0, 4), + ), + ], + ), + child: Column( + children: [ + Row( + spacing: 10, + children: [ + Icon( + RemixIcons.heart_line, + color: Theme.of(context).colorScheme.danger, + ), + Text( + "Health Recommendations", + style: Theme.of(context).textTheme.titleMedium, + ), + ], + ), + MarkdownWidget( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + data: detail.suggestions ?? "", + ), + ], + ), + ); + } +} diff --git a/lib/page/record/detail/widget/result_chip.dart b/lib/page/record/detail/widget/result_chip.dart new file mode 100644 index 0000000..cefd9b8 --- /dev/null +++ b/lib/page/record/detail/widget/result_chip.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:remixicon/remixicon.dart'; + +class ResultChip extends StatelessWidget { + final FoodScanDto detail; + + const ResultChip({super.key, required this.detail}); + + @override + Widget build(BuildContext context) { + Color currentColor = Colors.transparent; //设置主体颜色 + IconData iconData = Icons.check; //图标 + String title = ""; + String desc = ""; + + if (detail.foodType == 1) { + currentColor = Theme.of(context).colorScheme.success; + iconData = RemixIcons.shield_check_line; + title = "Safe to Eat"; + desc = "This food appears safe for your health profile"; + } else if (detail.foodType == 2) { + currentColor = Theme.of(context).colorScheme.warning; + iconData = RemixIcons.error_warning_fill; + title = "Proceed with Caution"; + desc = "This food may have some concerns for your health profile"; + } else if (detail.foodType == 3) { + currentColor = Theme.of(context).colorScheme.danger; + iconData = RemixIcons.close_circle_line; + title = "Avoid This Food"; + desc = "This food is not recommended for your health profile"; + } + return Container( + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + color: currentColor.withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(10), + border: Border.all(color: currentColor, width: 1), + ), + child: Column( + spacing: 20, + children: [ + Container( + width: 70, + height: 70, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: currentColor, + ), + child: Icon( + iconData, + color: Colors.white, + ), + ), + Text( + title, + style: Theme.of(context).textTheme.titleLarge, + textAlign: TextAlign.center, + ), + Text( + desc, + style: TextStyle(color: currentColor, fontSize: 14), + textAlign: TextAlign.center, + ), + SizedBox( + width: 150, + height: 150, + child: Image.network( + detail.imageUrl!, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return Container( + decoration: BoxDecoration(color: Theme.of(context).colorScheme.surfaceContainer), + child: Icon(RemixIcons.error_warning_fill), + ); + }, + ), + ), + Text( + detail.foodName ?? "", + style: Theme.of(context).textTheme.titleSmall, + textAlign: TextAlign.center, + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 20), + child: Text( + detail.foodDesc ?? "", + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } +} diff --git a/lib/page/record/list/record_list_page.dart b/lib/page/record/list/record_list_page.dart new file mode 100644 index 0000000..fea0029 --- /dev/null +++ b/lib/page/record/list/record_list_page.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; +import 'package:food_health/api/endpoints/food_api.dart'; + +import 'widget/record_list_card.dart'; + +class RecordListPage extends StatefulWidget { + const RecordListPage({super.key}); + + @override + State createState() => _RecordListPageState(); +} + +class _RecordListPageState extends State with TickerProviderStateMixin { + bool _loading = true; + + //tab + late TabController _tabController; + final tabs = ["All", "Safe", "Warning", "Danger"]; + + //列表数据 + List _record = []; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: tabs.length, vsync: this); + _loadData(); + } + + Future _loadData() async { + setState(() { + _loading = true; + }); + var res = await foodScanListApi(); + setState(() { + _record = res; + _loading = false; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Food Check History"), + bottom: TabBar( + controller: _tabController, + dividerColor: Colors.transparent, + tabs: tabs.map((item) { + return Tab(text: item); + }).toList(), + ), + ), + body: TabBarView( + controller: _tabController, + children: tabs.asMap().entries.map((entry) { + var index = entry.key; + var filterList = _record.where((item) { + if (index == 0) return true; + return item.foodType == index; + }).toList(); + + return RefreshIndicator( + onRefresh: () => _loadData(), + child: RecordListCard( + loading: _loading, + records: filterList, + onRefresh: () { + _loadData(); + }, + ), + ); + }).toList(), + ), + ); + } +} diff --git a/lib/page/record/list/widget/record_list_card.dart b/lib/page/record/list/widget/record_list_card.dart new file mode 100644 index 0000000..cac024c --- /dev/null +++ b/lib/page/record/list/widget/record_list_card.dart @@ -0,0 +1,157 @@ +import 'package:flutter/material.dart'; +import 'package:food_health/api/dto/food_scan_dto.dart'; +import 'package:food_health/config/theme/custom_colors.dart'; +import 'package:food_health/router/config/route_paths.dart'; +import 'package:food_health/widgets/common/async_image.dart'; +import 'package:food_health/widgets/ui_kit/empty/index.dart'; +import 'package:go_router/go_router.dart'; +import 'package:remixicon/remixicon.dart'; + +class RecordListCard extends StatelessWidget { + final bool loading; + final List records; + final Function() onRefresh; + + const RecordListCard({ + super.key, + required this.records, + required this.loading, + required this.onRefresh, + }); + + @override + Widget build(BuildContext context) { + if (loading) { + return Center( + child: CircularProgressIndicator(), + ); + } + return Visibility( + visible: records.isNotEmpty, + replacement: Empty( + child: ElevatedButton( + onPressed: onRefresh, + child: Text("Refresh"), + ), + ), + child: ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15), + itemBuilder: (context, index) { + var item = records[index]; + return InkWell( + onTap: () { + context.push(RoutePaths.detail, extra: item); + }, + child: Container( + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surface, + borderRadius: BorderRadius.circular(8), + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.shadow, + blurRadius: 4, + offset: Offset(0, 2), + ), + ], + ), + child: Row( + spacing: 15, + children: [ + Stack( + clipBehavior: Clip.none, + children: [ + SizedBox( + width: 80, + height: 80, + child: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: AsyncImage( + url: item.imageUrl!, + ), + ), + ), + Positioned( + right: -5, + top: -5, + child: StatusWidget( + type: item.foodType!, + ), + ), + ], + ), + Expanded( + child: Column( + spacing: 10, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.foodName ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.titleSmall, + ), + Text( + item.foodDesc ?? "", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.labelMedium, + ), + ], + ), + ), + ], + ), + ), + ); + }, + separatorBuilder: (context, index) { + return SizedBox(height: 15); + }, + itemCount: records.length, + ), + ); + } +} + +class StatusWidget extends StatelessWidget { + final int type; + + const StatusWidget({super.key, required this.type}); + + @override + Widget build(BuildContext context) { + IconData? iconData; + Color? color; + switch (type) { + case 1: + iconData = RemixIcons.shield_check_line; + color = Theme.of(context).colorScheme.success; + break; + case 2: + iconData = RemixIcons.error_warning_fill; + color = Theme.of(context).colorScheme.warning; + break; + case 3: + iconData = RemixIcons.close_circle_line; + color = Theme.of(context).colorScheme.danger; + break; + } + if (iconData == null) { + return SizedBox(); + } else { + return Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: color, + ), + child: Icon( + iconData, + color: Colors.white, + size: 15, + ), + ); + } + } +} diff --git a/lib/page/system/agree/agree_page.dart b/lib/page/system/agree/agree_page.dart new file mode 100644 index 0000000..eff5819 --- /dev/null +++ b/lib/page/system/agree/agree_page.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:webview_flutter/webview_flutter.dart'; + +class AgreePage extends StatelessWidget { + final String title; + final String url; + + const AgreePage({super.key, required this.title, required this.url}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(title), + ), + body: WebViewWidget( + controller: WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..loadRequest(Uri.parse(url)), + ), + ); + } +} diff --git a/lib/page/system/login/login_code_page.dart b/lib/page/system/login/login_code_page.dart new file mode 100644 index 0000000..fb291b5 --- /dev/null +++ b/lib/page/system/login/login_code_page.dart @@ -0,0 +1,115 @@ +import 'package:food_health/api/endpoints/user_api.dart'; +import 'package:food_health/api/network/safe.dart'; +import 'package:food_health/page/system/login/widget/widget.dart'; +import 'package:food_health/router/config/route_paths.dart'; +import 'package:food_health/widgets/ui_kit/button/custom_button.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:go_router/go_router.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/app_store.dart'; + +class LoginCodePage extends StatefulWidget { + final String email; + final String password; + + const LoginCodePage({super.key, required this.email, required this.password}); + + @override + State createState() => _LoginCodePageState(); +} + +class _LoginCodePageState extends State { + final _codeController = TextEditingController(); + var _subLoading = false; + + @override + void initState() { + super.initState(); + _handSendCode(); + } + + ///发送验证码 + void _handSendCode() { + sendEmailCodeApi(widget.email); + EasyLoading.showSuccess("Send success"); + } + + ///提交 + void _handSubmit() async { + if (_codeController.text.isNotEmpty) { + setState(() { + _subLoading = true; + }); + var res = await safeRequest( + registerApi( + widget.email, + widget.password, + _codeController.text, + ), + onError: (error) { + setState(() { + _subLoading = false; + }); + }, + ); + var appStore = context.read(); + await appStore.setInfo(res); + context.go(RoutePaths.layout); + setState(() { + _subLoading = false; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Container( + width: double.infinity, + padding: EdgeInsets.only(left: 20, right: 20, top: 40), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "Check your inbox", + style: Theme.of(context).textTheme.titleLarge, + ), + Container( + margin: EdgeInsets.only(top: 20, bottom: 40), + child: Text( + "Enter the verification code we just sent to ${widget.email}.", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.labelMedium, + ), + ), + InputBox(hintText: "Code", controller: _codeController), + Container( + margin: EdgeInsets.only(top: 20), + child: CustomButton( + loading: _subLoading, + onPressed: _handSubmit, + child: Text("Continue"), + ), + ), + Container( + margin: EdgeInsets.only(top: 20), + child: TextButton( + onPressed: () { + _handSendCode(); + }, + child: Text( + "Resend code", + style: Theme.of(context).textTheme.labelSmall, + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/page/system/login/login_page.dart b/lib/page/system/login/login_page.dart new file mode 100644 index 0000000..caa8319 --- /dev/null +++ b/lib/page/system/login/login_page.dart @@ -0,0 +1,293 @@ +import 'package:food_health/api/endpoints/user_api.dart'; +import 'package:food_health/data/models/other_login_type.dart'; +import 'package:food_health/router/config/route_paths.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:go_router/go_router.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:provider/provider.dart'; +import 'package:remixicon/remixicon.dart'; +import 'package:sign_in_with_apple/sign_in_with_apple.dart'; +import '../../../providers/app_store.dart'; +import '../../../utils/common.dart'; +import '../../../widgets/common/app_backend.dart'; +import '../../../widgets/ui_kit/button/custom_button.dart'; +import 'widget/agreement_box.dart'; +import 'widget/widget.dart'; + +class LoginPage extends StatefulWidget { + const LoginPage({super.key}); + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + var _subLoading = false; + + ///协议 + bool _agree = false; + + ///谷歌登陆 + final GoogleSignIn _googleSignIn = GoogleSignIn.instance; + + ///邮箱输入框 + final TextEditingController _emailController = TextEditingController(text: ""); + final TextEditingController _passwordController = TextEditingController(text: ""); + + //显示密码 + var _hidePassword = true; + + @override + void initState() { + super.initState(); + _ensureNetworkPermission(); + _initGoogleSign(); + } + + /// 预触发 iOS 网络权限弹窗 + Future _ensureNetworkPermission() async { + try { + await Dio().get( + 'https://captive.apple.com/hotspot-detect.html', + options: Options( + sendTimeout: const Duration(seconds: 3), + receiveTimeout: const Duration(seconds: 3), + headers: {'Cache-Control': 'no-cache'}, + ), + ); + return true; + } catch (_) { + return false; + } + } + + void _initGoogleSign() { + if (isAndroid()) { + _googleSignIn.initialize( + clientId: null, + serverClientId: "512878764950-0bsl98c4q4p695mlmfn35qhmr2ld5n0o.apps.googleusercontent.com", + ); + } else { + _googleSignIn.initialize( + clientId: "512878764950-u703jdn6imu33rthp94dg7cl5vmrc7rf.apps.googleusercontent.com", + serverClientId: "512878764950-0bsl98c4q4p695mlmfn35qhmr2ld5n0o.apps.googleusercontent.com", + ); + } + + _googleSignIn.authenticationEvents + .listen((_) { + print("登陆成功"); + }) + .onError((error) { + print('登录错误: $error'); + }); + } + + ///谷歌登录 + void _handleGoogleSignIn() async { + if (!_agree) { + EasyLoading.showToast('Please read and agree to the terms first.'); + return; + } + + try { + // 如果用户未登录,则启动标准的 Google 登录 + if (_googleSignIn.supportsAuthenticate()) { + // 使用 authenticate() 进行认证 + GoogleSignInAccount? user = await _googleSignIn.authenticate(); + var auth = user.authentication; + + // var res = await Dio().get("https://oauth2.googleapis.com/tokeninfo?id_token=${auth.idToken}"); + //登陆 + EasyLoading.show(status: "Logging in..."); + var res = await thirdLoginApi(auth.idToken!, OtherLoginType.google); + EasyLoading.dismiss(); + _onLogin(res); + } + // } catch (e) { + // if (e is GoogleSignInException) { + // if (e.code == GoogleSignInExceptionCode.canceled) { + // // 用户取消登录 + // print("User canceled login."); + // } else { + // // 其他错误 + // print("Google Sign-In error: $e"); + // } + // } else { + // print("Unknown error: $e"); + // } + // } + } catch (e) { + EasyLoading.showError("Login failed"); + print("登录错误: $e"); + } + } + + ///apple登录 + void _handAppleSignIn() async { + if (!_agree) { + EasyLoading.showToast('Please read and agree to the terms first.'); + return; + } + + try { + final credential = await SignInWithApple.getAppleIDCredential( + scopes: [ + AppleIDAuthorizationScopes.email, + AppleIDAuthorizationScopes.fullName, + ], + ); + EasyLoading.show(status: "Logging in..."); + var res = await thirdLoginApi(credential.identityToken!, OtherLoginType.apple); + EasyLoading.dismiss(); + _onLogin(res); + print('Apple Credential: ${credential.identityToken}'); + print('Apple Email: ${credential.email}'); + } catch (e) { + print('Error during Apple sign-in: $e'); + } + } + + void _handSubmit() async { + if (!_agree) { + EasyLoading.showToast('Please read and agree to the terms first.'); + return; + } + if (_emailController.text.isEmpty) { + //请输入邮箱 + EasyLoading.showError("Please enter your email"); + return; + } else if (_passwordController.text.isEmpty) { + EasyLoading.showError("Please enter your Password"); + return; + } + + try { + setState(() { + _subLoading = true; + }); + var isRegister = await checkRegisterApi(_emailController.text); + if (!isRegister) { + context.push( + RoutePaths.loginCode, + extra: { + "email": _emailController.text, + "password": _passwordController.text, + }, + ); + } else { + var res = await loginApi(_emailController.text, _passwordController.text); + _onLogin(res); + } + setState(() { + _subLoading = false; + }); + } catch (e) { + setState(() { + _subLoading = false; + }); + } + } + + ///登陆的操作 + void _onLogin(dynamic res) { + var appStore = context.read(); + appStore.setInfo(res); + context.go(RoutePaths.layout); + } + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => FocusScope.of(context).unfocus(), + child: AppBackend( + child: Scaffold( + resizeToAvoidBottomInset: false, + body: SafeArea( + child: Stack( + alignment: Alignment.center, + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only( + top: 0.07.sh, + left: 20, + right: 20, + ), + child: Column( + children: [ + LogoBox(), + PageHeader(), + InputBox( + hintText: "Email", + controller: _emailController, + ), + SizedBox(height: 15), + InputBox( + obscureText: _hidePassword, + hintText: "Password", + controller: _passwordController, + suffix: InkWell( + onTap: () { + setState(() { + _hidePassword = !_hidePassword; + }); + }, + child: Icon( + _hidePassword ? RemixIcons.eye_off_fill : RemixIcons.eye_fill, + size: 20, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + ), + ), + Container( + margin: EdgeInsets.only(top: 20), + height: 45, + child: CustomButton( + loading: _subLoading, + round: false, + onPressed: _handSubmit, + child: Text("Continue"), + ), + ), + LoginDivider(), + OtherButton( + title: "Continue with Google", + icon: "assets/image/google.png", + onTap: () { + _handleGoogleSignIn(); + }, + ), + SizedBox(height: 15), + OtherButton( + title: "Continue with Apple", + icon: "assets/image/apple.png", + onTap: () { + _handAppleSignIn(); + }, + ), + ], + ), + ), + Positioned( + bottom: 20, + child: AgreementBox( + checked: _agree, + onChanged: (value) { + setState(() { + _agree = value; + }); + }, + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/page/system/login/widget/agreement_box.dart b/lib/page/system/login/widget/agreement_box.dart new file mode 100644 index 0000000..ea5f566 --- /dev/null +++ b/lib/page/system/login/widget/agreement_box.dart @@ -0,0 +1,66 @@ +import 'package:food_health/router/config/route_paths.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +///勾中协议 +class AgreementBox extends StatelessWidget { + final bool checked; + final Function(bool) onChanged; + + const AgreementBox({ + super.key, + this.checked = false, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + width: 25, + child: Transform.scale( + scale: 0.8, + child: Checkbox( + value: checked, + shape: CircleBorder(), + onChanged: (value) { + onChanged(value!); + }, + ), + ), + ), + RichText( + text: TextSpan( + style: Theme.of(context).textTheme.labelSmall, + children: [ + TextSpan( + text: "I agree to the ", + ), + TextSpan( + text: "Terms", + style: TextStyle(color: Theme.of(context).primaryColor), + recognizer: TapGestureRecognizer() + ..onTap = () => context.push( + RoutePaths.agreement, + extra: {"title": "Terms of Service", "url": "https://support.curain.ai/privacy/derma/terms_service.html"}, + ), + ), + TextSpan(text: " & "), + TextSpan( + text: "Privacy Policy", + style: TextStyle(color: Theme.of(context).primaryColor), + recognizer: TapGestureRecognizer() + ..onTap = () => context.push( + RoutePaths.agreement, + extra: {"title": "Privacy", "url": "https://support.curain.ai/privacy/derma/privacy_policy.html"}, + ), + ), + ], + ), + ), + ], + ); + } +} diff --git a/lib/page/system/login/widget/widget.dart b/lib/page/system/login/widget/widget.dart new file mode 100644 index 0000000..cf8a8f7 --- /dev/null +++ b/lib/page/system/login/widget/widget.dart @@ -0,0 +1,166 @@ +import 'package:flutter/material.dart'; + +///登陆Box +class LogoBox extends StatelessWidget { + const LogoBox({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(bottom: 40), + child: Column( + children: [ + Image.asset( + "assets/image/logo.png", + width: 43, + ), + Text( + "FoodCura", + style: Theme.of(context).textTheme.titleSmall, + ), + ], + ), + ); + } +} + +///头部文案 +class PageHeader extends StatelessWidget { + const PageHeader({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(bottom: 30), + child: Column( + children: [ + Text( + "Create an account", + style: TextStyle(fontWeight: FontWeight.w700), + ), + Text( + "Enter your email to sign up for this app", + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + ); + } +} + +///输入框 +class InputBox extends StatelessWidget { + final bool obscureText; + final String hintText; + final TextEditingController controller; + final Widget? suffix; + + const InputBox({ + super.key, + this.obscureText = false, + required this.hintText, + required this.controller, + this.suffix, + }); + + @override + Widget build(BuildContext context) { + //边框 + var inputBorder = OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide( + color: Theme.of(context).colorScheme.surfaceContainer, + ), + ); + return TextField( + controller: controller, + maxLength: 100, + obscureText: obscureText, + style: Theme.of(context).textTheme.bodyMedium, + decoration: InputDecoration( + hintText: hintText, + hintStyle: Theme.of(context).textTheme.labelMedium, + counterText: '', + border: inputBorder, + enabledBorder: inputBorder, + suffix: suffix, + suffixIconConstraints: BoxConstraints( + minWidth: 0, + minHeight: 0, + ), + ), + ); + } +} + +///分割线 +class LoginDivider extends StatelessWidget { + const LoginDivider({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(top: 20, bottom: 20), + child: Row( + spacing: 8, + children: [ + Expanded( + child: Container( + height: 1, + color: Theme.of(context).colorScheme.surfaceContainer, + ), + ), + Text( + "or", + style: Theme.of(context).textTheme.labelMedium, + ), + Expanded( + child: Container( + height: 1, + color: Theme.of(context).colorScheme.surfaceContainer, + ), + ), + ], + ), + ); + } +} + +///其他登陆按钮 +class OtherButton extends StatelessWidget { + final Function() onTap; + final String title; + final String icon; + + const OtherButton({ + super.key, + required this.onTap, + required this.title, + required this.icon, + }); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Theme.of(context).colorScheme.surfaceContainer, + ), + child: Row( + spacing: 10, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(icon, width: 20), + Text( + title, + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + ), + ); + } +} diff --git a/lib/page/system/splash/splash_page.dart b/lib/page/system/splash/splash_page.dart new file mode 100644 index 0000000..c90f740 --- /dev/null +++ b/lib/page/system/splash/splash_page.dart @@ -0,0 +1,65 @@ +import 'package:food_health/providers/app_store.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:go_router/go_router.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/app_context.dart'; +import '../../../router/config/route_paths.dart'; +import '../../../router/routes.dart'; + +class SplashPage extends StatefulWidget { + const SplashPage({super.key}); + + @override + State createState() => _SplashPageState(); +} + +class _SplashPageState extends State { + @override + void initState() { + super.initState(); + init(); + } + + void init() { + WidgetsBinding.instance.addPostFrameCallback((_) async { + AppContext.setContent(navigatorKey.currentState!.context); + //效验 + AppStore appStore = context.read(); + await appStore.init(); + if (!mounted) return; + if (appStore.token.isEmpty) { + context.go(RoutePaths.login); + } else { + context.go(RoutePaths.layout); + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + "assets/image/logo.png", + width: 68.w, + ), + Container( + margin: EdgeInsets.only(top: 16), + child: Text( + "Demacare", + style: Theme.of(context).textTheme.titleMedium, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/providers/app_store.dart b/lib/providers/app_store.dart new file mode 100644 index 0000000..7a2326a --- /dev/null +++ b/lib/providers/app_store.dart @@ -0,0 +1,46 @@ +import 'package:food_health/api/dto/login_dto.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import '../data/local/storage.dart'; + +class AppStore with ChangeNotifier { + ///用户信息 + UserInfo? userInfo; + + ///token + String token = ''; + + //初始化 + Future init() async { + token = await getToken(); + var userInfoStorage = await Storage.get('userInfo'); + if (userInfoStorage != null) { + userInfo = UserInfo.fromJson(await Storage.get('userInfo')); + } + + notifyListeners(); + } + + ///设置用户数据 + Future setInfo(LoginDto data) async { + token = data.accessToken!; + userInfo = data.userInfo; + + await Storage.set('userInfo', userInfo?.toJson()); + await Storage.set('token', token); + } + + ///获取token + static Future getToken() async { + return await Storage.get("token") ?? ''; + } + + ///退出登录 + Future logout() async { + await Storage.remove('token'); + await Storage.remove('userInfo'); + token = ''; + userInfo = null; + notifyListeners(); + } +} diff --git a/lib/router/config/route_paths.dart b/lib/router/config/route_paths.dart new file mode 100644 index 0000000..341d893 --- /dev/null +++ b/lib/router/config/route_paths.dart @@ -0,0 +1,24 @@ +class RoutePaths { + RoutePaths._(); + + ///闪烁页 + static const splash = "/"; + + ///协议页 + static const agreement = "/agreement"; + + ///登录 + static const login = "/login"; + + ///登陆验证码 + static const loginCode = "/loginCode"; + + ///首页 + static const layout = "/layout"; + + ///预约详情 + static const detail = "/detail"; + + ///编辑我的 + static const myEdit = "/my_edit"; +} diff --git a/lib/router/config/route_type.dart b/lib/router/config/route_type.dart new file mode 100644 index 0000000..77f8617 --- /dev/null +++ b/lib/router/config/route_type.dart @@ -0,0 +1,16 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:go_router/go_router.dart'; + +class RouteType { + String path; + FutureOr Function(BuildContext, GoRouterState)? redirect; + Widget Function(GoRouterState) child; + + RouteType({ + required this.path, + required this.child, + this.redirect, + }); +} diff --git a/lib/router/modules/base.dart b/lib/router/modules/base.dart new file mode 100644 index 0000000..e39065d --- /dev/null +++ b/lib/router/modules/base.dart @@ -0,0 +1,49 @@ +import 'package:food_health/layout/layout_page.dart'; +import 'package:food_health/page/system/login/login_code_page.dart'; +import 'package:food_health/page/system/splash/splash_page.dart'; +import 'package:food_health/router/config/route_paths.dart'; + +import '../../page/system/agree/agree_page.dart'; +import '../../page/system/login/login_page.dart'; +import '../config/route_type.dart'; + +List baseRoutes = [ + RouteType( + path: RoutePaths.splash, + child: (state) { + return SplashPage(); + }, + ), + RouteType( + path: RoutePaths.agreement, + child: (state) { + final extra = state.extra as Map; + return AgreePage( + title: extra['title'] ?? "", + url: extra['url'] ?? "", + ); + }, + ), + RouteType( + path: RoutePaths.login, + child: (state) { + return LoginPage(); + }, + ), + RouteType( + path: RoutePaths.loginCode, + child: (state) { + final args = state.extra as Map; + return LoginCodePage( + email: args['email'], + password: args['password'], + ); + }, + ), + RouteType( + path: RoutePaths.layout, + child: (state) { + return LayoutPage(); + }, + ), +]; diff --git a/lib/router/modules/serve.dart b/lib/router/modules/serve.dart new file mode 100644 index 0000000..dfadf66 --- /dev/null +++ b/lib/router/modules/serve.dart @@ -0,0 +1,27 @@ +import 'package:food_health/page/profile/edit/my_edit_page.dart'; + +import '../../page/record/detail/record_detail_page.dart'; +import '../config/route_paths.dart'; +import '../config/route_type.dart'; + +List serverRoutes = [ + RouteType( + path: RoutePaths.myEdit, + child: (state) { + var extra = state.extra as dynamic; + return MyEditPage( + userProfile: extra, + ); + }, + ), + + RouteType( + path: RoutePaths.detail, + child: (state) { + var extra = state.extra as dynamic; + return RecordDetailPage( + detail: extra, + ); + }, + ), +]; diff --git a/lib/router/routes.dart b/lib/router/routes.dart new file mode 100644 index 0000000..35077aa --- /dev/null +++ b/lib/router/routes.dart @@ -0,0 +1,28 @@ +import 'package:flutter/cupertino.dart'; +import 'package:go_router/go_router.dart'; + +import 'modules/base.dart'; +import 'config/route_paths.dart'; +import 'config/route_type.dart'; +import 'modules/serve.dart'; + +GlobalKey navigatorKey = GlobalKey(); + +List routeConfigs = [...baseRoutes, ...serverRoutes]; + +//for循环遍历 +List routes = routeConfigs.map((item) { + return GoRoute( + path: item.path, + builder: (context, state) { + return item.child(state); + }, + ); +}).toList(); + +//变量命名 +GoRouter goRouter = GoRouter( + initialLocation: RoutePaths.splash, + routes: routes, + navigatorKey: navigatorKey, +); diff --git a/lib/utils/common.dart b/lib/utils/common.dart new file mode 100644 index 0000000..22f9b8d --- /dev/null +++ b/lib/utils/common.dart @@ -0,0 +1,14 @@ +import 'dart:io'; + +///判断是否是安卓 +bool isAndroid() { + return Platform.isAndroid; +} + +/// 获取非空的值 +String? getNotEmpty(String? value) { + if (value != null && value.isNotEmpty) { + return value; + } + return null; +} diff --git a/lib/utils/format.dart b/lib/utils/format.dart new file mode 100644 index 0000000..9f1080e --- /dev/null +++ b/lib/utils/format.dart @@ -0,0 +1,35 @@ +/// 格式化日期时间 +String formatDateUS(dynamic date, [String format = 'MM/DD/YYYY hh:mm:ss a']) { + DateTime dateTime; + + if (date is String) { + dateTime = DateTime.tryParse(date) ?? DateTime.now(); + } else if (date is DateTime) { + dateTime = date; + } else { + dateTime = DateTime.now(); + } + + final yyyy = dateTime.year.toString(); + final MM = dateTime.month.toString().padLeft(2, '0'); + final dd = dateTime.day.toString().padLeft(2, '0'); + + // 12小时制 + final hour12 = (dateTime.hour % 12 == 0 ? 12 : dateTime.hour % 12).toString().padLeft(2, '0'); + final HH = dateTime.hour.toString().padLeft(2, '0'); // 24小时制备用 + final mm = dateTime.minute.toString().padLeft(2, '0'); + final ss = dateTime.second.toString().padLeft(2, '0'); + final ampm = dateTime.hour >= 12 ? 'PM' : 'AM'; + + String result = format + .replaceFirst(RegExp('YYYY'), yyyy) + .replaceFirst(RegExp('MM'), MM) + .replaceFirst(RegExp('DD'), dd) + .replaceFirst(RegExp('hh'), hour12) + .replaceFirst(RegExp('HH'), HH) + .replaceFirst(RegExp('mm'), mm) + .replaceFirst(RegExp('ss'), ss) + .replaceFirst(RegExp('a'), ampm); + + return result; +} diff --git a/lib/widgets/common/app_backend.dart b/lib/widgets/common/app_backend.dart new file mode 100644 index 0000000..f8e9d36 --- /dev/null +++ b/lib/widgets/common/app_backend.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class AppBackend extends StatelessWidget { + final Widget child; + + const AppBackend({super.key, required this.child}); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: EdgeInsets.all(15), + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color(0xffdff8fb), + Color(0xffffffff), + Color(0xffdff8fb), + ], + ), + ), + child: SafeArea(child: child), + ); + } +} diff --git a/lib/widgets/common/app_header.dart b/lib/widgets/common/app_header.dart new file mode 100644 index 0000000..e686068 --- /dev/null +++ b/lib/widgets/common/app_header.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +class AppHeader extends StatefulWidget { + const AppHeader({super.key}); + + @override + State createState() => _AppHeaderState(); +} + +class _AppHeaderState extends State { + @override + Widget build(BuildContext context) { + return SafeArea( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + spacing: 10, + children: [ + Image.asset( + "assets/image/logo.png", + width: 44, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "FoodSafe", + style: TextStyle(fontWeight: FontWeight.bold), + ), + Text( + "AI Health Guardian", + style: Theme.of(context).textTheme.labelSmall, + ), + ], + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/widgets/common/async_image.dart b/lib/widgets/common/async_image.dart new file mode 100644 index 0000000..e4d8dda --- /dev/null +++ b/lib/widgets/common/async_image.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; + +class AsyncImage extends StatelessWidget { + final String url; + final double? width; + + const AsyncImage({ + super.key, + required this.url, + this.width, + }); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: width, + child: Image.network( + url, + fit: BoxFit.cover, + // 加载中的样式 + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) { + return child; // 加载完成,直接返回图片 + } + return Container( + color: Colors.grey[200], + alignment: Alignment.center, + child: CircularProgressIndicator(strokeWidth: 2), + ); + }, + // 加载失败的样式 + errorBuilder: (context, error, stackTrace) { + return Container( + color: Colors.grey[200], + child: const Icon( + Icons.broken_image, + size: 30, + color: Colors.grey, + ), + ); + }, + ), + ); + } +} diff --git a/lib/widgets/ui_kit/button/custom_button.dart b/lib/widgets/ui_kit/button/custom_button.dart new file mode 100644 index 0000000..0e3c76c --- /dev/null +++ b/lib/widgets/ui_kit/button/custom_button.dart @@ -0,0 +1,84 @@ +import 'package:flutter/material.dart'; + +///自定义按钮 +///包括loading功能 +class CustomButton extends StatelessWidget { + final Widget child; + final VoidCallback? onPressed; + final bool loading; + final bool round; + final bool disabled; + + const CustomButton({ + super.key, + required this.child, + this.onPressed, + this.loading = false, + this.round = true, + this.disabled = false, + }); + + @override + Widget build(BuildContext context) { + ///自定义颜色 + // switch (size) { + // case ButtonSize.small: + // height = 28; + // loadingSize = 16; + // fontSize = 12; + // padding = const EdgeInsets.symmetric(horizontal: 12); + // break; + // case ButtonSize.large: + // height = 48; + // loadingSize = 24; + // fontSize = 18; + // padding = const EdgeInsets.symmetric(horizontal: 20); + // break; + // case ButtonSize.medium: + // height = 45; + // loadingSize = 15; + // fontSize = 16; + // padding = const EdgeInsets.symmetric(horizontal: 16); + // break; + // } + + void handClick() { + if (!loading && !disabled) { + onPressed?.call(); + } + } + + return Opacity( + opacity: disabled ? 0.5 : 1, + child: ElevatedButton( + onPressed: handClick, + style: ElevatedButton.styleFrom( + shape: round + ? const StadiumBorder() + : RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Visibility( + visible: loading, + child: Container( + margin: EdgeInsets.only(right: 8), + child: SizedBox.square( + dimension: 15, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ), + ), + ), + child, + ], + ), + ), + ); + } +} diff --git a/lib/widgets/ui_kit/empty/index.dart b/lib/widgets/ui_kit/empty/index.dart new file mode 100644 index 0000000..36d64e4 --- /dev/null +++ b/lib/widgets/ui_kit/empty/index.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +import '../../../config/app_context.dart'; + +class Empty extends StatelessWidget { + final String? title; + final Widget? child; + + const Empty({super.key, this.title, this.child}); + + @override + Widget build(BuildContext context) { + return SizedBox.expand( + child: Align( + alignment: const FractionalOffset(0.5, 0.2), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + FractionallySizedBox( + widthFactor: 0.5, + child: Image.asset("assets/image/empty_data.png"), + ), + if (title != null) + Text( + title!, + style: AppContext.textTheme.labelMedium, + ), + if (child != null) child!, + ], + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..80246a1 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,898 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.13.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.2" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.19.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.4+2" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.8" + dbus: + dependency: transitive + description: + name: dbus + sha256: "79e0c23480ff85dc68de79e2cd6334add97e48f7f4865d17686dd6ea81a47e8c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.11" + dio: + dependency: "direct main" + description: + name: dio + sha256: d90ee57923d1828ac14e492ca49440f65477f4bb1263575900be731a3dac66a9 + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.9.0" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.1" + file_picker: + dependency: "direct main" + description: + name: file_picker + sha256: e7e16c9d15c36330b94ca0e2ad8cb61f93cd5282d0158c09805aed13b5452f22 + url: "https://pub.flutter-io.cn" + source: hosted + version: "10.3.2" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.9.3+2" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "19124ff4a3d8864fdc62072b6a2ef6c222d55a3404fe14893a3c02744907b60c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.9.4+4" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.6.2" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.9.3+4" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_easyloading: + dependency: "direct main" + description: + name: flutter_easyloading + sha256: ba21a3c883544e582f9cc455a4a0907556714e1e9cf0eababfcb600da191d17c + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.5" + flutter_highlight: + dependency: transitive + description: + name: flutter_highlight + sha256: "7b96333867aa07e122e245c033b8ad622e4e3a42a1a2372cbb098a2541d8782c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.0" + flutter_image_compress: + dependency: "direct main" + description: + name: flutter_image_compress + sha256: "51d23be39efc2185e72e290042a0da41aed70b14ef97db362a6b5368d0523b27" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.0" + flutter_image_compress_common: + dependency: transitive + description: + name: flutter_image_compress_common + sha256: c5c5d50c15e97dd7dc72ff96bd7077b9f791932f2076c5c5b6c43f2c88607bfb + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.6" + flutter_image_compress_macos: + dependency: transitive + description: + name: flutter_image_compress_macos + sha256: "20019719b71b743aba0ef874ed29c50747461e5e8438980dfa5c2031898f7337" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.3" + flutter_image_compress_ohos: + dependency: transitive + description: + name: flutter_image_compress_ohos + sha256: e76b92bbc830ee08f5b05962fc78a532011fcd2041f620b5400a593e96da3f51 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.0.3" + flutter_image_compress_platform_interface: + dependency: transitive + description: + name: flutter_image_compress_platform_interface + sha256: "579cb3947fd4309103afe6442a01ca01e1e6f93dc53bb4cbd090e8ce34a41889" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.5" + flutter_image_compress_web: + dependency: transitive + description: + name: flutter_image_compress_web + sha256: b9b141ac7c686a2ce7bb9a98176321e1182c9074650e47bb140741a44b6f5a96 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.1.5" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "6382ce712ff69b0f719640ce957559dde459e55ecd433c767e06d139ddf16cab" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.29" + flutter_screenutil: + dependency: "direct main" + description: + name: flutter_screenutil + sha256: "8239210dd68bee6b0577aa4a090890342d04a136ce1c81f98ee513fc0ce891de" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.9.3" + flutter_spinkit: + dependency: transitive + description: + name: flutter_spinkit + sha256: "77850df57c00dc218bfe96071d576a8babec24cf58b2ed121c83cca4a2fdce7f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.2.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: ced3fdc143c1437234ac3b8e985f3286cf138968bb83ca9a6f94d22f2951c6b9 + url: "https://pub.flutter-io.cn" + source: hosted + version: "16.2.0" + google_identity_services_web: + dependency: transitive + description: + name: google_identity_services_web + sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.3+1" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + sha256: "939a8b58f84c4053811b8c1bc9adbcb59449a15b37958264bbf60020698cca0e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.1.1" + google_sign_in_android: + dependency: transitive + description: + name: google_sign_in_android + sha256: f256b8f0e6c09d135c166fe20b25256e24d60fe1a72e6bdc112a200bd0d555b4 + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.3" + google_sign_in_ios: + dependency: transitive + description: + name: google_sign_in_ios + sha256: c7ee744ebbcd98353966dbdee735d4fca085226f6bf725c6bea8a5c8fe0055bc + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.0" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + sha256: "8736443134d2cccadd4f228d600177cb3947e36683466a6ab96877ce6932885a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + sha256: "09ac306b2787b48f19c857b9f93375b654f774643c75bd6a1a078c85f4f7b468" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + highlight: + dependency: transitive + description: + name: highlight + sha256: "5353a83ffe3e3eca7df0abfb72dcf3fa66cc56b953728e7113ad4ad88497cf21" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.0" + http: + dependency: transitive + description: + name: http + sha256: bb2ce4590bc2667c96f318d68cac1b5a7987ec819351d32b1c987239a815e007 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.5.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.2" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "736eb56a911cf24d1859315ad09ddec0b66104bc41a7f8c5b96b4e2620cf5041" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: e83b2b05141469c5e19d77e1dfa11096b6b1567d09065b2265d7c6904560050c + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.8.13" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "40c2a6a0da15556dc0f8e38a3246064a971a9f512386c3339b89f76db87269b6" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.0" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: eb06fe30bab4c4497bad449b66448f50edcc695f1c59408e78aa3a8059eb8f0e + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.8.13" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: d58cd9d67793d52beefd6585b12050af0a7663c0c2a6ece0fb110a35d6955e04 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.2" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "9f143b0dba3e459553209e20cc425c9801af48e6dfa4f01a0fcf927be3f41665" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.11.0" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.2" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "10.0.9" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.1.1" + logger: + dependency: "direct main" + description: + name: logger + sha256: "55d6c23a6c15db14920e037fe7e0dc32e7cdaf3b64b4b25df2d541b5b6b81c0c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.6.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.0" + markdown: + dependency: transitive + description: + name: markdown + sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.3.0" + markdown_widget: + dependency: "direct main" + description: + name: markdown_widget + sha256: b52c13d3ee4d0e60c812e15b0593f142a3b8a2003cde1babb271d001a1dbdc1c + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2+8" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.16.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "1a97266a94f7350d30ae522c0af07890c70b8e62c71e8e3920d1db4d23c057d1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.1" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.8" + provider: + dependency: "direct main" + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.5+1" + remixicon: + dependency: "direct main" + description: + name: remixicon + sha256: "9a0e6a67d622a1d6ddc5e5cff4898f9711ec8880fc2ebeb720f6e0bc268ea905" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.1" + scroll_to_index: + dependency: transitive + description: + name: scroll_to_index + sha256: b707546e7500d9f070d63e5acf74fd437ec7eeeb68d3412ef7b0afada0b4f176 + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.1" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.3" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "5bcf0772a761b04f8c6bf814721713de6f3e5d9d89caf8d3fe031b02a342379e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.11" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.5.4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + sign_in_with_apple: + dependency: "direct main" + description: + name: sign_in_with_apple + sha256: "8bd875c8e8748272749eb6d25b896f768e7e9d60988446d543fe85a37a2392b8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.1" + sign_in_with_apple_platform_interface: + dependency: transitive + description: + name: sign_in_with_apple_platform_interface + sha256: "981bca52cf3bb9c3ad7ef44aace2d543e5c468bb713fd8dda4275ff76dfa6659" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + sign_in_with_apple_web: + dependency: transitive + description: + name: sign_in_with_apple_web + sha256: f316400827f52cafcf50d00e1a2e8a0abc534ca1264e856a81c5f06bd5b10fed + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.0" + skeletonizer: + dependency: "direct main" + description: + name: skeletonizer + sha256: eebc03dc86b298e2d7f61e0ebce5713e9dbbc3e786f825909b4591756f196eb6 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0+1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.7.4" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.4.0" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "0aedad096a85b49df2e4725fa32118f9fa580f3b14af7a2d2221896a02cd5656" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.17" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.4" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: c043a77d6600ac9c38300567f33ef12b0ef4f4783a2c1f00231d2b1941fea13f + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.3" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.4" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.0+2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + url: "https://pub.flutter-io.cn" + source: hosted + version: "15.0.0" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: c3e4fe614b1c814950ad07186007eff2f2e5dd2935eba7b9a9a1af8e5885f1ba + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.13.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "0a42444056b24ed832bdf3442d65c5194f6416f7e782152384944053c2ecc9a3" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.10.0" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "63d26ee3aca7256a83ccb576a50272edd7cfc80573a4305caa98985feb493ee0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.14.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: fb46db8216131a3e55bcf44040ca808423539bc6732e7ed34fb6d8044e3d512f + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.23.0" + win32: + dependency: transitive + description: + name: win32 + sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03" + url: "https://pub.flutter-io.cn" + source: hosted + version: "5.14.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.6.1" +sdks: + dart: ">=3.8.1 <4.0.0" + flutter: ">=3.31.0-0.0.pre" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..27a955a --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,43 @@ +name: food_health +description: "A new Flutter project." +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +version: 1.0.0 + +environment: + sdk: ^3.8.1 + +dependencies: + flutter: + sdk: flutter + + cupertino_icons: ^1.0.8 + shared_preferences: ^2.5.3 + dio: ^5.8.0+1 + go_router: ^16.0.0 + remixicon: ^1.4.1 + flutter_screenutil: ^5.9.3 + skeletonizer: ^2.1.0+1 + webview_flutter: ^4.13.0 + logger: ^2.6.1 + provider: ^6.1.5 + flutter_easyloading: ^3.0.5 + google_sign_in: ^7.1.1 + file_picker: ^10.3.2 + image_picker: ^1.2.0 + markdown_widget: ^2.3.2+8 + sign_in_with_apple: ^7.0.1 + flutter_image_compress: ^2.4.0 + + +dev_dependencies: + flutter_test: + sdk: flutter + + flutter_lints: ^5.0.0 + +flutter: + + uses-material-design: true + assets: + - assets/image/ \ No newline at end of file diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..763afe2 --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:food_health/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +}