diff --git a/praresi/.gitignore b/praresi/.gitignore new file mode 100644 index 0000000..29a3a50 --- /dev/null +++ b/praresi/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/praresi/.metadata b/praresi/.metadata new file mode 100644 index 0000000..dd8de3f --- /dev/null +++ b/praresi/.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: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + - platform: android + create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9 + + # 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/praresi/README.md b/praresi/README.md new file mode 100644 index 0000000..0ccd942 --- /dev/null +++ b/praresi/README.md @@ -0,0 +1,16 @@ +# praresi + +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/praresi/analysis_options.yaml b/praresi/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/praresi/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/praresi/android/.gitignore b/praresi/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/praresi/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/praresi/android/app/build.gradle b/praresi/android/app/build.gradle new file mode 100644 index 0000000..c9d7671 --- /dev/null +++ b/praresi/android/app/build.gradle @@ -0,0 +1,85 @@ +plugins { + id "com.android.application" + // START: FlutterFire Configuration + id 'com.google.gms.google-services' + // END: FlutterFire Configuration + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.praresi" + // compileSdkVersion flutter.compileSdkVersion --> diganti dibawah + compileSdkVersion 34 + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + // defaultConfig { + // // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + // applicationId "com.example.praresi" + // // You can update the following values to match your application needs. + // // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + // minSdkVersion flutter.minSdkVersion + // targetSdkVersion flutter.targetSdkVersion + // versionCode flutterVersionCode.toInteger() + // versionName flutterVersionName + // multiDexEnabled true // tambahan + // } + + // baru dibawah + defaultConfig { + applicationId "com.example.praresi" + minSdkVersion 21 + targetSdkVersion 34 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + multiDexEnabled true + } + + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "androidx.multidex:multidex:2.0.1" // tambahan +} diff --git a/praresi/android/app/google-services.json b/praresi/android/app/google-services.json new file mode 100644 index 0000000..5f77a46 --- /dev/null +++ b/praresi/android/app/google-services.json @@ -0,0 +1,48 @@ +{ + "project_info": { + "project_number": "1084316054508", + "project_id": "snapresi-8e964", + "storage_bucket": "snapresi-8e964.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:1084316054508:android:86d995859cf2c85df306c9", + "android_client_info": { + "package_name": "com.example.praresi" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyBR6rF7--1ZQYFCPVVjn1wMAt5qcmfMgGw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:1084316054508:android:38e16231a48eb280f306c9", + "android_client_info": { + "package_name": "com.example.snapresi" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyBR6rF7--1ZQYFCPVVjn1wMAt5qcmfMgGw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/praresi/android/app/src/debug/AndroidManifest.xml b/praresi/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/praresi/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/praresi/android/app/src/main/AndroidManifest.xml b/praresi/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fdfc27f --- /dev/null +++ b/praresi/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/android/app/src/main/kotlin/com/example/praresi/MainActivity.kt b/praresi/android/app/src/main/kotlin/com/example/praresi/MainActivity.kt new file mode 100644 index 0000000..ebd33be --- /dev/null +++ b/praresi/android/app/src/main/kotlin/com/example/praresi/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.praresi + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/praresi/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/praresi/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..51c2576 Binary files /dev/null and b/praresi/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ diff --git a/praresi/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/praresi/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4b73f44 Binary files /dev/null and b/praresi/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ diff --git a/praresi/android/app/src/main/res/drawable-v21/launch_background.xml b/praresi/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/praresi/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/praresi/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/praresi/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4e18c31 Binary files /dev/null and b/praresi/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ diff --git a/praresi/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/praresi/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..322246e Binary files /dev/null and b/praresi/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ diff --git a/praresi/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/praresi/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..90c71d3 Binary files /dev/null and b/praresi/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ diff --git a/praresi/android/app/src/main/res/drawable/launch_background.xml b/praresi/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/praresi/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/praresi/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/praresi/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..5f349f7 --- /dev/null +++ b/praresi/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/praresi/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/praresi/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..d5dff77 Binary files /dev/null and b/praresi/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/praresi/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/praresi/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..9df92b3 Binary files /dev/null and b/praresi/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/praresi/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/praresi/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..34c7137 Binary files /dev/null and b/praresi/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/praresi/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/praresi/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..a023abd Binary files /dev/null and b/praresi/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/praresi/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/praresi/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..74d4aaa Binary files /dev/null and b/praresi/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/praresi/android/app/src/main/res/values-night/styles.xml b/praresi/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/praresi/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/praresi/android/app/src/main/res/values/colors.xml b/praresi/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..2ff3651 --- /dev/null +++ b/praresi/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #1976D2 + \ No newline at end of file diff --git a/praresi/android/app/src/main/res/values/styles.xml b/praresi/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/praresi/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/praresi/android/app/src/profile/AndroidManifest.xml b/praresi/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/praresi/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/praresi/android/build.gradle b/praresi/android/build.gradle new file mode 100644 index 0000000..e83fb5d --- /dev/null +++ b/praresi/android/build.gradle @@ -0,0 +1,30 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/praresi/android/gradle.properties b/praresi/android/gradle.properties new file mode 100644 index 0000000..598d13f --- /dev/null +++ b/praresi/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/praresi/android/gradle/wrapper/gradle-wrapper.properties b/praresi/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c472b9 --- /dev/null +++ b/praresi/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-7.5-all.zip diff --git a/praresi/android/settings.gradle b/praresi/android/settings.gradle new file mode 100644 index 0000000..495528e --- /dev/null +++ b/praresi/android/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false + // START: FlutterFire Configuration + id "com.google.gms.google-services" version "4.3.15" apply false + // END: FlutterFire Configuration +} + +include ":app" diff --git a/praresi/assets/data/regions.json b/praresi/assets/data/regions.json new file mode 100644 index 0000000..6fd6f1d --- /dev/null +++ b/praresi/assets/data/regions.json @@ -0,0 +1,738 @@ +[ + { + "provinsi":"Aceh", + "kota":[ + "Kota Banda Aceh", + "Kota Sabang", + "Kota Lhokseumawe", + "Kota Langsa", + "Kota Subulussalam", + "Kab. Aceh Selatan", + "Kab. Aceh Tenggara", + "Kab. Aceh Timur", + "Kab. Aceh Tengah", + "Kab. Aceh Barat", + "Kab. Aceh Besar", + "Kab. Pidie", + "Kab. Aceh Utara", + "Kab. Simeulue", + "Kab. Aceh Singkil", + "Kab. Bireun", + "Kab. Aceh Barat Daya", + "Kab. Gayo Lues", + "Kab. Aceh Jaya", + "Kab. Nagan Raya", + "Kab. Aceh Tamiang", + "Kab. Bener Meriah", + "Kab. Pidie Jaya" + ] + }, + + { + "provinsi":"Sumatera Utara", + "kota":[ + "Kota Medan", + "Kota Pematang Siantar", + "Kota Sibolga", + "Kota Tanjung Balai", + "Kota Binjai", + "Kota Tebing Tinggi", + "Kota Padang Sidempuan", + "Kota Gunung Sitoli", + "Kab. Serdang Bedagai", + "Kab. Samosir ", + "Kab. Humbang Hasundutan", + "Kab. Pakpak Bharat", + "Kab. Nias Selatan", + "Kab. Mandailing Natal", + "Kab. Toba Samosir", + "Kab. Dairi", + "Kab. Labuhan Batu", + "Kab. Asahan", + "Kab. Simalungun", + "Kab. Deli Serdang", + "Kab. Karo", + "Kab. Langkat", + "Kab. Nias", + "Kab. Tapanuli Selatan", + "Kab. Tapanuli Utara", + "Kab. Tapanuli Tengah", + "Kab. Batu Bara", + "Kab. Padang Lawas Utara", + "Kab. Padang Lawas", + "Kab. Labuhanbatu Selatan", + "Kab. Labuhanbatu Utara", + "Kab. Nias Utara", + "Kab. Nias Barat" + ] + }, + + { + "provinsi":"Sumatera Barat", + "kota":[ + "Kota Padang", + "Kota Solok", + "Kota Sawhlunto", + "Kota Padang Panjang", + "Kota Bukittinggi", + "Kota Payakumbuh", + "Kota Pariaman", + "Kab. Pasaman Barat", + "Kab. Solok Selatan", + "Kab. Dharmasraya", + "Kab. Kepulauan Mentawai", + "Kab. Pasaman", + "Kab. Lima Puluh Kota", + "Kab. Agam", + "Kab. Padang Pariaman", + "Kab. Tanah Datar", + "Kab. Sijunjung", + "Kab. Solok", + "Kab. Pesisir Selatan" + ] + }, + + { + "provinsi":"Riau", + "kota":[ + "Kota Pekan Baru", + "Kota Dumai", + "Kab. Kepulauan Meranti", + "Kab. Kuantan Singingi", + "Kab. Siak", + "Kab. Rokan Hilir", + "Kab. Rokan Hulu", + "Kab. Pelalawan", + "Kab. Indragiri Hilir", + "Kab. Bengkalis", + "Kab. Indragiri Hulu", + "Kab. Kampar" + ] + }, + + { + "provinsi":"Jambi", + "kota":[ + "Kota Jambi", + "Kota Sungai Penuh", + "Kab. Tebo", + "Kab. Bungo", + "Kab. Tanjung Jabung Timur", + "Kab. Tanjung Jabung Barat", + "Kab. Muaro Jambi", + "Kab. Batanghari", + "Kab. Sarolangun", + "Kab. Merangin", + "Kab. Kerinci" + ] + }, + + { + "provinsi":"Sumatera Selatan", + "kota":[ + "Kota Palembang", + "Kota Pagar Alam", + "Kota Lubuk Linggau", + "Kota Prabumulih", + "Kab. Musi Rawas Utara", + "Kab. Penukal Abab Lematang Ilir", + "Kab. Empat Lawang", + "Kab. Ogan Ilir ", + "Kab. Ogan Komering Ulu Selatan ", + "Kab. Ogan Komering Ulu Timur ", + "Kab. Banyuasin", + "Kab. Musi Banyuasin", + "Kab. Musi Rawas", + "Kab. Lahat", + "Kab. Muara Enim", + "Kab. Ogan Komering Ilir", + "Kab. Ogan Komering Ulu" + ] + }, + + { + "provinsi":"Bengkulu", + "kota":[ + "Kota Bengkulu", + "Kab. Bengkulu Tengah", + "Kab. Kepahiang ", + "Kab. Lebong", + "Kab. Muko Muko", + "Kab. Seluma", + "Kab. Kaur", + "Kab. Bengkulu Utara", + "Kab. Rejang Lebong", + "Kab. Bengkulu Selatan" + ] + }, + + { + "provinsi":"Lampung", + "kota":[ + "Kota Bandar Lampung", + "Kota Metro", + "Kab. Pesisir Barat", + "Kab. Tulangbawang Barat", + "Kab. Mesuji", + "Kab. Pringsewu", + "Kab. Pesawaran", + "Kab. Way Kanan", + "Kab. Lampung Timur", + "Kab. Tanggamus", + "Kab. Tulang Bawang", + "Kab. Lampung Barat", + "Kab. Lampung Utara", + "Kab. Lampung Tengah", + "Kab. Lampung Selatan" + ] + }, + + { + "provinsi":"Kepulauan Bangka Belitung", + "kota":[ + "Kota Pangkal Pinang", + "Kab. Belitung Timur", + "Kab. Bangka Barat", + "Kab. Bangka Tengah", + "Kab. Bangka Selatan", + "Kab. Belitung", + "Kab. Bangka" + ] + }, + + { + "provinsi":"Kepulauan Riau", + "kota":[ + "Kota Batam", + "Kota Tanjung Pinang", + "Kab. Kepulauan Anambas", + "Kab. Lingga ", + "Kab. Natuna", + "Kab. Karimun", + "Kab. Bintan" + ] + }, + + { + "provinsi":"DKI Jakarta", + "kota":[ + "Kota Jakarta Timur", + "Kota Jakarta Selatan", + "Kota Jakarta Barat", + "Kota Jakarta Utara", + "Kota Jakarta Pusat", + "Kab. Kepulauan Seribu" + ] + }, + + { + "provinsi":"Jawa Barat", + "kota":[ + "Kota Bandung", + "Kota Banjar", + "Kota Tasikmalaya", + "Kota Cimahi", + "Kota Depok", + "Kota Bekasi", + "Kota Cirebon", + "Kota Sukabumi", + "Kota Bogor", + "Kab. Pangandaran", + "Kab. Bandung Barat", + "Kab. Bekasi", + "Kab. Karawang", + "Kab. Purwakarta", + "Kab. Subang", + "Kab. Indramayu", + "Kab. Sumedang", + "Kab. Majalengka", + "Kab. Cirebon", + "Kab. Kuningan", + "Kab. Ciamis", + "Kab. Tasikmalaya", + "Kab. Garut", + "Kab. Bandung", + "Kab. Cianjur", + "Kab. Sukabumi", + "Kab. Bogor" + ] + }, + + { + "provinsi":"Jawa Tengah", + "kota":[ + "Kota Semarang", + "Kota Tegal", + "Kota Pekalongan", + "Kota Salatiga", + "Kota Surakarta", + "Kota Magelang", + "Kab. Brebes", + "Kab. Tegal", + "Kab. Pemalang", + "Kab. Pekalongan", + "Kab. Batang", + "Kab. Kendal", + "Kab. Temanggung", + "Kab. Semarang", + "Kab. Demak", + "Kab. Jepara", + "Kab. Kudus", + "Kab. Pati", + "Kab. Rembang", + "Kab. Blora", + "Kab. Grobogan", + "Kab. Sragen", + "Kab. Karanganyar", + "Kab. Wonogiri", + "Kab. Sukoharjo", + "Kab. Klaten", + "Kab. Boyolali", + "Kab. Magelang", + "Kab. Wonosobo", + "Kab. Purworejo", + "Kab. Kebumen", + "Kab. Banjarnegara", + "Kab. Purbalingga", + "Kab. Banyumas", + "Kab. Cilacap" + ] + }, + + { + "provinsi":"DI Yogyakarta", + "kota":[ + "Kota Yogyakarta", + "Kab. Sleman", + "Kab. Gunung Kidul", + "Kab. Bantul", + "Kab. Kulon Progo" + ] + }, + + { + "provinsi":"Jawa Timur", + "kota":[ + "Kota Surabaya", + "Kota Batu", + "Kota Madiun", + "Kota Mojokerto", + "Kota Pasuruan", + "Kota Probolinggo", + "Kota Malang", + "Kota Blitar", + "Kota Kediri", + "Kab. Sumenep", + "Kab. Pamekasan", + "Kab. Sampang", + "Kab. Bangkalan", + "Kab. Gresik", + "Kab. Lamongan", + "Kab. Tuban", + "Kab. Bojonegoro", + "Kab. Ngawi", + "Kab. Magetan", + "Kab. Madiun", + "Kab. Nganjuk", + "Kab. Jombang", + "Kab. Mojokerto", + "Kab. Sidoarjo", + "Kab. Pasuruan", + "Kab. Probolinggo", + "Kab. Situbondo", + "Kab. Bondowoso", + "Kab. Banyuwangi", + "Kab. Jember", + "Kab. Lumajang", + "Kab. Malang", + "Kab. Kediri", + "Kab. Blitar", + "Kab. Tulungagung", + "Kab. Trenggalek", + "Kab. Ponorogo", + "Kab. Pacitan" + ] + }, + + { + "provinsi":"Banten", + "kota":[ + "Kota Serang", + "Kota Cilegon", + "Kota Tangerang", + "Kota Tangerang Selatan", + "Kab. Serang", + "Kab. Tangerang", + "Kab. Lebak", + "Kab. Pandeglang" + ] + }, + + { + "provinsi":"Bali", + "kota":[ + "Kota Denpasar", + "Kab. Buleleng", + "Kab. Karangasem", + "Kab. Bangli", + "Kab. Klungkung", + "Kab. Gianyar", + "Kab. Badung", + "Kab. Tabanan", + "Kab. Jembrana" + ] + }, + + { + "provinsi":"Nusa Tenggara Barat", + "kota":[ + "Kota Mataram", + "Kota Bima", + "Kab. Lombok Utara", + "Kab. Sumbawa Barat", + "Kab. Bima", + "Kab. Dompu", + "Kab. Sumbawa ", + "Kab. Lombok Timur", + "Kab. Lombok Tengah", + "Kab. Lombok Barat" + ] + }, + + { + "provinsi":"Nusa Tenggara Timur", + "kota":[ + "Kota Kupang", + "Kab. Malaka", + "Kab. Sabu Raijua", + "Kab. Manggarai Timur", + "Kab. Sumba Barat Daya", + "Kab. Sumba Tengah", + "Kab. Nagekeo", + "Kab. Manggarai Barat", + "Kab. Rote Ndao", + "Kab. Lembata", + "Kab. Sumba Barat", + "Kab. Sumba Timur", + "Kab. Manggarai", + "Kab. Ngada", + "Kab. Ende", + "Kab. Sikka", + "Kab. Flores Timur", + "Kab. Alor", + "Kab. Belu", + "Kab. Timor Tengah Utara", + "Kab. Timor Tengah Selatan", + "Kab. Kupang" + ] + }, + { + "provinsi":"Kalimantan Barat", + "kota":[ + "Kota Pontianak", + "Kota Singkawang", + "Kab. Kubu Raya", + "Kab. Kayong Utara", + "Kab. Sekadau", + "Kab. Melawi", + "Kab. Landak", + "Kab. Bengkayang", + "Kab. Kapuas Hulu", + "Kab. Sintang ", + "Kab. Ketapang", + "Kab. Sanggau ", + "Kab. Mempawah", + "Kab. Sambas" + ] + }, + + { + "provinsi":"Kalimantan Tengah", + "kota":[ + "Kota Palangkaraya", + "Kab. Barito Timur", + "Kab. Murung Raya", + "Kab. Pulang Pisau", + "Kab. Gunung Mas", + "Kab. Lamandau", + "Kab. Sukamara", + "Kab. Seruyan", + "Kab. Katingan", + "Kab. Barito Utara", + "Kab. Barito Selatan", + "Kab. Kapuas", + "Kab. Kotawaringin Timur", + "Kab. Kotawaringin Barat" + ] + }, + + { + "provinsi":"Kalimantan Selatan", + "kota":[ + "Kota Banjarmasin", + "Kota Banjarbaru", + "Kab. Balangan", + "Kab. Tanah Bambu", + "Kab. Tabalong", + "Kab. Hulu Sungai Utara", + "Kab. Hulu Sungai Tengah", + "Kab. Hulu Sungai Selatan", + "Kab. Tapin", + "Kab. Barito Kuala", + "Kab. Banjar", + "Kab. Kotabaru", + "Kab. Tanah Laut" + ] + }, + + { + "provinsi":"Kalimantan Timur", + "kota":[ + "Kota Samarinda", + "Kota Bontang", + "Kota Balikpapan", + "Kab. Mahakam Ulu", + "Kab. Penajam Paser Utara", + "Kab. Kutai Timur", + "Kab. Kutai Barat", + "Kab. Berau", + "Kab. Kutai Kertanegara", + "Kab. Paser" + ] + }, + + { + "provinsi":"Kalimantan Utara", + "kota":[ + "Kota Tarakan", + "Kab. Tana Tidung", + "Kab. Nunukan", + "Kab. Malinau", + "Kab. Bulungan" + ] + }, + + { + "provinsi":"Sulawesi Utara", + "kota":[ + "Kota Manado", + "Kota Tomohon", + "Kota Bitung", + "Kota Kotamobagu", + "Kab. Bolaang Mangondow Selatan", + "Kab. Bolaang Mangondow Timur", + "Kab. Kepulauan Siau Tagulandang Biaro", + "Kab. Bolaang Mangondow Utara", + "Kab. Minahasa Tenggara", + "Kab. Minahasa Utara", + "Kab. Minahasa Selatan", + "Kab. Kepulauan Talaud", + "Kab. Kepulauan Sangihe", + "Kab. Minahasa", + "Kab. Bolaang Mangondow" + ] + }, + + { + "provinsi":"Sulawesi Tengah", + "kota":[ + "Kota Palu", + "Kab. Morowali Utara", + "Kab. Banggai Laut", + "Kab. Sigi", + "Kab. Tojo Una-Una", + "Kab. Parigi Moutong", + "Kab. Banggai Kepulauan", + "Kab. Morowali", + "Kab. Buol", + "Kab. Toli-Toli", + "Kab. Donggala", + "Kab. Poso", + "Kab. Banggai" + ] + }, + + { + "provinsi":"Sulawesi Selatan", + "kota":[ + "Kota Makasar", + "Kota Palopo", + "Kota Pare Pare", + "Kab. Toraja Utara", + "Kab. Luwu Timur", + "Kab. Luwu Utara", + "Kab. Tana Toraja", + "Kab. Luwu", + "Kab. Enrekang", + "Kab. Pinrang", + "Kab. Sidenreng Rappang", + "Kab. Wajo", + "Kab. Soppeng", + "Kab. Barru", + "Kab. Pangkajene Kepulauan", + "Kab. Maros", + "Kab. Bone", + "Kab. Sinjai", + "Kab. Gowa", + "Kab. Takalar", + "Kab. Jeneponto", + "Kab. Bantaeng", + "Kab. Bulukumba", + "Kab. Kepulauan Selayar" + ] + }, + + { + "provinsi":"Sulawesi Tenggara", + "kota":[ + "Kota Kendari", + "Kota Bau Bau", + "Kab. Buton Selatan", + "Kab. Buton Tengah", + "Kab. Muna Barat", + "Kab. Konawe Kepulauan", + "Kab. Kolaka Timur", + "Kab. Buton Utara", + "Kab. Konawe Utara", + "Kab. Kolaka Utara", + "Kab. Wakatobi", + "Kab. Bombana", + "Kab. Konawe Selatan", + "Kab. Buton", + "Kab. Muna", + "Kab. Konawe", + "Kab. Kolaka" + ] + }, + + { + "provinsi":"Gorontalo", + "kota":[ + "Kota Gorontalo", + "Kab. Pohuwato", + "Kab. Bone Bolango", + "Kab. Boalemo", + "Kab. Gorontalo", + "Kab. Gorontalo Utara" + ] + }, + + { + "provinsi":"Sulawesi Barat", + "kota":[ + "Kab. Majene", + "Kab. Polowali Mandar", + "Kab. Mamasa", + "Kab. Mamuju", + "Kab. Mamuju Utara", + "Kab. Mamuju Tengah" + ] + }, + + { + "provinsi":"Maluku", + "kota":[ + "Kota Ambon", + "Kota Tual", + "Kab. Buru Selatan", + "Kab. Maluku Barat Daya", + "Kab. Kepulauan Aru", + "Kab. Seram Bagian Barat ", + "Kab. Seram Bagian Timur", + "Kab. Buru", + "Kab. Maluku Tenggara Barat", + "Kab. Maluku Tenggara", + "Kab. Maluku Tengah" + ] + }, + + { + "provinsi":"Maluku Utara", + "kota":[ + "Kota Ternate", + "Kota Tidore Kepulauan", + "Kab. Pulau Taliabu", + "Kab. Pulau Morotai", + "Kab. Halmahera Timur", + "Kab. Kepulauan Sula", + "Kab. Halmahera Selatan", + "Kab. Halmahera Utara", + "Kab. Halmahera Tengah", + "Kab. Halmahera Barat" + ] + }, + + { + "provinsi": "Papua", + "kota": [ + "Kota Jayapura", + "Kab. Sarmi", + "Kab. Keerom", + "Kab. Jayapura", + "Kab. Mamberamo Raya", + "Kab. Supiori", + "Kab. Biak Numfor", + "Kab. Kepulauan Yapen", + "Kab. Waropen" + ] + }, + + { + "provinsi": "Papua Barat", + "kota": [ + "Kab. Pegunungan Arfak", + "Kab. Manokwari Selatan", + "Kab. Kaimana", + "Kab. Teluk Wondama", + "Kab. Teluk Bintuni", + "Kab. FakFak", + "Kab. Manokwari" + ] + }, + { + "provinsi": "Papua Barat Daya", + "kota": [ + "Kota Sorong", + "Kab. Maybrat", + "Kab. Tambrauw", + "Kab. Raja Ampat", + "Kab. Sorong Selatan", + "Kab. Sorong" + ] + }, + { + "provinsi": "Papua Tengah", + "kota": [ + "Kab. Nabire", + "Kab. Paniai", + "Kab. Mimika", + "Kab. Dogiyai", + "Kab. Intan Jaya", + "Kab. Deiyai", + "Kab. Puncak", + "Kab. Puncak Jaya" + ] + }, + { + "provinsi": "Papua Pegunungan", + "kota": [ + "Kab. Jayawijaya", + "Kab. Lanny Jaya", + "Kab. Mamberamo Tengah", + "Kab. Nduga", + "Kab. Pegunungan Bintang", + "Kab. Tolikara", + "Kab. Yahukimo", + "Kab. Yalimo" + ] + }, + { + "provinsi": "Papua Selatan", + "kota": [ + "Kab. Merauke", + "Kab. Asmat", + "Kab. Boven Digoel", + "Kab. Mappi" + ] + } +] diff --git a/praresi/assets/images/app_icon.png b/praresi/assets/images/app_icon.png new file mode 100644 index 0000000..bf94bfa Binary files /dev/null and b/praresi/assets/images/app_icon.png differ diff --git a/praresi/assets/images/praresi_logo.png b/praresi/assets/images/praresi_logo.png new file mode 100644 index 0000000..d955b16 Binary files /dev/null and b/praresi/assets/images/praresi_logo.png differ diff --git a/praresi/firebase.json b/praresi/firebase.json new file mode 100644 index 0000000..d917d8d --- /dev/null +++ b/praresi/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"android":{"default":{"projectId":"snapresi-8e964","appId":"1:1084316054508:android:86d995859cf2c85df306c9","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"snapresi-8e964","configurations":{"android":"1:1084316054508:android:86d995859cf2c85df306c9"}}}}}} \ No newline at end of file diff --git a/praresi/ios/.gitignore b/praresi/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/praresi/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/praresi/ios/Flutter/AppFrameworkInfo.plist b/praresi/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..9625e10 --- /dev/null +++ b/praresi/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 + 11.0 + + diff --git a/praresi/ios/Flutter/Debug.xcconfig b/praresi/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/praresi/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/praresi/ios/Flutter/Release.xcconfig b/praresi/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/praresi/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/praresi/ios/Runner.xcodeproj/project.pbxproj b/praresi/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ab91d10 --- /dev/null +++ b/praresi/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,614 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 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 */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; +/* 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 = ""; }; + 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 = ""; }; + 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; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + 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 */, + 331C807E294A63A400263BE5 /* Frameworks */, + 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 = 1430; + 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; + 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; + 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 = 11.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.praresi; + 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; + baseConfigurationReference = AE0B7B92F70575B8D7E0D07E /* Pods-RunnerTests.debug.xcconfig */; + 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.praresi.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; + baseConfigurationReference = 89B67EB44CE7B6631473024E /* Pods-RunnerTests.release.xcconfig */; + 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.praresi.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; + baseConfigurationReference = 640959BDD8F10B91D80A66BE /* Pods-RunnerTests.profile.xcconfig */; + 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.praresi.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; + 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; + 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 = 11.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; + 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; + 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 = 11.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.praresi; + 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.praresi; + 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/praresi/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/praresi/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/praresi/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/praresi/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/praresi/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/praresi/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..87131a0 --- /dev/null +++ b/praresi/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/ios/Runner.xcworkspace/contents.xcworkspacedata b/praresi/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/praresi/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/praresi/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/praresi/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/praresi/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/praresi/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/praresi/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/praresi/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/praresi/ios/Runner/AppDelegate.swift b/praresi/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/praresi/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/praresi/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/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..fd8621e Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..696ee72 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..873e4f1 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..b19a11b Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..ee4b2e6 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..845bbe7 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..35445a2 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..873e4f1 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..f4f5a9f Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..087f690 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png new file mode 100644 index 0000000..8cee2bd Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png new file mode 100644 index 0000000..fca0f9f Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png new file mode 100644 index 0000000..1245103 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png new file mode 100644 index 0000000..f9956aa Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..087f690 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..b0bc568 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png new file mode 100644 index 0000000..d5dff77 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png new file mode 100644 index 0000000..a023abd Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..b9326e6 Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..e3e30cb Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0717fca Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/praresi/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/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/praresi/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/praresi/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/praresi/ios/Runner/Base.lproj/LaunchScreen.storyboard b/praresi/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/praresi/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/ios/Runner/Base.lproj/Main.storyboard b/praresi/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/praresi/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/ios/Runner/Info.plist b/praresi/ios/Runner/Info.plist new file mode 100644 index 0000000..0208fae --- /dev/null +++ b/praresi/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Praresi + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + praresi + 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 + + + diff --git a/praresi/ios/Runner/Runner-Bridging-Header.h b/praresi/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/praresi/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/praresi/ios/RunnerTests/RunnerTests.swift b/praresi/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/praresi/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/praresi/lib/config/models/user_model.dart b/praresi/lib/config/models/user_model.dart new file mode 100644 index 0000000..e69de29 diff --git a/praresi/lib/firebase_options.dart b/praresi/lib/firebase_options.dart new file mode 100644 index 0000000..75eb04b --- /dev/null +++ b/praresi/lib/firebase_options.dart @@ -0,0 +1,62 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for ios - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyBR6rF7--1ZQYFCPVVjn1wMAt5qcmfMgGw', + appId: '1:1084316054508:android:86d995859cf2c85df306c9', + messagingSenderId: '1084316054508', + projectId: 'snapresi-8e964', + storageBucket: 'snapresi-8e964.firebasestorage.app', + ); +} diff --git a/praresi/lib/main.dart b/praresi/lib/main.dart new file mode 100644 index 0000000..111b73a --- /dev/null +++ b/praresi/lib/main.dart @@ -0,0 +1,336 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:praresi/presentation/controllers/internet_controller.dart'; +import 'package:praresi/services/bubble_services.dart'; +import 'firebase_options.dart'; +import 'presentation/routes/app_pages.dart'; +import 'presentation/routes/app_routes.dart'; +import 'package:intl/date_symbol_data_local.dart'; + +// ✅ Entry point overlay +@pragma("vm:entry-point") +void overlayMain() { + runApp( + const MaterialApp( + debugShowCheckedModeBanner: false, + home: OverlayBubble(), + ), + ); +} + + + + +class OverlayBubble extends StatefulWidget { + const OverlayBubble({super.key}); + + @override + State createState() => _OverlayBubbleState(); +} + +class _OverlayBubbleState extends State with WidgetsBindingObserver { + bool _showInput = false; + final TextEditingController _controller = TextEditingController(); + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); // 👀 pantau lifecycle app + + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + // _controller.dispose(); + super.dispose(); + } + + // 🔔 Dipanggil saat app pause/resume/close + @override + void didChangeAppLifecycleState(AppLifecycleState state) async { + if (state == AppLifecycleState.detached || state == AppLifecycleState.paused) { + // Tutup bubble saat app ditutup atau masuk background + await BubbleService().hide(); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.transparent, + body: Center( + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + transitionBuilder: (child, animation) => ScaleTransition( + scale: animation, + child: child, + ), + child: _showInput + ? _buildInputBox(context) + : Stack( + alignment: Alignment.topRight, // tombol X di pojok kanan atas + children: [ + GestureDetector( + key: const ValueKey('bubble'), + onTap: _expandToInput, + child: const CircleAvatar( + radius: 30, + backgroundColor: Colors.white, + child: Icon(Icons.book_rounded, + color: Colors.black, size: 32), + ), + ), + // Tombol Close + Positioned( + right: -2, // sedikit keluar dari bubble + top: -5, + child: GestureDetector( + onTap: () async { + await BubbleService().hide(); // close bubble + }, + child: Container( + decoration: BoxDecoration( + color: Colors.red, + shape: BoxShape.rectangle, + ), + child: const Icon( + Icons.close, + size: 18, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); +} + + + Widget _buildInputBox(BuildContext context) { + return GestureDetector( + behavior: HitTestBehavior.deferToChild, + onTapDown: (_) => FocusScope.of(context).unfocus(), + child: Container( + key: const ValueKey('inputBox'), + width: 340, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(24), + boxShadow: const [ + BoxShadow( + color: Colors.black26, + blurRadius: 15, + offset: Offset(0, 6), + ), + ], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Masukkan Data Pengiriman", + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + const SizedBox(height: 10), + + Listener( + onPointerDown: (_) {}, + child: TextField( + controller: _controller, // <-- ini yang menghubungkan TextField dengan controller + maxLines: 4, + keyboardType: TextInputType.multiline, + decoration: InputDecoration( + hintText: "Data Pengiriman...", + hintStyle: const TextStyle(color: Colors.grey), + filled: true, + fillColor: Colors.grey.shade100, + contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: BorderSide(color: Colors.grey.shade400), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: const BorderSide(color: Colors.blue, width: 1.8), + ), + ), +) + + ), + + const SizedBox(height: 10), + + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + TextButton( + onPressed: () async { + final clipboardData = await Clipboard.getData(Clipboard.kTextPlain); + if (clipboardData?.text != null && clipboardData!.text!.isNotEmpty) { + setState(() { + _controller.text = clipboardData.text!; + _controller.selection = TextSelection.fromPosition( + TextPosition(offset: _controller.text.length), + ); + }); + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text("Clipboard kosong")), + ); + } + }, + style: TextButton.styleFrom( + foregroundColor: Colors.green, + textStyle: const TextStyle(fontSize: 12), + ), + child: const Text("Tempel"), +), + + + + // 🔘 Tombol Hapus + TextButton( + onPressed: () { + _controller.clear(); // menghapus isi TextField + }, + style: TextButton.styleFrom( + foregroundColor: Colors.redAccent, + textStyle: const TextStyle(fontSize: 12), + ), + child: const Text("Hapus"), + ), + const SizedBox(width: 8), + + TextButton( + onPressed: _collapseToBubble, + style: TextButton.styleFrom( + foregroundColor: const Color.fromARGB(255, 57, 57, 57), + textStyle: const TextStyle(fontSize: 12), + ), + child: const Text("Batal"), + ), + const SizedBox(width: 8), + + ElevatedButton( + onPressed: () { + debugPrint("Input terkirim: ${_controller.text}"); + _collapseToBubble(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: Colors.blueAccent, + padding: + const EdgeInsets.symmetric(horizontal: 22, vertical: 12), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(14), + ), + ), + child: const Text( + "Simpan", + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ), + ); +} + + + + // ✅ Saat bubble diklik, ubah tampilan jadi kotak input besar + Future _expandToInput() async { + await BubbleService().resize(360, 260, animated: true); + await Future.delayed(const Duration(milliseconds: 200)); // biar sempat apply + + setState(() => _showInput = true); + } + + + // ✅ Saat menekan "Batal" atau "Kirim", kembalikan ke bubble kecil + Future _collapseToBubble() async { + setState(() => _showInput = false); + await BubbleService().resize(100, 100, animated: true); + } +} + + + + + +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + + WidgetsFlutterBinding.ensureInitialized(); // 🟢 tambahkan ini + + // 🟢 inisialisasi locale "id_ID" untuk format tanggal Indonesia + await initializeDateFormatting('id_ID', null); + Get.put(InternetController()); + runApp(const MyApp()); + + AppLifecycleListener( + onDetach: () async { + await BubbleService().hide(); + }, + ); +} + + + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State with WidgetsBindingObserver { + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) async { + if (state == AppLifecycleState.detached) { + await BubbleService().hide(); // bubble hilang hanya saat app ditutup + } + } + + @override + Widget build(BuildContext context) { + return GetMaterialApp( + debugShowCheckedModeBanner: false, + title: 'Praresi', + initialRoute: AppRoutes.splash, + getPages: AppPages.routes, + ); + } +} + + diff --git a/praresi/lib/overlays/bubble_entry.dart b/praresi/lib/overlays/bubble_entry.dart new file mode 100644 index 0000000..4f9299a --- /dev/null +++ b/praresi/lib/overlays/bubble_entry.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +// import 'package:flutter_overlay_window/flutter_overlay_window.dart'; + +@pragma("vm:entry-point") +void overlayMain() { + runApp(const MaterialApp( + debugShowCheckedModeBanner: false, + home: OverlayBubble(), + )); +} + +class OverlayBubble extends StatefulWidget { + const OverlayBubble({super.key}); + + @override + State createState() => _OverlayBubbleState(); +} + +class _OverlayBubbleState extends State { + bool expanded = false; + final TextEditingController controller = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Material( + color: Colors.transparent, + child: Stack( + children: [ + if (expanded) + Positioned( + right: 80, + bottom: 50, + child: Container( + width: 250, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 8)], + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Salin / Tulis Alamat', + style: TextStyle(fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + TextField( + controller: controller, + maxLines: 3, + decoration: const InputDecoration( + hintText: 'Masukkan alamat di sini...', + border: OutlineInputBorder(), + ), + ), + const SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + TextButton( + onPressed: () => setState(() => expanded = false), + child: const Text('Tutup')), + ElevatedButton( + onPressed: () async { + // await FlutterOverlayWindow.shareData(controller.text); + controller.clear(); + }, + child: const Text('Kirim'), + ), + ], + ) + ], + ), + ), + ), + Positioned( + right: 10, + bottom: 10, + child: GestureDetector( + onTap: () => setState(() => expanded = !expanded), + child: Container( + width: 70, + height: 70, + decoration: const BoxDecoration( + color: Colors.blueAccent, + shape: BoxShape.circle, + boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 8)], + ), + child: const Icon(Icons.message, color: Colors.white, size: 32), + ), + ), + ) + ], + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/overlays/bubble_overlay.dart b/praresi/lib/overlays/bubble_overlay.dart new file mode 100644 index 0000000..455ed3b --- /dev/null +++ b/praresi/lib/overlays/bubble_overlay.dart @@ -0,0 +1,51 @@ +// // lib/overlays/bubble_overlay.dart +// import 'package:flutter/material.dart'; +// import 'package:flutter_overlay_window_sdk34/flutter_overlay_window_sdk34.dart'; + +// @pragma('vm:entry-point') +// void overlayMain() { +// runApp(const BubbleOverlay()); +// } + +// class BubbleOverlay extends StatelessWidget { +// const BubbleOverlay({super.key}); + +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// debugShowCheckedModeBanner: false, +// home: Scaffold( +// backgroundColor: Colors.transparent, +// body: SafeArea( +// child: Align( +// alignment: Alignment.bottomRight, +// child: GestureDetector( +// onTap: () async { +// // Tutup bubble & buka app utama +// await FlutterOverlayWindow.closeOverlay(); + +// }, +// child: Container( +// margin: const EdgeInsets.all(12), +// decoration: const BoxDecoration( +// color: Colors.blueAccent, +// shape: BoxShape.circle, +// boxShadow: [ +// BoxShadow( +// color: Colors.black26, +// blurRadius: 6, +// offset: Offset(2, 3), +// ), +// ], +// ), +// width: 70, +// height: 70, +// child: const Icon(Icons.account_balance_wallet_rounded, color: Colors.black, size: 40), +// ), +// ), +// ), +// ), +// ), +// ); +// } +// } diff --git a/praresi/lib/presentation/controllers/analisis_controller.dart b/praresi/lib/presentation/controllers/analisis_controller.dart new file mode 100644 index 0000000..2f1dd4d --- /dev/null +++ b/praresi/lib/presentation/controllers/analisis_controller.dart @@ -0,0 +1,133 @@ +import 'dart:async'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:get/get.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:intl/intl.dart'; + +class AnalisisController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + + var monthlyData = >[].obs; + var topCities = >[].obs; + var selectedMonth = ''.obs; + + StreamSubscription? _listenerRealtime; + + // 🔥 simpan semua data di memory + List>> _allDocs = []; + + @override + void onInit() { + super.onInit(); + selectedMonth.value = DateFormat('MMM').format(DateTime.now()); + _listenRealtimeData(); + } + + @override + void onClose() { + _listenerRealtime?.cancel(); + super.onClose(); + } + + void _listenRealtimeData() { + final user = _auth.currentUser; + if (user == null) return; + + _listenerRealtime = _firestore + .collection('resis') + .where('store_id', isEqualTo: user.uid) + .snapshots() + .listen((snapshot) { + _allDocs = snapshot.docs; + _updateData(); + }); + } + + void _updateData() { + final Map pengirimanPerBulan = {}; + final Map> kotaSummary = {}; + + for (var doc in _allDocs) { + final data = doc.data(); + + if (data['created_at'] == null || data['kota'] == null) continue; + + final createdAt = + (data['created_at'] as Timestamp).toDate().toLocal(); + final month = DateFormat('MMM').format(createdAt); + final kota = data['kota'].toString(); + final total = double.tryParse(data['total'].toString()) ?? 0; + + pengirimanPerBulan.update(month, (v) => v + 1, ifAbsent: () => 1); + + final key = '$month-$kota'; + + if (kotaSummary.containsKey(key)) { + kotaSummary[key]!['transaksi'] += 1; + kotaSummary[key]!['pendapatan'] += total; + } else { + kotaSummary[key] = { + 'month': month, + 'city': kota, + 'transaksi': 1, + 'pendapatan': total, + }; + } + } + + final monthlyList = pengirimanPerBulan.entries.map((e) { + return { + 'month': e.key, + 'pengiriman': e.value, + }; + }).toList() + ..sort((a, b) { + try { + final monthA = a['month']?.toString() ?? ''; + final monthB = b['month']?.toString() ?? ''; + + return DateFormat('MMM') + .parse(monthA) + .month + .compareTo( + DateFormat('MMM').parse(monthB).month, + ); + } catch (_) { + return 0; + } +}); + + + final kotaList = kotaSummary.values + .where((k) => k['month'] == selectedMonth.value) + .toList() + ..sort((a, b) => + (b['pendapatan'] as double).compareTo(a['pendapatan'] as double)); + + monthlyData.assignAll(monthlyList); + +// ✅ Pastikan selectedMonth valid +if (monthlyList.isNotEmpty) { + final months = monthlyList + .map((e) => e['month'] as String) + .toList(); + + if (!months.contains(selectedMonth.value)) { + selectedMonth.value = months.first; + } +} + topCities.assignAll(kotaList.take(10).toList()); + } + + void setSelectedMonth(String month) { + selectedMonth.value = month; + _updateData(); // 🔥 INI YANG PENTING + } + + String formatRupiah(num value) { + final format = NumberFormat.currency( + locale: 'id_ID', symbol: 'Rp ', decimalDigits: 0); + return format.format(value); + } +} diff --git a/praresi/lib/presentation/controllers/auth_controller.dart b/praresi/lib/presentation/controllers/auth_controller.dart new file mode 100644 index 0000000..cd0a9e7 --- /dev/null +++ b/praresi/lib/presentation/controllers/auth_controller.dart @@ -0,0 +1,242 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:get/get.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; + +class AuthController extends GetxController { + final FirebaseAuth _auth = FirebaseAuth.instance; + + var isLoading = false.obs; + var user = Rxn(); + + @override + void onInit() { + super.onInit(); + user.bindStream(_auth.authStateChanges()); // listen login/logout + } + + // LOGIN + Future login(String email, String password) async { + try { + isLoading.value = true; + + await _auth.signInWithEmailAndPassword( + email: email.trim(), + password: password.trim(), + ); + + Get.snackbar( + "Berhasil", + "Login berhasil", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + Get.offAllNamed('/home'); + + } on FirebaseAuthException catch (e) { + + String message; + + switch (e.code) { + case 'channel-error': + message = 'Email dan password wajib diisi.'; + break; + + case 'invalid-credential': + message = 'Email atau password salah.'; + break; + + default: + message = 'Login gagal. Silakan coba lagi.'; + } + + Get.snackbar( + "Login Gagal", + message, + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + } catch (e) { + Get.snackbar( + "Error", + "Terjadi kesalahan sistem.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + } finally { + isLoading.value = false; + } + } + + + // REGISTER + Future register(String name, String email, String password) async { + try { + isLoading.value = true; + + await _auth.createUserWithEmailAndPassword( + email: email.trim(), + password: password.trim(), + ).then((userCredential) async { + + await FirebaseFirestore.instance + .collection('users') + .doc(userCredential.user!.uid) + .set({ + "name": name.trim(), + "email": email.trim(), + "createdAt": DateTime.now(), + }); + + }); + + Get.snackbar( + "Berhasil", + "Registrasi berhasil", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + Get.offAllNamed('/home'); + + } on FirebaseAuthException catch (e) { + + String message; + + switch (e.code) { + case 'channel-error': + message = 'Semua field wajib diisi.'; + break; + + case 'invalid-email': + message = 'Format email tidak valid.'; + break; + + case 'email-already-in-use': + message = 'Email sudah terdaftar.'; + break; + + case 'weak-password': + message = 'Password minimal 6 karakter.'; + break; + + case 'network-request-failed': + message = 'Tidak ada koneksi internet.'; + break; + + default: + message = 'Registrasi gagal. Silakan coba lagi.'; + } + + Get.snackbar( + "Registrasi Gagal", + message, + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + } catch (e) { + + Get.snackbar( + "Error", + "Terjadi kesalahan sistem.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + } finally { + isLoading.value = false; + } + } + + + // RESET PASSWORD +Future resetPassword(String email) async { + try { + + // ========================== + // VALIDASI LOCAL + // ========================== + if (email.trim().isEmpty) { + Get.snackbar( + "Reset Password Gagal", + "Email wajib diisi.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + if (!GetUtils.isEmail(email.trim())) { + Get.snackbar( + "Reset Password Gagal", + "Format email tidak valid.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + // ========================== + // KIRIM RESET EMAIL + // ========================== + await _auth.sendPasswordResetEmail(email: email.trim()); + + Get.snackbar( + "Berhasil", + "Jika email terdaftar, link reset password telah dikirim.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + + } on FirebaseAuthException catch (e) { + + String message; + + switch (e.code) { + case 'user-not-found': + // Demi keamanan, sebaiknya jangan terlalu detail + message = "Jika email terdaftar, link reset password telah dikirim."; + break; + + case 'invalid-email': + message = "Format email tidak valid."; + break; + + case 'network-request-failed': + message = "Tidak ada koneksi internet."; + break; + + default: + message = "Gagal mengirim email reset."; + } + + Get.snackbar( + "Reset Password", + message, + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + } +} + + + // LOGOUT + Future logout() async { + await _auth.signOut(); + Get.offAllNamed('/login'); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/controllers/change_password_controller.dart b/praresi/lib/presentation/controllers/change_password_controller.dart new file mode 100644 index 0000000..f4ba5b8 --- /dev/null +++ b/praresi/lib/presentation/controllers/change_password_controller.dart @@ -0,0 +1,75 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class ChangePasswordController extends GetxController { + var isLoading = false.obs; + + Future changePassword({ + required String currentPassword, + required String newPassword, +}) async { + try { + isLoading.value = true; + + final user = FirebaseAuth.instance.currentUser!; + + final cred = EmailAuthProvider.credential( + email: user.email!, + password: currentPassword, + ); + + // ✅ Re-authenticate + await user.reauthenticateWithCredential(cred); + + // ✅ Update Password + await user.updatePassword(newPassword); + + Get.snackbar( + "Berhasil", + "Kata sandi berhasil diperbarui", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + icon: const Icon(Icons.check_circle, color: Colors.green), + ); + } on FirebaseAuthException catch (e) { + String message = "Terjadi kesalahan"; + + // ✅ HANDLE ERROR FIREBASE + switch (e.code) { + case 'wrong-password': + case 'invalid-credential': + message = "Password lama tidak sesuai"; + break; + + case 'weak-password': + message = "Password terlalu lemah (minimal 6 karakter)"; + break; + + case 'requires-recent-login': + message = "Silakan login ulang terlebih dahulu"; + break; + + default: + message = e.message ?? "Gagal memperbarui kata sandi"; + } + + Get.snackbar( + "Error", + message, + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + icon: const Icon(Icons.error, color: Colors.red), + ); + } finally { + isLoading.value = false; + } +} + +} \ No newline at end of file diff --git a/praresi/lib/presentation/controllers/home_controller.dart b/praresi/lib/presentation/controllers/home_controller.dart new file mode 100644 index 0000000..c2aa668 --- /dev/null +++ b/praresi/lib/presentation/controllers/home_controller.dart @@ -0,0 +1,131 @@ +import 'dart:async'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:get/get.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:intl/intl.dart'; +import 'package:fl_chart/fl_chart.dart'; + +class DashboardController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + + var totalPendapatan = 0.0.obs; + var totalPendapatanCOD = 0.0.obs; + var totalPendapatanNonCOD = 0.0.obs; + + var totalPaket = 0.obs; + var totalPaketCOD = 0.obs; + var totalPaketNonCOD = 0.obs; + + var isLoading = false.obs; + var grafikPengiriman = [].obs; + + StreamSubscription? _listenerRealtime; + + @override + void onInit() { + super.onInit(); + _listenRealtimeData(); + } + + @override + void onClose() { + _listenerRealtime?.cancel(); + super.onClose(); + } + + /// 🔁 Listener realtime dashboard & grafik + void _listenRealtimeData() { + final user = _auth.currentUser; + if (user == null) return; + final userId = user.uid; + + // Pastikan urut berdasarkan waktu dibuat + _listenerRealtime = _firestore + .collection('resis') + .where('store_id', isEqualTo: userId) + .orderBy('created_at', descending: false) + .snapshots() + .listen((snapshot) { + _updateDashboard(snapshot.docs); + }, onError: (e) { + print("🔥 Error listen data: $e"); + }); + } + + /// 🔹 Hitung ulang total dan grafik setiap ada perubahan data + void _updateDashboard(List>> docs) { + final now = DateTime.now(); + final cutoff = now.subtract(const Duration(days: 6)); + + double total = 0; + double totalCod = 0; + double totalNonCod = 0; + int paket = 0; + int paketCod = 0; + int paketNonCod = 0; + Map pengirimanPerTanggal = {}; + + for (var doc in docs) { + final data = doc.data(); + if (data['created_at'] == null) continue; + + final createdAt = (data['created_at'] as Timestamp).toDate().toLocal(); + final tanggalKey = DateFormat('yyyy-MM-dd').format(createdAt); + + // Total untuk hari ini + if (createdAt.year == now.year && + createdAt.month == now.month && + createdAt.day == now.day) { + final totalTransaksi = double.tryParse(data['total'].toString()) ?? 0; + final pembayaran = data['pembayaran']?.toString().toUpperCase() ?? ''; + + total += totalTransaksi; + paket++; + + if (pembayaran == 'COD') { + paketCod++; + totalCod += totalTransaksi; + } else { + paketNonCod++; + totalNonCod += totalTransaksi; + } + } + + // Total pengiriman 7 hari terakhir + if (!(createdAt.isBefore(cutoff) || createdAt.isAfter(now))) { + pengirimanPerTanggal.update(tanggalKey, (v) => v + 1, + ifAbsent: () => 1); + } + } + + // 🔸 Update data observabel + totalPendapatan.value = total; + totalPendapatanCOD.value = totalCod; + totalPendapatanNonCOD.value = totalNonCod; + totalPaket.value = paket; + totalPaketCOD.value = paketCod; + totalPaketNonCOD.value = paketNonCod; + + // 🔹 Buat data untuk 7 hari grafik + final List newSpots = []; + for (int i = 0; i < 7; i++) { + final date = cutoff.add(Duration(days: i)); + final key = DateFormat('yyyy-MM-dd').format(date); + final jumlah = pengirimanPerTanggal[key] ?? 0; + newSpots.add(FlSpot(i.toDouble(), jumlah.toDouble())); + } + + // 🔸 Assign dan refresh supaya UI update langsung + grafikPengiriman.assignAll(newSpots); + grafikPengiriman.refresh(); + + print("📊 Dashboard & grafik diperbarui realtime (${DateTime.now()})"); + } + + String formatRupiah(double value) { + final format = + NumberFormat.currency(locale: 'id_ID', symbol: 'Rp ', decimalDigits: 0); + return format.format(value); + } +} diff --git a/praresi/lib/presentation/controllers/internet_controller.dart b/praresi/lib/presentation/controllers/internet_controller.dart new file mode 100644 index 0000000..a05a3b0 --- /dev/null +++ b/praresi/lib/presentation/controllers/internet_controller.dart @@ -0,0 +1,64 @@ +import 'package:get/get.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:flutter/material.dart'; + +class InternetController extends GetxController { + + var isOnline = true.obs; + bool lastStatus = true; + + final Connectivity _connectivity = Connectivity(); + + @override + void onInit() { + super.onInit(); + checkConnection(); + + _connectivity.onConnectivityChanged.listen((results) { + updateConnection(results); + }); + } + + Future checkConnection() async { + final results = await _connectivity.checkConnectivity(); + updateConnection(results); + } + + void updateConnection(List results) { + + bool currentStatus = !results.contains(ConnectivityResult.none); + + if (currentStatus != lastStatus) { + + if (!currentStatus) { + + isOnline.value = false; + + Get.snackbar( + "Tidak ada internet", + "Periksa koneksi internet Anda", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.red, + colorText: Colors.white, + duration: const Duration(seconds: 3), + ); + + } else { + + isOnline.value = true; + + Get.snackbar( + "Koneksi kembali", + "Internet sudah tersambung", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.green, + colorText: Colors.white, + duration: const Duration(seconds: 3), + ); + + } + + lastStatus = currentStatus; + } + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/controllers/pelanggan_controller.dart b/praresi/lib/presentation/controllers/pelanggan_controller.dart new file mode 100644 index 0000000..8ba1348 --- /dev/null +++ b/praresi/lib/presentation/controllers/pelanggan_controller.dart @@ -0,0 +1,76 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:get/get.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class PelangganController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + + var isLoading = true.obs; + var pelangganList = >[].obs; + var totalPelanggan = 0.obs; + + @override + void onInit() { + super.onInit(); + fetchAllPelanggan(); + } + + /// Ambil data pelanggan berdasarkan user yang login + Future fetchAllPelanggan() async { + try { + isLoading.value = true; + + final user = _auth.currentUser; + if (user == null) { + Get.snackbar("Error", "User belum login"); + return; + } + + final userId = user.uid; + + // Ambil semua resi yang dibuat oleh user yang login + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: userId) + .get(); + + // Mengelompokkan data berdasarkan nama penerima + final Map> pelangganMap = {}; + + for (var doc in snapshot.docs) { + final data = doc.data(); + + final nama = (data['penerima'] ?? '').toString(); + if (nama.isEmpty) continue; + + if (!pelangganMap.containsKey(nama)) { + pelangganMap[nama] = { + 'penerima': nama, + 'no_wa': data['no_wa'] ?? '-', + 'alamat': data['alamat'] ?? '-', + 'kota': data['kota'] ?? '-', + 'provinsi': data['provinsi'] ?? '-', + 'barang': data['barang'] ?? '-', // 🔹 Ganti totalTransaksi → barang + 'totalNominal': + double.tryParse(data['total']?.toString() ?? '0') ?? 0.0, + 'created_at': (data['created_at'] is Timestamp) + ? (data['created_at'] as Timestamp).toDate() + : DateTime.now(), // 🔹 Tambahan untuk tanggal pembuatan + }; + } else { + // Jika nama pelanggan sama, tambahkan nominal tapi barang tidak berubah + pelangganMap[nama]!['totalNominal'] += + double.tryParse(data['total']?.toString() ?? '0') ?? 0.0; + } + } + + pelangganList.assignAll(pelangganMap.values.toList()); + totalPelanggan.value = pelangganList.length; + } catch (e) { + Get.snackbar("Error", "Gagal memuat data pelanggan: $e"); + } finally { + isLoading.value = false; + } + } +} diff --git a/praresi/lib/presentation/controllers/profile_controller.dart b/praresi/lib/presentation/controllers/profile_controller.dart new file mode 100644 index 0000000..a154a6e --- /dev/null +++ b/praresi/lib/presentation/controllers/profile_controller.dart @@ -0,0 +1,93 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class ProfileController extends GetxController { + final FirebaseAuth _auth = FirebaseAuth.instance; + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + + var name = ''.obs; + var email = ''.obs; + var isLoading = true.obs; + + @override + void onInit() { + super.onInit(); + loadProfile(); + } + + Future loadProfile() async { + try { + isLoading.value = true; + final user = _auth.currentUser; + if (user != null) { + email.value = user.email ?? ""; + + final doc = + await _firestore.collection('users').doc(user.uid).get(); + + if (doc.exists) { + name.value = doc.data()?['name'] ?? ""; + } + } + } catch (e) { + Get.snackbar("Error", "Gagal memuat profil: $e"); + } finally { + isLoading.value = false; + } + } + +Future updateName() async { + try { + final user = _auth.currentUser; + if (user == null) return; + + /// ✅ VALIDASI NAMA + if (name.value.trim().isEmpty) { + Get.snackbar( + "Peringatan", + "Nama tidak boleh kosong", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + duration: const Duration(seconds: 2), + ); + return; + } + + await _firestore + .collection('users') + .doc(user.uid) + .update({ + "name": name.value.trim(), + }); + + Get.snackbar( + "Berhasil", + "Nama pengguna berhasil diperbarui", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + duration: const Duration(seconds: 2), + ); + + } catch (e) { + Get.snackbar( + "Error", + "Gagal memperbarui nama", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + duration: const Duration(seconds: 2), + ); + } +} + +} diff --git a/praresi/lib/presentation/controllers/resi_controller.dart b/praresi/lib/presentation/controllers/resi_controller.dart new file mode 100644 index 0000000..f142394 --- /dev/null +++ b/praresi/lib/presentation/controllers/resi_controller.dart @@ -0,0 +1,505 @@ +import 'dart:convert'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart' show rootBundle; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/internet_controller.dart'; + +class ResiController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + List> _wilayahData = []; + + var isSaving = false.obs; // ✅ loading save + + @override + void onInit() { + super.onInit(); + _loadWilayahData(); + } + + /// 🔹 Muat data provinsi & kota dari JSON lokal + Future _loadWilayahData() async { + try { + final String jsonString = await rootBundle.loadString('assets/data/regions.json'); + final List jsonData = jsonDecode(jsonString); + _wilayahData = jsonData.cast>(); + } catch (e) { + debugPrint("Gagal memuat data wilayah: $e"); + } + } + + /// 🔹 Deteksi provinsi & kota dari alamat (prioritaskan akhir alamat + fuzzy + aman) +// Map _extractWilayah(String alamat) { +// if (alamat.isEmpty || _wilayahData.isEmpty) { +// return {'kota': null, 'provinsi': null}; +// } + +// String alamatLower = alamat.toLowerCase(); +// String? provinsi; +// String? kota; +// double bestScore = 0.0; + +// // Ambil 4 kata terakhir, karena umumnya di situ ada kota/provinsi +// List alamatWords = alamatLower.split(RegExp(r'\s+')); +// String lastPart = alamatWords.length > 4 +// ? alamatWords.sublist(alamatWords.length - 4).join(' ') +// : alamatLower; + +// for (var data in _wilayahData) { +// if (data['provinsi'] == null || data['kota'] == null) continue; + +// final String prov = data['provinsi'].toString(); +// final List kotaList = List.from(data['kota']); +// final String provLower = prov.toLowerCase(); + +// // 🔹 Deteksi provinsi langsung atau pakai fuzzy matching +// if (lastPart.contains(provLower)) { +// provinsi = prov; +// } else if (_similarity(lastPart, provLower) > 0.7) { +// provinsi = prov; +// } else { +// // Cek singkatan umum provinsi +// if (provLower.contains('jawa timur') && lastPart.contains('jatim')) provinsi = prov; +// if (provLower.contains('jawa tengah') && lastPart.contains('jateng')) provinsi = prov; +// if (provLower.contains('jawa barat') && lastPart.contains('jabar')) provinsi = prov; +// if (provLower.contains('daerah istimewa yogyakarta') && lastPart.contains('diy')) provinsi = prov; +// } + +// // 🔹 Deteksi kota +// for (var k in kotaList) { +// if (k == null) continue; +// final String kotaNama = k.toString(); +// final String kotaLower = kotaNama.toLowerCase(); +// final String kotaBersih = kotaLower.replaceAll(RegExp(r'^(kab\.?|kota)\s*'), '').trim(); + +// // Hindari error: pastikan index valid +// int indexKota = alamatLower.contains(kotaBersih) +// ? alamatLower.lastIndexOf(kotaBersih) +// : -1; + +// // Semakin ke akhir alamat, bobot lebih tinggi +// double weight = (indexKota > 0) +// ? (indexKota / alamatLower.length).clamp(0.0, 1.0) +// : 0.0; + +// // Skor kemiripan +// double score; +// if (alamatLower.contains(kotaBersih)) { +// score = 0.9 + weight * 0.1; +// } else { +// score = _similarity(lastPart, kotaBersih) + weight * 0.1; +// } + +// // Simpan hasil terbaik +// if (score > bestScore) { +// bestScore = score; +// kota = kotaNama; +// provinsi ??= prov; +// } +// } +// } + +// return { +// 'kota': kota, +// 'provinsi': provinsi, +// }; +// } + +Map _extractWilayah(String alamat) { + if (alamat.isEmpty || _wilayahData.isEmpty) { + return {'kota': null, 'provinsi': null}; + } + + String alamatLower = alamat.toLowerCase(); + String? provinsi; + String? kota; + + // 🔹 Ambil bagian belakang alamat (lebih akurat) + List words = alamatLower.split(RegExp(r'\s+')); + String lastPart = words.length > 5 + ? words.sublist(words.length - 5).join(' ') + : alamatLower; + + // ============================== + // 🔹 STEP 1: DETEKSI PROVINSI DULU + // ============================== + for (var data in _wilayahData) { + final prov = data['provinsi']?.toString() ?? ''; + final provLower = prov.toLowerCase(); + + if (provLower.isEmpty) continue; + + if (lastPart.contains(provLower) || + _similarity(lastPart, provLower) > 0.7 || + (provLower.contains('jawa timur') && lastPart.contains('jatim')) || + (provLower.contains('jawa tengah') && lastPart.contains('jateng')) || + (provLower.contains('jawa barat') && lastPart.contains('jabar')) || + (provLower.contains('yogyakarta') && lastPart.contains('diy'))) { + provinsi = prov; + break; // 🔥 STOP kalau sudah ketemu + } + } + + // ❌ kalau provinsi tidak ketemu → langsung return + if (provinsi == null) { + return {'kota': null, 'provinsi': null}; + } + + // ============================== +// 🔹 STEP 2: CARI KOTA DALAM PROVINSI TERSEBUT +// ============================== +final provData = _wilayahData.firstWhere( + (e) => e['provinsi'] == provinsi, + orElse: () => {}, +); + +final List kotaList = List.from(provData['kota'] ?? []); + +double bestScore = 0; + +for (var k in kotaList) { + final kotaNama = k.toString(); + final kotaLower = kotaNama.toLowerCase(); + + final kotaBersih = + kotaLower.replaceAll(RegExp(r'^(kab\.?|kota)\s*'), '').trim(); + + double score; + + if (alamatLower.contains(kotaBersih)) { + score = 0.95; + } else { + score = _similarity(lastPart, kotaBersih); + } + + if (score > bestScore) { + bestScore = score; + kota = kotaNama; + } +} + +// 🔥 Tambahan penting di sini +if (bestScore < 0.75) { + kota = null; +} + +return { + 'kota': kota, + 'provinsi': provinsi, +}; +} + +/// 🔹 Fungsi bantu: fuzzy similarity sederhana antar string +double _similarity(String a, String b) { + if (a.isEmpty || b.isEmpty) return 0.0; + + final aWords = a.split(' '); + final bWords = b.split(' '); + int matches = 0; + + for (var aw in aWords) { + for (var bw in bWords) { + if (aw.isNotEmpty && bw.isNotEmpty && aw == bw) matches++; + } + } + + return matches / ((aWords.length + bWords.length) / 2); +} + + /// 🔹 Ekstrak data dari hasil OCR +Map parseResiData(String text, String storeId) { + final lines = text.split('\n').map((e) => e.trim()).where((e) => e.isNotEmpty).toList(); + + final RegExp penerimaExp = RegExp(r'Penerima\s*:\s*(.*)', caseSensitive: false); + final RegExp alamatExp = RegExp(r'Alamat\s*:\s*(.*)', caseSensitive: false); + final RegExp waExp = RegExp(r'(No\.?\s*Wa|Nomor\s*Wa|WA)\s*:\s*(.*)', caseSensitive: false); + final RegExp barangExp = RegExp(r'Barang\s*:\s*(.*)', caseSensitive: false); + final RegExp totalExp = RegExp(r'Total\s*:\s*([0-9.,]+)', caseSensitive: false); + final RegExp pembayaranExp = RegExp(r'(COD|Non\s*COD)', caseSensitive: false); + + String penerima = ''; + String alamat = ''; + String noWa = ''; + String barang = ''; + String total = ''; + String pembayaran = ''; + + bool inAlamatSection = false; + + for (int i = 0; i < lines.length; i++) { + final line = lines[i]; + + if (penerimaExp.hasMatch(line)) { + penerima = penerimaExp.firstMatch(line)?.group(1)?.trim() ?? ''; + } + else if (alamatExp.hasMatch(line)) { + // mulai tangkap alamat + alamat = alamatExp.firstMatch(line)?.group(1)?.trim() ?? ''; + inAlamatSection = true; + continue; + } + else if (waExp.hasMatch(line)) { + inAlamatSection = false; + noWa = waExp.firstMatch(line)?.group(2)?.trim() ?? ''; + } + else if (barangExp.hasMatch(line)) { + inAlamatSection = false; + barang = barangExp.firstMatch(line)?.group(1)?.trim() ?? ''; + } + else if (totalExp.hasMatch(line)) { + inAlamatSection = false; + total = totalExp.firstMatch(line)?.group(1)?.trim() ?? ''; + total = total.replaceAll(RegExp(r'[^\d]'), ''); + } + else if (pembayaranExp.hasMatch(line)) { + inAlamatSection = false; + pembayaran = pembayaranExp.firstMatch(line)?.group(1)?.trim().toUpperCase() ?? ''; + if (pembayaran.contains('NON')) { + pembayaran = 'NON COD'; + } else { + pembayaran = 'COD'; + } + } + else if (inAlamatSection) { + // gabungkan baris tambahan alamat + if (line.isNotEmpty && !line.contains(':')) { + alamat += ' $line'; + } + } + } + + // 🔍 Ekstrak kota & provinsi dari alamat lengkap + final wilayah = _extractWilayah(alamat); + + return { + 'store_id': storeId, + 'penerima': penerima, + 'alamat': alamat, + 'no_wa': noWa, + 'barang': barang, + 'total': total, + 'pembayaran': pembayaran, + 'kota': wilayah['kota'], + 'provinsi': wilayah['provinsi'], + 'created_at': FieldValue.serverTimestamp(), + }; +} + +/// 🔹 Simpan hasil OCR ke Firestore +Future saveResi(String ocrText, String userId) async { + try { + final storeRef = + await _firestore.collection('stores').doc(userId).get(); + + // 🔹 Cek apakah user punya toko + if (!storeRef.exists) { + Get.snackbar( + 'Gagal Menyimpan', + 'Kamu belum memiliki data toko.\nSilakan isi data toko terlebih dahulu.', + backgroundColor: const Color(0xFFFF9800), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + return; + } + + final storeId = storeRef.id; + + // 🔹 Parsing hasil OCR + final data = parseResiData(ocrText, storeId); + + // 🔹 Validasi field utama + List missing = []; + + if (data['penerima'].toString().isEmpty) missing.add('Penerima'); + if (data['alamat'].toString().isEmpty) missing.add('Alamat'); + if (data['no_wa'].toString().isEmpty) missing.add('No. WA'); + if (data['barang'].toString().isEmpty) missing.add('Barang'); + if (data['total'].toString().isEmpty) missing.add('Total'); + if (data['pembayaran'].toString().isEmpty) missing.add('Pembayaran'); + + if (missing.isNotEmpty) { + Get.snackbar( + 'Gagal Menyimpan', + 'Field berikut kosong:\n${missing.join(', ')}', + backgroundColor: const Color(0xFFFF9800), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + return; + } + + // 🔥 VALIDASI WILAYAH (INI YANG KAMU BUTUHKAN) + if (data['provinsi'] == null || + data['provinsi'].toString().isEmpty) { + Get.snackbar( + 'Gagal Menyimpan', + 'Provinsi tidak terdeteksi dari alamat!', + backgroundColor: const Color(0xFFFF9800), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + return; + } + + if (data['kota'] == null || + data['kota'].toString().isEmpty) { + Get.snackbar( + 'Gagal Menyimpan', + 'Kota/Kabupaten tidak terdeteksi!', + backgroundColor: const Color(0xFFFF9800), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + return; + } + + // 🔹 Simpan ke Firestore + await _firestore.collection('resis').add(data); + + Get.snackbar( + 'Berhasil', + 'Data resi berhasil disimpan!', + backgroundColor: const Color(0xFF4CAF50), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + } catch (e) { + Get.snackbar( + 'Error', + 'Gagal menyimpan data: $e', + backgroundColor: const Color(0xFFF44336), + colorText: Colors.white, + snackPosition: SnackPosition.BOTTOM, + ); + } +} + +// Future saveResi(String ocrText, String userId) async { + +// /// ✅ cegah double klik +// if (isSaving.value) return; + +// /// ✅ CEK INTERNET GLOBAL +// final internet = Get.find(); + +// if (!internet.isConnected.value) { +// Get.snackbar( +// 'Offline', +// 'Tidak dapat menyimpan tanpa koneksi internet.', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// try { +// isSaving.value = true; + +// final storeRef = +// await _firestore.collection('stores').doc(userId).get(); + +// if (!storeRef.exists) { +// Get.snackbar( +// 'Gagal Menyimpan', +// 'Kamu belum memiliki data toko.\nSilakan isi data toko terlebih dahulu.', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// final storeId = storeRef.id; +// final data = parseResiData(ocrText, storeId); + +// /// =============================== +// /// VALIDASI FIELD OCR +// /// =============================== +// List missing = []; + +// if (data['penerima'].toString().trim().isEmpty) +// missing.add('Penerima'); +// if (data['alamat'].toString().trim().isEmpty) +// missing.add('Alamat'); +// if (data['no_wa'].toString().trim().isEmpty) +// missing.add('No. WA'); +// if (data['barang'].toString().trim().isEmpty) +// missing.add('Barang'); +// if (data['total'].toString().trim().isEmpty) +// missing.add('Total'); +// if (data['pembayaran'].toString().trim().isEmpty) +// missing.add('Pembayaran'); + +// if (missing.isNotEmpty) { +// Get.snackbar( +// 'Gagal Menyimpan', +// 'Field berikut kosong:\n${missing.join(', ')}', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// /// =============================== +// /// ✅ ANTI DUPLICATE FIRESTORE +// /// =============================== + +// /// buat document id unik dari data resi +// final docId = +// "${data['no_wa']}_${data['total']}_${data['penerima']}"; + +// await _firestore +// .collection('resis') +// .doc(docId) +// .set(data); // ✅ BUKAN add() + +// Get.snackbar( +// 'Berhasil', +// 'Data resi berhasil disimpan!', +// backgroundColor: const Color(0xFF4CAF50), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); + +// } on FirebaseException catch (e) { + +// /// ✅ HANDLE INTERNET PUTUS TENGAH JALAN +// if (e.code == 'network-request-failed') { +// Get.snackbar( +// 'Koneksi Terputus', +// 'Internet tidak stabil.', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// } else { +// Get.snackbar( +// 'Error Firebase', +// e.message ?? 'Terjadi kesalahan.', +// backgroundColor: const Color(0xFFF44336), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// } + +// } catch (e) { + +// Get.snackbar( +// 'Error', +// 'Gagal menyimpan data.', +// backgroundColor: const Color(0xFFF44336), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); + +// } finally { + +// /// ✅ aktifkan button kembali +// isSaving.value = false; +// } +// } + +} \ No newline at end of file diff --git a/praresi/lib/presentation/controllers/riwayat_bulanan_controller.dart b/praresi/lib/presentation/controllers/riwayat_bulanan_controller.dart new file mode 100644 index 0000000..4990fdb --- /dev/null +++ b/praresi/lib/presentation/controllers/riwayat_bulanan_controller.dart @@ -0,0 +1,163 @@ +import 'package:get/get.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:intl/intl.dart'; + +class RiwayatBulananController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + + var isLoading = false.obs; + var monthlySummary = >[].obs; + + @override + void onInit() { + super.onInit(); + fetchMonthlySummary(); + } + + /// 🔹 Ambil ringkasan resi per bulan + Future fetchMonthlySummary() async { + try { + isLoading.value = true; + monthlySummary.clear(); + + final user = _auth.currentUser; + if (user == null) return; + final userId = user.uid; + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: userId) + .get(); + + // 🔸 Kelompokkan data berdasarkan bulan & tahun + Map> grouped = {}; + + for (var doc in snapshot.docs) { + final data = doc.data(); + if (data['created_at'] == null) continue; + + final createdAt = (data['created_at'] as Timestamp).toDate(); + final monthKey = DateFormat('MMMM yyyy', 'id_ID').format(createdAt); + + final pembayaran = (data['pembayaran'] ?? '').toString().toUpperCase(); + final total = double.tryParse(data['total'].toString()) ?? 0; + + if (!grouped.containsKey(monthKey)) { + grouped[monthKey] = { + 'month': monthKey, + 'rawDate': createdAt, + 'total': 0, + 'cod': 0, + 'nonCod': 0, + 'incomeCod': 0.0, + 'incomeNonCod': 0.0, + }; + } + + grouped[monthKey]!['total'] += 1; + if (pembayaran == 'COD') { + grouped[monthKey]!['cod'] += 1; + grouped[monthKey]!['incomeCod'] += total; + } else { + grouped[monthKey]!['nonCod'] += 1; + grouped[monthKey]!['incomeNonCod'] += total; + } + } + + // 🔸 Konversi ke List dan urutkan dari bulan terbaru + final sorted = grouped.values.toList() + ..sort((a, b) => b['rawDate'].compareTo(a['rawDate'])); + + monthlySummary.assignAll(sorted); + } catch (e) { + print('Error fetchMonthlySummary: $e'); + Get.snackbar('Error', 'Gagal mengambil data: $e'); + monthlySummary.clear(); + } finally { + isLoading.value = false; + } + } + + /// 🔹 Ambil pendapatan per bulan (COD & Non COD) + Future> getPendapatanBulanan(String monthLabel) async { + try { + final user = _auth.currentUser; + if (user == null) return {}; + + final parsedMonth = DateFormat('MMMM yyyy', 'id_ID').parse(monthLabel); + final start = DateTime(parsedMonth.year, parsedMonth.month, 1); + final end = + DateTime(parsedMonth.year, parsedMonth.month + 1, 0, 23, 59, 59); + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: user.uid) + .where('created_at', isGreaterThanOrEqualTo: start) + .where('created_at', isLessThanOrEqualTo: end) + .get(); + + double codIncome = 0; + double nonCodIncome = 0; + + for (var doc in snapshot.docs) { + final data = doc.data(); + final pembayaran = (data['pembayaran'] ?? '').toString().toUpperCase(); + final total = double.tryParse(data['total'].toString()) ?? 0; + + if (pembayaran == 'COD') { + codIncome += total; + } else { + nonCodIncome += total; + } + } + + return { + 'cod': codIncome, + 'nonCod': nonCodIncome, + }; + } catch (e) { + print('Error getPendapatanBulanan: $e'); + return {}; + } + } + + /// 🔹 Ambil semua resi di bulan tertentu + Future>> fetchResiByMonth(String monthLabel) async { + try { + final user = _auth.currentUser; + if (user == null) return []; + + final parsedMonth = DateFormat('MMMM yyyy', 'id_ID').parse(monthLabel); + final start = DateTime(parsedMonth.year, parsedMonth.month, 1); + final end = + DateTime(parsedMonth.year, parsedMonth.month + 1, 0, 23, 59, 59); + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: user.uid) + .where('created_at', isGreaterThanOrEqualTo: start) + .where('created_at', isLessThanOrEqualTo: end) + .orderBy('created_at', descending: true) + .get(); + + return snapshot.docs.map((doc) { + final data = doc.data(); + return { + 'resi_id': doc.id, + 'penerima': data['penerima'] ?? '-', + 'barang': data['barang'] ?? '-', + 'alamat': data['alamat'] ?? '-', + 'pembayaran': data['pembayaran'] ?? '-', + 'no_wa': data['no_wa'] ?? '-', + 'total': data['total'] ?? 0, + 'created_at': data['created_at'], + }; + }).toList(); + } catch (e) { + print('Error fetchResiByMonth: $e'); + return []; + } + } +} diff --git a/praresi/lib/presentation/controllers/riwayat_controller.dart b/praresi/lib/presentation/controllers/riwayat_controller.dart new file mode 100644 index 0000000..3d61666 --- /dev/null +++ b/praresi/lib/presentation/controllers/riwayat_controller.dart @@ -0,0 +1,568 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:intl/intl.dart'; + +class RiwayatController extends GetxController { + final FirebaseFirestore _firestore = FirebaseFirestore.instance; + final FirebaseAuth _auth = FirebaseAuth.instance; + List> _wilayahData = []; + + var monthlySummary = >[].obs; + + var isLoading = false.obs; + var dailySummary = >[].obs; + var dailyDetail = >[].obs; + + /// 🔹 Ambil data ringkasan resi per hari + Future fetchResiData({DateTime? start, DateTime? end}) async { + try { + isLoading.value = true; + final user = _auth.currentUser; + if (user == null) return; + final userId = user.uid; + + final DateTime now = DateTime.now(); + final DateTime startOfMonth = start ?? DateTime(now.year, now.month, 1); + final DateTime endOfMonth = + end ?? DateTime(now.year, now.month + 1, 0, 23, 59, 59); + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: userId) + .where('created_at', isGreaterThanOrEqualTo: startOfMonth) + .where('created_at', isLessThanOrEqualTo: endOfMonth) + .get(); + + final data = snapshot.docs.map((doc) { + final resi = doc.data(); + final createdAt = (resi['created_at'] as Timestamp).toDate(); + final tanggalKey = DateFormat('yyyy-MM-dd').format(createdAt); + + return { + 'id': doc.id, + 'tanggalKey': tanggalKey, + 'tanggalAsli': createdAt, + 'pembayaran': resi['pembayaran'] ?? '', + 'total': int.tryParse(resi['total'].toString()) ?? 0, + }; + }).toList(); + + final Map>> grouped = {}; + for (var item in data) { + grouped.putIfAbsent(item['tanggalKey'], () => []); + grouped[item['tanggalKey']]!.add(item); + } + + final List> summary = []; + grouped.forEach((key, list) { + int total = 0, codCount = 0, nonCodCount = 0, income = 0; + + for (var resi in list) { + total += 1; + final totalValue = num.tryParse(resi['total'].toString()) ?? 0; + income += totalValue.toInt(); + + if (resi['pembayaran'].toString().toUpperCase() == 'COD') { + codCount++; + } else { + nonCodCount++; + } + } + + final date = DateTime.parse(key); + summary.add({ + 'day': DateFormat('EEEE', 'id_ID').format(date), + 'date': DateFormat('d MMMM yyyy', 'id_ID').format(date), + 'total': total, + 'cod': codCount, + 'nonCod': nonCodCount, + 'income': income, + 'rawDate': date, + }); + }); + + summary.sort((a, b) => b['rawDate'].compareTo(a['rawDate'])); + dailySummary.assignAll(summary); + } catch (e) { + print('Error fetching resi data: $e'); + dailySummary.clear(); + } finally { + isLoading.value = false; + } + } + + /// 🔹 Ambil data resi + detail toko berdasarkan tanggal + Future fetchResiByDate(DateTime selectedDate) async { + try { + isLoading.value = true; + final user = _auth.currentUser; + if (user == null) return; + final userId = user.uid; + + final startOfDay = + DateTime(selectedDate.year, selectedDate.month, selectedDate.day); + final endOfDay = + DateTime(selectedDate.year, selectedDate.month, selectedDate.day, 23, 59, 59); + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: userId) + .where('created_at', isGreaterThanOrEqualTo: startOfDay) + .where('created_at', isLessThanOrEqualTo: endOfDay) + .get(); + + // 🔹 Ambil data resi & data toko + List> results = []; + + for (var doc in snapshot.docs) { + final data = doc.data(); + final storeId = data['store_id']; + + // ambil data toko + final storeSnapshot = + await _firestore.collection('stores').doc(storeId).get(); + final storeData = storeSnapshot.data() ?? {}; + + results.add({ + 'id': doc.id, + 'no_resi': data['no_resi'] ?? '-', + 'penerima': data['penerima'] ?? '-', + 'alamat': data['alamat'] ?? '-', + 'kota': data['kota'] ?? '-', + 'provinsi': data['provinsi'] ?? '-', + 'barang': data['barang'] ?? '-', + 'pembayaran': data['pembayaran'] ?? '-', + 'total': data['total'] ?? 0, + 'no_wa': data['no_wa'] ?? '-', + 'created_at': (data['created_at'] as Timestamp).toDate(), + 'store': { + 'namaToko': storeData['namaToko'] ?? '-', + 'alamat': storeData['alamat'] ?? '-', + 'noHp': storeData['noHp'] ?? '-', + 'noRegistrasi': storeData['noRegistrasi'] ?? '-', + 'keterangan': storeData['keterangan'] ?? '-', + } + }); + } + + dailyDetail.assignAll(results); + } catch (e) { + print('Error fetching resi detail: $e'); + dailyDetail.clear(); + } finally { + isLoading.value = false; + } + } + + + /// 🔹 Ambil total pendapatan COD & Non COD per tanggal + Future> getPendapatanHarian(DateTime date) async { + try { + final user = _auth.currentUser; + if (user == null) return {}; + + final startOfDay = DateTime(date.year, date.month, date.day); + final endOfDay = DateTime(date.year, date.month, date.day, 23, 59, 59); + + final snapshot = await _firestore + .collection('resis') + .where('store_id', isEqualTo: user.uid) + .where('created_at', isGreaterThanOrEqualTo: startOfDay) + .where('created_at', isLessThanOrEqualTo: endOfDay) + .get(); + + double codIncome = 0; + double nonCodIncome = 0; + + for (var doc in snapshot.docs) { + final data = doc.data(); + final pembayaran = (data['pembayaran'] ?? '').toString().toUpperCase(); + final total = double.tryParse(data['total'].toString()) ?? 0; + + if (pembayaran == 'COD') { + codIncome += total; + } else { + nonCodIncome += total; + } + } + + return { + 'cod': codIncome, + 'nonCod': nonCodIncome, + }; + } catch (e) { + print('Error getPendapatanHarian: $e'); + return {}; + } + } + + Map _extractWilayah(String alamat) { + if (alamat.isEmpty || _wilayahData.isEmpty) { + return {'kota': null, 'provinsi': null}; + } + + String alamatLower = alamat.toLowerCase(); + String? provinsi; + String? kota; + + // 🔹 Ambil bagian belakang alamat (lebih akurat) + List words = alamatLower.split(RegExp(r'\s+')); + String lastPart = words.length > 5 + ? words.sublist(words.length - 5).join(' ') + : alamatLower; + + // ============================== + // 🔹 STEP 1: DETEKSI PROVINSI DULU + // ============================== + for (var data in _wilayahData) { + final prov = data['provinsi']?.toString() ?? ''; + final provLower = prov.toLowerCase(); + + if (provLower.isEmpty) continue; + + if (lastPart.contains(provLower) || + _similarity(lastPart, provLower) > 0.7 || + (provLower.contains('jawa timur') && lastPart.contains('jatim')) || + (provLower.contains('jawa tengah') && lastPart.contains('jateng')) || + (provLower.contains('jawa barat') && lastPart.contains('jabar')) || + (provLower.contains('yogyakarta') && lastPart.contains('diy'))) { + provinsi = prov; + break; // 🔥 STOP kalau sudah ketemu + } + } + + // ❌ kalau provinsi tidak ketemu → langsung return + if (provinsi == null) { + return {'kota': null, 'provinsi': null}; + } + + // ============================== + // 🔹 STEP 2: CARI KOTA DALAM PROVINSI TERSEBUT + // ============================== + final provData = _wilayahData.firstWhere( + (e) => e['provinsi'] == provinsi, + orElse: () => {}, + ); + + final List kotaList = List.from(provData['kota'] ?? []); + + double bestScore = 0; + + for (var k in kotaList) { + final kotaNama = k.toString(); + final kotaLower = kotaNama.toLowerCase(); + + final kotaBersih = + kotaLower.replaceAll(RegExp(r'^(kab\.?|kota)\s*'), '').trim(); + + double score; + + if (alamatLower.contains(kotaBersih)) { + score = 0.95; + } else { + score = _similarity(lastPart, kotaBersih); + } + + if (score > bestScore) { + bestScore = score; + kota = kotaNama; + } + } + + return { + 'kota': kota, + 'provinsi': provinsi, + }; +} + +double _similarity(String a, String b) { + if (a.isEmpty || b.isEmpty) return 0.0; + + final aWords = a.split(' '); + final bWords = b.split(' '); + int matches = 0; + + for (var aw in aWords) { + for (var bw in bWords) { + if (aw.isNotEmpty && bw.isNotEmpty && aw == bw) matches++; + } + } + + return matches / ((aWords.length + bWords.length) / 2); +} + + /// 🔹 Update data resi berdasarkan ID +Future updateResi(String id, Map updatedData) async { + try { + isLoading.value = true; + + // Pastikan dokumen dengan ID tersebut ada + final docRef = _firestore.collection('resis').doc(id); + final snapshot = await docRef.get(); + + if (!snapshot.exists) { + Get.snackbar( + "Gagal", + "Data resi tidak ditemukan.", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFFFCDD2), + colorText: const Color(0xFFB71C1C), + ); + return; + } + + // 🔹 Update data di Firestore + await docRef.update(updatedData); + + // 🔹 Refresh data setelah update + if (snapshot.data()?['created_at'] != null) { + final tanggal = (snapshot.data()!['created_at'] as Timestamp).toDate(); + await fetchResiByDate(tanggal); + } + + Get.snackbar( + "Berhasil", + "Data resi berhasil diperbarui.", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFC8E6C9), + colorText: const Color(0xFF1B5E20), + ); + } catch (e) { + print("Error update resi: $e"); + Get.snackbar( + "Error", + "Terjadi kesalahan saat memperbarui data.", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFFFCDD2), + colorText: const Color(0xFFB71C1C), + ); + } finally { + isLoading.value = false; + } +} +// Future updateResi(String id, Map updatedData) async { +// try { +// isLoading.value = true; + +// final docRef = _firestore.collection('resis').doc(id); +// final snapshot = await docRef.get(); + +// if (!snapshot.exists) { +// Get.snackbar( +// "Gagal", +// "Data resi tidak ditemukan.", +// snackPosition: SnackPosition.BOTTOM, +// backgroundColor: const Color(0xFFFFCDD2), +// colorText: const Color(0xFFB71C1C), +// ); +// return; +// } + +// final oldData = snapshot.data()!; + +// // ============================== +// // 🔥 VALIDASI FIELD KOSONG +// // ============================== +// bool isEmpty(String? val) => val == null || val.trim().isEmpty; + +// List missing = []; + +// if (isEmpty(updatedData['penerima'])) missing.add('Penerima'); +// if (isEmpty(updatedData['alamat'])) missing.add('Alamat'); +// if (isEmpty(updatedData['no_wa'])) missing.add('No. WA'); +// if (isEmpty(updatedData['barang'])) missing.add('Barang'); +// if (isEmpty(updatedData['total'])) missing.add('Total'); +// if (isEmpty(updatedData['pembayaran'])) missing.add('Pembayaran'); + +// if (missing.isNotEmpty) { +// Get.snackbar( +// 'Gagal Update', +// 'Field berikut kosong:\n${missing.join(', ')}', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// // ============================== +// // 🔥 VALIDASI FORMAT +// // ============================== + +// // No WA minimal 10 digit angka +// String noWa = +// updatedData['no_wa'].toString().replaceAll(RegExp(r'\D'), ''); +// if (noWa.length < 10) { +// Get.snackbar( +// 'Gagal Update', +// 'No. WA tidak valid!', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// // Total harus angka +// String total = +// updatedData['total'].toString().replaceAll(RegExp(r'\D'), ''); +// if (total.isEmpty || int.tryParse(total) == null) { +// Get.snackbar( +// 'Gagal Update', +// 'Total harus berupa angka!', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// // ============================== +// // 🔥 CEK APAKAH ALAMAT DIUBAH +// // ============================== +// final oldAlamat = oldData['alamat'] ?? ''; +// final newAlamat = updatedData['alamat'] ?? ''; +// // ============================== +// // 🔥 SELALU DETEKSI ULANG WILAYAH +// // ============================== +// final alamat = updatedData['alamat'].toString().trim(); + +// final wilayah = _extractWilayah(alamat); + +// // ❗ Kalau gagal detect → TOLAK +// if (wilayah['provinsi'] == null || wilayah['kota'] == null) { +// Get.snackbar( +// 'Gagal Update', +// 'Alamat tidak valid, provinsi/kota tidak terdeteksi!', +// backgroundColor: const Color(0xFFFF9800), +// colorText: Colors.white, +// snackPosition: SnackPosition.BOTTOM, +// ); +// return; +// } + +// // 🔥 SET ULANG +// updatedData['alamat'] = alamat; +// updatedData['kota'] = wilayah['kota']; +// updatedData['provinsi'] = wilayah['provinsi']; + +// // ============================== +// // 🔥 CLEAN DATA +// // ============================== +// updatedData.updateAll((key, value) => value.toString().trim()); + +// debugPrint("FINAL UPDATE DATA: $updatedData"); + +// // ============================== +// // 🔹 UPDATE FIRESTORE +// // ============================== +// await docRef.update(updatedData); + +// // 🔹 Refresh data +// if (snapshot.data()?['created_at'] != null) { +// final tanggal = +// (snapshot.data()!['created_at'] as Timestamp).toDate(); +// await fetchResiByDate(tanggal); +// } + +// Get.snackbar( +// "Berhasil", +// "Data resi berhasil diperbarui.", +// snackPosition: SnackPosition.BOTTOM, +// backgroundColor: const Color(0xFFC8E6C9), +// colorText: const Color(0xFF1B5E20), +// ); +// } catch (e) { +// debugPrint("Error update resi: $e"); + +// Get.snackbar( +// "Error", +// "Terjadi kesalahan saat memperbarui data.", +// snackPosition: SnackPosition.BOTTOM, +// backgroundColor: const Color(0xFFFFCDD2), +// colorText: const Color(0xFFB71C1C), +// ); +// } finally { +// isLoading.value = false; +// } +// } +Future deleteRiwayat(String id) async { + try { + isLoading(true); + + // Hapus dari Firestore + await _firestore.collection('riwayat_bulanan').doc(id).delete(); + + // Hapus juga dari list lokal agar tampilan otomatis ter-update + monthlySummary.removeWhere((item) => item['id'] == id); + + Get.snackbar( + "Berhasil", + "Data berhasil dihapus", + backgroundColor: const Color(0xFFFFCDD2), + snackPosition: SnackPosition.BOTTOM, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal menghapus data: $e", + backgroundColor: const Color(0xFFFFE0B2), + snackPosition: SnackPosition.BOTTOM, + ); + } finally { + isLoading(false); + } + } + +/// 🔹 Hapus data resi berdasarkan ID dokumen +Future deleteResi(String id) async { + try { + isLoading(true); + + // Cek apakah dokumen ada + final docRef = _firestore.collection('resis').doc(id); + final snapshot = await docRef.get(); + + if (!snapshot.exists) { + Get.snackbar( + "Gagal", + "Data tidak ditemukan atau sudah dihapus.", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFFFCDD2), + colorText: const Color(0xFFB71C1C), + ); + return; + } + + // 🔹 Hapus dari Firestore + await docRef.delete(); + + // 🔹 Hapus dari list lokal agar tampilan otomatis update + dailyDetail.removeWhere((item) => item['id'] == id); + dailySummary.removeWhere((item) => item['id'] == id); + + Get.snackbar( + "Berhasil", + "Data berhasil dihapus.", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFFFEBEE), + colorText: const Color(0xFFB71C1C), + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal menghapus data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: const Color(0xFFFFE0B2), + colorText: const Color(0xFFBF360C), + ); + } finally { + isLoading(false); + } +} + + + +} diff --git a/praresi/lib/presentation/controllers/store_controller.dart b/praresi/lib/presentation/controllers/store_controller.dart new file mode 100644 index 0000000..78adc9a --- /dev/null +++ b/praresi/lib/presentation/controllers/store_controller.dart @@ -0,0 +1,52 @@ +import 'package:get/get.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class StoreController extends GetxController { + final namaTokoC = ''.obs; + final noHpC = ''.obs; + final alamatC = ''.obs; + final noRegistrasiC = ''.obs; + final keteranganC = ''.obs; + + var storeData = Rxn>(); + var isLoading = false.obs; + + final uid = FirebaseAuth.instance.currentUser!.uid; + + @override + void onInit() { + super.onInit(); + getStoreData(); + } + + Future getStoreData() async { + isLoading.value = true; + final doc = await FirebaseFirestore.instance.collection('stores').doc(uid).get(); + if (doc.exists) { + storeData.value = doc.data(); + // isi obs supaya textfield terisi + namaTokoC.value = storeData.value?['namaToko'] ?? ''; + noHpC.value = storeData.value?['noHp'] ?? ''; + alamatC.value = storeData.value?['alamat'] ?? ''; + noRegistrasiC.value = storeData.value?['noRegistrasi'] ?? ''; + keteranganC.value = storeData.value?['keterangan'] ?? ''; + } + isLoading.value = false; + } + + Future saveStore() async { + isLoading.value = true; + final data = { + 'namaToko': namaTokoC.value, + 'noHp': noHpC.value, + 'alamat': alamatC.value, + 'noRegistrasi': noRegistrasiC.value, + 'keterangan': keteranganC.value, + 'updatedAt': DateTime.now(), + }; + await FirebaseFirestore.instance.collection('stores').doc(uid).set(data); + storeData.value = data; + isLoading.value = false; + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/routes/app_pages.dart b/praresi/lib/presentation/routes/app_pages.dart new file mode 100644 index 0000000..c9530e6 --- /dev/null +++ b/praresi/lib/presentation/routes/app_pages.dart @@ -0,0 +1,80 @@ +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/auth_controller.dart'; +import 'package:praresi/presentation/controllers/riwayat_controller.dart'; +import 'package:praresi/presentation/views/menu_akun/change_password_view.dart'; +import 'package:praresi/presentation/views/menu_akun/data_pelanggan_view.dart'; +import 'package:praresi/presentation/views/menu_akun/panduan_pengguna_view.dart'; +import 'package:praresi/presentation/views/menu_akun/profile_view.dart'; +import 'package:praresi/presentation/views/menu_akun/riwayat_pengiriman.dart'; +import 'package:praresi/presentation/views/menu_akun/store_view.dart'; +import 'package:praresi/presentation/views/menu_riwayat/detail_riwayat_view.dart'; +import 'package:praresi/presentation/views/splash_view.dart'; +import '../views/login_view.dart'; +import '../views/register_view.dart'; +import '../views/forgot_view.dart'; +import '../views/main_navbar.dart'; // import baru +import 'app_routes.dart'; + + +class AppPages { + static final routes = [ + GetPage( + name: AppRoutes.login, + page: () => LoginView(), + binding: BindingsBuilder(() { + Get.put(AuthController()); + }), + ), + GetPage( + name: AppRoutes.register, + page: () => RegisterView(), + ), + GetPage( + name: AppRoutes.forgot, + page: () => ForgotView(), + ), + GetPage( + name: AppRoutes.home, // gunakan route 'home' untuk MainNavbar + page: () => const MainNavbar(), + ), + GetPage( + name: AppRoutes.store, // gunakan route 'home' untuk MainNavbar + page: () => StoreView(), + ), + GetPage( + name: AppRoutes.splash, + page: () => const SplashView(), + ), + GetPage( + name: AppRoutes.changepassword, + page: () => ChangePasswordView(), + ), + GetPage( + name: AppRoutes.detailRiwayat, + page: () => const DetailRiwayatView(), + binding: BindingsBuilder(() { + Get.put(RiwayatController(), permanent: true); + }), + ), + GetPage( + name: AppRoutes.profile, + page: () => ProfileView(), + ), + GetPage( + name: AppRoutes.datapelanggan, + page: () => DataPelangganView(), + ), + GetPage( + name: AppRoutes.riwayatbulanan, + page: () => RiwayatBulananView(), + ), + + GetPage( + name: AppRoutes.panduanpengguna, + page: () => PanduanPenggunaPage(), + ), + + + + ]; +} \ No newline at end of file diff --git a/praresi/lib/presentation/routes/app_routes.dart b/praresi/lib/presentation/routes/app_routes.dart new file mode 100644 index 0000000..b9af761 --- /dev/null +++ b/praresi/lib/presentation/routes/app_routes.dart @@ -0,0 +1,17 @@ +class AppRoutes { + static const login = '/login'; + static const register = '/register'; + static const forgot = '/forgot'; + static const home = '/home'; + + static const store = '/store'; + static const changepassword = '/changepassword'; + static const splash = '/'; + + static const profile = '/profile'; + static const datapelanggan = '/data_pelanggan'; + static const riwayatbulanan = '/riwayat_Pengiriman'; + static const panduanpengguna = '/panduan_pengguna'; + + static const detailRiwayat = '/detail_riwayat'; +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/akun_view.dart b/praresi/lib/presentation/views/akun_view.dart new file mode 100644 index 0000000..c0c7b9c --- /dev/null +++ b/praresi/lib/presentation/views/akun_view.dart @@ -0,0 +1,254 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:get/get.dart'; + +class AkunView extends StatelessWidget { + const AkunView({super.key}); + + Future?> _getUserData() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return null; + + final doc = await FirebaseFirestore.instance + .collection('users') + .doc(user.uid) + .get(); + + if (doc.exists) { + return doc.data(); + } else { + return {"email": user.email, "name": "Tanpa Nama"}; + } + } + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFFE3F2FD)], // biru → putih + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SafeArea( + child: FutureBuilder?>( + future: _getUserData(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } + + if (!snapshot.hasData) { + return const Center(child: Text("Tidak ada data user")); + } + + final data = snapshot.data!; + final name = data['name'] ?? 'Tanpa Nama'; + final email = data['email'] ?? '-'; + + return SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), + child: Column( + children: [ + // Card profil + Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: Column( + children: [ + const CircleAvatar( + radius: 40, + backgroundColor: Color(0xFF1976D2), + child: Icon(Icons.person, + size: 40, color: Colors.white), + ), + const SizedBox(height: 10), + Text( + name, + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Text( + email, + style: const TextStyle( + fontSize: 16, color: Colors.grey), + ), + ], + ), + ), + + const SizedBox(height: 30), + + // Submenu sebagai button card + _menuButton( + icon: Icons.person, // 👤 ikon profil + title: "Profil", + onTap: () => Get.toNamed('/profile'), + ), + _menuButton( + icon: Icons.storefront, // 🏪 ikon toko + title: "Toko", + onTap: () => Get.toNamed('/store'), + ), + _menuButton( + icon: Icons.people, // 👥 ikon pelanggan + title: "Data Pelanggan", + onTap: () => Get.toNamed('/data_pelanggan'), + ), + + _menuButton( + icon: Icons.history, // 📦 ikon riwayat pengiriman + title: "Riwayat Pengiriman", + onTap: () => Get.toNamed('/riwayat_Pengiriman'), + ), + _menuButton( + icon: Icons.lock, // 🔒 ikon ubah sandi + title: "Ubah Kata Sandi", + onTap: () => Get.toNamed('/changepassword'), + ), + _menuButton( + icon: Icons.help_outline, // ikon untuk petunjuk + title: "Panduan Pengguna", + onTap: () => Get.toNamed('/panduan_pengguna'), + ), + + // _menuButton( + // icon: Icons.settings, + // title: "Pengaturan", + // onTap: () {}, + // ), + // _menuButton( + // icon: Icons.help_outline, + // title: "Bantuan", + // onTap: () {}, + // ), + + const SizedBox(height: 30), + + // Tombol logout + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton.icon( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 3, + ), + onPressed: () async { + final confirm = await showDialog( + context: context, + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + title: const Text("Konfirmasi"), + content: const Text( + "Apakah Anda yakin ingin keluar dari akun?", + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, false), + child: const Text("Tidak"), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red, + ), + onPressed: () => Navigator.pop(context, true), + child: const Text( + "Ya, Keluar", + style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ); + + /// ✅ jika pilih YA + if (confirm == true) { + await FirebaseAuth.instance.signOut(); + Navigator.of(context) + .pushReplacementNamed('/login'); + } + }, + icon: const Icon(Icons.logout, color: Colors.white), + label: const Text( + "Keluar", + style: TextStyle(color: Colors.white), + ), + ), + ), + + ], + ), + ); + }, + ), + ), + ), + ); + } + + // Widget helper untuk button submenu + Widget _menuButton({ + required IconData icon, + required String title, + required VoidCallback onTap, + }) { + return Container( + margin: const EdgeInsets.only(bottom: 15), + child: Material( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + elevation: 3, + child: InkWell( + borderRadius: BorderRadius.circular(15), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + child: Row( + children: [ + Icon(icon, color: const Color(0xFF1976D2)), + const SizedBox(width: 15), + Expanded( + child: Text( + title, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + ), + ), + ), + const Icon(Icons.arrow_forward_ios, size: 16, color: Colors.grey), + ], + ), + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/analisis_view.dart b/praresi/lib/presentation/views/analisis_view.dart new file mode 100644 index 0000000..08dcdca --- /dev/null +++ b/praresi/lib/presentation/views/analisis_view.dart @@ -0,0 +1,296 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:fl_chart/fl_chart.dart'; +import '../controllers/analisis_controller.dart'; + +class AnalisisView extends StatelessWidget { + const AnalisisView({super.key}); + + @override + Widget build(BuildContext context) { + final AnalisisController controller = Get.put(AnalisisController()); + + return Scaffold( + extendBodyBehindAppBar: true, + body: Obx(() { + final monthlyData = controller.monthlyData; + final topCities = controller.topCities; + final selectedMonth = controller.selectedMonth.value; + + return Container( + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFFE3F2FD)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SafeArea( + child: Column( + children: [ + const SizedBox(height: 12), + + // 🔹 Grafik Pengiriman Bulanan + Container( + margin: + const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(18), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 4), + ), + ], + ), + child: Column( + children: [ + Row( + children: const [ + Icon(Icons.bar_chart, color: Color(0xFF1976D2)), + SizedBox(width: 8), + Text( + "Pengiriman Bulanan", + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black87, + fontSize: 16, + ), + ), + ], + ), + const SizedBox(height: 12), + monthlyData.isEmpty + ? const SizedBox( + height: 200, + child: Center( + child: Text( + "Belum ada data pengiriman", + style: TextStyle(color: Colors.black54), + ), + ), + ) + : SizedBox( + height: 220, + child: BarChart( + BarChartData( + alignment: BarChartAlignment.spaceAround, + gridData: FlGridData(show: false), + borderData: FlBorderData(show: false), + titlesData: FlTitlesData( + leftTitles: const AxisTitles( + sideTitles: + SideTitles(showTitles: false), + ), + topTitles: const AxisTitles( + sideTitles: + SideTitles(showTitles: false), + ), + rightTitles: const AxisTitles( + sideTitles: + SideTitles(showTitles: false), + ), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, _) { + final index = value.toInt(); + if (index >= 0 && + index < monthlyData.length) { + return Padding( + padding: + const EdgeInsets.only(top: 6), + child: Text( + monthlyData[index]['month'], + style: const TextStyle( + fontSize: 12, + color: Colors.black87, + fontWeight: FontWeight.w500, + ), + ), + ); + } + return const SizedBox.shrink(); + }, + ), + ), + ), + barGroups: + monthlyData.asMap().entries.map((e) { + final pengiriman = + (e.value['pengiriman'] as num) + .toDouble(); + return BarChartGroupData( + x: e.key, + barRods: [ + BarChartRodData( + toY: pengiriman, + gradient: const LinearGradient( + colors: [ + Color(0xFF1976D2), + Color(0xFF64B5F6), + ], + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + ), + width: 18, + borderRadius: + BorderRadius.circular(6), + ), + ], + ); + }).toList(), + ), + ), + ), + + // 🔹 Tampilkan jumlah di atas batang + if (monthlyData.isNotEmpty) const SizedBox(height: 12), + if (monthlyData.isNotEmpty) + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: monthlyData.map((e) { + return Text( + e['pengiriman'].toString(), + style: const TextStyle( + fontSize: 12, + color: Colors.black54, + fontWeight: FontWeight.w600, + ), + ); + }).toList(), + ), + ], + ), + ), + + // 🔹 Top Kota Tujuan per Bulan + Expanded( + child: Container( + width: double.infinity, + margin: const EdgeInsets.symmetric(horizontal: 16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(18), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 8, + offset: const Offset(0, 3), + ), + ], + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: const [ + Icon(Icons.location_city, + color: Color(0xFF1976D2)), + SizedBox(width: 6), + Text( + "Top 10 Kota Tujuan", + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black87, + fontSize: 16, + ), + ), + ], + ), + // 🔹 Dropdown pilih bulan + DropdownButton( + value: selectedMonth, + items: controller.monthlyData + .map((e) => DropdownMenuItem( + value: e['month'], + child: Text(e['month']), + )) + .toList(), + onChanged: (value) { + if (value != null) { + controller.setSelectedMonth(value); + } + }, + underline: const SizedBox(), + style: const TextStyle( + color: Colors.black87, fontSize: 14), + icon: const Icon(Icons.arrow_drop_down, + color: Color(0xFF1976D2)), + ), + ], + ), + ), + const Divider(height: 1, color: Color(0xFFE0E0E0)), + Expanded( + child: topCities.isEmpty + ? const Center( + child: Text( + "Tidak ada data untuk bulan ini", + style: TextStyle(color: Colors.black54), + ), + ) + : ListView.separated( + padding: const EdgeInsets.symmetric( + horizontal: 12), + itemCount: topCities.length, + separatorBuilder: (_, __) => Divider( + color: Colors.grey.shade200, + height: 1, + ), + itemBuilder: (context, index) { + final city = topCities[index]; + return ListTile( + contentPadding: + const EdgeInsets.symmetric( + horizontal: 8, vertical: 6), + leading: CircleAvatar( + backgroundColor: Colors.blue.shade50, + child: Text( + '${index + 1}', + style: const TextStyle( + color: Color(0xFF1976D2), + fontWeight: FontWeight.bold, + ), + ), + ), + title: Text( + city['city'], + style: const TextStyle( + fontWeight: FontWeight.w600, + fontSize: 14, + ), + ), + subtitle: Text( + "Pengiriman: ${city['transaksi']} kali\nPendapatan: ${controller.formatRupiah(city['pendapatan'])}", + style: const TextStyle(fontSize: 12), + ), + // trailing: const Icon( + // Icons.chevron_right_rounded, + // color: Colors.grey, + // ), + ); + }, + ), + ), + ], + ), + ), + ), + const SizedBox(height: 16), + ], + ), + ), + ); + }), + ); + } +} diff --git a/praresi/lib/presentation/views/forgot_view.dart b/praresi/lib/presentation/views/forgot_view.dart new file mode 100644 index 0000000..08136e3 --- /dev/null +++ b/praresi/lib/presentation/views/forgot_view.dart @@ -0,0 +1,110 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/auth_controller.dart'; + +class ForgotView extends GetView { + ForgotView({super.key}); + + final emailC = TextEditingController(); + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFF42A5F5)], // biru tua → biru muda + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 100), + // Icon atau logo + const Icon(Icons.lock_reset, size: 80, color: Colors.white), + const SizedBox(height: 10), + const Text( + "Lupa Password", + style: TextStyle( + color: Colors.white, + fontSize: 26, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 30), + + // Card form lupa password + Container( + width: size.width * 0.9, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: Column( + children: [ + TextField( + controller: emailC, + decoration: InputDecoration( + labelText: "Email", + prefixIcon: const Icon(Icons.email_outlined), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 3, + ), + onPressed: () => controller.resetPassword(emailC.text), + child: const Text( + "Kirim Reset Link", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.white + ), + ), + ), + ), + ], + ), + ), + + const SizedBox(height: 20), + TextButton( + onPressed: () => Get.back(), + child: const Text( + "Kembali ke Login", + style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/home_view.dart b/praresi/lib/presentation/views/home_view.dart new file mode 100644 index 0000000..ad61327 --- /dev/null +++ b/praresi/lib/presentation/views/home_view.dart @@ -0,0 +1,1046 @@ +import 'dart:math'; +import 'package:flutter/material.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; +import 'package:fl_chart/fl_chart.dart'; +import 'package:intl/intl.dart'; +import 'package:praresi/presentation/controllers/home_controller.dart'; +import 'package:praresi/presentation/controllers/riwayat_controller.dart'; +import 'package:praresi/services/bubble_services.dart'; +import 'package:praresi/utils/pdf_export_daily_a4.dart'; +import 'package:praresi/utils/pdf_export_daily_a4_multi.dart'; +import 'package:praresi/utils/pdf_export_daily_a5.dart'; +import 'package:praresi/utils/pdf_export_daily_a5_multi.dart'; +import 'package:praresi/utils/pdf_export_daily_a6.dart'; + +class HomeView extends StatefulWidget { + const HomeView({super.key}); + + @override + State createState() => _HomeViewState(); +} + +class _HomeViewState extends State with SingleTickerProviderStateMixin { + bool isBubbleActive = false; + String lastName = 'Pengguna'; + String greeting = ''; + IconData timeIcon = Icons.wb_sunny_outlined; + + final DashboardController c = Get.put(DashboardController()); + final riwayatC = Get.put(RiwayatController(), permanent: true); + + + late AnimationController _controller; + late Animation _rotateAnim; + + Future _refreshData() async { + // Matikan dulu listener lama biar tidak dobel + c.onClose(); + // Jalankan ulang listener realtime + c.onInit(); + // Bisa juga muat ulang user data + await _loadUserData(); + + // Delay kecil supaya animasi refresh terasa smooth + await Future.delayed(const Duration(seconds: 1)); + } + + void _showPrintFormatDialog( + BuildContext context, + String day, + String date, + dynamic controller, +) { + Get.bottomSheet( + Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + child: Wrap( + children: [ + const Center( + child: Text( + "Pilih Format Unduh", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 20), + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A4"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Export PDF (1 halaman = 1 data) + final path = await PdfExportDailyA4_onedata.exportDailyToA4_onedata( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A5"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal "25 Oktober 2025" ke DateTime + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Cetak ke PDF format A4 + final path = await PdfExportDailyA5_onedata.exportDailyToA5_onedata( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + // 🔹 FORMAT A6 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A6"), + onTap: () async { + Get.back(); + try { + final parsedDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + await controller.fetchResiByDate(parsedDate); + + final path = await PdfExportDailyA6.exportDailyToA6( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + // 🔹 FORMAT A4 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A4 (Multi)"), + onTap: () async { + Get.back(); + try { + final parsedDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + await controller.fetchResiByDate(parsedDate); + + final path = await PdfExportDailyA4.exportDailyToA4( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + // 🔹 FORMAT A5 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A5 (Multi)"), + onTap: () async { + Get.back(); + try { + final parsedDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + await controller.fetchResiByDate(parsedDate); + + final path = await PdfExportDailyA5.exportDailyToA5( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + + ], + ), + ), + ); +} + + + @override + void initState() { + super.initState(); + _setGreeting(); + _loadUserData(); + + _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 800), + ); + + _rotateAnim = Tween(begin: 0, end: 2 * pi).animate( + CurvedAnimation(parent: _controller, curve: Curves.easeInOut), + ); + } + + void _salinFormat(BuildContext context) { + const formatText = ''' +Penerima : +Alamat : +No. Wa : +Barang : +Total : +Pembayaran : +'''; + + Clipboard.setData(const ClipboardData(text: formatText)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Format pengiriman berhasil disalin!"), + duration: Duration(seconds: 2), + ), + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + void _setGreeting() { + final hour = DateTime.now().hour; + if (hour < 11) { + greeting = 'Selamat Pagi,'; + timeIcon = Icons.wb_twilight; + } else if (hour < 15) { + greeting = 'Selamat Siang,'; + timeIcon = Icons.wb_sunny_outlined; + } else if (hour < 18) { + greeting = 'Selamat Sore,'; + timeIcon = Icons.wb_sunny_sharp; + } else { + greeting = 'Selamat Malam,'; + timeIcon = Icons.bedtime_rounded; + } + } + + Future _loadUserData() async { + final user = FirebaseAuth.instance.currentUser; + if (user == null) return; + try { + final doc = await FirebaseFirestore.instance.collection('users').doc(user.uid).get(); + if (doc.exists) { + final name = (doc.data()?['name'] ?? '').toString().trim(); + if (name.isNotEmpty) { + final parts = name.split(RegExp(r'\s+')); + setState(() { + lastName = parts.isNotEmpty ? parts.last : name; + }); + } + } + } catch (_) {} + } + + void _animateIcon() { + if (_controller.isAnimating) return; + _controller.forward(from: 0); + } + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFFE3F2FD)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SafeArea( + child: RefreshIndicator( + color: const Color(0xFF1976D2), + onRefresh: _refreshData, + child: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 28), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // === CARD SAPAAN === + Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.10), + blurRadius: 10, + offset: const Offset(0, 6), + ), + ], + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + greeting, + style: const TextStyle( + fontSize: 16, + color: Colors.black87, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 4), + Text( + lastName, + style: const TextStyle( + fontSize: 24, + color: Color(0xFF1976D2), + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 8), + const Text( + 'Buat dan cetak alamat pengiriman Anda dengan cepat dan mudah!', + textAlign: TextAlign.justify, + style: TextStyle( + fontSize: 14, + color: Colors.black54, + height: 1.3, + ), + ), + ], + ), + ), + GestureDetector( + onTap: _animateIcon, + child: AnimatedBuilder( + animation: _rotateAnim, + builder: (context, child) { + return Transform.rotate( + angle: _rotateAnim.value, + child: Icon( + timeIcon, + color: const Color(0xFF1976D2), + size: 42, + ), + ); + }, + ), + ), + ], + ), + ), + + const SizedBox(height: 16), + + // === CARD CETAK DAN BUBBLE SEJAJAR === + Row( + children: [ + Expanded( + child: Container( + height: 85, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Center( + child: ElevatedButton.icon( + onPressed: () async { + final now = DateTime.now(); + final day = DateFormat.EEEE('id_ID').format(now); + final date = DateFormat('d MMMM yyyy', 'id_ID').format(now); + + final controller = Get.find(); + + // 🔥 Ambil data hari ini dulu + await controller.fetchResiByDate(now); + + // 🔥 CEK DATA + if (controller.dailyDetail.isEmpty) { + Get.snackbar( + "Tidak Ada Data", + "Belum ada riwayat pengiriman hari ini.", + backgroundColor: Colors.orange.shade100, + colorText: Colors.black, + snackPosition: SnackPosition.BOTTOM, + ); + return; + } + + // ✅ Kalau ada data → lanjut + _showPrintFormatDialog(context, day, date, controller); + }, + icon: const Icon(Icons.download), + label: const Text('Unduh Data Pengiriman'), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + foregroundColor: const Color(0xFF1976D2), + elevation: 0, + ), + ), + + ), + ), + ), + const SizedBox(width: 14), + + Expanded( + child: Container( + height: 85, + padding: const EdgeInsets.symmetric(horizontal: 12), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Center( + child: ElevatedButton.icon( + onPressed: () => _salinFormat(context), + icon: const Icon(Icons.copy), + label: const Text('Salin Format'), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + foregroundColor: const Color(0xFF1976D2), + elevation: 0, + ), + ), + ), + ), + ), + + ], + ), + + const SizedBox(height: 16), + + // === CARD PENDAPATAN HARI INI === + Container( + width: double.infinity, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.10), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + // Bagian kiri: teks + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Pendapatan Hari Ini', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + SizedBox(height: 8), + Text( + "${c.formatRupiah(c.totalPendapatan.value)}", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + ], + ), + + // Bagian kanan: ikon uang + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: const Color(0xFF1976D2), // warna biru border + width: 1, // ketebalan border + ), + ), + child: const Icon( + Icons.attach_money_outlined, + color: Color(0xFF1976D2), + size: 32, + ), + ) + + ], + ), + ), + + + const SizedBox(height: 16), + + // === CARD PENGIRIMAN BESAR === + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.10), + blurRadius: 10, + offset: const Offset(0, 6), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Pengiriman', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + color: Color(0xFF1976D2), + ), + ), + const SizedBox(height: 12), + Row( + children: [ + // KIRI: TOTAL + Expanded( + flex: 2, + child: Container( + height: 150, + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFF1976D2), width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Total', + style: TextStyle( + color: Color(0xFF1976D2), + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + SizedBox(height: 8), + Text( + "${c.totalPaket.value}", + style: TextStyle( + color: Color(0xFF1976D2), + fontSize: 36, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + ), + + const SizedBox(width: 12), + + // KANAN: COD & NON COD + Expanded( + flex: 2, + child: Column( + children: [ + // ✅ Card COD + InkWell( + onTap: () { + showDialog( + context: context, + builder: (context) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + decoration: BoxDecoration( + color: Colors.orange.withOpacity(0.15), + shape: BoxShape.circle, + ), + padding: const EdgeInsets.all(16), + child: const Icon( + Icons.attach_money_rounded, + color: Colors.orange, + size: 48, + ), + ), + const SizedBox(height: 16), + const Text( + 'Pendapatan COD Hari Ini', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.black87, + ), + ), + const SizedBox(height: 12), + Text( + "${c.formatRupiah(c.totalPendapatanCOD.value)}", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + color: Colors.orange, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => Navigator.pop(context), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.orange, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + padding: const EdgeInsets.symmetric(vertical: 12), + ), + child: const Text( + 'Tutup', + style: TextStyle(fontSize: 16, color: Colors.white), + ), + ), + ), + ], + ), + ), + ); + }, + ); + }, + child: Container( + height: 68, + decoration: BoxDecoration( + border: Border.all(color: Colors.orange, width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "COD : ${c.totalPaketCOD.value}", + style: TextStyle( + color: Colors.orange, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + ), + ), + + const SizedBox(height: 12), + + // ✅ Card Non-COD + InkWell( + onTap: () { + showDialog( + context: context, + builder: (context) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + decoration: BoxDecoration( + color: Colors.green.withOpacity(0.15), + shape: BoxShape.circle, + ), + padding: const EdgeInsets.all(16), + child: const Icon( + Icons.payments_rounded, + color: Colors.green, + size: 48, + ), + ), + const SizedBox(height: 16), + const Text( + 'Pendapatan Non-COD Hari Ini', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + color: Colors.black87, + ), + ), + const SizedBox(height: 12), + Text( + "${c.formatRupiah(c.totalPendapatanNonCOD.value)}", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + color: Colors.green, + ), + ), + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () => Navigator.pop(context), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + padding: const EdgeInsets.symmetric(vertical: 12), + ), + child: const Text( + 'Tutup', + style: TextStyle(fontSize: 16, color: Colors.white), + ), + ), + ), + ], + ), + ), + ); + }, + ); + }, + child: Container( + height: 68, + decoration: BoxDecoration( + border: Border.all(color: Colors.green, width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "Non COD : ${c.totalPaketNonCOD.value}", + style: TextStyle( + color: Colors.green, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + ), + ), + ), + ], + ), + ) + + ], + ), + ], + ), + ), + + const SizedBox(height: 24), + + // === CARD GRAFIK PENGIRIMAN === + Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.10), + blurRadius: 8, + offset: const Offset(0, 4), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Grafik Pengiriman Harian', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + color: Colors.black87, + ), + ), + const SizedBox(height: 12), + + // === Grafik Garis === + SizedBox( + height: 200, + child: Obx(() { + if (c.grafikPengiriman.isEmpty) { + return const Center(child: Text("Belum ada data pengiriman")); + } + + final now = DateTime.now(); + final startDate = now.subtract(const Duration(days: 6)); + final todayIndex = 6; + + final spots = List.from(c.grafikPengiriman) + ..sort((a, b) => a.x.compareTo(b.x)); + + return LineChart( + LineChartData( + minX: 0, + maxX: 6, + minY: 0, + maxY: spots.map((e) => e.y).reduce((a, b) => a > b ? a : b) + 1, + gridData: const FlGridData(show: true, drawVerticalLine: false), + titlesData: FlTitlesData( + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) { + if (value < 0 || value > 6) return const SizedBox(); + final date = startDate.add(Duration(days: value.toInt())); + final dayLabel = + DateFormat('E', 'id_ID').format(date); // Sen, Sel, dll + final isToday = value.toInt() == todayIndex; + return Padding( + padding: const EdgeInsets.only(top: 6), + child: Text( + dayLabel, + style: TextStyle( + fontSize: 12, + fontWeight: + isToday ? FontWeight.bold : FontWeight.normal, + color: isToday ? Colors.red : Colors.black, + ), + ), + ); + }, + ), + ), + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + reservedSize: 32, + getTitlesWidget: (value, meta) { + if (value % 1 != 0) return const SizedBox(); + return Text( + value.toInt().toString(), + style: const TextStyle( + fontSize: 10, color: Colors.black54), + ); + }, + ), + ), + ), + borderData: FlBorderData( + show: true, + border: const Border( + top: BorderSide.none, + right: BorderSide.none, + left: BorderSide(color: Colors.black12), + bottom: BorderSide(color: Colors.black12), + ), + ), + lineBarsData: [ + LineChartBarData( + isCurved: true, + color: const Color(0xFF1976D2), + barWidth: 3, + isStrokeCapRound: true, + spots: spots, + belowBarData: BarAreaData( + show: true, + gradient: LinearGradient( + colors: [ + const Color(0xFF1976D2).withOpacity(0.3), + Colors.transparent + ], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + dotData: FlDotData( + show: true, + getDotPainter: (spot, percent, barData, index) { + final isToday = spot.x == todayIndex.toDouble(); + return FlDotCirclePainter( + radius: isToday ? 5 : 3, + color: isToday ? Colors.red : Colors.blueAccent, + strokeWidth: 2, + strokeColor: Colors.white, + ); + }, + ), + ), + ], + ), + ); + }), + ), + + const SizedBox(height: 16), + + // === Card Daftar Total Pengiriman per Hari === + Obx(() { + if (c.grafikPengiriman.isEmpty) return const SizedBox(); + + final now = DateTime.now(); + final startDate = now.subtract(const Duration(days: 6)); + + return Container( + width: double.infinity, + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.grey[50], + borderRadius: BorderRadius.circular(12), + border: Border.all(color: Colors.black12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: List.generate(7, (index) { + final date = startDate.add(Duration(days: index)); + final dayLabel = DateFormat('EEEE', 'id_ID').format(date); + final value = c.grafikPengiriman + .firstWhereOrNull((e) => e.x == index.toDouble()) + ?.y + .toInt() ?? + 0; + + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(dayLabel, style: const TextStyle(fontSize: 13)), + Text("$value resi", + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13)), + ], + ), + ); + }), + ), + ); + }), + ], + ), +) + + + ], + ), + ), + + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/login_view.dart b/praresi/lib/presentation/views/login_view.dart new file mode 100644 index 0000000..e4969fb --- /dev/null +++ b/praresi/lib/presentation/views/login_view.dart @@ -0,0 +1,135 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/auth_controller.dart'; + +class LoginView extends GetView { + LoginView({super.key}); + + final emailC = TextEditingController(); + final passC = TextEditingController(); + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + return Scaffold( + // background putih biru + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFF42A5F5)], // biru tua ke biru muda + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 100), + // Logo atau Judul + const Icon(Icons.lock, size: 80, color: Colors.white), + const SizedBox(height: 10), + const Text( + "Selamat Datang", + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 30), + + // Card form login + Container( + width: size.width * 0.9, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: Column( + children: [ + TextField( + controller: emailC, + decoration: InputDecoration( + labelText: "Email", + prefixIcon: const Icon(Icons.email_outlined), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + const SizedBox(height: 15), + TextField( + controller: passC, + obscureText: true, + decoration: InputDecoration( + labelText: "Password", + prefixIcon: const Icon(Icons.lock_outline), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + const SizedBox(height: 20), + + // Tombol login + Obx(() { + return controller.isLoading.value + ? const CircularProgressIndicator() + : SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 3, + ), + onPressed: () => + controller.login(emailC.text, passC.text), + child: const Text( + "Login", + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white), + ), + ), + ); + }), + const SizedBox(height: 15), + TextButton( + onPressed: () => Get.toNamed('/forgot'), + child: const Text( + "Lupa password?", + style: TextStyle(color: Colors.grey), + ), + ), + ], + ), + ), + + const SizedBox(height: 20), + TextButton( + onPressed: () => Get.toNamed('/register'), + child: const Text( + "Belum punya akun? Register", + style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/main_navbar.dart b/praresi/lib/presentation/views/main_navbar.dart new file mode 100644 index 0000000..442e339 --- /dev/null +++ b/praresi/lib/presentation/views/main_navbar.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'home_view.dart'; +import 'riwayat_view.dart'; +import 'ocr_view.dart'; +import 'analisis_view.dart'; +import 'akun_view.dart'; + +class MainNavbar extends StatefulWidget { + const MainNavbar({super.key}); + + @override + State createState() => _MainNavbarState(); +} + +class _MainNavbarState extends State { + int _currentIndex = 0; + + final List _pages = const [ + HomeView(), + RiwayatView(), + OCRView(), + AnalisisView(), + AkunView(), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: _pages[_currentIndex], + bottomNavigationBar: BottomNavigationBar( + backgroundColor: Colors.white, + currentIndex: _currentIndex, + type: BottomNavigationBarType.fixed, + selectedItemColor: const Color(0xFF1565C0), // biru tua elegan + unselectedItemColor: Colors.blueGrey, // abu kebiruan + onTap: (index) { + setState(() { + _currentIndex = index; + }); + }, + items: [ + const BottomNavigationBarItem( + icon: Icon(Icons.home), + label: 'Beranda', + ), + const BottomNavigationBarItem( + icon: Icon(Icons.history), + label: 'Riwayat', + ), + + /// OCR Item di tengah — block warna biru + BottomNavigationBarItem( + icon: Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + // buat gradient biru supaya stand out + gradient: LinearGradient( + colors: _currentIndex == 2 + ? [Color(0xFF1565C0), Color(0xFF42A5F5)] + : [Color(0x332196F3), Color(0x332196F3)], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + shape: BoxShape.circle, + boxShadow: _currentIndex == 2 + ? [ + BoxShadow( + color: Colors.blue.withOpacity(0.3), + blurRadius: 8, + offset: const Offset(0, 3), + ) + ] + : [], + ), + child: Icon( + Icons.camera_alt, + size: 28, + color: _currentIndex == 2 ? Colors.white : Colors.blue, + ), + ), + label: '', + ), + + const BottomNavigationBarItem( + icon: Icon(Icons.analytics), + label: 'Analisis', + ), + const BottomNavigationBarItem( + icon: Icon(Icons.person), + label: 'Akun', + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/menu_akun/change_password_view.dart b/praresi/lib/presentation/views/menu_akun/change_password_view.dart new file mode 100644 index 0000000..c9f78f6 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/change_password_view.dart @@ -0,0 +1,157 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/change_password_controller.dart'; + + +class ChangePasswordView extends StatelessWidget { + ChangePasswordView({super.key}); + + final _currentPasswordC = TextEditingController(); + final _newPasswordC = TextEditingController(); + final _confirmPasswordC = TextEditingController(); + + final changePasswordC = Get.put(ChangePasswordController()); + + InputDecoration _inputDeco(String label, {String? hint}) { + return InputDecoration( + labelText: label, + hintText: hint, + floatingLabelBehavior: FloatingLabelBehavior.always, + contentPadding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide(color: Color(0xFF1976D2), width: 2), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey[50], + appBar: AppBar( + backgroundColor: Colors.blue, + elevation: 0, + iconTheme: const IconThemeData(color: Colors.white), + title: const Text( + 'Ubah Kata Sandi', + style: TextStyle(color: Colors.white), + ), + centerTitle: true, + ), + body: Obx(() { + return SingleChildScrollView( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: _currentPasswordC, + obscureText: true, + decoration: _inputDeco( + 'Kata sandi saat ini', + hint: 'Masukkan kata sandi lama', + ), + ), + const SizedBox(height: 16), + TextField( + controller: _newPasswordC, + obscureText: true, + decoration: _inputDeco( + 'Kata sandi baru', + hint: 'Masukkan kata sandi baru', + ), + ), + const SizedBox(height: 16), + TextField( + controller: _confirmPasswordC, + obscureText: true, + decoration: _inputDeco( + 'Konfirmasi kata sandi baru', + hint: 'Ulangi kata sandi baru', + ), + ), + const SizedBox(height: 24), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + minimumSize: const Size.fromHeight(50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 0, + ), + onPressed: changePasswordC.isLoading.value + ? null + : () { + // ✅ VALIDASI FIELD KOSONG + if (_currentPasswordC.text.trim().isEmpty || + _newPasswordC.text.trim().isEmpty || + _confirmPasswordC.text.trim().isEmpty) { + Get.snackbar( + "Peringatan", + "Semua field harus diisi", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + + ); + return; + } + + // ✅ VALIDASI PASSWORD SAMA + if (_newPasswordC.text != _confirmPasswordC.text) { + Get.snackbar( + "Error", + "Konfirmasi kata sandi tidak sama", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + icon: const Icon(Icons.error, color: Colors.red), + ); + return; + } + + // ✅ PROSES CHANGE PASSWORD + changePasswordC.changePassword( + currentPassword: _currentPasswordC.text, + newPassword: _newPasswordC.text, + ); + }, + child: changePasswordC.isLoading.value + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ) + : const Text( + 'Simpan Perubahan', + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), +), + + ], + ), + ); + }), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/menu_akun/data_pelanggan_view.dart b/praresi/lib/presentation/views/menu_akun/data_pelanggan_view.dart new file mode 100644 index 0000000..800d66e --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/data_pelanggan_view.dart @@ -0,0 +1,261 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:intl/intl.dart'; +import 'package:praresi/presentation/controllers/pelanggan_controller.dart'; +import 'package:praresi/utils/excel_exporter.dart'; + +class DataPelangganView extends StatefulWidget { + const DataPelangganView({super.key}); + + @override + State createState() => _DataPelangganViewState(); +} + +class _DataPelangganViewState extends State { + final PelangganController controller = Get.put(PelangganController()); + final TextEditingController searchController = TextEditingController(); + var filteredList = >[].obs; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + filteredList.assignAll(controller.pelangganList); + controller.pelangganList.listen((_) { + filteredList.assignAll(controller.pelangganList); + }); + }); + searchController.addListener(_filterData); + } + + void _filterData() { + final query = searchController.text.toLowerCase(); + if (query.isEmpty) { + filteredList.assignAll(controller.pelangganList); + } else { + filteredList.assignAll( + controller.pelangganList.where((item) { + final nama = (item['penerima'] ?? '').toString().toLowerCase(); + return nama.contains(query); + }).toList(), + ); + } + } + + Future exportToExcel() async { + try { + final path = await ExcelExporter.exportPelangganToExcel( + controller.pelangganList.toList(), + ); + Get.snackbar( + "Berhasil", + "File diekspor ke: $path", + backgroundColor: Colors.green.shade50, + colorText: Colors.black, + duration: const Duration(seconds: 5), + ); + } catch (e) { + Get.snackbar( + "Gagal", + "Terjadi kesalahan saat mengekspor: $e", + backgroundColor: Colors.red.shade50, + colorText: Colors.black, + ); + } +} + + + + @override + void dispose() { + searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text( + "Data Pelanggan", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + + ), + centerTitle: true, + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + actions: [ + PopupMenuButton( + icon: const Icon(Icons.more_vert), + onSelected: (value) { + if (value == 'unduh') { + exportToExcel(); + } else if (value == 'refresh') { + controller.fetchAllPelanggan(); + } + }, + itemBuilder: (context) => [ + const PopupMenuItem( + value: 'unduh', + child: Row( + children: [ + Icon(Icons.download, color: Colors.blue), + SizedBox(width: 10), + Text("Unduh Data Pelanggan"), + ], + ), + ), + const PopupMenuItem( + value: 'refresh', + child: Row( + children: [ + Icon(Icons.refresh, color: Colors.green), + SizedBox(width: 10), + Text("Muat Ulang Data"), + ], + ), + ), + ], + ), + ], + ), + body: Obx(() { + if (controller.isLoading.value) { + return const Center( + child: CircularProgressIndicator(color: Color(0xFF1976D2)), + ); + } + + return Column( + children: [ + // 🔹 Statistik jumlah pelanggan + Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + color: Colors.blue.shade50, + child: Text( + "Total Pelanggan: ${controller.totalPelanggan.value}", + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xFF1976D2), + ), + ), + ), + + // 🔹 Search Bar + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: TextField( + controller: searchController, + decoration: InputDecoration( + hintText: 'Cari berdasarkan nama pelanggan...', + prefixIcon: const Icon(Icons.search_rounded, + color: Color(0xFF1976D2)), + filled: true, + fillColor: Colors.white, + contentPadding: + const EdgeInsets.symmetric(vertical: 14, horizontal: 16), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + BorderSide(color: Colors.grey.shade300, width: 1), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + const BorderSide(color: Color(0xFF1976D2), width: 1.5), + ), + ), + cursorColor: const Color(0xFF1976D2), + ), + ), + + // 🔹 Daftar Pelanggan + Expanded( + child: Obx(() { + if (filteredList.isEmpty) { + return const Center(child: Text("Tidak ada data pelanggan")); + } + + return ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: filteredList.length, + itemBuilder: (context, index) { + final item = filteredList[index]; + + // Format tanggal + final createdAt = item['created_at'] != null + ? DateFormat('dd MMM yyyy, HH:mm', 'id_ID') + .format(item['created_at']) + : '-'; + + return Card( + margin: const EdgeInsets.only(bottom: 12), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 3, + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item['penerima'] ?? '-', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + const SizedBox(height: 8), + _buildText("No. WA", item['no_wa']), + _buildText("Alamat", item['alamat']), + _buildText("Kota", item['kota']), + _buildText("Provinsi", item['provinsi']), + _buildText("Barang", item['barang']), + _buildText( + "Total Nominal", + "Rp ${NumberFormat('#,###', 'id_ID').format(item['totalNominal'] ?? 0)}", + isHighlight: true, + ), + const SizedBox(height: 6), + _buildText("Tanggal Dibuat", createdAt), + ], + ), + ), + ); + }, + ); + }), + ), + ], + ); + }), + ); + } + + Widget _buildText(String title, String? value, {bool isHighlight = false}) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(flex: 3, child: Text("$title:")), + Expanded( + flex: 5, + child: Text( + value ?? '-', + style: TextStyle( + color: isHighlight ? Colors.green : Colors.black, + fontWeight: + isHighlight ? FontWeight.bold : FontWeight.normal, + ), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/lib/presentation/views/menu_akun/detail_riwayat_pengiriman.dart b/praresi/lib/presentation/views/menu_akun/detail_riwayat_pengiriman.dart new file mode 100644 index 0000000..f162008 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/detail_riwayat_pengiriman.dart @@ -0,0 +1,193 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:intl/intl.dart'; +import 'package:praresi/presentation/controllers/riwayat_bulanan_controller.dart'; + +class RiwayatBulananDetailView extends StatefulWidget { + final String month; + const RiwayatBulananDetailView({super.key, required this.month}); + + @override + State createState() => + _RiwayatBulananDetailViewState(); +} + +class _RiwayatBulananDetailViewState extends State { + final RiwayatBulananController controller = + Get.find(); + final TextEditingController searchController = TextEditingController(); + + var filteredList = >[].obs; + + @override + void initState() { + super.initState(); + _loadData(); + searchController.addListener(_filterData); + } + + Future _loadData() async { + final data = await controller.fetchResiByMonth(widget.month); + filteredList.assignAll(data); + } + + void _filterData() { + final query = searchController.text.toLowerCase(); + if (query.isEmpty) { + _loadData(); + } else { + filteredList.assignAll( + filteredList.where((item) { + final nama = (item['penerima'] ?? '').toString().toLowerCase(); + return nama.contains(query); + }).toList(), + ); + } + } + + @override + void dispose() { + searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text( + "Riwayat ${widget.month}", + style: const TextStyle(fontWeight: FontWeight.bold), + ), + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + ), + body: Obx(() { + if (controller.isLoading.value) { + return const Center( + child: CircularProgressIndicator(color: Color(0xFF1976D2)), + ); + } + + if (filteredList.isEmpty) { + return const Center( + child: Text("Tidak ada data resi untuk bulan ini"), + ); + } + + return Column( + children: [ + // 🔹 Search bar + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: TextField( + controller: searchController, + decoration: InputDecoration( + hintText: 'Cari berdasarkan nama penerima...', + prefixIcon: + const Icon(Icons.search, color: Color(0xFF1976D2)), + filled: true, + fillColor: Colors.white, + contentPadding: + const EdgeInsets.symmetric(vertical: 14, horizontal: 16), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + BorderSide(color: Colors.grey.shade200, width: 1), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + const BorderSide(color: Color(0xFF1976D2), width: 1.5), + ), + suffixIcon: IconButton( + icon: const Icon(Icons.clear, + color: Colors.grey, size: 20), + onPressed: () { + searchController.clear(); + }, + ), + ), + ), + ), + + // 🔹 List data penerima + Expanded( + child: ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: filteredList.length, + itemBuilder: (context, index) { + final item = filteredList[index]; + final createdAt = item['created_at'] is DateTime + ? item['created_at'] as DateTime + : (item['created_at']?.toDate() ?? DateTime.now()); + final total = num.tryParse(item['total'].toString()) ?? 0; + + return Card( + margin: const EdgeInsets.only(bottom: 16), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + elevation: 3, + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "📦 Detail Penerima", + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 16), + ), + const SizedBox(height: 10), + _buildText("Penerima", item['penerima']), + _buildText("Barang", item['barang']), + _buildText("Alamat", item['alamat']), + _buildText("No. WA", item['no_wa']), + _buildText("Pembayaran", item['pembayaran']), + _buildText( + "Total", + "Rp ${NumberFormat('#,###', 'id_ID').format(total)}", + isHighlight: true, + ), + _buildText( + "Tanggal Dibuat", + DateFormat('dd MMM yyyy, HH:mm', 'id_ID') + .format(createdAt), + ), + ], + ), + ), + ); + }, + ), + ), + ], + ); + }), + ); + } + + Widget _buildText(String title, String? value, + {bool isHighlight = false}) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(flex: 3, child: Text("$title:")), + Expanded( + flex: 5, + child: Text( + value ?? '-', + style: TextStyle( + color: isHighlight ? Colors.green : Colors.black, + fontWeight: + isHighlight ? FontWeight.bold : FontWeight.normal, + ), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/lib/presentation/views/menu_akun/panduan_pengguna_view.dart b/praresi/lib/presentation/views/menu_akun/panduan_pengguna_view.dart new file mode 100644 index 0000000..a0d2508 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/panduan_pengguna_view.dart @@ -0,0 +1,387 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class PanduanPenggunaPage extends StatelessWidget { + const PanduanPenggunaPage({super.key}); + + void _salinFormat(BuildContext context) { + const formatText = ''' +Penerima : +Alamat : +No. Wa : +Barang : +Total : +Pembayaran : +'''; + + Clipboard.setData(const ClipboardData(text: formatText)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Format pengiriman berhasil disalin!"), + duration: Duration(seconds: 2), + ), + ); + } + + Widget _buildSection({ + required String title, + required String description, + required IconData icon, +}) { + return Container( + width: double.infinity, + margin: const EdgeInsets.symmetric(vertical: 8), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: BorderRadius.circular(14), + border: Border.all( + color: Colors.blue.shade200, + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 6, + offset: const Offset(0, 3), + ) + ], + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.blue.shade100, + borderRadius: BorderRadius.circular(10), + ), + child: Icon( + icon, + color: const Color(0xFF1976D2), + size: 24, + ), + ), + + const SizedBox(width: 14), + + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: const TextStyle( + fontSize: 16.5, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + + const SizedBox(height: 6), + + Text( + description, + style: const TextStyle( + fontSize: 15, + height: 1.6, + color: Colors.black87, + ), + ), + ], + ), + ), + ], + ), + ); +} + + + Widget _buildExampleBox() { + Widget item(String title, String value) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + const SizedBox(width: 10), + + SizedBox( + width: 100, + child: Text( + title, + style: const TextStyle( + fontWeight: FontWeight.w600, + ), + ), + ), + + const Text(" : "), + + Expanded( + child: Text( + value, + style: const TextStyle(color: Colors.black87), + ), + ), + ], + ), + ); + } + + return Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + margin: const EdgeInsets.symmetric(vertical: 10), + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: BorderRadius.circular(14), + border: Border.all( + color: Colors.blue.shade200, + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.05), + blurRadius: 6, + offset: const Offset(0, 3), + ) + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Contoh Format Pengiriman", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.blue, + ), + ), + + const Divider(height: 20), + + item("Penerima", "[Nama Penerima]"), + item("Alamat", + "[Detail Alamat], [Kota/Kab.], [Provinsi]"), + item("No. WA", "08581245xxxx"), + item("Barang", "Barang"), + item("Total", "100.000"), + item("Pembayaran", "[COD / NonCOD]"), + ], + ), + ); +} + + + Widget _buildRulesBox() { + Widget ruleItem(String text) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: const EdgeInsets.only(top: 3), + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: Colors.blue.shade100, + shape: BoxShape.circle, + ), + child: const Icon( + Icons.check, + size: 14, + color: Color(0xFF1976D2), + ), + ), + const SizedBox(width: 10), + Expanded( + child: Text( + text, + style: const TextStyle( + fontSize: 15, + height: 1.6, + color: Colors.black87, + ), + ), + ), + ], + ), + ); + } + + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + margin: const EdgeInsets.only(top: 8, bottom: 16), + decoration: BoxDecoration( + color: Colors.blue.shade50, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: Colors.blue.shade200), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Row( + children: [ + Icon( + Icons.rule, + color: Color(0xFF1976D2), + ), + SizedBox(width: 8), + Text( + "Aturan Format Pengiriman", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + ], + ), + + const SizedBox(height: 12), + + ruleItem("Penerima : diisi nama penerima barang"), + ruleItem( + "Alamat : wajib mencantumkan kota/kabupaten dan provinsi"), + ruleItem( + "No. WA : nomor WhatsApp penerima yang aktif"), + ruleItem("Barang : nama barang yang dikirim"), + ruleItem( + "Total : hanya angka tanpa simbol (contoh: 75000)"), + ruleItem( + "Pembayaran : hanya ‘COD’ atau ‘Non COD’"), + ], + ), + ); +} + + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + title: const Text( + "Panduan Pengguna", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w600, + ), + ), + centerTitle: true, + backgroundColor: const Color(0xFF1976D2), + elevation: 2, + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(18), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Center( + child: Column( + children: [ + const Icon( + Icons.help_outline_rounded, + color: Color(0xFF1976D2), + size: 72, + ), + const SizedBox(height: 8), + Text( + "Panduan Pengguna Aplikasi", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.grey.shade800, + ), + ), + const SizedBox(height: 6), + Text( + "Ikuti langkah-langkah di bawah untuk menggunakan aplikasi dengan mudah.", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14.5, + color: Colors.grey.shade700, + ), + ), + ], + ), + ), + + const SizedBox(height: 24), + + _buildSection( + title: "Langkah 1 — Isi Data Toko", + description: + "Setelah berhasil registrasi dan login, langkah pertama adalah mengisi data toko Anda. " + "Menu untuk mengisi data toko dapat ditemukan di bagian menu ‘Akun’.", + icon: Icons.store_rounded, + ), + + _buildSection( + title: "Langkah 2 — Input Data Resi", + description: + "Setelah data toko diisi, Anda dapat menambahkan data pengiriman dengan mengikuti format yang telah ditentukan di bawah ini:", + icon: Icons.receipt_long_rounded, + ), + + _buildExampleBox(), + + Center( + child: ElevatedButton.icon( + onPressed: () => _salinFormat(context), + icon: const Icon(Icons.copy_rounded), + label: const Text("Salin Format Pengiriman"), + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 12), + textStyle: const TextStyle( + fontSize: 15.5, + fontWeight: FontWeight.w600, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + ), + + const SizedBox(height: 18), + + _buildSection( + title: "Ketentuan Pengisian", + description: + "Pastikan setiap kolom diisi dengan benar agar data resi tersimpan dan terbaca dengan baik oleh sistem.", + icon: Icons.rule_rounded, + ), + + _buildRulesBox(), + + _buildSection( + title: "Tips Penggunaan", + description: + "💡 Pastikan format sesuai contoh, gunakan huruf kapital di awal kata, dan hindari penggunaan simbol yang tidak perlu.", + icon: Icons.lightbulb_rounded, + ), + + const SizedBox(height: 24), + Center( + child: Text( + "Terima kasih telah menggunakan aplikasi kami 👋", + style: TextStyle( + fontSize: 14, + color: Colors.grey.shade700, + fontStyle: FontStyle.italic, + ), + ), + ), + const SizedBox(height: 12), + ], + ), + ), + ); + } +} diff --git a/praresi/lib/presentation/views/menu_akun/profile_view.dart b/praresi/lib/presentation/views/menu_akun/profile_view.dart new file mode 100644 index 0000000..7ed8345 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/profile_view.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/profile_controller.dart'; + +class ProfileView extends StatelessWidget { + ProfileView({Key? key}) : super(key: key); + + final controller = Get.put(ProfileController()); + + InputDecoration _inputDeco(String label, {bool readOnly = false}) { + return InputDecoration( + labelText: label, + filled: readOnly, + fillColor: readOnly ? Colors.grey[200] : null, + floatingLabelBehavior: FloatingLabelBehavior.always, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide(color: Color(0xFF1976D2), width: 2), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Profil Pengguna", style: TextStyle(color: Colors.white)), + + backgroundColor: const Color(0xFF1976D2), + centerTitle: true, + ), + body: Obx(() { + if (controller.isLoading.value) { + return const Center(child: CircularProgressIndicator()); + } + + return Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + TextFormField( + controller: TextEditingController(text: controller.name.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: controller.name.value.length), + ), + onChanged: (v) => controller.name.value = v, + decoration: _inputDeco("Nama Pengguna"), + ), + const SizedBox(height: 16), + TextFormField( + readOnly: true, + controller: TextEditingController(text: controller.email.value), + decoration: _inputDeco("Email", readOnly: true), + ), + const SizedBox(height: 32), + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + minimumSize: const Size.fromHeight(50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + onPressed: controller.updateName, + child: const Text( + "Simpan Perubahan", + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ], + ), + ); + }), + ); + } +} diff --git a/praresi/lib/presentation/views/menu_akun/riwayat_pengiriman.dart b/praresi/lib/presentation/views/menu_akun/riwayat_pengiriman.dart new file mode 100644 index 0000000..14acc60 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/riwayat_pengiriman.dart @@ -0,0 +1,299 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:intl/intl.dart'; +import 'package:praresi/presentation/controllers/riwayat_bulanan_controller.dart'; +import 'package:praresi/presentation/views/menu_akun/detail_riwayat_pengiriman.dart'; + +class RiwayatBulananView extends StatelessWidget { + const RiwayatBulananView({super.key}); + + @override + Widget build(BuildContext context) { + final riwayatBulananC = Get.put(RiwayatBulananController(), permanent: true); + + return Scaffold( + backgroundColor: Colors.grey[50], + appBar: AppBar( + backgroundColor: const Color(0xFF1976D2), + elevation: 0, + iconTheme: const IconThemeData(color: Colors.white), + centerTitle: true, + title: const Text( + 'Riwayat Pengiriman', + style: TextStyle(color: Colors.white), + ), + ), + body: Obx(() { + if (riwayatBulananC.isLoading.value) { + return const Center( + child: CircularProgressIndicator(color: Color(0xFF1976D2)), + ); + } + + if (riwayatBulananC.monthlySummary.isEmpty) { + return const Center( + child: Text( + "Belum ada data bulanan", + style: TextStyle(color: Colors.black54, fontSize: 16), + ), + ); + } + + return SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: Column( + children: riwayatBulananC.monthlySummary.map((data) { + return Padding( + padding: const EdgeInsets.only(bottom: 15), + child: _monthlyCard(riwayatBulananC, data), + ); + }).toList(), + ), + ); + }), + ); + } + + Widget _monthlyCard( + RiwayatBulananController controller, Map data) { + final month = data['month']; + final total = data['total']; + final cod = data['cod']; + final nonCod = data['nonCod']; + final incomeCod = data['incomeCod']; + final incomeNonCod = data['incomeNonCod']; + final totalIncome = incomeCod + incomeNonCod; + + return InkWell( + onTap: () { + // Navigasi ke halaman detail riwayat bulanan + Get.to(() => RiwayatBulananDetailView(month: month)); + }, + borderRadius: BorderRadius.circular(20), + child: Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 8, + offset: const Offset(0, 5), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 🔹 Nama Bulan + Text( + month, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + const SizedBox(height: 15), + + // 🔹 Total dan COD/NON-COD + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Container( + height: 90, + margin: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFF1976D2), width: 2), + borderRadius: BorderRadius.circular(14), + ), + child: Center( + child: Text( + "Total \n$total", + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + ), + ), + ), + Expanded( + flex: 2, + child: Column( + children: [ + // 🔸 COD + InkWell( + onTap: () async { + final income = await controller.getPendapatanBulanan(month); + final codPendapatan = income['cod'] ?? 0.0; + + Get.defaultDialog( + title: "Pendapatan COD", + titleStyle: const TextStyle( + color: Color(0xFFFF9800), + fontWeight: FontWeight.bold, + fontSize: 18, + ), + radius: 14, + content: Column( + children: [ + const Icon(Icons.local_shipping, + color: Color(0xFFFF9800), size: 48), + const SizedBox(height: 12), + Text( + month, + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 8), + Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(codPendapatan)}", + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Color(0xFFFF9800), + ), + ), + ], + ), + confirm: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFFF9800), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + onPressed: () => Get.back(), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ); + }, + child: Container( + height: 40, + margin: const EdgeInsets.only(bottom: 10), + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFFFF9800), width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "COD: $cod", + style: const TextStyle( + color: Color(0xFFFF9800), + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ), + ), + + // 🔸 Non COD + InkWell( + onTap: () async { + final income = await controller.getPendapatanBulanan(month); + final nonCodPendapatan = income['nonCod'] ?? 0.0; + + Get.defaultDialog( + title: "Pendapatan Non COD", + titleStyle: const TextStyle( + color: Color(0xFF4CAF50), + fontWeight: FontWeight.bold, + fontSize: 18, + ), + radius: 14, + content: Column( + children: [ + const Icon(Icons.account_balance_wallet, + color: Color(0xFF4CAF50), size: 48), + const SizedBox(height: 12), + Text( + month, + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 8), + Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(nonCodPendapatan)}", + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Color(0xFF4CAF50), + ), + ), + ], + ), + confirm: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF4CAF50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + onPressed: () => Get.back(), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ); + }, + child: Container( + height: 40, + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFF4CAF50), width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "Non COD: $nonCod", + style: const TextStyle( + color: Color(0xFF4CAF50), + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ), + + const SizedBox(height: 10), + + // 🔸 Pendapatan Total + Container( + width: double.infinity, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey.shade400, width: 1.2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(totalIncome)}", + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/praresi/lib/presentation/views/menu_akun/store_view.dart b/praresi/lib/presentation/views/menu_akun/store_view.dart new file mode 100644 index 0000000..3be4db9 --- /dev/null +++ b/praresi/lib/presentation/views/menu_akun/store_view.dart @@ -0,0 +1,159 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/store_controller.dart'; + +class StoreView extends StatelessWidget { + StoreView({Key? key}) : super(key: key); + + final storeC = Get.put(StoreController()); + + // gaya input border + label + InputDecoration _inputDeco(String label, {String? hint}) { + return InputDecoration( + labelText: label, + hintText: hint, + floatingLabelBehavior: FloatingLabelBehavior.always, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide(color: Color(0xFF1976D2), width: 2), + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.grey[50], + appBar: AppBar( + backgroundColor: Colors.blue, + elevation: 0, + iconTheme: const IconThemeData(color: Colors.white), + title: const Text( + 'Toko', + style: TextStyle(color: Colors.white), + ), + centerTitle: true, + ), + body: Obx(() { + if (storeC.isLoading.value) { + return const Center(child: CircularProgressIndicator()); + } + + final isNew = storeC.storeData.value == null; + + return SingleChildScrollView( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Nama Toko + TextFormField( + decoration: _inputDeco('Nama Toko'), + controller: TextEditingController( + text: storeC.namaTokoC.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: storeC.namaTokoC.value.length)), + onChanged: (v) => storeC.namaTokoC.value = v, + ), + const SizedBox(height: 16), + + // No HP + TextFormField( + decoration: _inputDeco('No HP Toko'), + keyboardType: TextInputType.phone, + controller: TextEditingController( + text: storeC.noHpC.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: storeC.noHpC.value.length)), + onChanged: (v) => storeC.noHpC.value = v, + ), + const SizedBox(height: 16), + + // Alamat + TextFormField( + decoration: _inputDeco('Alamat Toko'), + maxLines: 2, + controller: TextEditingController( + text: storeC.alamatC.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: storeC.alamatC.value.length)), + onChanged: (v) => storeC.alamatC.value = v, + ), + const SizedBox(height: 16), + + // No Registrasi + TextFormField( + decoration: _inputDeco('No Registrasi'), + controller: TextEditingController( + text: storeC.noRegistrasiC.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: storeC.noRegistrasiC.value.length)), + onChanged: (v) => storeC.noRegistrasiC.value = v, + ), + const SizedBox(height: 16), + + // Keterangan + TextFormField( + decoration: _inputDeco('Keterangan'), + maxLines: 3, + controller: TextEditingController( + text: storeC.keteranganC.value) + ..selection = TextSelection.fromPosition( + TextPosition(offset: storeC.keteranganC.value.length)), + onChanged: (v) => storeC.keteranganC.value = v, + ), + const SizedBox(height: 24), + + // Tombol simpan + SizedBox( + width: double.infinity, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + minimumSize: const Size.fromHeight(50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 0, + ), + onPressed: () { + if (storeC.namaTokoC.value.trim().isEmpty || + storeC.noHpC.value.trim().isEmpty || + storeC.alamatC.value.trim().isEmpty) { + Get.snackbar( + "Peringatan", + "Nama toko, No HP, dan Alamat wajib diisi", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + margin: const EdgeInsets.all(12), + borderRadius: 12, + + ); + return; + } + + storeC.saveStore(); +}, + + child: Text( + isNew ? 'Simpan Toko' : 'Update Toko', + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ], + ), + ); + }), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/menu_riwayat/detail_riwayat_view.dart b/praresi/lib/presentation/views/menu_riwayat/detail_riwayat_view.dart new file mode 100644 index 0000000..ccd4180 --- /dev/null +++ b/praresi/lib/presentation/views/menu_riwayat/detail_riwayat_view.dart @@ -0,0 +1,607 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:intl/intl.dart'; +import 'package:praresi/presentation/controllers/riwayat_controller.dart'; +import 'package:praresi/utils/pdf_exporter.dart'; + +class DetailRiwayatView extends StatefulWidget { + const DetailRiwayatView({super.key}); + + @override + State createState() => _DetailRiwayatViewState(); +} + +class _DetailRiwayatViewState extends State { + final RiwayatController controller = Get.find(); + final TextEditingController searchController = TextEditingController(); + + var filteredList = >[].obs; + + @override + void initState() { + super.initState(); + + final args = Get.arguments; + final String date = args['date']; + + WidgetsBinding.instance.addPostFrameCallback((_) async { + await controller + .fetchResiByDate(DateFormat('d MMMM yyyy', 'id_ID').parse(date)); + + filteredList.assignAll(controller.dailyDetail); + }); + + searchController.addListener(_filterData); + } + + void _filterData() { + final query = searchController.text.toLowerCase(); + if (query.isEmpty) { + filteredList.assignAll(controller.dailyDetail); + } else { + filteredList.assignAll( + controller.dailyDetail.where((item) { + final nama = (item['penerima'] ?? '').toString().toLowerCase(); + return nama.contains(query); + }).toList(), + ); + } + } + + @override + void dispose() { + searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final args = Get.arguments; + final String day = args['day']; + final String date = args['date']; + + return Scaffold( + appBar: AppBar( + title: Text( + "$day, $date", + style: const TextStyle(fontWeight: FontWeight.bold), + ), + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + ), + body: Obx(() { + if (controller.isLoading.value) { + return const Center( + child: CircularProgressIndicator(color: Color(0xFF1976D2)), + ); + } + + if (controller.dailyDetail.isEmpty) { + return const Center( + child: Text("Tidak ada data resi untuk hari ini"), + ); + } + + return Column( + children: [ + // 🔹 Search Bar + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: TextField( + controller: searchController, + decoration: InputDecoration( + hintText: 'Cari berdasarkan nama penerima...', + hintStyle: TextStyle( + color: Colors.grey[500], + fontSize: 14, + fontWeight: FontWeight.w400, + ), + prefixIcon: const Icon( + Icons.search_rounded, + color: Color(0xFF1976D2), + size: 22, + ), + filled: true, + fillColor: Colors.white, + contentPadding: + const EdgeInsets.symmetric(vertical: 14, horizontal: 16), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + BorderSide(color: Colors.grey.shade200, width: 1), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: + const BorderSide(color: Color(0xFF1976D2), width: 1.5), + ), + suffixIcon: IconButton( + icon: const Icon(Icons.clear, color: Colors.grey, size: 20), + onPressed: () { + searchController.clear(); + }, + ), + ), + style: const TextStyle( + fontSize: 15, + color: Colors.black87, + fontWeight: FontWeight.w500, + ), + cursorColor: const Color(0xFF1976D2), + ), + ), + + // 🔹 Daftar hasil pencarian + Expanded( + child: Obx(() { + if (filteredList.isEmpty) { + return const Center( + child: Text("Tidak ada hasil pencarian"), + ); + } + + return ListView.builder( + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: filteredList.length, + itemBuilder: (context, index) { + final item = filteredList[index]; + final createdAt = item['created_at'] as DateTime; + final store = item['store'] ?? {}; + + return Card( + margin: const EdgeInsets.only(bottom: 16), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + elevation: 3, + child: Padding( + padding: const EdgeInsets.all(16), + child: Stack( + children: [ + // 🔸 Isi utama kartu + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("📦 Detail Penerima", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16)), + const SizedBox(height: 10), + _buildText("Penerima", item['penerima']), + _buildText("Barang", item['barang']), + _buildText("Alamat", item['alamat']), + _buildText("No. WA", item['no_wa']), + _buildText("Pembayaran", item['pembayaran']), + _buildText( + "Total", + "Rp ${NumberFormat('#,###', 'id_ID').format(num.tryParse(item['total'].toString()) ?? 0)}", + isHighlight: true, + ), + _buildText( + "Tanggal Dibuat", + DateFormat('dd MMM yyyy, HH:mm', 'id_ID') + .format(createdAt), + ), + const Divider(height: 24), + const Text("🏪 Pengirim", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16)), + const SizedBox(height: 8), + _buildText("Nama Toko", store['namaToko']), + _buildText("No HP", store['noHp']), + _buildText( + "No Registrasi", store['noRegistrasi']), + _buildText("Keterangan", store['keterangan']), + ], + ), + + // 🔹 Tombol titik tiga (menu) + Positioned( + right: 0, + top: 0, + child: PopupMenuButton( + onSelected: (value) async { + if (value == 'edit') { + _onEdit(item); + } else if (value == 'hapus') { + _onDelete(controller, item['id']); + } else if (value == 'cetak') { + _onPrint(item); + } + }, + itemBuilder: (context) => [ + const PopupMenuItem( + value: 'edit', + child: Row( + children: [ + Icon(Icons.edit, color: Colors.blue), + SizedBox(width: 8), + Text("Edit"), + ], + ), + ), + const PopupMenuItem( + value: 'hapus', + child: Row( + children: [ + Icon(Icons.delete, color: Colors.red), + SizedBox(width: 8), + Text("Hapus"), + ], + ), + ), + const PopupMenuItem( + value: 'cetak', + child: Row( + children: [ + Icon(Icons.download, + color: Colors.green), + SizedBox(width: 8), + Text("Unduh"), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ); + }, + ); + }), + ), + ], + ); + }), + ); + } + + Widget _buildText(String title, String? value, {bool isHighlight = false}) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 2), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(flex: 3, child: Text("$title:")), + Expanded( + flex: 5, + child: Text( + value ?? '-', + style: TextStyle( + color: isHighlight ? Colors.green : Colors.black, + fontWeight: isHighlight ? FontWeight.bold : FontWeight.normal, + ), + ), + ), + ], + ), + ); + } + + // 🔹 Fungsi aksi tombol titik tiga +void _onEdit(Map item) { + final TextEditingController penerimaController = + TextEditingController(text: item['penerima'] ?? ''); + final TextEditingController barangController = + TextEditingController(text: item['barang'] ?? ''); + final TextEditingController alamatController = + TextEditingController(text: item['alamat'] ?? ''); + final TextEditingController noWaController = + TextEditingController(text: item['no_wa'] ?? ''); + final TextEditingController pembayaranController = + TextEditingController(text: item['pembayaran'] ?? ''); + final TextEditingController totalController = + TextEditingController(text: item['total']?.toString() ?? ''); + + Get.defaultDialog( + title: "Edit Data Penerima", + radius: 10, + content: ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: 300, // 👈 batasi tinggi agar dialog bisa discroll + ), + child: SingleChildScrollView( + child: Column( + children: [ + _buildEditField("Nama Penerima", penerimaController), + _buildEditField("Nama Barang", barangController), + _buildEditField("Alamat", alamatController), + _buildEditField("No. WA", noWaController), + _buildEditField("Pembayaran",pembayaranController,isDropdown: true,), + _buildEditField("Total (Rp)", totalController, + inputType: TextInputType.number), + const SizedBox(height: 20), + ElevatedButton.icon( + onPressed: () async { + // 🔹 Validasi input sederhana + if (penerimaController.text.isEmpty || + barangController.text.isEmpty || + alamatController.text.isEmpty) { + Get.snackbar("Gagal", "Pastikan semua data terisi", + backgroundColor: Colors.red.shade100, + snackPosition: SnackPosition.BOTTOM); + return; + } + + try { + await controller.updateResi(item['id'], { + 'penerima': penerimaController.text, + 'barang': barangController.text, + 'alamat': alamatController.text, + 'no_wa': noWaController.text, + 'pembayaran': pembayaranController.text, + 'total': totalController.text, + }); + + Get.back(); // Tutup dialog + Get.snackbar("Berhasil", "Data berhasil diperbarui", + backgroundColor: Colors.green.shade100, + snackPosition: SnackPosition.BOTTOM); + } catch (e) { + Get.snackbar("Error", "Gagal memperbarui data: $e", + backgroundColor: Colors.red.shade100, + snackPosition: SnackPosition.BOTTOM); + } + }, + icon: const Icon(Icons.save), + label: const Text("Simpan Perubahan"), + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + minimumSize: const Size(double.infinity, 45), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + ), + ], + ), + ), + ), + ); +} + + +// Widget _buildEditField(String label, TextEditingController controller, +// {TextInputType inputType = TextInputType.text}) { +// return Padding( +// padding: const EdgeInsets.only(bottom: 12), +// child: TextField( +// controller: controller, +// keyboardType: inputType, +// decoration: InputDecoration( +// labelText: label, +// labelStyle: +// const TextStyle(color: Colors.black54, fontWeight: FontWeight.w500), +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(8), +// ), +// focusedBorder: const OutlineInputBorder( +// borderSide: BorderSide(color: Color(0xFF1976D2), width: 1.5), +// ), +// ), +// ), +// ); +// } + +Widget _buildEditField( + String label, + TextEditingController controller, { + TextInputType inputType = TextInputType.text, + bool isDropdown = false, +}) { + return Padding( + padding: const EdgeInsets.only(bottom: 12), + child: TextField( + controller: controller, + keyboardType: inputType, + readOnly: isDropdown, // 🔥 penting + onTap: isDropdown + ? () async { + final selected = await showModalBottomSheet( + context: Get.context!, + builder: (context) { + return SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + title: const Text("COD"), + onTap: () => Navigator.pop(context, "COD"), + ), + ListTile( + title: const Text("NON COD"), + onTap: () => Navigator.pop(context, "NON COD"), + ), + ], + ), + ); + }, + ); + + if (selected != null) { + controller.text = selected; + } + } + : null, + decoration: InputDecoration( + labelText: label, + labelStyle: const TextStyle( + color: Colors.black54, + fontWeight: FontWeight.w500, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFF1976D2), width: 1.5), + ), + suffixIcon: isDropdown + ? const Icon(Icons.arrow_drop_down) // 🔥 biar keliatan dropdown + : null, + ), + ), + ); +} + + + void _onDelete(RiwayatController controller, String id) async { + final confirm = await Get.defaultDialog( + title: "Hapus Data", + middleText: "Apakah kamu yakin ingin menghapus data ini?", + textCancel: "Batal", + textConfirm: "Hapus", + confirmTextColor: Colors.white, + onConfirm: () => Get.back(result: true), + onCancel: () => Get.back(result: false), + ); + + if (confirm == true) { + await controller.deleteResi(id); + } +} + + + void _onPrint(Map item) async { + try { + // Ambil tanggal untuk tampilan info di PDF + final createdAt = item['created_at'] ?? DateTime.now(); + final day = DateFormat.EEEE('id_ID').format(createdAt); + final date = DateFormat('d MMMM yyyy', 'id_ID').format(createdAt); + + // Ambil controller Analisis (kalau dibutuhkan) + final controller = Get.find(); + + // 🔹 Tampilkan dialog pemilihan format + _showPrintFormatDialog(Get.context!, day, date, item, controller); + } catch (e) { + Get.snackbar( + "Error", + "Gagal memproses cetak: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } +} + + +void _showPrintFormatDialog( + BuildContext context, + String day, + String date, + Map item, + dynamic controller, +) { + Get.bottomSheet( + Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + child: Wrap( + children: [ + const Center( + child: Text( + "Pilih Format Unduh", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + ), + const SizedBox(height: 20), + + // 🔹 FORMAT A4 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A4"), + onTap: () async { + Get.back(); + try { + final path = await PdfExporter.exportSingleItemToPdf( + item, + format: 'A4', + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + // 🔹 FORMAT A5 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A5"), + onTap: () async { + Get.back(); + try { + final path = await PdfExporter.exportSingleItemToPdf( + item, + format: 'A5', + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + // 🔹 FORMAT A6 + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A6"), + onTap: () async { + Get.back(); + try { + final path = await PdfExporter.exportSingleItemToPdf( + item, + format: 'A6', + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + ], + ), + ), + ); +} + + +} diff --git a/praresi/lib/presentation/views/ocr_view.dart b/praresi/lib/presentation/views/ocr_view.dart new file mode 100644 index 0000000..385b3c6 --- /dev/null +++ b/praresi/lib/presentation/views/ocr_view.dart @@ -0,0 +1,392 @@ +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:image_cropper/image_cropper.dart'; +import 'package:google_mlkit_text_recognition/google_mlkit_text_recognition.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:praresi/presentation/controllers/resi_controller.dart'; + + +class OCRView extends StatefulWidget { + const OCRView({super.key}); + + @override + State createState() => _OCRViewState(); +} + + + +class _OCRViewState extends State { + File? _imageFile; + final picker = ImagePicker(); + final TextEditingController _textController = TextEditingController(); + bool _isProcessing = false; + + bool _isSaving = false; + + + final ResiController resiController = Get.put(ResiController()); + final FirebaseAuth _auth = FirebaseAuth.instance; + + /// Ambil gambar dan jalankan OCR + Future _pickImage(ImageSource source) async { + final pickedFile = await picker.pickImage(source: source, imageQuality: 80); + if (pickedFile != null) { + File? cropped = await _cropImage(pickedFile.path); + if (cropped != null) { + setState(() { + _imageFile = cropped; + }); + await _performOCR(cropped); + } + } + } + + @override +void initState() { + super.initState(); + + _textController.addListener(() { + setState(() {}); + }); +} + + /// Crop gambar + Future _cropImage(String imagePath) async { + final croppedFile = await ImageCropper().cropImage( + sourcePath: imagePath, + aspectRatioPresets: [ + CropAspectRatioPreset.original, + CropAspectRatioPreset.square, + CropAspectRatioPreset.ratio4x3, + CropAspectRatioPreset.ratio16x9, + ], + uiSettings: [ + AndroidUiSettings( + toolbarTitle: 'Crop Gambar', + toolbarColor: const Color(0xFF1976D2), + toolbarWidgetColor: Colors.white, + activeControlsWidgetColor: const Color(0xFF1976D2), + initAspectRatio: CropAspectRatioPreset.original, + lockAspectRatio: false, // 🔓 supaya bisa geser & ubah ukuran bebas + ), + IOSUiSettings( + title: 'Crop Gambar', + aspectRatioLockEnabled: false, // 🔓 untuk iPhone/iPad + ), + ], + ); + return croppedFile != null ? File(croppedFile.path) : null; +} + + /// Jalankan OCR pakai Google ML Kit + Future _performOCR(File imageFile) async { + setState(() { + _isProcessing = true; + }); + + final inputImage = InputImage.fromFile(imageFile); + final textRecognizer = TextRecognizer(); + final recognizedText = await textRecognizer.processImage(inputImage); + await textRecognizer.close(); + + setState(() { + _textController.text = recognizedText.text; + _isProcessing = false; + }); + + Get.snackbar( + 'Selesai', + 'Teks berhasil dikenali!', + backgroundColor: Colors.green, + colorText: Colors.white, + ); + } + + /// Simpan hasil OCR ke Firestore + Future _saveResi() async { + + /// ✅ cegah double klik + if (_isSaving) return; + + final user = _auth.currentUser; + + if (user == null) { + Get.snackbar( + 'Gagal', + 'User belum login!', + backgroundColor: Colors.red, + colorText: Colors.white, + ); + return; + } + + if (_textController.text.trim().isEmpty) { + Get.snackbar( + 'Peringatan', + 'Tidak ada teks untuk disimpan!', + backgroundColor: Colors.orange, + colorText: Colors.white, + ); + return; + } + + setState(() { + _isSaving = true; + }); + + try { + final storeId = user.uid; + + await resiController.saveResi( + _textController.text.trim(), + storeId, + ); + + } finally { + + /// ✅ aktif kembali setelah selesai + setState(() { + _isSaving = false; + }); + } +} + + + @override + void dispose() { + _textController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + appBar: AppBar( + title: const Text("Pindai Pemesanan"), + centerTitle: true, + backgroundColor: const Color(0xFF1976D2), + foregroundColor: Colors.white, + ), + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFFE3F2FD)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SafeArea( + child: Column( + children: [ + const SizedBox(height: 20), + + // Gambar hasil ambil/crop + Expanded( + flex: 4, + child: Container( + width: double.infinity, + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: _imageFile == null + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon(Icons.camera_alt, + size: 50, color: Colors.grey), + SizedBox(height: 12), + Text( + "Belum ada gambar", + style: TextStyle( + fontSize: 16, color: Colors.grey), + ), + ], + ) + : ClipRRect( + borderRadius: BorderRadius.circular(12), + child: Image.file(_imageFile!, fit: BoxFit.cover), + ), + ), + ), + + const SizedBox(height: 20), + + // Tombol ambil/pilih gambar + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + children: [ + Expanded( + child: ElevatedButton.icon( + onPressed: () => _pickImage(ImageSource.camera), + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + icon: const Icon(Icons.camera, color: Colors.white), + label: const Text("Kamera", + style: + TextStyle(color: Colors.white, fontSize: 16)), + ), + ), + const SizedBox(width: 10), + Expanded( + child: OutlinedButton.icon( + onPressed: () => _pickImage(ImageSource.gallery), + style: OutlinedButton.styleFrom( + side: const BorderSide(color: Color(0xFF1976D2), width: 2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + icon: const Icon(Icons.photo_library, + color: Color(0xFF1976D2)), + label: const Text("Galeri", + style: TextStyle( + color: Color(0xFF1976D2), fontSize: 16)), + ), + ), + ], + ), + ), + + const SizedBox(height: 20), + + // Area hasil OCR + Expanded( + flex: 3, + child: Stack( + children: [ + Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: _isProcessing + ? const Center( + child: CircularProgressIndicator( + color: Color(0xFF1976D2), + ), + ) + : TextField( + controller: _textController, + maxLines: null, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Hasil OCR akan muncul di sini...", + ), + ), + ), + + // =============================== + // ICON HAPUS + // =============================== + if (_textController.text.isNotEmpty) + Positioned( + top: 8, + right: 24, + child: GestureDetector( + onTap: () { + setState(() { + _textController.clear(); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.grey.shade200, + shape: BoxShape.circle, + ), + padding: const EdgeInsets.all(6), + child: const Icon( + Icons.close, + size: 18, + color: Colors.black54, + ), + ), + ), + ), + ], + ), + + ), + + const SizedBox(height: 10), + + // Tombol Simpan ke Firestore + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton.icon( + + /// ✅ disable saat saving + onPressed: _isSaving ? null : _saveResi, + + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + + /// ✅ loading icon + icon: _isSaving + ? const SizedBox( + width: 20, + height: 20, + child: CircularProgressIndicator( + color: Colors.white, + strokeWidth: 2, + ), + ) + : const Icon(Icons.save, color: Colors.white), + + label: Text( + _isSaving ? "Menyimpan..." : "Simpan", + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + ), + + + const SizedBox(height: 20), + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/register_view.dart b/praresi/lib/presentation/views/register_view.dart new file mode 100644 index 0000000..f9e4382 --- /dev/null +++ b/praresi/lib/presentation/views/register_view.dart @@ -0,0 +1,261 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/auth_controller.dart'; + +class RegisterView extends GetView { + RegisterView({super.key}); + + final nameC = TextEditingController(); + final emailC = TextEditingController(); + final passC = TextEditingController(); + final confirmPassC = TextEditingController(); + + // RxBool untuk toggle password + final RxBool isPassHidden = true.obs; + final RxBool isConfirmPassHidden = true.obs; + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFF42A5F5)], // biru tua → biru muda + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SingleChildScrollView( + child: Column( + children: [ + const SizedBox(height: 80), + const Icon(Icons.person_add_alt_1, size: 80, color: Colors.white), + const SizedBox(height: 10), + const Text( + "Buat Akun Baru", + style: TextStyle( + color: Colors.white, + fontSize: 26, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 30), + + // Card form register + Container( + width: size.width * 0.9, + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 5), + ) + ], + ), + child: Column( + children: [ + TextField( + controller: nameC, + decoration: InputDecoration( + labelText: "Nama Lengkap", + prefixIcon: const Icon(Icons.person_outline), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + const SizedBox(height: 15), + TextField( + controller: emailC, + decoration: InputDecoration( + labelText: "Email", + prefixIcon: const Icon(Icons.email_outlined), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + ), + ), + const SizedBox(height: 15), + + // password + Obx(() => TextField( + controller: passC, + obscureText: isPassHidden.value, + decoration: InputDecoration( + labelText: "Password", + prefixIcon: const Icon(Icons.lock_outline), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + suffixIcon: IconButton( + icon: Icon( + isPassHidden.value + ? Icons.visibility_off + : Icons.visibility, + ), + onPressed: () => + isPassHidden.value = !isPassHidden.value, + ), + ), + )), + const SizedBox(height: 15), + + // konfirmasi password + Obx(() => TextField( + controller: confirmPassC, + obscureText: isConfirmPassHidden.value, + decoration: InputDecoration( + labelText: "Konfirmasi Password", + prefixIcon: const Icon(Icons.lock_outline), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + ), + suffixIcon: IconButton( + icon: Icon( + isConfirmPassHidden.value + ? Icons.visibility_off + : Icons.visibility, + ), + onPressed: () => isConfirmPassHidden.value = + !isConfirmPassHidden.value, + ), + ), + )), + const SizedBox(height: 20), + + // Tombol Register + Obx(() { + final isLoading = controller.isLoading.value; + + return SizedBox( + width: double.infinity, + height: 50, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF1976D2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + elevation: 3, + ), + onPressed: isLoading + ? null // ⛔ disable saat loading (cegah double klik) + : () { + + // ============================== + // VALIDASI FIELD KOSONG + // ============================== + if (nameC.text.trim().isEmpty || + emailC.text.trim().isEmpty || + passC.text.trim().isEmpty || + confirmPassC.text.trim().isEmpty) { + + Get.snackbar( + "Registrasi Gagal", + "Semua field wajib diisi.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + // ============================== + // VALIDASI FORMAT EMAIL + // ============================== + if (!GetUtils.isEmail(emailC.text.trim())) { + Get.snackbar( + "Registrasi Gagal", + "Format email tidak valid.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + // ============================== + // VALIDASI PASSWORD MINIMAL + // ============================== + if (passC.text.trim().length < 6) { + Get.snackbar( + "Registrasi Gagal", + "Password minimal 6 karakter.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + // ============================== + // VALIDASI KONFIRMASI PASSWORD + // ============================== + if (passC.text.trim() != confirmPassC.text.trim()) { + Get.snackbar( + "Registrasi Gagal", + "Konfirmasi password tidak sesuai.", + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.white, + colorText: Colors.black, + ); + return; + } + + // ============================== + // JIKA SEMUA VALID, PANGGIL REGISTER + // ============================== + controller.register( + nameC.text.trim(), + emailC.text.trim(), + passC.text.trim(), + ); + }, + child: isLoading + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : const Text( + "Register", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ); + }), + + ], + ), + ), + + const SizedBox(height: 20), + TextButton( + onPressed: () => Get.back(), + child: const Text( + "Sudah punya akun? Login", + style: TextStyle(color: Colors.white), + ), + ), + ], + ), + ), + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/presentation/views/riwayat_view.dart b/praresi/lib/presentation/views/riwayat_view.dart new file mode 100644 index 0000000..23867ae --- /dev/null +++ b/praresi/lib/presentation/views/riwayat_view.dart @@ -0,0 +1,751 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/routes/app_routes.dart'; +import 'package:praresi/utils/pdf_export_daily_a4.dart'; +import 'package:praresi/utils/pdf_export_daily_a4_multi.dart'; +import 'package:praresi/utils/pdf_export_daily_a5.dart'; +import 'package:praresi/utils/pdf_export_daily_a5_multi.dart'; +import 'package:praresi/utils/pdf_export_daily_a6.dart'; +import '../controllers/riwayat_controller.dart'; + +class RiwayatView extends StatefulWidget { + const RiwayatView({super.key}); + + @override + State createState() => _RiwayatViewState(); +} + +class _RiwayatViewState extends State { + DateTime? startDate; + DateTime? endDate; + final riwayatC = Get.put(RiwayatController(), permanent: true); + + + @override + void initState() { + super.initState(); + + final now = DateTime.now(); + startDate = DateTime(now.year, now.month, 1); + endDate = DateTime(now.year, now.month + 1, 0, 23, 59, 59); + riwayatC.fetchResiData(); // 🔹 ambil data default (1 bulan terakhir) + } + + Future _selectDate(bool isStart) async { + final now = DateTime.now(); + + final picked = await showDatePicker( + context: context, + initialDate: isStart + ? (startDate ?? DateTime(now.year, now.month, 1)) + : (endDate ?? DateTime(now.year, now.month + 1, 0)), + firstDate: DateTime(2023), + lastDate: DateTime(2100), + builder: (context, child) => Theme( + data: Theme.of(context).copyWith( + colorScheme: const ColorScheme.light( + primary: Color(0xFF1976D2), + onPrimary: Colors.white, + onSurface: Colors.black, + ), + ), + child: child!, + ), + ); + + if (picked != null) { + setState(() { + if (isStart) { + startDate = DateTime(picked.year, picked.month, picked.day); + } else { + // ⏰ tambahkan jam agar mencakup full hari terakhir + endDate = DateTime(picked.year, picked.month, picked.day, 23, 59, 59); + } + }); + + // 🔹 Kalau dua-duanya sudah terisi, ambil data + if (startDate != null && endDate != null) { + riwayatC.fetchResiData(start: startDate, end: endDate); + } + } +} + + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF1976D2), Color(0xFFE3F2FD)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: SafeArea( + child: Column( + children: [ + // 🔹 Card filter tanggal + Container( + margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.1), + blurRadius: 10, + offset: const Offset(0, 4), + ), + ], + ), + child: Row( + children: [ + Expanded( + child: _dateInputCard( + label: "Mulai dari", + date: startDate, + onTap: () => _selectDate(true), + ), + ), + const SizedBox(width: 12), + Expanded( + child: _dateInputCard( + label: "Hingga", + date: endDate, + onTap: () => _selectDate(false), + ), + ), + ], + ), + ), + // 🔹 Garis pembatas putih dari kiri ke kanan + const Padding( + padding: EdgeInsets.symmetric(horizontal: 16), + child: Divider( + color: Colors.white, // warna garis + thickness: 1, // ketebalan garis + ), + ), + + // 🔹 Daftar data dari Firestore + Expanded( + child: Obx(() { + if (riwayatC.isLoading.value) { + return const Center( + child: + CircularProgressIndicator(color: Color(0xFF1976D2)), + ); + } + + if (riwayatC.dailySummary.isEmpty) { + return const Center( + child: Text( + "Belum ada data resi", + style: TextStyle(color: Colors.black54, fontSize: 16), + ), + ); + } + + return SingleChildScrollView( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 10), + child: Column( + children: riwayatC.dailySummary.map((data) { + return Padding( + padding: const EdgeInsets.only(bottom: 15), + child: _dailySummaryCard( + day: data['day'], + date: data['date'], + total: data['total'], + cod: data['cod'], + nonCod: data['nonCod'], + income: data['income'], + ), + ); + }).toList(), + ), + ); + }), + ), + ], + ), + ), + ), + ); + } + + // 🔹 Widget input tanggal + Widget _dateInputCard({ + required String label, + required DateTime? date, + required VoidCallback onTap, + }) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: Colors.grey.shade300), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(label, + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + fontWeight: FontWeight.w500, + )), + const SizedBox(height: 4), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + date == null + ? "Pilih tanggal" + : DateFormat('dd MMM yyyy', 'id_ID').format(date), + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Colors.black87, + ), + ), + const Icon(Icons.calendar_today, + color: Color(0xFF1976D2), size: 18), + ], + ), + ], + ), + ), + ); + } + + // 🔹 Widget tampilan per hari (sesuai desain kamu) + Widget _dailySummaryCard({ + required String day, + required String date, + required int total, + required int cod, + required int nonCod, + required int income, + }) { + return GestureDetector( + onTap: () async { + final controller = Get.find(); + try { + // ubah format tanggal "21 Oktober 2025" ke DateTime + final rawDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // tampilkan snackbar loading sementara + Get.snackbar( + 'Memuat', + 'Mengambil data detail...', + showProgressIndicator: true, + isDismissible: false, + snackPosition: SnackPosition.BOTTOM, + ); + + // ambil data dulu + await controller.fetchResiByDate(rawDate); + + // tutup snackbar + Get.closeAllSnackbars(); + + // navigasi ke halaman detail (pakai named route) + Get.toNamed( + AppRoutes.detailRiwayat, + arguments: { + 'day': day, + 'date': date, + }, + ); + } catch (e) { + Get.closeAllSnackbars(); + Get.snackbar('Error', 'Gagal membuka detail: $e'); + } +}, + + + child: Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(20), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: 8, + offset: const Offset(0, 5), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 🔹 Baris header: hari & tanggal + ikon print di kanan atas + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "$day, $date", + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + IconButton( + icon: const Icon(Icons.download, color: Color(0xFF1976D2)), + tooltip: "Unduh data hari ini", + onPressed: () { + _showPrintFormatDialog(context, day, date, riwayatC); + }, + ), + ], + ), + + const Divider(), + const SizedBox(height: 5), + + // 🔸 Total paket dan COD/NON-COD + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Container( + height: 90, + margin: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFF1976D2), width: 2), + borderRadius: BorderRadius.circular(14), + ), + child: Center( + child: Text( + "Total \n$total", + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: Color(0xFF1976D2), + ), + ), + ), + ), + ), + Expanded( + flex: 2, + child: Column( + children: [ + // 🔹 Card COD + InkWell( + onTap: () async { + final rawDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + final pendapatan = + await riwayatC.getPendapatanHarian(rawDate); + final totalCod = pendapatan['cod'] ?? 0.0; + + Get.defaultDialog( + title: "Pendapatan COD", + titleStyle: const TextStyle( + color: Color(0xFFFF9800), + fontWeight: FontWeight.bold, + fontSize: 18, + ), + contentPadding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 16), + radius: 14, + content: Column( + children: [ + Icon(Icons.local_shipping, + color: const Color(0xFFFF9800), size: 48), + const SizedBox(height: 12), + Text( + "Tanggal: ${DateFormat('d MMMM yyyy', 'id_ID').format(rawDate)}", + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 8), + Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(totalCod)}", + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Color(0xFFFF9800), + ), + ), + ], + ), + confirm: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFFF9800), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + padding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 10), + ), + onPressed: () => Get.back(), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ); + }, + child: Container( + height: 40, + margin: const EdgeInsets.only(bottom: 10), + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFFFF9800), width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "COD: $cod", + style: const TextStyle( + color: Color(0xFFFF9800), + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ), + ), + + // 🔹 Card Non COD + InkWell( + onTap: () async { + final rawDate = DateFormat('d MMMM yyyy', 'id_ID').parse(date); + final pendapatan = + await riwayatC.getPendapatanHarian(rawDate); + final totalNonCod = pendapatan['nonCod'] ?? 0.0; + + Get.defaultDialog( + title: "Pendapatan Non COD", + titleStyle: const TextStyle( + color: Color(0xFF4CAF50), + fontWeight: FontWeight.bold, + fontSize: 18, + ), + contentPadding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 16), + radius: 14, + content: Column( + children: [ + Icon(Icons.account_balance_wallet, + color: const Color(0xFF4CAF50), size: 48), + const SizedBox(height: 12), + Text( + "Tanggal: ${DateFormat('d MMMM yyyy', 'id_ID').format(rawDate)}", + style: const TextStyle(fontSize: 14), + ), + const SizedBox(height: 8), + Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(totalNonCod)}", + style: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Color(0xFF4CAF50), + ), + ), + ], + ), + confirm: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF4CAF50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12), + ), + padding: const EdgeInsets.symmetric( + horizontal: 20, vertical: 10), + ), + onPressed: () => Get.back(), + child: const Text( + "Tutup", + style: TextStyle(color: Colors.white), + ), + ), + ); + }, + child: Container( + height: 40, + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFF4CAF50), width: 2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "Non COD: $nonCod", + style: const TextStyle( + color: Color(0xFF4CAF50), + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ), + + + + const SizedBox(height: 10), + + // 🔸 Pendapatan + Container( + width: double.infinity, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey.shade400, width: 1.2), + borderRadius: BorderRadius.circular(12), + ), + child: Center( + child: Text( + "Rp ${NumberFormat('#,###', 'id_ID').format(income)}", + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.black87, + ), + ), + ), + ), + ], + ), + ), + ); + } + + + void _showPrintFormatDialog(BuildContext context, String day, String date, dynamic controller,) { + Get.bottomSheet( + Container( + padding: const EdgeInsets.all(20), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + child: Wrap( + children: [ + const Center( + child: Text( + "Pilih Format Unduh", + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ), + const SizedBox(height: 20), + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A4"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Export PDF (1 halaman = 1 data) + final path = await PdfExportDailyA4_onedata.exportDailyToA4_onedata( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A5"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal "25 Oktober 2025" ke DateTime + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Cetak ke PDF format A4 + final path = await PdfExportDailyA5_onedata.exportDailyToA5_onedata( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A6"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal "25 Oktober 2025" ke DateTime + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Cetak ke PDF format A4 + final path = await PdfExportDailyA6.exportDailyToA6( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mengunduh data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A4 (Multi)"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal "25 Oktober 2025" ke DateTime + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Cetak ke PDF format A4 + final path = await PdfExportDailyA4.exportDailyToA4( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + + + + ListTile( + leading: const Icon(Icons.picture_as_pdf, color: Colors.blue), + title: const Text("Format A5 (Multi)"), + onTap: () async { + Get.back(); + + try { + // 🔹 Parse tanggal "25 Oktober 2025" ke DateTime + final parsedDate = + DateFormat('d MMMM yyyy', 'id_ID').parse(date); + + // 🔹 Ambil data harian + await controller.fetchResiByDate(parsedDate); + + // 🔹 Cetak ke PDF format A4 + final path = await PdfExportDailyA5.exportDailyToA5( + controller.dailyDetail, + parsedDate, + ); + + Get.snackbar( + "Berhasil", + "PDF disimpan di: $path", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.green.shade100, + ); + } catch (e) { + Get.snackbar( + "Error", + "Gagal mencetak data: $e", + snackPosition: SnackPosition.BOTTOM, + backgroundColor: Colors.red.shade100, + ); + } + }, + ), + + + + + ], + ), + ), + ); + } + +} diff --git a/praresi/lib/presentation/views/splash_view.dart b/praresi/lib/presentation/views/splash_view.dart new file mode 100644 index 0000000..706026f --- /dev/null +++ b/praresi/lib/presentation/views/splash_view.dart @@ -0,0 +1,122 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'dart:async'; + +class SplashView extends StatefulWidget { + const SplashView({super.key}); + + @override + State createState() => _SplashViewState(); +} + +class _SplashViewState extends State + with SingleTickerProviderStateMixin { + + late AnimationController _controller; + late Animation _fadeAnim; + late Animation _scaleAnim; + + @override + void initState() { + super.initState(); + + /// ✅ Animation setup + _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 1500), + ); + + _fadeAnim = Tween(begin: 0, end: 1).animate( + CurvedAnimation(parent: _controller, curve: Curves.easeIn), + ); + + _scaleAnim = Tween(begin: 0.7, end: 1).animate( + CurvedAnimation( + parent: _controller, + curve: Curves.easeOutBack, + ), + ); + + _controller.forward(); + + _navigate(); + } + + void _navigate() { + Timer(const Duration(seconds: 2), () { + final user = FirebaseAuth.instance.currentUser; + + if (user != null) { + Get.offAllNamed('/home'); + } else { + Get.offAllNamed('/login'); + } + }); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final size = MediaQuery.of(context).size; + + return Scaffold( + body: Container( + width: size.width, + height: size.height, + decoration: const BoxDecoration( + gradient: LinearGradient( + colors: [ + Color(0xFF1976D2), + Color(0xFF42A5F5), + ], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + ), + child: Center( + child: FadeTransition( + opacity: _fadeAnim, + child: ScaleTransition( + scale: _scaleAnim, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + + /// ✅ LOGO DARI ASSETS + Image.asset( + "assets/images/praresi_logo.png", + width: 140, + ), + + const SizedBox(height: 24), + + const Text( + "PraResi", + style: TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, + letterSpacing: 1.2, + ), + ), + + const SizedBox(height: 30), + + const CircularProgressIndicator( + color: Colors.white, + ), + ], + ), + ), + ), + ), + ), + ); + } +} diff --git a/praresi/lib/services/bubble_services.dart b/praresi/lib/services/bubble_services.dart new file mode 100644 index 0000000..767ec57 --- /dev/null +++ b/praresi/lib/services/bubble_services.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_overlay_window_sdk34/flutter_overlay_window_sdk34.dart'; + +class BubbleService { + static final BubbleService _instance = BubbleService._internal(); + factory BubbleService() => _instance; + BubbleService._internal(); + + final ValueNotifier isActive = ValueNotifier(false); + + Future show() async { + isActive.value = true; + + // ✅ Cek izin overlay + final granted = await FlutterOverlayWindow.isPermissionGranted(); + if (granted != true) { + final requestGranted = await FlutterOverlayWindow.requestPermission(); + if (requestGranted != true) return; + } + + // ✅ Tampilkan overlay bubble + await FlutterOverlayWindow.showOverlay( + height: 100, + width: 100, + alignment: OverlayAlignment.topRight, + enableDrag: true, + positionGravity: PositionGravity.auto, + overlayTitle: "Bubble Chat", + overlayContent: "Bubble aktif", + startPosition:const OverlayPosition(100, 100), + // flag: OverlayFlag.focusPointer, // ✅ tambahkan ini + ); + } + + // ✅ Fungsi untuk mengubah ukuran bubble + Future resize(int width, int height, {bool animated = true}) async { + try { + await FlutterOverlayWindow.resizeOverlay(width, height, animated); + } catch (e) { + debugPrint("Resize error: $e"); + } + } + + + + // ✅ Sembunyikan overlay + Future hide() async { + isActive.value = false; + await FlutterOverlayWindow.closeOverlay(); + } + + + + // untuk method channel +} diff --git a/praresi/lib/services/bubble_widget.dart b/praresi/lib/services/bubble_widget.dart new file mode 100644 index 0000000..23f286c --- /dev/null +++ b/praresi/lib/services/bubble_widget.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:praresi/services/bubble_services.dart'; + +class BubbleWidget extends StatelessWidget { + const BubbleWidget({super.key}); + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder( + valueListenable: BubbleService().isActive, + builder: (context, isActive, _) { + if (!isActive) return const SizedBox.shrink(); + + return Align( + alignment: Alignment.bottomRight, + child: Padding( + padding: const EdgeInsets.all(16), + child: GestureDetector( + onTap: () { + showDialog( + context: context, + builder: (ctx) { + final controller = TextEditingController(); + return AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12)), + title: const Text('Input / Salin Alamat'), + content: TextField( + controller: controller, + maxLines: 3, + decoration: const InputDecoration( + hintText: 'Masukkan teks di sini...', + border: OutlineInputBorder(), + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(ctx), + child: const Text('Tutup'), + ), + ElevatedButton( + onPressed: () { + final text = controller.text.trim(); + if (text.isNotEmpty) { + ScaffoldMessenger.of(ctx).showSnackBar( + SnackBar(content: Text('Teks dikirim: $text')), + ); + } + Navigator.pop(ctx); + }, + child: const Text('Kirim'), + ), + ], + ); + }, + ); + }, + child: Container( + width: 60, + height: 60, + decoration: const BoxDecoration( + color: Colors.blueAccent, + shape: BoxShape.circle, + boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 8)], + ), + child: const Icon(Icons.chat_bubble, color: Colors.white, size: 32), + ), + ), + ), + ); + }, + ); + } +} \ No newline at end of file diff --git a/praresi/lib/services/resi_input_handler.dart b/praresi/lib/services/resi_input_handler.dart new file mode 100644 index 0000000..10b84ff --- /dev/null +++ b/praresi/lib/services/resi_input_handler.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:praresi/presentation/controllers/resi_controller.dart'; +import 'package:firebase_auth/firebase_auth.dart'; + +class ResiInputHandler { + static final ResiController _controller = Get.find(); + static final FirebaseAuth _auth = FirebaseAuth.instance; + + /// Fungsi untuk menerima input dari bubble + static Future saveResiFromBubble(String inputText) async { + final user = _auth.currentUser; + if (user == null) { + Get.snackbar( + 'Gagal', + 'User belum login!', + backgroundColor: Colors.red, + colorText: Colors.white, + ); + return; + } + + if (inputText.trim().isEmpty) { + Get.snackbar( + 'Peringatan', + 'Tidak ada teks untuk disimpan!', + backgroundColor: Colors.orange, + colorText: Colors.white, + ); + return; + } + + await _controller.saveResi(inputText.trim(), user.uid); + + Get.snackbar( + 'Berhasil', + 'Data berhasil disimpan ke Firestore!', + backgroundColor: Colors.green, + colorText: Colors.white, + ); + } +} diff --git a/praresi/lib/utils/excel_exporter.dart b/praresi/lib/utils/excel_exporter.dart new file mode 100644 index 0000000..63217e1 --- /dev/null +++ b/praresi/lib/utils/excel_exporter.dart @@ -0,0 +1,83 @@ +import 'dart:io'; +import 'package:excel/excel.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:intl/intl.dart'; + +class ExcelExporter { + static Future exportPelangganToExcel( + List> data) async { + final excel = Excel.createExcel(); + final sheet = excel['Data Pelanggan']; + + // Header kolom + final headers = [ + TextCellValue('Nama Penerima'), + TextCellValue('No. WA'), + TextCellValue('Alamat'), + TextCellValue('Kota'), + TextCellValue('Provinsi'), + TextCellValue('Barang'), + TextCellValue('Total Nominal'), + TextCellValue('Tanggal Dibuat'), + ]; + sheet.appendRow(headers); + + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + // Isi data + for (final item in data) { + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final row = [ + TextCellValue(item['penerima']?.toString() ?? '-'), + TextCellValue(item['no_wa']?.toString() ?? '-'), + TextCellValue(item['alamat']?.toString() ?? '-'), + TextCellValue(item['kota']?.toString() ?? '-'), + TextCellValue(item['provinsi']?.toString() ?? '-'), + TextCellValue(item['barang']?.toString() ?? '-'), + TextCellValue(item['totalNominal']?.toString() ?? '0'), + TextCellValue(createdAt), + ]; + + sheet.appendRow(row); + } + + // 🔹 Tentukan folder penyimpanan + Directory? saveDir; + + if (Platform.isAndroid) { + // Folder Download Android + saveDir = Directory('/storage/emulated/0/Download'); + } else if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) { + // Folder Downloads desktop + saveDir = await getDownloadsDirectory(); + } else if (Platform.isIOS) { + // iOS tidak punya folder Download, pakai dokumen aplikasi + saveDir = await getApplicationDocumentsDirectory(); + } else { + throw Exception("Platform tidak didukung"); + } + + // 🔸 Pastikan folder valid dan ada + if (saveDir == null) { + throw Exception("Folder penyimpanan tidak ditemukan."); + } + + if (!await saveDir.exists()) { + await saveDir.create(recursive: true); + } + + // 🔸 Nama file dengan timestamp + final filePath = + '${saveDir.path}/Data_Pelanggan_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.xlsx'; + + // Simpan file + final bytes = excel.encode(); + final file = File(filePath); + await file.writeAsBytes(bytes!, flush: true); + + return filePath; + } +} diff --git a/praresi/lib/utils/pdf_export_daily_a4.dart b/praresi/lib/utils/pdf_export_daily_a4.dart new file mode 100644 index 0000000..32cb87f --- /dev/null +++ b/praresi/lib/utils/pdf_export_daily_a4.dart @@ -0,0 +1,164 @@ +import 'dart:io'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:pdf/pdf.dart'; +import 'package:pdf/widgets.dart' as pw; + +class PdfExportDailyA4 { + /// Cetak seluruh data resi dalam 1 hari ke format A4 (maks 4 resi per halaman) + static Future exportDailyToA4( + List> items, + DateTime selectedDate, + ) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + // Bagi data menjadi grup per 4 item + final chunkedItems = >>[]; + for (var i = 0; i < items.length; i += 4) { + chunkedItems.add(items.skip(i).take(4).toList()); + } + + for (final pageItems in chunkedItems) { + pdf.addPage( + pw.Page( + pageFormat: PdfPageFormat.a4, + margin: const pw.EdgeInsets.all(20), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + // 🔹 Loop 4 data per halaman + ...pageItems.asMap().entries.map((entry) { + final index = entry.key + 1; + final item = entry.value; + + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final totalNominal = + num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + return pw.Container( + margin: const pw.EdgeInsets.only(bottom: 10), + padding: const pw.EdgeInsets.all(8), + decoration: pw.BoxDecoration( + border: pw.Border.all(color: PdfColors.grey700, width: 0.8), + borderRadius: pw.BorderRadius.circular(6), + ), + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, + children: [ + pw.Text( + 'DATA PENGIRIMAN #$index', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 11, + ), + ), + pw.Text( + createdAt, + style: const pw.TextStyle(fontSize: 9), + ), + ], + ), + pw.SizedBox(height: 6), + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + pw.SizedBox(height: 5), + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 10, + ), + ), + pw.SizedBox(height: 3), + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + ], + ), + ); + }).toList(), + + pw.Spacer(), + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 9), + ), + ), + ], + ); + }, + ), + ); + } + + // 🔹 Simpan ke folder Download + Directory? downloadDir; + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Resi_Harian_A4_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.pdf'; + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// 🔹 Komponen pembantu untuk membuat baris label : value + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 1.2), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 100, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 9.5, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 9.5), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/lib/utils/pdf_export_daily_a4_multi.dart b/praresi/lib/utils/pdf_export_daily_a4_multi.dart new file mode 100644 index 0000000..8d30bf9 --- /dev/null +++ b/praresi/lib/utils/pdf_export_daily_a4_multi.dart @@ -0,0 +1,156 @@ +import 'dart:io'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:pdf/pdf.dart'; +import 'package:pdf/widgets.dart' as pw; + +class PdfExportDailyA4_onedata { + /// Cetak seluruh data resi dalam 1 hari ke format A4 (1 resi per halaman) + static Future exportDailyToA4_onedata( + List> items, + DateTime selectedDate, + ) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + for (var i = 0; i < items.length; i++) { + final item = items[i]; + + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final totalNominal = + num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + pdf.addPage( + pw.Page( + pageFormat: PdfPageFormat.a4, + margin: const pw.EdgeInsets.all(30), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + + /// HEADER + pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, + children: [ + pw.Text( + 'DATA PENGIRIMAN #${i + 1}', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 18, + ), + ), + pw.Text( + createdAt, + style: const pw.TextStyle(fontSize: 12), + ), + ], + ), + + pw.SizedBox(height: 10), + pw.Divider(), + + /// DATA PENERIMA + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + + pw.SizedBox(height: 20), + + /// DATA TOKO + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 16, + ), + ), + + pw.Divider(), + + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + + pw.Spacer(), + + /// FOOTER + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 10), + ), + ), + ], + ); + }, + ), + ); + } + + /// Simpan file + Directory? downloadDir; + + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Resi_Harian_A4_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.pdf'; + + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// Komponen baris label : value + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 4), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 160, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 12, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 12), + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/utils/pdf_export_daily_a5.dart b/praresi/lib/utils/pdf_export_daily_a5.dart new file mode 100644 index 0000000..cc1f807 --- /dev/null +++ b/praresi/lib/utils/pdf_export_daily_a5.dart @@ -0,0 +1,163 @@ +import 'dart:io'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:pdf/pdf.dart'; +import 'package:pdf/widgets.dart' as pw; + +class PdfExportDailyA5 { + /// Cetak seluruh data resi dalam 1 hari ke format A5 (maks 3 resi per halaman) + static Future exportDailyToA5( + List> items, + DateTime selectedDate, + ) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + // 🔹 Bagi data menjadi grup per 3 item + final chunkedItems = >>[]; + for (var i = 0; i < items.length; i += 3) { + chunkedItems.add(items.skip(i).take(3).toList()); + } + + for (final pageItems in chunkedItems) { + pdf.addPage( + pw.Page( + pageFormat: PdfPageFormat.a5, + margin: const pw.EdgeInsets.all(12), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + ...pageItems.asMap().entries.map((entry) { + final index = entry.key + 1; + final item = entry.value; + + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final totalNominal = + num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + return pw.Container( + margin: const pw.EdgeInsets.only(bottom: 6), + padding: const pw.EdgeInsets.all(5), + decoration: pw.BoxDecoration( + border: pw.Border.all(color: PdfColors.grey700, width: 0.6), + borderRadius: pw.BorderRadius.circular(4), + ), + child: pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, + children: [ + pw.Text( + 'DATA PENGIRIMAN #$index', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 9, + ), + ), + pw.Text( + createdAt, + style: const pw.TextStyle(fontSize: 7.5), + ), + ], + ), + pw.SizedBox(height: 3), + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + pw.SizedBox(height: 3), + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 8.5, + ), + ), + pw.SizedBox(height: 2), + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + ], + ), + ); + }).toList(), + + pw.Spacer(), + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 7.5), + ), + ), + ], + ); + }, + ), + ); + } + + // 🔹 Simpan ke folder Download + Directory? downloadDir; + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Resi_Harian_A5_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.pdf'; + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// 🔹 Komponen pembantu untuk membuat baris label : value + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 0.6), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 80, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 7.8, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 7.8), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/lib/utils/pdf_export_daily_a5_multi.dart b/praresi/lib/utils/pdf_export_daily_a5_multi.dart new file mode 100644 index 0000000..dbc9968 --- /dev/null +++ b/praresi/lib/utils/pdf_export_daily_a5_multi.dart @@ -0,0 +1,156 @@ +import 'dart:io'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:pdf/pdf.dart'; +import 'package:pdf/widgets.dart' as pw; + +class PdfExportDailyA5_onedata { + /// Cetak seluruh data resi dalam 1 hari ke format A5 (1 resi per halaman) + static Future exportDailyToA5_onedata( + List> items, + DateTime selectedDate, + ) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + for (var i = 0; i < items.length; i++) { + final item = items[i]; + + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final totalNominal = + num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + pdf.addPage( + pw.Page( + pageFormat: PdfPageFormat.a5, + margin: const pw.EdgeInsets.all(20), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + + /// HEADER + pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, + children: [ + pw.Text( + 'DATA PENGIRIMAN #${i + 1}', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 14, + ), + ), + pw.Text( + createdAt, + style: const pw.TextStyle(fontSize: 10), + ), + ], + ), + + pw.SizedBox(height: 6), + pw.Divider(), + + /// DATA PENERIMA + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + + pw.SizedBox(height: 10), + + /// DATA TOKO + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 12, + ), + ), + + pw.Divider(), + + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + + pw.Spacer(), + + /// FOOTER + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 9), + ), + ), + ], + ); + }, + ), + ); + } + + /// Simpan ke folder Download + Directory? downloadDir; + + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Resi_Harian_A5_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.pdf'; + + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// Komponen label : value + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 2), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 120, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 10, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 10), + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/praresi/lib/utils/pdf_export_daily_a6.dart b/praresi/lib/utils/pdf_export_daily_a6.dart new file mode 100644 index 0000000..272c7be --- /dev/null +++ b/praresi/lib/utils/pdf_export_daily_a6.dart @@ -0,0 +1,140 @@ +import 'dart:io'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:pdf/pdf.dart'; +import 'package:pdf/widgets.dart' as pw; + +class PdfExportDailyA6 { + /// Cetak seluruh data resi dalam 1 hari ke format A6 (1 resi per halaman) + static Future exportDailyToA6( + List> items, + DateTime selectedDate, + ) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + + for (var i = 0; i < items.length; i++) { + final item = items[i]; + + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + final totalNominal = + num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + pdf.addPage( + pw.Page( + pageFormat: PdfPageFormat.a6, + margin: const pw.EdgeInsets.all(10), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Row( + mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, + children: [ + pw.Text( + 'DATA PENGIRIMAN #${i + 1}', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 8.5, + ), + ), + pw.Text( + createdAt, + style: const pw.TextStyle(fontSize: 7), + ), + ], + ), + pw.Divider(thickness: 0.5), + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + pw.SizedBox(height: 3), + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 8, + ), + ), + pw.Divider(thickness: 0.5), + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + pw.Spacer(), + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 7), + ), + ), + ], + ); + }, + ), + ); + } + + // 🔹 Simpan ke folder Download + Directory? downloadDir; + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Resi_Harian_A6_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}.pdf'; + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// 🔹 Komponen pembantu untuk membuat baris label : value + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 0.5), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 75, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 7.2, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 7.2), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/lib/utils/pdf_exporter.dart b/praresi/lib/utils/pdf_exporter.dart new file mode 100644 index 0000000..268bcf9 --- /dev/null +++ b/praresi/lib/utils/pdf_exporter.dart @@ -0,0 +1,142 @@ +import 'dart:io'; +import 'package:pdf/widgets.dart' as pw; +import 'package:pdf/pdf.dart'; +import 'package:intl/intl.dart'; +import 'package:path_provider/path_provider.dart'; + +class PdfExporter { + /// 🔹 Ekspor satu data pelanggan ke file PDF + static Future exportSingleItemToPdf( + Map item, { + String format = 'A6', // 🔹 default A6 + }) async { + final pdf = pw.Document(); + final dateFormat = DateFormat('dd MMM yyyy, HH:mm', 'id_ID'); + final createdAt = item['created_at'] != null + ? dateFormat.format(item['created_at']) + : '-'; + + // Tentukan ukuran halaman berdasarkan format + final pageFormat = switch (format.toUpperCase()) { + 'A4' => PdfPageFormat.a4, + 'A5' => PdfPageFormat.a5, + _ => PdfPageFormat.a6, // default A6 + }; + + // Pastikan total nominal berupa angka + final totalNominal = num.tryParse(item['total']?.toString() ?? '0') ?? 0; + + // Ambil data toko (jika ada) + final store = item['store'] ?? {}; + final namaToko = store['namaToko'] ?? '-'; + final alamatToko = store['alamat'] ?? '-'; + final noHpToko = store['noHp'] ?? '-'; + final noRegistrasi = store['noRegistrasi'] ?? '-'; + final keteranganToko = store['keterangan'] ?? '-'; + + pdf.addPage( + pw.Page( + pageFormat: pageFormat, // 🔹 gunakan ukuran halaman sesuai format + margin: const pw.EdgeInsets.all(12), + build: (pw.Context context) { + return pw.Column( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Center( + child: pw.Text( + 'DATA PENGIRIMAN', + style: pw.TextStyle( + fontSize: 14, + fontWeight: pw.FontWeight.bold, + ), + ), + ), + pw.SizedBox(height: 6), + _buildRow('Nama Penerima', item['penerima']), + _buildRow('No. WA', item['no_wa']), + _buildRow('Alamat', item['alamat']), + _buildRow('Kota', item['kota']), + _buildRow('Provinsi', item['provinsi']), + _buildRow('Barang', item['barang']), + _buildRow( + 'Total Nominal', + 'Rp ${NumberFormat('#,##0', 'id_ID').format(totalNominal)}', + ), + _buildRow('Pembayaran', item['pembayaran']), + _buildRow('Tanggal Dibuat', createdAt), + pw.SizedBox(height: 6), + pw.Divider(thickness: 0.8), + + pw.SizedBox(height: 4), + pw.Text( + 'DATA TOKO PENGIRIM', + style: pw.TextStyle( + fontSize: 12, + fontWeight: pw.FontWeight.bold, + ), + ), + pw.SizedBox(height: 4), + _buildRow('Nama Toko', namaToko), + _buildRow('Alamat Toko', alamatToko), + _buildRow('No. HP Toko', noHpToko), + _buildRow('No. Registrasi', noRegistrasi), + _buildRow('Keterangan', keteranganToko), + + pw.Spacer(), + pw.Center( + child: pw.Text( + 'Dicetak otomatis oleh sistem Praresi', + style: const pw.TextStyle(fontSize: 8), + ), + ), + ], + ); + }, + ), + ); + + // 🔹 Simpan ke folder Download (Android) + Directory? downloadDir; + if (Platform.isAndroid) { + downloadDir = Directory('/storage/emulated/0/Download'); + } else { + downloadDir = await getApplicationDocumentsDirectory(); + } + + final filePath = + '${downloadDir.path}/Data_Pengiriman_${DateFormat('yyyyMMdd_HHmmss').format(DateTime.now())}_$format.pdf'; + + final file = File(filePath); + await file.writeAsBytes(await pdf.save()); + + return filePath; + } + + /// 🔹 Komponen baris label dan isi + static pw.Widget _buildRow(String label, dynamic value) { + return pw.Padding( + padding: const pw.EdgeInsets.symmetric(vertical: 1.5), + child: pw.Row( + crossAxisAlignment: pw.CrossAxisAlignment.start, + children: [ + pw.Container( + width: 90, + child: pw.Text( + label, + style: pw.TextStyle( + fontWeight: pw.FontWeight.bold, + fontSize: 9.5, + ), + ), + ), + pw.Expanded( + child: pw.Text( + value?.toString() ?? '-', + style: const pw.TextStyle(fontSize: 9.5), + ), + ), + ], + ), + ); + } +} diff --git a/praresi/linux/.gitignore b/praresi/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/praresi/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/praresi/linux/CMakeLists.txt b/praresi/linux/CMakeLists.txt new file mode 100644 index 0000000..2c205af --- /dev/null +++ b/praresi/linux/CMakeLists.txt @@ -0,0 +1,145 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "praresi") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.praresi") + +# 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) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/praresi/linux/flutter/CMakeLists.txt b/praresi/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/praresi/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/praresi/linux/flutter/generated_plugin_registrant.cc b/praresi/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..64a0ece --- /dev/null +++ b/praresi/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/praresi/linux/flutter/generated_plugin_registrant.h b/praresi/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/praresi/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/praresi/linux/flutter/generated_plugins.cmake b/praresi/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2db3c22 --- /dev/null +++ b/praresi/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/praresi/linux/main.cc b/praresi/linux/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/praresi/linux/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/praresi/linux/my_application.cc b/praresi/linux/my_application.cc new file mode 100644 index 0000000..8a16279 --- /dev/null +++ b/praresi/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "praresi"); + 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, "praresi"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements 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_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/praresi/linux/my_application.h b/praresi/linux/my_application.h new file mode 100644 index 0000000..72271d5 --- /dev/null +++ b/praresi/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/praresi/macos/.gitignore b/praresi/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/praresi/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/praresi/macos/Flutter/Flutter-Debug.xcconfig b/praresi/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/praresi/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/praresi/macos/Flutter/Flutter-Release.xcconfig b/praresi/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/praresi/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/praresi/macos/Flutter/GeneratedPluginRegistrant.swift b/praresi/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..b602492 --- /dev/null +++ b/praresi/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,22 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import cloud_firestore +import connectivity_plus +import file_selector_macos +import firebase_auth +import firebase_core +import path_provider_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) + ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) + FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) +} diff --git a/praresi/macos/Runner.xcodeproj/project.pbxproj b/praresi/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..28ef999 --- /dev/null +++ b/praresi/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,695 @@ +// !$*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 /* praresi.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "praresi.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 /* praresi.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 /* praresi.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1430; + 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.praresi.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/praresi.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/praresi"; + }; + 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.praresi.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/praresi.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/praresi"; + }; + 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.praresi.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/praresi.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/praresi"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/praresi/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/praresi/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/praresi/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/praresi/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/praresi/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..16fa4a1 --- /dev/null +++ b/praresi/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/macos/Runner.xcworkspace/contents.xcworkspacedata b/praresi/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/praresi/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/praresi/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/praresi/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/praresi/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/praresi/macos/Runner/AppDelegate.swift b/praresi/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/praresi/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/praresi/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/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/praresi/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/praresi/macos/Runner/Base.lproj/MainMenu.xib b/praresi/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/praresi/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/praresi/macos/Runner/Configs/AppInfo.xcconfig b/praresi/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..7313c39 --- /dev/null +++ b/praresi/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 = praresi + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.praresi + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. diff --git a/praresi/macos/Runner/Configs/Debug.xcconfig b/praresi/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/praresi/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/praresi/macos/Runner/Configs/Release.xcconfig b/praresi/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/praresi/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/praresi/macos/Runner/Configs/Warnings.xcconfig b/praresi/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/praresi/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/praresi/macos/Runner/DebugProfile.entitlements b/praresi/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/praresi/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/praresi/macos/Runner/Info.plist b/praresi/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/praresi/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/praresi/macos/Runner/MainFlutterWindow.swift b/praresi/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/praresi/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/praresi/macos/Runner/Release.entitlements b/praresi/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/praresi/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/praresi/macos/RunnerTests/RunnerTests.swift b/praresi/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..5418c9f --- /dev/null +++ b/praresi/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +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/praresi/pubspec.lock b/praresi/pubspec.lock new file mode 100644 index 0000000..b32b59b --- /dev/null +++ b/praresi/pubspec.lock @@ -0,0 +1,834 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: "4eec93681221723a686ad580c2e7d960e1017cf1a4e0a263c2573c2c6b0bf5cd" + url: "https://pub.dev" + source: hosted + version: "1.3.25" + archive: + dependency: transitive + description: + name: archive + sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d + url: "https://pub.dev" + source: hosted + version: "3.6.1" + args: + dependency: transitive + description: + name: args + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + barcode: + dependency: transitive + description: + name: barcode + sha256: "7b6729c37e3b7f34233e2318d866e8c48ddb46c1f7ad01ff7bb2a8de1da2b9f4" + url: "https://pub.dev" + source: hosted + version: "2.2.9" + bidi: + dependency: transitive + description: + name: bidi + sha256: "77f475165e94b261745cf1032c751e2032b8ed92ccb2bf5716036db79320637d" + url: "https://pub.dev" + source: hosted + version: "2.0.13" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 + url: "https://pub.dev" + source: hosted + version: "0.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + sha256: "31cfa4d65d6e9ea837234fffe121304034c30c9214c06207b4a35867e3757900" + url: "https://pub.dev" + source: hosted + version: "4.15.8" + cloud_firestore_platform_interface: + dependency: transitive + description: + name: cloud_firestore_platform_interface + sha256: a0097a26569b015faf8142e159e855241609ea9a1738b5fd1c40bfe8411b41a0 + url: "https://pub.dev" + source: hosted + version: "6.1.9" + cloud_firestore_web: + dependency: transitive + description: + name: cloud_firestore_web + sha256: ed680ece29a5750985119c09cdc276b460c3a2fa80e8c12f9b7241f6b4a7ca16 + url: "https://pub.dev" + source: hosted + version: "3.10.8" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + connectivity_plus: + dependency: "direct main" + description: + name: connectivity_plus + sha256: db7a4e143dc72cc3cb2044ef9b052a7ebfe729513e6a82943bc3526f784365b8 + url: "https://pub.dev" + source: hosted + version: "6.0.3" + connectivity_plus_platform_interface: + dependency: transitive + description: + name: connectivity_plus_platform_interface + sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: fedaadfa3a6996f75211d835aaeb8fede285dae94262485698afd832371b9a5e + url: "https://pub.dev" + source: hosted + version: "0.3.3+8" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + dash_bubble: + dependency: "direct main" + description: + name: dash_bubble + sha256: a331ac641bf4cc42d75c9501566a88e9ce9a64a54cacf04e6c05f974328c895a + url: "https://pub.dev" + source: hosted + version: "2.0.0" + dbus: + dependency: transitive + description: + name: dbus + sha256: d0c98dcd4f5169878b6cf8f6e0a52403a9dff371a3e2f019697accbf6f44a270 + url: "https://pub.dev" + source: hosted + version: "0.7.12" + equatable: + dependency: transitive + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" + excel: + dependency: "direct main" + description: + name: excel + sha256: "1a15327dcad260d5db21d1f6e04f04838109b39a2f6a84ea486ceda36e468780" + url: "https://pub.dev" + source: hosted + version: "4.0.6" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" + url: "https://pub.dev" + source: hosted + version: "0.9.2+1" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385 + url: "https://pub.dev" + source: hosted + version: "0.9.4" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b + url: "https://pub.dev" + source: hosted + version: "2.6.2" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "2ad726953f6e8affbc4df8dc78b77c3b4a060967a291e528ef72ae846c60fb69" + url: "https://pub.dev" + source: hosted + version: "0.9.3+2" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + sha256: "17b841e1b000c3441b8ffceca88f468e078d0443db9643e77541bdfb7a3fd16b" + url: "https://pub.dev" + source: hosted + version: "4.17.8" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + sha256: f294ceef40409a36c819a14280ca864fe487b44033e5276443377c66cb448310 + url: "https://pub.dev" + source: hosted + version: "7.1.8" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + sha256: "1f231da900fe7ff9f2974f8adcbdb3363c410c24725978afa5dc33e1e7e62e06" + url: "https://pub.dev" + source: hosted + version: "5.9.8" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "53316975310c8af75a96e365f9fccb67d1c544ef0acdbf0d88bbe30eedd1c4f9" + url: "https://pub.dev" + source: hosted + version: "2.27.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: "8bcfad6d7033f5ea951d15b867622a824b13812178bfec0c779b9d81de011bbb" + url: "https://pub.dev" + source: hosted + version: "5.4.2" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: c8e1d59385eee98de63c92f961d2a7062c5d9a65e7f45bdc7f1b0b205aab2492 + url: "https://pub.dev" + source: hosted + version: "2.11.5" + fl_chart: + dependency: "direct main" + description: + name: fl_chart + sha256: d0f0d49112f2f4b192481c16d05b6418bd7820e021e265a3c22db98acf7ed7fb + url: "https://pub.dev" + source: hosted + version: "0.68.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_launcher_icons: + dependency: "direct dev" + description: + name: flutter_launcher_icons + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" + source: hosted + version: "0.13.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_map: + dependency: "direct main" + description: + name: flutter_map + sha256: cda8d72135b697f519287258b5294a57ce2f2a5ebf234f0e406aad4dc14c9399 + url: "https://pub.dev" + source: hosted + version: "6.1.0" + flutter_overlay_window_sdk34: + dependency: "direct main" + description: + name: flutter_overlay_window_sdk34 + sha256: a4eb64319406ab96d2518662f0c97d224eeb6263c0a2575053c3a92a6f725538 + url: "https://pub.dev" + source: hosted + version: "0.4.7" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" + url: "https://pub.dev" + source: hosted + version: "2.0.19" + 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" + get: + dependency: "direct main" + description: + name: get + sha256: e4e7335ede17452b391ed3b2ede016545706c01a02292a6c97619705e7d2a85e + url: "https://pub.dev" + source: hosted + version: "4.6.6" + google_mlkit_commons: + dependency: transitive + description: + name: google_mlkit_commons + sha256: "046586b381cdd139f7f6a05ad6998f7e339d061bd70158249907358394b5f496" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + google_mlkit_text_recognition: + dependency: "direct main" + description: + name: google_mlkit_text_recognition + sha256: d484de2a10961a6f0ff8b54cc92b71bfbb0e65509be0903edca0e1f9256ca4c2 + url: "https://pub.dev" + source: hosted + version: "0.11.0" + http: + dependency: transitive + description: + name: http + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + url: "https://pub.dev" + source: hosted + version: "1.2.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + image: + dependency: transitive + description: + name: image + sha256: f31d52537dc417fdcde36088fdf11d191026fd5e4fae742491ebd40e5a8bea7d + url: "https://pub.dev" + source: hosted + version: "4.3.0" + image_cropper: + dependency: "direct main" + description: + name: image_cropper + sha256: f4bad5ed2dfff5a7ce0dfbad545b46a945c702bb6182a921488ef01ba7693111 + url: "https://pub.dev" + source: hosted + version: "5.0.1" + image_cropper_for_web: + dependency: transitive + description: + name: image_cropper_for_web + sha256: "865d798b5c9d826f1185b32e5d0018c4183ddb77b7b82a931e1a06aa3b74974e" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + image_cropper_platform_interface: + dependency: transitive + description: + name: image_cropper_platform_interface + sha256: ee160d686422272aa306125f3b6fb1c1894d9b87a5e20ed33fa008e7285da11e + url: "https://pub.dev" + source: hosted + version: "5.0.0" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "1f498d086203360cca099d20ffea2963f48c39ce91bdd8a3b6d4a045786b02c8" + url: "https://pub.dev" + source: hosted + version: "1.0.8" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "844c6da4e4f2829dffdab97816bca09d0e0977e8dcef7450864aba4e07967a58" + url: "https://pub.dev" + source: hosted + version: "0.8.9+6" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: e2423c53a68b579a7c37a1eda967b8ae536c3d98518e5db95ca1fe5719a730a3 + url: "https://pub.dev" + source: hosted + version: "3.0.2" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: fadafce49e8569257a0cad56d24438a6fa1f0cbd7ee0af9b631f7492818a4ca3 + url: "https://pub.dev" + source: hosted + version: "0.8.9+1" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b + url: "https://pub.dev" + source: hosted + version: "2.9.3" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" + url: "https://pub.dev" + source: hosted + version: "0.2.1+1" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + latlong2: + dependency: "direct main" + description: + name: latlong2 + sha256: "98227922caf49e6056f91b6c56945ea1c7b166f28ffcd5fb8e72fc0b453cc8fe" + url: "https://pub.dev" + source: hosted + version: "0.9.1" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + 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: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.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: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" + url: "https://pub.dev" + source: hosted + version: "1.0.6" + nm: + dependency: transitive + description: + name: nm + sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" + source: hosted + version: "1.0.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 + url: "https://pub.dev" + source: hosted + version: "2.1.4" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d + url: "https://pub.dev" + source: hosted + version: "2.2.4" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + 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" + pdf: + dependency: "direct main" + description: + name: pdf + sha256: "28eacad99bffcce2e05bba24e50153890ad0255294f4dd78a17075a2ba5c8416" + url: "https://pub.dev" + source: hosted + version: "3.11.3" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + 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" + qr: + dependency: transitive + description: + name: qr + sha256: "64957a3930367bf97cc211a5af99551d630f2f4625e38af10edd6b19131b64b3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + unicode: + dependency: transitive + description: + name: unicode + sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + 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: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d + url: "https://pub.dev" + source: hosted + version: "1.0.4" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.3 <4.0.0" + flutter: ">=3.16.0" diff --git a/praresi/pubspec.yaml b/praresi/pubspec.yaml new file mode 100644 index 0000000..630134d --- /dev/null +++ b/praresi/pubspec.yaml @@ -0,0 +1,134 @@ +name: praresi +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.2.3 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + get: ^4.6.5 + firebase_core: ^2.25.5 + firebase_auth: ^4.17.5 + cloud_firestore: ^4.15.5 + + image_picker: ^1.0.7 + # image_cropper: ^4.0.1 + image_cropper: ^5.0.1 + google_mlkit_text_recognition: ^0.11.0 + fl_chart: ^0.68.0 + # flutter_overlay_window: ^0.5.0 + dash_bubble: ^2.0.0 + flutter_overlay_window_sdk34: ^0.4.7 + intl: ^0.18.1 + + flutter_map: ^6.1.0 + latlong2: ^0.9.1 + connectivity_plus: ^6.0.3 + + excel: ^4.0.6 + pdf: ^3.11.3 + path_provider: ^2.1.2 + + + # charts_flutter: ^0.16.0 + # flutter_overlay_apps: ^1.2.0 + + # cloud_firestore: ^5.0.0 + # firebase_database: ^11.0.0 + + + + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_launcher_icons: ^0.13.1 + flutter_test: + sdk: flutter + + + # 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: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + assets: + - assets/data/regions.json + - assets/images/praresi_logo.png + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # 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/custom-fonts/#from-packages +flutter_launcher_icons: + android: true + ios: true + image_path: "assets/images/app_icon.png" + adaptive_icon_background: "#1976D2" + adaptive_icon_foreground: "assets/images/app_icon.png" diff --git a/praresi/web/favicon.png b/praresi/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/praresi/web/favicon.png differ diff --git a/praresi/web/icons/Icon-192.png b/praresi/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/praresi/web/icons/Icon-192.png differ diff --git a/praresi/web/icons/Icon-512.png b/praresi/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/praresi/web/icons/Icon-512.png differ diff --git a/praresi/web/icons/Icon-maskable-192.png b/praresi/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/praresi/web/icons/Icon-maskable-192.png differ diff --git a/praresi/web/icons/Icon-maskable-512.png b/praresi/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/praresi/web/icons/Icon-maskable-512.png differ diff --git a/praresi/web/index.html b/praresi/web/index.html new file mode 100644 index 0000000..e70f179 --- /dev/null +++ b/praresi/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + praresi + + + + + + + + + + diff --git a/praresi/web/manifest.json b/praresi/web/manifest.json new file mode 100644 index 0000000..3b92488 --- /dev/null +++ b/praresi/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "praresi", + "short_name": "praresi", + "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/praresi/windows/.gitignore b/praresi/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/praresi/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/praresi/windows/CMakeLists.txt b/praresi/windows/CMakeLists.txt new file mode 100644 index 0000000..4894ed4 --- /dev/null +++ b/praresi/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(praresi 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 "praresi") + +# 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/praresi/windows/flutter/CMakeLists.txt b/praresi/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..903f489 --- /dev/null +++ b/praresi/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/praresi/windows/flutter/generated_plugin_registrant.cc b/praresi/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..c882774 --- /dev/null +++ b/praresi/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,26 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include +#include +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + CloudFirestorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("CloudFirestorePluginCApi")); + ConnectivityPlusWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + FileSelectorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FileSelectorWindows")); + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); +} diff --git a/praresi/windows/flutter/generated_plugin_registrant.h b/praresi/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/praresi/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/praresi/windows/flutter/generated_plugins.cmake b/praresi/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..bc4f50d --- /dev/null +++ b/praresi/windows/flutter/generated_plugins.cmake @@ -0,0 +1,28 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + cloud_firestore + connectivity_plus + file_selector_windows + firebase_auth + firebase_core +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/praresi/windows/runner/CMakeLists.txt b/praresi/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/praresi/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/praresi/windows/runner/Runner.rc b/praresi/windows/runner/Runner.rc new file mode 100644 index 0000000..0231d5e --- /dev/null +++ b/praresi/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", "praresi" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "praresi" "\0" + VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "praresi.exe" "\0" + VALUE "ProductName", "praresi" "\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/praresi/windows/runner/flutter_window.cpp b/praresi/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..955ee30 --- /dev/null +++ b/praresi/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/praresi/windows/runner/flutter_window.h b/praresi/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/praresi/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/praresi/windows/runner/main.cpp b/praresi/windows/runner/main.cpp new file mode 100644 index 0000000..456118c --- /dev/null +++ b/praresi/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"praresi", 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/praresi/windows/runner/resource.h b/praresi/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/praresi/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/praresi/windows/runner/resources/app_icon.ico b/praresi/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/praresi/windows/runner/resources/app_icon.ico differ diff --git a/praresi/windows/runner/runner.exe.manifest b/praresi/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..a42ea76 --- /dev/null +++ b/praresi/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/praresi/windows/runner/utils.cpp b/praresi/windows/runner/utils.cpp new file mode 100644 index 0000000..b2b0873 --- /dev/null +++ b/praresi/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(); + } + 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/praresi/windows/runner/utils.h b/praresi/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/praresi/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/praresi/windows/runner/win32_window.cpp b/praresi/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/praresi/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/praresi/windows/runner/win32_window.h b/praresi/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/praresi/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_