commit 5a0182d69eb2088d92b3227bf4afc3ff4140d480 Author: BakoL2323 <142969559+ardiyanto1234@users.noreply.github.com> Date: Fri Jun 19 11:09:54 2026 +0700 push diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 0000000..3383c71 --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Dart + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + # Note: This workflow uses the latest stable version of the Dart SDK. + # You can specify other versions if desired, see documentation here: + # https://github.com/dart-lang/setup-dart/blob/main/README.md + # - uses: dart-lang/setup-dart@v1 + - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603 + + - name: Install dependencies + run: dart pub get + + # Uncomment this step to verify the use of 'dart format' on each commit. + # - name: Verify formatting + # run: dart format --output=none --set-exit-if-changed . + + # Consider passing '--fatal-infos' for slightly stricter analysis. + - name: Analyze project source + run: dart analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. Note that Flutter projects will + # want to change this to 'flutter test'. + - name: Run tests + run: dart test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3820a95 --- /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-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# 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..9fb0019 --- /dev/null +++ b/.metadata @@ -0,0 +1,30 @@ +# 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: "582a0e7c5581dc0ca5f7bfd8662bb8db6f59d536" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 582a0e7c5581dc0ca5f7bfd8662bb8db6f59d536 + base_revision: 582a0e7c5581dc0ca5f7bfd8662bb8db6f59d536 + - platform: android + create_revision: 582a0e7c5581dc0ca5f7bfd8662bb8db6f59d536 + base_revision: 582a0e7c5581dc0ca5f7bfd8662bb8db6f59d536 + + # 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/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..16fe745 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "sidakpelem-mobile-main", + "request": "launch", + "type": "dart" + }, + { + "name": "sidakpelem-mobile-main (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "sidakpelem-mobile-main (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fbf5a29 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# sidak_desa_mobile + +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..8fa4bf0 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,33 @@ +# 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. +analyzer: + errors: + avoid_print: ignore + deprecated_member_use: ignore + unused_import: ignore +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..1653be0 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.example.sidak_desa_mobile" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.sidak_desa_mobile" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..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..a41c647 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/example/sidak_desa_mobile/MainActivity.kt b/android/app/src/main/kotlin/com/example/sidak_desa_mobile/MainActivity.kt new file mode 100644 index 0000000..c579005 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/sidak_desa_mobile/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.sidak_desa_mobile + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + 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..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + 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..db77bb4 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..17987b7 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..09d4391 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..d5f1c8d 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..4d6372e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..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..dbee657 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,24 @@ +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/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html new file mode 100644 index 0000000..0a894d1 --- /dev/null +++ b/android/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..3c6656c --- /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 +dev.steenbakker.mobile_scanner.useUnbundled=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e4ef43f --- /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.14-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..ca7fe06 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,26 @@ +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.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/assets/images/Union.png b/assets/images/Union.png new file mode 100644 index 0000000..3485652 Binary files /dev/null and b/assets/images/Union.png differ diff --git a/assets/images/banner.png b/assets/images/banner.png new file mode 100644 index 0000000..37265b8 Binary files /dev/null and b/assets/images/banner.png differ diff --git a/assets/images/gito.jpg b/assets/images/gito.jpg new file mode 100644 index 0000000..525bba6 Binary files /dev/null and b/assets/images/gito.jpg differ diff --git a/assets/images/icon_izin.png b/assets/images/icon_izin.png new file mode 100644 index 0000000..b34d500 Binary files /dev/null and b/assets/images/icon_izin.png differ diff --git a/assets/images/icon_masuk.png b/assets/images/icon_masuk.png new file mode 100644 index 0000000..f1eb81c Binary files /dev/null and b/assets/images/icon_masuk.png differ diff --git a/assets/images/icon_riwayat.png b/assets/images/icon_riwayat.png new file mode 100644 index 0000000..a2a1553 Binary files /dev/null and b/assets/images/icon_riwayat.png differ diff --git a/assets/images/ilustrasi.png b/assets/images/ilustrasi.png new file mode 100644 index 0000000..e77809a Binary files /dev/null and b/assets/images/ilustrasi.png differ diff --git a/assets/images/indro.jpg b/assets/images/indro.jpg new file mode 100644 index 0000000..525bba6 Binary files /dev/null and b/assets/images/indro.jpg differ diff --git a/assets/images/logo.png b/assets/images/logo.png new file mode 100644 index 0000000..8e8e573 Binary files /dev/null and b/assets/images/logo.png differ diff --git a/assets/images/splash_screen.png b/assets/images/splash_screen.png new file mode 100644 index 0000000..8fe1c21 Binary files /dev/null and b/assets/images/splash_screen.png differ diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..fa0b357 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/docs/image.png b/docs/image.png new file mode 100644 index 0000000..dea1aa2 Binary files /dev/null and b/docs/image.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..1dc6cf7 --- /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 + 13.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..a76c27c --- /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 = 13.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.sidakDesaMobile; + 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.sidakDesaMobile.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.sidakDesaMobile.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.sidakDesaMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.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.sidakDesaMobile; + 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.sidakDesaMobile; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..e3773d4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..6266644 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} 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..dc9ada4 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..7353c41 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..797d452 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..6ed2d93 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..4cd7b00 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..fe73094 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..321773c 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..797d452 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..502f463 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..0ec3034 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-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 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..e9f5fea 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-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a 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..8953cba 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..0467bf1 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/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..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..f2e259c --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..963aafc --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,53 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Sidak Desa Mobile + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + sidak_desa_mobile + 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 + + NSLocationWhenInUseUsageDescription + Aplikasi membutuhkan lokasi untuk validasi kehadiran. + NSLocationAlwaysAndWhenInUseUsageDescription + Aplikasi membutuhkan lokasi untuk validasi kehadiran. + + 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/core/api/api.dart b/lib/core/api/api.dart new file mode 100644 index 0000000..8166507 --- /dev/null +++ b/lib/core/api/api.dart @@ -0,0 +1,3 @@ +class Apiconfig { + static const String baseUrl = 'https://sidakdesapelem.my.id'; +} diff --git a/lib/core/const/app_colors.dart b/lib/core/const/app_colors.dart new file mode 100644 index 0000000..089cda5 --- /dev/null +++ b/lib/core/const/app_colors.dart @@ -0,0 +1,5 @@ +import 'package:flutter/material.dart'; + +class AppColors { + static const Color primaryColor = Color(0xFF077b7a); +} diff --git a/lib/core/widgets/app_bottom_navbar.dart b/lib/core/widgets/app_bottom_navbar.dart new file mode 100644 index 0000000..3010e26 --- /dev/null +++ b/lib/core/widgets/app_bottom_navbar.dart @@ -0,0 +1,110 @@ +import 'package:flutter/material.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; + +class AppBottomNavbar extends StatelessWidget { + const AppBottomNavbar({ + required this.currentIndex, + required this.onTabSelected, + super.key, + this.onCenterTap, + }); + + final int currentIndex; + final ValueChanged onTabSelected; + final VoidCallback? onCenterTap; + + @override + Widget build(BuildContext context) { + return SizedBox( + height: 96, + child: Stack( + alignment: Alignment.topCenter, + clipBehavior: Clip.none, + children: [ + Positioned.fill( + top: 20, + child: Container( + decoration: BoxDecoration( + color: const Color(0xFFECECEC), + borderRadius: BorderRadius.circular(24), + boxShadow: const [ + BoxShadow( + color: Color(0x26000000), + blurRadius: 8, + offset: Offset(0, -1), + ), + ], + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + _NavItem( + icon: Icons.menu_book_outlined, + isSelected: currentIndex == 0, + onTap: () => onTabSelected(0), + ), + const SizedBox(width: 72), + _NavItem( + icon: Icons.person_outline, + isSelected: currentIndex == 1, + onTap: () => onTabSelected(1), + ), + ], + ), + ), + ), + GestureDetector( + onTap: onCenterTap, + child: Container( + width: 74, + height: 74, + decoration: const BoxDecoration( + color: AppColors.primaryColor, + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: Color(0x33000000), + blurRadius: 10, + offset: Offset(0, 3), + ), + ], + ), + child: const Icon( + Icons.qr_code_scanner_rounded, + color: Colors.white, + size: 34, + ), + ), + ), + ], + ), + ); + } +} + +class _NavItem extends StatelessWidget { + const _NavItem({ + required this.icon, + required this.isSelected, + required this.onTap, + }); + + final IconData icon; + final bool isSelected; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return IconButton( + onPressed: onTap, + splashRadius: 24, + icon: Icon( + icon, + size: 34, + color: isSelected + ? AppColors.primaryColor + : AppColors.primaryColor.withOpacity(0.8), + ), + ); + } +} diff --git a/lib/core/widgets/app_button.dart b/lib/core/widgets/app_button.dart new file mode 100644 index 0000000..b634c7e --- /dev/null +++ b/lib/core/widgets/app_button.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; + +class AppButton extends StatelessWidget { + const AppButton({ + required this.text, + required this.onPressed, + super.key, + this.height = 55, + }); + + final String text; + final VoidCallback? onPressed; + final double height; + + @override + Widget build(BuildContext context) { + return ElevatedButton( + onPressed: onPressed, + style: ElevatedButton.styleFrom( + backgroundColor: AppColors.primaryColor, + minimumSize: Size.fromHeight(height), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + child: Text( + text, + style: const TextStyle(color: Colors.white, fontSize: 18), + ), + ); + } +} diff --git a/lib/core/widgets/app_textfield.dart b/lib/core/widgets/app_textfield.dart new file mode 100644 index 0000000..02fca9f --- /dev/null +++ b/lib/core/widgets/app_textfield.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; + +class AppTextField extends StatelessWidget { + const AppTextField({ + required this.hintText, + super.key, + this.controller, + this.keyboardType, + this.textInputAction, + this.onChanged, + this.readOnly = false, + }); + + final String hintText; + final TextEditingController? controller; + final TextInputType? keyboardType; + final TextInputAction? textInputAction; + final ValueChanged? onChanged; + final bool readOnly; + + @override + Widget build(BuildContext context) { + return TextField( + controller: controller, + keyboardType: keyboardType, + textInputAction: textInputAction, + onChanged: onChanged, + readOnly: readOnly, + decoration: InputDecoration( + hintText: hintText, + border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: AppColors.primaryColor, width: 1), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: AppColors.primaryColor, width: 2), + ), + ), + ); + } +} diff --git a/lib/core/widgets/app_textfield_password.dart b/lib/core/widgets/app_textfield_password.dart new file mode 100644 index 0000000..b311154 --- /dev/null +++ b/lib/core/widgets/app_textfield_password.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; + +class AppTextFieldPassword extends StatefulWidget { + const AppTextFieldPassword({ + super.key, + this.hintText = 'Password', + this.controller, + this.textInputAction, + this.onChanged, + }); + + final String hintText; + final TextEditingController? controller; + final TextInputAction? textInputAction; + final ValueChanged? onChanged; + + @override + State createState() => _AppTextFieldPasswordState(); +} + +class _AppTextFieldPasswordState extends State { + bool _obscureText = true; + + @override + Widget build(BuildContext context) { + return TextField( + controller: widget.controller, + obscureText: _obscureText, + textInputAction: widget.textInputAction, + onChanged: widget.onChanged, + decoration: InputDecoration( + hintText: widget.hintText, + suffixIcon: IconButton( + onPressed: () { + setState(() { + _obscureText = !_obscureText; + }); + }, + icon: Icon( + _obscureText ? Icons.visibility_off : Icons.visibility, + ), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide( + color: AppColors.primaryColor, + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide( + color: AppColors.primaryColor, + width: 2, + ), + ), + ), + ); + } +} diff --git a/lib/data/fetch/attedance_api.dart b/lib/data/fetch/attedance_api.dart new file mode 100644 index 0000000..4a7c722 --- /dev/null +++ b/lib/data/fetch/attedance_api.dart @@ -0,0 +1,69 @@ +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'dart:convert'; +import 'package:http/http.dart' as http; + +class AttedanceApi { + Future> verifyAttendance({ + required String token, + required int userId, + String? deviceInfo, + double? latitude, + double? longitude, + }) async { + final uri = Uri.parse('${Apiconfig.baseUrl}/api/attendance/verify'); + + final res = await http.post( + uri, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: jsonEncode({ + 'token': token, + 'user_id': userId, + 'device_info': deviceInfo, // boleh null + 'latitude': latitude, + 'longitude': longitude, + }), + ); + + final data = jsonDecode(res.body); + + if (res.statusCode >= 200 && res.statusCode < 300) { + if (data is Map) return data; + return {'data': data}; + } + + // Laravel biasanya kasih message + errors + if (data is Map) { + final msg = (data['message'] ?? 'Verifikasi absen gagal').toString(); + throw Exception(msg); + } + + throw Exception('Verifikasi absen gagal'); + } + + Future> getDailyAttendance({ + required int userId, + required String date, + }) async { + final url = Uri.parse( + "${Apiconfig.baseUrl}/api/riwayat/$userId?date=$date", + ); + final response = await http.get( + url, + headers: {'Accept': 'application/json'}, + ); + + print("DAILY STATUS: ${response.statusCode}"); + print("DAILY BODY: ${response.body}"); + + final data = jsonDecode(response.body); + + if (response.statusCode == 200 && data['ok'] == true) { + return data; + } + + throw Exception("Gagal ambil data"); + } +} diff --git a/lib/data/fetch/auth_api.dart b/lib/data/fetch/auth_api.dart new file mode 100644 index 0000000..0cfe619 --- /dev/null +++ b/lib/data/fetch/auth_api.dart @@ -0,0 +1,84 @@ +import 'dart:convert'; +import 'package:http/http.dart' as http; + +import '../../core/api/api.dart'; +import '../model/user_model.dart'; + +class AuthApi { + Future login({ + required String email, + required String password, + required String deviceId, + }) async { + final url = Uri.parse('${Apiconfig.baseUrl}/api/mobile/login'); + + print("FULL URL: $url"); + + final response = await http.post( + url, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: { + 'email': email, + 'password': password, + 'device_id': deviceId, + }, + ); + + print("STATUS CODE: ${response.statusCode}"); + print("RAW BODY: ${response.body}"); + + // 🔥 Antisipasi server mati / tidak merespon JSON + if (response.body.isEmpty) { + throw Exception("Server tidak merespon"); + } + + // 🔥 Cegah error HTML (route salah / 500 Laravel) + if (response.body.startsWith('')) { + throw Exception( + "Server mengembalikan HTML. Cek URL atau route Laravel."); + } + + final data = jsonDecode(response.body); + + // ✅ SUKSES + if (response.statusCode == 200 && data['ok'] == true) { + final userJson = data['data']; + + // 🔥 inject token ke user model (penting!) + userJson['token'] = data['token']; + + // 🔥 Fix URL foto + if (userJson['url_photo'] != null && + userJson['url_photo'].toString().isNotEmpty && + !userJson['url_photo'].toString().startsWith('http')) { + userJson['url_photo'] = + "${Apiconfig.baseUrl}/storage/${userJson['url_photo']}"; + } + + print("FINAL PHOTO URL: ${userJson['url_photo']}"); + print("TOKEN: ${data['token']}"); + + return UserModel.fromJson(userJson); + } + + // ❌ HANDLE ERROR LEBIH SPESIFIK + if (response.statusCode == 401) { + throw Exception("Email atau password salah"); + } + + if (response.statusCode == 403) { + throw Exception(data['message'] ?? + "Akun sudah digunakan di device lain"); + } + + if (response.statusCode == 422) { + throw Exception("Validasi gagal"); + } + + // fallback + throw Exception(data['message'] ?? 'Login gagal'); + } +} \ No newline at end of file diff --git a/lib/data/model/user_model.dart b/lib/data/model/user_model.dart new file mode 100644 index 0000000..6a60d13 --- /dev/null +++ b/lib/data/model/user_model.dart @@ -0,0 +1,185 @@ +import 'dart:convert'; + +/// ======================= +/// USER MODEL +/// ======================= +class UserModel { + const UserModel({ + this.id, + this.nik, + this.name, + this.tempatLahir, + this.tanggalLahir, + this.email, + this.role, + this.jabatan, + this.phone, + this.noTelepon, + this.employeeId, + this.status, + this.address, + this.alamat, + this.hireDate, + this.jenisKelamin, + this.urlPhoto, + this.password, + }); + + final int? id; + final String? nik; + final String? name; + final String? tempatLahir; + final String? tanggalLahir; + final String? email; + final String? role; + final String? jabatan; + final String? phone; + final String? noTelepon; + final String? employeeId; + final String? status; + final String? address; + final String? alamat; + final String? hireDate; + final String? jenisKelamin; + final String? urlPhoto; + final String? password; + + factory UserModel.fromJson(Map json) { + return UserModel( + id: _parseInt(json['id']), + nik: json['nik']?.toString(), + name: json['name']?.toString(), + tempatLahir: json['tempat_lahir']?.toString(), + tanggalLahir: json['tanggal_lahir']?.toString(), + email: json['email']?.toString(), + role: json['role']?.toString(), + jabatan: json['jabatan']?.toString(), + phone: json['phone']?.toString(), + noTelepon: json['no_telepon']?.toString(), + employeeId: json['employee_id']?.toString(), + status: json['status']?.toString(), + address: json['address']?.toString(), + alamat: json['alamat']?.toString(), + hireDate: json['hire_date']?.toString(), + jenisKelamin: json['jenis_kelamin']?.toString(), + urlPhoto: json['url_photo']?.toString(), + password: json['password']?.toString(), + ); + } + + Map toJson() { + return { + 'id': id, + 'nik': nik, + 'name': name, + 'tempat_lahir': tempatLahir, + 'tanggal_lahir': tanggalLahir, + 'email': email, + 'role': role, + 'jabatan': jabatan, + 'phone': phone, + 'no_telepon': noTelepon, + 'employee_id': employeeId, + 'status': status, + 'address': address, + 'alamat': alamat, + 'hire_date': hireDate, + 'jenis_kelamin': jenisKelamin, + 'url_photo': urlPhoto, + 'password': password, + }; + } + + String toJsonString() => jsonEncode(toJson()); + + factory UserModel.fromJsonString(String source) => + UserModel.fromJson(jsonDecode(source)); + + Null get foto => null; + + UserModel copyWith({ + int? id, + String? nik, + String? name, + String? tempatLahir, + String? tanggalLahir, + String? email, + String? role, + String? jabatan, + String? phone, + String? noTelepon, + String? employeeId, + String? status, + String? address, + String? alamat, + String? hireDate, + String? jenisKelamin, + String? urlPhoto, + String? password, + }) { + return UserModel( + id: id ?? this.id, + nik: nik ?? this.nik, + name: name ?? this.name, + tempatLahir: tempatLahir ?? this.tempatLahir, + tanggalLahir: tanggalLahir ?? this.tanggalLahir, + email: email ?? this.email, + role: role ?? this.role, + jabatan: jabatan ?? this.jabatan, + phone: phone ?? this.phone, + noTelepon: noTelepon ?? this.noTelepon, + employeeId: employeeId ?? this.employeeId, + status: status ?? this.status, + address: address ?? this.address, + alamat: alamat ?? this.alamat, + hireDate: hireDate ?? this.hireDate, + jenisKelamin: jenisKelamin ?? this.jenisKelamin, + urlPhoto: urlPhoto ?? this.urlPhoto, + password: password ?? this.password, + ); + } + + static int? _parseInt(dynamic value) { + if (value == null) return null; + if (value is int) return value; + return int.tryParse(value.toString()); + } +} + +/// ======================= +/// DAILY MODEL +/// ======================= +class DailyModel { + final int id; + final String type; + final String jenis; + final String tanggal; + final String jam; + final String icon; + final String statusValidasi; + final String sortDate; + + DailyModel({ + required this.id, + required this.type, + required this.jenis, + required this.tanggal, + required this.jam, + required this.icon, + required this.statusValidasi, + required this.sortDate, + }); + + factory DailyModel.fromJson(Map json) { + return DailyModel( + id: json['id'] ?? 0, + type: json['type'] ?? '', + jenis: json['jenis'] ?? '', + tanggal: json['tanggal'] ?? '', + jam: json['jam'] ?? '', + icon: json['icon'] ?? '', + statusValidasi: json['status_validasi'] ?? '', + sortDate: json['sort_date'] ?? '', + ); + } +} \ No newline at end of file diff --git a/lib/data/shared/auth_storage.dart b/lib/data/shared/auth_storage.dart new file mode 100644 index 0000000..753e7e7 --- /dev/null +++ b/lib/data/shared/auth_storage.dart @@ -0,0 +1,32 @@ +import 'package:shared_preferences/shared_preferences.dart'; + +import '../model/user_model.dart'; + +class AuthStorage { + static const _keyUser = 'auth_user'; + static const _keyLoggedIn = 'auth_logged_in'; + + Future saveUser(UserModel user) async { + final prefs = await SharedPreferences.getInstance(); + await prefs.setString(_keyUser, user.toJsonString()); + await prefs.setBool(_keyLoggedIn, true); + } + + Future getUser() async { + final prefs = await SharedPreferences.getInstance(); + final raw = prefs.getString(_keyUser); + if (raw == null || raw.isEmpty) return null; + return UserModel.fromJsonString(raw); + } + + Future isLoggedIn() async { + final prefs = await SharedPreferences.getInstance(); + return prefs.getBool(_keyLoggedIn) ?? false; + } + + Future logout() async { + final prefs = await SharedPreferences.getInstance(); + await prefs.remove(_keyUser); + await prefs.setBool(_keyLoggedIn, false); + } +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..7b9623b --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/presentation/views/splash_screen.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + @override + Widget build(BuildContext context) { + return GetMaterialApp( + title: 'Sidak Desa Mobile', + debugShowCheckedModeBanner: false, + theme: ThemeData( + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + ), + home: SplashScreen(), + ); + } +} diff --git a/lib/presentation/controllers/absen_controller.dart b/lib/presentation/controllers/absen_controller.dart new file mode 100644 index 0000000..f7a0ebe --- /dev/null +++ b/lib/presentation/controllers/absen_controller.dart @@ -0,0 +1,325 @@ +// ignore_for_file: unused_local_variable + +import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/presentation/views/main_screen.dart'; + +import '../../data/fetch/attedance_api.dart'; +import '../../data/model/user_model.dart'; +import '../../data/shared/auth_storage.dart'; +import '../../utils/device_id.dart'; + +class AbsenController extends GetxController { + AbsenController({required Map qrData}) { + this.qrData.value = qrData; + } + + final _api = AttedanceApi(); + final _storage = AuthStorage(); + + final user = Rxn(); + final qrData = {}.obs; + final nameController = TextEditingController(); + + final isSubmitting = false.obs; + final isLoadingDaily = false.obs; + final isLoadingLocation = false.obs; + final latitude = RxnDouble(); + final longitude = RxnDouble(); + final locationError = RxnString(); + + final selectedDate = ''.obs; + final daily = Rxn>(); + + @override + void onInit() { + _init(); + super.onInit(); + } + + Future _init() async { + selectedDate.value = _todayDate(); + await loadUser(); + await fetchDaily(); + await getCurrentLocation(); + } + + Future loadUser() async { + user.value = await _storage.getUser(); + nameController.text = user.value?.name ?? ''; + } + + @override + void onClose() { + nameController.dispose(); + super.onClose(); + } + + String get checkInText => _formatTime(daily.value?['check_in']); + String get checkOutText => _formatTime(daily.value?['check_out']); + + Future fetchDaily() async { + final uid = user.value?.id; + if (uid == null) return; + + isLoadingDaily.value = true; + + try { + final res = await _api.getDailyAttendance( + userId: uid, + date: selectedDate.value, + ); + + if (res['ok'] == true) { + if (res['data'] != null && res['data'] is Map) { + daily.value = Map.from(res['data']); + } else { + daily.value = null; + } + } else { + daily.value = null; + } + } catch (_) { + daily.value = null; + } finally { + isLoadingDaily.value = false; + } + } + + Future submitAbsen() async { + if (isSubmitting.value) return; + + final token = (qrData['raw'] ?? '').toString().trim(); + final uid = user.value?.id; + if (token.isEmpty || uid == null) return; + + isSubmitting.value = true; + + try { + final deviceId = await DeviceIdUtil.getDeviceId(); + + final response = await _api.verifyAttendance( + token: token, + userId: uid, + deviceInfo: deviceId, + latitude: latitude.value, + longitude: longitude.value, + ); + + await fetchDaily(); + + // ✅ DIALOG BERHASIL + Get.dialog( + Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 80, + height: 80, + decoration: const BoxDecoration( + color: Color(0xFF0F766E), // hijau teal + shape: BoxShape.circle, + ), + child: const Icon(Icons.check, color: Colors.white, size: 45), + ), + const SizedBox(height: 16), + const Text( + "Absensi Berhasil", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + const Text( + "Absensi berhasil dilakukan", + textAlign: TextAlign.center, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () { + Get.offAll(() => const MainScreen()); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + ), + child: const Text( + "Oke", + style: TextStyle(color: Colors.white), + ), + ), + ), + ], + ), + ), + ), + barrierDismissible: false, + ); + } catch (e) { + // ❌ DIALOG DITOLAK + Get.dialog( + Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 80, + height: 80, + decoration: const BoxDecoration( + color: Colors.red, + shape: BoxShape.circle, + ), + child: const Icon(Icons.close, color: Colors.white, size: 45), + ), + const SizedBox(height: 16), + const Text( + "Absen Ditolak", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + Text( + e.toString().replaceAll('Exception:', ''), + textAlign: TextAlign.center, + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => Get.back(), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ), + ], + ), + ), + ), + barrierDismissible: false, + ); + } finally { + isSubmitting.value = false; + } + } + + Future getCurrentLocation() async { + isLoadingLocation.value = true; + locationError.value = null; + + try { + final isServiceEnabled = await Geolocator.isLocationServiceEnabled(); + if (!isServiceEnabled) { + locationError.value = 'Layanan lokasi tidak aktif'; + return; + } + + var permission = await Geolocator.checkPermission(); + if (permission == LocationPermission.denied) { + permission = await Geolocator.requestPermission(); + } + + if (permission == LocationPermission.denied || + permission == LocationPermission.deniedForever) { + locationError.value = 'Izin lokasi ditolak'; + return; + } + + final position = await Geolocator.getCurrentPosition( + locationSettings: const LocationSettings( + accuracy: LocationAccuracy.high, + ), + ); + + latitude.value = position.latitude; + longitude.value = position.longitude; + } catch (_) { + locationError.value = 'Gagal mengambil lokasi terkini'; + } finally { + isLoadingLocation.value = false; + } + } + + String _todayDate() { + final now = DateTime.now(); + final yyyy = now.year.toString().padLeft(4, '0'); + final mm = now.month.toString().padLeft(2, '0'); + final dd = now.day.toString().padLeft(2, '0'); + return '$yyyy-$mm-$dd'; + } + + String _formatTime(dynamic value) { + if (value == null) return '-'; + final s = value.toString().trim(); + if (s.isEmpty || s == 'null') return '-'; + + if (s.contains('T')) { + try { + final dt = DateTime.parse(s).toLocal(); + final hh = dt.hour.toString().padLeft(2, '0'); + final mm = dt.minute.toString().padLeft(2, '0'); + return '$hh:$mm'; + } catch (_) {} + } + + final parts = s.split(':'); + if (parts.length >= 2) { + return '${parts[0].padLeft(2, '0')}:${parts[1].padLeft(2, '0')}'; + } + + return s; + } + + String get tanggalFormatted { + final now = DateTime.now(); + return "${now.day} ${_bulanIndo(now.month)} ${now.year}"; + } + + String _bulanIndo(int bulan) { + const bulanList = [ + "", + "Januari", + "Februari", + "Maret", + "April", + "Mei", + "Juni", + "Juli", + "Agustus", + "September", + "Oktober", + "November", + "Desember", + ]; + return bulanList[bulan]; + } + + String get statusText { + if (daily.value == null) return "-"; + if (daily.value?['check_in'] != null) { + return "Hadir"; + } + return "-"; + } + + String get keteranganText { + if (daily.value == null) return "-"; + final checkIn = daily.value?['check_in']; + if (checkIn == null) return "-"; + return "Tepat Waktu"; + } +} diff --git a/lib/presentation/controllers/dashboard_controller.dart b/lib/presentation/controllers/dashboard_controller.dart new file mode 100644 index 0000000..f64a80f --- /dev/null +++ b/lib/presentation/controllers/dashboard_controller.dart @@ -0,0 +1,140 @@ +import 'package:get/get.dart'; +import '../../data/fetch/attedance_api.dart'; +import '../../data/model/user_model.dart'; +import '../../data/shared/auth_storage.dart'; + +class DashboardController extends GetxController { + final _api = AttedanceApi(); + final _storage = AuthStorage(); + + final user = Rxn(); + final dailyList = [].obs; + + final datangInfo = '- WIB'.obs; + final pulangInfo = '- WIB'.obs; + final isLoadingDaily = false.obs; + final selectedDate = ''.obs; + + final isLoading = false.obs; + + @override + void onInit() { + super.onInit(); + _initialize(); + } + + Future _initialize() async { + selectedDate.value = _todayDate(); + + await fetchUser(); + + if (user.value != null) { + await fetchDaily(); + } else { + print("USER NULL - fetchDaily dibatalkan"); + } + } + + /// ================= REFRESH ================= + Future refreshAll() async { + await fetchUser(); + await fetchDaily(); + } + + /// ================= FETCH USER ================= + Future fetchUser() async { + try { + isLoading.value = true; + + final userData = await _storage.getUser(); + + if (userData == null) { + print("User kosong"); + isLoading.value = false; + return; + } + + // ✅ FIX: langsung assign + user.value = userData; + + print("USER FETCHED: ${user.value?.id}"); + + isLoading.value = false; + } catch (e) { + print("ERROR FETCH USER: $e"); + isLoading.value = false; + } + } + + /// ================= LOGOUT ================= + Future logout() async { + await _storage.logout(); + } + + /// ================= FETCH DAILY ================= + Future fetchDaily() async { + final uid = user.value?.id; + + if (uid == null) { + print("UID NULL - Tidak bisa fetchDaily"); + return; + } + + isLoadingDaily.value = true; + + try { + print("FETCH DAILY UID: $uid"); + print("DATE: ${selectedDate.value}"); + + final res = await _api.getDailyAttendance( + userId: uid, + date: selectedDate.value, + ); + + print("API RESULT: $res"); + + if (res['ok'] == true && res['data'] is List) { + List listData = res['data']; + + dailyList.value = listData.map((e) => DailyModel.fromJson(e)).toList(); + + if (dailyList.isNotEmpty) { + final today = dailyList.first; + + if (today.jam.contains('-')) { + final split = today.jam.split('-'); + + datangInfo.value = "${split[0].trim()} WIB"; + pulangInfo.value = "${split.last.trim()} WIB"; + } else { + _resetAttendance(); + } + } + + print("TOTAL DATA DASHBOARD: ${dailyList.length}"); + } else { + _resetAttendance(); + } + } catch (e) { + print("ERROR FETCH DAILY: $e"); + _resetAttendance(); + } finally { + isLoadingDaily.value = false; + } + } + + /// ================= RESET ================= + void _resetAttendance() { + dailyList.clear(); + datangInfo.value = '- WIB'; + pulangInfo.value = '- WIB'; + } + + /// ================= DATE ================= + String _todayDate() { + final now = DateTime.now(); + return '${now.year.toString().padLeft(4, '0')}-' + '${now.month.toString().padLeft(2, '0')}-' + '${now.day.toString().padLeft(2, '0')}'; + } +} diff --git a/lib/presentation/controllers/login_controller.dart b/lib/presentation/controllers/login_controller.dart new file mode 100644 index 0000000..f38993c --- /dev/null +++ b/lib/presentation/controllers/login_controller.dart @@ -0,0 +1,62 @@ +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/presentation/views/main_screen.dart'; + +import '../../data/fetch/auth_api.dart'; +import '../../data/shared/auth_storage.dart'; +import '../../utils/device_id.dart'; + +class LoginController extends GetxController { + final AuthApi _api = AuthApi(); + final AuthStorage _storage = AuthStorage(); + + final isLoading = false.obs; + final errorMessage = RxnString(); + + Future login({required String email, required String password}) async { + errorMessage.value = null; + + if (email.isEmpty || password.isEmpty) { + errorMessage.value = 'Email dan password wajib diisi'; + return; + } + + isLoading.value = true; + + try { + // ✅ Ambil device ID + final deviceId = await DeviceIdUtil.getDeviceId(); + + if (deviceId == null || deviceId.isEmpty) { + throw Exception('Device ID tidak ditemukan'); + } + + // ✅ Hit API login (pastikan kirim device_id) + final response = await _api.login( + email: email, + password: password, + deviceId: deviceId, + ); + + // ✅ Simpan user + token + await _storage.saveUser(response); + + // ✅ Pindah ke halaman utama + Get.offAll(() => MainScreen()); + } catch (e) { + final message = e.toString().replaceFirst('Exception: ', ''); + + errorMessage.value = message; + + // 🔥 Custom handling dari backend + if (message.contains('device lain')) { + Get.snackbar('Akses Ditolak', message); + } else if (message.contains('Email atau password salah')) { + Get.snackbar('Login Gagal', message); + } else { + Get.snackbar('Error', message); + } + } finally { + isLoading.value = false; + } + } +} diff --git a/lib/presentation/controllers/splash_screen_controller.dart b/lib/presentation/controllers/splash_screen_controller.dart new file mode 100644 index 0000000..39efdbb --- /dev/null +++ b/lib/presentation/controllers/splash_screen_controller.dart @@ -0,0 +1,32 @@ +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/data/shared/auth_storage.dart'; +import 'package:sidak_desa_mobile/presentation/views/login_screen.dart'; +import 'package:sidak_desa_mobile/presentation/views/main_screen.dart'; + +class SplashScreenController extends GetxController { + final AuthStorage _authStorage = AuthStorage(); + + @override + void onInit() { + super.onInit(); + _checkAuthSession(); + } + + Future _checkAuthSession() async { + await Future.delayed(const Duration(seconds: 2)); + + try { + final isLoggedIn = await _authStorage.isLoggedIn(); + final user = await _authStorage.getUser(); + + if (isLoggedIn && user != null) { + Get.offAll(() => const MainScreen()); + return; + } + } catch (_) { + // Fallback to login when local session data cannot be read. + } + + Get.offAll(() => LoginScreen()); + } +} diff --git a/lib/presentation/views/login_screen.dart b/lib/presentation/views/login_screen.dart new file mode 100644 index 0000000..3966822 --- /dev/null +++ b/lib/presentation/views/login_screen.dart @@ -0,0 +1,284 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; +import 'package:sidak_desa_mobile/core/widgets/app_button.dart'; +import 'package:sidak_desa_mobile/core/widgets/app_textfield.dart'; +import 'package:sidak_desa_mobile/core/widgets/app_textfield_password.dart'; +import 'package:sidak_desa_mobile/presentation/controllers/login_controller.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/forgotpassword_page.dart'; + +class LoginScreen extends StatefulWidget { + const LoginScreen({super.key}); + + @override + State createState() => _LoginScreenState(); +} + +class _LoginScreenState extends State { + final TextEditingController emailController = TextEditingController(); + final TextEditingController passwordController = TextEditingController(); + + final LoginController controller = Get.put(LoginController()); + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void dispose() { + emailController.dispose(); + passwordController.dispose(); + super.dispose(); + } + + void login() { + final email = emailController.text.trim(); + final password = passwordController.text; + + if (email.isEmpty || password.isEmpty) { + Get.snackbar( + 'Data Belum Lengkap', + 'Email dan password wajib diisi.', + backgroundColor: Colors.red, + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + margin: const EdgeInsets.all(16), + borderRadius: 12, + ); + return; + } + + controller.login(email: email, password: password); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: SafeArea( + child: Stack( + children: [ + Container( + height: 310, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [Color(0xFF0B7D77), Color(0xFF0FA39A)], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(36), + bottomRight: Radius.circular(36), + ), + ), + ), + + SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(22, 28, 22, 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 8), + + Column( + children: [ + Container( + width: 250, + height: 102, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(30), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.12), + blurRadius: 22, + offset: Offset(0, 10), + ), + ], + ), + child: Image.asset( + 'assets/images/logo.png', + fit: BoxFit.contain, + ), + ), + + const SizedBox(height: 20), + + const Text( + 'Selamat Datang', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 27, + height: 1.2, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + + const SizedBox(height: 8), + + const Text( + 'Silakan masuk untuk melanjutkan ke aplikasi SIDAK Desa.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + height: 1.5, + color: Color.fromRGBO(255, 255, 255, 0.88), + ), + ), + ], + ), + + const SizedBox(height: 34), + + Container( + padding: const EdgeInsets.all(22), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + blurRadius: 24, + offset: Offset(0, 12), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: Image.asset( + 'assets/images/ilustrasi.png', + width: 190, + fit: BoxFit.contain, + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Masuk Akun', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 6), + + const Text( + 'Gunakan email dan password yang sudah terdaftar.', + style: TextStyle( + fontSize: 13, + height: 1.5, + color: textSoftColor, + ), + ), + + const SizedBox(height: 24), + + const Text( + 'Email', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: textDarkColor, + ), + ), + + const SizedBox(height: 8), + + AppTextField( + hintText: 'Masukkan email', + keyboardType: TextInputType.emailAddress, + controller: emailController, + textInputAction: TextInputAction.next, + ), + + const SizedBox(height: 18), + + const Text( + 'Password', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: textDarkColor, + ), + ), + + const SizedBox(height: 8), + + AppTextFieldPassword( + hintText: 'Masukkan password', + controller: passwordController, + textInputAction: TextInputAction.done, + ), + + const SizedBox(height: 12), + + Align( + alignment: Alignment.centerRight, + child: GestureDetector( + onTap: () { + Get.to(() => const ForgotPasswordPage()); + }, + child: const Text( + 'Lupa kata sandi?', + style: TextStyle( + color: primaryColor, + fontSize: 14, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + + const SizedBox(height: 26), + + Obx( + () => controller.isLoading.value + ? const SizedBox( + height: 54, + child: Center( + child: CircularProgressIndicator( + color: primaryColor, + ), + ), + ) + : SizedBox( + height: 54, + child: AppButton( + text: 'Masuk', + onPressed: login, + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Pastikan data login Anda benar sebelum masuk ke aplikasi.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + height: 1.5, + color: textSoftColor, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/views/main_screen.dart b/lib/presentation/views/main_screen.dart new file mode 100644 index 0000000..a148164 --- /dev/null +++ b/lib/presentation/views/main_screen.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/core/widgets/app_bottom_navbar.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/dashboard_screen.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/profile_screen.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/scanner_screen.dart'; + +class MainScreen extends StatefulWidget { + const MainScreen({super.key}); + + @override + State createState() => _MainScreenState(); +} + +class _MainScreenState extends State { + int _currentIndex = 0; + + final _pages = const [DashboardScreen(), ProfileScreen()]; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + body: IndexedStack(index: _currentIndex, children: _pages), + bottomNavigationBar: SafeArea( + minimum: const EdgeInsets.fromLTRB(14, 0, 14, 10), + child: AppBottomNavbar( + currentIndex: _currentIndex, + onTabSelected: (index) { + setState(() { + _currentIndex = index; + }); + }, + onCenterTap: () { + Get.to(() => const ScannerScreen()); + }, + ), + ), + ); + } +} diff --git a/lib/presentation/views/pages/absen_screen.dart b/lib/presentation/views/pages/absen_screen.dart new file mode 100644 index 0000000..8798b45 --- /dev/null +++ b/lib/presentation/views/pages/absen_screen.dart @@ -0,0 +1,162 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_map/flutter_map.dart'; +import 'package:get/get.dart'; +import 'package:latlong2/latlong.dart'; +import '../../controllers/absen_controller.dart'; + +class AbsenScreen extends StatelessWidget { + const AbsenScreen({super.key, required this.qrData}); + + final Map qrData; + + @override + Widget build(BuildContext context) { + final c = Get.put(AbsenController(qrData: qrData)); + + return Scaffold( + appBar: AppBar(title: const Text("ABSEN"), centerTitle: true), + body: Padding( + padding: const EdgeInsets.all(16), + child: Obx(() { + final lat = c.latitude.value; + final lng = c.longitude.value; + + Widget buildField(String label, String value) { + return Padding( + padding: const EdgeInsets.only(bottom: 14), + child: Row( + children: [ + SizedBox( + width: 95, + child: Text( + "$label :", + style: const TextStyle(fontSize: 14), + ), + ), + Expanded( + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 14, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + border: Border.all(color: Colors.teal), + ), + child: Text( + value, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w500, + ), + ), + ), + ), + ], + ), + ); + } + + return SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + buildField("Nama", c.user.value?.name ?? "-"), + + buildField("Tanggal", c.tanggalFormatted), + + buildField("Jabatan", c.user.value?.jabatan ?? "-"), + + buildField("Jenis Kelamin", c.user.value?.jenisKelamin ?? "-"), + + buildField("Alamat", c.user.value?.address ?? "-"), + + const SizedBox(height: 10), + const Text("Lokasi :", style: TextStyle(fontSize: 14)), + const SizedBox(height: 8), + + if (lat != null && lng != null) + SizedBox( + height: 200, + child: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: FlutterMap( + options: MapOptions( + initialCenter: LatLng(lat, lng), + initialZoom: 16, + ), + children: [ + TileLayer( + urlTemplate: + 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + userAgentPackageName: 'com.sidakdesa.mobile', + ), + MarkerLayer( + markers: [ + Marker( + point: LatLng(lat, lng), + width: 40, + height: 40, + child: const Icon( + Icons.location_on, + color: Colors.red, + size: 36, + ), + ), + ], + ), + ], + ), + ), + ) + else + Container( + height: 200, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.grey.shade200, + ), + child: const Text("Lokasi belum tersedia"), + ), + + const SizedBox(height: 24), + + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: c.isSubmitting.value ? null : c.submitAbsen, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + minimumSize: const Size.fromHeight(55), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + child: c.isSubmitting.value + ? const Text( + "Memproses...", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ) + : const Text( + "Kirim", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ); + }), + ), + ); + } +} diff --git a/lib/presentation/views/pages/dashboard_screen.dart b/lib/presentation/views/pages/dashboard_screen.dart new file mode 100644 index 0000000..5a95f76 --- /dev/null +++ b/lib/presentation/views/pages/dashboard_screen.dart @@ -0,0 +1,582 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/presentation/views/login_screen.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/detail_riwayat.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/fiturizin_page.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/riwayat_page.dart'; + +import '../../controllers/dashboard_controller.dart'; + +class DashboardScreen extends StatelessWidget { + const DashboardScreen({super.key}); + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color secondaryColor = Color(0xFF0FA39A); + static const Color accentColor = Color(0xFFFF8C32); + static const Color yellowColor = Color(0xFFF3C644); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + Widget build(BuildContext context) { + final DashboardController controller = + Get.isRegistered() + ? Get.find() + : Get.put(DashboardController()); + + return Scaffold( + backgroundColor: backgroundColor, + body: RefreshIndicator( + color: primaryColor, + onRefresh: () async { + await controller.refreshAll(); + }, + child: SingleChildScrollView( + physics: const AlwaysScrollableScrollPhysics(), + child: SafeArea( + child: Stack( + children: [ + Container( + height: 300, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + primaryColor, + secondaryColor, + ], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(0), + bottomRight: Radius.circular(0), + ), + ), + ), + + Padding( + padding: const EdgeInsets.fromLTRB(16, 18, 16, 28), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildHeader(controller), + + const SizedBox(height: 24), + + _buildBanner(), + + const SizedBox(height: 22), + + _buildMenuSection(controller), + + const SizedBox(height: 24), + + _buildTodayInfo(controller), + + const SizedBox(height: 30), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } + + Widget _buildHeader(DashboardController controller) { + return Obx(() { + final user = controller.user.value; + final photoUrl = user?.urlPhoto; + + return Row( + children: [ + _buildProfileAvatar(photoUrl), + + const SizedBox(width: 12), + + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Selamat Datang 👋', + style: TextStyle( + fontSize: 13, + color: Color.fromRGBO(255, 255, 255, 0.85), + ), + ), + + const SizedBox(height: 4), + + Text( + user?.name ?? 'User', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 19, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + ], + ), + ), + + const SizedBox(width: 10), + + InkWell( + onTap: () { + controller.logout().then((_) { + Get.offAll(() => const LoginScreen()); + }); + }, + borderRadius: BorderRadius.circular(14), + child: Container( + width: 44, + height: 44, + decoration: BoxDecoration( + color: const Color.fromRGBO(255, 255, 255, 0.18), + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.logout_rounded, + color: Colors.white, + size: 22, + ), + ), + ), + ], + ); + }); + } + + Widget _buildProfileAvatar(String? photoUrl) { + return Container( + width: 58, + height: 58, + padding: const EdgeInsets.all(3), + decoration: BoxDecoration( + color: const Color.fromRGBO(255, 255, 255, 0.25), + shape: BoxShape.circle, + border: Border.all( + color: const Color.fromRGBO(255, 255, 255, 0.45), + width: 1.4, + ), + ), + child: ClipOval( + child: Container( + color: Colors.white, + child: (photoUrl != null && photoUrl.isNotEmpty) + ? Image.network( + photoUrl, + width: 52, + height: 52, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return const Icon( + Icons.person_rounded, + color: primaryColor, + size: 30, + ); + }, + ) + : const Icon( + Icons.person_rounded, + color: primaryColor, + size: 30, + ), + ), + ), + ); + } + + Widget _buildBanner() { + return Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + blurRadius: 24, + offset: Offset(0, 12), + ), + ], + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + decoration: BoxDecoration( + color: const Color.fromRGBO(11, 125, 119, 0.10), + borderRadius: BorderRadius.circular(100), + ), + child: const Text( + 'Absensi Hari Ini', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, + color: primaryColor, + ), + ), + ), + + const SizedBox(height: 12), + + const Text( + 'Sudah absen\nhari ini?', + style: TextStyle( + fontSize: 23, + height: 1.15, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 8), + + const Text( + 'Ayo laporkan kegiatanmu hari ini dengan cepat dan mudah.', + style: TextStyle( + fontSize: 13, + height: 1.45, + color: textSoftColor, + ), + ), + ], + ), + ), + + const SizedBox(width: 12), + + Image.asset( + 'assets/images/banner.png', + height: 105, + fit: BoxFit.contain, + ), + ], + ), + ); + } + + Widget _buildMenuSection(DashboardController controller) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Menu Utama', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 6), + + const Text( + 'Pilih fitur yang ingin digunakan.', + style: TextStyle( + fontSize: 13, + color: textSoftColor, + ), + ), + + const SizedBox(height: 14), + + Row( + children: [ + Expanded( + child: _buildMenuCard( + title: 'Izin', + subtitle: 'Ajukan izin', + imagePath: 'assets/images/Union.png', + color: yellowColor, + icon: Icons.edit_calendar_rounded, + onTap: () async { + await Get.to(() => const IzinPage()); + controller.refreshAll(); + }, + ), + ), + + const SizedBox(width: 14), + + Expanded( + child: _buildMenuCard( + title: 'Riwayat', + subtitle: 'Lihat data', + imagePath: 'assets/images/icon_riwayat.png', + color: primaryColor, + icon: Icons.history_rounded, + onTap: () async { + await Get.to(() => const RiwayatPage()); + controller.refreshAll(); + }, + ), + ), + ], + ), + ], + ); + } + + Widget _buildMenuCard({ + required String title, + required String subtitle, + required String imagePath, + required Color color, + required IconData icon, + required VoidCallback onTap, + }) { + final Color shadowColor = color == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.28) + : const Color.fromRGBO(243, 198, 68, 0.32); + + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(24), + child: Ink( + height: 178, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(24), + boxShadow: [ + BoxShadow( + color: shadowColor, + blurRadius: 18, + offset: const Offset(0, 10), + ), + ], + ), + child: Stack( + children: [ + Positioned( + right: -8, + bottom: -4, + child: Opacity( + opacity: 0.92, + child: Image.asset( + imagePath, + height: 92, + fit: BoxFit.contain, + ), + ), + ), + + Positioned( + right: 0, + top: 0, + child: Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: const Color.fromRGBO(255, 255, 255, 0.20), + borderRadius: BorderRadius.circular(12), + ), + child: Icon( + icon, + color: Colors.white, + size: 21, + ), + ), + ), + + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + color: Colors.white, + fontSize: 21, + fontWeight: FontWeight.w800, + ), + ), + + const SizedBox(height: 4), + + Text( + subtitle, + style: const TextStyle( + color: Color.fromRGBO(255, 255, 255, 0.88), + fontSize: 13, + fontWeight: FontWeight.w500, + ), + ), + + const Spacer(), + + Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 7, + ), + decoration: BoxDecoration( + color: const Color.fromRGBO(255, 255, 255, 0.18), + borderRadius: BorderRadius.circular(100), + ), + child: const Text( + 'Buka', + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ], + ), + ), + ); + } + + Widget _buildTodayInfo(DashboardController controller) { + return Container( + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(24), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.06), + blurRadius: 20, + offset: Offset(0, 10), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Row( + children: [ + Icon( + Icons.today_rounded, + color: primaryColor, + size: 22, + ), + + SizedBox(width: 8), + + Text( + 'Info Hari Ini', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + ], + ), + + const SizedBox(height: 16), + + Obx( + () => _buildInfoTile( + icon: Icons.login_rounded, + title: 'Datang', + value: controller.isLoadingDaily.value + ? 'Memuat...' + : controller.datangInfo.value, + iconColor: primaryColor, + ), + ), + + const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Divider( + height: 1, + color: Color(0xFFE2E8F0), + ), + ), + + Obx( + () => _buildInfoTile( + icon: Icons.logout_rounded, + title: 'Pulang', + value: controller.isLoadingDaily.value + ? 'Memuat...' + : controller.pulangInfo.value, + iconColor: accentColor, + ), + ), + ], + ), + ); + } + + Widget _buildInfoTile({ + required IconData icon, + required String title, + required String value, + required Color iconColor, + }) { + final Color backgroundIconColor = iconColor == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.10) + : const Color.fromRGBO(255, 140, 50, 0.10); + + return Row( + children: [ + Container( + width: 46, + height: 46, + decoration: BoxDecoration( + color: backgroundIconColor, + borderRadius: BorderRadius.circular(16), + ), + child: Icon( + icon, + color: iconColor, + size: 24, + ), + ), + + const SizedBox(width: 12), + + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 4), + + Text( + value, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 13, + height: 1.4, + fontWeight: FontWeight.w600, + color: primaryColor, + ), + ), + ], + ), + ), + ], + ); + } +} \ No newline at end of file diff --git a/lib/presentation/views/pages/detail_riwayat.dart b/lib/presentation/views/pages/detail_riwayat.dart new file mode 100644 index 0000000..2583462 --- /dev/null +++ b/lib/presentation/views/pages/detail_riwayat.dart @@ -0,0 +1,749 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; + +class DetailRiwayatPage extends StatefulWidget { + final Map data; + final int attendancesId; + + const DetailRiwayatPage({ + super.key, + required this.data, + required this.attendancesId, + }); + + @override + State createState() => _DetailRiwayatPageState(); +} + +class _DetailRiwayatPageState extends State { + late Future> futureDetail; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void initState() { + super.initState(); + futureDetail = loadDetailRiwayat(); + } + + Future> loadDetailRiwayat() async { + final listData = _unwrapData(_safeMap(widget.data)); + + debugPrint('============== DEBUG DATA DARI LIST =============='); + debugPrint('DATA DARI LIST: $listData'); + + final statusDariList = _normalizeStatusFromData(listData); + + debugPrint('STATUS DARI LIST: $statusDariList'); + + // Untuk izin, sakit, dan cuti, status dari list lebih akurat. + // Jangan biarkan data detail attendance menimpa status menjadi "Hadir". + if (statusDariList == 'izin' || + statusDariList == 'sakit' || + statusDariList == 'cuti') { + return _normalizeDisplayData({ + ...listData, + 'status': statusDariList, + 'status_jenis': statusDariList, + 'check_in': null, + 'check_out': null, + 'jam_masuk': null, + 'jam_pulang': null, + 'jam': null, + }); + } + + final int id = widget.attendancesId; + + debugPrint('ATTENDANCES ID DARI RIWAYAT PAGE: $id'); + + try { + final detailData = await getDetailRiwayat(id); + + debugPrint('============== DEBUG MERGE DATA DETAIL =============='); + debugPrint('DATA DARI API DETAIL: $detailData'); + debugPrint('DATA DARI LIST RIWAYAT: $listData'); + + final mergedData = _mergeDetailWithListData( + detailData: detailData, + listData: listData, + ); + + debugPrint('DATA SETELAH DIGABUNG: $mergedData'); + + return _normalizeDisplayData(mergedData); + } catch (e) { + debugPrint('ERROR DETAIL RIWAYAT: $e'); + debugPrint('Gagal ambil API detail. Menampilkan data dari list.'); + return _normalizeDisplayData(listData); + } + } + + Future> getDetailRiwayat(int attendancesId) async { + final urlString = '${Apiconfig.baseUrl}/api/riwayat/detail/$attendancesId'; + final url = Uri.parse(urlString); + + debugPrint('============== DEBUG DETAIL RIWAYAT =============='); + debugPrint('ATTENDANCES ID DIKIRIM KE API: $attendancesId'); + debugPrint('URL DETAIL RIWAYAT: $urlString'); + + final response = await http.get(url); + + debugPrint('STATUS CODE DETAIL RIWAYAT: ${response.statusCode}'); + debugPrint('BODY DETAIL RIWAYAT: ${response.body}'); + + if (response.statusCode != 200) { + throw Exception('Gagal mengambil detail riwayat'); + } + + final decoded = jsonDecode(response.body); + + debugPrint('DECODED DETAIL RIWAYAT: $decoded'); + + if (decoded is Map) { + final bool isSuccess = decoded['success'] == true || decoded['ok'] == true; + + debugPrint('SUCCESS DETAIL RIWAYAT: $isSuccess'); + + final detailData = decoded['data']; + + if (isSuccess && detailData is Map) { + debugPrint('DATA DETAIL RIWAYAT: $detailData'); + return detailData; + } + + if (isSuccess && detailData is Map) { + final safeDetailData = Map.from(detailData); + debugPrint('DATA DETAIL RIWAYAT: $safeDetailData'); + return safeDetailData; + } + + if (detailData is Map) { + return detailData; + } + + if (detailData is Map) { + return Map.from(detailData); + } + } + + throw Exception('Format data detail tidak sesuai'); + } + + Map _mergeDetailWithListData({ + required Map detailData, + required Map listData, + }) { + final statusTextSource = _buildStatusTextSource( + listData: listData, + detailData: detailData, + ); + + return { + ...detailData, + + // ID + 'attendances_id': detailData['attendances_id'] ?? + detailData['id'] ?? + listData['attendances_id'] ?? + listData['id'], + + // Data tanggal dari detail tetap diprioritaskan. + 'date': detailData['date'] ?? listData['date'], + 'tanggal': detailData['tanggal'] ?? listData['tanggal'], + 'sort_date': detailData['sort_date'] ?? listData['sort_date'], + + // Data waktu dari detail tetap diprioritaskan. + 'check_in': detailData['check_in'] ?? listData['check_in'], + 'check_out': detailData['check_out'] ?? listData['check_out'], + 'jam_masuk': detailData['jam_masuk'] ?? listData['jam_masuk'], + 'jam_pulang': detailData['jam_pulang'] ?? listData['jam_pulang'], + 'jam': detailData['jam'] ?? listData['jam'], + + // Data status dari list diprioritaskan karena list riwayat yang tahu sakit/izin/cuti. + 'status_jenis': listData['status_jenis'] ?? detailData['status_jenis'], + 'jenis': listData['jenis'] ?? detailData['jenis'], + 'tipe': listData['tipe'] ?? detailData['tipe'], + 'kategori': listData['kategori'] ?? detailData['kategori'], + 'alasan': listData['alasan'] ?? detailData['alasan'], + 'keterangan': listData['keterangan'] ?? detailData['keterangan'], + 'catatan': listData['catatan'] ?? detailData['catatan'], + 'notes': listData['notes'] ?? detailData['notes'], + 'status_validasi': + listData['status_validasi'] ?? detailData['status_validasi'], + 'status_kehadiran': + listData['status_kehadiran'] ?? detailData['status_kehadiran'], + 'icon': listData['icon'] ?? detailData['icon'], + + // Simpan dua sumber status agar bisa dicek saat debug. + 'status_from_list': listData['status'] ?? + listData['status_jenis'] ?? + listData['jenis'] ?? + listData['status_validasi'], + 'status_from_detail': detailData['status'], + + // Status utama diprioritaskan dari list. + // Ini yang mencegah "Sakit" berubah menjadi "Hadir" di detail. + 'status': listData['status_jenis'] ?? + listData['status'] ?? + listData['jenis'] ?? + detailData['status'], + + // Sumber gabungan untuk menentukan status final. + 'status_text_source': statusTextSource, + }; + } + + String _buildStatusTextSource({ + required Map listData, + required Map detailData, + }) { + final keys = [ + 'status_jenis', + 'jenis', + 'tipe', + 'kategori', + 'alasan', + 'keterangan', + 'catatan', + 'notes', + 'status_validasi', + 'status_kehadiran', + 'icon', + 'status', + ]; + + final values = []; + + for (final key in keys) { + values.add(listData[key]); + } + + for (final key in keys) { + values.add(detailData[key]); + } + + return values + .where((value) => _hasValue(value)) + .map((value) => value.toString().toLowerCase().trim()) + .join(' '); + } + + Map _safeMap(Map value) { + return Map.from(value); + } + + Map _unwrapData(Map value) { + final data = value['data']; + + if (data is Map) { + return data; + } + + if (data is Map) { + return Map.from(data); + } + + return value; + } + + Map _normalizeDisplayData(Map data) { + final String? jam = _nullableText(data['jam']); + + String? checkIn = _nullableText(data['check_in'] ?? data['jam_masuk']); + String? checkOut = _nullableText(data['check_out'] ?? data['jam_pulang']); + + if ((checkIn == null || checkOut == null) && + jam != null && + jam.contains('-')) { + final parts = jam.split('-'); + + if (parts.isNotEmpty && checkIn == null) { + checkIn = parts[0].trim(); + } + + if (parts.length > 1 && checkOut == null) { + checkOut = parts[1].trim(); + } + } + + final status = _normalizeStatusFromData(data); + + return { + 'attendances_id': data['attendances_id'] ?? data['id'], + 'date': data['date'] ?? data['tanggal'] ?? data['sort_date'], + 'check_in': checkIn, + 'check_out': checkOut, + 'status': status, + 'lates_minutes': data['lates_minutes'] ?? data['late_minutes'], + 'notes': _pickNotesByStatus(data, status), + 'device_info': data['device_info'], + 'location': data['location'] ?? data['lokasi'], + }; + } + + dynamic _pickNotesByStatus(Map data, String status) { + if (status == 'sakit' || status == 'izin' || status == 'cuti') { + return data['alasan'] ?? + data['keterangan'] ?? + data['catatan'] ?? + data['notes']; + } + + return data['notes'] ?? + data['catatan'] ?? + data['keterangan'] ?? + data['alasan']; + } + + String _normalizeStatusFromData(Map data) { + final List priorityValues = [ + data['status_jenis'], + data['status_text_source'], + data['jenis'], + data['tipe'], + data['kategori'], + data['alasan'], + data['keterangan'], + data['catatan'], + data['notes'], + data['status_validasi'], + data['status_kehadiran'], + data['icon'], + data['status_from_list'], + data['status_from_detail'], + data['status'], + ]; + + final joinedText = priorityValues + .where((value) => _hasValue(value)) + .map((value) => value.toString().toLowerCase().trim()) + .join(' '); + + debugPrint('============== DEBUG NORMALIZE STATUS =============='); + debugPrint('TEXT STATUS GABUNGAN: $joinedText'); + + if (joinedText.contains('sakit')) { + return 'sakit'; + } + + if (joinedText.contains('cuti')) { + return 'cuti'; + } + + if (joinedText.contains('izin')) { + return 'izin'; + } + + if (joinedText.contains('diajukan') || joinedText.contains('menunggu')) { + return 'izin'; + } + + if (joinedText.contains('alpha') || joinedText.contains('ditolak')) { + return 'alpha'; + } + + if (joinedText.contains('tidak hadir')) { + return 'tidak hadir'; + } + + if (joinedText.contains('hadir')) { + return 'hadir'; + } + + return 'tidak diketahui'; + } + + bool _hasValue(dynamic value) { + if (value == null) { + return false; + } + + final text = value.toString().trim(); + + if (text.isEmpty || text.toLowerCase() == 'null') { + return false; + } + + return true; + } + + String? _nullableText(dynamic value) { + if (!_hasValue(value)) { + return null; + } + + return value.toString().trim(); + } + + String _safeText(dynamic value, {String fallback = '-'}) { + if (!_hasValue(value)) { + return fallback; + } + + return value.toString().trim(); + } + + Color statusColor(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + return primaryColor; + case 'izin': + case 'sakit': + case 'cuti': + return accentColor; + case 'alpha': + case 'tidak hadir': + return Colors.red; + default: + return Colors.grey; + } + } + + String statusText(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + return 'Hadir'; + case 'izin': + return 'Izin'; + case 'sakit': + return 'Sakit'; + case 'cuti': + return 'Cuti'; + case 'alpha': + return 'Alpha'; + case 'tidak hadir': + return 'Tidak Hadir'; + default: + return 'Tidak diketahui'; + } + } + + IconData statusIcon(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + return Icons.check_rounded; + case 'izin': + case 'sakit': + case 'cuti': + return Icons.hourglass_top_rounded; + case 'alpha': + case 'tidak hadir': + return Icons.close_rounded; + default: + return Icons.help_outline_rounded; + } + } + + Color _softBackgroundColor(Color color) { + if (color == primaryColor) { + return const Color.fromRGBO(11, 125, 119, 0.10); + } + + if (color == accentColor) { + return const Color.fromRGBO(255, 140, 50, 0.10); + } + + if (color == Colors.red) { + return const Color.fromRGBO(244, 67, 54, 0.10); + } + + return const Color.fromRGBO(158, 158, 158, 0.10); + } + + Color _softBorderColor(Color color) { + if (color == primaryColor) { + return const Color.fromRGBO(11, 125, 119, 0.18); + } + + if (color == accentColor) { + return const Color.fromRGBO(255, 140, 50, 0.18); + } + + if (color == Colors.red) { + return const Color.fromRGBO(244, 67, 54, 0.18); + } + + return const Color.fromRGBO(158, 158, 158, 0.18); + } + + Widget _buildStatusCard(Map data) { + final status = data['status']; + final color = statusColor(status); + + return Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: _softBackgroundColor(color), + borderRadius: BorderRadius.circular(24), + border: Border.all( + color: _softBorderColor(color), + ), + ), + child: Column( + children: [ + Container( + width: 62, + height: 62, + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + ), + child: Icon( + statusIcon(status), + color: Colors.white, + size: 34, + ), + ), + const SizedBox(height: 14), + const Text( + 'Status Kehadiran', + style: TextStyle( + fontSize: 13, + color: textSoftColor, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 6), + Text( + statusText(status), + style: TextStyle( + color: color, + fontWeight: FontWeight.w900, + fontSize: 21, + ), + ), + ], + ), + ); + } + + Widget _buildItem({ + required IconData icon, + required String title, + required dynamic value, + Color iconColor = primaryColor, + }) { + final textValue = _safeText(value); + + return Container( + margin: const EdgeInsets.only(bottom: 12), + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(18), + boxShadow: const [ + BoxShadow( + blurRadius: 18, + color: Color.fromRGBO(0, 0, 0, 0.06), + offset: Offset(0, 8), + ), + ], + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 44, + height: 44, + decoration: BoxDecoration( + color: iconColor == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.10) + : const Color.fromRGBO(255, 140, 50, 0.10), + borderRadius: BorderRadius.circular(15), + ), + child: Icon( + icon, + color: iconColor, + size: 22, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: textSoftColor, + ), + ), + const SizedBox(height: 4), + Text( + textValue, + style: const TextStyle( + fontSize: 14, + height: 1.4, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + ], + ), + ), + ], + ), + ); + } + + Widget _buildLoadingView() { + return const Center( + child: CircularProgressIndicator( + color: primaryColor, + ), + ); + } + + Widget _buildErrorView(Object? error) { + return Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.warning_amber_rounded, + color: Colors.red, + size: 52, + ), + const SizedBox(height: 14), + const Text( + 'Gagal Memuat Detail', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 8), + Text( + error.toString(), + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 13, + height: 1.5, + color: textSoftColor, + ), + ), + const SizedBox(height: 18), + ElevatedButton( + onPressed: () { + setState(() { + futureDetail = loadDetailRiwayat(); + }); + }, + style: ElevatedButton.styleFrom( + backgroundColor: primaryColor, + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text('Coba Lagi'), + ), + ], + ), + ), + ); + } + + Widget _buildDetailContent(Map data) { + debugPrint('============== DATA YANG DITAMPILKAN =============='); + debugPrint(data.toString()); + + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + _buildStatusCard(data), + const SizedBox(height: 18), + _buildItem( + icon: Icons.calendar_today_rounded, + title: 'Tanggal', + value: data['date'], + ), + _buildItem( + icon: Icons.login_rounded, + title: 'Check In', + value: data['check_in'], + iconColor: accentColor, + ), + _buildItem( + icon: Icons.logout_rounded, + title: 'Check Out', + value: data['check_out'], + iconColor: accentColor, + ), + _buildItem( + icon: Icons.devices_rounded, + title: 'Device Info', + value: data['device_info'], + iconColor: accentColor, + ), + _buildItem( + icon: Icons.location_on_outlined, + title: 'Lokasi', + value: data['location'], + ), + const SizedBox(height: 20), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + appBar: AppBar( + title: const Text( + 'Detail Riwayat', + style: TextStyle( + fontWeight: FontWeight.w800, + ), + ), + backgroundColor: Colors.white, + foregroundColor: primaryColor, + elevation: 0.8, + ), + body: FutureBuilder>( + future: futureDetail, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return _buildLoadingView(); + } + + if (snapshot.hasError) { + return _buildErrorView(snapshot.error); + } + + final data = snapshot.data; + + if (data == null || data.isEmpty) { + return _buildErrorView('Data detail kosong'); + } + + return _buildDetailContent(data); + }, + ), + ); + } +} \ No newline at end of file diff --git a/lib/presentation/views/pages/fiturizin_page.dart b/lib/presentation/views/pages/fiturizin_page.dart new file mode 100644 index 0000000..1932bda --- /dev/null +++ b/lib/presentation/views/pages/fiturizin_page.dart @@ -0,0 +1,452 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'package:sidak_desa_mobile/data/shared/auth_storage.dart'; +import 'package:sidak_desa_mobile/data/model/user_model.dart'; + +class IzinPage extends StatefulWidget { + const IzinPage({super.key}); + + @override + State createState() => _IzinPageState(); +} + +class _IzinPageState extends State { + final TextEditingController namaController = TextEditingController(); + final TextEditingController jabatanController = TextEditingController(); + final TextEditingController keteranganController = TextEditingController(); + + DateTime selectedDate = DateTime.now(); + + // Jangan pakai "cuti" kalau kolom status di database tidak menerima cuti. + String jenis = "izin"; + + File? imageFile; + bool isLoading = false; + + late Uri baseUrl; + UserModel? user; + + @override + void initState() { + super.initState(); + baseUrl = Uri.parse("${Apiconfig.baseUrl}/api/mobile/izin"); + loadUser(); + } + + @override + void dispose() { + namaController.dispose(); + jabatanController.dispose(); + keteranganController.dispose(); + super.dispose(); + } + + Future loadUser() async { + final authStorage = AuthStorage(); + user = await authStorage.getUser(); + + if (user != null) { + namaController.text = user!.name ?? ''; + jabatanController.text = user!.jabatan ?? ''; + } + + if (!mounted) return; + setState(() {}); + } + + InputDecoration customInput(String hint) { + return InputDecoration( + hintText: hint, + contentPadding: const EdgeInsets.symmetric(horizontal: 12), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Color(0xFF0097A7)), + borderRadius: BorderRadius.circular(6), + ), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Color(0xFF0097A7), width: 2), + borderRadius: BorderRadius.circular(6), + ), + ); + } + + String normalizeJenisValue(dynamic value) { + final text = value.toString().trim().toLowerCase(); + + if (text == "sakit") { + return "sakit"; + } + + // Default aman untuk database attendance. + return "izin"; + } + + String formatTanggalApi(DateTime date) { + final year = date.year.toString(); + final month = date.month.toString().padLeft(2, '0'); + final day = date.day.toString().padLeft(2, '0'); + + return "$year-$month-$day"; + } + + String formatTanggalView(DateTime date) { + final day = date.day.toString().padLeft(2, '0'); + final month = date.month.toString().padLeft(2, '0'); + final year = date.year.toString(); + + return "$day-$month-$year"; + } + + Future pickImage() async { + final picked = await ImagePicker().pickImage( + source: ImageSource.gallery, + imageQuality: 80, + ); + + if (picked == null) return; + + setState(() { + imageFile = File(picked.path); + }); + } + + void showSuccessDialog(String message) { + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => AlertDialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const CircleAvatar( + radius: 35, + backgroundColor: Color(0xFF009688), + child: Icon(Icons.check, color: Colors.white, size: 40), + ), + const SizedBox(height: 15), + const Text( + "Berhasil", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + Text(message, textAlign: TextAlign.center), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom(backgroundColor: Colors.orange), + onPressed: () { + Navigator.pop(context); + Navigator.pop(context, true); + }, + child: const Text("Oke", style: TextStyle(color: Colors.white)), + ), + ), + ], + ), + ), + ); + } + + void showErrorDialog(String message) { + showDialog( + context: context, + builder: (_) => AlertDialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const CircleAvatar( + radius: 35, + backgroundColor: Colors.red, + child: Icon(Icons.close, color: Colors.white, size: 40), + ), + const SizedBox(height: 15), + const Text( + "Gagal", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + Text( + message, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 13), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom(backgroundColor: Colors.red), + onPressed: () => Navigator.pop(context), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ), + ], + ), + ), + ); + } + + Future submitIzin() async { + final authStorage = AuthStorage(); + final currentUser = await authStorage.getUser(); + + if (currentUser == null) { + showErrorDialog("User tidak ditemukan. Silakan login ulang."); + return; + } + + final nama = namaController.text.trim(); + final jabatan = jabatanController.text.trim(); + final keterangan = keteranganController.text.trim(); + final jenisIzin = normalizeJenisValue(jenis); + + if (nama.isEmpty || jabatan.isEmpty || keterangan.isEmpty) { + showErrorDialog("Semua field wajib diisi."); + return; + } + + if (imageFile == null) { + showErrorDialog("Upload bukti terlebih dahulu."); + return; + } + + setState(() => isLoading = true); + + try { + final request = http.MultipartRequest("POST", baseUrl); + + request.headers.addAll({"Accept": "application/json"}); + + request.fields['user_id'] = currentUser.id.toString(); + request.fields['nama'] = nama; + request.fields['jabatan'] = jabatan; + request.fields['tanggal'] = formatTanggalApi(selectedDate); + + // Field ini dikirim sebagai jenis izin. + // Nilainya hanya "izin" atau "sakit" supaya tidak merusak kolom status database. + request.fields['jenis'] = jenisIzin; + + request.fields['keterangan'] = keterangan; + + request.files.add( + await http.MultipartFile.fromPath( + 'bukti', + imageFile!.path, + filename: imageFile!.path.split('/').last, + ), + ); + + final response = await request.send(); + final respStr = await response.stream.bytesToString(); + + debugPrint('============== DEBUG SUBMIT IZIN =============='); + debugPrint('URL: $baseUrl'); + debugPrint('STATUS CODE: ${response.statusCode}'); + debugPrint('RESPONSE BODY: $respStr'); + debugPrint('USER ID: ${currentUser.id}'); + debugPrint('TANGGAL DIKIRIM: ${formatTanggalApi(selectedDate)}'); + debugPrint('JENIS DIKIRIM: $jenisIzin'); + + Map jsonData = {}; + + try { + final decoded = json.decode(respStr); + + if (decoded is Map) { + jsonData = decoded; + } else if (decoded is Map) { + jsonData = Map.from(decoded); + } + } catch (_) { + jsonData = {}; + } + + if (!mounted) return; + setState(() => isLoading = false); + + final bool success = + response.statusCode == 200 || response.statusCode == 201; + + final bool apiOk = jsonData['ok'] == true || jsonData['success'] == true; + + if (success && apiOk) { + showSuccessDialog("Izin berhasil dikirim."); + } else { + final message = jsonData['message']?.toString(); + + showErrorDialog( + message == null || message.isEmpty ? "Gagal mengirim izin." : message, + ); + } + } catch (e) { + debugPrint('ERROR SUBMIT IZIN: $e'); + + if (!mounted) return; + setState(() => isLoading = false); + + showErrorDialog("Terjadi kesalahan sistem."); + } + } + + Widget label(String text) { + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(bottom: 5), + child: Text(text, style: const TextStyle(fontWeight: FontWeight.w500)), + ), + ); + } + + @override + Widget build(BuildContext context) { + final selectedJenis = normalizeJenisValue(jenis); + + return Scaffold( + backgroundColor: const Color(0xFFF2F2F2), + appBar: AppBar( + title: const Text("Izin", style: TextStyle(color: Color(0xFF0097A7))), + backgroundColor: Colors.white, + elevation: 1, + iconTheme: const IconThemeData(color: Color(0xFF0097A7)), + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + label("Nama"), + TextField( + controller: namaController, + readOnly: true, + decoration: customInput("Masukkan nama"), + ), + + const SizedBox(height: 15), + + label("Jabatan"), + TextField( + controller: jabatanController, + readOnly: true, + decoration: customInput("Masukkan jabatan"), + ), + + const SizedBox(height: 15), + + label("Tanggal"), + InkWell( + onTap: () async { + final picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(2020), + lastDate: DateTime(2030), + ); + + if (picked == null) return; + + setState(() { + selectedDate = picked; + }); + }, + child: InputDecorator( + decoration: customInput(""), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(formatTanggalView(selectedDate)), + const Icon(Icons.calendar_today, color: Color(0xFF0097A7)), + ], + ), + ), + ), + + const SizedBox(height: 15), + + label("Jenis Izin"), + DropdownButtonFormField( + value: selectedJenis, + items: const [ + DropdownMenuItem(value: "izin", child: Text("Izin")), + DropdownMenuItem(value: "sakit", child: Text("Sakit")), + ], + onChanged: (val) { + if (val == null) return; + + setState(() { + jenis = normalizeJenisValue(val); + }); + }, + decoration: customInput(""), + ), + + const SizedBox(height: 15), + + label("Keterangan"), + TextField( + controller: keteranganController, + minLines: 1, + maxLines: 3, + decoration: customInput("Masukkan keterangan"), + ), + + const SizedBox(height: 20), + + ElevatedButton.icon( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + minimumSize: const Size.fromHeight(45), + ), + onPressed: isLoading ? null : pickImage, + icon: const Icon(Icons.camera_alt, color: Colors.white), + label: const Text( + "Upload gambar", + style: TextStyle(color: Colors.white), + ), + ), + + if (imageFile != null) + Padding( + padding: const EdgeInsets.all(8), + child: Image.file(imageFile!, height: 150, fit: BoxFit.cover), + ), + + const SizedBox(height: 30), + + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + minimumSize: const Size.fromHeight(50), + ), + onPressed: isLoading ? null : submitIzin, + child: isLoading + ? const SizedBox( + width: 22, + height: 22, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ) + : const Text( + "Kirim", + style: TextStyle(fontSize: 16, color: Colors.white), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/views/pages/forgotpassword_page.dart b/lib/presentation/views/pages/forgotpassword_page.dart new file mode 100644 index 0000000..0abb0ee --- /dev/null +++ b/lib/presentation/views/pages/forgotpassword_page.dart @@ -0,0 +1,468 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/veryfikasiOTP.dart'; + +class ForgotPasswordPage extends StatefulWidget { + const ForgotPasswordPage({super.key}); + + @override + State createState() => _ForgotPasswordPageState(); +} + +class _ForgotPasswordPageState extends State { + final TextEditingController emailController = TextEditingController(); + + bool isLoading = false; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void dispose() { + emailController.dispose(); + super.dispose(); + } + + Future checkEmail() async { + final email = emailController.text.trim(); + + if (email.isEmpty) { + showMessage( + title: 'Email Kosong', + message: 'Silakan masukkan email terlebih dahulu.', + isError: true, + ); + return; + } + + if (!_isValidEmail(email)) { + showMessage( + title: 'Email Tidak Valid', + message: 'Format email yang Anda masukkan belum benar.', + isError: true, + ); + return; + } + + setState(() => isLoading = true); + + try { + final response = await http.post( + Uri.parse('${Apiconfig.baseUrl}/api/lupa-kata-sandi'), + headers: {'Content-Type': 'application/json'}, + body: jsonEncode({ + 'email': email, + 'type': 'email', + }), + ); + + final data = jsonDecode(response.body); + + if (!mounted) return; + + if (data['status'] == true) { + setState(() => isLoading = false); + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => OtpVerificationPage(email: email), + ), + ); + } else { + setState(() => isLoading = false); + + showMessage( + title: 'Email Tidak Terdaftar', + message: data['message'] ?? 'Email yang Anda masukkan tidak ditemukan.', + isError: true, + ); + } + } catch (e) { + if (!mounted) return; + + setState(() => isLoading = false); + + showMessage( + title: 'Koneksi Bermasalah', + message: 'Terjadi kesalahan koneksi. Silakan coba lagi.', + isError: true, + ); + } + } + + bool _isValidEmail(String email) { + final emailRegex = RegExp( + r'^[\w\.-]+@([\w-]+\.)+[\w-]{2,4}$', + ); + + return emailRegex.hasMatch(email); + } + + void showMessage({ + required String title, + required String message, + required bool isError, + }) { + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => Dialog( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + child: Padding( + padding: const EdgeInsets.fromLTRB(24, 28, 24, 24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 76, + height: 76, + decoration: BoxDecoration( + color: isError + ? Colors.red.withOpacity(0.10) + : primaryColor.withOpacity(0.12), + shape: BoxShape.circle, + ), + child: Icon( + isError + ? Icons.warning_amber_rounded + : Icons.check_circle_outline_rounded, + color: isError ? Colors.red : primaryColor, + size: 42, + ), + ), + const SizedBox(height: 20), + Text( + title, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 19, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 10), + Text( + message, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 14, + height: 1.5, + color: textSoftColor, + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + onPressed: () => Navigator.pop(context), + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Kembali', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } + + InputDecoration _emailInputDecoration() { + return InputDecoration( + labelText: 'Email', + hintText: 'Masukkan email Anda', + prefixIcon: const Icon( + Icons.email_outlined, + color: primaryColor, + ), + filled: true, + fillColor: const Color(0xFFF8FAFC), + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 18, + ), + labelStyle: const TextStyle(color: textSoftColor), + hintStyle: const TextStyle(color: Color(0xFF94A3B8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide( + color: primaryColor, + width: 1.4, + ), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Colors.red), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Colors.red), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: SafeArea( + child: Stack( + children: [ + Container( + height: 310, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color(0xFF0B7D77), + Color(0xFF0FA39A), + ], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(36), + bottomRight: Radius.circular(36), + ), + ), + ), + + SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(22, 16, 22, 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + if (Navigator.canPop(context)) + InkWell( + onTap: () => Navigator.pop(context), + borderRadius: BorderRadius.circular(14), + child: Container( + width: 42, + height: 42, + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.18), + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.arrow_back_ios_new_rounded, + color: Colors.white, + size: 18, + ), + ), + ), + ], + ), + + const SizedBox(height: 18), + + Column( + children: [ + Container( + width: 250, + height: 96, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.12), + blurRadius: 22, + offset: const Offset(0, 10), + ), + ], + ), + child: Image.asset( + 'assets/images/logo.png', + fit: BoxFit.contain, + ), + ), + const SizedBox(height: 22), + const Text( + 'Lupa Kata Sandi?', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 27, + height: 1.2, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + const SizedBox(height: 10), + Text( + 'Masukkan email akun Anda untuk menerima kode verifikasi.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + height: 1.5, + color: Colors.white.withOpacity(0.9), + ), + ), + ], + ), + + const SizedBox(height: 36), + + Container( + padding: const EdgeInsets.all(22), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 24, + offset: const Offset(0, 12), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Text( + 'Verifikasi Email', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 6), + const Text( + 'Kode OTP akan dikirimkan ke email yang terdaftar pada akun Anda.', + style: TextStyle( + fontSize: 13, + height: 1.5, + color: textSoftColor, + ), + ), + + const SizedBox(height: 24), + + TextField( + controller: emailController, + keyboardType: TextInputType.emailAddress, + textInputAction: TextInputAction.done, + decoration: _emailInputDecoration(), + ), + + const SizedBox(height: 18), + + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: primaryColor.withOpacity(0.08), + borderRadius: BorderRadius.circular(16), + border: Border.all( + color: primaryColor.withOpacity(0.12), + ), + ), + child: const Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Icons.info_outline_rounded, + color: primaryColor, + size: 20, + ), + SizedBox(width: 10), + Expanded( + child: Text( + 'Pastikan email yang dimasukkan sama dengan email saat pendaftaran.', + style: TextStyle( + fontSize: 12.5, + height: 1.45, + color: textSoftColor, + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 26), + + SizedBox( + height: 54, + child: ElevatedButton( + onPressed: isLoading ? null : checkEmail, + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + disabledBackgroundColor: + accentColor.withOpacity(0.55), + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + child: isLoading + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2.4, + ), + ) + : const Text( + 'Kirim Kode OTP', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Jika email terdaftar, Anda akan diarahkan ke halaman verifikasi OTP.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + height: 1.5, + color: textSoftColor, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/presentation/views/pages/konfirmasi_sandi_baru.dart b/lib/presentation/views/pages/konfirmasi_sandi_baru.dart new file mode 100644 index 0000000..0cf06d8 --- /dev/null +++ b/lib/presentation/views/pages/konfirmasi_sandi_baru.dart @@ -0,0 +1,499 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'package:sidak_desa_mobile/presentation/views/login_screen.dart'; + +class ResetPasswordPage extends StatefulWidget { + final String email; + + const ResetPasswordPage({super.key, required this.email}); + + @override + State createState() => _ResetPasswordPageState(); +} + +class _ResetPasswordPageState extends State { + final TextEditingController passwordController = TextEditingController(); + final TextEditingController confirmController = TextEditingController(); + + bool isLoading = false; + bool isPasswordHidden = true; + bool isConfirmHidden = true; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void dispose() { + passwordController.dispose(); + confirmController.dispose(); + super.dispose(); + } + + Future resetPassword() async { + final password = passwordController.text; + final confirmPassword = confirmController.text; + + if (password.isEmpty || confirmPassword.isEmpty) { + _showSnackBar('Kata sandi tidak boleh kosong', Colors.red); + return; + } + + if (password.length < 6) { + _showSnackBar('Kata sandi minimal 6 karakter', Colors.red); + return; + } + + if (password != confirmPassword) { + _showSnackBar('Konfirmasi sandi tidak cocok', Colors.red); + return; + } + + setState(() => isLoading = true); + + try { + final response = await http.post( + Uri.parse('${Apiconfig.baseUrl}/api/reset-password'), + headers: {'Content-Type': 'application/json'}, + body: jsonEncode({ + 'email': widget.email, + 'password': password, + 'password_confirmation': confirmPassword, + }), + ); + + final data = jsonDecode(response.body); + + if (!mounted) return; + setState(() => isLoading = false); + + if (response.statusCode == 200 && data['status'] == true) { + _showSuccessDialog(); + } else { + _showSnackBar(data['message'] ?? 'Gagal membuat password', Colors.red); + } + } catch (e) { + if (!mounted) return; + setState(() => isLoading = false); + _showSnackBar('Terjadi kesalahan server', Colors.red); + } + } + + void _showSnackBar(String message, Color color) { + if (!mounted) return; + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + backgroundColor: color, + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + margin: const EdgeInsets.all(16), + ), + ); + } + + void _showSuccessDialog() { + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => Dialog( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)), + child: Padding( + padding: const EdgeInsets.fromLTRB(24, 28, 24, 24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 86, + height: 86, + decoration: BoxDecoration( + color: primaryColor.withOpacity(0.12), + shape: BoxShape.circle, + ), + child: Center( + child: Container( + width: 62, + height: 62, + decoration: const BoxDecoration( + color: primaryColor, + shape: BoxShape.circle, + ), + child: const Icon( + Icons.check_rounded, + color: Colors.white, + size: 36, + ), + ), + ), + ), + const SizedBox(height: 22), + const Text( + 'Kata Sandi Berhasil Diubah', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + height: 1.3, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 10), + const Text( + 'Silakan masuk kembali menggunakan kata sandi baru Anda.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + height: 1.5, + color: textSoftColor, + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + height: 52, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + onPressed: () { + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (_) => LoginScreen()), + ); + }, + child: const Text( + 'Masuk Sekarang', + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700), + ), + ), + ), + ], + ), + ), + ), + ); + } + + InputDecoration _inputDecoration({ + required String label, + required String hint, + required IconData icon, + required Widget suffixIcon, + }) { + return InputDecoration( + labelText: label, + hintText: hint, + prefixIcon: Icon(icon, color: primaryColor), + suffixIcon: suffixIcon, + filled: true, + fillColor: const Color(0xFFF8FAFC), + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18), + labelStyle: const TextStyle(color: textSoftColor), + hintStyle: const TextStyle(color: Color(0xFF94A3B8)), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: primaryColor, width: 1.4), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Colors.red), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide(color: Colors.red), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: SafeArea( + child: Stack( + children: [ + Container( + height: 290, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [Color(0xFF0B7D77), Color(0xFF0FA39A)], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(36), + bottomRight: Radius.circular(36), + ), + ), + ), + + SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(22, 16, 22, 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + if (Navigator.canPop(context)) + InkWell( + onTap: () => Navigator.pop(context), + borderRadius: BorderRadius.circular(14), + child: Container( + width: 42, + height: 42, + decoration: BoxDecoration( + color: Colors.white.withOpacity(0.18), + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.arrow_back_ios_new_rounded, + color: Colors.white, + size: 18, + ), + ), + ), + ], + ), + + const SizedBox(height: 18), + + Column( + children: [ + Container( + width: 250, + height: 96, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.12), + blurRadius: 22, + offset: const Offset(0, 10), + ), + ], + ), + child: Image.asset( + 'assets/images/logo.png', + fit: BoxFit.contain, + ), + ), + const SizedBox(height: 22), + const Text( + 'Buat Kata Sandi Baru', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 26, + height: 1.2, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + const SizedBox(height: 10), + Text( + 'Akun: ${widget.email}', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + color: Colors.white.withOpacity(0.88), + ), + ), + ], + ), + + const SizedBox(height: 34), + + Container( + padding: const EdgeInsets.all(22), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 24, + offset: const Offset(0, 12), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Text( + 'Atur ulang kata sandi', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 6), + const Text( + 'Gunakan kata sandi yang mudah diingat, tetapi sulit ditebak orang lain.', + style: TextStyle( + fontSize: 13, + height: 1.5, + color: textSoftColor, + ), + ), + + const SizedBox(height: 24), + + TextField( + controller: passwordController, + obscureText: isPasswordHidden, + decoration: _inputDecoration( + label: 'Kata Sandi Baru', + hint: 'Minimal 6 karakter', + icon: Icons.lock_outline_rounded, + suffixIcon: IconButton( + onPressed: () { + setState(() { + isPasswordHidden = !isPasswordHidden; + }); + }, + icon: Icon( + isPasswordHidden + ? Icons.visibility_off_outlined + : Icons.visibility_outlined, + color: textSoftColor, + ), + ), + ), + ), + + const SizedBox(height: 16), + + TextField( + controller: confirmController, + obscureText: isConfirmHidden, + decoration: _inputDecoration( + label: 'Konfirmasi Sandi', + hint: 'Ulangi kata sandi baru', + icon: Icons.verified_user_outlined, + suffixIcon: IconButton( + onPressed: () { + setState(() { + isConfirmHidden = !isConfirmHidden; + }); + }, + icon: Icon( + isConfirmHidden + ? Icons.visibility_off_outlined + : Icons.visibility_outlined, + color: textSoftColor, + ), + ), + ), + ), + + const SizedBox(height: 18), + + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: primaryColor.withOpacity(0.08), + borderRadius: BorderRadius.circular(16), + border: Border.all( + color: primaryColor.withOpacity(0.12), + ), + ), + child: const Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Icons.info_outline_rounded, + color: primaryColor, + size: 20, + ), + SizedBox(width: 10), + Expanded( + child: Text( + 'Disarankan memakai kombinasi huruf, angka, dan simbol agar akun lebih aman.', + style: TextStyle( + fontSize: 12.5, + height: 1.45, + color: textSoftColor, + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 26), + + SizedBox( + height: 54, + child: ElevatedButton( + onPressed: isLoading ? null : resetPassword, + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + disabledBackgroundColor: accentColor.withOpacity( + 0.55, + ), + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + child: isLoading + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2.4, + ), + ) + : const Text( + 'Simpan Kata Sandi', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Pastikan Anda tidak membagikan kata sandi kepada siapa pun.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + height: 1.5, + color: textSoftColor, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/views/pages/profile_screen.dart b/lib/presentation/views/pages/profile_screen.dart new file mode 100644 index 0000000..7c9848e --- /dev/null +++ b/lib/presentation/views/pages/profile_screen.dart @@ -0,0 +1,776 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'package:sidak_desa_mobile/data/shared/auth_storage.dart'; +import 'package:sidak_desa_mobile/presentation/views/login_screen.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/forgotpassword_page.dart'; + +class ProfileScreen extends StatefulWidget { + const ProfileScreen({super.key}); + + @override + State createState() => _ProfileScreenState(); +} + +class _ProfileScreenState extends State { + String name = ''; + String email = ''; + String urlPhoto = ''; + bool isLoading = true; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color secondaryColor = Color(0xFF0FA39A); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void initState() { + super.initState(); + fetchProfile(); + } + + Future fetchProfile() async { + try { + final storage = AuthStorage(); + final user = await storage.getUser(); + + if (user == null || user.id == null || user.id.toString().isEmpty) { + debugPrint('User tidak valid'); + + if (!mounted) return; + setState(() => isLoading = false); + + return; + } + + final response = await http.get( + Uri.parse('${Apiconfig.baseUrl}/api/profile?user_id=${user.id}'), + ); + + debugPrint('RESPONSE PROFILE: ${response.body}'); + + if (response.statusCode == 200) { + final body = json.decode(response.body); + + Map data; + + if (body is List && body.isNotEmpty) { + data = Map.from(body[0]); + } else if (body is Map) { + data = Map.from(body['data'] ?? body); + } else { + throw Exception('Format JSON tidak dikenali'); + } + + if (!mounted) return; + + setState(() { + name = data['name']?.toString() ?? 'Nama Tidak Ditemukan'; + email = data['email']?.toString() ?? 'Email Tidak Ditemukan'; + urlPhoto = data['url_photo']?.toString() ?? ''; + isLoading = false; + }); + } else { + debugPrint('Error status: ${response.statusCode}'); + + if (!mounted) return; + setState(() => isLoading = false); + } + } catch (e) { + debugPrint('ERROR FETCH PROFILE: $e'); + + if (!mounted) return; + setState(() => isLoading = false); + } + } + + void _showProfilePhotoDialog() { + showDialog( + context: context, + builder: (_) => Dialog( + backgroundColor: Colors.transparent, + insetPadding: const EdgeInsets.symmetric(horizontal: 24), + child: Stack( + children: [ + Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox(height: 10), + + Container( + width: 220, + height: 220, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: const Color(0xFFF1F5F9), + border: Border.all( + color: const Color(0xFFE2E8F0), + width: 2, + ), + ), + child: ClipOval( + child: urlPhoto.isNotEmpty + ? Image.network( + urlPhoto, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return const Icon( + Icons.person_rounded, + color: primaryColor, + size: 100, + ); + }, + ) + : const Icon( + Icons.person_rounded, + color: primaryColor, + size: 100, + ), + ), + ), + + const SizedBox(height: 18), + + Text( + name.isNotEmpty ? name : 'Nama Tidak Ditemukan', + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 6), + + Text( + email.isNotEmpty ? email : 'Email Tidak Ditemukan', + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 13, + color: textSoftColor, + ), + ), + + const SizedBox(height: 20), + ], + ), + ), + + Positioned( + top: 10, + right: 10, + child: InkWell( + onTap: () => Navigator.pop(context), + borderRadius: BorderRadius.circular(100), + child: Container( + width: 34, + height: 34, + decoration: const BoxDecoration( + color: Color(0xFFF1F5F9), + shape: BoxShape.circle, + ), + child: const Icon( + Icons.close_rounded, + size: 20, + color: textDarkColor, + ), + ), + ), + ), + ], + ), + ), + ); + } + + void _showLogoutDialog() { + showDialog( + context: context, + builder: (_) => Dialog( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + child: Padding( + padding: const EdgeInsets.fromLTRB(24, 28, 24, 24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 76, + height: 76, + decoration: const BoxDecoration( + color: Color.fromRGBO(244, 67, 54, 0.10), + shape: BoxShape.circle, + ), + child: const Icon( + Icons.logout_rounded, + color: Colors.red, + size: 40, + ), + ), + + const SizedBox(height: 20), + + const Text( + 'Keluar dari Akun?', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 10), + + const Text( + 'Anda akan diarahkan kembali ke halaman login.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + height: 1.5, + color: textSoftColor, + ), + ), + + const SizedBox(height: 24), + + Row( + children: [ + Expanded( + child: SizedBox( + height: 50, + child: OutlinedButton( + onPressed: () => Navigator.pop(context), + style: OutlinedButton.styleFrom( + foregroundColor: textSoftColor, + side: const BorderSide( + color: Color(0xFFE2E8F0), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Batal', + style: TextStyle( + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ), + + const SizedBox(width: 12), + + Expanded( + child: SizedBox( + height: 50, + child: ElevatedButton( + onPressed: () { + Get.offAll(() => LoginScreen()); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Keluar', + style: TextStyle( + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ), + ], + ), + ], + ), + ), + ), + ); + } + + Widget _buildProfileImage() { + return GestureDetector( + onTap: _showProfilePhotoDialog, + child: Stack( + children: [ + Container( + width: 132, + height: 132, + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: const Color.fromRGBO(255, 255, 255, 0.25), + border: Border.all( + color: const Color.fromRGBO(255, 255, 255, 0.55), + width: 1.5, + ), + ), + child: ClipOval( + child: Container( + color: Colors.white, + child: urlPhoto.isNotEmpty + ? Image.network( + urlPhoto, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { + return const Icon( + Icons.person_rounded, + color: primaryColor, + size: 66, + ); + }, + ) + : const Icon( + Icons.person_rounded, + color: primaryColor, + size: 66, + ), + ), + ), + ), + + Positioned( + right: 4, + bottom: 4, + child: Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: accentColor, + shape: BoxShape.circle, + border: Border.all( + color: Colors.white, + width: 3, + ), + ), + child: const Icon( + Icons.remove_red_eye_rounded, + color: Colors.white, + size: 18, + ), + ), + ), + ], + ), + ); + } + + Widget _buildAccountCard() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(22), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + blurRadius: 24, + offset: Offset(0, 12), + ), + ], + ), + child: Column( + children: [ + _buildInfoRow( + icon: Icons.person_outline_rounded, + title: 'Nama Lengkap', + value: name.isNotEmpty ? name : 'Nama Tidak Ditemukan', + iconColor: primaryColor, + ), + + const Padding( + padding: EdgeInsets.symmetric(vertical: 14), + child: Divider( + height: 1, + color: Color(0xFFE2E8F0), + ), + ), + + _buildInfoRow( + icon: Icons.email_outlined, + title: 'Email', + value: email.isNotEmpty ? email : 'Email Tidak Ditemukan', + iconColor: accentColor, + ), + ], + ), + ); + } + + Widget _buildInfoRow({ + required IconData icon, + required String title, + required String value, + required Color iconColor, + }) { + final Color iconBackground = iconColor == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.10) + : const Color.fromRGBO(255, 140, 50, 0.10); + + return Row( + children: [ + Container( + width: 46, + height: 46, + decoration: BoxDecoration( + color: iconBackground, + borderRadius: BorderRadius.circular(16), + ), + child: Icon( + icon, + color: iconColor, + size: 24, + ), + ), + + const SizedBox(width: 12), + + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: textSoftColor, + ), + ), + + const SizedBox(height: 4), + + Text( + value, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 15, + height: 1.35, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + ], + ), + ), + ], + ); + } + + Widget _buildMenuCard() { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(24), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.06), + blurRadius: 20, + offset: Offset(0, 10), + ), + ], + ), + child: Column( + children: [ + _buildMenuItem( + icon: Icons.lock_outline_rounded, + title: 'Ubah Kata Sandi', + subtitle: 'Atur ulang kata sandi akun Anda', + iconColor: accentColor, + onTap: () { + Get.to(() => const ForgotPasswordPage()); + }, + ), + + const Padding( + padding: EdgeInsets.symmetric(vertical: 12), + child: Divider( + height: 1, + color: Color(0xFFE2E8F0), + ), + ), + + _buildMenuItem( + icon: Icons.logout_rounded, + title: 'Keluar', + subtitle: 'Keluar dari akun aplikasi', + iconColor: Colors.red, + onTap: _showLogoutDialog, + ), + ], + ), + ); + } + + Widget _buildMenuItem({ + required IconData icon, + required String title, + required String subtitle, + required Color iconColor, + required VoidCallback onTap, + }) { + final Color iconBackground = iconColor == accentColor + ? const Color.fromRGBO(255, 140, 50, 0.10) + : const Color.fromRGBO(244, 67, 54, 0.10); + + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(18), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Row( + children: [ + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: iconBackground, + borderRadius: BorderRadius.circular(16), + ), + child: Icon( + icon, + color: iconColor, + size: 24, + ), + ), + + const SizedBox(width: 12), + + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 4), + + Text( + subtitle, + style: const TextStyle( + fontSize: 12.5, + height: 1.35, + color: textSoftColor, + ), + ), + ], + ), + ), + + const Icon( + Icons.arrow_forward_ios_rounded, + size: 16, + color: Color(0xFF94A3B8), + ), + ], + ), + ), + ); + } + + Widget _buildLoadingView() { + return const Center( + child: CircularProgressIndicator( + color: primaryColor, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: isLoading + ? _buildLoadingView() + : RefreshIndicator( + color: primaryColor, + onRefresh: fetchProfile, + child: SingleChildScrollView( + physics: const AlwaysScrollableScrollPhysics(), + child: Stack( + children: [ + Container( + height: 300, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + primaryColor, + secondaryColor, + ], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(36), + bottomRight: Radius.circular(36), + ), + ), + ), + + SafeArea( + child: Padding( + padding: const EdgeInsets.fromLTRB(18, 16, 18, 28), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + InkWell( + onTap: () => Navigator.pop(context), + borderRadius: BorderRadius.circular(14), + child: Container( + width: 42, + height: 42, + decoration: BoxDecoration( + color: const Color.fromRGBO( + 255, + 255, + 255, + 0.18, + ), + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.arrow_back_ios_new_rounded, + color: Colors.white, + size: 18, + ), + ), + ), + + const Expanded( + child: Center( + child: Text( + 'Profil', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + ), + ), + + const SizedBox(width: 42), + ], + ), + + const SizedBox(height: 26), + + Center( + child: _buildProfileImage(), + ), + + const SizedBox(height: 16), + + Text( + name.isNotEmpty ? name : 'Nama Tidak Ditemukan', + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 23, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + + const SizedBox(height: 6), + + Text( + email.isNotEmpty + ? email + : 'Email Tidak Ditemukan', + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 14, + color: Color.fromRGBO(255, 255, 255, 0.86), + ), + ), + + const SizedBox(height: 8), + + const Text( + 'Ketuk foto untuk melihat lebih besar', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + color: Color.fromRGBO(255, 255, 255, 0.72), + ), + ), + + const SizedBox(height: 24), + + _buildAccountCard(), + + const SizedBox(height: 22), + + const Text( + 'Tentang Akun', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 6), + + const Text( + 'Kelola keamanan dan sesi akun Anda.', + style: TextStyle( + fontSize: 13, + color: textSoftColor, + ), + ), + + const SizedBox(height: 14), + + _buildMenuCard(), + + const SizedBox(height: 26), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/presentation/views/pages/riwayat_page.dart b/lib/presentation/views/pages/riwayat_page.dart new file mode 100644 index 0000000..36ce3f2 --- /dev/null +++ b/lib/presentation/views/pages/riwayat_page.dart @@ -0,0 +1,1137 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; +import 'package:sidak_desa_mobile/data/shared/auth_storage.dart'; +import 'package:sidak_desa_mobile/presentation/views/pages/detail_riwayat.dart'; + +class RiwayatPage extends StatefulWidget { + const RiwayatPage({super.key}); + + @override + State createState() => _RiwayatPageState(); +} + +class _RiwayatPageState extends State with WidgetsBindingObserver { + List> allData = []; + List> filteredData = []; + + String selectedFilter = 'Semua'; + String searchQuery = ''; + + bool isLoading = true; + bool isFetchingRiwayat = false; + String errorMessage = ''; + + Timer? refreshTimer; + + late String baseUrl; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + @override + void initState() { + super.initState(); + + WidgetsBinding.instance.addObserver(this); + baseUrl = '${Apiconfig.baseUrl}/api'; + + fetchRiwayat(); + startRealtimeRefresh(); + } + + @override + void dispose() { + refreshTimer?.cancel(); + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state == AppLifecycleState.resumed) { + fetchRiwayat(silent: true); + } + } + + void startRealtimeRefresh() { + refreshTimer?.cancel(); + + refreshTimer = Timer.periodic(const Duration(seconds: 5), (_) { + if (!mounted) return; + + final route = ModalRoute.of(context); + + if (route != null && route.isCurrent) { + fetchRiwayat(silent: true); + } + }); + } + + Future fetchRiwayat({bool silent = false}) async { + if (isFetchingRiwayat) return; + + isFetchingRiwayat = true; + + if (!silent && mounted) { + setState(() { + isLoading = true; + errorMessage = ''; + }); + } + + try { + final storage = AuthStorage(); + final user = await storage.getUser(); + + if (user == null || user.id == null) { + if (!mounted) return; + + setState(() { + isLoading = false; + errorMessage = 'User tidak ditemukan'; + allData = []; + filteredData = []; + }); + + return; + } + + final uri = Uri.parse('$baseUrl/riwayat/${user.id}').replace( + queryParameters: { + '_t': DateTime.now().millisecondsSinceEpoch.toString(), + }, + ); + + final response = await http.get( + uri, + headers: { + 'Accept': 'application/json', + 'Cache-Control': 'no-cache', + 'Pragma': 'no-cache', + }, + ); + + debugPrint('============== DEBUG RIWAYAT =============='); + debugPrint('URL: $uri'); + debugPrint('STATUS CODE: ${response.statusCode}'); + debugPrint('BODY: ${response.body}'); + + if (!mounted) return; + + if (response.statusCode != 200) { + if (!silent) { + setState(() { + isLoading = false; + errorMessage = 'Gagal mengambil data riwayat'; + allData = []; + filteredData = []; + }); + } + + return; + } + + final decoded = jsonDecode(response.body); + + if (decoded is! Map) { + if (!silent) { + setState(() { + isLoading = false; + errorMessage = 'Format data tidak sesuai'; + allData = []; + filteredData = []; + }); + } + + return; + } + + final bool isSuccess = + decoded['ok'] == true || decoded['success'] == true; + + if (!isSuccess) { + if (!silent) { + setState(() { + isLoading = false; + errorMessage = + decoded['message']?.toString() ?? 'Data gagal dimuat'; + allData = []; + filteredData = []; + }); + } + + return; + } + + final rawData = decoded['data']; + final List rawList; + + if (rawData is List) { + rawList = rawData; + } else if (rawData is Map) { + rawList = [rawData]; + } else { + rawList = []; + } + + final rawMapList = rawList + .whereType() + .map((item) => Map.from(item)) + .toList(); + + final normalizedList = rawMapList.map((item) { + return _normalizeItemFromDebug(item); + }).toList(); + + final cleanList = _removeDuplicateAndFakeData(normalizedList); + final sortedList = _sortByDateDesc(cleanList); + + if (!mounted) return; + + setState(() { + allData = sortedList; + isLoading = false; + errorMessage = ''; + }); + + applyFilter(); + + debugPrint('============== DEBUG RIWAYAT FINAL =============='); + debugPrint('JUMLAH RAW API: ${rawList.length}'); + debugPrint('JUMLAH NORMALIZE: ${normalizedList.length}'); + debugPrint('JUMLAH FINAL: ${sortedList.length}'); + debugPrint('DATA FINAL: $sortedList'); + } catch (e) { + debugPrint('ERROR FETCH RIWAYAT: $e'); + + if (!mounted) return; + + if (!silent) { + setState(() { + isLoading = false; + errorMessage = 'Terjadi kesalahan saat mengambil data'; + allData = []; + filteredData = []; + }); + } + } finally { + isFetchingRiwayat = false; + } + } + + Map _normalizeItemFromDebug(Map item) { + final rawJenis = _safeText(item['jenis'], fallback: '').toLowerCase(); + final rawIcon = _safeText(item['icon'], fallback: '').toLowerCase(); + final rawStatus = _safeText( + item['status_validasi'], + fallback: '', + ).toLowerCase(); + final rawJam = _safeText(item['jam'], fallback: '-'); + + final statusJenis = _detectStatusJenis( + rawJenis: rawJenis, + rawIcon: rawIcon, + rawStatus: rawStatus, + rawJam: rawJam, + ); + + final statusValidasi = _detectStatusValidasi( + statusJenis: statusJenis, + rawStatus: rawStatus, + ); + + final tanggal = _safeText(item['tanggal'], fallback: '-'); + final jam = _normalizeJam(rawJam); + + final keterangan = _safeText( + item['keterangan'] ?? item['notes'] ?? item['catatan'], + fallback: '-', + ); + + final displayInfo = _buildDisplayInfo( + statusJenis: statusJenis, + jam: jam, + keterangan: keterangan, + ); + + return { + ...item, + 'attendances_id': item['attendances_id'] ?? item['id'], + 'jenis': _titleJenis(statusJenis), + 'status_jenis': statusJenis, + 'status_validasi': statusValidasi, + 'tanggal': tanggal, + 'jam': jam, + 'keterangan': keterangan, + 'display_info': displayInfo, + 'sort_date': item['sort_date'] ?? item['date'] ?? item['tanggal'], + 'is_fake_tidak_hadir_izin': _isFakeTidakHadirIzin(item), + }; + } + + String _detectStatusJenis({ + required String rawJenis, + required String rawIcon, + required String rawStatus, + required String rawJam, + }) { + if (rawJenis == 'izin' || rawJenis.contains('izin')) { + return 'izin'; + } + + if (rawJenis == 'sakit' || rawJenis.contains('sakit')) { + return 'sakit'; + } + + if (rawJenis == 'cuti' || rawJenis.contains('cuti')) { + return 'cuti'; + } + + if (rawJenis == 'hadir') { + return 'hadir'; + } + + if (rawJenis == 'alpha' || rawJenis == 'alpa') { + return 'alpha'; + } + + if (rawJenis == 'tidak hadir') { + if (rawIcon == 'hadir' && + rawStatus == 'izin' && + rawJam.contains('- - -')) { + return 'fake'; + } + + return 'alpha'; + } + + if (rawIcon == 'izin') { + return 'izin'; + } + + if (rawIcon == 'sakit') { + return 'sakit'; + } + + if (rawIcon == 'cuti') { + return 'cuti'; + } + + if (rawIcon == 'hadir') { + return 'hadir'; + } + + if (rawIcon == 'alpha' || rawIcon == 'alpa') { + return 'alpha'; + } + + if (rawStatus == 'alpha' || rawStatus == 'alpa') { + return 'alpha'; + } + + if (rawStatus == 'hadir') { + return 'hadir'; + } + + return 'tidak diketahui'; + } + + String _detectStatusValidasi({ + required String statusJenis, + required String rawStatus, + }) { + if (rawStatus == 'disetujui' || rawStatus == 'approved') { + return 'disetujui'; + } + + if (rawStatus == 'ditolak' || rawStatus == 'rejected') { + return 'ditolak'; + } + + if (rawStatus == 'diajukan' || + rawStatus == 'diproses' || + rawStatus == 'di proses' || + rawStatus == 'proses' || + rawStatus == 'pending' || + rawStatus == 'menunggu') { + return 'menunggu'; + } + + if (statusJenis == 'hadir') { + return 'hadir'; + } + + if (statusJenis == 'alpha') { + return 'alpha'; + } + + if (statusJenis == 'izin' || + statusJenis == 'sakit' || + statusJenis == 'cuti') { + if (rawStatus == 'izin' || rawStatus == 'sakit' || rawStatus == 'cuti') { + return 'menunggu'; + } + + return 'menunggu'; + } + + if (statusJenis == 'fake') { + return 'fake'; + } + + return 'tidak diketahui'; + } + + bool _isFakeTidakHadirIzin(Map item) { + final jenis = _safeText(item['jenis'], fallback: '').toLowerCase(); + final jam = _safeText(item['jam'], fallback: '').toLowerCase(); + final icon = _safeText(item['icon'], fallback: '').toLowerCase(); + final statusValidasi = _safeText( + item['status_validasi'], + fallback: '', + ).toLowerCase(); + + return jenis == 'tidak hadir' && + jam.contains('- - -') && + icon == 'hadir' && + statusValidasi == 'izin'; + } + + List> _removeDuplicateAndFakeData( + List> items, + ) { + final groupedById = >>{}; + final noIdItems = >[]; + + for (final item in items) { + final id = _safeText(item['attendances_id'], fallback: ''); + + if (id.isEmpty || id == '-') { + noIdItems.add(item); + continue; + } + + groupedById.putIfAbsent(id, () => []); + groupedById[id]!.add(item); + } + + final result = >[]; + + for (final entry in groupedById.entries) { + final group = entry.value; + + final nonFake = group.where((item) { + return item['is_fake_tidak_hadir_izin'] != true && + item['status_jenis'] != 'fake' && + item['status_validasi'] != 'fake'; + }).toList(); + + if (nonFake.isNotEmpty) { + nonFake.sort((a, b) => _itemScore(b).compareTo(_itemScore(a))); + result.add(nonFake.first); + } + } + + final seenFallback = {}; + + for (final item in noIdItems) { + if (item['is_fake_tidak_hadir_izin'] == true || + item['status_jenis'] == 'fake' || + item['status_validasi'] == 'fake') { + continue; + } + + final key = [ + _safeText(item['tanggal'], fallback: ''), + _safeText(item['status_jenis'], fallback: ''), + _safeText(item['status_validasi'], fallback: ''), + _safeText(item['jam'], fallback: ''), + _safeText(item['keterangan'], fallback: ''), + ].join('|'); + + if (seenFallback.contains(key)) { + continue; + } + + seenFallback.add(key); + result.add(item); + } + + return result; + } + + int _itemScore(Map item) { + int score = 0; + + final statusJenis = _safeText( + item['status_jenis'], + fallback: '', + ).toLowerCase(); + + final statusValidasi = _safeText( + item['status_validasi'], + fallback: '', + ).toLowerCase(); + + if (item['is_fake_tidak_hadir_izin'] == true || statusJenis == 'fake') { + return -1000; + } + + if (statusValidasi == 'disetujui') { + score += 100; + } else if (statusValidasi == 'ditolak') { + score += 95; + } else if (statusValidasi == 'menunggu') { + score += 90; + } else if (statusValidasi == 'hadir') { + score += 80; + } else if (statusValidasi == 'alpha') { + score += 70; + } + + if (statusJenis == 'izin' || + statusJenis == 'sakit' || + statusJenis == 'cuti') { + score += 10; + } + + if (statusJenis == 'hadir') { + score += 8; + } + + if (statusJenis == 'alpha') { + score += 6; + } + + final tanggal = _safeText(item['tanggal'], fallback: ''); + final jam = _safeText(item['jam'], fallback: ''); + final keterangan = _safeText(item['keterangan'], fallback: ''); + + if (tanggal.isNotEmpty && tanggal != '-') score += 2; + if (jam.isNotEmpty && jam != '-') score += 2; + if (keterangan.isNotEmpty && keterangan != '-') score += 2; + + return score; + } + + List> _sortByDateDesc(List> items) { + final result = List>.from(items); + + result.sort((a, b) { + final dateA = DateTime.tryParse(_safeText(a['sort_date'], fallback: '')); + final dateB = DateTime.tryParse(_safeText(b['sort_date'], fallback: '')); + + if (dateA != null && dateB != null) { + final dateCompare = dateB.compareTo(dateA); + if (dateCompare != 0) return dateCompare; + } + + final idA = _safeInt(a['attendances_id']) ?? 0; + final idB = _safeInt(b['attendances_id']) ?? 0; + + return idB.compareTo(idA); + }); + + return result; + } + + String _titleJenis(String statusJenis) { + switch (statusJenis) { + case 'hadir': + return 'Hadir'; + case 'izin': + return 'Izin'; + case 'sakit': + return 'Sakit'; + case 'cuti': + return 'Cuti'; + case 'alpha': + return 'Alpha'; + case 'fake': + return 'Fake'; + default: + return 'Riwayat'; + } + } + + String _normalizeJam(String jam) { + final value = jam.trim(); + + if (value.isEmpty || value.toLowerCase() == 'null') { + return '-'; + } + + if (value == '- - -') { + return '-'; + } + + return value; + } + + String _buildDisplayInfo({ + required String statusJenis, + required String jam, + required String keterangan, + }) { + if ((statusJenis == 'izin' || + statusJenis == 'sakit' || + statusJenis == 'cuti') && + keterangan.isNotEmpty && + keterangan != '-') { + return keterangan; + } + + return jam; + } + + String _safeText(dynamic value, {String fallback = '-'}) { + if (value == null) return fallback; + + final text = value.toString().trim(); + + if (text.isEmpty || text.toLowerCase() == 'null') { + return fallback; + } + + return text; + } + + int? _safeInt(dynamic value) { + if (value == null) return null; + + if (value is int) return value; + if (value is double) return value.toInt(); + + return int.tryParse(value.toString()); + } + + void applyFilter() { + List> temp = List>.from(allData); + + if (selectedFilter != 'Semua') { + temp = temp.where((item) { + final statusValidasi = _safeText( + item['status_validasi'], + fallback: '', + ).toLowerCase(); + + if (selectedFilter == 'Menunggu') { + return statusValidasi == 'menunggu' || + statusValidasi == 'diajukan' || + statusValidasi == 'diproses' || + statusValidasi == 'di proses' || + statusValidasi == 'proses' || + statusValidasi == 'pending' || + statusValidasi == 'izin' || + statusValidasi == 'sakit' || + statusValidasi == 'cuti'; + } + + if (selectedFilter == 'Disetujui') { + return statusValidasi == 'disetujui' || statusValidasi == 'approved'; + } + + if (selectedFilter == 'Ditolak') { + return statusValidasi == 'ditolak' || statusValidasi == 'rejected'; + } + + return true; + }).toList(); + } + + if (searchQuery.trim().isNotEmpty) { + final query = searchQuery.toLowerCase().trim(); + + temp = temp.where((item) { + final jenis = _safeText(item['jenis']).toLowerCase(); + final tanggal = _safeText(item['tanggal']).toLowerCase(); + final jam = _safeText(item['jam']).toLowerCase(); + final displayInfo = _safeText(item['display_info']).toLowerCase(); + final statusJenis = _safeText(item['status_jenis']).toLowerCase(); + final statusValidasi = _safeText(item['status_validasi']).toLowerCase(); + + return jenis.contains(query) || + tanggal.contains(query) || + jam.contains(query) || + displayInfo.contains(query) || + statusJenis.contains(query) || + statusValidasi.contains(query); + }).toList(); + } + + if (!mounted) return; + + setState(() { + filteredData = temp; + }); + } + + Color getStatusColor(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + case 'disetujui': + return primaryColor; + + case 'menunggu': + case 'diajukan': + case 'diproses': + case 'di proses': + case 'proses': + case 'pending': + case 'izin': + case 'sakit': + case 'cuti': + return accentColor; + + case 'alpha': + case 'alpa': + case 'tidak hadir': + case 'ditolak': + return Colors.red; + + default: + return Colors.grey; + } + } + + String getStatusText(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + return 'Hadir'; + + case 'disetujui': + return 'Disetujui'; + + case 'ditolak': + return 'Ditolak'; + + case 'menunggu': + case 'diajukan': + case 'diproses': + case 'di proses': + case 'proses': + case 'pending': + case 'izin': + case 'sakit': + case 'cuti': + return 'Menunggu'; + + case 'alpha': + case 'alpa': + case 'tidak hadir': + return 'Alpha'; + + default: + return 'Tidak diketahui'; + } + } + + IconData getStatusIcon(dynamic value) { + final status = _safeText(value, fallback: '').toLowerCase(); + + switch (status) { + case 'hadir': + case 'disetujui': + return Icons.check_rounded; + + case 'menunggu': + case 'diajukan': + case 'diproses': + case 'di proses': + case 'proses': + case 'pending': + case 'izin': + case 'sakit': + case 'cuti': + return Icons.hourglass_top_rounded; + + case 'alpha': + case 'alpa': + case 'tidak hadir': + case 'ditolak': + return Icons.close_rounded; + + default: + return Icons.help_outline_rounded; + } + } + + Widget buildFilterButton(String title) { + final bool isActive = selectedFilter == title; + + return GestureDetector( + onTap: () { + setState(() { + selectedFilter = title; + }); + + applyFilter(); + }, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 9), + decoration: BoxDecoration( + color: isActive ? primaryColor : Colors.white, + borderRadius: BorderRadius.circular(100), + border: Border.all( + color: isActive ? primaryColor : const Color(0xFFE2E8F0), + ), + boxShadow: isActive + ? const [ + BoxShadow( + color: Color.fromRGBO(11, 125, 119, 0.20), + blurRadius: 12, + offset: Offset(0, 6), + ), + ] + : [], + ), + child: Text( + title, + style: TextStyle( + color: isActive ? Colors.white : textSoftColor, + fontSize: 13, + fontWeight: FontWeight.w700, + ), + ), + ), + ); + } + + Widget buildCard(Map item) { + final jenis = _safeText(item['jenis']); + final tanggal = _safeText(item['tanggal']); + final info = _safeText(item['display_info']); + final status = item['status_validasi']; + final statusColor = getStatusColor(status); + + return GestureDetector( + onTap: () { + final int? attendancesId = _safeInt(item['attendances_id']); + + debugPrint('DATA DIKIRIM KE DETAIL:'); + debugPrint(item.toString()); + debugPrint('ATTENDANCES ID DIKIRIM: $attendancesId'); + + if (attendancesId == null) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Attendances ID tidak ditemukan')), + ); + return; + } + + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + DetailRiwayatPage(data: item, attendancesId: attendancesId), + ), + ).then((_) { + fetchRiwayat(silent: true); + }); + }, + child: Container( + margin: const EdgeInsets.only(bottom: 14), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(22), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.06), + blurRadius: 18, + offset: Offset(0, 8), + ), + ], + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: statusColor == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.12) + : statusColor == accentColor + ? const Color.fromRGBO(255, 140, 50, 0.12) + : statusColor == Colors.red + ? const Color.fromRGBO(244, 67, 54, 0.12) + : const Color.fromRGBO(158, 158, 158, 0.12), + borderRadius: BorderRadius.circular(16), + ), + child: Icon(getStatusIcon(status), color: statusColor, size: 24), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + jenis, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: textDarkColor, + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 5), + Text( + tanggal, + style: const TextStyle( + color: textSoftColor, + fontSize: 13, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 5), + Text( + info, + style: const TextStyle( + color: textSoftColor, + fontSize: 13, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 10), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + decoration: BoxDecoration( + color: statusColor == primaryColor + ? const Color.fromRGBO(11, 125, 119, 0.10) + : statusColor == accentColor + ? const Color.fromRGBO(255, 140, 50, 0.10) + : statusColor == Colors.red + ? const Color.fromRGBO(244, 67, 54, 0.10) + : const Color.fromRGBO(158, 158, 158, 0.10), + borderRadius: BorderRadius.circular(100), + ), + child: Text( + getStatusText(status), + style: TextStyle( + color: statusColor, + fontSize: 12, + fontWeight: FontWeight.w800, + ), + ), + ), + ], + ), + ), + const SizedBox(width: 8), + const Icon( + Icons.arrow_forward_ios_rounded, + size: 16, + color: Color(0xFF94A3B8), + ), + ], + ), + ), + ); + } + + Widget _buildEmptyState() { + return ListView( + physics: const AlwaysScrollableScrollPhysics(), + children: [ + Padding( + padding: const EdgeInsets.only(top: 70), + child: Column( + children: [ + Container( + width: 82, + height: 82, + decoration: BoxDecoration( + color: const Color.fromRGBO(11, 125, 119, 0.10), + borderRadius: BorderRadius.circular(26), + ), + child: const Icon( + Icons.history_rounded, + color: primaryColor, + size: 42, + ), + ), + const SizedBox(height: 16), + const Text( + 'Tidak ada data', + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 6), + const Text( + 'Riwayat belum tersedia.', + style: TextStyle(fontSize: 13, color: textSoftColor), + ), + ], + ), + ), + ], + ); + } + + Widget _buildErrorState() { + return ListView( + physics: const AlwaysScrollableScrollPhysics(), + children: [ + Padding( + padding: const EdgeInsets.only(top: 70), + child: Column( + children: [ + const Icon( + Icons.warning_amber_rounded, + color: Colors.red, + size: 46, + ), + const SizedBox(height: 12), + Text( + errorMessage, + textAlign: TextAlign.center, + style: const TextStyle( + color: textDarkColor, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: () => fetchRiwayat(), + style: ElevatedButton.styleFrom( + backgroundColor: primaryColor, + foregroundColor: Colors.white, + elevation: 0, + ), + child: const Text('Coba Lagi'), + ), + ], + ), + ), + ], + ); + } + + Widget _buildContent() { + if (isLoading) { + return const Expanded( + child: Center(child: CircularProgressIndicator(color: primaryColor)), + ); + } + + if (errorMessage.isNotEmpty) { + return Expanded(child: _buildErrorState()); + } + + if (filteredData.isEmpty) { + return Expanded(child: _buildEmptyState()); + } + + return Expanded( + child: ListView.builder( + physics: const AlwaysScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemCount: filteredData.length, + itemBuilder: (context, index) { + return buildCard(filteredData[index]); + }, + ), + ); + } + + Future _handleRefresh() async { + await fetchRiwayat(silent: true); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + appBar: AppBar( + title: const Text( + 'Riwayat', + style: TextStyle(fontWeight: FontWeight.w800), + ), + backgroundColor: Colors.white, + foregroundColor: primaryColor, + elevation: 0.8, + ), + body: RefreshIndicator( + color: primaryColor, + onRefresh: _handleRefresh, + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + buildFilterButton('Semua'), + const SizedBox(width: 8), + buildFilterButton('Menunggu'), + const SizedBox(width: 8), + buildFilterButton('Disetujui'), + const SizedBox(width: 8), + buildFilterButton('Ditolak'), + ], + ), + ), + const SizedBox(height: 14), + TextField( + decoration: InputDecoration( + hintText: 'Cari riwayat', + prefixIcon: const Icon( + Icons.search_rounded, + color: primaryColor, + ), + filled: true, + fillColor: Colors.white, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 16, + ), + hintStyle: const TextStyle( + color: Color(0xFF94A3B8), + fontSize: 13, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(18), + borderSide: const BorderSide(color: Color(0xFFE2E8F0)), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(18), + borderSide: const BorderSide( + color: primaryColor, + width: 1.4, + ), + ), + ), + onChanged: (val) { + searchQuery = val; + applyFilter(); + }, + ), + const SizedBox(height: 16), + _buildContent(), + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/views/pages/scanner_screen.dart b/lib/presentation/views/pages/scanner_screen.dart new file mode 100644 index 0000000..bfd9e71 --- /dev/null +++ b/lib/presentation/views/pages/scanner_screen.dart @@ -0,0 +1,101 @@ +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:mobile_scanner/mobile_scanner.dart'; +import 'absen_screen.dart'; + +class ScannerScreen extends StatefulWidget { + const ScannerScreen({super.key}); + + @override + State createState() => _ScannerScreenState(); +} + +class _ScannerScreenState extends State { + final MobileScannerController _controller = MobileScannerController( + detectionSpeed: DetectionSpeed.noDuplicates, + facing: CameraFacing.back, + ); + + bool _handled = false; + + Map _parseQr(String raw) { + try { + final decoded = jsonDecode(raw); + if (decoded is Map) return decoded; + return {'raw': raw, 'data': decoded}; + } catch (_) { + return {'raw': raw}; + } + } + + void _onDetect(BarcodeCapture capture) async { + if (_handled) return; + + final barcode = capture.barcodes.isNotEmpty ? capture.barcodes.first : null; + final raw = barcode?.rawValue; + if (raw == null || raw.isEmpty) return; + _handled = true; + + await _controller.stop(); + final qrData = _parseQr(raw); + + Get.off(() => AbsenScreen(qrData: qrData)); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.black, + appBar: AppBar( + title: const Text('Scan QR'), + backgroundColor: Colors.black, + foregroundColor: Colors.white, + actions: [ + IconButton( + onPressed: () => _controller.toggleTorch(), + icon: const Icon(Icons.flash_on), + ), + IconButton( + onPressed: () => _controller.switchCamera(), + icon: const Icon(Icons.cameraswitch), + ), + ], + ), + body: Stack( + children: [ + MobileScanner(controller: _controller, onDetect: _onDetect), + + // overlay panduan (kotak scan) + Center( + child: Container( + width: 260, + height: 260, + decoration: BoxDecoration( + border: Border.all(color: Colors.white, width: 2), + borderRadius: BorderRadius.circular(16), + ), + ), + ), + + const Positioned( + left: 0, + right: 0, + bottom: 24, + child: Text( + 'Arahkan QR ke dalam kotak', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/views/pages/veryfikasiOTP.dart b/lib/presentation/views/pages/veryfikasiOTP.dart new file mode 100644 index 0000000..ea53d57 --- /dev/null +++ b/lib/presentation/views/pages/veryfikasiOTP.dart @@ -0,0 +1,483 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:http/http.dart' as http; +import 'package:sidak_desa_mobile/core/api/api.dart'; + +import 'konfirmasi_sandi_baru.dart'; + +class OtpVerificationPage extends StatefulWidget { + final String email; + + const OtpVerificationPage({super.key, required this.email}); + + @override + State createState() => _OtpVerificationPageState(); +} + +class _OtpVerificationPageState extends State { + final List otpControllers = List.generate( + 5, + (_) => TextEditingController(), + ); + + final List focusNodes = List.generate( + 5, + (_) => FocusNode(), + ); + + bool isLoading = false; + + static const Color primaryColor = Color(0xFF0B7D77); + static const Color accentColor = Color(0xFFFF8C32); + static const Color backgroundColor = Color(0xFFF4F7F8); + static const Color textDarkColor = Color(0xFF1E293B); + static const Color textSoftColor = Color(0xFF64748B); + + String get otpCode { + return otpControllers.map((controller) => controller.text).join(); + } + + @override + void dispose() { + for (final controller in otpControllers) { + controller.dispose(); + } + + for (final node in focusNodes) { + node.dispose(); + } + + super.dispose(); + } + + Future verifyOtp() async { + final otpString = otpCode; + + if (otpString.length < 5) { + showMessage( + title: 'OTP Belum Lengkap', + message: 'Masukkan kode OTP 5 digit terlebih dahulu.', + ); + return; + } + + setState(() => isLoading = true); + + try { + final response = await http.post( + Uri.parse('${Apiconfig.baseUrl}/api/verify-otp'), + headers: const { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: jsonEncode({ + 'email': widget.email, + 'otp': otpString, + }), + ); + + final data = jsonDecode(response.body); + + if (!mounted) return; + + setState(() => isLoading = false); + + if (response.statusCode == 200) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (_) => ResetPasswordPage(email: widget.email), + ), + ); + } else { + showMessage( + title: 'OTP Salah', + message: data['message'] ?? 'Kode OTP yang Anda masukkan tidak sesuai.', + ); + } + } catch (e) { + if (!mounted) return; + + setState(() => isLoading = false); + + showMessage( + title: 'Koneksi Bermasalah', + message: 'Gagal terhubung ke server. Silakan coba lagi.', + ); + } + } + + void showMessage({ + required String title, + required String message, + }) { + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => Dialog( + backgroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + child: Padding( + padding: const EdgeInsets.fromLTRB(24, 28, 24, 24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 76, + height: 76, + decoration: const BoxDecoration( + color: Color.fromRGBO(244, 67, 54, 0.10), + shape: BoxShape.circle, + ), + child: const Icon( + Icons.warning_amber_rounded, + color: Colors.red, + size: 42, + ), + ), + const SizedBox(height: 20), + Text( + title, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 19, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + const SizedBox(height: 10), + Text( + message, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 14, + height: 1.5, + color: textSoftColor, + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + onPressed: () => Navigator.pop(context), + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + 'Kembali', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } + + Widget otpBox(int index) { + return SizedBox( + width: 52, + height: 58, + child: TextField( + controller: otpControllers[index], + focusNode: focusNodes[index], + keyboardType: TextInputType.number, + maxLength: 1, + textAlign: TextAlign.center, + cursorColor: primaryColor, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + decoration: InputDecoration( + counterText: '', + filled: true, + fillColor: const Color(0xFFF8FAFC), + contentPadding: EdgeInsets.zero, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide( + color: Color(0xFFE2E8F0), + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: const BorderSide( + color: primaryColor, + width: 1.5, + ), + ), + ), + onChanged: (value) { + if (value.isNotEmpty && index < 4) { + focusNodes[index + 1].requestFocus(); + } + + if (value.isEmpty && index > 0) { + focusNodes[index - 1].requestFocus(); + } + }, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: backgroundColor, + body: SafeArea( + child: Stack( + children: [ + Container( + height: 290, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color(0xFF0B7D77), + Color(0xFF0FA39A), + ], + ), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(36), + bottomRight: Radius.circular(36), + ), + ), + ), + + SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(22, 16, 22, 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + if (Navigator.canPop(context)) + InkWell( + onTap: () => Navigator.pop(context), + borderRadius: BorderRadius.circular(14), + child: Container( + width: 42, + height: 42, + decoration: BoxDecoration( + color: const Color.fromRGBO(255, 255, 255, 0.18), + borderRadius: BorderRadius.circular(14), + ), + child: const Icon( + Icons.arrow_back_ios_new_rounded, + color: Colors.white, + size: 18, + ), + ), + ), + ], + ), + + const SizedBox(height: 18), + + Column( + children: [ + Container( + width: 250, + height: 96, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.12), + blurRadius: 22, + offset: Offset(0, 10), + ), + ], + ), + child: Image.asset( + 'assets/images/logo.png', + fit: BoxFit.contain, + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Verifikasi OTP', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 26, + height: 1.2, + fontWeight: FontWeight.w800, + color: Colors.white, + ), + ), + + const SizedBox(height: 10), + + Text( + 'Akun: ${widget.email}', + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 14, + color: Color.fromRGBO(255, 255, 255, 0.88), + ), + ), + ], + ), + + const SizedBox(height: 34), + + Container( + padding: const EdgeInsets.all(22), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + blurRadius: 24, + offset: Offset(0, 12), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const Text( + 'Masukkan Kode OTP', + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w800, + color: textDarkColor, + ), + ), + + const SizedBox(height: 6), + + const Text( + 'Isi 5 digit kode OTP yang telah dikirim ke email Anda.', + style: TextStyle( + fontSize: 13, + height: 1.5, + color: textSoftColor, + ), + ), + + const SizedBox(height: 26), + + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: List.generate(5, otpBox), + ), + + const SizedBox(height: 18), + + Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: const Color.fromRGBO(11, 125, 119, 0.08), + borderRadius: BorderRadius.circular(16), + border: Border.all( + color: const Color.fromRGBO(11, 125, 119, 0.12), + ), + ), + child: const Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + Icons.info_outline_rounded, + color: primaryColor, + size: 20, + ), + SizedBox(width: 10), + Expanded( + child: Text( + 'Jangan bagikan kode OTP kepada siapa pun demi keamanan akun Anda.', + style: TextStyle( + fontSize: 12.5, + height: 1.45, + color: textSoftColor, + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 26), + + SizedBox( + height: 54, + child: ElevatedButton( + onPressed: isLoading ? null : verifyOtp, + style: ElevatedButton.styleFrom( + backgroundColor: accentColor, + disabledBackgroundColor: + const Color.fromRGBO(255, 140, 50, 0.55), + foregroundColor: Colors.white, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + child: isLoading + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2.4, + ), + ) + : const Text( + 'Verifikasi OTP', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 22), + + const Text( + 'Setelah OTP benar, Anda akan diarahkan ke halaman pembuatan kata sandi baru.', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + height: 1.5, + color: textSoftColor, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/presentation/views/splash_screen.dart b/lib/presentation/views/splash_screen.dart new file mode 100644 index 0000000..01ce9aa --- /dev/null +++ b/lib/presentation/views/splash_screen.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:sidak_desa_mobile/core/const/app_colors.dart'; +import 'package:sidak_desa_mobile/presentation/controllers/splash_screen_controller.dart'; + +class SplashScreen extends StatelessWidget { + SplashScreen({super.key}); + + final controller = Get.put(SplashScreenController()); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(width: 200, 'assets/images/logo.png'), + const SizedBox(height: 20), + const CircularProgressIndicator(color: AppColors.primaryColor), + ], + ), + ), + ); + } +} diff --git a/lib/utils/device_id.dart b/lib/utils/device_id.dart new file mode 100644 index 0000000..d991aca --- /dev/null +++ b/lib/utils/device_id.dart @@ -0,0 +1,21 @@ +import 'dart:io'; +import 'package:device_info_plus/device_info_plus.dart'; + +class DeviceIdUtil { + static Future getDeviceId() async { + final deviceInfo = DeviceInfoPlugin(); + + if (Platform.isAndroid) { + final android = await deviceInfo.androidInfo; + // android.id biasanya cukup untuk kebutuhan "device_id" + return android.id; + } + + if (Platform.isIOS) { + final ios = await deviceInfo.iosInfo; + return ios.identifierForVendor ?? 'unknown-ios'; + } + + return 'unknown-device'; + } +} 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..a839056 --- /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 "sidak_desa_mobile") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.sidak_desa_mobile") + +# 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..64a0ece --- /dev/null +++ b/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include + +void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); + file_selector_plugin_register_with_registrar(file_selector_linux_registrar); +} 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..2db3c22 --- /dev/null +++ b/linux/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + file_selector_linux +) + +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..0ac5c49 --- /dev/null +++ b/linux/runner/my_application.cc @@ -0,0 +1,148 @@ +#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) + +// Called when first Flutter frame received. +static void first_frame_cb(MyApplication* self, FlView* view) { + gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); +} + +// 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, "sidak_desa_mobile"); + 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, "sidak_desa_mobile"); + } + + gtk_window_set_default_size(window, 1280, 720); + + 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); + GdkRGBA background_color; + // Background defaults to black, override it here if necessary, e.g. #00000000 + // for transparent. + gdk_rgba_parse(&background_color, "#000000"); + fl_view_set_background_color(view, &background_color); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + // Show the window when Flutter renders. + // Requires the view to be realized so we can start rendering. + g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), + self); + gtk_widget_realize(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..db16367 --- /dev/null +++ b/linux/runner/my_application.h @@ -0,0 +1,21 @@ +#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..b2672af --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,20 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import device_info_plus +import file_selector_macos +import geolocator_apple +import mobile_scanner +import shared_preferences_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) + MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) +} diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..06d43d5 --- /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 /* sidak_desa_mobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "sidak_desa_mobile.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 /* sidak_desa_mobile.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 /* sidak_desa_mobile.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.sidakDesaMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sidak_desa_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sidak_desa_mobile"; + }; + 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.sidakDesaMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sidak_desa_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sidak_desa_mobile"; + }; + 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.sidakDesaMobile.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/sidak_desa_mobile.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/sidak_desa_mobile"; + }; + 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.15; + 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.15; + 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.15; + 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..7744f95 --- /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..6f2fbbd --- /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 = sidak_desa_mobile + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.sidakDesaMobile + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 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..d46f483 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,698 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.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: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" + source: hosted + version: "1.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937" + url: "https://pub.dev" + source: hosted + version: "0.3.5+2" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + dart_earcut: + dependency: transitive + description: + name: dart_earcut + sha256: e485001bfc05dcbc437d7bfb666316182e3522d4c3f9668048e004d0eb2ce43b + url: "https://pub.dev" + source: hosted + version: "1.2.0" + device_info_plus: + dependency: "direct main" + description: + name: device_info_plus + sha256: a7fd703482b391a87d60b6061d04dfdeab07826b96f9abd8f5ed98068acc0074 + url: "https://pub.dev" + source: hosted + version: "10.1.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f + url: "https://pub.dev" + source: hosted + version: "7.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0" + url: "https://pub.dev" + source: hosted + version: "0.9.4" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a" + url: "https://pub.dev" + source: hosted + version: "0.9.5" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85" + url: "https://pub.dev" + source: hosted + version: "2.7.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd" + url: "https://pub.dev" + source: hosted + version: "0.9.3+5" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1" + url: "https://pub.dev" + source: hosted + version: "6.0.0" + flutter_map: + dependency: "direct main" + description: + name: flutter_map + sha256: "2ecb34619a4be19df6f40c2f8dce1591675b4eff7a6857bd8f533706977385da" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1 + url: "https://pub.dev" + source: hosted + version: "2.0.33" + 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" + geolocator: + dependency: "direct main" + description: + name: geolocator + sha256: f62bcd90459e63210bbf9c35deb6a51c521f992a78de19a1fe5c11704f9530e2 + url: "https://pub.dev" + source: hosted + version: "13.0.4" + geolocator_android: + dependency: transitive + description: + name: geolocator_android + sha256: fcb1760a50d7500deca37c9a666785c047139b5f9ee15aa5469fae7dbbe3170d + url: "https://pub.dev" + source: hosted + version: "4.6.2" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + sha256: dbdd8789d5aaf14cf69f74d4925ad1336b4433a6efdf2fce91e8955dc921bf22 + url: "https://pub.dev" + source: hosted + version: "2.3.13" + geolocator_platform_interface: + dependency: transitive + description: + name: geolocator_platform_interface + sha256: "30cb64f0b9adcc0fb36f628b4ebf4f731a2961a0ebd849f4b56200205056fe67" + url: "https://pub.dev" + source: hosted + version: "4.2.6" + geolocator_web: + dependency: transitive + description: + name: geolocator_web + sha256: b1ae9bdfd90f861fde8fd4f209c37b953d65e92823cb73c7dee1fa021b06f172 + url: "https://pub.dev" + source: hosted + version: "4.1.3" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + sha256: "175435404d20278ffd220de83c2ca293b73db95eafbdc8131fe8609be1421eb6" + url: "https://pub.dev" + source: hosted + version: "0.2.5" + get: + dependency: "direct main" + description: + name: get + sha256: "5ed34a7925b85336e15d472cc4cfe7d9ebf4ab8e8b9f688585bf6b50f4c3d79a" + url: "https://pub.dev" + source: hosted + version: "4.7.3" + http: + dependency: "direct main" + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "784210112be18ea55f69d7076e2c656a4e24949fa9e76429fe53af0c0f4fa320" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: eda9b91b7e266d9041084a42d605a74937d996b87083395c5e47835916a86156 + url: "https://pub.dev" + source: hosted + version: "0.8.13+14" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: b9c4a438a9ff4f60808c9cf0039b93a42bb6c2211ef6ebb647394b2b3fa84588 + url: "https://pub.dev" + source: hosted + version: "0.8.13+6" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91" + url: "https://pub.dev" + source: hosted + version: "0.2.2+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" + url: "https://pub.dev" + source: hosted + version: "2.11.1" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.dev" + source: hosted + version: "0.2.2" + intl: + dependency: transitive + description: + name: intl + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + url: "https://pub.dev" + source: hosted + version: "0.20.2" + latlong2: + dependency: "direct main" + description: + name: latlong2 + sha256: "98227922caf49e6056f91b6c56945ea1c7b166f28ffcd5fb8e72fc0b453cc8fe" + url: "https://pub.dev" + source: hosted + version: "0.9.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + lists: + dependency: transitive + description: + name: lists + sha256: "4ca5c19ae4350de036a7e996cdd1ee39c93ac0a2b840f4915459b7d0a7d4ab27" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + logger: + dependency: transitive + description: + name: logger + sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3 + url: "https://pub.dev" + source: hosted + version: "2.6.2" + matcher: + dependency: transitive + description: + name: matcher + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" + url: "https://pub.dev" + source: hosted + version: "0.12.18" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mgrs_dart: + dependency: transitive + description: + name: mgrs_dart + sha256: fb89ae62f05fa0bb90f70c31fc870bcbcfd516c843fb554452ab3396f78586f7 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mobile_scanner: + dependency: "direct main" + description: + name: mobile_scanner + sha256: c6184bf2913dd66be244108c9c27ca04b01caf726321c44b0e7a7a1e32d41044 + url: "https://pub.dev" + source: hosted + version: "7.1.4" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + polylabel: + dependency: transitive + description: + name: polylabel + sha256: "41b9099afb2aa6c1730bdd8a0fab1400d287694ec7615dd8516935fa3144214b" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + proj4dart: + dependency: transitive + description: + name: proj4dart + sha256: c8a659ac9b6864aa47c171e78d41bbe6f5e1d7bd790a5814249e6b68bc44324e + url: "https://pub.dev" + source: hosted + version: "2.1.0" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: cbc40be9be1c5af4dab4d6e0de4d5d3729e6f3d65b89d21e1815d57705644a6f + url: "https://pub.dev" + source: hosted + version: "2.4.20" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + 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: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" + url: "https://pub.dev" + source: hosted + version: "0.7.9" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + unicode: + dependency: transitive + description: + name: unicode + sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8 + url: "https://pub.dev" + source: hosted + version: "4.5.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + win32_registry: + dependency: transitive + description: + name: win32_registry + sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852" + url: "https://pub.dev" + source: hosted + version: "1.1.5" + wkt_parser: + dependency: transitive + description: + name: wkt_parser + sha256: "8a555fc60de3116c00aad67891bcab20f81a958e4219cc106e3c037aa3937f13" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" +sdks: + dart: ">=3.10.4 <4.0.0" + flutter: ">=3.38.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..f63183a --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,94 @@ +name: sidak_desa_mobile +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.10.4 + +# 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: + cupertino_icons: ^1.0.8 + flutter: + sdk: flutter + get: ^4.7.3 + http: ^1.2.2 + shared_preferences: ^2.2.2 + device_info_plus: ^10.1.2 + mobile_scanner: ^7.1.4 + geolocator: ^13.0.2 + flutter_map: ^7.0.2 + latlong2: ^0.9.1 + image_picker: ^1.0.7 + +dev_dependencies: + # 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: ^6.0.0 + flutter_test: + sdk: flutter + +# 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: + - assets/images/ + - assets/images/gito.jpg + - assets/images/logo.png + - assets/images/Union.png + - assets/images/icon_riwayat.png + - assets/images/icon_izin.png + - assets/images/icon_masuk.png + + # 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..0bb6880 --- /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:sidak_desa_mobile/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..f211334 --- /dev/null +++ b/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + sidak_desa_mobile + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..0001f87 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "sidak_desa_mobile", + "short_name": "sidak_desa_mobile", + "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/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..799d343 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(sidak_desa_mobile 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 "sidak_desa_mobile") + +# 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..f35b3a6 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,17 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + GeolocatorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("GeolocatorWindows")); +} 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..389222b --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,25 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + file_selector_windows + geolocator_windows +) + +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..f2cc893 --- /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", "sidak_desa_mobile" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "sidak_desa_mobile" "\0" + VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "sidak_desa_mobile.exe" "\0" + VALUE "ProductName", "sidak_desa_mobile" "\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..d369c0d --- /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"sidak_desa_mobile", 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_