commit bff1688ae2ec44510bbab16f1bb91a0ecb0c0146 Author: abilhabibillah Date: Fri Jul 18 14:12:39 2025 +0700 first commit 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..d77a4e0 --- /dev/null +++ b/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "c23637390482d4cf9598c3ce3f2be31aa7332daf" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: android + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: ios + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: linux + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: macos + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: web + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + - platform: windows + create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf + + # 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/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e909eeb --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# ta_running + +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..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options 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..b16a3a6 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,46 @@ +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") + id("com.google.gms.google-services") +} + +android { + namespace = "com.example.ta_running" + compileSdk = 34 + ndkVersion = "27.2.12479018" + + 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.example.ta_running" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = 23 + targetSdk = 34 + 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/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..4e20f05 --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "888886225940", + "project_id": "ta-running", + "storage_bucket": "ta-running.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:888886225940:android:c49c02701a3ce79804cb01", + "android_client_info": { + "package_name": "com.example.ta_running" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDcIQatv2KWTh96025wlFNEbH3xH2MK88k" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /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..f2924e7 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/example/ta_running/MainActivity.kt b/android/app/src/main/kotlin/com/example/ta_running/MainActivity.kt new file mode 100644 index 0000000..76bac6f --- /dev/null +++ b/android/app/src/main/kotlin/com/example/ta_running/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.ta_running + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-hdpi/splash.png b/android/app/src/main/res/drawable-hdpi/splash.png new file mode 100644 index 0000000..6b55ff2 Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-mdpi/splash.png b/android/app/src/main/res/drawable-mdpi/splash.png new file mode 100644 index 0000000..baa5d78 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-v21/background.png b/android/app/src/main/res/drawable-v21/background.png new file mode 100644 index 0000000..8e21404 Binary files /dev/null and b/android/app/src/main/res/drawable-v21/background.png differ 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..3cc4948 --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/android/app/src/main/res/drawable-xhdpi/splash.png b/android/app/src/main/res/drawable-xhdpi/splash.png new file mode 100644 index 0000000..ce6e657 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/splash.png b/android/app/src/main/res/drawable-xxhdpi/splash.png new file mode 100644 index 0000000..4c72bfc Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/splash.png b/android/app/src/main/res/drawable-xxxhdpi/splash.png new file mode 100644 index 0000000..7b321a1 Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable/background.png b/android/app/src/main/res/drawable/background.png new file mode 100644 index 0000000..8e21404 Binary files /dev/null and b/android/app/src/main/res/drawable/background.png differ 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..65d2889 --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/run.png b/android/app/src/main/res/drawable/run.png new file mode 100644 index 0000000..18ef13d Binary files /dev/null and b/android/app/src/main/res/drawable/run.png differ 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..7c4b32f 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-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..145f102 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..b5a04b4 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..d100921 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..6b55ff2 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-v31/styles.xml b/android/app/src/main/res/values-night-v31/styles.xml new file mode 100644 index 0000000..5fef228 --- /dev/null +++ b/android/app/src/main/res/values-night-v31/styles.xml @@ -0,0 +1,19 @@ + + + + + + + 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..dbc9ea9 --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/android/app/src/main/res/values-v31/styles.xml b/android/app/src/main/res/values-v31/styles.xml new file mode 100644 index 0000000..d0a68e9 --- /dev/null +++ b/android/app/src/main/res/values-v31/styles.xml @@ -0,0 +1,19 @@ + + + + + + + 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..0d1fa8f --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /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..3cd4270 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + // ... + + // Add the dependency for the Google services Gradle plugin + id("com.google.gms.google-services") version "4.3.15" apply false + +} + +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..afa1e8e --- /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\://services.gradle.org/distributions/gradle-8.10.2-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..9e2d35c --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,28 @@ +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.0" apply false + // START: FlutterFire Configuration + id("com.google.gms.google-services") version("4.3.15") apply false + // END: FlutterFire Configuration + id("org.jetbrains.kotlin.android") version "1.8.22" apply false +} + +include(":app") diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..9a5a800 --- /dev/null +++ b/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"android":{"default":{"projectId":"ta-running","appId":"1:888886225940:android:c49c02701a3ce79804cb01","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"ta-running","configurations":{"android":"1:888886225940:android:c49c02701a3ce79804cb01"}}}}}} \ No newline at end of file diff --git a/images/run.png b/images/run.png new file mode 100644 index 0000000..18ef13d Binary files /dev/null and b/images/run.png differ 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..9031830 --- /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.example.taRunning; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.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 = AppIcon; + 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 = AppIcon; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning; + 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..15cada4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..d0d98aa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1 @@ +{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}} \ No newline at end of file diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..ba3cc48 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..5877f15 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..19c670e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..e4f85db Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..0602e39 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..26e3e48 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..e94fd89 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..19c670e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..eb7088e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..9212007 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png new file mode 100644 index 0000000..06be540 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png new file mode 100644 index 0000000..393829e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png new file mode 100644 index 0000000..44d6489 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png new file mode 100644 index 0000000..9d70dae Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..9212007 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..5abaae3 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png new file mode 100644 index 0000000..7c4b32f Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png new file mode 100644 index 0000000..d100921 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..8016f7e Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..d1bb825 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..4bfbfbf Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json new file mode 100644 index 0000000..9f447e1 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchBackground.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "background.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png b/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.png new file mode 100644 index 0000000..8e21404 Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchBackground.imageset/background.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..00cabce --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "LaunchImage.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "LaunchImage@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "LaunchImage@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} 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..baa5d78 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..ce6e657 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..4c72bfc 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..89c2725 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ 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..7aa6dfb --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..1cffdcd --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,51 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Ta Running + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ta_running + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + UIStatusBarHidden + + + 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/app/routes.dart b/lib/app/routes.dart new file mode 100644 index 0000000..b9f78bb --- /dev/null +++ b/lib/app/routes.dart @@ -0,0 +1 @@ +// TODO Implement this library. \ No newline at end of file diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..7ace1e6 --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,62 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for ios - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyDcIQatv2KWTh96025wlFNEbH3xH2MK88k', + appId: '1:888886225940:android:c49c02701a3ce79804cb01', + messagingSenderId: '888886225940', + projectId: 'ta-running', + storageBucket: 'ta-running.firebasestorage.app', + ); +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..50fe1c8 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:ta_running/screens/splash_screen.dart'; +import 'package:intl/date_symbol_data_local.dart'; + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); + await initializeDateFormatting('id_ID', null); // locale Indonesia + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: const [ + Locale('id', ''), // Bahasa Indonesia + Locale('en', ''), // Bahasa Inggris (default backup) + ], + home: const SplashScreen(), + ); + } +} diff --git a/lib/routes.dart b/lib/routes.dart new file mode 100644 index 0000000..634bdf3 --- /dev/null +++ b/lib/routes.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; +import 'screens/splash_screen.dart'; +import 'screens/auth/login_screen.dart'; +import 'screens/auth/register_screen.dart'; + +final Map appRoutes = { + '/': (context) => SplashScreen(), + '/login': (context) => LoginScreen(), + '/register': (context) => RegisterScreen(), +}; diff --git a/lib/screens/all_activity_screen.dart b/lib/screens/all_activity_screen.dart new file mode 100644 index 0000000..a9a7a58 --- /dev/null +++ b/lib/screens/all_activity_screen.dart @@ -0,0 +1,135 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class AllActivityScreen extends StatelessWidget { + const AllActivityScreen({super.key}); + + Future>> fetchWeeklySummary() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return {}; + + final snapshot = await FirebaseFirestore.instance.collection('activities').get(); + final Map> weeklyData = {}; + + final allDays = ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']; + + for (var doc in snapshot.docs) { + final data = doc.data()['data']; + if (data == null || data['userId'] != user.uid) continue; + + final timestamp = (data['timestamp'] as Timestamp?)?.toDate(); + if (timestamp == null) continue; + + final weekStart = DateTime(timestamp.year, timestamp.month, timestamp.day) + .subtract(Duration(days: timestamp.weekday - 1)); + final weekKey = DateFormat('dd MMM yyyy').format(weekStart); + + final hari = DateFormat('EEEE', 'id_ID').format(timestamp); + final jarak = (data['jarak'] ?? 0).toDouble(); + final satuan = data['satuan'] ?? 'M'; + final jarakKm = satuan == 'M' ? jarak / 1000.0 : jarak; + + weeklyData.putIfAbsent(weekKey, () => { + for (var day in allDays) day: 0.0 + }); + + weeklyData[weekKey]![hari] = (weeklyData[weekKey]![hari] ?? 0) + jarakKm; + } + + return weeklyData; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: const Text("View All Weeks", style: TextStyle(color: Colors.white),), + automaticallyImplyLeading: true, + backgroundColor: Colors.blueAccent, + iconTheme: const IconThemeData(color: Colors.white), + ), + body: FutureBuilder>>( + future: fetchWeeklySummary(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + final data = snapshot.data ?? {}; + if (data.isEmpty) { + return const Center(child: Text("Belum ada data aktivitas lari.")); + } + + final sortedWeeks = data.keys.toList() + ..sort((a, b) => DateFormat('dd MMM yyyy').parse(b).compareTo(DateFormat('dd MMM yyyy').parse(a))); + + return ListView.builder( + itemCount: sortedWeeks.length, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + itemBuilder: (context, index) { + final week = sortedWeeks[index]; + final daysData = data[week]!; + final totalKm = daysData.values.fold(0.0, (a, b) => a + b); + + return Card( + color: Colors.white, + elevation: 3, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + margin: const EdgeInsets.only(bottom: 16), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + const Icon(Icons.calendar_today, size: 20, color: Colors.blue), + const SizedBox(width: 8), + Text( + 'Minggu dimulai: $week', + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + ], + ), + const SizedBox(height: 12), + Column( + children: daysData.entries.map((entry) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(entry.key, style: const TextStyle(fontSize: 14)), + Text('${entry.value.toStringAsFixed(2)} KM', + style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500)), + ], + ), + ); + }).toList(), + ), + const Divider(height: 24, thickness: 1), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + const Icon(Icons.directions_run, size: 18, color: Colors.green), + const SizedBox(width: 6), + Text( + 'Total: ${totalKm.toStringAsFixed(2)} KM', + style: const TextStyle(fontWeight: FontWeight.w600), + ), + ], + ), + ], + ), + ), + ); + }, + ); + }, + ), + ); + } +} diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart new file mode 100644 index 0000000..eaa5a03 --- /dev/null +++ b/lib/screens/auth/login_screen.dart @@ -0,0 +1,229 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:ta_running/screens/main_screen.dart'; // tetap sama +import 'register_screen.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:ta_running/screens/super_user_dashboard.dart'; // pastikan path sesuai + + +class LoginScreen extends StatefulWidget { + const LoginScreen({super.key}); + + @override + State createState() => _LoginScreenState(); +} + +class _LoginScreenState extends State { + final _formKey = GlobalKey(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + bool _obscurePassword = true; + + Future _login() async { + if (_formKey.currentState!.validate()) { + try { + final userCredential = await FirebaseAuth.instance.signInWithEmailAndPassword( + email: _emailController.text.trim(), + password: _passwordController.text.trim(), + ); + + final user = userCredential.user; + + if (user != null) { + final doc = await FirebaseFirestore.instance + .collection('users') + .doc(user.uid) + .get(); + + final role = doc.data()?['role'] ?? 'runner'; + + if (role == 'superuser') { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => SuperUserDashboard()), + (route) => false, + ); + } else { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => const MainScreen()), + (route) => false, + ); + } + } + } on FirebaseAuthException catch (e) { + String message = ''; + switch (e.code) { + case 'user-not-found': + message = 'Email tidak ditemukan. Silakan daftar terlebih dahulu.'; + break; + case 'wrong-password': + message = 'Password salah. Silakan coba lagi.'; + break; + case 'invalid-email': + message = 'Format email tidak valid.'; + break; + case 'user-disabled': + message = 'Akun ini telah dinonaktifkan.'; + break; + default: + message = 'Terjadi kesalahan saat login.'; + } + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message))); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Login gagal: ${e.toString()}"))); + } + } +} + + @override + Widget build(BuildContext context) { + final inputBorder = OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Colors.blueAccent), + ); + + return Scaffold( + backgroundColor: Colors.white, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(80), + child: Container( + decoration: const BoxDecoration( + color: Colors.blueAccent, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40), // untuk push tulisan agak ke bawah + child: const Center( + child: Text( + "Login", + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), + child: Form( + key: _formKey, + child: Column( + children: [ + // Logo di atas + Image.asset( + 'images/run.png', + width: 95, + height: 95, + fit: BoxFit.contain, + ), + + const SizedBox(height: 19), + + // Judul + Text( + 'Running', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Colors.black87, + fontWeight: FontWeight.bold, + ), + ), + + const SizedBox(height: 32), + + // Email input + TextFormField( + controller: _emailController, + decoration: InputDecoration( + labelText: "Email", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.email, color: Colors.blueAccent), + ), + keyboardType: TextInputType.emailAddress, + validator: (value) => value == null || value.isEmpty ? "Masukkan email" : null, + ), + + const SizedBox(height: 20), + + // Password input + TextFormField( + controller: _passwordController, + obscureText: _obscurePassword, + decoration: InputDecoration( + labelText: "Password", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.lock, color: Colors.blueAccent), + suffixIcon: IconButton( + icon: Icon(_obscurePassword ? Icons.visibility : Icons.visibility_off, color: Colors.blueAccent), + onPressed: () => setState(() => _obscurePassword = !_obscurePassword), + ), + ), + validator: (value) => value == null || value.isEmpty ? "Masukkan password" : null, + ), + + const SizedBox(height: 36), + + // Login Button full width + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _login, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 14), + backgroundColor: Colors.blueAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 5, + ), + child: const Text( + "Login", + style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + ), + + const SizedBox(height: 12), + + // Link ke Register + TextButton( + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const RegisterScreen()), + ), + child: RichText( + text: TextSpan( + children: [ + const TextSpan( + text: 'Belum punya akun? ', + style: TextStyle( + fontSize: 16, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + TextSpan( + text: 'Register', + style: const TextStyle( + fontSize: 16, + color: Colors.blueAccent, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/auth/register_screen.dart b/lib/screens/auth/register_screen.dart new file mode 100644 index 0000000..075ad52 --- /dev/null +++ b/lib/screens/auth/register_screen.dart @@ -0,0 +1,251 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:ta_running/screens/auth/login_screen.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; + +class RegisterScreen extends StatefulWidget { + const RegisterScreen({super.key}); + + @override + State createState() => _RegisterScreenState(); +} + +class _RegisterScreenState extends State { + final _formKey = GlobalKey(); + final _usernameController = TextEditingController(); + String? _selectedGender; + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + bool _obscurePassword = true; + + Future _register() async { + if (_formKey.currentState!.validate()) { + try { + final userCredential = await FirebaseAuth.instance.createUserWithEmailAndPassword( + email: _emailController.text.trim(), + password: _passwordController.text.trim(), + ); + // Simpan data tambahan ke Firestore + await FirebaseFirestore.instance.collection('users').doc(userCredential.user!.uid).set({ + 'username': _usernameController.text.trim(), + 'gender': _selectedGender, + 'email': _emailController.text.trim(), + 'role': 'runner', + }); + + // Arahkan ke login setelah berhasil + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => const LoginScreen()), + (route) => false, + ); + } on FirebaseAuthException catch (e) { + String message = ''; + if (e.code == 'email-already-in-use') { + message = 'Email sudah digunakan.'; + } else { + message = 'Registrasi gagal: ${e.message}'; + } + + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message))); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Registrasi gagal: ${e.toString()}"))); + } + } + } + + @override + Widget build(BuildContext context) { + final inputBorder = OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide(color: Colors.blueAccent), + ); + + return Scaffold( + backgroundColor: Colors.white, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(80), + child: Container( + decoration: const BoxDecoration( + color: Colors.blueAccent, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40), // untuk push tulisan agak ke bawah + child: const Center( + child: Text( + "Register", + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), + child: Form( + key: _formKey, + child: Column( + children: [ + // Logo di atas + Image.asset( + 'images/run.png', + width: 95, + height: 95, + fit: BoxFit.contain, + ), + + const SizedBox(height: 19), + + // Judul + Text( + 'Daftar Akun', + style: Theme.of(context).textTheme.headlineSmall?.copyWith( + color: Colors.black87, + fontWeight: FontWeight.bold, + ), + ), + + const SizedBox(height: 32), + + // Username + TextFormField( + controller: _usernameController, + decoration: InputDecoration( + labelText: "Username", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.person, color: Colors.blueAccent), + ), + validator: (value) => value == null || value.isEmpty ? "Masukkan username" : null, + ), + + const SizedBox(height: 20), + + // Gender Dropdown + DropdownButtonFormField( + decoration: InputDecoration( + labelText: "Gender", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.wc, color: Colors.blueAccent), + ), + value: _selectedGender, + items: const [ + DropdownMenuItem(value: 'Laki-laki', child: Text('Laki-laki')), + DropdownMenuItem(value: 'Perempuan', child: Text('Perempuan')), + ], + onChanged: (value) => setState(() => _selectedGender = value), + validator: (value) => value == null ? "Pilih gender" : null, + ), + + const SizedBox(height: 20), + + // Email + TextFormField( + controller: _emailController, + decoration: InputDecoration( + labelText: "Email", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.email, color: Colors.blueAccent), + ), + keyboardType: TextInputType.emailAddress, + validator: (value) { + if (value == null || value.isEmpty) return "Masukkan email"; + final emailRegex = RegExp(r"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"); + if (!emailRegex.hasMatch(value)) return "Format email tidak valid"; + return null; + }, + ), + + const SizedBox(height: 20), + + // Password + TextFormField( + controller: _passwordController, + obscureText: _obscurePassword, + decoration: InputDecoration( + labelText: "Password", + border: inputBorder, + focusedBorder: inputBorder.copyWith(borderSide: const BorderSide(color: Colors.blueAccent, width: 2)), + prefixIcon: const Icon(Icons.lock, color: Colors.blueAccent), + suffixIcon: IconButton( + icon: Icon(_obscurePassword ? Icons.visibility : Icons.visibility_off, color: Colors.blueAccent), + onPressed: () => setState(() => _obscurePassword = !_obscurePassword), + ), + ), + validator: (value) { + if (value == null || value.isEmpty) return "Masukkan password"; + if (!RegExp(r'^(?=.*[a-zA-Z])(?=.*\d).{6,}$').hasMatch(value)) { + return "Password harus kombinasi huruf & angka"; + } + return null; + }, + ), + + const SizedBox(height: 36), + + // Register Button + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: _register, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 14), + backgroundColor: Colors.blueAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 5, + ), + child: const Text( + "Daftar", + style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold), + ), + ), + ), + + const SizedBox(height: 12), + + // Link Login + TextButton( + onPressed: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const LoginScreen()), + ), + child: RichText( + text: TextSpan( + children: [ + const TextSpan( + text: 'Sudah punya akun? ', + style: TextStyle( + fontSize: 16, + color: Colors.black, + fontWeight: FontWeight.w400, + ), + ), + TextSpan( + text: 'Login', + style: const TextStyle( + fontSize: 16, + color: Colors.blueAccent, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/create_event_page.dart b/lib/screens/create_event_page.dart new file mode 100644 index 0000000..9379c94 --- /dev/null +++ b/lib/screens/create_event_page.dart @@ -0,0 +1,204 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; // Untuk mendapatkan email user yang login + +class CreateEventPage extends StatefulWidget { + @override + _CreateEventPageState createState() => _CreateEventPageState(); +} + +class _CreateEventPageState extends State { + final _nameController = TextEditingController(); + final _lapController = TextEditingController(); + final _formKey = GlobalKey(); // Tambahkan FormKey + + static const int MIN_LAPS = 3; // Konstanta untuk minimal putaran + + // Warna utama yang terinspirasi dari gambar Anda + final Color primaryBlue = Color(0xFF42A5F5); // Biru muda yang cerah + final Color lightBlue = Color(0xFFBBDEFB); // Biru yang lebih terang untuk background + final Color darkBlue = Color(0xFF1976D2); // Biru yang lebih gelap untuk teks/ikon + + void _createEvent() async { + // Validasi form secara keseluruhan + if (!_formKey.currentState!.validate()) { + return; // Hentikan jika ada error validasi + } + + final eventName = _nameController.text.trim(); + final totalLaps = int.parse(_lapController.text.trim()); // Sudah dipastikan valid oleh validator + + // Validasi tambahan untuk minimal putaran + if (totalLaps < MIN_LAPS) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Jumlah Putaran Tidak Valid', style: TextStyle(color: darkBlue)), + content: Text('Minimal jumlah putaran adalah $MIN_LAPS.', style: TextStyle(color: Colors.grey[800])), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text('OK', style: TextStyle(color: primaryBlue)), + ), + ], + ), + ); + return; // Hentikan proses jika putaran kurang dari minimal + } + + final totalDistance = totalLaps * 400; // 1 putaran = 400 meter + + String createdBy = 'unknown_user@example.com'; // Default value + User? currentUser = FirebaseAuth.instance.currentUser; + if (currentUser != null && currentUser.email != null) { + createdBy = currentUser.email!; + } else { + print("Peringatan: Email user tidak ditemukan. Menggunakan email default."); + } + + try { + await FirebaseFirestore.instance.collection('events').add({ + 'name': eventName, + 'created_at': Timestamp.now(), + 'created_by': createdBy, + 'start_status': false, + 'participants': {}, + 'total_laps': totalLaps, + 'total_distance': totalDistance, + 'type': 'track', + 'is_started_permanently': false, // Tambahkan field ini + 'is_finished_permanently': false, // Tambahkan field ini + }); + + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('Event "$eventName" berhasil dibuat ($totalLaps putaran = ${totalDistance / 1000} KM).'), + backgroundColor: Colors.green, // Warna hijau untuk sukses + )); + + Navigator.pop(context); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text('Gagal membuat event: $e'), + backgroundColor: Colors.red, // Warna merah untuk error + )); + print('Error creating event: $e'); + } + } + + @override + void dispose() { + _nameController.dispose(); + _lapController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey[50], // Background lembut + appBar: AppBar( + title: Text( + 'Buat Event Baru', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + centerTitle: true, + backgroundColor: primaryBlue, // Warna AppBar + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), // Sudut melengkung di kiri bawah + bottomRight: Radius.circular(20), // Sudut melengkung di kanan bawah + ), + ), + iconTheme: IconThemeData(color: Colors.white), // Warna ikon back + elevation: 5, // Tambahkan sedikit bayangan + ), + body: SingleChildScrollView( // Agar bisa di-scroll jika keyboard muncul + child: Padding( + padding: EdgeInsets.all(24), // Padding lebih besar + child: Form( // Wrap dengan Form widget + key: _formKey, // Pasang GlobalKey + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, // Agar elemen mengisi lebar + children: [ + Center( // Wrap dengan Center agar gambar di tengah + child: Image.asset( + 'images/run.png', // Path ke gambar logo Anda + height: 80, // Sesuaikan tinggi gambar + width: 80, // Sesuaikan lebar gambar + // Anda bisa menambahkan fit: BoxFit.contain, jika perlu + ), + ), + SizedBox(height: 24), + TextFormField( // Ganti TextField dengan TextFormField + controller: _nameController, + decoration: InputDecoration( + labelText: 'Nama Event', + hintText: 'Misal: Jember Marathon', + border: OutlineInputBorder( // Border melengkung + borderRadius: BorderRadius.circular(12), + ), + focusedBorder: OutlineInputBorder( // Warna border saat fokus + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide(color: primaryBlue, width: 2), + ), + // prefixIcon: Icon(Icons.event, color: primaryBlue), // Ikon + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Nama event tidak boleh kosong'; + } + return null; + }, + ), + SizedBox(height: 20), // Spasi antar input + TextFormField( // Ganti TextField dengan TextFormField + controller: _lapController, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: 'Jumlah Putaran (lap)', + hintText: 'Minimal 3 putaran', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: BorderSide(color: primaryBlue, width: 2), + ), + // prefixIcon: Icon(Icons.sports_score, color: primaryBlue), // Ikon + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Jumlah putaran tidak boleh kosong'; + } + final n = int.tryParse(value); + if (n == null || n <= 0) { + return 'Masukkan angka lebih dari 0'; + } + return null; + }, + ), + SizedBox(height: 32), // Spasi sebelum tombol + ElevatedButton.icon( + onPressed: _createEvent, + // icon: Icon(Icons.add_circle, color: Colors.white), + label: Text( + 'Buat Event', + style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold), + ), + style: ElevatedButton.styleFrom( + backgroundColor: primaryBlue, // Warna tombol biru + padding: EdgeInsets.symmetric(vertical: 16), // Padding lebih besar + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), // Sudut melengkung + ), + elevation: 5, // Bayangan tombol + ), + ), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/detail_hasil_screen.dart b/lib/screens/detail_hasil_screen.dart new file mode 100644 index 0000000..7646b0f --- /dev/null +++ b/lib/screens/detail_hasil_screen.dart @@ -0,0 +1,429 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class DetailHasilLariScreen extends StatefulWidget { + final Map data; + + const DetailHasilLariScreen({super.key, required this.data}); + + @override + State createState() => _DetailHasilLariScreenState(); +} + +class _DetailHasilLariScreenState extends State { + List kecepatanList = []; + bool loading = true; + + @override + void initState() { + super.initState(); + fetchLapData(); + } + + Future fetchLapData() async { + final jenis = widget.data['type']; + + // ===================== + // NON-LINTASAN + // ===================== + if (jenis == 'non-lintasan') { + final duration = widget.data['duration']; + final rawJarak = widget.data['jarak'] ?? widget.data['distance'] ?? 0.0; + final satuan = widget.data['satuan'] ?? 'M'; + final jarakKm = satuan == 'KM' ? rawJarak.toDouble() : rawJarak.toDouble() / 1000.0; + + if (duration is int && jarakKm > 0) { + final durSec = duration / 1000; + final pacePerKmSec = durSec / jarakKm; + + // Gunakan floor agar hanya simulasikan per-km (jangan 1.5 jadi 2) + List tempPaces = List.generate(jarakKm.floor(), (_) => pacePerKmSec); + + widget.data['pace_sec_per_km'] = pacePerKmSec; + + setState(() { + kecepatanList = tempPaces; + loading = false; + }); + return; + } + } + + // ===================== + // LINTASAN + // ===================== + final docId = widget.data['docId']; + final totalLaps = widget.data['putaran']; + + if (docId == null || totalLaps == null) { + setState(() => loading = false); + return; + } + + final doc = await FirebaseFirestore.instance.collection('activities').doc(docId).get(); + final laps = doc['data']['laps']; + + if (laps == null || laps is! Map) { + setState(() => loading = false); + return; + } + + final rawStart = widget.data['startTime']; + DateTime? startTime; + if (rawStart is Timestamp) { + startTime = rawStart.toDate(); + } else if (rawStart is int) { + startTime = DateTime.fromMillisecondsSinceEpoch(rawStart); + } + + final lapZero = laps['lap_0']; + DateTime? prevTime; + if (lapZero != null && lapZero['timestamp'] != null) { + prevTime = DateTime.parse(lapZero['timestamp']); + } else if (startTime != null) { + prevTime = startTime; + } + + List tempSpeeds = []; + final jarak = widget.data['jarak'] ?? 0; + final jarakPerLap = jarak / totalLaps; + + for (int i = 1; i <= totalLaps; i++) { + final lapData = laps['lap_$i']; + if (lapData == null || lapData['timestamp'] == null) continue; + + final timestamp = DateTime.parse(lapData['timestamp']); + + if (prevTime != null) { + final durationMs = timestamp.difference(prevTime).inMilliseconds; + + if (durationMs <= 0) { + tempSpeeds.add(0.0); + } else { + final speed = jarakPerLap / (durationMs / 1000); + tempSpeeds.add(speed); + } + } + + prevTime = timestamp; + } + + setState(() { + kecepatanList = tempSpeeds; + loading = false; + }); + } + + + void _confirmDelete(BuildContext context) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: const Text('Hapus Aktivitas?'), + content: const Text('Apakah kamu yakin ingin menghapus aktivitas ini?'), + actions: [ + TextButton( + onPressed: () => Navigator.pop(ctx), + child: const Text('Batal'), + ), + TextButton( + onPressed: () async { + Navigator.pop(ctx); + await _deleteActivity(context); + }, + child: const Text('Hapus', style: TextStyle(color: Colors.red)), + ), + ], + ), + ); + } + + Future _deleteActivity(BuildContext context) async { + try { + final docId = widget.data['docId']; + if (docId != null) { + await FirebaseFirestore.instance.collection('activities').doc(docId).delete(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Aktivitas berhasil dihapus')), + ); + Navigator.pop(context); + } else { + throw Exception('ID dokumen tidak ditemukan'); + } + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Gagal menghapus: $e')), + ); + } + } + + String getRunPeriodLabel(DateTime time) { + final hour = time.hour; + if (hour >= 6 && hour <= 10) { + return 'Berlari Pagi'; + } else if (hour >= 11 && hour <= 14) { + return 'Berlari Siang'; + } else if (hour >= 15 && hour <= 17) { + return 'Berlari Sore'; + } else { + return 'Berlari Malam'; + } +} + + @override + Widget build(BuildContext context) { + final data = widget.data; + final timestamp = (data['timestamp'] as Timestamp).toDate(); + final jenis = data['type'] == 'lintasan' ? 'Lintasan' : 'Non-Lintasan'; + final duration = data['duration']; + + DateTime? startTime; + final rawStart = data['startTime']; + if (rawStart is Timestamp) { + startTime = rawStart.toDate(); + } else if (rawStart is int) { + startTime = DateTime.fromMillisecondsSinceEpoch(rawStart); + } + + final formattedStart = startTime != null ? DateFormat('HH:mm:ss').format(startTime) : '-'; + + String durationFormatted = '-'; + if (duration is int) { + final d = Duration(milliseconds: duration); + durationFormatted = d.toString().split('.').first.padLeft(8, "0"); + } + + String? paceFormatted; + if (data['type'] == 'non-lintasan' && data['pace_sec_per_km'] != null) { + final paceSec = (data['pace_sec_per_km'] as num).toDouble(); + final paceMin = paceSec ~/ 60; + final paceSecRem = (paceSec % 60).round(); + paceFormatted = '$paceMin:${paceSecRem.toString().padLeft(2, '0')} /km'; + } + + final rawJarak = data['jarak'] ?? data['distance'] ?? 0.0; + final satuan = data['satuan'] ?? 'M'; + final jarakKm = satuan == 'KM' ? rawJarak.toDouble() : rawJarak.toDouble() / 1000.0; + final putaran = data['putaran']; + + return Scaffold( + appBar: PreferredSize( + preferredSize: const Size.fromHeight(100), + child: Container( + decoration: const BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40, left: 20, right: 20, bottom: 13), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white), + onPressed: () => Navigator.of(context).pop(), + ), + const Text( + "Detail Hasil Lari", + style: TextStyle( + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + IconButton( + icon: const Icon(Icons.delete, color: Colors.white), + tooltip: 'Hapus Aktivitas', + onPressed: () => _confirmDelete(context), + ), + ], + ), + ), + ), + backgroundColor: Colors.white, + body: Padding( + padding: const EdgeInsets.only(top: 30, left: 20, right: 20, bottom: 16), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue.shade300, Colors.blue.shade600], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(24), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), + offset: const Offset(0, 4), + blurRadius: 8, + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Center( + child: Text( + getRunPeriodLabel(timestamp), + style: const TextStyle( + fontSize: 26, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + const SizedBox(height: 4), + Text( + DateFormat('dd MMMM yyyy, HH:mm').format(timestamp), + style: const TextStyle(color: Colors.white70, fontSize: 14), + ), + const SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // KIRI + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + durationFormatted, + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + const Text('Durasi', style: TextStyle(color: Colors.white70)), + + if (data['type'] == 'non-lintasan' && paceFormatted != null) ...[ + const SizedBox(height: 12), + Text( + paceFormatted!, + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + const Text('Pace', style: TextStyle(color: Colors.white70)), + ], + + if (data['type'] == 'lintasan') ...[ + const SizedBox(height: 12), + Text( + '$putaran', + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + const Text('Putaran', style: TextStyle(color: Colors.white70)), + ], + ], + ), + + // KANAN + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + '${jarakKm.toStringAsFixed(2)} KM', + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + const Text('Jarak', style: TextStyle(color: Colors.white70)), + const SizedBox(height: 12), + Text( + jenis, + style: const TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 4), + const Text('Jenis Aktivitas', style: TextStyle(color: Colors.white70)), + ], + ), + ], + ), + + const SizedBox(height: 16), + ], + ), + ), + const SizedBox(height: 32), + if (data['type'] == 'lintasan') ...[ + const SizedBox(height: 32), + const Text("Splits Kecepatan", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), + const SizedBox(height: 12), + loading + ? const Center(child: CircularProgressIndicator()) + : kecepatanList.isEmpty + ? const Text("Data kecepatan tidak tersedia.") + : Column( + children: List.generate(kecepatanList.length, (index) { + final speed = kecepatanList[index]; + final maxSpeed = kecepatanList.reduce((a, b) => a > b ? a : b); + final barFraction = (speed / maxSpeed).clamp(0.0, 1.0); + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Row( + children: [ + SizedBox(width: 40, child: Text("Lap ${index + 1}", style: const TextStyle(fontSize: 14))), + const SizedBox(width: 8), + Expanded( + child: Stack( + children: [ + Container( + height: 20, + decoration: BoxDecoration( + color: Colors.grey.shade300, + borderRadius: BorderRadius.circular(6), + ), + ), + FractionallySizedBox( + widthFactor: barFraction, + child: Container( + height: 20, + decoration: BoxDecoration( + color: Colors.blueAccent, + borderRadius: BorderRadius.circular(6), + ), + ), + ), + ], + ), + ), + const SizedBox(width: 8), + Text("${speed.toStringAsFixed(2)} m/s", style: const TextStyle(fontSize: 14)), + ], + ), + ); + }), + ), + ], + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/edit_profile_screen.dart b/lib/screens/edit_profile_screen.dart new file mode 100644 index 0000000..6852a3d --- /dev/null +++ b/lib/screens/edit_profile_screen.dart @@ -0,0 +1,141 @@ +import 'package:flutter/material.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class EditProfileScreen extends StatefulWidget { + const EditProfileScreen({super.key}); + + @override + State createState() => _EditProfileScreenState(); +} + +class _EditProfileScreenState extends State { + final TextEditingController usernameController = TextEditingController(); + String? selectedGender; + bool isLoading = true; + + @override + void initState() { + super.initState(); + fetchUserData(); + } + + Future fetchUserData() async { + final user = FirebaseAuth.instance.currentUser; + if (user != null) { + final doc = await FirebaseFirestore.instance.collection('users').doc(user.uid).get(); + final data = doc.data(); + if (data != null) { + usernameController.text = data['username'] ?? ''; + selectedGender = data['gender'] ?? ''; + } + } + setState(() { + isLoading = false; + }); + } + + Future saveProfile() async { + final username = usernameController.text.trim(); + + if (username.isEmpty || username.length < 3) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Peringatan"), + content: const Text("Username minimal 3 karakter"), + actions: [ + TextButton( + child: const Text("OK"), + onPressed: () => Navigator.pop(context), + ), + ], + ), + ); + return; + } + + final user = FirebaseAuth.instance.currentUser; + if (user != null) { + await FirebaseFirestore.instance.collection('users').doc(user.uid).update({ + 'username': username, + 'gender': selectedGender, + }); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Profil berhasil diperbarui!'), + behavior: SnackBarBehavior.floating, + margin: EdgeInsets.all(50), + duration: Duration(seconds: 2), + ), + ); + + Navigator.pop(context, true); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: const Text('Edit profile', style: TextStyle(color: Colors.white),), + automaticallyImplyLeading: true, + backgroundColor: Colors.blueAccent, + iconTheme: const IconThemeData(color: Colors.white), + ), + body: isLoading + ? const Center(child: CircularProgressIndicator()) + : Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + const SizedBox(height: 20), + Card( + color: Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + elevation: 4, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + TextField( + controller: usernameController, + decoration: const InputDecoration(labelText: "Username"), + ), + const SizedBox(height: 16), + DropdownButtonFormField( + value: selectedGender, + items: const [ + DropdownMenuItem(value: 'Laki-laki', child: Text('Laki-laki')), + DropdownMenuItem(value: 'Perempuan', child: Text('Perempuan')), + ], + onChanged: (value) { + setState(() { + selectedGender = value; + }); + }, + decoration: const InputDecoration(labelText: "Jenis Kelamin"), + ), + ], + ), + ), + ), + const Spacer(), + ElevatedButton.icon( + onPressed: saveProfile, + icon: const Icon(Icons.save), + label: const Text("Simpan Perubahan"), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blueAccent, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/event_detail_page.dart b/lib/screens/event_detail_page.dart new file mode 100644 index 0000000..0ae8186 --- /dev/null +++ b/lib/screens/event_detail_page.dart @@ -0,0 +1,816 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:flutter/material.dart'; +import 'dart:async'; + +class EventDetailPage extends StatefulWidget { + final String eventId; + final String eventName; + + EventDetailPage({required this.eventId, required this.eventName}); + + @override + _EventDetailPageState createState() => _EventDetailPageState(); +} + +class _EventDetailPageState extends State { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + late FirebaseDatabase _rtdb; + late DatabaseReference _eventStatusRef; + late DatabaseReference _scanResultRef; + late DatabaseReference _eventActivityDataRef; + + // Map untuk menyimpan status finished dan current laps DARI RTDB (Hanya relevan saat event aktif) + Map _liveParticipantFinishedStatus = {}; + Map _liveParticipantCurrentLaps = {}; + + // Map untuk mapping UID RFID ke Firestore userId + Map _rfidUidToUserIdMap = {}; + + // List untuk menyimpan subscriptions agar bisa di-cancel saat dispose + final List _rtdbSubscriptions = []; + + // Variabel untuk menyimpan status event global dari RTDB (hanya untuk kontrol internal sementara) + bool _rtdbEventStarted = false; + bool _rtdbEventFinished = false; + + // StreamSubscription untuk Realtime Database listeners + StreamSubscription? _activityDataSubscription; + StreamSubscription? _finishedSubscription; + StreamSubscription? _lapsSubscription; + StreamSubscription? _scanResultSubscription; + + // Warna utama yang terinspirasi dari gambar Anda + final Color primaryBlue = Color(0xFF42A5F5); // Biru muda yang cerah + final Color lightBlue = Color(0xFFBBDEFB); // Biru yang lebih terang untuk background + final Color darkBlue = Color(0xFF1976D2); // Biru yang lebih gelap untuk teks/ikon + + @override + void initState() { + super.initState(); + + _rtdb = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + + _eventStatusRef = _rtdb.ref('event_status/${widget.eventId}'); + _scanResultRef = _rtdb.ref('scan_result/${widget.eventId}'); + _eventActivityDataRef = _rtdb.ref('event_activity_data/${widget.eventId}'); + + _preloadRfidToUserIdsMap().then((_) { + _listenToRealtimeEventStatus(); // Mendengarkan status global dari RTDB (untuk internal saja) + }); + } + + @override + void dispose() { + for (var subscription in _rtdbSubscriptions) { + subscription.cancel(); + } + super.dispose(); + } + + Future _preloadRfidToUserIdsMap() async { + try { + final eventDoc = await _firestore.collection('events').doc(widget.eventId).get(); + if (eventDoc.exists) { + final participantsData = eventDoc.data()?['participants'] as Map?; + if (participantsData != null) { + participantsData.forEach((userId, data) { + final rfidUid = data['rfid_uid'] as String?; + if (rfidUid != null) { + _rfidUidToUserIdMap[rfidUid] = userId; + } + }); + print("Preloaded RFID UID to User ID Map: $_rfidUidToUserIdMap"); + } + } + } catch (e) { + print("Error preloading RFID UID to User ID map: $e"); + } + } + + // Listener Realtime Database untuk status event global (hanya untuk tujuan internal) + void _listenToRealtimeEventStatus() { + _rtdbSubscriptions.add(_eventStatusRef.onValue.listen((event) async { + if (event.snapshot.exists && event.snapshot.value != null) { + final eventStatusData = event.snapshot.value as Map; + setState(() { + _rtdbEventStarted = eventStatusData['started'] ?? false; + _rtdbEventFinished = eventStatusData['finished'] ?? false; + }); + + // Ambil status permanen dari Firestore untuk perbandingan + final firestoreDoc = await _firestore.collection('events').doc(widget.eventId).get(); + final firestoreData = firestoreDoc.data(); + bool isEventFinishedPermanently = firestoreData?['is_finished_permanently'] ?? false; + + // Jika event baru saja selesai di RTDB oleh ESP32, dan belum di Firestore + if (_rtdbEventFinished && !isEventFinishedPermanently) { + _endEventPermanentlyFromRTDB(); + } + } else { + setState(() { + _rtdbEventStarted = false; + _rtdbEventFinished = false; + }); + } + print("Internal RTDB Event Status: Started=$_rtdbEventStarted, Finished=$_rtdbEventFinished"); + })); + } + + // Fungsi baru: jika RTDB menandakan selesai, dan Firestore belum, akhiri permanen + Future _endEventPermanentlyFromRTDB() async { + print("RTDB menandakan event selesai, mengakhiri secara permanen di Firestore."); + try { + await _firestore.collection('events').doc(widget.eventId).update({ + 'is_started_permanently': false, + 'is_finished_permanently': true, + }); + // Bersihkan RTDB setelah status permanen di Firestore diupdate + await _rtdb.ref('event_activity_data/${widget.eventId}').remove(); + await _rtdb.ref('event_status/${widget.eventId}').remove(); + await _rtdb.ref('scan_result/${widget.eventId}').remove(); + print("✅ Event diakhiri secara permanen di Firestore dan RTDB dibersihkan."); + } catch (e) { + print("❌ Gagal mengakhiri event secara permanen dari RTDB: $e"); + } + } + + // Fungsi untuk mengelola listener Realtime Database + void _manageRealtimeListeners(bool activate) { + if (activate) { + // Aktifkan listener aktivitas peserta jika belum ada + if (_activityDataSubscription == null) { + print("Mengaktifkan Realtime Database activity listeners..."); + // Gunakan onChildAdded untuk inisialisasi awal dan onChildChanged untuk update + _activityDataSubscription = _eventActivityDataRef.onChildAdded.listen((event) { + final uidTag = event.snapshot.key; + if (uidTag != null) { + // Subscribe ke 'finished' + _finishedSubscription = _eventActivityDataRef.child(uidTag).child('finished').onValue.listen((finishedEvent) async { + if (finishedEvent.snapshot.exists && finishedEvent.snapshot.value != null) { + final finished = finishedEvent.snapshot.value as bool; + setState(() { + _liveParticipantFinishedStatus[uidTag] = finished; + }); + final userId = _rfidUidToUserIdMap[uidTag]; + if (userId != null) { + try { + await _firestore.collection('events').doc(widget.eventId).update({ + 'participants.$userId.finished': finished, + }); + if (finished) { + final totalTimeSnapshot = await _eventActivityDataRef.child(uidTag).child('duration').get(); + if (totalTimeSnapshot.exists && totalTimeSnapshot.value != null) { + final totalTimeMs = totalTimeSnapshot.value as int; + String formattedTime = _formatDuration(Duration(milliseconds: totalTimeMs)); + await _firestore.collection('events').doc(widget.eventId).update({ + 'participants.$userId.total_time': formattedTime, + }); + } + } + } catch (e) { + print("❌ Gagal update Firestore participants.$userId.finished/total_time: $e"); + } + } + } + }); + _rtdbSubscriptions.add(_finishedSubscription!); + + // Subscribe ke 'laps' + _lapsSubscription = _eventActivityDataRef.child(uidTag).child('laps').onValue.listen((lapsEvent) async { + if (lapsEvent.snapshot.exists && lapsEvent.snapshot.value != null) { + final lapsData = lapsEvent.snapshot.value as Map; + final lapsCount = lapsData.length; + setState(() { + _liveParticipantCurrentLaps[uidTag] = lapsCount; + }); + final userId = _rfidUidToUserIdMap[uidTag]; + if (userId != null) { + try { + await _firestore.collection('events').doc(widget.eventId).update({ + 'participants.$userId.laps': lapsCount > 0 ? lapsCount - 1 : 0, + }); + + Map currentTimestamps = {}; + lapsData.forEach((key, value) { + if (value is Map && value.containsKey('timestamp')) { + currentTimestamps[key.toString()] = DateTime.parse(value['timestamp']); + } + }); + + Map lapDurations = {}; + final sortedKeys = currentTimestamps.keys.toList()..sort((a, b) => a.compareTo(b)); + + for (int i = 1; i < sortedKeys.length; i++) { + final prevTimestamp = currentTimestamps[sortedKeys[i - 1]]; + final currentTimestamp = currentTimestamps[sortedKeys[i]]; + if (prevTimestamp != null && currentTimestamp != null) { + final durationSeconds = currentTimestamp.difference(prevTimestamp).inMilliseconds / 1000.0; + lapDurations['lap_${i}'] = durationSeconds; + } + } + + if (lapDurations.isNotEmpty) { + await _firestore.collection('events').doc(widget.eventId).update({ + 'participants.$userId.lap_durations': lapDurations, + }); + } + } catch (e) { + print("❌ Gagal update Firestore participants.$userId.laps atau lap_durations: $e"); + } + } + } + }); + _rtdbSubscriptions.add(_lapsSubscription!); + } + }); + _rtdbSubscriptions.add(_activityDataSubscription!); + } + + // Aktifkan listener scan RFID jika belum aktif + if (_scanResultSubscription == null) { + print("Mengaktifkan scan_result listener..."); + final scanRef = _rtdb.ref('scan_result/${widget.eventId}'); + _scanResultSubscription = scanRef.onChildAdded.listen((event) { + final scannedUID = event.snapshot.key; + final value = event.snapshot.value; + if (scannedUID != null && value == true) { + processUID(scannedUID, widget.eventId); + } + }); + _rtdbSubscriptions.add(_scanResultSubscription!); + // Panggil processUID untuk data yang sudah ada saat ini juga (saat listener diaktifkan) + scanRef.get().then((snapshot) { + if (snapshot.exists) { + final data = snapshot.value as Map; + data.forEach((key, value) { + if (value == true) { + processUID(key, widget.eventId); + } + }); + } + }); + } + } else { + // Nonaktifkan semua listener jika event tidak dimulai secara permanen atau sudah selesai + print("Menonaktifkan Realtime Database listeners..."); + _activityDataSubscription?.cancel(); + _finishedSubscription?.cancel(); + _lapsSubscription?.cancel(); + _scanResultSubscription?.cancel(); + + // Set semua subscription ke null agar bisa diinisialisasi ulang + _activityDataSubscription = null; + _finishedSubscription = null; + _lapsSubscription = null; + _scanResultSubscription = null; + + // Juga kosongkan data live RTDB jika listener dimatikan + _liveParticipantFinishedStatus.clear(); + _liveParticipantCurrentLaps.clear(); + } + } + + String _formatDuration(Duration duration) { + String twoDigits(int n) => n.toString().padLeft(2, "0"); + String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60)); + String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60)); + String threeDigitMilliseconds = (duration.inMilliseconds.remainder(1000)).toString().padLeft(3, "0"); + return "${twoDigits(duration.inHours)}:$twoDigitMinutes:$twoDigitSeconds.$threeDigitMilliseconds"; + } + + void processUID(String scannedUID, String eventId) async { + print("🔍 Mencari user dengan idGelang = '$scannedUID'"); + + final querySnapshot = await _firestore + .collection('users') + .where('idGelang', isEqualTo: scannedUID.trim()) + .limit(1) + .get(); + + if (querySnapshot.docs.isEmpty) { + print('❌ UID $scannedUID tidak ditemukan di Firestore.'); + return; + } + + final userDoc = querySnapshot.docs.first; + final userId = userDoc.id; + final userData = userDoc.data(); + + _rfidUidToUserIdMap[scannedUID] = userId; + print("Mapped RFID UID $scannedUID to User ID $userId"); + + final eventRef = _firestore.collection('events').doc(eventId); + final eventSnapshot = await eventRef.get(); + + Map participants = eventSnapshot.data()?['participants'] ?? {}; + Map existing = participants[userId] ?? {}; + + final participantData = { + 'name': userData['username'] ?? existing['name'] ?? '-', + 'user_id': userId, + 'rfid_uid': scannedUID, + 'laps': existing['laps'] ?? 0, + 'finished': existing['finished'] ?? false, + 'total_time': existing['total_time'] ?? '-', + 'lap_durations': existing['lap_durations'] ?? {}, + }; + + await eventRef.update({ + 'participants.$userId': participantData, + }); + + print("🎉 Peserta ${participantData['name']} berhasil dimasukkan/diupdate di event $eventId di Firestore."); + } + + @override + Widget build(BuildContext context) { + final docRef = _firestore.collection('events').doc(widget.eventId); + + return Scaffold( + backgroundColor: Colors.grey[50], // Background lembut + body: StreamBuilder( + stream: docRef.snapshots(), + builder: (context, firestoreSnapshot) { + if (!firestoreSnapshot.hasData) { + return Center(child: CircularProgressIndicator(color: primaryBlue)); + } + if (firestoreSnapshot.hasError) { + return Center(child: Text('Error: ${firestoreSnapshot.error}', style: TextStyle(color: Colors.red))); + } + + final firestoreData = firestoreSnapshot.data!.data() as Map?; + + if (firestoreData == null) { + return Center(child: Text('Data event tidak ditemukan di Firestore.')); + } + + // Ambil status permanen dari Firestore + bool isEventStartedPermanently = firestoreData['is_started_permanently'] ?? false; + bool isEventFinishedPermanently = firestoreData['is_finished_permanently'] ?? false; + + // Kelola listener RTDB berdasarkan status permanen event + WidgetsBinding.instance.addPostFrameCallback((_) { + _manageRealtimeListeners(isEventStartedPermanently && !isEventFinishedPermanently); + }); + + // Logic untuk menentukan status yang ditampilkan di UI + String displayEventStatusText; + Color displayEventStatusColor; + if (isEventFinishedPermanently) { + displayEventStatusText = "Sudah Selesai Permanen"; + displayEventStatusColor = Colors.green.shade700; + } else if (isEventStartedPermanently) { + displayEventStatusText = "Sedang Berlangsung"; + displayEventStatusColor = Colors.orange.shade700; + } else { + displayEventStatusText = "Belum Dimulai"; + displayEventStatusColor = Colors.red.shade700; + } + + + final totalLaps = firestoreData['total_laps'] ?? 0; + final totalDistance = firestoreData['total_distance'] ?? 0; + final createdBy = firestoreData['created_by'] ?? '-'; + final createdAt = firestoreData['created_at'] != null + ? (firestoreData['created_at'] as Timestamp).toDate() + : null; + + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 180.0, // Tinggi AppBar saat expanded + floating: false, + pinned: true, // AppBar tetap terlihat saat scroll + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), // Sudut melengkung di kiri bawah + bottomRight: Radius.circular(20), // Sudut melengkung di kanan bawah + ), + ), + backgroundColor: primaryBlue, // Warna dasar AppBar + flexibleSpace: FlexibleSpaceBar( + centerTitle: true, + titlePadding: EdgeInsets.only(bottom: 16.0, left: 16.0, right: 16.0), + // Pastikan background juga melengkung + background: ClipRRect( // Tambahkan ClipRRect di sini + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [primaryBlue, darkBlue], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: Center( + child: Padding( + padding: const EdgeInsets.only(top: 24.0), // Beri sedikit padding atas agar tidak terlalu mepet + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.event, + color: Colors.white, + size: 48, + ), + SizedBox(height: 8), + Text( + widget.eventName, + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Colors.white, + shadows: [ + Shadow( + blurRadius: 4.0, + color: Colors.black.withOpacity(0.3), + offset: Offset(1.0, 1.0), + ), + ], + ), + textAlign: TextAlign.center, + ), + SizedBox(height: 4), + Text( + "${totalLaps} Putaran | ${(totalDistance / 1000).toStringAsFixed(2)} KM", + style: TextStyle( + fontSize: 14, + color: Colors.white.withOpacity(0.8), + ), + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ), + ), + ), + actions: [ + IconButton( + icon: Icon(Icons.delete_forever, color: Colors.white), + tooltip: 'Hapus Event', + onPressed: () async { + final confirm = await showDialog( + context: context, + builder: (_) => AlertDialog( + title: Text('Konfirmasi Hapus', style: TextStyle(color: darkBlue)), + content: Text('Apakah Anda yakin ingin menghapus event "${widget.eventName}" dan semua datanya?', style: TextStyle(color: Colors.grey[800])), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: Text('Batal', style: TextStyle(color: primaryBlue)), + ), + TextButton( + onPressed: () => Navigator.pop(context, true), + child: Text('Hapus', style: TextStyle(color: Colors.red)), + ), + ], + ), + ); + + if (confirm == true) { + await docRef.delete(); + await _rtdb.ref('event_activity_data/${widget.eventId}').remove(); + await _rtdb.ref('event_status/${widget.eventId}').remove(); + await _rtdb.ref('scan_result/${widget.eventId}').remove(); + + Navigator.pop(context); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Event "${widget.eventName}" telah dihapus.')), + ); + } + }, + ), + ], + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Informasi Detail Event + Card( + elevation: 4, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + color: Colors.white, // CARD PUTIH + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildInfoRow(Icons.person, "Dibuat oleh", createdBy), + SizedBox(height: 8), + if (createdAt != null) + _buildInfoRow( + Icons.calendar_today, + "Tanggal dibuat", + "${createdAt.day}/${createdAt.month}/${createdAt.year} ${createdAt.hour.toString().padLeft(2, '0')}:${createdAt.minute.toString().padLeft(2, '0')}", + ), + SizedBox(height: 16), + Divider(color: Colors.grey[300]), + SizedBox(height: 16), + Text("Status Event", style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: darkBlue)), + SizedBox(height: 8), + Row( + children: [ + Icon(Icons.play_circle_outline, size: 20, color: Colors.grey[700]), + SizedBox(width: 8), + Text( + displayEventStatusText, // Teks status baru + style: TextStyle( + fontSize: 15, + color: displayEventStatusColor, // Warna status baru + fontWeight: FontWeight.w600, + ), + ), + ], + ), + SizedBox(height: 4), + Row( + children: [ + Icon(Icons.check_circle_outline, size: 20, color: Colors.grey[700]), + SizedBox(width: 8), + Text( + "Selesai Permanen: ${isEventFinishedPermanently ? 'Ya ✅' : 'Tidak ❌'}", + style: TextStyle( + fontSize: 15, + color: isEventFinishedPermanently ? Colors.green.shade700 : Colors.red.shade700, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + SizedBox(height: 24), + + // Tombol Mulai Event + SizedBox( + width: double.infinity, + child: ElevatedButton.icon( + onPressed: (isEventStartedPermanently || isEventFinishedPermanently) + ? null + : () async { + final confirm = await showDialog( + context: context, + builder: (_) => AlertDialog( + title: Text('Mulai Event', style: TextStyle(color: darkBlue)), + content: Text('Peserta akan mulai scan RFID untuk event ini.', style: TextStyle(color: Colors.grey[800])), + actions: [ + TextButton(onPressed: () => Navigator.pop(context, false), child: Text('Batal', style: TextStyle(color: primaryBlue))), + TextButton(onPressed: () => Navigator.pop(context, true), child: Text('Mulai', style: TextStyle(color: Colors.green))), + ], + ), + ); + + if (confirm == true) { + final currentEventData = await docRef.get(); + final currentTotalLaps = (currentEventData.data() as Map?)?['total_laps'] ?? 0; + + await docRef.update({ + 'is_started_permanently': true, + 'is_finished_permanently': false, + 'start_time': Timestamp.now(), + }).catchError((e) { + print("❌ Gagal update Firestore: $e"); + }); + + await _eventStatusRef.set({ + 'started': true, + 'scan_mode': true, + 'timestamp': ServerValue.timestamp, + 'total_laps_target': currentTotalLaps, + 'finished': false, + }); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Event dimulai. Peserta dapat scan RFID sekarang.')), + ); + } + }, + icon: Icon(Icons.play_arrow, color: Colors.white), + label: Text( + 'Mulai Event (Scan RFID)', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + style: ElevatedButton.styleFrom( + backgroundColor: (isEventStartedPermanently || isEventFinishedPermanently) ? Colors.grey : Colors.green.shade600, + padding: EdgeInsets.symmetric(vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + elevation: 3, + ), + ), + ), + + // Tombol Akhiri Event Manual + if (isEventStartedPermanently && !isEventFinishedPermanently) + Padding( + padding: const EdgeInsets.only(top: 12.0), + child: SizedBox( + width: double.infinity, + child: ElevatedButton.icon( + onPressed: () async { + final confirm = await showDialog( + context: context, + builder: (_) => AlertDialog( + title: Text('Akhiri Event', style: TextStyle(color: darkBlue)), + content: Text('Apakah Anda yakin ingin mengakhiri event ini secara manual? Status event akan permanen selesai dan data Realtime akan dihapus.', style: TextStyle(color: Colors.grey[800])), + actions: [ + TextButton(onPressed: () => Navigator.pop(context, false), child: Text('Batal', style: TextStyle(color: primaryBlue))), + TextButton(onPressed: () => Navigator.pop(context, true), child: Text('Akhiri', style: TextStyle(color: Colors.red))), + ], + ), + ); + + if (confirm == true) { + await docRef.update({ + 'is_started_permanently': false, + 'is_finished_permanently': true, + }); + + await _rtdb.ref('event_activity_data/${widget.eventId}').remove(); + await _rtdb.ref('event_status/${widget.eventId}').remove(); + await _rtdb.ref('scan_result/${widget.eventId}').remove(); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Event telah diakhiri secara manual dan disimpan secara permanen.')), + ); + } + }, + icon: Icon(Icons.stop, color: Colors.white), + label: Text( + 'Akhiri Event Manual', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red.shade600, + padding: EdgeInsets.symmetric(vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + elevation: 3, + ), + ), + ), + ), + ], + ), + ), + ), + SizedBox(height: 24), + Text("Peserta Event:", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: darkBlue)), + SizedBox(height: 1), + ], + ), + ), + ), + // Daftar Peserta + SliverPadding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + sliver: ((firestoreData['participants'] as Map?)?.entries.isNotEmpty ?? false) + ? SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + final participantEntry = (firestoreData['participants'] as Map).entries.toList()[index]; + final participant = participantEntry.value; + final name = participant['name'] ?? 'Nama tidak ditemukan'; + final rfidUid = participant['rfid_uid'] as String?; + + bool participantFinishedDisplay; + int participantLapsDisplay; + String participantTotalTimeDisplay = participant['total_time'] ?? '-'; + + // Prioritaskan data live (RTDB) jika event sedang berjalan (permanen) + if (isEventStartedPermanently && !isEventFinishedPermanently && _liveParticipantFinishedStatus.containsKey(rfidUid)) { + participantFinishedDisplay = _liveParticipantFinishedStatus[rfidUid]!; + } else { + participantFinishedDisplay = participant['finished'] ?? false; // Ambil dari Firestore + } + + if (isEventStartedPermanently && !isEventFinishedPermanently && _liveParticipantCurrentLaps.containsKey(rfidUid)) { + participantLapsDisplay = _liveParticipantCurrentLaps[rfidUid]! > 0 ? _liveParticipantCurrentLaps[rfidUid]! - 1 : 0; + } else { + participantLapsDisplay = participant['laps'] ?? 0; // Ambil dari Firestore + } + + return Card( + margin: EdgeInsets.symmetric(vertical: 8), + elevation: 4, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + color: Colors.white, // CARD PUTIH + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name, + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + ), + SizedBox(height: 8), + _buildParticipantInfoRow(Icons.credit_card, "UID RFID", rfidUid ?? 'N/A'), + _buildParticipantInfoRow(Icons.sports_score, "Putaran", "$participantLapsDisplay"), + _buildParticipantInfoRow( + Icons.flag, + "Selesai", + participantFinishedDisplay ? 'Ya ✅' : 'Tidak ❌', + valueColor: participantFinishedDisplay ? Colors.green.shade700 : Colors.red.shade700, + ), + if (participantFinishedDisplay && participantTotalTimeDisplay != '-') + _buildParticipantInfoRow( + Icons.timer, + "Waktu Total", + participantTotalTimeDisplay, + valueColor: darkBlue, + ), + ], + ), + ), + ); + }, + childCount: (firestoreData['participants'] as Map).length, + ), + ) + : SliverToBoxAdapter( + child: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + "Belum ada peserta yang terdaftar untuk event ini.", + style: TextStyle(fontSize: 16, color: Colors.grey[600]), + textAlign: TextAlign.center, + ), + ), + ), + ), + ), + SliverToBoxAdapter( + child: SizedBox(height: 24), // Tambahan spasi di bagian bawah + ), + ], + ); + }, + ), + ); + } + + // Helper widget untuk baris informasi event + Widget _buildInfoRow(IconData icon, String label, String value) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(icon, size: 20, color: primaryBlue), + SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Colors.grey[700]), + ), + Text( + value, + style: TextStyle(fontSize: 15, color: Colors.grey[900]), + ), + ], + ), + ), + ], + ); + } + + // Helper widget untuk baris informasi peserta + Widget _buildParticipantInfoRow(IconData icon, String label, String value, {Color? valueColor}) { + return Padding( + padding: const EdgeInsets.only(bottom: 4.0), + child: Row( + children: [ + Icon(icon, size: 16, color: Colors.grey[600]), + SizedBox(width: 8), + Text( + "$label: ", + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + Expanded( + child: Text( + value, + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: valueColor ?? darkBlue), + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/event_result_page.dart b/lib/screens/event_result_page.dart new file mode 100644 index 0000000..4c94550 --- /dev/null +++ b/lib/screens/event_result_page.dart @@ -0,0 +1,379 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:intl/intl.dart'; + +class EventResultPage extends StatelessWidget { + final String eventId; + final String eventName; + + EventResultPage({required this.eventId, required this.eventName}); + + final Color primaryBlue = Color(0xFF42A5F5); + final Color lightBlue = Color(0xFFBBDEFB); + final Color darkBlue = Color(0xFF1976D2); + final Color successGreen = Colors.green.shade700; + final Color warningOrange = Colors.orange.shade700; + final Color dangerRed = Colors.red.shade700; + + @override + Widget build(BuildContext context) { + final docRef = FirebaseFirestore.instance.collection('events').doc(eventId); + + return Scaffold( + backgroundColor: Colors.grey[50], + appBar: AppBar( + title: Text( + 'Hasil Event: $eventName', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + centerTitle: true, + backgroundColor: primaryBlue, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + iconTheme: IconThemeData(color: Colors.white), + elevation: 5, + ), + body: StreamBuilder( + stream: docRef.snapshots(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center(child: CircularProgressIndicator(color: primaryBlue)); + } + if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}', style: TextStyle(color: dangerRed))); + } + if (!snapshot.hasData || !snapshot.data!.exists) { + return Center(child: Text('Event tidak ditemukan.', style: TextStyle(color: Colors.grey[600]))); + } + + final data = snapshot.data!.data() as Map?; + + if (data == null || data['participants'] == null) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.people_alt_outlined, size: 60, color: Colors.grey[400]), + SizedBox(height: 16), + Text('Belum ada peserta yang terdaftar untuk event ini.', style: TextStyle(fontSize: 16, color: Colors.grey[600])), + ], + ), + ); + } + + final participants = data['participants'] as Map; + + if (participants.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.people_alt_outlined, size: 60, color: Colors.grey[400]), + SizedBox(height: 16), + Text('Belum ada peserta yang terdaftar untuk event ini.', style: TextStyle(fontSize: 16, color: Colors.grey[600])), + ], + ), + ); + } + + List> sortedParticipants = participants.entries.toList(); + sortedParticipants.sort((a, b) { + final pA = a.value as Map; + final pB = b.value as Map; + + final finishedA = pA['finished'] == true; + final finishedB = pB['finished'] == true; + + if (finishedA && !finishedB) return -1; + if (!finishedA && finishedB) return 1; + + if (finishedA && finishedB) { + final timeA = _parseTimeToSeconds(pA['total_time']); + final timeB = _parseTimeToSeconds(pB['total_time']); + return timeA.compareTo(timeB); + } + + final lapsA = pA['laps'] ?? 0; + final lapsB = pB['laps'] ?? 0; + return lapsB.compareTo(lapsA); + }); + + + return ListView.builder( + padding: EdgeInsets.all(16), + itemCount: sortedParticipants.length, + itemBuilder: (context, index) { + final entry = sortedParticipants[index]; + final p = entry.value as Map; + + final name = p['name'] ?? 'Peserta Tidak Dikenal'; + final laps = p['laps'] ?? 0; + final finished = p['finished'] == true; + final totalTime = p['total_time'] ?? '-'; + final rfidUid = p['rfid_uid'] ?? '-'; + final lapDurations = p['lap_durations'] as Map? ?? {}; + + String participantStatus = finished ? 'Selesai' : 'Berlangsung'; + Color participantStatusColor = finished ? successGreen : warningOrange; + + String formattedTotalTime = '-'; + if (finished && totalTime != '-') { + try { + final duration = Duration(milliseconds: _parseMilliseconds(totalTime)); + formattedTotalTime = _formatDuration(duration); + } catch (e) { + formattedTotalTime = totalTime; + } + } + + List kecepatanWidgets = []; + final sortedLapKeys = lapDurations.keys.toList()..sort((a, b) { + final intA = int.parse(a.split('_')[1]); + final intB = int.parse(b.split('_')[1]); + return intA.compareTo(intB); + }); + + for (String lapKey in sortedLapKeys) { + final dynamic durasiDetikRaw = lapDurations[lapKey]; + double durasiDetik = 0.0; + if (durasiDetikRaw is int) { + durasiDetik = durasiDetikRaw.toDouble(); + } else if (durasiDetikRaw is double) { + durasiDetik = durasiDetikRaw; + } + + String formattedDuration = '${durasiDetik.toStringAsFixed(2)} s'; + + if (durasiDetik > 0) { + final kecepatan = 400 / durasiDetik; + kecepatanWidgets.add( + Row( + children: [ + SizedBox(width: 24), + Text( + "Lap ${lapKey.split('_')[1]}: ${kecepatan.toStringAsFixed(2)} m/s ", + style: TextStyle(fontSize: 13, color: Colors.grey[800]), + ), + Text( + "($formattedDuration)", + style: TextStyle(fontSize: 12, color: Colors.grey[600]), + ), + ], + ), + ); + } else { + kecepatanWidgets.add( + Padding( + padding: const EdgeInsets.only(left: 24.0), + child: Text( + "Lap ${lapKey.split('_')[1]}: Durasi tidak valid", + style: TextStyle(fontSize: 13, color: Colors.grey[500], fontStyle: FontStyle.italic), + ), + ), + ); + } + } + + return Card( + margin: EdgeInsets.only(bottom: 16), + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text( + name, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + overflow: TextOverflow.ellipsis, + ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: participantStatusColor.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + participantStatus, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: participantStatusColor, + ), + ), + ), + ], + ), + SizedBox(height: 8), + Divider(color: Colors.grey[200]), + SizedBox(height: 8), + _buildInfoRow("RFID Tag", rfidUid, darkBlue), + _buildInfoRow("Putaran Selesai", "$laps", darkBlue), + if (finished) _buildInfoRow("Waktu Total", formattedTotalTime, darkBlue), + + if (kecepatanWidgets.isNotEmpty) ...[ + SizedBox(height: 12), + Text( + "Detail Kecepatan per Lap:", + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + ), + SizedBox(height: 8), + ...kecepatanWidgets, + ], + + // Tombol hapus peserta + SizedBox(height: 16), + Align( + alignment: Alignment.centerRight, + child: IconButton( // <-- DIUBAH DARI TextButton.icon MENJADI IconButton + icon: Icon(Icons.delete_outline, color: dangerRed, size: 24), // Ukuran ikon diperbesar sedikit + tooltip: 'Hapus Peserta', // Tooltip tetap ada saat ditekan lama + onPressed: () async { + final confirm = await showDialog( + context: context, + builder: (_) => AlertDialog( + title: Text('Konfirmasi Hapus Peserta', style: TextStyle(color: dangerRed)), + content: Text('Apakah Anda yakin ingin menghapus peserta "$name" dari event ini?', style: TextStyle(color: Colors.grey[800])), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: Text('Batal', style: TextStyle(color: primaryBlue)), + ), + TextButton( + onPressed: () => Navigator.pop(context, true), + child: Text('Hapus', style: TextStyle(color: dangerRed)), + ), + ], + ), + ); + + if (confirm == true) { + try { + await docRef.update({ + 'participants.${entry.key}': FieldValue.delete(), + }); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Peserta "$name" berhasil dihapus.'), backgroundColor: Colors.green), + ); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Gagal menghapus peserta: $e'), backgroundColor: Colors.red), + ); + print('Error deleting participant: $e'); + } + } + }, + ), + ), + ], + ), + ), + ); + }, + ); + }, + ), + ); + } + + // Helper widget untuk baris informasi yang clean tanpa ikon + Widget _buildInfoRow(String label, String value, Color valueColor) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 2, + child: Text( + "$label:", + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14, color: Colors.grey[700]), + ), + ), + Expanded( + flex: 3, + child: Text( + value, + style: TextStyle(fontSize: 15, color: valueColor), + overflow: TextOverflow.ellipsis, + ), + ), + ], + ), + ); + } + + // Helper untuk parsing waktu (misal "00:01:23.456" menjadi milidetik) + int _parseMilliseconds(String timeString) { + if (timeString == '-') return 0; + + final parts = timeString.split(':'); + if (parts.length < 3) return 0; // Invalid format + + int hours = int.parse(parts[0]); + int minutes = int.parse(parts[1]); + double secondsWithMs = double.parse(parts[2]); + + int totalMilliseconds = ((hours * 3600 + minutes * 60 + secondsWithMs) * 1000).toInt(); + return totalMilliseconds; + } + + // Helper untuk format total_time dari milidetik + String _formatDuration(Duration duration) { + String twoDigits(int n) => n.toString().padLeft(2, "0"); + String threeDigits(int n) => n.toString().padLeft(3, "0"); + + String minutes = twoDigits(duration.inMinutes.remainder(60)); + String seconds = twoDigits(duration.inSeconds.remainder(60)); + String milliseconds = threeDigits(duration.inMilliseconds.remainder(1000)); + String hours = twoDigits(duration.inHours); + + if (duration.inHours > 0) { + return "$hours:$minutes:$seconds.$milliseconds"; + } else { + return "$minutes:$seconds.$milliseconds"; + } + } + + // Helper untuk mengonversi string waktu (HH:MM:SS.ms) ke total detik (untuk sorting) + double _parseTimeToSeconds(String timeString) { + if (timeString == '-') return double.infinity; + + try { + final parts = timeString.split(':'); + if (parts.length != 3) return double.infinity; + + final hours = int.parse(parts[0]); + final minutes = int.parse(parts[1]); + final secondsParts = parts[2].split('.'); + final seconds = int.parse(secondsParts[0]); + final milliseconds = secondsParts.length > 1 ? int.parse(secondsParts[1]) : 0; + + return (hours * 3600 + minutes * 60 + seconds + milliseconds / 1000).toDouble(); + } catch (e) { + return double.infinity; + } + } +} \ No newline at end of file diff --git a/lib/screens/hasil_event_page.dart b/lib/screens/hasil_event_page.dart new file mode 100644 index 0000000..9f767e1 --- /dev/null +++ b/lib/screens/hasil_event_page.dart @@ -0,0 +1,214 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'event_result_page.dart'; // Import halaman hasil peserta + +class HasilEventPage extends StatelessWidget { + // Warna utama yang terinspirasi dari gambar Anda + final Color primaryBlue = Color(0xFF42A5F5); // Biru muda yang cerah + final Color lightBlue = Color(0xFFBBDEFB); // Biru yang lebih terang untuk background + final Color darkBlue = Color(0xFF1976D2); // Biru yang lebih gelap untuk teks/ikon + + @override + Widget build(BuildContext context) { + final eventCollection = FirebaseFirestore.instance.collection('events'); + + return Scaffold( + backgroundColor: Colors.grey[50], // Background lembut + appBar: AppBar( + title: Text( + 'Daftar Hasil Event', + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + centerTitle: true, + backgroundColor: primaryBlue, // Warna AppBar + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), // Sudut melengkung di kiri bawah + bottomRight: Radius.circular(20), // Sudut melengkung di kanan bawah + ), + ), + iconTheme: IconThemeData(color: Colors.white), // Warna ikon back + elevation: 5, // Tambahkan sedikit bayangan + ), + body: StreamBuilder( + stream: eventCollection.orderBy('created_at', descending: true).snapshots(), // Urutkan terbaru di atas + builder: (context, snapshot) { + if (!snapshot.hasData) { + return Center(child: CircularProgressIndicator(color: primaryBlue)); + } + if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}', style: TextStyle(color: Colors.red))); + } + + final docs = snapshot.data!.docs; + + if (docs.isEmpty) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(Icons.event_note, size: 60, color: Colors.grey[400]), + SizedBox(height: 16), + Text( + "Belum ada event yang tersedia.", + style: TextStyle(fontSize: 18, color: Colors.grey[600]), + ), + ], + ), + ); + } + + return ListView.builder( + padding: EdgeInsets.all(16.0), // Padding menyeluruh untuk ListView + itemCount: docs.length, + itemBuilder: (context, index) { + final doc = docs[index]; + final data = doc.data() as Map; + + final eventName = data['name'] ?? 'Tanpa Nama'; + final totalLaps = data['total_laps'] ?? 0; + final totalDistance = data['total_distance'] ?? 0; + final participantsMap = data['participants'] as Map? ?? {}; // Ambil map peserta + + // Ambil status permanen dari Firestore + bool isEventFinishedPermanently = data['is_finished_permanently'] ?? false; + bool isEventStartedPermanently = data['is_started_permanently'] ?? false; + + String displayEventStatusText; + Color displayEventStatusColor; + if (isEventFinishedPermanently) { + displayEventStatusText = "Selesai"; // Lebih ringkas + displayEventStatusColor = Colors.green.shade700; + } else if (isEventStartedPermanently) { + displayEventStatusText = "Berlangsung"; // Lebih ringkas + displayEventStatusColor = Colors.orange.shade700; + } else { + displayEventStatusText = "Belum Mulai"; // Lebih ringkas + displayEventStatusColor = Colors.red.shade700; + } + + return Card( + margin: EdgeInsets.only(bottom: 16), // Spasi antar card + elevation: 4, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), // Radius pada Card + ), + color: Colors.white, // Warna Card putih + child: InkWell( // Gunakan InkWell untuk efek visual saat ditekan + borderRadius: BorderRadius.circular(12), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => EventResultPage( + eventId: doc.id, + eventName: eventName, + ), + ), + ); + }, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( // Menggunakan Column untuk menata konten + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( // Baris untuk Nama Event dan Status + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text( + eventName, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + overflow: TextOverflow.ellipsis, + ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: displayEventStatusColor.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + ), + child: Text( + displayEventStatusText, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: displayEventStatusColor, + ), + ), + ), + ], + ), + SizedBox(height: 4), + Text( + "${totalLaps} Putaran | ${(totalDistance / 1000).toStringAsFixed(2)} KM", + style: TextStyle( + fontSize: 14, + color: Colors.grey[700], + ), + ), + SizedBox(height: 12), // Spasi sebelum daftar peserta + Text( + "Peserta (${participantsMap.length}):", + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + ), + SizedBox(height: 8), + if (participantsMap.isEmpty) + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Text( + "Belum ada peserta terdaftar.", + style: TextStyle(fontSize: 14, fontStyle: FontStyle.italic, color: Colors.grey[600]), + ), + ) + else + // List nama peserta + ...participantsMap.entries.map((entry) { + final p = entry.value as Map; + final name = p['name'] ?? 'Nama tidak ditemukan'; + final finished = p['finished'] == true; + final currentLaps = p['laps'] ?? 0; + String statusText = finished ? 'Selesai' : 'Berlangsung ($currentLaps putaran)'; + Color statusColor = finished ? Colors.green.shade700 : Colors.orange.shade700; + + return Padding( + padding: const EdgeInsets.only(left: 8.0, bottom: 4.0), + child: Row( + children: [ + Icon(Icons.person, size: 16, color: Colors.grey[700]), // Ikon orang + SizedBox(width: 8), + Expanded( + child: Text( + name, + style: TextStyle(fontSize: 14, color: Colors.grey[900]), + overflow: TextOverflow.ellipsis, + ), + ), + Text( + statusText, + style: TextStyle(fontSize: 12, color: statusColor), + ), + ], + ), + ); + }).toList(), + ], + ), + ), + ), + ); + }, + ); + }, + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart new file mode 100644 index 0000000..bd4aa29 --- /dev/null +++ b/lib/screens/home_screen.dart @@ -0,0 +1,425 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:fl_chart/fl_chart.dart'; +import 'package:intl/intl.dart'; +import 'detail_hasil_screen.dart'; +import 'all_activity_screen.dart'; + +class HomeScreen extends StatelessWidget { + const HomeScreen({super.key}); + + Future getUsername() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return ''; + final doc = await FirebaseFirestore.instance.collection('users').doc(user.uid).get(); + return doc.data()?['username'] ?? ''; + } + + Future> fetchRunningData() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return {}; + + final now = DateTime.now(); + final startOfWeek = DateTime(now.year, now.month, now.day - (now.weekday - 1)); + final endOfWeek = startOfWeek.add(const Duration(days: 7)).subtract(const Duration(seconds: 1)); + + final snapshot = await FirebaseFirestore.instance.collection('activities').get(); + final Map distancePerDay = {}; + + for (var doc in snapshot.docs) { + final data = doc.data()['data']; + if (data == null || data['userId'] != user.uid) continue; + + final timestamp = (data['timestamp'] as Timestamp?)?.toDate(); + if (timestamp == null || timestamp.isBefore(startOfWeek) || timestamp.isAfter(endOfWeek)) continue; + + final day = DateFormat('EEEE', 'id_ID').format(timestamp); + final jarak = (data['jarak'] ?? 0).toDouble(); + final satuan = data['satuan'] ?? 'M'; + final jarakKm = satuan == 'M' ? jarak / 1000.0 : jarak; + + distancePerDay[day] = (distancePerDay[day] ?? 0) + jarakKm; + } + + const sortedDays = ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']; + for (var dayName in sortedDays) { + distancePerDay.putIfAbsent(dayName, () => 0.0); + } + + return distancePerDay; + } + + Future>> fetchRingkasanData() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return []; + + final snapshot = await FirebaseFirestore.instance.collection('activities').get(); + final List> result = []; + + for (var doc in snapshot.docs) { + final data = doc.data()['data']; // penting! + if (data == null || data['userId'] != user.uid) continue; + result.add({ + ...data, + 'docId': doc.id, // tambahkan docId untuk referensi penghapusan nanti + }); + } + + result.sort((a, b) { + final aTime = (a['timestamp'] as Timestamp?)?.toDate() ?? DateTime(2000); + final bTime = (b['timestamp'] as Timestamp?)?.toDate() ?? DateTime(2000); + return bTime.compareTo(aTime); + }); + + return result; + } + + String getGreeting() { + final hour = DateTime.now().hour; + if (hour >= 6 && hour <= 10) { + return 'Selamat Pagi'; + } else if (hour >= 11 && hour <= 14) { + return 'Selamat Siang'; + } else if (hour >= 15 && hour <= 17) { + return 'Selamat Sore'; + } else { + return 'Selamat Malam'; + } + } + + DateTime? parseTimestamp(dynamic raw) { + if (raw is Timestamp) { + return raw.toDate(); + } else if (raw is DateTime) { + return raw; + } else if (raw is String) { + return DateTime.tryParse(raw); + } else if (raw is int) { + return DateTime.fromMillisecondsSinceEpoch(raw); + } + return null; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(80), + child: FutureBuilder( + future: getUsername(), + builder: (context, snapshot) { + final greeting = getGreeting(); + final username = snapshot.data ?? '...'; + + return Container( + decoration: const BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40, left: 20, right: 20, bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '$greeting, $username', + style: const TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + ), + Image.asset( + 'images/run.png', + height: 55, + width: 55, + ), + ], + ), + ); + }, + ), + ), + body: RefreshIndicator( + onRefresh: () async { + // Memanggil kembali data setelah pull-to-refresh + fetchRunningData(); + fetchRingkasanData(); + }, + child: Padding( + padding: const EdgeInsets.only(top: 0.0, bottom: 0.0, right: 14.0, left: 14.0), + child: FutureBuilder( + future: Future.wait([fetchRunningData(), fetchRingkasanData(), getUsername()]), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + final runningData = snapshot.data?[0] as Map? ?? {}; + final ringkasanData = snapshot.data?[1] as List>? ?? []; + + final sortedDays = ['Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu']; + final values = sortedDays.map((day) => runningData[day] ?? 0.0).toList(); + final totalMinggu = values.fold(0.0, (a, b) => a + b); + int totalDurasiDetik = 0; + final now = DateTime.now(); + final startOfWeek = DateTime(now.year, now.month, now.day - (now.weekday - 1)); + final endOfWeek = startOfWeek.add(const Duration(days: 7)).subtract(const Duration(seconds: 1)); + + for (var data in ringkasanData) { + final timestamp = parseTimestamp(data['timestamp']); + if (timestamp == null) continue; + if (timestamp.isBefore(startOfWeek) || timestamp.isAfter(endOfWeek)) continue; + + totalDurasiDetik += (((data['duration'] ?? data['durasi'] ?? 0) as num).toInt() ~/ 1000); + } + + String formatDurasi(int totalSeconds) { + final jam = totalSeconds ~/ 3600; + final menit = (totalSeconds % 3600) ~/ 60; + final detik = totalSeconds % 60; + return '${jam}j ${menit}m ${detik}d'; + } + + final totalDurasiFormatted = formatDurasi(totalDurasiDetik); + + final maxValue = values.reduce((a, b) => a > b ? a : b); + final highestDay = sortedDays[values.indexOf(maxValue)]; + + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Minggu ini', + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + ), + ), + TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (_) => const AllActivityScreen()), + ); + }, + child: const Text( + 'View all weeks', + style: TextStyle(color: Colors.blue), + ), + ), + ], + ), + const SizedBox(height: 1), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Jarak', + style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal), + ), + Text( + '${totalMinggu.toStringAsFixed(2)} km', + style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ], + ), + const SizedBox(width: 20), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Waktu', + style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal), + ), + Text( + totalDurasiFormatted, + style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ], + ), + ], + ), + const SizedBox(height: 20), + SizedBox( + height: 170, + child: Padding( + padding: const EdgeInsets.only(left: 5.0, right: 6.0), + child: LineChart( + LineChartData( + minY: 0.0, + maxY: (values.isEmpty ? 5.0 : values.reduce((a, b) => a > b ? a : b)), + gridData: FlGridData( + show: true, + drawVerticalLine: true, + drawHorizontalLine: false, + verticalInterval: 1, + getDrawingVerticalLine: (value) { + return FlLine( + color: Colors.blue.withOpacity(0.2), + strokeWidth: 1, + ); + }, + ), + extraLinesData: ExtraLinesData( + verticalLines: [ + VerticalLine( + x: 0, + color: Colors.blue.withOpacity(0.2), + strokeWidth: 1, + ), + VerticalLine( + x: (sortedDays.length - 1).toDouble(), + color: Colors.blue.withOpacity(0.2), + strokeWidth: 1, + ), + ], + ), + titlesData: FlTitlesData( + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + interval: 1, + getTitlesWidget: (value, meta) { + int index = value.toInt(); + if (index < 0 || index >= sortedDays.length) { + return const SizedBox.shrink(); + } + EdgeInsets padding = EdgeInsets.zero; + if (index == 0) { + padding = const EdgeInsets.only(left: 12); + } else if (index == sortedDays.length - 1) { + padding = const EdgeInsets.only(right: 12); + } + return Padding( + padding: padding.add(const EdgeInsets.only(top: 4)), // tambah jarak dari grafik ke teks + child: Text( + sortedDays[index].substring(0, 3), + style: const TextStyle(fontSize: 10), + ), + ); + }, + ), + ), + leftTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)), + rightTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + reservedSize: 35, + getTitlesWidget: (value, _) { + if (value == 0.0 || value == maxValue || value == (maxValue + 1)) { + return Padding( + padding: const EdgeInsets.only(left: 8), + child: Text('${value.toStringAsFixed(1)} KM', style: const TextStyle(fontSize: 10)), + ); + } + return const SizedBox.shrink(); + }, + ), + ), + topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)), + ), + borderData: FlBorderData(show: false), + lineBarsData: [ + LineChartBarData( + spots: List.generate(values.length, (i) => FlSpot(i.toDouble(), values[i])), + isCurved: false, + barWidth: 3, + dotData: FlDotData(show: true), + belowBarData: BarAreaData( + show: true, + color: Colors.lightBlueAccent.withOpacity(0.3), + ), + color: Colors.blue, + ), + ], + ), + ), + ), + ), + const SizedBox(height: 24), + Text('Hari Teraktif: $highestDay (${maxValue.toStringAsFixed(2)} KM)', + style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500)), + const SizedBox(height: 16), + + const Text('Ringkasan Hasil Lari', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600)), + const SizedBox(height: 8), + + ringkasanData.isEmpty + ? const Text('Belum ada data untuk hari teraktif.') + : ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: ringkasanData.length, + separatorBuilder: (_, __) => const SizedBox(height: 12), + itemBuilder: (context, index) { + final data = ringkasanData[index]; + final timestamp = (data['timestamp'] as Timestamp?)?.toDate(); + if (timestamp == null) return const SizedBox(); + + final jarak = (data['jarak'] ?? 0).toDouble(); + final satuan = data['satuan'] ?? 'M'; + final jarakKm = satuan == 'M' ? jarak / 1000.0 : jarak; + + return GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => DetailHasilLariScreen( + data: { + ...data, + 'docId': ringkasanData[index]['docId'] ?? '', // tambahkan docId kalau tersedia + }, + ), + ), + ); + }, + + child: Card( + color: const Color.fromARGB(255, 60, 193, 255), + elevation: 2, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + child: ListTile( + leading: Padding( + padding: const EdgeInsets.only(top: 12.0), // geser ke bawah + child: const Icon(Icons.directions_run), + ), + title: Text('${jarak.toStringAsFixed(0)} $satuan'), + subtitle: Text( + '${DateFormat('dd MMM yyyy, HH:mm').format(timestamp)}\n(${jarakKm.toStringAsFixed(2)} KM)', + ), + isThreeLine: true, + trailing: Padding( + padding: const EdgeInsets.only(top: 12.0), // geser ke bawah + child: const Icon(Icons.arrow_forward_ios, size: 16), + ), + ), + ), + ); + }, + ), + ], + ), + ); + }, + ), + ), + ) + ); + } +} diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart new file mode 100644 index 0000000..4b2d9ad --- /dev/null +++ b/lib/screens/main_screen.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import 'package:ta_running/screens/start_activity_screen.dart'; +import 'home_screen.dart'; +import 'profile_screen.dart'; + +class MainScreen extends StatefulWidget { + const MainScreen({super.key}); + + @override + State createState() => _MainScreenState(); +} + +class _MainScreenState extends State { + int _selectedIndex = 0; + + final List _screens = [ + const HomeScreen(), + const StartActivityScreen(), + const ProfileScreen(), + ]; + + void _onTabTapped(int index) { + setState(() => _selectedIndex = index); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: _screens[_selectedIndex], + bottomNavigationBar: Container( + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.2), // Warna bayangan hitam dengan transparansi + blurRadius: 10, // Ukuran blur bayangan + offset: Offset(0, -4), // Posisi bayangan + ), + ], + ), + child: BottomNavigationBar( + currentIndex: _selectedIndex, + onTap: _onTabTapped, + showSelectedLabels: true, // label tampil saat aktif + showUnselectedLabels: false, // label disembunyikan saat tidak aktif + selectedItemColor: Colors.blueAccent, + unselectedItemColor: Colors.grey, + backgroundColor: Colors.white, + type: BottomNavigationBarType.fixed, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Home', + ), + BottomNavigationBarItem( + icon: Icon(Icons.play_arrow), + label: 'Start', + ), + BottomNavigationBarItem( + icon: Icon(Icons.person), + label: 'Profile', + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/monitoring_screen.dart b/lib/screens/monitoring_screen.dart new file mode 100644 index 0000000..db1b4e3 --- /dev/null +++ b/lib/screens/monitoring_screen.dart @@ -0,0 +1,118 @@ +import 'dart:async'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'result_screen.dart'; + +class MonitoringScreen extends StatefulWidget { + final String userId; + const MonitoringScreen({Key? key, required this.userId}) : super(key: key); + + @override + State createState() => _MonitoringScreenState(); +} + + class _MonitoringScreenState extends State { + late DatabaseReference _activityRef; + StreamSubscription? _subscription; + bool _navigated = false; + + @override + void initState() { + super.initState(); + final db = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + _activityRef = db.ref("activities/${widget.userId}"); + + _subscription = _activityRef.onValue.listen((event) { + final raw = event.snapshot.value; + if (raw is Map) { + final data = Map.from(raw); + + // ✅ Cek dan simpan startTime jika status == 'running' dan startTime belum ada + if (data['status'] == 'running' && data['startTime'] == null) { + final now = DateTime.now().toUtc(); // ambil SEKALI dalam UTC + final nowMillis = now.millisecondsSinceEpoch; + final nowIso = now.toIso8601String(); + + _activityRef.update({ + 'startTime': nowMillis, + 'laps/lap_0/timestamp': nowIso, + }); + + print("⏱️ startTime dan lap_0 disimpan ke RTDB: $nowIso"); + } + + // ✅ Saat status 'done', proses navigasi dan simpan durasi + if (!_navigated && data['status'] == 'done') { + _navigated = true; + _subscription?.cancel(); + + int? dur; + + if (data['startTime'] != null) { + final now = DateTime.now().millisecondsSinceEpoch; + dur = now - (data['startTime'] as int); + _activityRef.update({'duration': dur}); + data['duration'] = dur; + } + + final type = data['type']; + final rawJarak = data['jarak']; + final satuan = data['satuan'] ?? 'M'; + + double jarakKm = 0; + if (rawJarak != null) { + jarakKm = satuan == 'KM' + ? (rawJarak as num).toDouble() + : (rawJarak as num).toDouble() / 1000.0; + } + + if (type == 'non-lintasan' && jarakKm > 0 && dur != null) { + final durSec = dur / 1000.0; + final pacePerKmSec = durSec / jarakKm; + _activityRef.update({'pace_sec_per_km': pacePerKmSec}); + data['pace_sec_per_km'] = pacePerKmSec; + } + + data['uidTag'] = widget.userId; + + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => ResultScreen(activityData: data), + ), + ); + } + } + }); + } + + @override + void dispose() { + _subscription?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return const Scaffold( + backgroundColor: Colors.white, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator(color: Colors.blueAccent), + SizedBox(height: 20), + Text( + 'Aktivitas sedang berlangsung...', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ], + ), + ), + ); + } + } \ No newline at end of file diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart new file mode 100644 index 0000000..4687f3b --- /dev/null +++ b/lib/screens/profile_screen.dart @@ -0,0 +1,265 @@ +import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:firebase_core/firebase_core.dart'; +import '../screens/auth/login_screen.dart'; +import 'edit_profile_screen.dart'; + +class ProfileScreen extends StatefulWidget { + const ProfileScreen({super.key}); + + @override + State createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + String? username; + String? gender; + String? email; + + @override + void initState() { + super.initState(); + _fetchUserData(); + } + + Future _fetchUserData() async { + final user = FirebaseAuth.instance.currentUser; + if (user != null) { + final doc = await FirebaseFirestore.instance.collection('users').doc(user.uid).get(); + setState(() { + username = doc['username']; + gender = doc['gender']; + email = user.email; + }); + } + } + + Future _logout() async { + final shouldLogout = await showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Konfirmasi Logout'), + content: const Text('Apakah kamu yakin ingin keluar dari akun ini?'), + actions: [ + TextButton(onPressed: () => Navigator.pop(context, false), child: const Text('Batal')), + ElevatedButton(onPressed: () => Navigator.pop(context, true), child: const Text('Logout')), + ], + ), + ); + + if (shouldLogout == true) { + await FirebaseAuth.instance.signOut(); + if (!mounted) return; + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => const LoginScreen()), + (route) => false, + ); + } + } + + Widget _buildInfoRow(String label, String value) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: const TextStyle( + fontSize: 14, + color: Colors.grey, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 4), + Text( + value, + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + ], + ), + ); + } + + Future _refreshData() async { + await _fetchUserData(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(100), + child: Container( + decoration: const BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40, left: 20, right: 20, bottom: 20), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Profile", + style: const TextStyle( + color: Colors.white, + fontSize: 22, + fontWeight: FontWeight.bold, + ), + ), + Row( + children: [ + IconButton( + tooltip: 'Edit Profil', + onPressed: () async { + final updated = await Navigator.push( + context, + MaterialPageRoute(builder: (_) => const EditProfileScreen()), + ); + if (updated == true) { + _fetchUserData(); + } + }, + icon: const Icon(Icons.edit, color: Colors.white, size: 24), + ), + IconButton( + tooltip: 'Logout', + onPressed: _logout, + icon: const Icon(Icons.logout, color: Colors.white, size: 24), + ), + ], + ) + ], + ), + ), + ), + body: RefreshIndicator( + onRefresh: _refreshData, + child: ListView( + padding: const EdgeInsets.all(20), + children: [ + username == null || gender == null || email == null + ? const Center(child: CircularProgressIndicator()) + : Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 20), + CircleAvatar( + radius: 40, + backgroundColor: Colors.blue, + child: Text( + username![0].toUpperCase(), + style: const TextStyle(fontSize: 32, color: Colors.white), + ), + ), + const SizedBox(height: 16), + Text( + username!, + style: const TextStyle(fontSize: 22, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 24), + Card( + color: Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + elevation: 6, + shadowColor: Colors.blueAccent.withOpacity(0.4), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildInfoRow("Username", username!), + const Divider(), + _buildInfoRow("Gender", gender!), + const Divider(), + _buildInfoRow("Email", email!), + const Divider(), + FutureBuilder( + future: FirebaseFirestore.instance + .collection("users") + .doc(FirebaseAuth.instance.currentUser?.uid) + .get(), + builder: (context, snapshot) { + String rfidText = "Belum terdaftar"; + if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { + final data = snapshot.data?.data() as Map?; + if (data != null && data.containsKey("idGelang")) { + rfidText = data["idGelang"]; + } + } + return _buildInfoRow("UID RFID", rfidText); + }, + ), + ], + ), + ), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () async { + final user = FirebaseAuth.instance.currentUser; + if (user != null) { + final db = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + final gelangRef = db.ref("/gelang"); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Menunggu scan gelang di alat..."), + duration: Duration(seconds: 3), + ), + ); + + StreamSubscription? sub; + sub = gelangRef.onValue.listen((event) async { + final data = event.snapshot.value; + if (data != null && data is String) { + final rfid = data; + + await FirebaseFirestore.instance + .collection("users") + .doc(user.uid) + .set({"idGelang": rfid}, SetOptions(merge: true)); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Gelang berhasil didaftarkan: $rfid"), + duration: const Duration(seconds: 3), + ), + ); + + await sub?.cancel(); + } + }); + } + }, + child: const Text("Daftarkan RFID"), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/result_screen.dart b/lib/screens/result_screen.dart new file mode 100644 index 0000000..63f3fd5 --- /dev/null +++ b/lib/screens/result_screen.dart @@ -0,0 +1,237 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:flutter/material.dart'; +import 'main_screen.dart'; + +class ResultScreen extends StatelessWidget { + final Map activityData; + + const ResultScreen({Key? key, required this.activityData}) : super(key: key); + + Future _saveActivityAndGoHome(BuildContext context) async { + try { + final user = FirebaseAuth.instance.currentUser; + if (user == null) throw Exception("User belum login"); + + final docRef = FirebaseFirestore.instance.collection('activities').doc(); // buat ID manual + await docRef.set({ + 'data': { + 'userId': user.uid, + 'type': activityData['type'] ?? 'non-lintasan', + 'jarak': activityData['jarak'] ?? activityData['distance'] ?? 0.0, + 'satuan': activityData['satuan'] ?? 'M', + 'putaran': activityData['putaran'] ?? 0, + 'duration': activityData['duration'], + 'startTime': activityData['startTime'], + 'timestamp': FieldValue.serverTimestamp(), + } + }); + + + // AMBIL LAPS DARI RTDB DAN SIMPAN JUGA + final rtdb = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + + final lapsRef = rtdb.ref("activities/${activityData['uidTag']}/laps"); + final lapSnap = await lapsRef.get(); + final lapData = lapSnap.value; + + if (lapData != null && lapData is Map) { + await docRef.update({ + 'data.laps': lapData, + }); + print("✅ Laps disimpan ke Firestore."); + } else { + print("⚠️ Laps tidak ditemukan di RTDB."); + } + + + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => const MainScreen()), + (route) => false, + ); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Gagal menyimpan aktivitas: $e')), + ); + } + } + + @override + Widget build(BuildContext context) { + final type = activityData['type'] ?? 'Tidak diketahui'; + final rawJarak = activityData['jarak'] ?? activityData['distance'] ?? 0.0; + final satuan = activityData['satuan'] ?? 'M'; + final jarak = satuan == 'M' ? rawJarak / 1000.0 : rawJarak; + final putaran = activityData['putaran'] ?? '-'; + + int? startTimeMillis = activityData['startTime']; + DateTime? startTime; + if (startTimeMillis != null) { + startTime = DateTime.fromMillisecondsSinceEpoch(startTimeMillis); + } + + int? durationMillis = activityData['duration']; + String durationFormatted = '-'; + if (durationMillis != null) { + final dur = Duration(milliseconds: durationMillis); + durationFormatted = dur.toString().split('.').first.padLeft(8, "0"); + } else if (startTime != null) { + final dur = DateTime.now().difference(startTime); + durationFormatted = dur.toString().split('.').first.padLeft(8, "0"); + } + + // ✅ Format pace jika tersedia + String? paceFormatted; + if (type == 'non-lintasan' && activityData['pace_sec_per_km'] != null) { + final paceSec = (activityData['pace_sec_per_km'] as num).toDouble(); + final paceMin = paceSec ~/ 60; + final paceSecRem = (paceSec % 60).round(); + paceFormatted = '$paceMin:${paceSecRem.toString().padLeft(2, '0')} /km'; + } + + String getRunPeriodLabel(DateTime time) { + final hour = time.hour; + if (hour >= 6 && hour <= 10) { + return 'Berlari Pagi'; + } else if (hour >= 11 && hour <= 14) { + return 'Berlari Siang'; + } else if (hour >= 15 && hour <= 17) { + return 'Berlari Sore'; + } else { + return 'Berlari Malam'; + } + } + + + return Scaffold( + backgroundColor: Colors.white, + body: Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 40), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'Selamat! Kamu telah menyelesaikan\naktivitas', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 26, fontWeight: FontWeight.w700), + ), + const SizedBox(height: 30), + Container( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blueAccent.shade200, Colors.blue.shade400], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.4), + offset: const Offset(0, 4), + blurRadius: 8, + ), + ], + ), + child: Column( + children: [ + Text( + getRunPeriodLabel(startTime ?? DateTime.now()), + style: const TextStyle( + fontSize: 30, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 20), + if (type == 'lintasan') ...[ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _infoItem('${jarak.toStringAsFixed(2)} KM', 'Jarak'), + _infoItem(durationFormatted, 'Durasi'), + ], + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _infoItem('$putaran', 'Putaran'), + _infoItem('Lintasan', 'Jenis Aktivitas'), + ], + ), + ] else ...[ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _infoItem('${jarak.toStringAsFixed(2)} KM', 'Jarak'), + _infoItem(durationFormatted, 'Durasi'), + ], + ), + if (paceFormatted != null) ...[ + const SizedBox(height: 16), + _infoItem(paceFormatted!, 'Pace'), + ], + const SizedBox(height: 16), + Text( + 'Jenis Aktivitas\nNon-Lintasan', + textAlign: TextAlign.center, + style: const TextStyle(color: Colors.white, fontSize: 15), + ), + ], + ], + ), + ), + const SizedBox(height: 40), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => _saveActivityAndGoHome(context), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blue, + padding: const EdgeInsets.symmetric(vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + ), + child: const Text( + 'Kembali ke Beranda', + style: TextStyle(fontSize: 16, color: Colors.white), + ), + ), + ), + ], + ), + ), + ), + ); + } + + Widget _infoItem(String value, String label) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + value, + style: const TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + const SizedBox(height: 4), + Text( + label, + style: const TextStyle(color: Colors.white70, fontSize: 12), + ), + ], + ); + } +} diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart new file mode 100644 index 0000000..f40e544 --- /dev/null +++ b/lib/screens/splash_screen.dart @@ -0,0 +1,91 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:ta_running/screens/auth/login_screen.dart'; +import 'package:ta_running/screens/main_screen.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'super_user_dashboard.dart'; + +class SplashScreen extends StatefulWidget { + const SplashScreen({super.key}); + + @override + State createState() => _SplashScreenState(); +} + +class _SplashScreenState extends State { + @override + void initState() { + super.initState(); + _checkLogin(); + } + + Future _checkLogin() async { + await Future.delayed(const Duration(seconds: 2)); + final user = FirebaseAuth.instance.currentUser; + + if (user != null) { + // Ambil data user dari Firestore + final doc = await FirebaseFirestore.instance + .collection('users') + .doc(user.uid) + .get(); + + final role = doc.data()?['role'] ?? 'runner'; + + if (role == 'superuser') { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => SuperUserDashboard()), + ); + } else { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => const MainScreen()), + ); + } + } else { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => const LoginScreen()), + ); + } + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.blueAccent, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'images/run.png', + width: 100, + height: 100, + ), + const SizedBox(height: 20), + const Text( + 'Selamat Datang, Runners!', + style: TextStyle( + fontSize: 26, + fontWeight: FontWeight.bold, + color: Colors.white, + letterSpacing: 1.2, + ), + ), + const SizedBox(height: 10), + const Text( + 'Ayo mulai lari dan pantau performamu!', + style: TextStyle( + fontSize: 16, + color: Colors.white70, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/start_activity_screen.dart b/lib/screens/start_activity_screen.dart new file mode 100644 index 0000000..31c4fea --- /dev/null +++ b/lib/screens/start_activity_screen.dart @@ -0,0 +1,371 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'wait_for_rfid_screen.dart'; + +class StartActivityScreen extends StatefulWidget { + const StartActivityScreen({super.key}); + + @override + State createState() => _StartActivityScreenState(); +} + +class _StartActivityScreenState extends State { + String? _selectedType; + final _lapController = TextEditingController(); // Untuk input jumlah putaran + final _calculatedDistanceController = TextEditingController(); // Untuk menampilkan jarak total + String _unit = 'KM'; + + // Variabel untuk menghitung waktu setiap lap + DateTime lapStartTime = DateTime.now(); + DateTime lapEndTime = DateTime.now(); + double lapTimeInSeconds = 0; + double speed = 0.0; // Kecepatan dalam m/s + + void _showError(String message) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Error", style: TextStyle(color: Colors.red)), + content: Text(message), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text("OK", style: TextStyle(color: Colors.blue)), + ) + ], + ), + ); + } + + // Fungsi untuk memulai timer saat lap dimulai + void startLapTimer() { + lapStartTime = DateTime.now(); // Mulai timer dengan DateTime + } + + // Fungsi untuk menghentikan timer saat lap selesai dan menghitung kecepatan + void endLapTimer(double lapDistance, String uidTag) { + lapEndTime = DateTime.now(); // Hentikan timer dengan DateTime + lapTimeInSeconds = lapEndTime.difference(lapStartTime).inSeconds.toDouble(); // Hitung waktu dalam detik + speed = lapDistance / lapTimeInSeconds; // Hitung kecepatan dalam meter per detik + + // Simpan kecepatan per lap di Firebase + saveSpeedToFirebase(uidTag, speed); + } + + // Fungsi untuk menyimpan kecepatan per lap ke Firebase (RTDB) + void saveSpeedToFirebase(String uidTag, double speed) { + final user = FirebaseAuth.instance.currentUser; + + if (user == null) { + print("User tidak ditemukan"); + return; + } + + try { + final db = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + final ref = db.ref("activities/$uidTag"); + + // Simpan kecepatan per lap + ref.child('kecepatan_lap').push().set({ + 'speed': speed, + 'timestamp': DateTime.now().toIso8601String(), + }); + + print("Kecepatan lap $uidTag berhasil disimpan: $speed m/s"); + } catch (e) { + print("❌ Gagal menyimpan kecepatan lap: $e"); + } + } + + // Fungsi untuk mengupdate jarak dan kecepatan setiap lap + void _updateDistance() { + final laps = int.tryParse(_lapController.text); + if (laps != null && laps >= 3) { + final totalDistance = laps * 400; // 400 meter per putaran + _calculatedDistanceController.text = totalDistance.toString(); + } else if (laps != null && laps < 3) { + _calculatedDistanceController.text = ''; + _showError("Jumlah putaran minimal adalah 3 (1200m)."); + } else { + _calculatedDistanceController.text = ''; + } + } + + // Fungsi untuk submit aktivitas ke Firebase + void _submit() { + if (_selectedType == 'Lintasan') { + final laps = int.tryParse(_lapController.text); + + if (laps == null || laps < 3) { + _showError("Masukkan jumlah putaran yang valid (minimal 3)."); + return; + } + + final totalDistance = laps * 400; // 400 meter per putaran + + _calculatedDistanceController.text = totalDistance.toString(); + + submitToFirebase( + jarak: totalDistance.toDouble(), + jenisAktivitas: 'lintasan', + satuan: 'M', + putaran: laps, + ); + } else if (_selectedType == 'Non-Lintasan') { + final jarak = double.tryParse(_lapController.text); + + if (jarak == null || jarak <= 0) { + _showError("Masukkan jarak yang valid."); + return; + } + + submitToFirebase( + jarak: jarak, + jenisAktivitas: 'non-lintasan', + satuan: _unit, + ); + } else { + _showError("Pilih jenis aktivitas terlebih dahulu."); + } + } + + // Fungsi untuk submit data ke Firebase + void submitToFirebase({ + required double jarak, + required String jenisAktivitas, + required String satuan, + int? putaran, + }) async { + final user = FirebaseAuth.instance.currentUser; + + if (user == null) { + print("User tidak ditemukan"); + return; + } + + try { + final userDoc = await FirebaseFirestore.instance + .collection("users") + .doc(user.uid) + .get(); + + final userData = userDoc.data(); + if (userData == null || !userData.containsKey("idGelang")) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Silakan daftarkan gelang RFID terlebih dahulu.")), + ); + return; + } + + final uidTag = userData["idGelang"]; + + final db = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + final ref = db.ref("activities/$uidTag"); + + await ref.set({ + 'uid_apk': user.uid, + 'jarak': jarak, + 'satuan': satuan, + 'putaran': putaran, + 'type': jenisAktivitas, + 'status': 'waiting_for_rfid', + 'timestamp': DateTime.now().toIso8601String(), + }); + + print("✅ Data aktivitas dikirim ke Firebase dengan UID tag: $uidTag"); + + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => WaitForRfidScreen(uidTag: uidTag), + ), + ); + } catch (e) { + print("❌ Gagal mengirim aktivitas: $e"); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text("Gagal mengirim aktivitas: $e")), + ); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(80), + child: Container( + decoration: const BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + padding: const EdgeInsets.only(top: 40, left: 16, right: 16), + child: Row( + children: [ + if (_selectedType != null) + IconButton( + icon: const Icon(Icons.arrow_back, color: Colors.white), + onPressed: () => setState(() => _selectedType = null), + ) + else + const SizedBox(width: 48), + Expanded( + child: Center( + child: Text( + "Start Activity", + style: const TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + const SizedBox(width: 48), + ], + ), + ), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), + child: _selectedType == null + ? Column( + children: [ + const SizedBox(height: 70), + Image.asset( + 'images/run.png', + width: 100, + height: 100, + ), + const SizedBox(height: 80), + const Text( + 'Pilih Jenis Aktivitas', + style: TextStyle(fontSize: 28, fontWeight: FontWeight.w800), + textAlign: TextAlign.center, + ), + const SizedBox(height: 28), + Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: () => setState(() => _selectedType = 'Lintasan'), + style: ElevatedButton.styleFrom( + backgroundColor: _selectedType == 'Lintasan' ? Colors.blueAccent : Colors.white, + side: const BorderSide(color: Colors.blueAccent), + foregroundColor: _selectedType == 'Lintasan' ? Colors.white : Colors.blueAccent, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + padding: const EdgeInsets.symmetric(vertical: 14), + ), + child: const Text('LINTASAN'), + ), + ), + const SizedBox(width: 12), + Expanded( + child: ElevatedButton( + onPressed: () => setState(() => _selectedType = 'Non-Lintasan'), + style: ElevatedButton.styleFrom( + backgroundColor: _selectedType == 'Non-Lintasan' ? Colors.blueAccent : Colors.white, + side: const BorderSide(color: Colors.blueAccent), + foregroundColor: _selectedType == 'Non-Lintasan' ? Colors.white : Colors.blueAccent, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), + padding: const EdgeInsets.symmetric(vertical: 14), + ), + child: const Text('NON-LINTASAN'), + ), + ), + ], + ), + ], + ) + : Column( + children: [ + const SizedBox(height: 70), + Image.asset( + 'images/run.png', + width: 100, + height: 100, + fit: BoxFit.contain, + ), + const SizedBox(height: 80), + Text( + _selectedType!, + style: const TextStyle(fontSize: 28, fontWeight: FontWeight.w800), + ), + const SizedBox(height: 20), + if (_selectedType == 'Lintasan') ...[ + TextField( + controller: _lapController, + keyboardType: TextInputType.number, + decoration: const InputDecoration( + labelText: 'Jumlah Putaran (400M/Putaran)', + border: OutlineInputBorder(), + ), + onChanged: (text) { + _updateDistance(); // Update jarak total setiap kali jumlah putaran diubah + }, + ), + const SizedBox(height: 12), + TextField( + controller: _calculatedDistanceController, + enabled: false, // Disable editing + decoration: const InputDecoration( + labelText: 'Jarak Total (M)', + border: OutlineInputBorder(), + ), + ), + ] else ...[ + Row( + children: [ + Expanded( + child: TextField( + controller: _lapController, // Menggunakan lapController untuk Non-Lintasan + keyboardType: TextInputType.number, + decoration: const InputDecoration( + labelText: 'Jarak', + border: OutlineInputBorder(), + ), + ), + ), + const SizedBox(width: 12), + DropdownButton( + value: _unit, + items: const [ + DropdownMenuItem(value: 'KM', child: Text('KM')), + DropdownMenuItem(value: 'M', child: Text('M')), + ], + onChanged: (value) => setState(() => _unit = value!), + ), + ], + ), + ], + const SizedBox(height: 20), + ElevatedButton( + onPressed: _submit, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blueAccent, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + ), + child: const Text( + 'Submit dan Scan RFID', + style: TextStyle(fontSize: 16, color: Colors.white), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/super_user_dashboard.dart b/lib/screens/super_user_dashboard.dart new file mode 100644 index 0000000..5dad9db --- /dev/null +++ b/lib/screens/super_user_dashboard.dart @@ -0,0 +1,341 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'auth/login_screen.dart'; // Pastikan path ini benar +import 'create_event_page.dart'; // Pastikan path ini benar +import 'event_detail_page.dart'; // Pastikan path ini benar +import 'hasil_event_page.dart'; // Pastikan path ini benar + +class SuperUserDashboard extends StatefulWidget { + @override + State createState() => _SuperUserDashboardState(); +} + +class _SuperUserDashboardState extends State { + // Warna utama yang terinspirasi dari gambar Anda + final Color primaryBlue = Color(0xFF42A5F5); // Biru muda yang cerah + final Color lightBlue = Color(0xFFBBDEFB); // Biru yang lebih terang untuk background + final Color darkBlue = Color(0xFF1976D2); // Biru yang lebih gelap untuk teks/ikon + + Future _refresh() async { + // Memaksa rebuild StreamBuilder saat refresh + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, // Background lembut + body: RefreshIndicator( // RefreshIndicator di sini untuk keseluruhan body + onRefresh: _refresh, + color: primaryBlue, // Warna indicator refresh + child: CustomScrollView( + // Pastikan physics di CustomScrollView agar bisa di-scroll + physics: const AlwaysScrollableScrollPhysics(), + slivers: [ + SliverAppBar( + expandedHeight: 200.0, // Tinggi appBar saat expanded + floating: false, + pinned: true, // AppBar tetap terlihat saat scroll + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), // Sudut melengkung di kiri bawah + bottomRight: Radius.circular(20), // Sudut melengkung di kanan bawah + ), + ), + backgroundColor: primaryBlue, // Set warna dasar AppBar (penting untuk transisi) + flexibleSpace: FlexibleSpaceBar( + centerTitle: true, + titlePadding: EdgeInsets.only(bottom: 16.0, left: 16.0, right: 16.0), + // Untuk membuat "Dashboard Event" dan logo terlihat melengkung, + // kita bisa membungkus konten background FlexibleSpaceBar + // dengan ClipRRect dan Container tambahan. + background: ClipRRect( // <<< Tambahkan ClipRRect di sini + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + child: Container( // <<< Tambahkan Container di sini + decoration: BoxDecoration( + gradient: LinearGradient( // Tetap gunakan gradient untuk warna + colors: [primaryBlue, darkBlue], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + // Hapus borderRadius di sini karena sudah ada di ClipRRect + ), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: 20), // Spasi untuk logo + Image.asset( + 'images/run.png', // Pastikan path logo benar + height: 80, + ), + // Jika Anda ingin teks 'Dashboard Event' juga terlihat di expanded state, + // dan melengkung bersama background, Anda bisa menambahkannya di sini. + // Namun, secara default, title FlexibleSpaceBar akan bergerak. + // Untuk membuat teks title 'tetap' dengan background yang melengkung, + // Anda mungkin perlu menempatkan teks di dalam Column ini juga, + // dan menghapus properti 'title' dari FlexibleSpaceBar. + // Untuk saat ini, kita biarkan 'title' seperti adanya untuk animasi. + // Jika Anda ingin title statis di dalam background melengkung, beritahu saya. + ], + ), + ), + ), + ), + title: Text( // Ini adalah title yang akan bergerak saat scroll + 'Dashboard Event', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + actions: [ + IconButton( + icon: Icon(Icons.logout, color: Colors.white), + tooltip: 'Logout', + onPressed: () async { + final shouldLogout = await showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Konfirmasi Logout'), + content: Text('Apakah Anda yakin ingin keluar dari akun Super User?'), + actions: [ + TextButton(onPressed: () => Navigator.pop(context, false), child: Text('Batal')), + TextButton( + onPressed: () async { + await FirebaseAuth.instance.signOut(); + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (_) => const LoginScreen()), + (route) => false, + ); + }, + child: Text('Logout', style: TextStyle(color: Colors.red))), + ], + ), + ); + }, + ), + ], + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Card( + elevation: 4, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + // Teks "Aksi Cepat" sudah dihapus dari sini sesuai permintaan sebelumnya + _buildActionButton( + context, + icon: Icons.add_circle_outline, + label: 'Buat Event Baru', + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (_) => CreateEventPage())); + }, + color: primaryBlue, + ), + SizedBox(height: 12), + _buildActionButton( + context, + icon: Icons.bar_chart, + label: 'Lihat Hasil Event', + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (_) => HasilEventPage())); + }, + color: Colors.green.shade600, // Warna hijau yang bagus + ), + ], + ), + ), + ), + SizedBox(height: 24), + Text( + 'Daftar Event', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + ), + SizedBox(height: 1), + ], + ), + ), + ), + StreamBuilder( + stream: FirebaseFirestore.instance + .collection('events') + .orderBy('created_at', descending: true) // Urutkan terbaru di atas + .snapshots(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return SliverFillRemaining( + child: Center(child: CircularProgressIndicator(color: primaryBlue))); + } + if (snapshot.hasError) { + return SliverFillRemaining( + child: Center(child: Text('Error: ${snapshot.error}', style: TextStyle(color: Colors.red)))); + } + if (!snapshot.hasData || snapshot.data!.docs.isEmpty) { + return SliverFillRemaining(child: Center(child: Text('Belum ada event yang dibuat.'))); + } + + final events = snapshot.data!.docs; + + return SliverList( + delegate: SliverChildBuilderDelegate( + (context, index) { + final data = events[index].data() as Map; + final docId = events[index].id; + final eventName = data['name'] ?? 'Tanpa Nama Event'; + final totalLaps = data['total_laps'] ?? 0; + final totalDistance = data['total_distance'] ?? 0; + final createdAt = data['created_at'] is Timestamp + ? (data['created_at'] as Timestamp).toDate() + : null; + final isStartedPermanently = data['is_started_permanently'] ?? false; + final isFinishedPermanently = data['is_finished_permanently'] ?? false; + + String statusText; + Color statusColor; + + if (isFinishedPermanently) { + statusText = 'Selesai'; + statusColor = Colors.green.shade700; + } else if (isStartedPermanently) { + statusText = 'Sedang Berlangsung'; + statusColor = Colors.orange.shade700; + } else { + statusText = 'Belum Dimulai'; + statusColor = darkBlue; + } + + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), + child: Card( + elevation: 5, + color: Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => EventDetailPage( + eventId: docId, + eventName: eventName, + ), + ), + ); + }, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + eventName, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: darkBlue, + ), + ), + SizedBox(height: 8), + Row( + children: [ + Icon(Icons.flag_outlined, size: 18, color: Colors.grey[700]), + SizedBox(width: 8), + Text( + '$totalLaps Putaran (${(totalDistance / 1000).toStringAsFixed(2)} KM)', // Format KM dengan 2 desimal + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + ], + ), + SizedBox(height: 4), + Row( + children: [ + Icon(Icons.event, size: 18, color: Colors.grey[700]), + SizedBox(width: 8), + Text( + createdAt != null ? '${createdAt.day}/${createdAt.month}/${createdAt.year}' : 'Tanggal tidak diketahui', + style: TextStyle(fontSize: 14, color: Colors.grey[700]), + ), + ], + ), + SizedBox(height: 8), + Align( + alignment: Alignment.bottomRight, + child: Chip( + label: Text( + statusText, + style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + backgroundColor: statusColor, + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5), + shape: StadiumBorder(), + ), + ), + ], + ), + ), + ), + ), + ); + }, + childCount: events.length, + ), + ); + }, + ), + ], + ), + ), + ); + } + + // Helper method untuk membuat tombol aksi yang konsisten + Widget _buildActionButton( + BuildContext context, { + required IconData icon, + required String label, + required VoidCallback onPressed, + required Color color, + }) { + return SizedBox( + width: double.infinity, // Membuat tombol full width + child: ElevatedButton.icon( + onPressed: onPressed, + icon: Icon(icon, color: Colors.white), + label: Text( + label, + style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold), + ), + style: ElevatedButton.styleFrom( + backgroundColor: color, + padding: EdgeInsets.symmetric(vertical: 14), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 5, + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/wait_for_rfid_screen.dart b/lib/screens/wait_for_rfid_screen.dart new file mode 100644 index 0000000..dae777e --- /dev/null +++ b/lib/screens/wait_for_rfid_screen.dart @@ -0,0 +1,121 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:ta_running/screens/monitoring_screen.dart'; +import 'package:ta_running/screens/result_screen.dart'; + +class WaitForRfidScreen extends StatelessWidget { + final String uidTag; + + const WaitForRfidScreen({Key? key, required this.uidTag}) : super(key: key); + + @override + Widget build(BuildContext context) { + final db = FirebaseDatabase.instanceFor( + app: Firebase.app(), + databaseURL: "https://ta-running-default-rtdb.asia-southeast1.firebasedatabase.app", + ); + final DatabaseReference statusRef = db.ref('activities/$uidTag/status'); + + debugPrint('🔍 Listening to RTDB path: ${statusRef.path}'); + + return StreamBuilder( + stream: statusRef.onValue, + builder: (context, snapshot) { + debugPrint('📡 StreamBuilder state: ' + 'hasData=${snapshot.hasData}, ' + 'hasError=${snapshot.hasError}, ' + 'connectionState=${snapshot.connectionState}'); + + if (snapshot.hasError) { + debugPrint('⚠ StreamBuilder error: ${snapshot.error}'); + return _buildErrorScreen(snapshot.error.toString()); + } + + if (snapshot.hasData) { + final dbEvent = snapshot.data!; + final snap = dbEvent.snapshot; + + debugPrint('📥 Snapshot exists=${snap.exists}, key=${snap.key}'); + + if (snap.exists) { + final value = snap.value; + debugPrint('🔢 Raw value at status: $value (${value.runtimeType})'); + + if (value is String) { + final status = value.trim().toLowerCase(); + debugPrint('✅ Parsed status: $status'); + + if (status == 'running') { + debugPrint('➡ Navigating to MonitoringScreen'); + WidgetsBinding.instance.addPostFrameCallback((_) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => MonitoringScreen(userId: uidTag), + ), + ); + }); + } else if (status == 'done') { + debugPrint('➡ Status done, fetching full data...'); + WidgetsBinding.instance.addPostFrameCallback((_) { + FirebaseDatabase.instance + .ref('activities/$uidTag') + .get() + .then((fullSnap) { + if (fullSnap.exists) { + final data = Map.from( + fullSnap.value as Map, + ); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => ResultScreen(activityData: data), + ), + ); + } + }).catchError((e) { + debugPrint('⚠ Error fetching full data: $e'); + }); + }); + } else { + debugPrint('⏳ Waiting status: $status'); + } + } else { + debugPrint('❌ Expected String status, got ${value.runtimeType}'); + } + } + } + + return Scaffold( + backgroundColor: Colors.white, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + CircularProgressIndicator(color: Colors.blueAccent), + SizedBox(height: 20), + Text( + 'Menunggu pemindaian RFID...', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + ], + ), + ), + ); + }, + ); + } + + Widget _buildErrorScreen(String message) { + return Scaffold( + appBar: AppBar(title: const Text('Error')), + body: Center( + child: Text( + 'Terjadi kesalahan: $message', + style: const TextStyle(color: Colors.red), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart new file mode 100644 index 0000000..afa397c --- /dev/null +++ b/lib/services/auth_service.dart @@ -0,0 +1,33 @@ +import 'package:firebase_auth/firebase_auth.dart'; + +class AuthService { + static FirebaseAuth _auth = FirebaseAuth.instance; + + static Future registerWithEmail({ + required String email, + required String password, + }) async { + final credential = await _auth.createUserWithEmailAndPassword( + email: email, + password: password, + ); + return credential.user; + } + + static Future signInWithEmail({ + required String email, + required String password, + }) async { + final credential = await _auth.signInWithEmailAndPassword( + email: email, + password: password, + ); + return credential.user; + } + + static Future signOut() async { + await _auth.signOut(); + } + + static User? get currentUser => _auth.currentUser; +} diff --git a/linux/.gitignore b/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt new file mode 100644 index 0000000..74d4fea --- /dev/null +++ b/linux/CMakeLists.txt @@ -0,0 +1,128 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "ta_running") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.ta_running") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..e71a16d --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2e1de87 --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/linux/runner/CMakeLists.txt b/linux/runner/CMakeLists.txt new file mode 100644 index 0000000..e97dabc --- /dev/null +++ b/linux/runner/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the application ID. +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") diff --git a/linux/runner/main.cc b/linux/runner/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/linux/runner/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc new file mode 100644 index 0000000..698a5ce --- /dev/null +++ b/linux/runner/my_application.cc @@ -0,0 +1,130 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "ta_running"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "ta_running"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + //MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/linux/runner/my_application.h b/linux/runner/my_application.h new file mode 100644 index 0000000..72271d5 --- /dev/null +++ b/linux/runner/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..b3447b4 --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,18 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import cloud_firestore +import firebase_auth +import firebase_core +import firebase_database + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + FLTFirebaseDatabasePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseDatabasePlugin")) +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a61bf6a --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* ta_running.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ta_running.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* ta_running.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* ta_running.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ta_running.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ta_running"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ta_running.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ta_running"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ta_running.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ta_running"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + 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_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..7e5affd --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..b3c1761 --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..bc3d759 --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = ta_running + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.taRunning + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..61f3bd1 --- /dev/null +++ b/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +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/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..a19cc44 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,495 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: de9ecbb3ddafd446095f7e833c853aff2fa1682b017921fe63a833f9d6f0e422 + url: "https://pub.dev" + source: hosted + version: "1.3.54" + archive: + dependency: transitive + description: + name: archive + sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd" + url: "https://pub.dev" + source: hosted + version: "4.0.7" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + url: "https://pub.dev" + source: hosted + version: "2.12.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + sha256: "89a5e32716794b6a8d0ec1b5dfda988194e92daedaa3f3bed66fa0d0a595252e" + url: "https://pub.dev" + source: hosted + version: "5.6.6" + cloud_firestore_platform_interface: + dependency: transitive + description: + name: cloud_firestore_platform_interface + sha256: "9f012844eb59be6827ed97415875c5a29ccacd28bc79bf85b4680738251a33df" + url: "https://pub.dev" + source: hosted + version: "6.6.6" + cloud_firestore_web: + dependency: transitive + description: + name: cloud_firestore_web + sha256: b8b754269be0e907acd9ff63ad60f66b84c78d330ca1d7e474f86c9527ddc803 + url: "https://pub.dev" + source: hosted + version: "4.4.6" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + email_validator: + dependency: "direct main" + description: + name: email_validator + sha256: e9a90f27ab2b915a27d7f9c2a7ddda5dd752d6942616ee83529b686fc086221b + url: "https://pub.dev" + source: hosted + version: "2.1.17" + equatable: + dependency: transitive + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + sha256: "54c62b2d187709114dd09ce658a8803ee91f9119b0e0d3fc2245130ad9bff9ad" + url: "https://pub.dev" + source: hosted + version: "5.5.2" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + sha256: "5402d13f4bb7f29f2fb819f3b6b5a5a56c9f714aef2276546d397e25ac1b6b8e" + url: "https://pub.dev" + source: hosted + version: "7.6.2" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + sha256: "2be496911f0807895d5fe8067b70b7d758142dd7fb26485cbe23e525e2547764" + url: "https://pub.dev" + source: hosted + version: "5.14.2" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "017d17d9915670e6117497e640b2859e0b868026ea36bf3a57feb28c3b97debe" + url: "https://pub.dev" + source: hosted + version: "3.13.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: d7253d255ff10f85cfd2adaba9ac17bae878fa3ba577462451163bd9f1d1f0bf + url: "https://pub.dev" + source: hosted + version: "5.4.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "129a34d1e0fb62e2b488d988a1fc26cc15636357e50944ffee2862efe8929b23" + url: "https://pub.dev" + source: hosted + version: "2.22.0" + firebase_database: + dependency: "direct main" + description: + name: firebase_database + sha256: "182ce4713d47ffc5f19a5a7b934867d1fae9c33081febcec8c062cb89fc14652" + url: "https://pub.dev" + source: hosted + version: "11.3.5" + firebase_database_platform_interface: + dependency: transitive + description: + name: firebase_database_platform_interface + sha256: b65f416dd2c8ac2d5322241e5411a24ed3da43d0f38aaf9ab6c211d72e52261b + url: "https://pub.dev" + source: hosted + version: "0.2.6+5" + firebase_database_web: + dependency: transitive + description: + name: firebase_database_web + sha256: "5203141fe00a1edfaed5f8e0444b8e4ef807a8ec6eca925621b1cab69b6c06e4" + url: "https://pub.dev" + source: hosted + version: "0.2.6+11" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + sha256: f2e9137f261d0f53a820f6b829c80ba570ac915284c8e32789d973834796eca0 + url: "https://pub.dev" + source: hosted + version: "0.71.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_launcher_icons: + dependency: "direct dev" + description: + name: flutter_launcher_icons + sha256: bfa04787c85d80ecb3f8777bde5fc10c3de809240c48fa061a2c2bf15ea5211c + url: "https://pub.dev" + source: hosted + version: "0.14.3" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + 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" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + image: + dependency: transitive + description: + name: image + sha256: "4e973fcf4caae1a4be2fa0a13157aa38a8f9cb049db6529aa00b4d71abc4d928" + url: "https://pub.dev" + source: hosted + version: "4.5.4" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec + url: "https://pub.dev" + source: hosted + version: "10.0.8" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.dev" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + posix: + dependency: transitive + description: + name: posix + sha256: f0d7856b6ca1887cfa6d1d394056a296ae33489db914e365e2044fdada449e62 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + 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.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" + source: hosted + version: "0.7.4" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + url: "https://pub.dev" + source: hosted + version: "14.3.1" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.7.2 <4.0.0" + flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..089617c --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,117 @@ +name: ta_running +description: "A new Flutter project." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: ^3.7.2 + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + flutter_localizations: + sdk: flutter + email_validator: ^2.1.17 + firebase_core: ^3.13.0 + firebase_auth: ^5.5.2 + cloud_firestore: ^5.6.6 + firebase_database: ^11.3.5 + fl_chart: ^0.71.0 + intl: ^0.19.0 + # share_plus: ^11.0.0 + # image_picker: ^1.1.2 + # firebase_storage: ^12.4.5 + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 +# flutter_native_splash: ^2.4.6 + +# flutter_native_splash: +# color: "FFFFFF" +# image: assets/run.png +# android : true +# ios : true + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^5.0.0 + flutter_launcher_icons: ^0.14.3 + +flutter_icons: + android: true + ios: true + image_path: "images/run.png" + + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^5.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - images/ + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..7926255 --- /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:ta_running/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); + }); +} diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..6cfc272 --- /dev/null +++ b/web/index.html @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + ta_running + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..3434289 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "ta_running", + "short_name": "ta_running", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/web/splash/img/dark-1x.png b/web/splash/img/dark-1x.png new file mode 100644 index 0000000..baa5d78 Binary files /dev/null and b/web/splash/img/dark-1x.png differ diff --git a/web/splash/img/dark-2x.png b/web/splash/img/dark-2x.png new file mode 100644 index 0000000..ce6e657 Binary files /dev/null and b/web/splash/img/dark-2x.png differ diff --git a/web/splash/img/dark-3x.png b/web/splash/img/dark-3x.png new file mode 100644 index 0000000..4c72bfc Binary files /dev/null and b/web/splash/img/dark-3x.png differ diff --git a/web/splash/img/dark-4x.png b/web/splash/img/dark-4x.png new file mode 100644 index 0000000..7b321a1 Binary files /dev/null and b/web/splash/img/dark-4x.png differ diff --git a/web/splash/img/light-1x.png b/web/splash/img/light-1x.png new file mode 100644 index 0000000..baa5d78 Binary files /dev/null and b/web/splash/img/light-1x.png differ diff --git a/web/splash/img/light-2x.png b/web/splash/img/light-2x.png new file mode 100644 index 0000000..ce6e657 Binary files /dev/null and b/web/splash/img/light-2x.png differ diff --git a/web/splash/img/light-3x.png b/web/splash/img/light-3x.png new file mode 100644 index 0000000..4c72bfc Binary files /dev/null and b/web/splash/img/light-3x.png differ diff --git a/web/splash/img/light-4x.png b/web/splash/img/light-4x.png new file mode 100644 index 0000000..7b321a1 Binary files /dev/null and b/web/splash/img/light-4x.png differ diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..a0586a5 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(ta_running LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "ta_running") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..903f489 --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..bf6d21a --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,20 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + CloudFirestorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("CloudFirestorePluginCApi")); + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b83b40a --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,26 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + cloud_firestore + firebase_auth + firebase_core +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..4855fa7 --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "ta_running" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "ta_running" "\0" + VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "ta_running.exe" "\0" + VALUE "ProductName", "ta_running" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..955ee30 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..b6eb79c --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"ta_running", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..153653e --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..3a0b465 --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_