commit b19a6e1cd4e74e0d1137ffc0ea82470b67542005 Author: Dennis Nemec Date: Sat Sep 20 16:14:06 2025 +0200 Initial draft diff --git a/README.md b/README.md new file mode 100644 index 0000000..2501fde --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# hl_lieferservice + +Holzleitner LieferApp Refactored + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..be3943c --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..a756767 --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "de.holzleitner.liefer.hl_lieferservice" + compileSdk = flutter.compileSdkVersion + //ndkVersion = flutter.ndkVersion + ndkVersion = "27.0.12077973" + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "de.holzleitner.liefer.hl_lieferservice" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a522d24 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/kotlin/de/holzleitner/liefer/hl_lieferservice/MainActivity.kt b/android/app/src/main/kotlin/de/holzleitner/liefer/hl_lieferservice/MainActivity.kt new file mode 100644 index 0000000..8954855 --- /dev/null +++ b/android/app/src/main/kotlin/de/holzleitner/liefer/hl_lieferservice/MainActivity.kt @@ -0,0 +1,5 @@ +package de.holzleitner.liefer.hl_lieferservice + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..89176ef --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,21 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..f018a61 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..afa1e8e --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 0000000..a439442 --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,25 @@ +pluginManagement { + val flutterSdkPath = run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.7.0" apply false + id("org.jetbrains.kotlin.android") version "1.8.22" apply false +} + +include(":app") diff --git a/assets/hl_server_config.json b/assets/hl_server_config.json new file mode 100644 index 0000000..6403941 --- /dev/null +++ b/assets/hl_server_config.json @@ -0,0 +1,7 @@ +{ + "host": "http://192.168.1.9:8334", + "user": "GSDWebServiceTmp", + "pass": "098f6bcd4621d373cade4e832627b4f6", + "appKey": "GSD-RestApi", + "appNames": ["GSD-RestApi"] +} \ No newline at end of file diff --git a/assets/holzleitner_Logo_2017_RZ.png b/assets/holzleitner_Logo_2017_RZ.png new file mode 100644 index 0000000..1967cf0 Binary files /dev/null and b/assets/holzleitner_Logo_2017_RZ.png differ diff --git a/assets/holzleitner_Logo_2017_RZ_transparent.png b/assets/holzleitner_Logo_2017_RZ_transparent.png new file mode 100644 index 0000000..d8965ac Binary files /dev/null and b/assets/holzleitner_Logo_2017_RZ_transparent.png differ diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..2bc8e05 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,4 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: + - provider: true \ No newline at end of file diff --git a/hl_lieferservice_backup_04_09_25.zip b/hl_lieferservice_backup_04_09_25.zip new file mode 100644 index 0000000..1da47d4 Binary files /dev/null and b/hl_lieferservice_backup_04_09_25.zip differ diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..7c56964 --- /dev/null +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 12.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..ec97fc6 --- /dev/null +++ b/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..c4855bf --- /dev/null +++ b/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..e549ee2 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..1dc7670 --- /dev/null +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,619 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 37Z4ZA4QU2; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 37Z4ZA4QU2; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice; + 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)"; + DEVELOPMENT_TEAM = 37Z4ZA4QU2; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = de.holzleitner.liefer.hlLieferservice; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..15cada4 --- /dev/null +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..6266644 --- /dev/null +++ b/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..7353c41 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..6ed2d93 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cd7b00 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fe73094 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..321773c Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..502f463 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..e9f5fea Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..8953cba Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0467bf1 Binary files /dev/null and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist new file mode 100644 index 0000000..654a7f9 --- /dev/null +++ b/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Hl Lieferservice + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + hl_lieferservice + 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/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/ios/RunnerTests/RunnerTests.swift b/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/lib/bloc/app_bloc.dart b/lib/bloc/app_bloc.dart new file mode 100644 index 0000000..0a45173 --- /dev/null +++ b/lib/bloc/app_bloc.dart @@ -0,0 +1,37 @@ +import 'dart:convert'; + +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/bloc/app_events.dart'; +import 'package:hl_lieferservice/bloc/app_states.dart'; +import 'package:hl_lieferservice/repository/config.dart'; + +import '../services/erpframe.dart'; + +class AppBloc extends Bloc { + AppBloc() : super(AppInitial()) { + on(_loadConfig); + } + + Future _loadConfig(AppLoadConfig event, Emitter emit) async { + emit(AppConfigLoading()); + try { + final repository = ConfigurationRepository(path: event.path); + final configuration = LocalDocuFrameConfiguration.fromJson( + json.decode(await rootBundle.loadString("assets/${event.path}")), + ); + + repository.setDocuFrameConfiguration(configuration); + + emit( + AppConfigLoaded(config: await repository.getDocuFrameConfiguration()), + ); + } catch (e) { + emit( + AppConfigLoadingFailed( + message: "Fehler beim Laden der Konfigurationsdatei.", + ), + ); + } + } +} diff --git a/lib/bloc/app_events.dart b/lib/bloc/app_events.dart new file mode 100644 index 0000000..1eb105a --- /dev/null +++ b/lib/bloc/app_events.dart @@ -0,0 +1,7 @@ +abstract class AppEvents {} + +class AppLoadConfig extends AppEvents { + String path; + + AppLoadConfig({required this.path}); +} \ No newline at end of file diff --git a/lib/bloc/app_states.dart b/lib/bloc/app_states.dart new file mode 100644 index 0000000..04cd477 --- /dev/null +++ b/lib/bloc/app_states.dart @@ -0,0 +1,16 @@ +import '../services/erpframe.dart'; + +abstract class AppState {} + +class AppInitial extends AppState {} +class AppConfigLoading extends AppState {} +class AppConfigLoaded extends AppState { + LocalDocuFrameConfiguration config; + + AppConfigLoaded({required this.config}); +} +class AppConfigLoadingFailed extends AppState { + String message; + + AppConfigLoadingFailed({required this.message}); +} \ No newline at end of file diff --git a/lib/dto/address.dart b/lib/dto/address.dart new file mode 100644 index 0000000..53c76ea --- /dev/null +++ b/lib/dto/address.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'address.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class AddressDTO { + AddressDTO( + {required this.streetName, + required this.postalCode, + required this.city}); + + String streetName; + String postalCode; + String city; + + factory AddressDTO.fromJson(Map json) => + _$AddressDTOFromJson(json); + + Map toJson() => _$AddressDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/address.g.dart b/lib/dto/address.g.dart new file mode 100644 index 0000000..2c7df80 --- /dev/null +++ b/lib/dto/address.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +AddressDTO _$AddressDTOFromJson(Map json) => AddressDTO( + streetName: json['street_name'] as String, + postalCode: json['postal_code'] as String, + city: json['city'] as String, +); + +Map _$AddressDTOToJson(AddressDTO instance) => + { + 'street_name': instance.streetName, + 'postal_code': instance.postalCode, + 'city': instance.city, + }; diff --git a/lib/dto/article.dart b/lib/dto/article.dart new file mode 100644 index 0000000..afc1121 --- /dev/null +++ b/lib/dto/article.dart @@ -0,0 +1,35 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'article.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class ArticleDTO { + ArticleDTO({ + required this.name, + required this.articleNr, + required this.quantity, + required this.price, + required this.scannable, + required this.internalId, + required this.scannedRemovedAmount, + required this.scannedAmount, + required this.removeNoteId, + required this.taxRate, + }); + + String name; + String articleNr; + String quantity; + String price; + String taxRate; + String internalId; + String scannedAmount; + String scannedRemovedAmount; + String? removeNoteId; + bool scannable; + + factory ArticleDTO.fromJson(Map json) => + _$ArticleDTOFromJson(json); + + Map toJson() => _$ArticleDTOToJson(this); +} diff --git a/lib/dto/article.g.dart b/lib/dto/article.g.dart new file mode 100644 index 0000000..a913f06 --- /dev/null +++ b/lib/dto/article.g.dart @@ -0,0 +1,34 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'article.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ArticleDTO _$ArticleDTOFromJson(Map json) => ArticleDTO( + name: json['name'] as String, + articleNr: json['article_nr'] as String, + quantity: json['quantity'] as String, + price: json['price'] as String, + scannable: json['scannable'] as bool, + internalId: json['internal_id'] as String, + scannedRemovedAmount: json['scanned_removed_amount'] as String, + scannedAmount: json['scanned_amount'] as String, + removeNoteId: json['remove_note_id'] as String?, + taxRate: json['tax_rate'] as String, +); + +Map _$ArticleDTOToJson(ArticleDTO instance) => + { + 'name': instance.name, + 'article_nr': instance.articleNr, + 'quantity': instance.quantity, + 'price': instance.price, + 'tax_rate': instance.taxRate, + 'internal_id': instance.internalId, + 'scanned_amount': instance.scannedAmount, + 'scanned_removed_amount': instance.scannedRemovedAmount, + 'remove_note_id': instance.removeNoteId, + 'scannable': instance.scannable, + }; diff --git a/lib/dto/basic_response.dart b/lib/dto/basic_response.dart new file mode 100644 index 0000000..7def3b1 --- /dev/null +++ b/lib/dto/basic_response.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'basic_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class BasicResponseDTO { + BasicResponseDTO( + {required this.succeeded, + required this.message}); + + final bool succeeded; + final String message; + + factory BasicResponseDTO.fromJson(Map json) => _$BasicResponseDTOFromJson(json); + Map toJson() => _$BasicResponseDTOToJson(this); +} diff --git a/lib/dto/basic_response.g.dart b/lib/dto/basic_response.g.dart new file mode 100644 index 0000000..405bf6d --- /dev/null +++ b/lib/dto/basic_response.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'basic_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BasicResponseDTO _$BasicResponseDTOFromJson(Map json) => + BasicResponseDTO( + succeeded: json['succeeded'] as bool, + message: json['message'] as String, + ); + +Map _$BasicResponseDTOToJson(BasicResponseDTO instance) => + { + 'succeeded': instance.succeeded, + 'message': instance.message, + }; diff --git a/lib/dto/car.dart b/lib/dto/car.dart new file mode 100644 index 0000000..70a4851 --- /dev/null +++ b/lib/dto/car.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'car.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class CarDTO { + CarDTO( + {required this.id, + required this.plate}); + + final String id; + final String plate; + + factory CarDTO.fromJson(Map json) => _$CarDTOFromJson(json); + Map toJson() => _$CarDTOToJson(this); +} diff --git a/lib/dto/car.g.dart b/lib/dto/car.g.dart new file mode 100644 index 0000000..135e5a4 --- /dev/null +++ b/lib/dto/car.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CarDTO _$CarDTOFromJson(Map json) => + CarDTO(id: json['id'] as String, plate: json['plate'] as String); + +Map _$CarDTOToJson(CarDTO instance) => { + 'id': instance.id, + 'plate': instance.plate, +}; diff --git a/lib/dto/car_add.dart b/lib/dto/car_add.dart new file mode 100644 index 0000000..64550be --- /dev/null +++ b/lib/dto/car_add.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'car_add.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class CarAddDTO { + CarAddDTO( + {required this.teamId, + required this.plate}); + + final int teamId; + final String plate; + + factory CarAddDTO.fromJson(Map json) => _$CarAddDTOFromJson(json); + factory CarAddDTO.make(int teamID, String plate) { + Map data = {"team_id": teamID, "plate": plate}; + return CarAddDTO.fromJson(data); + } + Map toJson() => _$CarAddDTOToJson(this); +} diff --git a/lib/dto/car_add.g.dart b/lib/dto/car_add.g.dart new file mode 100644 index 0000000..f15f9af --- /dev/null +++ b/lib/dto/car_add.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car_add.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CarAddDTO _$CarAddDTOFromJson(Map json) => CarAddDTO( + teamId: (json['team_id'] as num).toInt(), + plate: json['plate'] as String, +); + +Map _$CarAddDTOToJson(CarAddDTO instance) => { + 'team_id': instance.teamId, + 'plate': instance.plate, +}; diff --git a/lib/dto/car_add_response.dart b/lib/dto/car_add_response.dart new file mode 100644 index 0000000..a63b3cf --- /dev/null +++ b/lib/dto/car_add_response.dart @@ -0,0 +1,19 @@ +import 'car.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'car_add_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class CarAddResponseDTO { + CarAddResponseDTO( + {required this.succeeded, + required this.message, + required this.car}); + + final bool succeeded; + final String message; + final CarDTO car; + + factory CarAddResponseDTO.fromJson(Map json) => _$CarAddResponseDTOFromJson(json); + Map toJson() => _$CarAddResponseDTOToJson(this); +} diff --git a/lib/dto/car_add_response.g.dart b/lib/dto/car_add_response.g.dart new file mode 100644 index 0000000..3344fe1 --- /dev/null +++ b/lib/dto/car_add_response.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car_add_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CarAddResponseDTO _$CarAddResponseDTOFromJson(Map json) => + CarAddResponseDTO( + succeeded: json['succeeded'] as bool, + message: json['message'] as String, + car: CarDTO.fromJson(json['car'] as Map), + ); + +Map _$CarAddResponseDTOToJson(CarAddResponseDTO instance) => + { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'car': instance.car, + }; diff --git a/lib/dto/car_get_response.dart b/lib/dto/car_get_response.dart new file mode 100644 index 0000000..3074b94 --- /dev/null +++ b/lib/dto/car_get_response.dart @@ -0,0 +1,19 @@ +import 'car.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'car_get_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class CarGetResponseDTO { + CarGetResponseDTO( + {required this.succeeded, + required this.message, + required this.cars}); + + final bool succeeded; + final String message; + final List? cars; + + factory CarGetResponseDTO.fromJson(Map json) => _$CarGetResponseDTOFromJson(json); + Map toJson() => _$CarGetResponseDTOToJson(this); +} diff --git a/lib/dto/car_get_response.g.dart b/lib/dto/car_get_response.g.dart new file mode 100644 index 0000000..bb2ddb7 --- /dev/null +++ b/lib/dto/car_get_response.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car_get_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CarGetResponseDTO _$CarGetResponseDTOFromJson(Map json) => + CarGetResponseDTO( + succeeded: json['succeeded'] as bool, + message: json['message'] as String, + cars: + (json['cars'] as List?) + ?.map((e) => CarDTO.fromJson(e as Map)) + .toList(), + ); + +Map _$CarGetResponseDTOToJson(CarGetResponseDTO instance) => + { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'cars': instance.cars, + }; diff --git a/lib/dto/contact_person.dart b/lib/dto/contact_person.dart new file mode 100644 index 0000000..c567916 --- /dev/null +++ b/lib/dto/contact_person.dart @@ -0,0 +1,20 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'contact_person.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class ContactPersonDTO { + ContactPersonDTO( + {required this.name, + required this.salutation, + required this.phoneNo, + required this.mobileNo}); + + String name; + String salutation; + String phoneNo; + String mobileNo; + + factory ContactPersonDTO.fromJson(Map json) => _$ContactPersonDTOFromJson(json); + Map toJson() => _$ContactPersonDTOToJson(this); +} diff --git a/lib/dto/contact_person.g.dart b/lib/dto/contact_person.g.dart new file mode 100644 index 0000000..2bc50ed --- /dev/null +++ b/lib/dto/contact_person.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'contact_person.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ContactPersonDTO _$ContactPersonDTOFromJson(Map json) => + ContactPersonDTO( + name: json['name'] as String, + salutation: json['salutation'] as String, + phoneNo: json['phone_no'] as String, + mobileNo: json['mobile_no'] as String, + ); + +Map _$ContactPersonDTOToJson(ContactPersonDTO instance) => + { + 'name': instance.name, + 'salutation': instance.salutation, + 'phone_no': instance.phoneNo, + 'mobile_no': instance.mobileNo, + }; diff --git a/lib/dto/customer.dart b/lib/dto/customer.dart new file mode 100644 index 0000000..bec7f0b --- /dev/null +++ b/lib/dto/customer.dart @@ -0,0 +1,15 @@ +import 'address.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'customer.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class CustomerDTO { + CustomerDTO({required this.name, required this.address}); + + String name; + AddressDTO address; + + factory CustomerDTO.fromJson(Map json) => _$CustomerDTOFromJson(json); + Map toJson() => _$CustomerDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/customer.g.dart b/lib/dto/customer.g.dart new file mode 100644 index 0000000..609291b --- /dev/null +++ b/lib/dto/customer.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'customer.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CustomerDTO _$CustomerDTOFromJson(Map json) => CustomerDTO( + name: json['name'] as String, + address: AddressDTO.fromJson(json['address'] as Map), +); + +Map _$CustomerDTOToJson(CustomerDTO instance) => + {'name': instance.name, 'address': instance.address}; diff --git a/lib/dto/delivery.dart b/lib/dto/delivery.dart new file mode 100644 index 0000000..dcfab01 --- /dev/null +++ b/lib/dto/delivery.dart @@ -0,0 +1,83 @@ +import 'article.dart'; +import 'contact_person.dart'; +import 'customer.dart'; +import 'discount.dart'; +import 'image.dart'; +import 'note.dart'; +import 'payment.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'delivery.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DeliveryOptionDTO { + DeliveryOptionDTO({ + required this.numerical, + required this.value, + required this.display, + required this.key, + }); + + bool numerical; + String value; + String display; + String key; + + factory DeliveryOptionDTO.fromJson(Map json) => + _$DeliveryOptionDTOFromJson(json); + + Map toJson() => _$DeliveryOptionDTOToJson(this); +} + +@JsonSerializable(fieldRename: FieldRename.snake) +class DeliveryDTO { + DeliveryDTO({ + required this.internalReceiptNo, + required this.specialAggreements, + required this.currency, + required this.notes, + required this.totalPrice, + required this.prepayment, + required this.paymentAtDelivery, + required this.desiredTime, + required this.contactPerson, + required this.articles, + required this.totalNetValue, + required this.totalGrossValue, + required this.images, + required this.customer, + required this.finishedTime, + required this.note, + required this.state, + required this.payment, + required this.carId, + required this.options, + }); + + String internalReceiptNo; + String? specialAggreements; + CustomerDTO customer; + String totalPrice; + String desiredTime; + String totalGrossValue; + String totalNetValue; + ContactPersonDTO contactPerson; + String? currency; + List articles; + String note; + String finishedTime; + String carId; + String state; + String prepayment; + String paymentAtDelivery; + DiscountDTO? discount; + PaymentMethodDTO payment; + List notes; + List images; + List options; + + factory DeliveryDTO.fromJson(Map json) => + _$DeliveryDTOFromJson(json); + + Map toJson() => _$DeliveryDTOToJson(this); +} diff --git a/lib/dto/delivery.g.dart b/lib/dto/delivery.g.dart new file mode 100644 index 0000000..1d912a1 --- /dev/null +++ b/lib/dto/delivery.g.dart @@ -0,0 +1,89 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'delivery.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DeliveryOptionDTO _$DeliveryOptionDTOFromJson(Map json) => + DeliveryOptionDTO( + numerical: json['numerical'] as bool, + value: json['value'] as String, + display: json['display'] as String, + key: json['key'] as String, + ); + +Map _$DeliveryOptionDTOToJson(DeliveryOptionDTO instance) => + { + 'numerical': instance.numerical, + 'value': instance.value, + 'display': instance.display, + 'key': instance.key, + }; + +DeliveryDTO _$DeliveryDTOFromJson(Map json) => DeliveryDTO( + internalReceiptNo: json['internal_receipt_no'] as String, + specialAggreements: json['special_aggreements'] as String?, + currency: json['currency'] as String?, + notes: + (json['notes'] as List) + .map((e) => NoteDTO.fromJson(e as Map)) + .toList(), + totalPrice: json['total_price'] as String, + prepayment: json['prepayment'] as String, + paymentAtDelivery: json['payment_at_delivery'] as String, + desiredTime: json['desired_time'] as String, + contactPerson: ContactPersonDTO.fromJson( + json['contact_person'] as Map, + ), + articles: + (json['articles'] as List) + .map((e) => ArticleDTO.fromJson(e as Map)) + .toList(), + totalNetValue: json['total_net_value'] as String, + totalGrossValue: json['total_gross_value'] as String, + images: + (json['images'] as List) + .map((e) => ImageDTO.fromJson(e as Map)) + .toList(), + customer: CustomerDTO.fromJson(json['customer'] as Map), + finishedTime: json['finished_time'] as String, + note: json['note'] as String, + state: json['state'] as String, + payment: PaymentMethodDTO.fromJson(json['payment'] as Map), + carId: json['car_id'] as String, + options: + (json['options'] as List) + .map((e) => DeliveryOptionDTO.fromJson(e as Map)) + .toList(), + ) + ..discount = + json['discount'] == null + ? null + : DiscountDTO.fromJson(json['discount'] as Map); + +Map _$DeliveryDTOToJson(DeliveryDTO instance) => + { + 'internal_receipt_no': instance.internalReceiptNo, + 'special_aggreements': instance.specialAggreements, + 'customer': instance.customer, + 'total_price': instance.totalPrice, + 'desired_time': instance.desiredTime, + 'total_gross_value': instance.totalGrossValue, + 'total_net_value': instance.totalNetValue, + 'contact_person': instance.contactPerson, + 'currency': instance.currency, + 'articles': instance.articles, + 'note': instance.note, + 'finished_time': instance.finishedTime, + 'car_id': instance.carId, + 'state': instance.state, + 'prepayment': instance.prepayment, + 'payment_at_delivery': instance.paymentAtDelivery, + 'discount': instance.discount, + 'payment': instance.payment, + 'notes': instance.notes, + 'images': instance.images, + 'options': instance.options, + }; diff --git a/lib/dto/delivery_response.dart b/lib/dto/delivery_response.dart new file mode 100644 index 0000000..eb31efe --- /dev/null +++ b/lib/dto/delivery_response.dart @@ -0,0 +1,22 @@ +import 'delivery.dart'; +import 'driver.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'delivery_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DeliveryResponseDTO { + DeliveryResponseDTO( + {required this.deliveries, + required this.driver, + required this.discountArticleNumber}); + + List deliveries; + DriverDTO driver; + String discountArticleNumber; + + factory DeliveryResponseDTO.fromJson(Map json) => + _$DeliveryResponseDTOFromJson(json); + + Map toJson() => _$DeliveryResponseDTOToJson(this); +} diff --git a/lib/dto/delivery_response.g.dart b/lib/dto/delivery_response.g.dart new file mode 100644 index 0000000..b4f71d4 --- /dev/null +++ b/lib/dto/delivery_response.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'delivery_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DeliveryResponseDTO _$DeliveryResponseDTOFromJson(Map json) => + DeliveryResponseDTO( + deliveries: + (json['deliveries'] as List) + .map((e) => DeliveryDTO.fromJson(e as Map)) + .toList(), + driver: DriverDTO.fromJson(json['driver'] as Map), + discountArticleNumber: json['discount_article_number'] as String, + ); + +Map _$DeliveryResponseDTOToJson( + DeliveryResponseDTO instance, +) => { + 'deliveries': instance.deliveries, + 'driver': instance.driver, + 'discount_article_number': instance.discountArticleNumber, +}; diff --git a/lib/dto/delivery_update.dart b/lib/dto/delivery_update.dart new file mode 100644 index 0000000..7596034 --- /dev/null +++ b/lib/dto/delivery_update.dart @@ -0,0 +1,55 @@ +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'delivery_update.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DeliveryUpdateDTO { + DeliveryUpdateDTO({ + required this.deliveryId, + this.note, + this.finishedDate, + this.discount, + this.selectedPaymentMethodId, + this.state, + this.carId, + }); + + String deliveryId; + String? note; + String? finishedDate; + String? state; + int? carId; + String? selectedPaymentMethodId; + double? discount; + + factory DeliveryUpdateDTO.fromJson(Map json) => + _$DeliveryUpdateDTOFromJson(json); + + factory DeliveryUpdateDTO.fromEntity(Delivery delivery) { + String state = ""; + + switch (delivery.state) { + case DeliveryState.finished: + state = "geliefert"; + break; + case DeliveryState.ongoing: + state = "laufend"; + break; + case DeliveryState.onhold: + state = "vertagt"; + break; + case DeliveryState.canceled: + state = "abgebrochen"; + break; + } + + return DeliveryUpdateDTO( + deliveryId: delivery.id, + state: state, + carId: delivery.carId, + ); + } + + Map toJson() => _$DeliveryUpdateDTOToJson(this); +} diff --git a/lib/dto/delivery_update.g.dart b/lib/dto/delivery_update.g.dart new file mode 100644 index 0000000..9451ee0 --- /dev/null +++ b/lib/dto/delivery_update.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'delivery_update.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DeliveryUpdateDTO _$DeliveryUpdateDTOFromJson(Map json) => + DeliveryUpdateDTO( + deliveryId: json['delivery_id'] as String, + note: json['note'] as String?, + finishedDate: json['finished_date'] as String?, + discount: (json['discount'] as num?)?.toDouble(), + selectedPaymentMethodId: json['selected_payment_method_id'] as String?, + state: json['state'] as String?, + carId: (json['car_id'] as num?)?.toInt(), + ); + +Map _$DeliveryUpdateDTOToJson(DeliveryUpdateDTO instance) => + { + 'delivery_id': instance.deliveryId, + 'note': instance.note, + 'finished_date': instance.finishedDate, + 'state': instance.state, + 'car_id': instance.carId, + 'selected_payment_method_id': instance.selectedPaymentMethodId, + 'discount': instance.discount, + }; diff --git a/lib/dto/delivery_update_response.dart b/lib/dto/delivery_update_response.dart new file mode 100644 index 0000000..737201e --- /dev/null +++ b/lib/dto/delivery_update_response.dart @@ -0,0 +1,17 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'delivery_update_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DeliveryUpdateResponseDTO { + DeliveryUpdateResponseDTO( + {required this.message, required this.code}); + + final String code; + final String message; + + factory DeliveryUpdateResponseDTO.fromJson(Map json) => + _$DeliveryUpdateResponseDTOFromJson(json); + + Map toJson() => _$DeliveryUpdateResponseDTOToJson(this); +} diff --git a/lib/dto/delivery_update_response.g.dart b/lib/dto/delivery_update_response.g.dart new file mode 100644 index 0000000..b5c7823 --- /dev/null +++ b/lib/dto/delivery_update_response.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'delivery_update_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DeliveryUpdateResponseDTO _$DeliveryUpdateResponseDTOFromJson( + Map json, +) => DeliveryUpdateResponseDTO( + message: json['message'] as String, + code: json['code'] as String, +); + +Map _$DeliveryUpdateResponseDTOToJson( + DeliveryUpdateResponseDTO instance, +) => {'code': instance.code, 'message': instance.message}; diff --git a/lib/dto/discount.dart b/lib/dto/discount.dart new file mode 100644 index 0000000..9e8fd1b --- /dev/null +++ b/lib/dto/discount.dart @@ -0,0 +1,15 @@ +import 'article.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'discount.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountDTO { + DiscountDTO({required this.note, required this.noteId, required this.article}); + String? note; + String? noteId; + ArticleDTO article; + + factory DiscountDTO.fromJson(Map json) => _$DiscountDTOFromJson(json); + Map toJson() => _$DiscountDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/discount.g.dart b/lib/dto/discount.g.dart new file mode 100644 index 0000000..faf5558 --- /dev/null +++ b/lib/dto/discount.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountDTO _$DiscountDTOFromJson(Map json) => DiscountDTO( + note: json['note'] as String?, + noteId: json['note_id'] as String?, + article: ArticleDTO.fromJson(json['article'] as Map), +); + +Map _$DiscountDTOToJson(DiscountDTO instance) => + { + 'note': instance.note, + 'note_id': instance.noteId, + 'article': instance.article, + }; diff --git a/lib/dto/discount_add.dart b/lib/dto/discount_add.dart new file mode 100644 index 0000000..ea07328 --- /dev/null +++ b/lib/dto/discount_add.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'discount_add.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountAddDTO { + DiscountAddDTO( + {required this.note, required this.deliveryId, required this.discount}); + + String note; + String deliveryId; + int discount; + + factory DiscountAddDTO.fromJson(Map json) => + _$DiscountAddDTOFromJson(json); + + Map toJson() => _$DiscountAddDTOToJson(this); +} diff --git a/lib/dto/discount_add.g.dart b/lib/dto/discount_add.g.dart new file mode 100644 index 0000000..128f9d1 --- /dev/null +++ b/lib/dto/discount_add.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_add.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountAddDTO _$DiscountAddDTOFromJson(Map json) => + DiscountAddDTO( + note: json['note'] as String, + deliveryId: json['delivery_id'] as String, + discount: (json['discount'] as num).toInt(), + ); + +Map _$DiscountAddDTOToJson(DiscountAddDTO instance) => + { + 'note': instance.note, + 'delivery_id': instance.deliveryId, + 'discount': instance.discount, + }; diff --git a/lib/dto/discount_add_response.dart b/lib/dto/discount_add_response.dart new file mode 100644 index 0000000..0edf7c8 --- /dev/null +++ b/lib/dto/discount_add_response.dart @@ -0,0 +1,63 @@ +import 'article.dart'; +import 'basic_response.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'discount_add_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class PriceInformation { + PriceInformation({required this.net, required this.gross}); + + double net; + double gross; + + factory PriceInformation.fromJson(Map json) => + _$PriceInformationFromJson(json); + + Map toJson() => _$PriceInformationToJson(this); +} + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteInformation { + NoteInformation({required this.rowId, required this.noteDescription}); + + String rowId; + String noteDescription; + + factory NoteInformation.fromJson(Map json) => + _$NoteInformationFromJson(json); + + Map toJson() => _$NoteInformationToJson(this); +} + +@JsonSerializable(fieldRename: FieldRename.snake) +class UpdatedValues { + UpdatedValues( + {required this.discount, + required this.receipt, + required this.article, + required this.note}); + + PriceInformation discount; + PriceInformation receipt; + NoteInformation note; + ArticleDTO article; + + factory UpdatedValues.fromJson(Map json) => + _$UpdatedValuesFromJson(json); + + Map toJson() => _$UpdatedValuesToJson(this); +} + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountAddResponseDTO extends BasicResponseDTO { + DiscountAddResponseDTO( + {required this.values, required super.succeeded, required super.message}); + + UpdatedValues values; + + factory DiscountAddResponseDTO.fromJson(Map json) => + _$DiscountAddResponseDTOFromJson(json); + + Map toJson() => _$DiscountAddResponseDTOToJson(this); +} diff --git a/lib/dto/discount_add_response.g.dart b/lib/dto/discount_add_response.g.dart new file mode 100644 index 0000000..470196b --- /dev/null +++ b/lib/dto/discount_add_response.g.dart @@ -0,0 +1,61 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_add_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PriceInformation _$PriceInformationFromJson(Map json) => + PriceInformation( + net: (json['net'] as num).toDouble(), + gross: (json['gross'] as num).toDouble(), + ); + +Map _$PriceInformationToJson(PriceInformation instance) => + {'net': instance.net, 'gross': instance.gross}; + +NoteInformation _$NoteInformationFromJson(Map json) => + NoteInformation( + rowId: json['row_id'] as String, + noteDescription: json['note_description'] as String, + ); + +Map _$NoteInformationToJson(NoteInformation instance) => + { + 'row_id': instance.rowId, + 'note_description': instance.noteDescription, + }; + +UpdatedValues _$UpdatedValuesFromJson( + Map json, +) => UpdatedValues( + discount: PriceInformation.fromJson(json['discount'] as Map), + receipt: PriceInformation.fromJson(json['receipt'] as Map), + article: ArticleDTO.fromJson(json['article'] as Map), + note: NoteInformation.fromJson(json['note'] as Map), +); + +Map _$UpdatedValuesToJson(UpdatedValues instance) => + { + 'discount': instance.discount, + 'receipt': instance.receipt, + 'note': instance.note, + 'article': instance.article, + }; + +DiscountAddResponseDTO _$DiscountAddResponseDTOFromJson( + Map json, +) => DiscountAddResponseDTO( + values: UpdatedValues.fromJson(json['values'] as Map), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, +); + +Map _$DiscountAddResponseDTOToJson( + DiscountAddResponseDTO instance, +) => { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'values': instance.values, +}; diff --git a/lib/dto/discount_remove.dart b/lib/dto/discount_remove.dart new file mode 100644 index 0000000..7ca17db --- /dev/null +++ b/lib/dto/discount_remove.dart @@ -0,0 +1,15 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'discount_remove.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountRemoveDTO { + DiscountRemoveDTO( + {required this.deliveryId}); + String deliveryId; + + factory DiscountRemoveDTO.fromJson(Map json) => + _$DiscountRemoveDTOFromJson(json); + + Map toJson() => _$DiscountRemoveDTOToJson(this); +} diff --git a/lib/dto/discount_remove.g.dart b/lib/dto/discount_remove.g.dart new file mode 100644 index 0000000..d4692d9 --- /dev/null +++ b/lib/dto/discount_remove.g.dart @@ -0,0 +1,13 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_remove.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountRemoveDTO _$DiscountRemoveDTOFromJson(Map json) => + DiscountRemoveDTO(deliveryId: json['delivery_id'] as String); + +Map _$DiscountRemoveDTOToJson(DiscountRemoveDTO instance) => + {'delivery_id': instance.deliveryId}; diff --git a/lib/dto/discount_remove_response.dart b/lib/dto/discount_remove_response.dart new file mode 100644 index 0000000..b88389b --- /dev/null +++ b/lib/dto/discount_remove_response.dart @@ -0,0 +1,22 @@ +import 'basic_response.dart'; +import 'package:json_annotation/json_annotation.dart'; + +import 'discount_add_response.dart'; + +part 'discount_remove_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountRemoveResponseDTO extends BasicResponseDTO { + DiscountRemoveResponseDTO( + { + required this.receipt, + required super.succeeded, + required super.message}); + + PriceInformation receipt; + + factory DiscountRemoveResponseDTO.fromJson(Map json) => + _$DiscountRemoveResponseDTOFromJson(json); + + Map toJson() => _$DiscountRemoveResponseDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/discount_remove_response.g.dart b/lib/dto/discount_remove_response.g.dart new file mode 100644 index 0000000..6528bf8 --- /dev/null +++ b/lib/dto/discount_remove_response.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_remove_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountRemoveResponseDTO _$DiscountRemoveResponseDTOFromJson( + Map json, +) => DiscountRemoveResponseDTO( + receipt: PriceInformation.fromJson(json['receipt'] as Map), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, +); + +Map _$DiscountRemoveResponseDTOToJson( + DiscountRemoveResponseDTO instance, +) => { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'receipt': instance.receipt, +}; diff --git a/lib/dto/discount_update.dart b/lib/dto/discount_update.dart new file mode 100644 index 0000000..5b536ba --- /dev/null +++ b/lib/dto/discount_update.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'discount_update.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountUpdateDTO { + DiscountUpdateDTO( + {required this.note, required this.deliveryId, required this.discount}); + + String? note; + String deliveryId; + int? discount; + + factory DiscountUpdateDTO.fromJson(Map json) => + _$DiscountUpdateDTOFromJson(json); + + Map toJson() => _$DiscountUpdateDTOToJson(this); +} diff --git a/lib/dto/discount_update.g.dart b/lib/dto/discount_update.g.dart new file mode 100644 index 0000000..827ec78 --- /dev/null +++ b/lib/dto/discount_update.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_update.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountUpdateDTO _$DiscountUpdateDTOFromJson(Map json) => + DiscountUpdateDTO( + note: json['note'] as String?, + deliveryId: json['delivery_id'] as String, + discount: (json['discount'] as num?)?.toInt(), + ); + +Map _$DiscountUpdateDTOToJson(DiscountUpdateDTO instance) => + { + 'note': instance.note, + 'delivery_id': instance.deliveryId, + 'discount': instance.discount, + }; diff --git a/lib/dto/discount_update_response.dart b/lib/dto/discount_update_response.dart new file mode 100644 index 0000000..7bdc3e6 --- /dev/null +++ b/lib/dto/discount_update_response.dart @@ -0,0 +1,22 @@ +import 'package:hl_lieferservice/dto/article.dart'; + +import 'basic_response.dart'; +import 'discount_add_response.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'discount_update_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DiscountUpdateResponseDTO extends BasicResponseDTO { + DiscountUpdateResponseDTO( + {required this.values, + required super.succeeded, + required super.message}); + + UpdatedValues? values; + + factory DiscountUpdateResponseDTO.fromJson(Map json) => + _$DiscountUpdateResponseDTOFromJson(json); + + Map toJson() => _$DiscountUpdateResponseDTOToJson(this); +} diff --git a/lib/dto/discount_update_response.g.dart b/lib/dto/discount_update_response.g.dart new file mode 100644 index 0000000..a7e5543 --- /dev/null +++ b/lib/dto/discount_update_response.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'discount_update_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DiscountUpdateResponseDTO _$DiscountUpdateResponseDTOFromJson( + Map json, +) => DiscountUpdateResponseDTO( + values: + json['values'] == null + ? null + : UpdatedValues.fromJson(json['values'] as Map), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, +); + +Map _$DiscountUpdateResponseDTOToJson( + DiscountUpdateResponseDTO instance, +) => { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'values': instance.values, +}; diff --git a/lib/dto/driver.dart b/lib/dto/driver.dart new file mode 100644 index 0000000..d562489 --- /dev/null +++ b/lib/dto/driver.dart @@ -0,0 +1,16 @@ +import 'car.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'driver.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class DriverDTO { + DriverDTO({required this.id, required this.name, required this.salutation, required this.cars}); + String id; + String name; + String salutation; + List cars; + + factory DriverDTO.fromJson(Map json) => _$DriverDTOFromJson(json); + Map toJson() => _$DriverDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/driver.g.dart b/lib/dto/driver.g.dart new file mode 100644 index 0000000..29fd322 --- /dev/null +++ b/lib/dto/driver.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'driver.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DriverDTO _$DriverDTOFromJson(Map json) => DriverDTO( + id: json['id'] as String, + name: json['name'] as String, + salutation: json['salutation'] as String, + cars: + (json['cars'] as List) + .map((e) => CarDTO.fromJson(e as Map)) + .toList(), +); + +Map _$DriverDTOToJson(DriverDTO instance) => { + 'id': instance.id, + 'name': instance.name, + 'salutation': instance.salutation, + 'cars': instance.cars, +}; diff --git a/lib/dto/image.dart b/lib/dto/image.dart new file mode 100644 index 0000000..9db9e3d --- /dev/null +++ b/lib/dto/image.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'image.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class ImageDTO { + ImageDTO( + {required this.url, required this.name, required this.oid}); + + String url; + String name; + String oid; + + factory ImageDTO.fromJson(Map json) => + _$ImageDTOFromJson(json); + + Map toJson() => _$ImageDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/image.g.dart b/lib/dto/image.g.dart new file mode 100644 index 0000000..1025e20 --- /dev/null +++ b/lib/dto/image.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'image.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ImageDTO _$ImageDTOFromJson(Map json) => ImageDTO( + url: json['url'] as String, + name: json['name'] as String, + oid: json['oid'] as String, +); + +Map _$ImageDTOToJson(ImageDTO instance) => { + 'url': instance.url, + 'name': instance.name, + 'oid': instance.oid, +}; diff --git a/lib/dto/note.dart b/lib/dto/note.dart new file mode 100644 index 0000000..f68d96b --- /dev/null +++ b/lib/dto/note.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'note.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteDTO { + NoteDTO( + {required this.id, + required this.note}); + + final String id; + final String note; + + factory NoteDTO.fromJson(Map json) => _$NoteDTOFromJson(json); + Map toJson() => _$NoteDTOToJson(this); +} diff --git a/lib/dto/note.g.dart b/lib/dto/note.g.dart new file mode 100644 index 0000000..11c47b3 --- /dev/null +++ b/lib/dto/note.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'note.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoteDTO _$NoteDTOFromJson(Map json) => + NoteDTO(id: json['id'] as String, note: json['note'] as String); + +Map _$NoteDTOToJson(NoteDTO instance) => { + 'id': instance.id, + 'note': instance.note, +}; diff --git a/lib/dto/note_add_response.dart b/lib/dto/note_add_response.dart new file mode 100644 index 0000000..64116c9 --- /dev/null +++ b/lib/dto/note_add_response.dart @@ -0,0 +1,16 @@ +import 'package:hl_lieferservice/dto/basic_response.dart'; +import 'package:hl_lieferservice/dto/note.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'note_add_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteAddResponseDTO extends BasicResponseDTO { + NoteAddResponseDTO( + {required this.note, required super.succeeded, required super.message}); + + final NoteDTO? note; + + factory NoteAddResponseDTO.fromJson(Map json) => _$NoteAddResponseDTOFromJson(json); + Map toJson() => _$NoteAddResponseDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/note_add_response.g.dart b/lib/dto/note_add_response.g.dart new file mode 100644 index 0000000..af068d1 --- /dev/null +++ b/lib/dto/note_add_response.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'note_add_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoteAddResponseDTO _$NoteAddResponseDTOFromJson(Map json) => + NoteAddResponseDTO( + note: + json['note'] == null + ? null + : NoteDTO.fromJson(json['note'] as Map), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, + ); + +Map _$NoteAddResponseDTOToJson(NoteAddResponseDTO instance) => + { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'note': instance.note, + }; diff --git a/lib/dto/note_get_response.dart b/lib/dto/note_get_response.dart new file mode 100644 index 0000000..a1c7ad4 --- /dev/null +++ b/lib/dto/note_get_response.dart @@ -0,0 +1,19 @@ +import 'note.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'note_get_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteGetResponseDTO { + NoteGetResponseDTO( + {required this.notes, required this.succeeded, required this.message}); + + final List notes; + final bool succeeded; + final String message; + + factory NoteGetResponseDTO.fromJson(Map json) => + _$NoteGetResponseDTOFromJson(json); + + Map toJson() => _$NoteGetResponseDTOToJson(this); +} diff --git a/lib/dto/note_get_response.g.dart b/lib/dto/note_get_response.g.dart new file mode 100644 index 0000000..c956860 --- /dev/null +++ b/lib/dto/note_get_response.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'note_get_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoteGetResponseDTO _$NoteGetResponseDTOFromJson(Map json) => + NoteGetResponseDTO( + notes: + (json['notes'] as List) + .map((e) => NoteDTO.fromJson(e as Map)) + .toList(), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, + ); + +Map _$NoteGetResponseDTOToJson(NoteGetResponseDTO instance) => + { + 'notes': instance.notes, + 'succeeded': instance.succeeded, + 'message': instance.message, + }; diff --git a/lib/dto/note_template.dart b/lib/dto/note_template.dart new file mode 100644 index 0000000..24f96d9 --- /dev/null +++ b/lib/dto/note_template.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'note_template.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteTemplateDTO { + NoteTemplateDTO( + {required this.language, + required this.title, + required this.note}); + + final String note; + final String language; + final String title; + + factory NoteTemplateDTO.fromJson(Map json) => _$NoteTemplateDTOFromJson(json); + Map toJson() => _$NoteTemplateDTOToJson(this); +} diff --git a/lib/dto/note_template.g.dart b/lib/dto/note_template.g.dart new file mode 100644 index 0000000..de522a0 --- /dev/null +++ b/lib/dto/note_template.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'note_template.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoteTemplateDTO _$NoteTemplateDTOFromJson(Map json) => + NoteTemplateDTO( + language: json['language'] as String, + title: json['title'] as String, + note: json['note'] as String, + ); + +Map _$NoteTemplateDTOToJson(NoteTemplateDTO instance) => + { + 'note': instance.note, + 'language': instance.language, + 'title': instance.title, + }; diff --git a/lib/dto/note_template_response.dart b/lib/dto/note_template_response.dart new file mode 100644 index 0000000..03dd93d --- /dev/null +++ b/lib/dto/note_template_response.dart @@ -0,0 +1,19 @@ +import 'note_template.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'note_template_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class NoteTemplateResponseDTO { + NoteTemplateResponseDTO( + {required this.notes, required this.succeeded, required this.message}); + + final List notes; + final bool succeeded; + final String message; + + factory NoteTemplateResponseDTO.fromJson(Map json) => + _$NoteTemplateResponseDTOFromJson(json); + + Map toJson() => _$NoteTemplateResponseDTOToJson(this); +} diff --git a/lib/dto/note_template_response.g.dart b/lib/dto/note_template_response.g.dart new file mode 100644 index 0000000..0660885 --- /dev/null +++ b/lib/dto/note_template_response.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'note_template_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +NoteTemplateResponseDTO _$NoteTemplateResponseDTOFromJson( + Map json, +) => NoteTemplateResponseDTO( + notes: + (json['notes'] as List) + .map((e) => NoteTemplateDTO.fromJson(e as Map)) + .toList(), + succeeded: json['succeeded'] as bool, + message: json['message'] as String, +); + +Map _$NoteTemplateResponseDTOToJson( + NoteTemplateResponseDTO instance, +) => { + 'notes': instance.notes, + 'succeeded': instance.succeeded, + 'message': instance.message, +}; diff --git a/lib/dto/payment.dart b/lib/dto/payment.dart new file mode 100644 index 0000000..af3587c --- /dev/null +++ b/lib/dto/payment.dart @@ -0,0 +1,17 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'payment.g.dart'; + +@JsonSerializable() +class PaymentMethodDTO { + PaymentMethodDTO(this.id, + {required this.description, + required this.shortCode}); + + final String id; + final String description; + final String shortCode; + + factory PaymentMethodDTO.fromJson(Map json) => _$PaymentMethodDTOFromJson(json); + Map toJson() => _$PaymentMethodDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/payment.g.dart b/lib/dto/payment.g.dart new file mode 100644 index 0000000..d55c729 --- /dev/null +++ b/lib/dto/payment.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'payment.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PaymentMethodDTO _$PaymentMethodDTOFromJson(Map json) => + PaymentMethodDTO( + json['id'] as String, + description: json['description'] as String, + shortCode: json['shortCode'] as String, + ); + +Map _$PaymentMethodDTOToJson(PaymentMethodDTO instance) => + { + 'id': instance.id, + 'description': instance.description, + 'shortCode': instance.shortCode, + }; diff --git a/lib/dto/payments.dart b/lib/dto/payments.dart new file mode 100644 index 0000000..1e00154 --- /dev/null +++ b/lib/dto/payments.dart @@ -0,0 +1,14 @@ +import 'payment.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'payments.g.dart'; + +@JsonSerializable() +class PaymentMethodListDTO { + PaymentMethodListDTO({required this.paymentMethods}); + + final List paymentMethods; + + factory PaymentMethodListDTO.fromJson(Map json) => _$PaymentMethodListDTOFromJson(json); + Map toJson() => _$PaymentMethodListDTOToJson(this); +} \ No newline at end of file diff --git a/lib/dto/payments.g.dart b/lib/dto/payments.g.dart new file mode 100644 index 0000000..0a03b28 --- /dev/null +++ b/lib/dto/payments.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'payments.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PaymentMethodListDTO _$PaymentMethodListDTOFromJson( + Map json, +) => PaymentMethodListDTO( + paymentMethods: + (json['paymentMethods'] as List) + .map((e) => PaymentMethodDTO.fromJson(e as Map)) + .toList(), +); + +Map _$PaymentMethodListDTOToJson( + PaymentMethodListDTO instance, +) => {'paymentMethods': instance.paymentMethods}; diff --git a/lib/dto/scan.dart b/lib/dto/scan.dart new file mode 100644 index 0000000..442a736 --- /dev/null +++ b/lib/dto/scan.dart @@ -0,0 +1,15 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'scan.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class ScanDTO { + ScanDTO({required this.internalId}); + + String internalId; + + factory ScanDTO.fromJson(Map json) => + _$ScanDTOFromJson(json); + + Map toJson() => _$ScanDTOToJson(this); +} diff --git a/lib/dto/scan.g.dart b/lib/dto/scan.g.dart new file mode 100644 index 0000000..5f1275b --- /dev/null +++ b/lib/dto/scan.g.dart @@ -0,0 +1,14 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'scan.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ScanDTO _$ScanDTOFromJson(Map json) => + ScanDTO(internalId: json['internal_id'] as String); + +Map _$ScanDTOToJson(ScanDTO instance) => { + 'internal_id': instance.internalId, +}; diff --git a/lib/dto/scan_response.dart b/lib/dto/scan_response.dart new file mode 100644 index 0000000..e4c52c9 --- /dev/null +++ b/lib/dto/scan_response.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'scan_response.g.dart'; + +@JsonSerializable(fieldRename: FieldRename.snake) +class ScanResponseDTO { + ScanResponseDTO( + {required this.message, required this.succeeded, required this.noteId}); + + final bool succeeded; + final String message; + final String? noteId; + + factory ScanResponseDTO.fromJson(Map json) => + _$ScanResponseDTOFromJson(json); + + Map toJson() => _$ScanResponseDTOToJson(this); +} diff --git a/lib/dto/scan_response.g.dart b/lib/dto/scan_response.g.dart new file mode 100644 index 0000000..a2f9f9a --- /dev/null +++ b/lib/dto/scan_response.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'scan_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ScanResponseDTO _$ScanResponseDTOFromJson(Map json) => + ScanResponseDTO( + message: json['message'] as String, + succeeded: json['succeeded'] as bool, + noteId: json['note_id'] as String?, + ); + +Map _$ScanResponseDTOToJson(ScanResponseDTO instance) => + { + 'succeeded': instance.succeeded, + 'message': instance.message, + 'note_id': instance.noteId, + }; diff --git a/lib/feature/authentication/bloc/auth_bloc.dart b/lib/feature/authentication/bloc/auth_bloc.dart new file mode 100644 index 0000000..eeeea86 --- /dev/null +++ b/lib/feature/authentication/bloc/auth_bloc.dart @@ -0,0 +1,28 @@ +import 'package:hl_lieferservice/feature/authentication/bloc/auth_event.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart'; +import 'package:hl_lieferservice/repository/user_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; + +class AuthBloc extends Bloc { + UserRepository repository; + OperationBloc operationBloc; + + AuthBloc({required this.repository, required this.operationBloc}) + : super(Unauthenticated()) { + on(_auth); + on(_logout); + } + + Future _auth(Authenticate event, Emitter emit) async { + operationBloc.add(LoadOperation()); + await Future.delayed(Duration(seconds: 5)); + emit(Authenticated(teamId: event.username)); + operationBloc.add(FinishOperation()); + } + + Future _logout(Logout event, Emitter emit) async { + emit(Unauthenticated()); + } +} diff --git a/lib/feature/authentication/bloc/auth_event.dart b/lib/feature/authentication/bloc/auth_event.dart new file mode 100644 index 0000000..048ef8c --- /dev/null +++ b/lib/feature/authentication/bloc/auth_event.dart @@ -0,0 +1,14 @@ +abstract class AuthEvent {} + +class Authenticate extends AuthEvent { + String username; + String password; + + Authenticate({required this.username, required this.password}); +} + +class Logout extends AuthEvent { + String username; + + Logout({required this.username}); +} \ No newline at end of file diff --git a/lib/feature/authentication/bloc/auth_state.dart b/lib/feature/authentication/bloc/auth_state.dart new file mode 100644 index 0000000..1ecba2b --- /dev/null +++ b/lib/feature/authentication/bloc/auth_state.dart @@ -0,0 +1,9 @@ +abstract class AuthState {} + +class Unauthenticated extends AuthState {} +class Authenticated extends AuthState { + String teamId; + + Authenticated({required this.teamId}); +} + diff --git a/lib/feature/authentication/presentation/login_enforcer.dart b/lib/feature/authentication/presentation/login_enforcer.dart new file mode 100644 index 0000000..45f6ec4 --- /dev/null +++ b/lib/feature/authentication/presentation/login_enforcer.dart @@ -0,0 +1,25 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/presentation/login_page.dart'; + +import '../bloc/auth_bloc.dart'; +import '../bloc/auth_state.dart'; + +class LoginEnforcer extends StatelessWidget { + final Widget child; + + const LoginEnforcer({super.key, required this.child}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is Authenticated) { + return child; + } + + return LoginPage(); + }, + ); + } +} diff --git a/lib/feature/authentication/presentation/login_page.dart b/lib/feature/authentication/presentation/login_page.dart new file mode 100644 index 0000000..ce6ff5c --- /dev/null +++ b/lib/feature/authentication/presentation/login_page.dart @@ -0,0 +1,121 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_event.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; +import 'package:hl_lieferservice/widget/operations/presentation/operation_view_enforcer.dart'; + +import '../bloc/auth_bloc.dart'; + +class LoginPage extends StatefulWidget { + const LoginPage({super.key}); + + @override + State createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + final _loginFormKey = GlobalKey(); + final TextEditingController _passwordEditingController = + TextEditingController(); + final TextEditingController _userIdEditingController = + TextEditingController(); + + bool _isEmpty = false; + + void onChanged(String value) { + setState(() { + _isEmpty = value.isEmpty; + }); + } + + void _onPressLogin(BuildContext context) async { + if (context.mounted) { + context.read().add( + Authenticate( + username: _userIdEditingController.text, + password: _passwordEditingController.text, + ), + ); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(50), + child: Column( + children: [ + Image.asset( + "assets/holzleitner_Logo_2017_RZ_transparent.png", + ), + const Padding( + padding: EdgeInsets.only(top: 20), + child: Text( + "Auslieferservice", + style: TextStyle( + fontWeight: FontWeight.w400, + fontSize: 20, + ), + ), + ), + ], + ), + ), + Form( + key: _loginFormKey, + child: FractionallySizedBox( + widthFactor: 0.8, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 20), + child: TextFormField( + decoration: const InputDecoration( + labelText: "Personalnummer", + border: OutlineInputBorder( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + ), + ), + controller: _userIdEditingController, + onChanged: onChanged, + ), + ), + TextFormField( + decoration: const InputDecoration( + labelText: "Passwort", + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + ), + ), + controller: _passwordEditingController, + obscureText: true, + onChanged: onChanged, + ), + Padding( + padding: const EdgeInsets.only(top: 15, bottom: 15), + child: OutlinedButton( + onPressed: + !_isEmpty ? () => _onPressLogin(context) : null, + child: const Text("Anmelden"), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/cars/bloc/cars_bloc.dart b/lib/feature/cars/bloc/cars_bloc.dart new file mode 100644 index 0000000..66d4052 --- /dev/null +++ b/lib/feature/cars/bloc/cars_bloc.dart @@ -0,0 +1,106 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/cars/repository/cars_repository.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; + +import '../../../model/car.dart'; +import 'cars_event.dart'; +import 'cars_state.dart'; + +class CarsBloc extends Bloc { + CarsRepository repository; + OperationBloc opBloc; + + CarsBloc({required this.repository, required this.opBloc}) + : super(CarsInitial()) { + on(_carAdd); + on(_carEdit); + on(_carDelete); + on(_carLoad); + } + + Future _carLoad(CarLoad event, Emitter emit) async { + try { + emit(CarsLoading()); + List cars = await repository.getAll(event.teamId); + emit(CarsLoaded(cars: cars, teamId: event.teamId)); + } catch (e) { + emit(CarsLoadingFailed()); + } + } + + Future _carAdd(CarAdd event, Emitter emit) async { + final currentState = state; + + try { + opBloc.add(LoadOperation()); + Car newCar = await repository.add(event.teamId, event.plate); + + if (currentState is CarsLoaded) { + emit( + currentState.copyWith( + cars: List.from(currentState.cars)..add(newCar), + ), + ); + } + + opBloc.add(FinishOperation(message: "Auto erfolgreich hinzugefügt")); + } catch (e) { + opBloc.add(FailOperation(message: "Fehler beim Hinzufügen eines Autos")); + } + } + + Future _carEdit(CarEdit event, Emitter emit) async { + final currentState = state; + + try { + opBloc.add(LoadOperation()); + await repository.edit(event.teamId, event.newCar); + + if (currentState is CarsLoaded) { + emit( + currentState.copyWith( + cars: + List.from(currentState.cars).map((car) { + if (car.id == event.newCar.id) { + return event.newCar; + } + + return car; + }).toList(), + ), + ); + } + + opBloc.add(FinishOperation(message: "Auto erfolgreich editiert")); + } catch (e) { + opBloc.add(FailOperation(message: "Fehler beim Editieren des Autos")); + } + } + + Future _carDelete(CarDelete event, Emitter emit) async { + final currentState = state; + + try { + opBloc.add(LoadOperation()); + await repository.delete(event.carId, event.teamId); + + if (currentState is CarsLoaded) { + emit( + CarsLoaded( + cars: [ + ...currentState.cars.where( + (car) => car.id != int.parse(event.carId), + ), + ], + teamId: currentState.teamId, + ), + ); + } + + opBloc.add(FinishOperation(message: "Auto erfolgreich gelöscht")); + } catch (e) { + opBloc.add(FailOperation(message: "Fehler beim Löschen des Autos")); + } + } +} diff --git a/lib/feature/cars/bloc/cars_event.dart b/lib/feature/cars/bloc/cars_event.dart new file mode 100644 index 0000000..b71c280 --- /dev/null +++ b/lib/feature/cars/bloc/cars_event.dart @@ -0,0 +1,30 @@ +import '../../../model/car.dart'; + +abstract class CarEvents {} + +class CarLoad extends CarEvents { + String teamId; + + CarLoad({required this.teamId}); +} + +class CarEdit extends CarEvents { + Car newCar; + String teamId; + + CarEdit({required this.newCar, required this.teamId}); +} + +class CarAdd extends CarEvents { + String teamId; + String plate; + + CarAdd({required this.teamId, required this.plate}); +} + +class CarDelete extends CarEvents { + String carId; + String teamId; + + CarDelete({required this.carId, required this.teamId}); +} \ No newline at end of file diff --git a/lib/feature/cars/bloc/cars_state.dart b/lib/feature/cars/bloc/cars_state.dart new file mode 100644 index 0000000..6a09593 --- /dev/null +++ b/lib/feature/cars/bloc/cars_state.dart @@ -0,0 +1,23 @@ +import 'package:hl_lieferservice/model/car.dart'; + +abstract class CarsState {} + +class CarsInitial extends CarsState {} + +class CarsLoading extends CarsState {} + +class CarsLoadingFailed extends CarsState {} + +class CarsLoaded extends CarsState { + List cars; + String teamId; + + CarsLoaded({required this.cars, required this.teamId}); + + CarsLoaded copyWith({List? cars, String? teamId}) { + return CarsLoaded( + cars: cars ?? this.cars, + teamId: teamId ?? this.teamId, + ); + } +} \ No newline at end of file diff --git a/lib/feature/cars/presentation/car_card.dart b/lib/feature/cars/presentation/car_card.dart new file mode 100644 index 0000000..4a06c6b --- /dev/null +++ b/lib/feature/cars/presentation/car_card.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; + +import '../../../model/car.dart'; +import 'car_dialog.dart'; + +class CarCard extends StatelessWidget { + final Car car; + final Function(Car car) onDelete; + final Function(Car car, String newName) onEdit; + + const CarCard({ + super.key, + required this.car, + required this.onEdit, + required this.onDelete, + }); + + @override + Widget build(BuildContext context) { + return Card( + child: Padding( + padding: const EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 10), + child: Icon( + Icons.local_shipping, + size: 32, + color: Theme.of(context).primaryColor, + ), + ), + Padding( + padding: const EdgeInsets.only(left: 10), + child: Text(car.plate), + ), + ], + ), + + Row( + children: [ + IconButton( + onPressed: () { + showDialog( + context: context, + builder: (context) { + return CarDialog( + onAction: (plate) { + onEdit(car, plate); + }, + action: CarAction.edit, + initialPlateValue: car.plate, + ); + }, + ); + }, + icon: Icon(Icons.edit, color: Theme.of(context).primaryColor), + ), + IconButton( + onPressed: () { + onDelete(car); + }, + icon: const Icon(Icons.delete, color: Colors.redAccent), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/cars/presentation/car_dialog.dart b/lib/feature/cars/presentation/car_dialog.dart new file mode 100644 index 0000000..24ba038 --- /dev/null +++ b/lib/feature/cars/presentation/car_dialog.dart @@ -0,0 +1,92 @@ +import 'package:flutter/material.dart'; + +enum CarAction { edit, add } + +class CarDialog extends StatefulWidget { + const CarDialog({ + super.key, + required this.onAction, + this.action = CarAction.add, + this.initialPlateValue = "", + }); + + final CarAction action; + final String initialPlateValue; + final Function(String) onAction; + + @override + State createState() => _CarDialogState(); +} + +class _CarDialogState extends State { + bool _isLoading = false; + final _formKey = GlobalKey(); + late final TextEditingController _plateController; + + @override + void initState() { + super.initState(); + + _plateController = TextEditingController.fromValue( + TextEditingValue(text: widget.initialPlateValue), + ); + } + + @override + Widget build(BuildContext context) { + return AlertDialog( + content: SizedBox( + height: 120, + child: Form( + key: _formKey, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10.0), + child: Text( + "Fahrzeug ${widget.action == CarAction.add ? "hinzufügen" : "bearbeiten"}", + style: const TextStyle( + fontSize: 18.0, + fontWeight: FontWeight.bold, + ), + ), + ), + TextFormField( + validator: (value) { + if (value == "") { + return "Kennzeichen darf nicht leer sein"; + } + + return null; + }, + decoration: const InputDecoration(labelText: "Kennzeichen"), + controller: _plateController, + ), + ], + ), + ), + ), + actions: [ + OutlinedButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text("Abbrechen"), + ), + FilledButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + widget.onAction(_plateController.text); + Navigator.of(context).pop(); + } + }, + child: Text( + widget.action == CarAction.add ? "Hinzufügen" : "Bearbeiten", + ), + ), + ], + ); + } +} diff --git a/lib/feature/cars/presentation/car_management.dart b/lib/feature/cars/presentation/car_management.dart new file mode 100644 index 0000000..e66549b --- /dev/null +++ b/lib/feature/cars/presentation/car_management.dart @@ -0,0 +1,78 @@ +import 'package:hl_lieferservice/feature/cars/presentation/car_card.dart'; + +import '../../../model/car.dart'; +import 'car_dialog.dart'; +import 'package:flutter/material.dart'; + +class CarManagementOverview extends StatefulWidget { + final List cars; + final Function(String plate) onAdd; + final Function(String id) onDelete; + final Function(String id, String plate) onEdit; + + const CarManagementOverview({ + super.key, + required this.cars, + required this.onDelete, + required this.onEdit, + required this.onAdd, + }); + + @override + State createState() => _CarManagementOverviewState(); +} + +class _CarManagementOverviewState extends State { + void _addCar() async { + showDialog( + context: context, + builder: (context) { + return CarDialog(onAction: widget.onAdd); + }, + ); + } + + void _removeCar(Car car) async { + widget.onDelete(car.id.toString()); + } + + void _editCar(Car car, String newName) async { + widget.onEdit(car.id.toString(), newName); + } + + Widget _buildCarOverview() { + return Padding( + padding: const EdgeInsets.all(10), + child: widget.cars.isEmpty ? const Center(child: Text("keine Fahrzeuge vorhanden")) : ListView.builder( + itemBuilder: + (context, index) => CarCard( + car: widget.cars[index], + onEdit: _editCar, + onDelete: _removeCar, + ), + itemCount: widget.cars.length, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text( + "Fahrzeugverwaltung", + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _addCar, + backgroundColor: Theme.of(context).primaryColor, + child: Icon( + Icons.add, + color: Theme.of(context).colorScheme.onSecondary, + ), + ), + body: _buildCarOverview(), + ); + } +} diff --git a/lib/feature/cars/presentation/car_management_page.dart b/lib/feature/cars/presentation/car_management_page.dart new file mode 100644 index 0000000..08fb93f --- /dev/null +++ b/lib/feature/cars/presentation/car_management_page.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart'; +import 'package:hl_lieferservice/feature/cars/bloc/cars_bloc.dart'; +import 'package:hl_lieferservice/feature/cars/bloc/cars_event.dart'; +import 'package:hl_lieferservice/feature/cars/bloc/cars_state.dart'; +import 'package:hl_lieferservice/feature/cars/presentation/car_management.dart'; +import 'package:hl_lieferservice/model/car.dart'; + +class CarManagementPage extends StatefulWidget { + const CarManagementPage({super.key}); + + @override + State createState() => _CarManagementPageState(); +} + +class _CarManagementPageState extends State { + late Authenticated _authState; + + @override + void initState() { + super.initState(); + + // Load cars + _authState = context.read().state as Authenticated; + context.read().add(CarLoad(teamId: _authState.teamId)); + } + + void _add(String plate) { + context.read().add( + CarAdd(teamId: _authState.teamId, plate: plate), + ); + } + + void _remove(String id) { + context.read().add( + CarDelete(carId: id, teamId: _authState.teamId), + ); + } + + void _edit(String id, String plate) { + context.read().add( + CarEdit( + newCar: Car(id: int.parse(id), plate: plate), + teamId: _authState.teamId, + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: BlocBuilder( + builder: (context, state) { + debugPrint('BlocBuilder rebuilding with state: $state'); + + if (state is CarsLoading) { + return Center(child: const CircularProgressIndicator()); + } + + if (state is CarsLoaded) { + return CarManagementOverview( + cars: state.cars, + onEdit: _edit, + onAdd: _add, + onDelete: _remove, + ); + } + + if (state is CarsLoadingFailed) { + return Center( + child: const Text("Fahrzeuge konnten nicht geladen werden"), + ); + } + + return Container(); + }, + ), + ); + } +} diff --git a/lib/feature/cars/repository/cars_repository.dart b/lib/feature/cars/repository/cars_repository.dart new file mode 100644 index 0000000..6e0329a --- /dev/null +++ b/lib/feature/cars/repository/cars_repository.dart @@ -0,0 +1,25 @@ +import 'package:hl_lieferservice/feature/cars/service/cars_service.dart'; + +import '../../../model/car.dart'; + +class CarsRepository { + CarService service; + + CarsRepository({required this.service}); + + Future> getAll(String teamId) async { + return service.getCars(int.parse(teamId)); + } + + Future delete(String carId, String teamId) async { + return service.removeCar(int.parse(carId), int.parse(teamId)); + } + + Future edit(String teamId, Car newCar) async { + return service.editCar(newCar); + } + + Future add(String teamId, String plate) async { + return service.addCar(plate, int.parse(teamId)); + } +} \ No newline at end of file diff --git a/lib/feature/cars/service/cars_service.dart b/lib/feature/cars/service/cars_service.dart new file mode 100644 index 0000000..b086661 --- /dev/null +++ b/lib/feature/cars/service/cars_service.dart @@ -0,0 +1,146 @@ +import 'dart:convert'; + +import 'package:docuframe/docuframe.dart' as df; +import 'package:flutter/cupertino.dart'; +import 'package:hl_lieferservice/services/erpframe.dart'; + +import '../../../dto/basic_response.dart'; +import '../../../dto/car_add.dart'; +import '../../../dto/car_add_response.dart'; +import '../../../dto/car_get_response.dart'; +import '../../../model/car.dart'; + +class CarService extends ErpFrameService { + CarService({required super.config}); + + Future addCar(String plate, int teamId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_addCar", + parameter: CarAddDTO.make(teamId, plate).toJson() + as Map); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + CarAddResponseDTO responseDto = CarAddResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return Car( + id: int.parse(responseDto.car.id), plate: responseDto.car.plate); + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE ADDING CAR"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future editCar(Car car) async { + df.LoginSession? session; + + try { + session = await getSession(); + + debugPrint(car.plate); + debugPrint(car.id.toString()); + + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_editCar", + parameter: {"id": car.id, "plate": car.plate}); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE EDITING CAR ${car.id}"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future removeCar(int carId, int teamId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_removeCar", + parameter: {"team_id": teamId, "id": carId}); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE REMOVING CAR"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future> getCars(int teamId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_getCars", parameter: {"team_id": teamId}); + + debugPrint(teamId.toString()); + + Map responseJson = jsonDecode(response.body!); + debugPrint("RESPONSE"); + debugPrint(responseJson.toString()); + CarGetResponseDTO responseDto = CarGetResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return responseDto.cars! + .map((carDto) => Car(id: int.parse(carDto.id), plate: carDto.plate)) + .toList(); + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE FETCHING CARS"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } +} diff --git a/lib/feature/delivery/detail/bloc/delivery_bloc.dart b/lib/feature/delivery/detail/bloc/delivery_bloc.dart new file mode 100644 index 0000000..3e4754a --- /dev/null +++ b/lib/feature/delivery/detail/bloc/delivery_bloc.dart @@ -0,0 +1,309 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/dto/discount_add_response.dart'; +import 'package:hl_lieferservice/dto/discount_update_response.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_state.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/repository/delivery_repository.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; + +import '../../../../dto/discount_remove_response.dart'; +import '../../../../model/article.dart'; +import '../../../../model/delivery.dart' as model; + +class DeliveryBloc extends Bloc { + OperationBloc opBloc; + DeliveryRepository repository; + + DeliveryBloc({required this.opBloc, required this.repository}) + : super(DeliveryInitial()) { + on(_unscan); + on(_resetAmount); + on(_load); + on(_addDiscount); + on(_removeDiscount); + on(_updateDiscount); + on(_updateDeliveryOptions); + on(_updatePayment); + } + + void _updatePayment( + UpdateSelectedPaymentMethod event, + Emitter emit, + ) { + final currentState = state; + + if (currentState is DeliveryLoaded) { + emit( + DeliveryLoaded( + delivery: currentState.delivery.copyWith(payment: event.payment), + ), + ); + } + } + + void _updateDeliveryOptions( + UpdateDeliveryOption event, + Emitter emit, + ) { + final currentState = state; + + if (currentState is DeliveryLoaded) { + List options = + currentState.delivery.options.map((option) { + if (option.key == event.key) { + return option.copyWith(value: event.value.toString()); + } + + return option; + }).toList(); + + emit( + DeliveryLoaded( + delivery: currentState.delivery.copyWith(options: options), + ), + ); + } + } + + void _updateDiscount( + UpdateDiscountEvent event, + Emitter emit, + ) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + + if (currentState is DeliveryLoaded) { + DiscountUpdateResponseDTO response = await repository.updateDiscount( + event.deliveryId, + event.reason, + event.value, + ); + + model.Delivery delivery = currentState.delivery; + + if (response.values?.receipt != null) { + delivery.totalNetValue = response.values!.receipt.net; + delivery.totalGrossValue = response.values!.receipt.gross; + } + + String discountArticleNumber = delivery.discount!.article.articleNumber; + delivery.discount = model.Discount( + article: + response.values?.article != null + ? Article.fromDTO(response.values!.article) + : delivery.discount!.article, + note: + response.values?.note != null + ? response.values!.note.noteDescription + : delivery.discount!.note, + noteId: + response.values?.note != null + ? response.values!.note.rowId + : delivery.discount!.noteId, + ); + + delivery.articles = [ + ...delivery.articles.where( + (article) => article.articleNumber != discountArticleNumber, + ), + delivery.discount!.article, + ]; + + emit(currentState.copyWith(delivery)); + + opBloc.add(FinishOperation()); + } + } catch (e, st) { + debugPrint( + "Fehler beim Hinzufügen eins Discounts zur Lieferung: ${event.deliveryId}:", + ); + debugPrint("$e"); + debugPrint("$st"); + + opBloc.add( + FailOperation(message: "Fehler beim Hinzufügen des Discounts: $e"), + ); + } + } + + void _removeDiscount( + RemoveDiscountEvent event, + Emitter emit, + ) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + + if (currentState is DeliveryLoaded) { + model.Delivery delivery = currentState.delivery; + + DiscountRemoveResponseDTO response = await repository.removeDiscount( + event.deliveryId, + ); + + delivery.articles = + delivery.articles + .where( + (article) => + article.internalId != + delivery.discount?.article.internalId, + ) + .toList(); + + delivery.discount = null; + delivery.totalGrossValue = response.receipt.gross; + delivery.totalNetValue = response.receipt.net; + + emit(currentState.copyWith(delivery)); + + opBloc.add(FinishOperation()); + } + } catch (e, st) { + debugPrint( + "Fehler beim Löschen des Discounts der Lieferung: ${event.deliveryId}:", + ); + debugPrint("$e"); + debugPrint("$st"); + + opBloc.add( + FailOperation(message: "Fehler beim Löschen des Discounts: $e"), + ); + } + } + + void _addDiscount(AddDiscountEvent event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + + if (currentState is DeliveryLoaded) { + DiscountAddResponseDTO response = await repository.addDiscount( + event.deliveryId, + event.reason, + event.value, + ); + + model.Delivery delivery = currentState.delivery; + delivery.totalNetValue = response.values.receipt.net; + delivery.totalGrossValue = response.values.receipt.gross; + + delivery.discount = model.Discount( + article: Article.fromDTO(response.values.article), + note: response.values.note.noteDescription, + noteId: response.values.note.rowId, + ); + + delivery.articles = [...delivery.articles, delivery.discount!.article]; + + emit(currentState.copyWith(delivery)); + + opBloc.add(FinishOperation()); + } + } catch (e, st) { + debugPrint( + "Fehler beim Hinzufügen eins Discounts zur Lieferung: ${event.deliveryId}:", + ); + debugPrint("$e"); + debugPrint("$st"); + + opBloc.add( + FailOperation(message: "Fehler beim Hinzufügen des Discounts: $e"), + ); + } + } + + void _load(LoadDeliveryEvent event, Emitter emit) async { + debugPrint("Discount; ${event.delivery.discount?.note}"); + emit(DeliveryLoaded(delivery: event.delivery)); + } + + void _unscan(UnscanArticleEvent event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + String? noteId = await repository.unscan( + event.articleId, + event.newAmount, + event.reason, + ); + + if (noteId != null) { + final currentState = state; + + if (currentState is DeliveryLoaded) { + Article article = currentState.delivery.articles.firstWhere( + (article) => article.internalId == int.parse(event.articleId), + ); + + article.removeNoteId = noteId; + article.scannedRemovedAmount += event.newAmount; + article.scannedAmount -= event.newAmount; + + List
articles = [ + ...currentState.delivery.articles.where( + (article) => article.internalId != int.parse(event.articleId), + ), + article, + ]; + currentState.delivery.articles = articles; + + emit.call(currentState.copyWith(currentState.delivery)); + } + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Unscan des Artikels: ${event.articleId}:"); + debugPrint("$e"); + debugPrint("$st"); + + opBloc.add(FailOperation(message: "Fehler beim Unscan des Artikels: $e")); + } + } + + void _resetAmount( + ResetScanAmountEvent event, + Emitter emit, + ) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + await repository.resetScan(event.articleId); + + if (currentState is DeliveryLoaded) { + Article article = currentState.delivery.articles.firstWhere( + (article) => article.internalId == int.parse(event.articleId), + ); + + article.removeNoteId = null; + article.scannedRemovedAmount = 0; + article.scannedAmount = article.amount; + + List
articles = [ + ...currentState.delivery.articles.where( + (article) => article.internalId != int.parse(event.articleId), + ), + article, + ]; + currentState.delivery.articles = articles; + + emit.call(currentState.copyWith(currentState.delivery)); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Unscan des Artikels: ${event.articleId}:"); + debugPrint("$e"); + debugPrint("$st"); + + opBloc.add(FailOperation(message: "Fehler beim Zurücksetzen: $e")); + } + } +} diff --git a/lib/feature/delivery/detail/bloc/delivery_event.dart b/lib/feature/delivery/detail/bloc/delivery_event.dart new file mode 100644 index 0000000..14442db --- /dev/null +++ b/lib/feature/delivery/detail/bloc/delivery_event.dart @@ -0,0 +1,71 @@ +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/model/tour.dart'; + +abstract class DeliveryEvent {} + +class LoadDeliveryEvent extends DeliveryEvent { + LoadDeliveryEvent({required this.delivery}); + + Delivery delivery; +} + +class UnscanArticleEvent extends DeliveryEvent { + UnscanArticleEvent({ + required this.articleId, + required this.newAmount, + required this.reason, + }); + + String articleId; + String reason; + int newAmount; +} + +class ResetScanAmountEvent extends DeliveryEvent { + ResetScanAmountEvent({required this.articleId}); + + String articleId; +} + +class AddDiscountEvent extends DeliveryEvent { + AddDiscountEvent({ + required this.deliveryId, + required this.value, + required this.reason, + }); + + String deliveryId; + String reason; + int value; +} + +class RemoveDiscountEvent extends DeliveryEvent { + RemoveDiscountEvent({required this.deliveryId}); + + String deliveryId; +} + +class UpdateDiscountEvent extends DeliveryEvent { + UpdateDiscountEvent({ + required this.deliveryId, + required this.value, + required this.reason, + }); + + String deliveryId; + String? reason; + int? value; +} + +class UpdateDeliveryOption extends DeliveryEvent { + UpdateDeliveryOption({required this.key, required this.value}); + + String key; + dynamic value; +} + +class UpdateSelectedPaymentMethod extends DeliveryEvent { + UpdateSelectedPaymentMethod({required this.payment}); + + Payment payment; +} diff --git a/lib/feature/delivery/detail/bloc/delivery_state.dart b/lib/feature/delivery/detail/bloc/delivery_state.dart new file mode 100644 index 0000000..0ebf874 --- /dev/null +++ b/lib/feature/delivery/detail/bloc/delivery_state.dart @@ -0,0 +1,15 @@ +import 'package:hl_lieferservice/model/delivery.dart'; + +abstract class DeliveryState {} + +class DeliveryInitial extends DeliveryState {} + +class DeliveryLoaded extends DeliveryState { + DeliveryLoaded({required this.delivery}); + + Delivery delivery; + + DeliveryLoaded copyWith(Delivery? delivery) { + return DeliveryLoaded(delivery: delivery ?? this.delivery); + } +} \ No newline at end of file diff --git a/lib/feature/delivery/detail/bloc/note_bloc.dart b/lib/feature/delivery/detail/bloc/note_bloc.dart new file mode 100644 index 0000000..cf8e8ea --- /dev/null +++ b/lib/feature/delivery/detail/bloc/note_bloc.dart @@ -0,0 +1,188 @@ +import 'dart:typed_data'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; + +import 'note_event.dart'; +import 'note_state.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/repository/note_repository.dart'; + +class NoteBloc extends Bloc { + final NoteRepository repository; + final OperationBloc opBloc; + + NoteBloc({required this.repository, required this.opBloc}) + : super(NoteInitial()) { + on(_load); + on(_add); + on(_edit); + on(_remove); + on(_upload); + on(_removeImage); + } + + Future _removeImage( + RemoveImageNote event, + Emitter emit, + ) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + await repository.deleteImage(event.deliveryId, event.objectId); + + if (currentState is NoteLoaded) { + emit.call( + currentState.copyWith( + images: + currentState.images + .where((image) => image.$1.objectId != event.objectId) + .toList(), + ), + ); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Löschen des Bildes: $e"); + debugPrint(st.toString()); + + opBloc.add(FailOperation(message: e.toString())); + } + } + + Future _upload(AddImageNote event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + Uint8List imageBytes = await event.file.readAsBytes(); + ImageNote note = await repository.addImage(event.deliveryId, imageBytes); + + if (currentState is NoteLoaded) { + emit.call( + currentState.copyWith( + images: [...currentState.images, (note, imageBytes)], + ), + ); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Hinzufügen des Bildes: $e"); + debugPrint(st.toString()); + + opBloc.add(FailOperation(message: e.toString())); + } + } + + Future _load(LoadNote event, Emitter emit) async { + emit.call(NoteLoading()); + + try { + List urls = + event.delivery.images.map((image) => image.url).toList(); + List notes = await repository.loadNotes(event.delivery.id); + List templates = await repository.loadTemplates(); + List images = await repository.loadImages(urls); + + emit.call( + NoteLoaded( + notes: notes, + templates: templates, + images: List.generate( + images.length, + (index) => (event.delivery.images[index], images[index]), + ), + ), + ); + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Herunterladen der Notizen: $e"); + debugPrint(st.toString()); + + opBloc.add( + FailOperation(message: "Notizen konnten nicht heruntergeladen werden."), + ); + + emit.call(NoteLoadingFailed()); + } + } + + Future _add(AddNote event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + Note note = await repository.addNote(event.deliveryId, event.note); + + if (currentState is NoteLoaded) { + List refreshedNotes = [...currentState.notes, note]; + emit.call(currentState.copyWith(notes: refreshedNotes)); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Hinzufügen der Notiz: $e"); + debugPrint(st.toString()); + + opBloc.add(FailOperation(message: e.toString())); + } + } + + Future _edit(EditNote event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + await repository.editNote(event.noteId, event.content); + + if (currentState is NoteLoaded) { + List refreshedNotes = [ + ...currentState.notes.where( + (note) => note.id != int.parse(event.noteId), + ), + Note(content: event.content, id: int.parse(event.noteId)), + ]; + emit.call(currentState.copyWith(notes: refreshedNotes)); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Hinzufügen der Notiz: $e"); + debugPrint(st.toString()); + + opBloc.add(FailOperation(message: e.toString())); + } + } + + Future _remove(RemoveNote event, Emitter emit) async { + opBloc.add(LoadOperation()); + + try { + final currentState = state; + await repository.deleteNote(event.noteId); + + if (currentState is NoteLoaded) { + List refreshedNotes = + currentState.notes + .where((note) => note.id != int.parse(event.noteId)) + .toList(); + + emit.call(currentState.copyWith(notes: refreshedNotes)); + } + + opBloc.add(FinishOperation()); + } catch (e, st) { + debugPrint("Fehler beim Hinzufügen der Notiz: $e"); + debugPrint(st.toString()); + + opBloc.add( + FailOperation(message: "Notizen konnte nicht gelöscht werden."), + ); + } + } +} diff --git a/lib/feature/delivery/detail/bloc/note_event.dart b/lib/feature/delivery/detail/bloc/note_event.dart new file mode 100644 index 0000000..2064123 --- /dev/null +++ b/lib/feature/delivery/detail/bloc/note_event.dart @@ -0,0 +1,44 @@ +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:image_picker/image_picker.dart'; + +abstract class NoteEvent {} + +class LoadNote extends NoteEvent { + LoadNote({required this.delivery}); + + final Delivery delivery; +} + +class AddNote extends NoteEvent { + AddNote({required this.note, required this.deliveryId}); + + final String note; + final String deliveryId; +} + +class RemoveNote extends NoteEvent { + RemoveNote({required this.noteId}); + + final String noteId; +} + +class EditNote extends NoteEvent { + EditNote({required this.content, required this.noteId}); + + final String noteId; + final String content; +} + +class AddImageNote extends NoteEvent { + AddImageNote({required this.file, required this.deliveryId}); + + final XFile file; + final String deliveryId; +} + +class RemoveImageNote extends NoteEvent { + RemoveImageNote({required this.objectId, required this.deliveryId}); + + final String objectId; + final String deliveryId; +} diff --git a/lib/feature/delivery/detail/bloc/note_state.dart b/lib/feature/delivery/detail/bloc/note_state.dart new file mode 100644 index 0000000..4565839 --- /dev/null +++ b/lib/feature/delivery/detail/bloc/note_state.dart @@ -0,0 +1,35 @@ +import 'dart:typed_data'; + +import 'package:hl_lieferservice/model/delivery.dart'; + +abstract class NoteState {} + +class NoteInitial extends NoteState {} + +class NoteLoading extends NoteState {} + +class NoteLoadingFailed extends NoteState {} + +class NoteLoaded extends NoteState { + NoteLoaded({ + required this.notes, + required this.templates, + required this.images, + }); + + List notes; + List templates; + List<(ImageNote, Uint8List)> images; + + NoteLoaded copyWith({ + List? notes, + List? templates, + List<(ImageNote, Uint8List)>? images, + }) { + return NoteLoaded( + notes: notes ?? this.notes, + templates: templates ?? this.templates, + images: images ?? this.images, + ); + } +} diff --git a/lib/feature/delivery/detail/model/note.dart b/lib/feature/delivery/detail/model/note.dart new file mode 100644 index 0000000..229d276 --- /dev/null +++ b/lib/feature/delivery/detail/model/note.dart @@ -0,0 +1,9 @@ +import 'package:hl_lieferservice/model/article.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class NoteInformation { + NoteInformation({required this.note, this.article}); + + Note note; + Article? article; +} diff --git a/lib/feature/delivery/detail/presentation/article/article_list.dart b/lib/feature/delivery/detail/presentation/article/article_list.dart new file mode 100644 index 0000000..68f17cb --- /dev/null +++ b/lib/feature/delivery/detail/presentation/article/article_list.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/article/article_list_item.dart'; +import 'package:hl_lieferservice/model/article.dart'; + +class ArticleList extends StatefulWidget { + const ArticleList({ + super.key, + required this.articles, + required this.deliveryId, + }); + + final List
articles; + final String deliveryId; + + @override + State createState() => _ArticleListState(); +} + +class _ArticleListState extends State { + @override + Widget build(BuildContext context) { + return ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: + (context, index) => ArticleListItem( + article: widget.articles[index], + deliveryId: widget.deliveryId, + ), + separatorBuilder: (context, index) => const Divider(height: 0), + itemCount: widget.articles.length, + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/article/article_list_item.dart b/lib/feature/delivery/detail/presentation/article/article_list_item.dart new file mode 100644 index 0000000..d995b85 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/article/article_list_item.dart @@ -0,0 +1,85 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/article/article_reset_scan_dialog.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/article/article_unscan_dialog.dart'; +import 'package:hl_lieferservice/model/article.dart'; + +class ArticleListItem extends StatefulWidget { + const ArticleListItem({ + super.key, + required this.article, + required this.deliveryId, + }); + + final Article article; + final String deliveryId; + + @override + State createState() => _ArticleListItem(); +} + +class _ArticleListItem extends State { + Widget _leading() { + int amount = widget.article.getScannedAmount(); + Color? color; + Color? textColor; + + if (amount == 0) { + color = Colors.redAccent; + textColor = Theme.of(context).colorScheme.onSecondary; + } + + return CircleAvatar( + backgroundColor: color, + child: Text("${amount}x", style: TextStyle(color: textColor)), + ); + } + + @override + Widget build(BuildContext context) { + Widget actionButton = IconButton.outlined( + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll(Colors.redAccent), + ), + onPressed: () { + showDialog( + context: context, + builder: (context) => ArticleUnscanDialog(article: widget.article), + ); + }, + icon: Icon( + Icons.delete, + color: Theme.of(context).colorScheme.onSecondary, + ), + ); + + if (widget.article.unscanned()) { + actionButton = IconButton.outlined( + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll(Colors.blueAccent), + ), + onPressed: () { + showDialog( + context: context, + builder: + (context) => ResetArticleAmountDialog(article: widget.article), + ); + }, + icon: Icon( + Icons.refresh, + color: Theme.of(context).colorScheme.onSecondary, + ), + ); + } + + return Padding( + padding: const EdgeInsets.all(0), + child: ListTile( + tileColor: Theme.of(context).colorScheme.surfaceContainerLowest, + title: Text(widget.article.name), + leading: _leading(), + subtitle: Text("Artikelnr. ${widget.article.articleNumber}"), + trailing: actionButton, + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/article/article_reset_scan_dialog.dart b/lib/feature/delivery/detail/presentation/article/article_reset_scan_dialog.dart new file mode 100644 index 0000000..57614d7 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/article/article_reset_scan_dialog.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; + +import '../../../../../model/article.dart'; + +class ResetArticleAmountDialog extends StatefulWidget { + const ResetArticleAmountDialog({super.key, required this.article}); + + final Article article; + + @override + State createState() => _ResetArticleAmountDialogState(); +} + +class _ResetArticleAmountDialogState extends State { + void _reset() { + context.read().add( + ResetScanAmountEvent(articleId: widget.article.internalId.toString()), + ); + + Navigator.pop(context); + } + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: const Text("Anzahl Artikel zurücksetzen?"), + content: SizedBox( + height: 120, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text("Wollen Sie die entfernten Artikel wieder hinzufügen?"), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + FilledButton( + onPressed: _reset, + child: const Text("Zurücksetzen"), + ), + OutlinedButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text("Abbrechen"), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/article/article_unscan_dialog.dart b/lib/feature/delivery/detail/presentation/article/article_unscan_dialog.dart new file mode 100644 index 0000000..f496377 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/article/article_unscan_dialog.dart @@ -0,0 +1,153 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; + +import '../../../../../model/article.dart'; + +class ArticleUnscanDialog extends StatefulWidget { + const ArticleUnscanDialog({super.key, required this.article}); + + final Article article; + + @override + State createState() => _ArticleUnscanDialogState(); +} + +class _ArticleUnscanDialogState extends State { + late TextEditingController unscanAmountController; + late TextEditingController unscanNoteController; + bool isValidText = false; + final _formKey = GlobalKey(); + + void _unscan() { + context.read().add( + UnscanArticleEvent( + articleId: widget.article.internalId.toString(), + newAmount: int.parse(unscanAmountController.text), + reason: unscanNoteController.text, + ), + ); + + Navigator.pop(context); + } + + @override + void initState() { + super.initState(); + + unscanAmountController = TextEditingController(text: "1"); + unscanNoteController = TextEditingController(text: ""); + + unscanNoteController.addListener(() { + setState(() { + isValidText = _isValid(); + }); + }); + + unscanAmountController.addListener(() { + setState(() { + isValidText = _isValid(); + }); + }); + } + + @override + void dispose() { + unscanAmountController.dispose(); + unscanNoteController.dispose(); + super.dispose(); + } + + bool _isValid() { + return _isAmountValid() && unscanNoteController.text.isNotEmpty; + } + + bool _isAmountValid() { + final amount = int.tryParse(unscanAmountController.text); + return amount != null && amount > 0 && amount <= widget.article.amount; + } + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: const Text("Scan rückgängig machen"), + content: SizedBox( + width: double.infinity, + height: 350, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + "Wollen Sie den Scanvorgang des Artikel '${widget.article.name}' rückgängig machen und den Artikel aus der Bestellung entfernen?", + ), + Form( + key: _formKey, + autovalidateMode: AutovalidateMode.always, + child: Column( + children: [ + TextFormField( + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + validator: (text) { + if (text == null || text.isEmpty) { + return "Geben Sie eine Zahl ein"; + } + + final amount = int.tryParse(text); + if (amount == null || amount <= 0) { + return "Geben Sie eine gültige Zahl ein"; + } + + if (amount > widget.article.amount) { + return "Maximal ${widget.article.amount} möglich."; + } + + return null; + }, + controller: unscanAmountController, + decoration: const InputDecoration( + labelText: "Menge zu löschender Artikel", + ), + ), + TextFormField( + controller: unscanNoteController, + keyboardType: TextInputType.text, + decoration: const InputDecoration( + labelText: "Grund für die Entfernung", + ), + validator: (text) { + if (text == null || text.isEmpty) { + return "Geben Sie einen Grund an."; + } + + return null; + }, + ), + ], + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + FilledButton( + onPressed: isValidText ? _unscan : null, + child: const Text("Entfernen"), + ), + OutlinedButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Abbrechen"), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/delivery_detail_page.dart b/lib/feature/delivery/detail/presentation/delivery_detail_page.dart new file mode 100644 index 0000000..50a4417 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/delivery_detail_page.dart @@ -0,0 +1,186 @@ +import 'dart:typed_data'; + +import 'package:easy_stepper/easy_stepper.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_state.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_sign.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step.dart'; +import 'package:hl_lieferservice/model/delivery.dart' as model; + +class DeliveryDetail extends StatefulWidget { + final model.Delivery delivery; + + const DeliveryDetail({super.key, required this.delivery}); + + @override + State createState() => _DeliveryDetailState(); +} + +class _DeliveryDetailState extends State { + late int _step; + late List _steps; + + @override + void initState() { + super.initState(); + + // Initialize BLOC + context.read().add( + LoadDeliveryEvent(delivery: widget.delivery), + ); + + // Initialize steps + _step = 0; + _steps = [ + EasyStep( + icon: const Icon(Icons.info), + customTitle: Text("Info", textAlign: TextAlign.center), + ), + EasyStep( + icon: const Icon(Icons.book), + customTitle: Text("Notizen", textAlign: TextAlign.center), + ), + EasyStep( + icon: const Icon(Icons.shopping_cart), + customTitle: Text("Artikel/Gutschriften", textAlign: TextAlign.center), + ), + EasyStep( + icon: const Icon(Icons.settings), + customTitle: Text("Optionen", textAlign: TextAlign.center), + ), + EasyStep( + icon: const Icon(Icons.check_box), + customTitle: Text( + "Überprüfen", + textAlign: TextAlign.center, + overflow: TextOverflow.clip, + ), + ), + ]; + } + + Widget _stepInfo() { + return DecoratedBox( + decoration: const BoxDecoration(), + child: SizedBox( + height: 115, + child: EasyStepper( + activeStep: _step, + showLoadingAnimation: false, + activeStepTextColor: Theme.of(context).primaryColor, + activeStepBorderType: BorderType.dotted, + finishedStepBorderType: BorderType.normal, + unreachedStepBorderType: BorderType.normal, + activeStepBackgroundColor: Colors.white, + borderThickness: 2, + internalPadding: 0.0, + enableStepTapping: true, + stepRadius: 25.0, + onStepReached: + (index) => { + setState(() { + _step = index; + }), + }, + steps: _steps, + ), + ), + ); + } + + Widget _stepMissingWarning() { + return Center( + child: Text("Kein Inhalt für den aktuellen Step $_step gefunden."), + ); + } + + void _clickForward() { + if (_step < _steps.length) { + setState(() { + _step += 1; + }); + } + } + + void _clickBack() { + if (_step > 0) { + setState(() { + _step -= 1; + }); + } + } + + void _openSignatureView() { + Navigator.of(context).push( + MaterialPageRoute( + builder: + (context) => SignatureView( + onSigned: _onSign, + customer: widget.delivery.customer, + ), + ), + ); + } + + void _onSign(Uint8List customer, Uint8List driver) async { + + } + + Widget _stepsNavigation() { + return SizedBox( + width: double.infinity, + height: 90, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + OutlinedButton( + onPressed: _step == 0 ? null : _clickBack, + child: const Text("zurück"), + ), + Padding( + padding: const EdgeInsets.only(left: 20), + child: FilledButton( + onPressed: _step == _steps.length - 1 ? _openSignatureView : _clickForward, + child: + _step == _steps.length - 1 + ? const Text("Unterschreiben") + : const Text("weiter"), + ), + ), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text("Auslieferungsdetails")), + body: BlocBuilder( + builder: (context, state) { + final currentState = state; + + if (currentState is DeliveryLoaded) { + return Column( + children: [ + _stepInfo(), + const Divider(), + Expanded( + child: + StepFactory().make(_step, currentState.delivery) ?? + _stepMissingWarning(), + ), + _stepsNavigation(), + ], + ); + } + + return Container(); + }, + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/delivery_discount.dart b/lib/feature/delivery/detail/presentation/delivery_discount.dart new file mode 100644 index 0000000..b45d696 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/delivery_discount.dart @@ -0,0 +1,221 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class DeliveryDiscount extends StatefulWidget { + const DeliveryDiscount({ + super.key, + this.discount, + required this.disabled, + required this.deliveryId, + }); + + final bool disabled; + final Discount? discount; + final String deliveryId; + + @override + State createState() => _DeliveryDiscountState(); +} + +class _DeliveryDiscountState extends State { + final int stepSize = 10; + + late TextEditingController _reasonController; + late bool _isReasonEmpty; + late bool _isUpdated; + late int _discountValue; + + @override + void initState() { + super.initState(); + + _reasonController = TextEditingController(text: widget.discount?.note); + _isReasonEmpty = _reasonController.text.isEmpty; + _reasonController.addListener(() { + setState(() { + _isReasonEmpty = _reasonController.text.isEmpty; + }); + }); + + _discountValue = + widget.discount?.article.getGrossPrice().floor().abs() ?? 0; + + _isUpdated = _discountValue > 0 && _reasonController.text.isNotEmpty; + } + + @override + void dispose() { + super.dispose(); + _reasonController.dispose(); + } + + bool _maximumReached() { + return _discountValue >= 150; + } + + bool _minimumReached() { + return _discountValue <= 0; + } + + Widget _incrementDiscount() { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton.filled( + onPressed: + _minimumReached() || widget.disabled + ? null + : () { + setState(() { + if (_discountValue - stepSize >= 0) { + _discountValue -= stepSize; + } + }); + }, + icon: const Icon(Icons.remove), + style: ButtonStyle( + backgroundColor: + _minimumReached() || widget.disabled + ? WidgetStateProperty.all(Colors.grey) + : WidgetStateProperty.all(Colors.red), + ), + ), + Padding( + padding: const EdgeInsets.all(5), + child: Column( + children: [ + Text( + "${_discountValue.abs()}€", + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18.0, + ), + ), + const Text("max. 150€", style: TextStyle(fontSize: 10.0)), + ], + ), + ), + IconButton.filled( + onPressed: + _maximumReached() || widget.disabled + ? null + : () { + setState(() { + _discountValue += stepSize; + }); + }, + icon: const Icon(Icons.add), + style: ButtonStyle( + backgroundColor: + _maximumReached() || widget.disabled + ? WidgetStateProperty.all(Colors.grey) + : WidgetStateProperty.all(Colors.green), + ), + ), + ], + ); + } + + void _resetValues() async { + setState(() { + _discountValue = 0; + _reasonController.clear(); + _isUpdated = false; + }); + + context.read().add( + RemoveDiscountEvent(deliveryId: widget.deliveryId), + ); + } + + void _updateValues() async { + if (_isUpdated) { + context.read().add( + UpdateDiscountEvent( + deliveryId: widget.deliveryId, + value: _discountValue, + reason: _reasonController.text, + ), + ); + } else { + context.read().add( + AddDiscountEvent( + deliveryId: widget.deliveryId, + value: _discountValue, + reason: _reasonController.text, + ), + ); + + setState(() { + setState(() { + _isUpdated = true; + }); + }); + } + } + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.onSecondary, + ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Form( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + "Betrag:", + style: TextStyle(fontWeight: FontWeight.bold), + ), + _incrementDiscount(), + const Padding( + padding: const EdgeInsets.only(top: 10), + child: const Text( + "Begründung:", + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 20), + child: TextFormField( + controller: _reasonController, + validator: (text) { + if (text == null || text.isEmpty) { + return "Begründung für Gutschrift notwendig."; + } + + return null; + }, + ), + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.only(right: 10), + child: FilledButton( + onPressed: + !_isReasonEmpty && _discountValue > 0 + ? _updateValues + : null, + child: const Text("Speichern"), + ), + ), + OutlinedButton( + onPressed: _discountValue > 0 ? _resetValues : null, + child: const Text("Gutschrift entfernen"), + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/delivery_options.dart b/lib/feature/delivery/detail/presentation/delivery_options.dart new file mode 100644 index 0000000..85add48 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/delivery_options.dart @@ -0,0 +1,84 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; +import 'package:hl_lieferservice/model/delivery.dart' as model; + +class DeliveryOptionsView extends StatefulWidget { + const DeliveryOptionsView({super.key, required this.options}); + + final List options; + + @override + State createState() => _DeliveryOptionsViewState(); +} + +class _DeliveryOptionsViewState extends State { + @override + void initState() { + super.initState(); + } + + @override + void didUpdateWidget(covariant DeliveryOptionsView oldWidget) { + super.didUpdateWidget(oldWidget); + } + + void _update(model.DeliveryOption option, dynamic value) { + context.read().add( + UpdateDeliveryOption(key: option.key, value: value), + ); + } + + List _options() { + List boolOptions = + widget.options.where((option) => !option.numerical).map((option) { + return CheckboxListTile( + value: option.getValue() as bool, + onChanged: (value) => _update(option, value), + title: Text(option.display), + ); + }).toList(); + + List numericalOptions = + widget.options.where((option) => option.numerical).map((option) { + return Padding( + padding: const EdgeInsets.all(15), + child: TextFormField( + decoration: InputDecoration(labelText: option.display), + initialValue: option.getValue().toString(), + keyboardType: TextInputType.number, + onTapOutside: (event) => FocusScope.of(context).unfocus(), + onChanged: (value) => _update(option, value), + ), + ); + }).toList(); + + return [ + Padding( + padding: const EdgeInsets.only(bottom: 5), + child: Text( + "Auswählbare Optionen", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + ...boolOptions, + Padding( + padding: const EdgeInsets.only(top: 10), + child: Text( + "Zahlenwerte", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + ...numericalOptions, + ]; + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(10), + child: ListView(children: _options()), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/delivery_sign.dart b/lib/feature/delivery/detail/presentation/delivery_sign.dart new file mode 100644 index 0000000..f51520b --- /dev/null +++ b/lib/feature/delivery/detail/presentation/delivery_sign.dart @@ -0,0 +1,164 @@ +import 'dart:typed_data'; + +import 'package:hl_lieferservice/model/customer.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:signature/signature.dart'; + +class SignatureView extends StatefulWidget { + const SignatureView({ + super.key, + required this.onSigned, + required this.customer, + }); + + final Customer customer; + + /// Callback that is called when the user has signed. + /// The parameter stores the path to the image file of the signature. + final void Function(Uint8List customerSignaturePng, Uint8List driverSignaturePng) onSigned; + + @override + State createState() => _SignatureViewState(); +} + +class _SignatureViewState extends State { + final SignatureController _customerController = SignatureController( + penStrokeWidth: 5, + penColor: Colors.black, + exportBackgroundColor: Colors.white, + ); + + final SignatureController _driverController = SignatureController( + penStrokeWidth: 5, + penColor: Colors.black, + exportBackgroundColor: Colors.white, + ); + + bool _isDriverSigning = false; + bool _customerAccepted = false; + + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + _customerController.dispose(); + super.dispose(); + } + + Widget _signatureField() { + return Signature( + controller: _isDriverSigning ? _driverController : _customerController, + backgroundColor: Colors.white, + ); + } + + @override + Widget build(BuildContext context) { + String formattedDate = DateFormat("dd.MM.yyyy").format(DateTime.now()); + + return Scaffold( + appBar: AppBar( + title: + !_isDriverSigning + ? const Text("Unterschrift des Kunden") + : const Text("Unterschrift des Fahrers"), + ), + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: SizedBox( + width: double.infinity, + child: DecoratedBox( + decoration: const BoxDecoration(color: Colors.white), + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "Lieferung an: ${widget.customer.name}", + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + Expanded(child: _signatureField()), + ], + ), + ), + const Divider(), + Text( + "${widget.customer.address.city}, den $formattedDate", + ), + ], + ), + ), + ), + ), + ), + !_isDriverSigning + ? Padding( + padding: const EdgeInsets.only(top: 25.0, bottom: 25.0), + child: Row( + children: [ + Checkbox( + value: _customerAccepted, + onChanged: (value) { + setState(() { + _customerAccepted = value!; + }); + }, + ), + const Flexible( + child: Text( + "Ich bestätige, dass ich die Ware im ordnungsgemäßen Zustand erhalten habe und, dass die Aufstell- und Einbauarbeiten korrekt durchgeführt wurden.", + overflow: TextOverflow.fade, + ), + ), + ], + ), + ) + : Container(), + Padding( + padding: const EdgeInsets.only(top: 25.0, bottom: 25.0), + child: Center( + child: FilledButton( + onPressed: + !_customerAccepted + ? null + : () async { + if (!_isDriverSigning) { + setState(() { + _isDriverSigning = true; + }); + } else { + widget.onSigned( + (await _customerController.toPngBytes())!, + (await _driverController.toPngBytes())!, + ); + } + }, + child: + !_isDriverSigning + ? const Text("Weiter") + : const Text("Absenden"), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/delivery_summary.dart b/lib/feature/delivery/detail/presentation/delivery_summary.dart new file mode 100644 index 0000000..3dc8e93 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/delivery_summary.dart @@ -0,0 +1,182 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_event.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_state.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +import '../../../../model/tour.dart'; + +class DeliverySummary extends StatefulWidget { + const DeliverySummary({super.key, required this.delivery}); + + final Delivery delivery; + + @override + State createState() => _DeliverySummaryState(); +} + +class _DeliverySummaryState extends State { + late List _paymentMethods; + + @override + void initState() { + super.initState(); + + final tourState = context.read().state as TourLoaded; + _paymentMethods = [ + widget.delivery.payment, + ...tourState.tour.paymentMethods, + ]; + } + + Widget _deliveredArticles() { + List items = + widget.delivery + .getDeliveredArticles() + .map( + (article) => DecoratedBox( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.onSecondary, + ), + child: ListTile( + title: Text(article.name), + subtitle: Text("Artikelnr. ${article.articleNumber}"), + trailing: Text( + "${article.scannable ? article.getGrossPriceScanned().toStringAsFixed(2) : article.getGrossPrice().toStringAsFixed(2)}€", + ), + leading: CircleAvatar( + child: Text( + "${article.scannable ? article.scannedAmount : article.amount}x", + ), + ), + ), + ), + ) + .toList(); + items.add( + DecoratedBox( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.onSecondary, + ), + child: ListTile( + title: const Text( + "Gesamtsumme:", + style: TextStyle(fontWeight: FontWeight.bold), + ), + trailing: Text( + "${widget.delivery.getGrossPrice().toStringAsFixed(2)}€", + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + ); + + return ListView( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + children: items, + ); + } + + Widget _paymentOptions() { + List entries = + _paymentMethods + .map( + (payment) => DropdownMenuEntry( + value: payment.id, + label: "${payment.description} (${payment.shortcode})", + ), + ) + .toList(); + + debugPrint(widget.delivery.payment.id); + + return DropdownMenu( + dropdownMenuEntries: entries, + initialSelection: widget.delivery.payment.id, + onSelected: (id) { + context.read().add( + UpdateSelectedPaymentMethod( + payment: _paymentMethods.firstWhere( + (payment) => payment.id == id, + ), + ), + ); + }, + ); + } + + Widget _payment() { + return _paymentOptions(); + } + + Widget _paymentDone() { + return DecoratedBox( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.onSecondary, + ), + child: Column( + children: [ + ListTile( + title: const Text( + "Bei Bestellung bezahlt:", + style: TextStyle(fontWeight: FontWeight.bold), + ), + trailing: Text("${widget.delivery.prepayment.toStringAsFixed(2)}€"), + ), + ListTile( + title: const Text( + "Offener Betrag:", + style: TextStyle(fontWeight: FontWeight.bold), + ), + trailing: Text( + "${widget.delivery.getOpenPrice().toStringAsFixed(2)}€", + style: TextStyle(fontWeight: FontWeight.w900, color: Colors.red), + ), + ), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + final insets = EdgeInsets.all(10); + + return Padding( + padding: const EdgeInsets.all(10), + child: ListView( + children: [ + Text( + "Ausgelieferte Artikel", + style: Theme.of(context).textTheme.headlineSmall, + ), + + Padding(padding: insets, child: _deliveredArticles()), + + Padding( + padding: const EdgeInsets.only(top: 10), + child: Text( + "Geleistete Zahlung", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + + Padding(padding: insets, child: _paymentDone()), + + Padding( + padding: const EdgeInsets.only(top: 10), + child: Text( + "Zahlungsmethode", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + + Padding(padding: insets, child: _payment()), + ], + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_add_dialog.dart b/lib/feature/delivery/detail/presentation/note/note_add_dialog.dart new file mode 100644 index 0000000..6c2f30a --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_add_dialog.dart @@ -0,0 +1,151 @@ +import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class NoteAddDialog extends StatefulWidget { + final String delivery; + final List templates; + + const NoteAddDialog({ + super.key, + required this.delivery, + required this.templates, + }); + + @override + State createState() => _NoteAddDialogState(); +} + +class _NoteAddDialogState extends State { + final _noteController = TextEditingController(); + final _noteSelectionController = TextEditingController(); + late FocusNode _noteFieldFocusNode; + bool _isCustomNotesEmpty = true; + + @override + void initState() { + super.initState(); + + _noteFieldFocusNode = FocusNode(); + + _noteController.addListener(() { + setState(() { + _isCustomNotesEmpty = _noteController.text.isEmpty; + }); + }); + } + + void _onSave() { + String content = _noteController.text; + + if (_noteSelectionController.text.isNotEmpty) { + NoteTemplate template = widget.templates.firstWhere( + (note) => note.title == _noteSelectionController.text, + ); + + content = template.content; + } + + context.read().add( + AddNote(note: content, deliveryId: widget.delivery), + ); + + Navigator.pop(context); + } + + @override + Widget build(BuildContext context) { + return Dialog( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.75, + height: MediaQuery.of(context).size.height * 0.45, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Notiz hinzufügen", + style: Theme.of(context).textTheme.headlineSmall, + ), + IconButton( + onPressed: () { + Navigator.of(context).pop(); + }, + icon: Icon(Icons.close), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(bottom: 10.0, top: 20), + child: DropdownMenu( + controller: _noteSelectionController, + onSelected: (int? value) { + setState(() { + _noteSelectionController.text = + widget.templates[value!].title; + }); + }, + enabled: _isCustomNotesEmpty, + width: double.infinity, + label: const Text("Notiz auswählen"), + dropdownMenuEntries: + widget.templates + .mapIndexed( + (i, note) => + DropdownMenuEntry(value: i, label: note.title), + ) + .toList(), + ), + ), + const Padding( + padding: EdgeInsets.only(top: 0.0, bottom: 0.0), + child: Text("oder"), + ), + Padding( + padding: const EdgeInsets.only(top: 10.0, bottom: 20.0), + child: TextFormField( + controller: _noteController, + enabled: _noteSelectionController.text.isEmpty, + focusNode: _noteFieldFocusNode, + decoration: const InputDecoration( + labelText: "Eigene Notiz", + border: OutlineInputBorder(), + ), + minLines: 3, + maxLines: 5, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + FilledButton( + onPressed: + _noteSelectionController.text.isNotEmpty || + _noteController.text.isNotEmpty + ? _onSave + : null, + child: const Text("Hinzufügen"), + ), + Padding( + padding: const EdgeInsets.only(left: 10.0), + child: OutlinedButton( + onPressed: null, + child: const Text("Zurücksetzen"), + ), + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_edit_dialog.dart b/lib/feature/delivery/detail/presentation/note/note_edit_dialog.dart new file mode 100644 index 0000000..0600e53 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_edit_dialog.dart @@ -0,0 +1,104 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class NoteEditDialog extends StatefulWidget { + final Note note; + + const NoteEditDialog({super.key, required this.note}); + + @override + State createState() => _NoteEditDialogState(); +} + +class _NoteEditDialogState extends State { + final _formKey = GlobalKey(); + late TextEditingController _editController; + + @override + void initState() { + super.initState(); + + _editController = TextEditingController(text: widget.note.content); + } + + void _onEdit(BuildContext context) { + context.read().add( + EditNote( + content: _editController.text, + noteId: widget.note.id.toString(), + ), + ); + + Navigator.of(context).pop(); + } + + @override + Widget build(BuildContext context) { + return Dialog( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.75, + height: MediaQuery.of(context).size.height * 0.32, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + Text( + "Notiz bearbeiten", + style: Theme.of(context).textTheme.headlineMedium, + ), + + Padding( + padding: const EdgeInsets.only(top: 15), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextFormField( + onTapOutside: (event) { + FocusScope.of(context).unfocus(); + }, + decoration: InputDecoration(label: const Text("Notiz")), + controller: _editController, + minLines: 4, + maxLines: 8, + ), + + Padding( + padding: const EdgeInsets.only(top: 20), + child: Row( + children: [ + FilledButton( + onPressed: () { + _onEdit(context); + }, + child: const Text("Bearbeiten"), + ), + + Padding( + padding: const EdgeInsets.only(left: 10), + child: OutlinedButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text("Abbrechen"), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_image_overview.dart b/lib/feature/delivery/detail/presentation/note/note_image_overview.dart new file mode 100644 index 0000000..37d1eba --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_image_overview.dart @@ -0,0 +1,109 @@ +import 'dart:typed_data'; + +import 'package:carousel_slider/carousel_slider.dart'; +import 'package:flutter/material.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class NoteImageOverview extends StatefulWidget { + final List<(ImageNote, Uint8List)> images; + final String deliveryId; + + const NoteImageOverview({ + super.key, + required this.images, + required this.deliveryId, + }); + + @override + State createState() => _NoteImageOverviewState(); +} + +class _NoteImageOverviewState extends State { + int? _imageDeleting; + + void _onRemoveImage(int index) { + ImageNote note = widget.images[index].$1; + + context.read().add( + RemoveImageNote(objectId: note.objectId, deliveryId: widget.deliveryId), + ); + } + + Widget _buildImageCarousel() { + return CarouselSlider( + options: CarouselOptions( + height: 300.0, + aspectRatio: 2.0, + enableInfiniteScroll: false, + ), + items: + widget.images.mapIndexed((index, data) { + ImageNote note = data.$1; + Uint8List bytes = data.$2; + + return Builder( + builder: (BuildContext context) { + return Stack( + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Image.memory( + bytes, + fit: BoxFit.fill, + width: 1920.0, + height: 1090.0, + ), + ), + _imageDeleting == index + ? Stack( + children: [ + Padding( + padding: const EdgeInsets.all(15.0), + child: Container( + color: Colors.black.withValues(alpha: 0.5), + ), + ), + Center( + child: CircularProgressIndicator( + backgroundColor: + Theme.of(context).colorScheme.onSecondary, + ), + ), + ], + ) + : Container(), + Positioned( + right: 0.0, + top: 0.0, + child: CircleAvatar( + radius: 20, + child: IconButton.filled( + onPressed: + !(_imageDeleting == index) + ? () { + _onRemoveImage(index); + } + : null, + icon: const Icon(Icons.delete, color: Colors.white), + ), + ), + ), + ], + ); + }, + ); + }).toList(), + ); + } + + @override + Widget build(BuildContext context) { + return widget.images.isEmpty + ? const Center(child: Text("Noch keine Bilder hochgeladen")) + : _buildImageCarousel(); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_list.dart b/lib/feature/delivery/detail/presentation/note/note_list.dart new file mode 100644 index 0000000..4e806ee --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_list.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/model/note.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_list_item.dart'; + +class NoteList extends StatelessWidget { + final List notes; + final String deliveryId; + + const NoteList({super.key, required this.notes, required this.deliveryId}); + + @override + Widget build(BuildContext context) { + if (notes.isEmpty) { + return const Center(child: Text("keine Notizen vorhanden")); + } + + return ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: + (context, index) => NoteListItem( + note: notes[index], + deliveryId: deliveryId, + index: index, + ), + separatorBuilder: (context, index) => const Divider(height: 0), + itemCount: notes.length, + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_list_item.dart b/lib/feature/delivery/detail/presentation/note/note_list_item.dart new file mode 100644 index 0000000..66249db --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_list_item.dart @@ -0,0 +1,90 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/model/note.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_edit_dialog.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_state.dart'; + +import '../../../../../model/delivery.dart'; + +class NoteListItem extends StatelessWidget { + final NoteInformation note; + final String deliveryId; + final int index; + + const NoteListItem({ + super.key, + required this.note, + required this.deliveryId, + required this.index, + }); + + void _onDelete(BuildContext context) { + context.read().add(RemoveNote(noteId: note.note.id.toString())); + } + + Widget? _subtitle(BuildContext context) { + String discountArticleId = + (context.read().state as TourLoaded) + .tour + .discountArticleNumber; + + if (note.article != null && note.article?.articleNumber == discountArticleId) { + return const Text("Begründung der Gutschrift"); + } + + return note.article != null ? Text(note.article!.name) : null; + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(0), + child: ListTile( + title: Text(note.note.content), + subtitle: _subtitle(context), + tileColor: Theme.of(context).colorScheme.surfaceContainerLowest, + leading: CircleAvatar(child: Text("${index + 1}")), + trailing: PopupMenuButton( + itemBuilder: (context) { + return [ + PopupMenuItem( + onTap: () { + showDialog( + context: context, + builder: (context) => NoteEditDialog(note: note.note), + ); + }, + child: Row( + children: [ + Icon(Icons.edit, color: Colors.blueAccent), + Padding( + padding: const EdgeInsets.only(left: 5), + child: const Text("Editieren"), + ), + ], + ), + ), + PopupMenuItem( + onTap: () { + _onDelete(context); + }, + child: Row( + children: [ + Icon(Icons.delete, color: Colors.redAccent), + Padding( + padding: const EdgeInsets.only(left: 5), + child: const Text("Löschen"), + ), + ], + ), + ), + ]; + }, + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/note/note_overview.dart b/lib/feature/delivery/detail/presentation/note/note_overview.dart new file mode 100644 index 0000000..c553e0b --- /dev/null +++ b/lib/feature/delivery/detail/presentation/note/note_overview.dart @@ -0,0 +1,162 @@ +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/model/note.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_add_dialog.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_image_overview.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_list.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; +import 'package:image_picker/image_picker.dart'; + +class NoteOverview extends StatefulWidget { + final List notes; + final List templates; + final List<(ImageNote, Uint8List)> images; + final String deliveryId; + + const NoteOverview({ + super.key, + required this.notes, + required this.deliveryId, + required this.templates, + required this.images, + }); + + @override + State createState() => _NoteOverviewState(); +} + +class _NoteOverviewState extends State { + final _imagePicker = ImagePicker(); + + Widget _notes() { + return NoteList(notes: widget.notes, deliveryId: widget.deliveryId); + } + + Widget _images() { + return NoteImageOverview( + images: widget.images, + deliveryId: widget.deliveryId, + ); + } + + void _onAddNote(BuildContext context) { + showDialog( + context: context, + builder: (context) { + return NoteAddDialog( + delivery: widget.deliveryId, + templates: widget.templates, + ); + }, + ); + } + + void _onAddImage(BuildContext context) async { + XFile? file = await _imagePicker.pickImage(source: ImageSource.camera); + if (file == null) { + context.read().add( + FailOperation(message: "Fehler beim Aufnehmen des Bildes"), + ); + return; + } + + context.read().add( + AddImageNote(file: file, deliveryId: widget.deliveryId), + ); + } + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Padding( + padding: const EdgeInsets.all(10), + child: ListView( + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Text( + "Notizen", + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + _notes(), + + Padding( + padding: const EdgeInsets.only(bottom: 10, top: 10), + child: Text( + "Bilder", + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + + _images(), + ], + ), + ), + + Align( + alignment: Alignment.bottomRight, + child: Padding( + padding: const EdgeInsets.only(right: 25), + child: PopupMenuButton( + itemBuilder: (context) { + return [ + PopupMenuItem( + child: Row( + children: [ + Icon( + Icons.note_add_rounded, + color: Theme.of(context).primaryColor, + ), + Padding( + padding: const EdgeInsets.only(left: 10), + child: const Text("Notiz hinzufügen"), + ), + ], + ), + onTap: () => _onAddNote(context), + ), + PopupMenuItem( + child: Row( + children: [ + Icon( + Icons.image, + color: Theme.of(context).primaryColor, + ), + Padding( + padding: const EdgeInsets.only(left: 10), + child: const Text("Bild hochladen"), + ), + ], + ), + onTap: () => _onAddImage(context), + ), + ]; + }, + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll( + Theme.of(context).primaryColor, + ), + ), + child: CircleAvatar( + radius: 32, + backgroundColor: Theme.of(context).primaryColor, + child: Icon( + Icons.add, + color: Theme.of(context).colorScheme.onSecondary, + ), + ), + ), + ), + ), + ], + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/steps/step.dart b/lib/feature/delivery/detail/presentation/steps/step.dart new file mode 100644 index 0000000..eae03e0 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step.dart @@ -0,0 +1,32 @@ +import 'package:flutter/cupertino.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_article_management.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_delivery_options.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_info.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_note.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/steps/step_summary.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +abstract class IStepFactory { + Widget? make(int step, Delivery delivery); +} + +class StepFactory extends IStepFactory { + @override + Widget? make(int step, Delivery delivery) { + switch(step) { + case 0: + return DeliveryStepInfo(delivery: delivery); + case 1: + return DeliveryStepNote(delivery: delivery); + case 2: + return DeliveryStepArticleManagement(delivery: delivery); + case 3: + return DeliveryStepOptions(delivery: delivery); + case 4: + return DeliveryStepSummary(delivery: delivery); + } + + return null; + } + +} \ No newline at end of file diff --git a/lib/feature/delivery/detail/presentation/steps/step_article_management.dart b/lib/feature/delivery/detail/presentation/steps/step_article_management.dart new file mode 100644 index 0000000..f0edf1e --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step_article_management.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/article/article_list.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_discount.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_state.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class DeliveryStepArticleManagement extends StatefulWidget { + final Delivery delivery; + + const DeliveryStepArticleManagement({required this.delivery, super.key}); + + @override + State createState() => _DeliveryStepInfo(); +} + +class _DeliveryStepInfo extends State { + Widget _articleOverview() { + TourLoaded tour = context.read().state as TourLoaded; + + return ArticleList( + articles: + widget.delivery.articles + .where( + (article) => + article.articleNumber != tour.tour.discountArticleNumber, + ) + .toList(), + deliveryId: widget.delivery.id, + ); + } + + Widget _discountView() { + return DeliveryDiscount( + disabled: false, + discount: widget.delivery.discount, + deliveryId: widget.delivery.id, + ); + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(10), + child: Container( + width: double.infinity, + alignment: Alignment.centerLeft, + child: ListView( + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Text( + "Artikel", + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + _articleOverview(), + + Padding( + padding: const EdgeInsets.only(top: 20, bottom: 10), + child: Text( + "Gutschriften", + style: Theme.of(context).textTheme.headlineMedium, + ), + ), + + _discountView(), + ], + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/steps/step_delivery_options.dart b/lib/feature/delivery/detail/presentation/steps/step_delivery_options.dart new file mode 100644 index 0000000..894d993 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step_delivery_options.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_options.dart'; +import 'package:hl_lieferservice/model/delivery.dart' as model; + +class DeliveryStepOptions extends StatefulWidget { + final model.Delivery delivery; + + const DeliveryStepOptions({required this.delivery, super.key}); + + @override + State createState() => _DeliveryStepInfo(); +} + +class _DeliveryStepInfo extends State { + @override + Widget build(BuildContext context) { + debugPrint( + "${widget.delivery.options.map((option) => "${option.display}, ${option.value}")}", + ); + return DeliveryOptionsView(options: widget.delivery.options); + } +} diff --git a/lib/feature/delivery/detail/presentation/steps/step_info.dart b/lib/feature/delivery/detail/presentation/steps/step_info.dart new file mode 100644 index 0000000..3e74b75 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step_info.dart @@ -0,0 +1,199 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/model/article.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +import '../../../overview/bloc/tour_bloc.dart'; +import '../../../overview/bloc/tour_state.dart'; + +class DeliveryStepInfo extends StatefulWidget { + final Delivery delivery; + + const DeliveryStepInfo({required this.delivery, super.key}); + + @override + State createState() => _DeliveryStepInfo(); +} + +class _DeliveryStepInfo extends State { + Widget _fastActions() { + return SizedBox( + width: double.infinity, + child: Card( + color: Theme.of(context).colorScheme.onSecondary, + child: Padding( + padding: const EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + children: [ + IconButton.filled(onPressed: () {}, icon: Icon(Icons.phone)), + Text("Anrufen"), + ], + ), + + Column( + children: [ + IconButton.filled( + onPressed: () {}, + icon: Icon(Icons.map_outlined), + ), + Text("Navigation starten"), + ], + ), + ], + ), + ), + ), + ); + } + + Widget _customerInformation() { + return SizedBox( + width: double.infinity, + child: Card( + color: Theme.of(context).colorScheme.onSecondary, + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Row( + children: [ + Icon(Icons.person, color: Theme.of(context).primaryColor), + Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + widget.delivery.customer.name, + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ], + ), + + Padding( + padding: const EdgeInsets.only(top: 15), + child: Row( + children: [ + Icon( + Icons.other_houses, + color: Theme.of(context).primaryColor, + ), + Padding( + padding: const EdgeInsets.only(left: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(widget.delivery.customer.address.street), + Text( + "${widget.delivery.customer.address.postalCode} ${widget.delivery.customer.address.city}", + ), + ], + ), + ), + ], + ), + ), + + Padding( + padding: const EdgeInsets.only(top: 15), + child: Row( + children: [ + Icon(Icons.phone, color: Theme.of(context).primaryColor), + Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + widget.delivery.contactPerson?.phoneNumber.toString() ?? + "", + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + } + + Widget _articleList() { + TourLoaded tour = context.read().state as TourLoaded; + List
filteredArticles = + widget.delivery.articles + .where( + (article) => + article.articleNumber != tour.tour.discountArticleNumber, + ) + .toList(); + + return ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + Article article = filteredArticles[index]; + + return DecoratedBox( + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.onSecondary, + ), + child: ListTile( + title: Text(article.name), + subtitle: Text("Artikelnr. ${article.articleNumber}"), + leading: Chip(label: Text("${article.amount.toString()}x")), + ), + ); + }, + separatorBuilder: (context, index) => const Divider(height: 0), + itemCount: filteredArticles.length, + ); + } + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.all(10), + child: ListView( + children: [ + Text( + "Schnellaktionen", + style: Theme.of(context).textTheme.headlineSmall, + ), + + Padding( + padding: const EdgeInsets.only(top: 10), + child: _fastActions(), + ), + + Padding( + padding: const EdgeInsets.only(top: 20), + child: Text( + "Kundeninformationen", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 10), + child: _customerInformation(), + ), + + Padding( + padding: const EdgeInsets.only(top: 20), + child: Text( + "Zu liefernde Artikel", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + + Padding( + padding: const EdgeInsets.only(top: 20), + child: _articleList(), + ), + ], + ), + ), + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/steps/step_note.dart b/lib/feature/delivery/detail/presentation/steps/step_note.dart new file mode 100644 index 0000000..61908ff --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step_note.dart @@ -0,0 +1,91 @@ +import 'dart:typed_data'; + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_event.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_state.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/model/note.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/note/note_overview.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class DeliveryStepNote extends StatefulWidget { + final Delivery delivery; + + const DeliveryStepNote({required this.delivery, super.key}); + + @override + State createState() => _DeliveryStepInfo(); +} + +class _DeliveryStepInfo extends State { + @override + void initState() { + super.initState(); + context.read().add(LoadNote(delivery: widget.delivery)); + } + + Widget _notesLoadingFailed() { + return Center(child: Text("Notizen können nicht heruntergeladen werden..")); + } + + Widget _notesLoading() { + return Center(child: CircularProgressIndicator()); + } + + Widget _blocUndefinedState() { + return Center(child: const Text("NoteBloc in einem Fehlerhaften Zustand")); + } + + Widget _notesOverview( + BuildContext context, + List notes, + List templates, + List<(ImageNote, Uint8List)> images, + ) { + List hydratedNotes = + notes + .map( + (note) => NoteInformation( + note: note, + article: widget.delivery.findArticleWithNoteId( + note.id.toString(), + ), + ), + ) + .toList(); + + return NoteOverview( + notes: hydratedNotes, + deliveryId: widget.delivery.id, + templates: templates, + images: images, + ); + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is NoteLoading) { + return _notesLoading(); + } + + if (state is NoteLoaded) { + return _notesOverview( + context, + state.notes, + state.templates, + state.images, + ); + } + + if (state is NoteLoadingFailed) { + return _notesLoadingFailed(); + } + + return _blocUndefinedState(); + }, + ); + } +} diff --git a/lib/feature/delivery/detail/presentation/steps/step_summary.dart b/lib/feature/delivery/detail/presentation/steps/step_summary.dart new file mode 100644 index 0000000..71e8e38 --- /dev/null +++ b/lib/feature/delivery/detail/presentation/steps/step_summary.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_summary.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +class DeliveryStepSummary extends StatefulWidget { + final Delivery delivery; + + const DeliveryStepSummary({required this.delivery, super.key}); + + @override + State createState() => _DeliveryStepInfo(); +} + +class _DeliveryStepInfo extends State { + @override + Widget build(BuildContext context) { + return DeliverySummary(delivery: widget.delivery); + } +} diff --git a/lib/feature/delivery/detail/repository/delivery_repository.dart b/lib/feature/delivery/detail/repository/delivery_repository.dart new file mode 100644 index 0000000..1d8feae --- /dev/null +++ b/lib/feature/delivery/detail/repository/delivery_repository.dart @@ -0,0 +1,38 @@ +import 'package:hl_lieferservice/dto/discount_add_response.dart'; +import 'package:hl_lieferservice/dto/discount_remove_response.dart'; +import 'package:hl_lieferservice/dto/discount_update_response.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/service/delivery_info_service.dart'; + +class DeliveryRepository { + DeliveryRepository({required this.service}); + + DeliveryInfoService service; + + Future unscan(String articleId, int newAmount, String reason) async { + return await service.unscanArticle(articleId, newAmount, reason); + } + + Future resetScan(String articleId) async { + return await service.resetScannedArticleAmount(articleId); + } + + Future addDiscount( + String deliveryId, + String reason, + int value, + ) { + return service.addDiscount(deliveryId, value, reason); + } + + Future removeDiscount(String deliveryId) { + return service.removeDiscount(deliveryId); + } + + Future updateDiscount( + String deliveryId, + String? reason, + int? value, + ) { + return service.updateDiscount(deliveryId, reason, value); + } +} diff --git a/lib/feature/delivery/detail/repository/note_repository.dart b/lib/feature/delivery/detail/repository/note_repository.dart new file mode 100644 index 0000000..a250dd0 --- /dev/null +++ b/lib/feature/delivery/detail/repository/note_repository.dart @@ -0,0 +1,58 @@ +import 'dart:typed_data'; + +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/service/notes_service.dart'; + +class NoteRepository { + final NoteService service; + + NoteRepository({required this.service}); + + Future addNote(String deliveryId, String content) async { + return service.addNote(content, int.parse(deliveryId)); + } + + Future editNote(String noteId, String content) async { + return service.editNote(Note(content: content, id: int.parse(noteId))); + } + + Future deleteNote(String noteId) async { + return service.deleteNote(int.parse(noteId)); + } + + Future> loadNotes(String deliveryId) async { + return service.getNotes(deliveryId); + } + + Future> loadImages(List urls) async { + List images = []; + + for (final image in await service.downloadImages(urls)) { + images.add(await image); + } + + return images; + } + + Future> loadTemplates() async { + return service.getNoteTemplates(); + } + + Future addImage(String deliveryId, Uint8List bytes) async { + final fileName = + "delivery_note_${deliveryId}_${DateTime.timestamp().microsecondsSinceEpoch}.jpg"; + + String objectId = await service.uploadImage( + deliveryId, + fileName, + bytes, + "image/png", + ); + + return ImageNote.make(objectId, fileName); + } + + Future deleteImage(String deliveryId, String objectId) async { + await service.removeImage(objectId); + } +} diff --git a/lib/feature/delivery/detail/service/notes_service.dart b/lib/feature/delivery/detail/service/notes_service.dart new file mode 100644 index 0000000..a6453d8 --- /dev/null +++ b/lib/feature/delivery/detail/service/notes_service.dart @@ -0,0 +1,287 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:hl_lieferservice/dto/note_get_response.dart'; +import 'package:hl_lieferservice/services/erpframe.dart'; +import 'package:docuframe/docuframe.dart' as df; +import 'package:flutter/cupertino.dart'; +import 'package:http/http.dart' as http; + +import '../../../../dto/basic_response.dart'; +import '../../../../dto/note_add_response.dart'; +import '../../../../dto/note_template_response.dart'; +import '../../../../model/delivery.dart'; + +class NoteService extends ErpFrameService { + NoteService({required super.config}); + + Future deleteNote(int noteId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute("_web_deleteNote", parameter: {"id": noteId}); + + Map responseJson = jsonDecode(response.body!); + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE DELETING NOTE $noteId"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future editNote(Note newNote) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute( + "_web_editNote", + parameter: {"id": newNote.id, "note": newNote.content}, + ); + + Map responseJson = jsonDecode(response.body!); + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE EDITING NOTE ${newNote.id}"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future> getNoteTemplates() async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute("_web_getNoteTemplates"); + + Map responseJson = jsonDecode(response.body!); + NoteTemplateResponseDTO responseDto = NoteTemplateResponseDTO.fromJson( + responseJson, + ); + + if (responseDto.succeeded == true) { + return responseDto.notes.map(NoteTemplate.fromDTO).toList(); + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE GETTING NOTE TEMPLATES"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future> getNotes(String deliveryId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute("_web_getNotes", parameter: {"delivery_id": deliveryId}); + debugPrint(deliveryId); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + NoteGetResponseDTO responseDto = NoteGetResponseDTO.fromJson( + responseJson, + ); + + if (responseDto.succeeded == true) { + return responseDto.notes + .map((noteDto) => Note.fromDto(noteDto)) + .toList(); + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE GETTING NOTES"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future addNote(String note, int deliveryId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute( + "_web_addNote", + parameter: {"receipt_id": deliveryId, "note": note}, + ); + + debugPrint(deliveryId.toString()); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + NoteAddResponseDTO responseDto = NoteAddResponseDTO.fromJson( + responseJson, + ); + + if (responseDto.succeeded == true) { + return Note.fromDto(responseDto.note!); + } else { + debugPrint("ERROR: ${responseDto.message}"); + throw responseDto.message; + } + } catch (e) { + rethrow; + } finally { + await logout(session); + } + } + + Future uploadImage( + String deliveryId, + String filename, + Uint8List bytes, + String? mimeType, + ) async { + df.LoginSession? session; + + try { + session = await getSession(); + + // First get UPLOAD ID + df.UploadFile uploadHandler = df.UploadFile( + config: dfConfig, + session: session, + ); + df.GetUploadIdResponse uploadIdResponse = + await uploadHandler.getUploadId(); + + // Upload binary data to DOCUframe + debugPrint(filename); + df.FileInformationResponse response = await uploadHandler.uploadFile( + uploadIdResponse.uploadId, + bytes, + filename, + mimeType ?? "image/jpeg", + ); + debugPrint(response.body); + + // Commit file upload + df.CommitFileUploadResponse commitResponse = await uploadHandler + .commitUpload(uploadIdResponse.uploadId); + debugPrint(commitResponse.body); + + return commitResponse.objectId; + } catch (e, st) { + debugPrint("An error occured:"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future>> downloadImages(List urls) async { + df.LoginSession? session; + + debugPrint(urls.toString()); + + try { + session = await getSession(); + + final header = { + "sessionId": session.getAuthorizationHeader().$2, + "appKey": config.appNames[0], + }; + + return urls.map((url) async { + return (await http.get( + Uri.parse("${config.host}$url"), + headers: header, + )).bodyBytes; + }).toList(); + } catch (e, st) { + debugPrint("An error occured:"); + debugPrint("$e"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future removeImage(String oid) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = await df.Macro( + config: dfConfig, + session: session, + ).execute("_web_removeImage", parameter: {"oid": oid}); + + Map responseJson = jsonDecode(response.body!); + debugPrint(oid); + debugPrint(responseJson.toString()); + + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + debugPrint("ERROR: ${responseDto.message}"); + throw responseDto.message; + } + } on df.DocuFrameException catch (e, st) { + debugPrint("${e.errorMessage}"); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } +} diff --git a/lib/feature/delivery/overview/bloc/tour_bloc.dart b/lib/feature/delivery/overview/bloc/tour_bloc.dart new file mode 100644 index 0000000..434301e --- /dev/null +++ b/lib/feature/delivery/overview/bloc/tour_bloc.dart @@ -0,0 +1,33 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_state.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/repository/tour_repository.dart'; +import 'package:hl_lieferservice/model/tour.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; + +class TourBloc extends Bloc { + OperationBloc opBloc; + TourRepository deliveryRepository; + + TourBloc({required this.opBloc, required this.deliveryRepository}) + : super(TourInitial()) { + on(_load); + } + + Future _load(LoadTour event, Emitter emit) async { + opBloc.add(LoadOperation()); + try { + Tour tour = await deliveryRepository.loadAll(event.teamId); + List payments = await deliveryRepository.loadPaymentOptions(); + tour.paymentMethods = payments; + + emit(TourLoaded(tour: tour)); + opBloc.add(FinishOperation()); + } catch (e) { + opBloc.add( + FailOperation(message: "Fehler beim Laden der heutigen Fahrten"), + ); + } + } +} diff --git a/lib/feature/delivery/overview/bloc/tour_event.dart b/lib/feature/delivery/overview/bloc/tour_event.dart new file mode 100644 index 0000000..b33e2cd --- /dev/null +++ b/lib/feature/delivery/overview/bloc/tour_event.dart @@ -0,0 +1,7 @@ +abstract class TourEvent {} + +class LoadTour extends TourEvent { + String teamId; + + LoadTour({required this.teamId}); +} diff --git a/lib/feature/delivery/overview/bloc/tour_state.dart b/lib/feature/delivery/overview/bloc/tour_state.dart new file mode 100644 index 0000000..d3b0246 --- /dev/null +++ b/lib/feature/delivery/overview/bloc/tour_state.dart @@ -0,0 +1,13 @@ +import '../../../../model/tour.dart'; + +abstract class TourState {} + +class TourInitial extends TourState {} + +class TourLoading extends TourState {} + +class TourLoaded extends TourState { + Tour tour; + + TourLoaded({required this.tour}); +} \ No newline at end of file diff --git a/lib/feature/delivery/overview/presentation/delivery_info.dart b/lib/feature/delivery/overview/presentation/delivery_info.dart new file mode 100644 index 0000000..e2122d6 --- /dev/null +++ b/lib/feature/delivery/overview/presentation/delivery_info.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/model/tour.dart'; +import 'package:intl/intl.dart'; + +class DeliveryInfo extends StatelessWidget { + final Tour tour; + + const DeliveryInfo({super.key, required this.tour}); + + @override + Widget build(BuildContext context) { + String date = DateFormat("dd.MM.yyyy").format(tour.date); + String amountDeliveries = tour.deliveries.length.toString(); + + return Padding( + padding: const EdgeInsets.all(10), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Text( + "Informationen", + style: Theme.of(context).textTheme.headlineSmall, + ), + ), + + SizedBox( + width: double.infinity, + child: Card( + color: Theme.of(context).colorScheme.onSecondary, + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon(Icons.calendar_month), + Padding( + padding: const EdgeInsets.only(left: 5), + child: Text("Datum"), + ), + ], + ), + Text(date), + ], + ), + + Padding( + padding: const EdgeInsets.only(top: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Icon(Icons.local_shipping_outlined), + Padding( + padding: const EdgeInsets.only(left: 5), + child: Text("Lieferungen"), + ), + ], + ), + Text(amountDeliveries), + ], + ), + ), + ], + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/feature/delivery/overview/presentation/delivery_item.dart b/lib/feature/delivery/overview/presentation/delivery_item.dart new file mode 100644 index 0000000..ecd2bfa --- /dev/null +++ b/lib/feature/delivery/overview/presentation/delivery_item.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +import 'package:hl_lieferservice/feature/delivery/detail/presentation/delivery_detail_page.dart'; + +class DeliveryListItem extends StatelessWidget { + final Delivery delivery; + + const DeliveryListItem({super.key, required this.delivery}); + + Widget _leading(BuildContext context) { + if (delivery.state == DeliveryState.finished) { + return Icon(Icons.check_circle, color: Colors.green); + } + + if (delivery.state == DeliveryState.canceled) { + return Icon(Icons.cancel_rounded, color: Colors.red); + } + + return Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Icon(Icons.location_on, color: Theme.of(context).primaryColor), + Text("5min"), + ], + ); + } + + void _goToDelivery(BuildContext context) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => DeliveryDetail(delivery: delivery), + ), + ); + } + + @override + Widget build(BuildContext context) { + return ListTile( + title: Text( + delivery.customer.name, + style: Theme.of(context).textTheme.titleMedium, + ), + leading: _leading(context), + tileColor: Theme.of(context).colorScheme.surfaceContainerHigh, + subtitle: Text(delivery.customer.address.toString()), + trailing: Icon(Icons.arrow_forward_ios), + onTap: () => _goToDelivery(context), + ); + } +} diff --git a/lib/feature/delivery/overview/presentation/delivery_list.dart b/lib/feature/delivery/overview/presentation/delivery_list.dart new file mode 100644 index 0000000..8547932 --- /dev/null +++ b/lib/feature/delivery/overview/presentation/delivery_list.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; + +import 'delivery_item.dart'; + +class DeliveryList extends StatefulWidget { + final List deliveries; + + const DeliveryList({super.key, required this.deliveries}); + + @override + State createState() => _DeliveryListState(); +} + +class _DeliveryListState extends State { + @override + Widget build(BuildContext context) { + if (widget.deliveries.isEmpty) { + return ListView( + children: [Center(child: const Text("Keine Auslieferungen gefunden"))], + ); + } + + return ListView.separated( + separatorBuilder: (context, index) => const Divider(height: 0), + itemBuilder: + (context, index) => + DeliveryListItem(delivery: widget.deliveries[index]), + itemCount: widget.deliveries.length, + ); + } +} diff --git a/lib/feature/delivery/overview/presentation/delivery_overview.dart b/lib/feature/delivery/overview/presentation/delivery_overview.dart new file mode 100644 index 0000000..f777590 --- /dev/null +++ b/lib/feature/delivery/overview/presentation/delivery_overview.dart @@ -0,0 +1,119 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_info.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_list.dart'; +import 'package:hl_lieferservice/model/tour.dart'; + +import '../../../authentication/bloc/auth_bloc.dart'; +import '../../../authentication/bloc/auth_state.dart'; + +class DeliveryOverview extends StatefulWidget { + const DeliveryOverview({super.key, required this.tour}); + + final Tour tour; + + @override + State createState() => _DeliveryOverviewState(); +} + +class _DeliveryOverviewState extends State { + String? _selectedCarPlate; + + @override + void initState() { + super.initState(); + + // Select the first car for initialization + _selectedCarPlate = widget.tour.driver.cars.firstOrNull?.plate; + } + + Future _loadTour() async { + Authenticated state = context.read().state as Authenticated; + context.read().add(LoadTour(teamId: state.teamId)); + } + + Widget _carSelection() { + return SizedBox( + width: double.infinity, + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + children: + widget.tour.driver.cars.map((car) { + Color? backgroundColor; + Color? iconColor = Theme.of(context).primaryColor; + Color? textColor; + + if (_selectedCarPlate == car.plate) { + backgroundColor = Theme.of(context).primaryColor; + textColor = Theme.of(context).colorScheme.onSecondary; + iconColor = Theme.of(context).colorScheme.onSecondary; + } + + return Padding( + padding: const EdgeInsets.only(right: 8), + child: GestureDetector( + onTap: () { + setState(() { + _selectedCarPlate = car.plate; + }); + }, + child: Chip( + backgroundColor: backgroundColor, + label: Row( + children: [ + Icon(Icons.local_shipping, color: iconColor, size: 20), + Padding( + padding: const EdgeInsets.only(left: 5), + child: Text( + car.plate, + style: TextStyle(color: textColor, fontSize: 12), + ), + ), + ], + ), + ), + ), + ); + }).toList(), + ), + ); + } + + @override + Widget build(BuildContext context) { + return RefreshIndicator( + onRefresh: _loadTour, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DeliveryInfo(tour: widget.tour), + Padding( + padding: const EdgeInsets.only(left: 10, right: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Text( + "Fahrten", + style: Theme.of(context).textTheme.headlineSmall, + ), + ], + ), + IconButton(icon: Icon(Icons.filter_list), onPressed: () {}), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(left: 10, right: 10, bottom: 20), + child: _carSelection(), + ), + Expanded(child: DeliveryList(deliveries: widget.tour.deliveries)), + ], + ), + ); + } +} diff --git a/lib/feature/delivery/overview/presentation/delivery_overview_page.dart b/lib/feature/delivery/overview/presentation/delivery_overview_page.dart new file mode 100644 index 0000000..b10c306 --- /dev/null +++ b/lib/feature/delivery/overview/presentation/delivery_overview_page.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_overview.dart'; + +import '../bloc/tour_bloc.dart'; +import '../bloc/tour_state.dart'; + +class DeliveryOverviewPage extends StatefulWidget { + const DeliveryOverviewPage({super.key}); + + @override + State createState() => _DeliveryOverviewPageState(); +} + +class _DeliveryOverviewPageState extends State { + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is TourLoaded) { + final currentState = state; + + return Center(child: DeliveryOverview(tour: currentState.tour)); + } + + return Container(); + }, + ); + } +} diff --git a/lib/feature/delivery/overview/repository/tour_repository.dart b/lib/feature/delivery/overview/repository/tour_repository.dart new file mode 100644 index 0000000..8bd822f --- /dev/null +++ b/lib/feature/delivery/overview/repository/tour_repository.dart @@ -0,0 +1,19 @@ +import 'package:hl_lieferservice/feature/delivery/overview/service/delivery_info_service.dart'; +import 'package:hl_lieferservice/model/tour.dart'; + +class TourRepository { + DeliveryInfoService service; + + TourRepository({required this.service}); + + Future loadAll(String userId) async { + Tour? tour = await service.getTourOfToday(userId); + return tour!; + } + + Future> loadPaymentOptions() async { + return (await service.getPaymentMethods()) + .map((option) => Payment.fromDTO(option)) + .toList(); + } +} diff --git a/lib/feature/delivery/overview/service/delivery_info_service.dart b/lib/feature/delivery/overview/service/delivery_info_service.dart new file mode 100644 index 0000000..a93084f --- /dev/null +++ b/lib/feature/delivery/overview/service/delivery_info_service.dart @@ -0,0 +1,278 @@ +import 'dart:convert'; + +import 'package:docuframe/docuframe.dart' as df; +import 'package:flutter/material.dart'; + +import 'package:hl_lieferservice/dto/delivery_response.dart'; +import 'package:hl_lieferservice/dto/delivery_update.dart'; +import 'package:hl_lieferservice/dto/delivery_update_response.dart'; +import 'package:hl_lieferservice/dto/payment.dart'; +import 'package:hl_lieferservice/dto/payments.dart'; +import 'package:hl_lieferservice/model/car.dart'; +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/model/tour.dart'; +import 'package:hl_lieferservice/util.dart'; +import 'package:hl_lieferservice/services/erpframe.dart'; + +import '../../../../dto/basic_response.dart'; +import '../../../../dto/discount_add_response.dart'; +import '../../../../dto/discount_remove_response.dart'; +import '../../../../dto/discount_update_response.dart'; +import '../../../../dto/scan_response.dart'; + +class DeliveryInfoService extends ErpFrameService { + DeliveryInfoService({required super.config}); + + Future updateDelivery(Delivery delivery) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_updateDelivery", + parameter: DeliveryUpdateDTO.fromEntity(delivery).toJson() + as Map); + + df.Logout(config: dfConfig, session: session).logout(); + + Map responseJson = jsonDecode(response.body!); + DeliveryUpdateResponseDTO responseDto = + DeliveryUpdateResponseDTO.fromJson(responseJson); + + if (responseDto.code == "200") { + return; + } + + throw responseDto.message; + } on df.DocuFrameException catch (e, st) { + debugPrint("ERROR WHILE UPDATING DELIVERY"); + debugPrint(e.errorMessage); + debugPrint(e.errorCode); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + /// List all available deliveries for today. + + Future getTourOfToday(String userId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_getDeliveries", + parameter: {"driver_id": userId, "date": getTodayDate()}); + + Map responseJson = jsonDecode(response.body!); + + DeliveryResponseDTO responseDto = + DeliveryResponseDTO.fromJson(responseJson); + + return Tour( + discountArticleNumber: responseDto.discountArticleNumber, + date: DateTime.now(), + deliveries: responseDto.deliveries.map(Delivery.fromDTO).toList(), + paymentMethods: [], + driver: Driver( + cars: responseDto.driver.cars + .map((carDto) => + Car(id: int.parse(carDto.id), plate: carDto.plate)) + .toList(), + teamNumber: int.parse(responseDto.driver.id), + name: responseDto.driver.name, + salutation: responseDto.driver.salutation)); + } catch (e, stacktrace) { + debugPrint(e.toString()); + debugPrint(stacktrace.toString()); + debugPrint("RANDOM EXCEPTION!"); + + rethrow; + } finally { + await logout(session); + } + } + + Future> getPaymentMethods() async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_getPaymentMethods", parameter: {}); + + Map responseJson = jsonDecode(response.body!); + PaymentMethodListDTO responseDto = + PaymentMethodListDTO.fromJson(responseJson); + + return responseDto.paymentMethods; + } catch (e, st) { + debugPrint("ERROR while retrieving allowed payment methods"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future unscanArticle( + String internalId, int amount, String reason) async { + df.LoginSession? session; + + debugPrint("AMOUNT: $amount"); + debugPrint("ID: $internalId"); + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_unscanArticle", parameter: { + "article_id": internalId, + "amount": amount.toString(), + "reason": reason + }); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + ScanResponseDTO responseDto = ScanResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return responseDto.noteId; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE REVERTING THE SCAN OF ARTICLE $internalId"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future resetScannedArticleAmount(String receiptRowId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_unscanArticleReset", + parameter: {"receipt_row_id": receiptRowId}); + + Map responseJson = jsonDecode(response.body!); + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE REVERTING THE UNSCAN OF ARTICLE $receiptRowId"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future addDiscount( + String deliveryId, int discount, String note) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_addDiscount", parameter: { + "delivery_id": deliveryId, + "discount": discount.toString(), + "note": note + }); + + debugPrint("BODY: ${response.body!}"); + Map responseJson = jsonDecode(response.body!); + + // let it throw, if the values are invalid + return DiscountAddResponseDTO.fromJson(responseJson); + } catch (e, st) { + debugPrint("ERROR while adding discount"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future removeDiscount(String deliveryId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_removeDiscount", parameter: { + "delivery_id": deliveryId, + }); + + debugPrint("${response.body!}"); + + Map responseJson = jsonDecode(response.body!); + + // let it throw, if the values are invalid + return DiscountRemoveResponseDTO.fromJson(responseJson); + } catch (e, st) { + debugPrint("ERROR while removing discount"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future updateDiscount( + String deliveryId, String? note, int? discount) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_updateDiscount", parameter: { + "delivery_id": deliveryId, + "discount": discount, + "note": note + }); + + Map responseJson = jsonDecode(response.body!); + + // let it throw, if the values are invalid + return DiscountUpdateResponseDTO.fromJson(responseJson); + } catch (e, st) { + debugPrint("ERROR while retrieving allowed payment methods"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } +} diff --git a/lib/feature/delivery/overview/service/discount_service.dart b/lib/feature/delivery/overview/service/discount_service.dart new file mode 100644 index 0000000..acef14c --- /dev/null +++ b/lib/feature/delivery/overview/service/discount_service.dart @@ -0,0 +1,14 @@ +import 'dart:convert'; + +import '../../../../services/erpframe.dart'; +import 'package:docuframe/docuframe.dart' as df; +import 'package:flutter/cupertino.dart'; + +import '../../../../dto/discount_add_response.dart'; +import '../../../../dto/discount_remove_response.dart'; +import '../../../../dto/discount_update_response.dart'; + +class DiscountService extends ErpFrameService { + DiscountService({required super.config}); + +} diff --git a/lib/main.dart b/lib/main.dart new file mode 100644 index 0000000..62ba196 --- /dev/null +++ b/lib/main.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/bloc/app_bloc.dart'; +import 'package:hl_lieferservice/bloc/app_events.dart'; +import 'package:hl_lieferservice/widget/app.dart'; + +void main() { + runApp(BlocProvider(create: (context) => AppBloc(), child: App())); +} + +class App extends StatefulWidget { + const App({super.key}); + + @override + State createState() => _AppState(); +} + +class _AppState extends State { + @override + void initState() { + super.initState(); + context.read().add(AppLoadConfig(path: "hl_server_config.json")); + } + + @override + Widget build(BuildContext context) { + return DeliveryApp(); + } +} + diff --git a/lib/model/address.dart b/lib/model/address.dart new file mode 100644 index 0000000..767e183 --- /dev/null +++ b/lib/model/address.dart @@ -0,0 +1,24 @@ +import 'package:hl_lieferservice/dto/address.dart'; + +class Address { + const Address( + {required this.street, + required this.city, + required this.postalCode}); + + final String street; + final String postalCode; + final String city; + + factory Address.fromDTO(AddressDTO dto) { + return Address( + street: dto.streetName, + city: dto.city, + postalCode: dto.postalCode); + } + + @override + String toString() { + return "$street $postalCode $city"; + } +} diff --git a/lib/model/article.dart b/lib/model/article.dart new file mode 100644 index 0000000..6aeaa79 --- /dev/null +++ b/lib/model/article.dart @@ -0,0 +1,64 @@ +import 'package:flutter/cupertino.dart'; +import 'package:hl_lieferservice/dto/article.dart'; + +class Article { + Article({ + required this.name, + required this.articleNumber, + required this.amount, + required this.internalId, + required this.price, + required this.tax, + required this.scannable, + required this.scannedAmount, + required this.scannedRemovedAmount, + this.scannedDate, + this.removeNoteId + }); + + final String name; + final String articleNumber; + final int internalId; + + int amount; + double price; + double tax; + bool scannable; + DateTime? scannedDate; + String? removeNoteId; + int scannedAmount; + int scannedRemovedAmount; + + double getGrossPrice() { + return price * amount * ((100 + tax) / 100); + } + + double getGrossPriceScanned() { + return price * scannedAmount * ((100 + tax) / 100); + } + + bool unscanned() { + return scannedAmount == 0; + } + + int getScannedAmount() { + return scannedAmount; + } + + factory Article.fromDTO(ArticleDTO dto) { + return Article( + name: dto.name, + scannedAmount: int.parse( + dto.scannedAmount != "" ? dto.scannedAmount : "0", + ), + scannedRemovedAmount: int.tryParse(dto.scannedRemovedAmount) ?? 0, + removeNoteId: dto.removeNoteId, + internalId: int.parse(dto.internalId), + articleNumber: dto.articleNr, + amount: int.parse(dto.quantity == "" ? "0" : dto.quantity), + price: double.parse(dto.price == "" ? "0.0" : dto.price), + scannable: dto.scannable, + tax: double.parse(dto.taxRate == "" ? "19" : dto.taxRate), + ); + } +} diff --git a/lib/model/car.dart b/lib/model/car.dart new file mode 100644 index 0000000..332ace7 --- /dev/null +++ b/lib/model/car.dart @@ -0,0 +1,6 @@ +class Car { + Car({required this.id, required this.plate}); + + int id; + String plate; +} \ No newline at end of file diff --git a/lib/model/customer.dart b/lib/model/customer.dart new file mode 100644 index 0000000..3eec4da --- /dev/null +++ b/lib/model/customer.dart @@ -0,0 +1,14 @@ +import 'package:hl_lieferservice/dto/customer.dart'; + +import 'address.dart'; + +class Customer { + const Customer({required this.name, required this.address}); + + final String name; + final Address address; + + factory Customer.fromDTO(CustomerDTO dto) { + return Customer(name: dto.name, address: Address.fromDTO(dto.address)); + } +} diff --git a/lib/model/delivery.dart b/lib/model/delivery.dart new file mode 100644 index 0000000..dbf5e8d --- /dev/null +++ b/lib/model/delivery.dart @@ -0,0 +1,373 @@ +import 'package:flutter/cupertino.dart'; +import 'package:hl_lieferservice/dto/contact_person.dart'; +import 'package:hl_lieferservice/dto/delivery.dart'; +import 'package:hl_lieferservice/dto/image.dart'; +import 'package:hl_lieferservice/dto/note.dart'; +import 'package:hl_lieferservice/dto/note_template.dart'; +import 'package:hl_lieferservice/model/tour.dart'; +import 'package:hl_lieferservice/util.dart'; +import '../dto/payment.dart'; +import 'article.dart'; +import 'customer.dart'; + +class PaymentOptions { + PaymentOptions({this.value = 0.0, this.selectedPaymentMethod = "none"}); + + double value; + String selectedPaymentMethod; +} + +class Note { + Note({required this.content, required this.id}); + + final int id; + String content; + + factory Note.fromDto(NoteDTO dto) { + return Note(content: dto.note, id: int.parse(dto.id)); + } +} + +class NoteTemplate { + NoteTemplate({ + required this.title, + required this.content, + required this.language, + }); + + String title; + String content; + String language; + + factory NoteTemplate.fromDTO(NoteTemplateDTO dto) { + return NoteTemplate( + title: dto.title, + content: dto.note, + language: dto.language, + ); + } +} + +class ContactPerson { + const ContactPerson({required this.name, required this.phoneNumber}); + + final String name; + final String? phoneNumber; + + factory ContactPerson.fromDTO(ContactPersonDTO dto) { + String phone; + String phoneRegex = r'([0-9]+|[0-9]+(-|\/))[0-9]+'; + + if (dto.phoneNo == "" && dto.mobileNo != "") { + phone = dto.mobileNo; + } else if (dto.phoneNo != "" && dto.mobileNo == "") { + phone = dto.phoneNo; + } else { + phone = dto.mobileNo; + } + + return ContactPerson( + name: dto.name, + phoneNumber: concatenateRegexMatches(phone, phoneRegex), + ); + } +} + +enum DeliveryState { canceled, finished, ongoing, onhold } + +class Discount { + Discount({this.note, this.noteId, required this.article}); + + String? note; + String? noteId; + + /// The article refers to the special discount article such as "GUTSCHRIFT10" + /// for example. + Article article; +} + +class ImageNote { + const ImageNote({ + required this.name, + required this.url, + required this.objectId, + }); + + final String name; + final String url; + final String objectId; + + factory ImageNote.fromDTO(ImageDTO dto) { + return ImageNote(name: dto.name, url: dto.url, objectId: dto.oid); + } + + factory ImageNote.make(String objectId, String name) { + String url = "/v1/preview/1920_1080_100_png/$objectId"; + + return ImageNote(name: name, url: url, objectId: objectId); + } +} + +class DeliveryOption { + DeliveryOption({ + required this.numerical, + required this.value, + required this.display, + required this.key, + }); + + bool numerical; + String value; + String display; + String key; + + factory DeliveryOption.fromDTO(DeliveryOptionDTO dto) { + return DeliveryOption( + numerical: dto.numerical, + value: dto.value, + display: dto.display, + key: dto.key, + ); + } + + dynamic getValue() { + if (!numerical) { + if (value.isEmpty) { + return false; + } else { + return bool.parse(value); + } + } else { + if (value.isEmpty) { + return 0; + } else { + return int.parse(value); + } + } + } + + DeliveryOption copyWith({ + bool? numerical, + String? value, + String? display, + String? key, + }) { + return DeliveryOption( + numerical: numerical ?? this.numerical, + value: value ?? this.value, + display: display ?? this.display, + key: key ?? this.key, + ); + } +} + +class Delivery { + Delivery({ + required this.customer, + required this.id, + required this.articles, + required this.paymentOptions, + required this.notes, + required this.price, + required this.filePaths, + required this.currency, + required this.images, + required this.prepayment, + required this.paymentAtDelivery, + required this.payment, + required this.options, + this.state = DeliveryState.ongoing, + this.contactPerson, + required this.totalGrossValue, + required this.totalNetValue, + this.desiredTime, + this.discount, + this.specialAgreements, + this.carId, + }); + + final Customer customer; + final String id; + List
articles; + final ContactPerson? contactPerson; + final double price; + final String currency; + double totalGrossValue; + double totalNetValue; + String? desiredTime; + List filePaths; + Discount? discount; + DeliveryState state; + String? specialAgreements; + PaymentOptions paymentOptions; + int? carId; + List notes; + List images; + double prepayment; + double paymentAtDelivery; + Payment payment; + List options; + + Delivery copyWith({ + Customer? customer, + String? id, + List
? articles, + ContactPerson? contactPerson, + double? price, + String? currency, + double? totalGrossValue, + double? totalNetValue, + String? desiredTime, + List? filePaths, + Discount? discount, + DeliveryState? state, + String? specialAgreements, + PaymentOptions? paymentOptions, + int? carId, + List? notes, + List? images, + double? prepayment, + double? paymentAtDelivery, + Payment? payment, + List? options, + }) { + return Delivery( + customer: customer ?? this.customer, + id: id ?? this.id, + articles: articles ?? this.articles, + contactPerson: contactPerson ?? this.contactPerson, + price: price ?? this.price, + currency: currency ?? this.currency, + totalGrossValue: totalGrossValue ?? this.totalGrossValue, + totalNetValue: totalNetValue ?? this.totalNetValue, + desiredTime: desiredTime ?? this.desiredTime, + filePaths: filePaths ?? this.filePaths, + discount: discount ?? this.discount, + state: state ?? this.state, + specialAgreements: specialAgreements ?? this.specialAgreements, + paymentOptions: paymentOptions ?? this.paymentOptions, + carId: carId ?? this.carId, + notes: notes ?? this.notes, + images: images ?? this.images, + prepayment: prepayment ?? this.prepayment, + paymentAtDelivery: paymentAtDelivery ?? this.paymentAtDelivery, + payment: payment ?? this.payment, + options: options ?? this.options, + ); + } + + Article? findArticleWithNoteId(String noteId) { + Article? filteredArticle = + articles.where((article) => article.removeNoteId == noteId).firstOrNull; + + if (filteredArticle == null && discount?.article != null) { + filteredArticle = discount?.article; + } + + return filteredArticle; + } + + double getGrossPrice() { + return articles.fold(0, (acc, article) { + double price = article.getGrossPriceScanned(); + + if (!article.scannable) { + price = article.getGrossPrice(); + } + + return acc + price; + }); + } + + double getOpenPrice() { + return getGrossPrice() - prepayment; + } + + List
getDeliveredArticles() { + return articles + .where( + (article) { + debugPrint("Scannable: ${article.scannable}"); + + return article.scannedAmount > 0 || !article.scannable; + }, + ) + .toList(); + } + + bool containsArticle(String articleNr) { + return articles.any((article) => article.articleNumber == articleNr); + } + + Article getArticle(String nr) { + return articles.firstWhere((article) => article.articleNumber == nr); + } + + List
getScannableArticles() { + return articles.where((article) => article.scannable).toList(); + } + + bool allArticlesScanned() { + return getScannableArticles().every( + (article) => + article.amount == + article.scannedAmount + article.scannedRemovedAmount, + ); + } + + void scanArticle(String nr) { + if (!containsArticle(nr)) { + return; + } + + Article article = getArticle(nr); + if (article.scannedAmount < article.amount) { + article.scannedAmount += 1; + } + } + + factory Delivery.fromDTO(DeliveryDTO dto) { + double getPrice() { + return double.parse(dto.totalPrice == "" ? "0" : dto.totalPrice); + } + + return Delivery( + customer: Customer.fromDTO(dto.customer), + id: dto.internalReceiptNo, + articles: dto.articles.map(Article.fromDTO).toList(), + paymentOptions: PaymentOptions(value: getPrice()), + notes: dto.notes.map(Note.fromDto).toList(), + price: getPrice(), + payment: Payment.fromDTO(dto.payment), + specialAgreements: dto.specialAggreements, + desiredTime: dto.desiredTime, + prepayment: double.tryParse(dto.prepayment) ?? 0.0, + discount: + dto.discount == null + ? null + : Discount( + article: Article.fromDTO(dto.discount!.article), + note: dto.discount!.note, + noteId: dto.discount!.noteId, + ), + paymentAtDelivery: double.tryParse(dto.paymentAtDelivery) ?? 0.0, + images: dto.images.map(ImageNote.fromDTO).toList(), + carId: int.tryParse(dto.carId), + totalGrossValue: double.parse( + dto.totalGrossValue == "" ? "0" : dto.totalGrossValue, + ), + totalNetValue: double.parse( + dto.totalNetValue == "" ? "0" : dto.totalNetValue, + ), + filePaths: [], + options: + dto.options.map((option) => DeliveryOption.fromDTO(option)).toList(), + state: + dto.state != "" + ? getDeliveryStateFromString(dto.state) + : DeliveryState.ongoing, + contactPerson: ContactPerson.fromDTO(dto.contactPerson), + currency: dto.currency ?? "EUR", + ); + } +} diff --git a/lib/model/tour.dart b/lib/model/tour.dart new file mode 100644 index 0000000..4c957d9 --- /dev/null +++ b/lib/model/tour.dart @@ -0,0 +1,71 @@ +import 'package:hl_lieferservice/dto/payment.dart'; + +import 'car.dart'; +import 'delivery.dart'; + +class Payment { + const Payment({ + required this.description, + required this.shortcode, + required this.id, + }); + + final String id; + final String description; + final String shortcode; + + factory Payment.fromDTO(PaymentMethodDTO dto) { + return Payment( + description: dto.description, + shortcode: dto.shortCode, + id: dto.id, + ); + } +} + +class Tour { + Tour({ + required this.date, + required this.deliveries, + required this.driver, + required this.discountArticleNumber, + required this.paymentMethods, + }); + + final DateTime date; + final String discountArticleNumber; + Driver driver; + final List deliveries; + List paymentMethods; + + int getFinishedDeliveries(int carId) { + return deliveries + .where((delivery) => delivery.carId == carId) + .where((delivery) => delivery.state == DeliveryState.finished) + .toList() + .length; + } +} + +class Driver { + Driver({ + required this.teamNumber, + required this.name, + required this.salutation, + required this.cars, + }); + + final int teamNumber; + final String name; + final String salutation; + List cars; + + /// If the driver is representing a company, then the company name is returned. + String getSalutatedLastName() { + if (salutation != "Firma") { + return "$salutation, ${name.split(" ").first}"; + } + + return "$salutation, $name"; + } +} diff --git a/lib/model/user.dart b/lib/model/user.dart new file mode 100644 index 0000000..4cba11f --- /dev/null +++ b/lib/model/user.dart @@ -0,0 +1,5 @@ +class User { + const User({required this.id}); + + final String id; +} \ No newline at end of file diff --git a/lib/persistence.dart b/lib/persistence.dart new file mode 100644 index 0000000..13a536a --- /dev/null +++ b/lib/persistence.dart @@ -0,0 +1,20 @@ +import 'package:path_provider/path_provider.dart'; +import 'dart:io'; + +class FileStorage { + Future _path(String file) async { + return "${(await getApplicationDocumentsDirectory()).path}/$file"; + } + + Future write(String name, String content) async { + await File(await _path(name)).writeAsString(content); + } + + Future read(String name) async { + return await File(await _path(name)).readAsString(); + } + + Future exist(String name) async { + return File(await _path(name)).exists(); + } +} \ No newline at end of file diff --git a/lib/repository.dart b/lib/repository.dart new file mode 100644 index 0000000..f64064f --- /dev/null +++ b/lib/repository.dart @@ -0,0 +1,11 @@ +import 'package:hl_lieferservice/persistence.dart'; + +abstract class BaseRepository { + final String path; + + const BaseRepository({required this.path}); + + Future exist() { + return FileStorage().exist(path); + } +} \ No newline at end of file diff --git a/lib/repository/config.dart b/lib/repository/config.dart new file mode 100644 index 0000000..98efd34 --- /dev/null +++ b/lib/repository/config.dart @@ -0,0 +1,21 @@ +import 'dart:convert'; + +import 'package:hl_lieferservice/services/erpframe.dart'; +import 'package:hl_lieferservice/persistence.dart'; +import 'package:hl_lieferservice/repository.dart'; + +/// This repository manages the configuration file stored on the phone +/// locally. +class ConfigurationRepository extends BaseRepository{ + const ConfigurationRepository({required super.path}); + + Future getDocuFrameConfiguration() async { + String content = await FileStorage().read(path); + return LocalDocuFrameConfiguration.fromJson(json.decode(content)); + } + + Future setDocuFrameConfiguration(LocalDocuFrameConfiguration configuration) async { + String content = json.encode(configuration.toJson()); + await FileStorage().write(path, content); + } +} \ No newline at end of file diff --git a/lib/repository/file.dart b/lib/repository/file.dart new file mode 100644 index 0000000..e37e1ae --- /dev/null +++ b/lib/repository/file.dart @@ -0,0 +1,38 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:image_picker/image_picker.dart'; + +class FileRepository { + const FileRepository({required this.baseDirectory}); + final Directory baseDirectory; + + Future persistTemporaryFile(XFile file, String name) async { + File fileOnDisk = File("${baseDirectory.path}/$name"); + await fileOnDisk.writeAsBytes(await file.readAsBytes()); + + return fileOnDisk; + } + + Future persistTemporaryFileFromBytes(Uint8List bytes, String name) async { + File fileOnDisk = File("${baseDirectory.path}/$name"); + await fileOnDisk.writeAsBytes(bytes as List); + + return fileOnDisk; + } + + Future> getFilesByPrefix(String prefix) async { + return await baseDirectory + .list() + .where((file) => file is File) + .map((file) => file as File) + .where((file) => file.path.split("/").last.startsWith(prefix)) + .toList(); + } + + Future deleteAllFilesByPrefix(String prefix) async { + for (File file in await getFilesByPrefix(prefix)) { + await file.delete(); + } + } +} diff --git a/lib/repository/note.dart b/lib/repository/note.dart new file mode 100644 index 0000000..007f292 --- /dev/null +++ b/lib/repository/note.dart @@ -0,0 +1,28 @@ +import 'dart:typed_data'; + +import 'package:hl_lieferservice/model/delivery.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/service/notes_service.dart'; + +class NoteRepository { + final NoteService service; + NoteRepository({required this.service}); + + Future addNote(String deliveryId, String content) async { + return service.addNote(content, int.parse(deliveryId)); + } + + Future deleteNote(String noteId) async { + return service.deleteNote(int.parse(noteId)); + } + + Future> loadNotes(String deliveryId) async { + return []; + } + + Future> loadImages(String deliveryId) async { + return []; + } + + Future addImage(String deliveryId, Uint8List imageBytes) async {} + Future deleteImage(String deliveryId, String imageIdentifier) async {} +} \ No newline at end of file diff --git a/lib/repository/user_repository.dart b/lib/repository/user_repository.dart new file mode 100644 index 0000000..67a0560 --- /dev/null +++ b/lib/repository/user_repository.dart @@ -0,0 +1,3 @@ +class UserRepository { + +} \ No newline at end of file diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/services/erpframe.dart b/lib/services/erpframe.dart new file mode 100644 index 0000000..2f832f9 --- /dev/null +++ b/lib/services/erpframe.dart @@ -0,0 +1,75 @@ +import 'dart:async'; +import 'package:docuframe/docuframe.dart' as df; +import 'package:hl_lieferservice/util.dart'; +import 'package:flutter/cupertino.dart'; + +class LocalDocuFrameConfiguration { + String host; + final String user; + final String pass; + final List appNames; + final String appKey; + + LocalDocuFrameConfiguration( + {required this.host, + required this.appKey, + required this.appNames, + required this.pass, + required this.user}); + + Map toJson() { + return { + "host": host, + "user": user, + "pass": pass, + "appNames": appNames, + "appKey": appKey + }; + } + + factory LocalDocuFrameConfiguration.fromJson(Map json) { + return LocalDocuFrameConfiguration( + host: getValueOrThrowIfNotPresent("host", json), + appKey: getValueOrThrowIfNotPresent("appKey", json), + appNames: (getValueOrThrowIfNotPresent("appNames", json) as List) + .cast(), + pass: getValueOrThrowIfNotPresent("pass", json), + user: getValueOrThrowIfNotPresent("user", json)); + } +} + +class ErpFrameService { + ErpFrameService({required this.config}); + + final LocalDocuFrameConfiguration config; + + df.DocuFrameConfiguration get dfConfig { + df.DocuFrameConfiguration dfConfig = + df.DocuFrameConfiguration(url: config.host, appkey: config.appKey); + + return dfConfig; + } + + Future getSession() async { + df.LoginV1 request = df.LoginV1(config: dfConfig); + df.LoginSession session = + await request.authorize(config.user, config.pass, config.appNames); + + debugPrint("LOGIN WITH SESSION ID ${session.sessionId}"); + + return session; + } + + Future logout(df.LoginSession? session) async { + if (session != null) { + try { + await df.Logout(config: dfConfig, session: session).logout(); + } catch (e, st) { + debugPrint("Logout failed"); + debugPrint(e.toString()); + debugPrint(st.toString()); + } + debugPrint("Logged out with session ID: ${session.sessionId}"); + } + } +} \ No newline at end of file diff --git a/lib/services/scan_service.dart b/lib/services/scan_service.dart new file mode 100644 index 0000000..1d4927c --- /dev/null +++ b/lib/services/scan_service.dart @@ -0,0 +1,109 @@ +import 'dart:convert'; + +import 'package:hl_lieferservice/services/erpframe.dart'; +import 'package:docuframe/docuframe.dart' as df; +import 'package:flutter/cupertino.dart'; + +import '../dto/basic_response.dart'; +import '../dto/scan.dart'; +import '../dto/scan_response.dart'; + +class ScanService extends ErpFrameService { + ScanService({required super.config}); + + Future scanArticle(String internalId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_scanArticle", + parameter: ScanDTO(internalId: internalId).toJson() + as Map); + + Map responseJson = jsonDecode(response.body!); + ScanResponseDTO responseDto = ScanResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } on df.DocuFrameException catch (e, st) { + debugPrint("ERROR WHILE SCANNING ARTICLE $internalId"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future unscanArticle( + String internalId, int amount, String reason) async { + df.LoginSession? session; + + debugPrint("AMOUNT: $amount"); + debugPrint("ID: $internalId"); + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session) + .execute("_web_unscanArticle", parameter: { + "article_id": internalId, + "amount": amount.toString(), + "reason": reason + }); + + Map responseJson = jsonDecode(response.body!); + debugPrint(responseJson.toString()); + ScanResponseDTO responseDto = ScanResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return responseDto.noteId; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE REVERTING THE SCAN OF ARTICLE $internalId"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } + + Future resetScannedArticleAmount(String receiptRowId) async { + df.LoginSession? session; + + try { + session = await getSession(); + df.DocuFrameMacroResponse response = + await df.Macro(config: dfConfig, session: session).execute( + "_web_unscanArticleReset", + parameter: {"receipt_row_id": receiptRowId}); + + Map responseJson = jsonDecode(response.body!); + BasicResponseDTO responseDto = BasicResponseDTO.fromJson(responseJson); + + if (responseDto.succeeded == true) { + return; + } else { + throw responseDto.message; + } + } catch (e, st) { + debugPrint("ERROR WHILE REVERTING THE UNSCAN OF ARTICLE $receiptRowId"); + debugPrint(e.toString()); + debugPrint(st.toString()); + + rethrow; + } finally { + await logout(session); + } + } +} diff --git a/lib/util.dart b/lib/util.dart new file mode 100644 index 0000000..3b639ab --- /dev/null +++ b/lib/util.dart @@ -0,0 +1,60 @@ +import 'package:intl/intl.dart'; + +import 'model/delivery.dart'; + +dynamic getValueOrThrowIfNotPresent(String key, Map json) { + if (!json.containsKey(key)) { + throw Exception("Wert '$key' in der Konfigurationsdatei nicht gefunden"); + } + + return json[key]; +} + +/// Returns the current date as string in format YYYY-MM-DD. +String getTodayDate() { + return DateFormat('yyyy-MM-dd').format(DateTime.now()); +} + +String concatenateRegexMatches(String input, String pattern) { + final regex = RegExp(pattern); + final matches = regex.allMatches(input); + + return matches.fold("", (acc, match) => acc + match[0]!); +} + +/// Return the value or the default value if the string is empty. +String getOrDefaultValueFromStr(String value, String defaultValue) { + if (value != "") { + return value; + } else { + return defaultValue; + } +} + +DeliveryState getDeliveryStateFromString(String str) { + switch (str) { + case "laufend": + return DeliveryState.ongoing; + case "abgebrochen": + return DeliveryState.canceled; + case "vertagt": + return DeliveryState.onhold; + case "geliefert": + return DeliveryState.finished; + default: + throw Exception("Invalid state"); + } +} + +String getName(DeliveryState state) { + switch (state) { + case DeliveryState.ongoing: + return "laufend"; + case DeliveryState.canceled: + return "abgebrochen"; + case DeliveryState.onhold: + return "unterbrochen"; + case DeliveryState.finished: + return "ausgeliefert"; + } +} diff --git a/lib/widget/app.dart b/lib/widget/app.dart new file mode 100644 index 0000000..5a95237 --- /dev/null +++ b/lib/widget/app.dart @@ -0,0 +1,137 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/bloc/app_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/presentation/login_enforcer.dart'; +import 'package:hl_lieferservice/feature/cars/presentation/car_management_page.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/delivery_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/bloc/note_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/repository/delivery_repository.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/repository/note_repository.dart'; +import 'package:hl_lieferservice/feature/delivery/detail/service/notes_service.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/repository/tour_repository.dart'; +import 'package:hl_lieferservice/repository/user_repository.dart'; +import 'package:hl_lieferservice/widget/home/bloc/navigation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/presentation/operation_view_enforcer.dart'; + +import 'package:hl_lieferservice/bloc/app_states.dart'; +import '../feature/delivery/overview/service/delivery_info_service.dart'; +import 'home/bloc/navigation_state.dart'; +import 'home/presentation/home.dart'; + +class DeliveryApp extends StatefulWidget { + const DeliveryApp({super.key}); + + @override + State createState() => _DeliveryAppState(); +} + +class _DeliveryAppState extends State { + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is AppConfigLoaded) { + final currentAppState = state; + return MultiBlocProvider( + providers: [ + BlocProvider(create: (context) => NavigationBloc()), + BlocProvider(create: (context) => OperationBloc()), + BlocProvider( + create: + (context) => AuthBloc( + repository: UserRepository(), + operationBloc: context.read(), + ), + ), + BlocProvider( + create: + (context) => TourBloc( + opBloc: context.read(), + deliveryRepository: TourRepository( + service: DeliveryInfoService( + config: currentAppState.config, + ), + ), + ), + ), + BlocProvider( + create: + (context) => NoteBloc( + opBloc: context.read(), + repository: NoteRepository( + service: NoteService(config: currentAppState.config), + ), + ), + ), + BlocProvider( + create: + (context) => DeliveryBloc( + opBloc: context.read(), + repository: DeliveryRepository( + service: DeliveryInfoService( + config: currentAppState.config, + ), + ), + ), + ), + ], + child: MaterialApp( + home: OperationViewEnforcer( + child: BlocBuilder( + builder: (context, state) { + if (state is AppConfigLoading) { + return Scaffold( + body: Center(child: CircularProgressIndicator()), + ); + } + + if (state is AppConfigLoadingFailed) { + return Scaffold(body: Center(child: Text(state.message))); + } + + if (state is AppConfigLoaded) { + return BlocConsumer( + listener: (context, state) { + if (state is NavigateToRoute) { + Navigator.pushNamed( + context, + state.routeName, + arguments: state.arguments, + ); + } + }, + builder: (BuildContext context, NavigationState state) { + return LoginEnforcer(child: Home()); + }, + ); + } + + return Container(); + }, + ), + ), + routes: {"/cars": (context) => CarManagementPage()}, + ), + ); + } + + if (state is AppConfigLoadingFailed) { + return MaterialApp( + home: Scaffold( + body: Center(child: Text("Fehler beim Laden der Konfiguration")), + ), + ); + } + + return MaterialApp( + home: Scaffold( + body: Center(child: const CircularProgressIndicator()), + ), + ); + }, + ); + } +} diff --git a/lib/widget/home/bloc/navigation_bloc.dart b/lib/widget/home/bloc/navigation_bloc.dart new file mode 100644 index 0000000..9768ef5 --- /dev/null +++ b/lib/widget/home/bloc/navigation_bloc.dart @@ -0,0 +1,28 @@ +// Navigation events +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'navigation_event.dart'; +import 'navigation_state.dart'; + +// Navigation BLoC +class NavigationBloc extends Bloc { + NavigationBloc() : super(NavigateToRoute('/scan', index: 0)) { + on((event, emit) { + emit(NavigateToRoute('/cars', index: 2)); + }); + + on((event, emit) { + emit(NavigateToRoute('/deliveries', index: 1)); + }); + + on((event, emit) { + emit(NavigateToRoute('/delivery')); + }); + + on((event, emit) { + emit(NavigateToRoute('/scan', index: 0)); + }); + + // Add more navigation handlers... + } +} \ No newline at end of file diff --git a/lib/widget/home/bloc/navigation_event.dart b/lib/widget/home/bloc/navigation_event.dart new file mode 100644 index 0000000..62e2955 --- /dev/null +++ b/lib/widget/home/bloc/navigation_event.dart @@ -0,0 +1,8 @@ +abstract class NavigationEvent {} + +class NavigateToHome extends NavigationEvent {} +class NavigateToDeliveries extends NavigationEvent {} +class NavigateToDelivery extends NavigationEvent {} +class NavigateToScan extends NavigationEvent {} +class NavigateToCars extends NavigationEvent {} +class GoBack extends NavigationEvent {} \ No newline at end of file diff --git a/lib/widget/home/bloc/navigation_state.dart b/lib/widget/home/bloc/navigation_state.dart new file mode 100644 index 0000000..f886386 --- /dev/null +++ b/lib/widget/home/bloc/navigation_state.dart @@ -0,0 +1,11 @@ +// Navigation states +abstract class NavigationState {} + +class NavigationInitial extends NavigationState {} +class NavigateToRoute extends NavigationState { + final String routeName; + final int? index; + final Object? arguments; + + NavigateToRoute(this.routeName, {this.arguments, this.index}); +} \ No newline at end of file diff --git a/lib/widget/home/presentation/home.dart b/lib/widget/home/presentation/home.dart new file mode 100644 index 0000000..286c636 --- /dev/null +++ b/lib/widget/home/presentation/home.dart @@ -0,0 +1,79 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_bloc.dart'; +import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart'; +import 'package:hl_lieferservice/feature/cars/presentation/car_management_page.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_bloc.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/bloc/tour_event.dart'; +import 'package:hl_lieferservice/feature/delivery/overview/presentation/delivery_overview_page.dart'; +import 'package:hl_lieferservice/widget/navigation_bar/presentation/navigation_bar.dart'; + +import '../../../bloc/app_bloc.dart'; +import '../../../bloc/app_states.dart'; +import '../../../feature/cars/bloc/cars_bloc.dart'; +import '../../../feature/cars/repository/cars_repository.dart'; +import '../../../feature/cars/service/cars_service.dart'; +import '../../operations/bloc/operation_bloc.dart'; + +class Home extends StatefulWidget { + const Home({super.key}); + + @override + State createState() => _HomeState(); +} + +class _HomeState extends State { + int _selectedPage = 0; + + @override + void initState() { + super.initState(); + + // Load deliveries + Authenticated state = context.read().state as Authenticated; + context.read().add(LoadTour(teamId: state.teamId)); + } + + Widget _buildPage(index) { + if (index == 0) { + return Container(); + } + + if (index == 1) { + return DeliveryOverviewPage(); + } + + if (index == 2) { + final currentAppState = context.read().state as AppConfigLoaded; + return BlocProvider( + create: + (context) => CarsBloc( + repository: CarsRepository( + service: CarService(config: currentAppState.config), + ), + opBloc: context.read(), + ), + child: CarManagementPage(), + ); + } + + return Container(); + } + + void _onSelect(int index) { + setState(() { + _selectedPage = index; + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Center(child: Text("Holzleitner Lieferservice")), + ), + body: _buildPage(_selectedPage), + bottomNavigationBar: AppNavigationBar(onSelect: _onSelect), + ); + } +} diff --git a/lib/widget/navigation_bar/presentation/navigation_bar.dart b/lib/widget/navigation_bar/presentation/navigation_bar.dart new file mode 100644 index 0000000..e3eb499 --- /dev/null +++ b/lib/widget/navigation_bar/presentation/navigation_bar.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/widget/home/bloc/navigation_bloc.dart'; +import 'package:hl_lieferservice/widget/home/bloc/navigation_state.dart'; + +class AppNavigationBar extends StatefulWidget { + final Function(int) onSelect; + + const AppNavigationBar({required this.onSelect}); + + @override + State createState() => _AppNavigationBarState(); +} + +class _AppNavigationBarState extends State { + int _selectedPage = 0; + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + if (state is NavigateToRoute) { + return NavigationBar( + selectedIndex: _selectedPage, + destinations: const [ + NavigationDestination( + icon: Icon(Icons.barcode_reader), + label: "Beladung", + ), + NavigationDestination( + icon: Icon(Icons.fire_truck), + label: "Auslieferung", + ), + NavigationDestination( + icon: Icon(Icons.local_shipping), + label: "Fahrzeuge", + ), + ], + onDestinationSelected: (int index) { + widget.onSelect(index); + + setState(() { + _selectedPage = index; + }); + }, + ); + } + + return Container(); + }, + ); + } +} diff --git a/lib/widget/operations/bloc/operation_bloc.dart b/lib/widget/operations/bloc/operation_bloc.dart new file mode 100644 index 0000000..048f873 --- /dev/null +++ b/lib/widget/operations/bloc/operation_bloc.dart @@ -0,0 +1,31 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_event.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_state.dart'; + +class OperationBloc extends Bloc { + OperationBloc() : super(OperationIdle()) { + on(_loadOperation); + on(_failOperation); + on(_finishOperation); + } + + Future _loadOperation(LoadOperation event, Emitter emit) async { + emit(OperationLoading()); + } + + Future _failOperation(FailOperation event, Emitter emit) async { + emit(OperationFailed(message: event.message)); + + await Future.delayed(Duration(seconds: 5)); + + emit(OperationIdle()); + } + + Future _finishOperation(FinishOperation event, Emitter emit) async { + emit(OperationFinished(message: event.message)); + + await Future.delayed(Duration(seconds: 5)); + + emit(OperationIdle()); + } +} \ No newline at end of file diff --git a/lib/widget/operations/bloc/operation_event.dart b/lib/widget/operations/bloc/operation_event.dart new file mode 100644 index 0000000..95dc3e8 --- /dev/null +++ b/lib/widget/operations/bloc/operation_event.dart @@ -0,0 +1,15 @@ +abstract class OperationEvent {} + +class LoadOperation extends OperationEvent {} + +class FailOperation extends OperationEvent { + String message; + + FailOperation({required this.message}); +} + +class FinishOperation extends OperationEvent { + String? message; + + FinishOperation({this.message}); +} \ No newline at end of file diff --git a/lib/widget/operations/bloc/operation_state.dart b/lib/widget/operations/bloc/operation_state.dart new file mode 100644 index 0000000..aa179f3 --- /dev/null +++ b/lib/widget/operations/bloc/operation_state.dart @@ -0,0 +1,17 @@ +abstract class OperationState {} + +class OperationIdle extends OperationState {} + +class OperationLoading extends OperationState {} + +class OperationFailed extends OperationState { + String message; + + OperationFailed({required this.message}); +} + +class OperationFinished extends OperationState { + String? message; + + OperationFinished({this.message}); +} \ No newline at end of file diff --git a/lib/widget/operations/presentation/message_container.dart b/lib/widget/operations/presentation/message_container.dart new file mode 100644 index 0000000..519c62a --- /dev/null +++ b/lib/widget/operations/presentation/message_container.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class ErrorContainer extends MessageContainer { + const ErrorContainer({super.key, required super.message}) + : super(color: Colors.deepOrangeAccent); +} + +class SuccessContainer extends MessageContainer { + const SuccessContainer({super.key, required super.message}) + : super(color: Colors.greenAccent); +} + +class MessageContainer extends StatelessWidget { + final String message; + final Color color; + + const MessageContainer({ + super.key, + required this.message, + this.color = Colors.deepOrange, + }); + + @override + Widget build(BuildContext context) { + return DecoratedBox( + decoration: BoxDecoration(color: color), + child: Center(child: Text(message)), + ); + } +} diff --git a/lib/widget/operations/presentation/operation_view_enforcer.dart b/lib/widget/operations/presentation/operation_view_enforcer.dart new file mode 100644 index 0000000..b190ff3 --- /dev/null +++ b/lib/widget/operations/presentation/operation_view_enforcer.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/bloc/operation_bloc.dart'; +import 'package:hl_lieferservice/widget/operations/presentation/message_container.dart'; + +import '../bloc/operation_state.dart'; + +/// OperationViewEnforcer +/// +/// A view that encapsulates the functionality to react to asynchronous operations. +/// It is capable of showing a loading indicator while an operation is ongoing and it shows +/// a error message if the operation failed. +class OperationViewEnforcer extends StatefulWidget { + final Widget child; + const OperationViewEnforcer({super.key, required this.child}); + @override + State createState() => _OperationViewEnforcerState(); +} + +class _OperationViewEnforcerState extends State { + OverlayEntry? _overlayEntry; + + @override + void dispose() { + _overlayEntry?.remove(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return BlocListener( + listener: (context, state) { + if (state is OperationLoading) { + if (_overlayEntry == null) { + _overlayEntry = _createOverlayEntry(context); + Overlay.of(context).insert(_overlayEntry!); + } + } else { + _overlayEntry?.remove(); + _overlayEntry = null; + } + + if (state is OperationFinished) { + if (state.message != null) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(state.message!)), + ); + } + } + + if (state is OperationFailed) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(state.message)), + ); + } + }, + child: widget.child, + ); + } + + OverlayEntry _createOverlayEntry(BuildContext context) { + return OverlayEntry( + builder: (context) => DecoratedBox( + decoration: const BoxDecoration( + color: Color.fromRGBO(128, 128, 128, 0.8), + ), + child: const Center( + child: CircularProgressIndicator(color: Colors.white), + ), + ), + ); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..d4f2551 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,937 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f + url: "https://pub.dev" + source: hosted + version: "85.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d" + url: "https://pub.dev" + source: hosted + version: "7.7.1" + archive: + dependency: transitive + description: + name: archive + sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd" + url: "https://pub.dev" + source: hosted + version: "4.0.7" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + url: "https://pub.dev" + source: hosted + version: "2.12.0" + bloc: + dependency: transitive + description: + name: bloc + sha256: "52c10575f4445c61dd9e0cafcc6356fdd827c4c64dd7945ef3c4105f6b6ac189" + url: "https://pub.dev" + source: hosted + version: "9.0.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: "51dc711996cbf609b90cbe5b335bbce83143875a9d58e4b5c6d3c4f684d3dda7" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + url: "https://pub.dev" + source: hosted + version: "1.1.2" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" + url: "https://pub.dev" + source: hosted + version: "4.0.4" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: ee4257b3f20c0c90e72ed2b57ad637f694ccba48839a821e87db762548c22a62 + url: "https://pub.dev" + source: hosted + version: "2.5.4" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "382a4d649addbfb7ba71a3631df0ec6a45d5ab9b098638144faf27f02778eb53" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "85fbbb1036d576d966332a3f5ce83f2ce66a40bea1a94ad2d5fc29a19a0d3792" + url: "https://pub.dev" + source: hosted + version: "9.1.2" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: ba95c961bafcd8686d1cf63be864eb59447e795e124d98d6a27d91fcd13602fb + url: "https://pub.dev" + source: hosted + version: "8.11.1" + carousel_slider: + dependency: "direct main" + description: + name: carousel_slider + sha256: bcc61735345c9ab5cb81073896579e735f81e35fd588907a393143ea986be8ff + url: "https://pub.dev" + source: hosted + version: "5.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + url: "https://pub.dev" + source: hosted + version: "4.10.1" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670" + url: "https://pub.dev" + source: hosted + version: "0.3.4+2" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + docuframe: + dependency: "direct main" + description: + path: "../docuframe" + relative: true + source: path + version: "1.0.0" + easy_stepper: + dependency: "direct main" + description: + name: easy_stepper + sha256: "63f66314a509ec690c8152a41288961fd96ba9e92ef184299f068a5e78bd16ad" + url: "https://pub.dev" + source: hosted + version: "0.8.5+1" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" + url: "https://pub.dev" + source: hosted + version: "1.3.2" + ffi: + dependency: transitive + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" + url: "https://pub.dev" + source: hosted + version: "0.9.3+2" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "19124ff4a3d8864fdc62072b6a2ef6c222d55a3404fe14893a3c02744907b60c" + url: "https://pub.dev" + source: hosted + version: "0.9.4+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: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b" + url: "https://pub.dev" + source: hosted + version: "0.9.3+4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: cf51747952201a455a1c840f8171d273be009b932c75093020f9af64f2123e38 + url: "https://pub.dev" + source: hosted + version: "9.1.1" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "6382ce712ff69b0f719640ce957559dde459e55ecd433c767e06d139ddf16cab" + url: "https://pub.dev" + source: hosted + version: "2.0.29" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: b9c2ad5872518a27507ab432d1fb97e8813b05f0fc693f9d40fad06d073e0678 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + 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" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + http: + dependency: "direct main" + description: + name: http + sha256: bb2ce4590bc2667c96f318d68cac1b5a7987ec819351d32b1c987239a815e007 + url: "https://pub.dev" + source: hosted + version: "1.5.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "736eb56a911cf24d1859315ad09ddec0b66104bc41a7f8c5b96b4e2620cf5041" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: e83b2b05141469c5e19d77e1dfa11096b6b1567d09065b2265d7c6904560050c + url: "https://pub.dev" + source: hosted + version: "0.8.13" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "40c2a6a0da15556dc0f8e38a3246064a971a9f512386c3339b89f76db87269b6" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: eb06fe30bab4c4497bad449b66448f50edcc695f1c59408e78aa3a8059eb8f0e + url: "https://pub.dev" + source: hosted + version: "0.8.13" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: d58cd9d67793d52beefd6585b12050af0a7663c0c2a6ece0fb110a35d6955e04 + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: "9f143b0dba3e459553209e20cc425c9801af48e6dfa4f01a0fcf927be3f41665" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae + url: "https://pub.dev" + source: hosted + version: "0.2.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + url: "https://pub.dev" + source: hosted + version: "0.20.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: "direct main" + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c + url: "https://pub.dev" + source: hosted + version: "6.9.5" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec + url: "https://pub.dev" + source: hosted + version: "10.0.8" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 + url: "https://pub.dev" + source: hosted + version: "3.0.9" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + lottie: + dependency: transitive + description: + name: lottie + sha256: c5fa04a80a620066c15cf19cc44773e19e9b38e989ff23ea32e5903ef1015950 + url: "https://pub.dev" + source: hosted + version: "3.3.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mocktail: + dependency: transitive + description: + name: mocktail + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9 + url: "https://pub.dev" + source: hosted + version: "2.2.17" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "16eef174aacb07e09c351502740fa6254c165757638eba1e9116b0a781201bbd" + url: "https://pub.dev" + source: hosted + version: "2.4.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" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61" + url: "https://pub.dev" + source: hosted + version: "6.0.3" + provider: + dependency: transitive + description: + name: provider + sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272" + url: "https://pub.dev" + source: hosted + version: "6.1.5+1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + signature: + dependency: "direct main" + description: + name: signature + sha256: f3d14bd6dae46d3b4802c6a091d6d39c9c6080d999e8c5380581d3725c30e360 + url: "https://pub.dev" + source: hosted + version: "6.3.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: a447acb083d3a5ef17f983dd36201aeea33fedadb3228fa831f2f0c92f0f3aca + url: "https://pub.dev" + source: hosted + version: "1.3.7" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd + url: "https://pub.dev" + source: hosted + version: "0.7.4" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: a4f059dc26fc8295b5921376600a194c4ec7d55e72f2fe4c7d2831e103d461e6 + url: "https://pub.dev" + source: hosted + version: "1.1.19" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" + url: "https://pub.dev" + source: hosted + version: "1.1.13" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: d354a7ec6931e6047785f4db12a1f61ec3d43b207fc0790f863818543f8ff0dc + url: "https://pub.dev" + source: hosted + version: "1.1.19" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" + url: "https://pub.dev" + source: hosted + version: "14.3.1" + watcher: + dependency: transitive + description: + name: watcher + sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.7.2 <4.0.0" + flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..6f1428c --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,107 @@ +name: hl_lieferservice +description: "Holzleitner LieferApp Refactored" +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: ^3.7.2 + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.8 + flutter_bloc: ^9.1.1 + docuframe: + path: ../docuframe + http: ^1.5.0 + json_annotation: ^4.9.0 + image_picker: ^1.2.0 + path_provider: ^2.1.5 + intl: ^0.20.2 + easy_stepper: ^0.8.5+1 + carousel_slider: ^5.1.1 + signature: ^6.3.0 + +dev_dependencies: + build_runner: ^2.5.4 + 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: ^5.0.0 + json_serializable: ^6.9.5 + +# 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/holzleitner_Logo_2017_RZ_transparent.png + - assets/holzleitner_Logo_2017_RZ.png + - assets/hl_server_config.json + + # 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/to/resolution-aware-images + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/to/asset-from-package + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/to/font-from-package diff --git a/test/widget_test.dart b/test/widget_test.dart new file mode 100644 index 0000000..6fce1dc --- /dev/null +++ b/test/widget_test.dart @@ -0,0 +1,16 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:hl_lieferservice/widget/app.dart'; + +import 'package:hl_lieferservice/main.dart'; + +void main() { + +}