diff --git a/.gitignore b/.gitignore index ae1f183..ac246c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,37 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Web related -lib/generated_plugin_registrant.dart - -# Exceptions to above rules. -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Exceptions to above rules. +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/.metadata b/.metadata index 5d1241e..56b8ab2 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,27 @@ # This file should be version controlled and should not be manually edited. version: - revision: 9f5ff2306bb3e30b2b98eee79cd231b1336f41f4 - channel: stable + revision: "ead455963c12b453cdb2358cad34969c76daf180" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: ead455963c12b453cdb2358cad34969c76daf180 + base_revision: ead455963c12b453cdb2358cad34969c76daf180 + - platform: web + create_revision: ead455963c12b453cdb2358cad34969c76daf180 + base_revision: ead455963c12b453cdb2358cad34969c76daf180 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/.vscode/launch.json b/.vscode/launch.json index 3287bb6..5cda00e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,13 +1,13 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Flutter", - "request": "launch", - "type": "dart" - } - ] +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Flutter", + "request": "launch", + "type": "dart" + } + ] } \ No newline at end of file diff --git a/README.md b/README.md index a54c750..8c1c2a5 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# CSSD - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +# CSSD + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), 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..7b91d0d --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,27 @@ +# 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 index bc2100d..0b9e049 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -1,7 +1,7 @@ -gradle-wrapper.jar -/.gradle -/captures/ -/gradlew -/gradlew.bat -/local.properties -GeneratedPluginRegistrant.java +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java diff --git a/android/app/build.gradle b/android/app/build.gradle index 49865d4..f5b082c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,67 +1,68 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - -android { - compileSdkVersion 28 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - disable 'InvalidPackage' - } - - defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.cssd" - minSdkVersion 21 - targetSdkVersion 28 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - } - } -} - -flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' -} +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 33 + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + lintOptions { + // disable 'InvalidPackage' + baseline(file("lint-baseline.xml")) + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.cssd" + minSdkVersion 21 + targetSdkVersion 28 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} diff --git a/android/app/lint-baseline.xml b/android/app/lint-baseline.xml new file mode 100644 index 0000000..4f6d7b2 --- /dev/null +++ b/android/app/lint-baseline.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index e9b79e1..087b687 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 01d5a5a..5e21ae5 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/example/cssd/MainActivity.kt b/android/app/src/main/kotlin/com/example/cssd/MainActivity.kt index 9fb1905..83e08a2 100644 --- a/android/app/src/main/kotlin/com/example/cssd/MainActivity.kt +++ b/android/app/src/main/kotlin/com/example/cssd/MainActivity.kt @@ -1,12 +1,12 @@ -package com.example.cssd - -import androidx.annotation.NonNull; -import io.flutter.embedding.android.FlutterActivity -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugins.GeneratedPluginRegistrant - -class MainActivity: FlutterActivity() { - override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { - GeneratedPluginRegistrant.registerWith(flutterEngine); - } -} +package com.example.cssd + +import androidx.annotation.NonNull; +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugins.GeneratedPluginRegistrant + +class MainActivity: FlutterActivity() { + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + GeneratedPluginRegistrant.registerWith(flutterEngine); + } +} diff --git a/android/app/src/main/res/drawable/launch_background.xml b/android/app/src/main/res/drawable/launch_background.xml index 304732f..8403758 100644 --- a/android/app/src/main/res/drawable/launch_background.xml +++ b/android/app/src/main/res/drawable/launch_background.xml @@ -1,12 +1,12 @@ - - - - - - - - + + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 00fa441..4c57322 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index e9b79e1..087b687 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,7 +1,7 @@ - - - - + + + + diff --git a/android/build.gradle b/android/build.gradle index d47e9ee..f02d846 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.7.10' repositories { // google() maven { @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -34,6 +34,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/android/gradle.properties b/android/gradle.properties index 38c8d45..74c1d92 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true -android.useAndroidX=true -android.enableJetifier=true +org.gradle.jvmargs=-Xmx1536M +android.enableR8=true +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index bc6a58a..cfe88f6 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index 5a2f14f..4f14f8e 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,15 +1,15 @@ -include ':app' - -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() - -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} - -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/android/settings_aar.gradle b/android/settings_aar.gradle index e7b4def..d3db109 100644 --- a/android/settings_aar.gradle +++ b/android/settings_aar.gradle @@ -1 +1 @@ -include ':app' +include ':app' diff --git a/assets/Icons/cable.svg b/assets/Icons/cable.svg index 4b325d8..558ff5d 100644 --- a/assets/Icons/cable.svg +++ b/assets/Icons/cable.svg @@ -1,63 +1,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/Icons/calendar.svg b/assets/Icons/calendar.svg index db9f571..5f6e7ea 100644 --- a/assets/Icons/calendar.svg +++ b/assets/Icons/calendar.svg @@ -1,112 +1,112 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/.gitignore b/ios/.gitignore index e96ef60..0f1df0f 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -1,32 +1,32 @@ -*.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/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 +*.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/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 index 6b4c0f7..58e65f9 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -1,26 +1,26 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - App - CFBundleIdentifier - io.flutter.flutter.app - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - App - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 8.0 - - + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 8.0 + + diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index 592ceee..dfd2626 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ -#include "Generated.xcconfig" +#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 index 592ceee..a97381a 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ -#include "Generated.xcconfig" +#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..fdcc671 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '11.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! + use_modular_headers! + + 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 index 988ea38..8b956b6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -1,518 +1,518 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 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 PBXCopyFilesBuildPhase section */ - 9705A1C41CF9048500538489 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; 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 = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; 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 = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 9740EEB11CF90186004384FC /* Flutter */ = { - isa = PBXGroup; - children = ( - 3B80C3931E831B6300D905FE /* App.framework */, - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 9740EEB31CF90195004384FC /* Generated.xcconfig */, - ); - name = Flutter; - sourceTree = ""; - }; - 97C146E51CF9000F007C117D = { - isa = PBXGroup; - children = ( - 9740EEB11CF90186004384FC /* Flutter */, - 97C146F01CF9000F007C117D /* Runner */, - 97C146EF1CF9000F007C117D /* Products */, - ); - sourceTree = ""; - }; - 97C146EF1CF9000F007C117D /* Products */ = { - isa = PBXGroup; - children = ( - 97C146EE1CF9000F007C117D /* Runner.app */, - ); - name = Products; - sourceTree = ""; - }; - 97C146F01CF9000F007C117D /* Runner */ = { - isa = PBXGroup; - children = ( - 97C146FA1CF9000F007C117D /* Main.storyboard */, - 97C146FD1CF9000F007C117D /* Assets.xcassets */, - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, - 97C147021CF9000F007C117D /* Info.plist */, - 97C146F11CF9000F007C117D /* Supporting Files */, - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, - ); - path = Runner; - sourceTree = ""; - }; - 97C146F11CF9000F007C117D /* Supporting Files */ = { - isa = PBXGroup; - children = ( - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 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 = { - LastUpgradeCheck = 1020; - ORGANIZATIONNAME = "The Chromium Authors"; - TargetAttributes = { - 97C146ED1CF9000F007C117D = { - CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1100; - }; - }; - }; - buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 97C146E51CF9000F007C117D; - productRefGroup = 97C146EF1CF9000F007C117D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 97C146ED1CF9000F007C117D /* Runner */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 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; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; - }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - 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 */ - 97C146EA1CF9000F007C117D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase 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; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Profile; - }; - 249021D4217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Profile; - }; - 97C147031CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 97C147041CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 97C147061CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Debug; - }; - 97C147071CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Flutter", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; - 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 */ - 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 */; -} +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 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 PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; 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 = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; 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 = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 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 = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 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; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + 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 */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase 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; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd; + 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 */ + 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 index 1d526a1..59c6d39 100644 --- a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..be0b92e 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,91 +1,91 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..59c6d39 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -1,7 +1,7 @@ - - - - - + + + + + diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 70693e4..3763683 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit -import Flutter - -@UIApplicationMain -@objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } -} +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json index d36b1fa..1950fd8 100644 --- a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,122 +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" - } -} +{ + "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/LaunchImage.imageset/Contents.json b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json index 0bedcf2..d08a4de 100644 --- a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -1,23 +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" - } -} +{ + "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/README.md b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md index 89c2725..65a94b5 100644 --- a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +++ b/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -1,5 +1,5 @@ -# Launch Screen Assets - -You can customize the launch screen with your own desired assets by replacing the image files in this directory. - +# 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 index f2e259c..497371e 100644 --- a/ios/Runner/Base.lproj/LaunchScreen.storyboard +++ b/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard index f3c2851..bbb83ca 100644 --- a/ios/Runner/Base.lproj/Main.storyboard +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index b522c75..88c0a29 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -1,45 +1,45 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - cssd - 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 - - UIViewControllerBasedStatusBarAppearance - - - + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + cssd + 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 + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/lib/config/colors.dart b/lib/config/colors.dart new file mode 100644 index 0000000..e26b401 --- /dev/null +++ b/lib/config/colors.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; + +const kLightBlue = Color(0xFF32CAD5); +const kLightBlueSub = Color(0xFF5FDDE7); +const kPink = Color(0xFFEE3552); +const kPinkSub = Color(0xFFFE687F); +const kBlue = Color(0xFF389ADC); +const kBlueSub = Color(0xFF60AFE2); +const kPurple = Color(0xFFAF3C77); +const kPurpleSub = Color(0xFFBB5B8D); +const kDarkBlue = Color(0xFF14537D); +const kDarkBlueSub = Color(0XFF668FAC); +const kDarkPurple = Color(0xFF862054); +const kDarkPurpleSub = Color(0xFFB75788); diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 2f71a60..7d32664 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -1,27 +1,50 @@ -class Routes { - static const cycleAddScreen = '/CycleAddScreen'; - static const cycleDetailScreen = '/CycleDetailScreen'; - static const cycleFilterScreen = '/CycleFilterScreen'; - static const cycleResultScreen = '/CycleResultScreen'; - static const cycleScanScreen = '/CycleScanScreen'; - static const homePage = '/HomePage'; - static const labelAddScreen = '/LabelAddScreen'; - static const labelUpdateScreen = '/LabelUpdateScreen'; - static const labelDetailScreen = '/LabelDetailScreen'; - static const labelFilterScreen = '/LabelFilterScreen'; - static const labelResultScreen = '/LabelResultScreen'; - static const labelScanScreen = '/LabelScanScreen'; - static const loginScreen = '/LoginScreen'; - static const forgetPassScreen = '/ForgetPassScreen'; - static const sendCodeScreen = '/SendCodeScreen'; - static const rePassScreen = '/RePassScreen'; - static const myInfoScreen = '/MyInfoScreen'; - static const testResultAddScreen = '/TestResultAddScreen'; - static const testDetailsScreen = '/TestDetailsScreen'; - static const testFilterScreen = '/TestFilterScreen'; - static const testResultScreen = '/TestResultScreen'; - static const testVerifyScreen = '/TestVerifyScreen'; - static const testScanScreen = '/TestScanScreen'; - static const captureImageScreen = '/captureImageScreen'; - -} +class Routes { + static const cycleAddScreen = '/CycleAddScreen'; + static const cycleDetailScreen = '/CycleDetailScreen'; + static const cycleFilterScreen = '/CycleFilterScreen'; + static const cycleResultScreen = '/CycleResultScreen'; + static const cycleScanScreen = '/CycleScanScreen'; + static const homePage = '/HomePage'; + static const labelAddScreen = '/LabelAddScreen'; + static const labelUpdateScreen = '/LabelUpdateScreen'; + static const labelDetailScreen = '/LabelDetailScreen'; + static const labelFilterScreen = '/LabelFilterScreen'; + static const labelResultScreen = '/LabelResultScreen'; + static const labelScanScreen = '/LabelScanScreen'; + static const loginScreen = '/LoginScreen'; + static const forgetPassScreen = '/ForgetPassScreen'; + static const sendCodeScreen = '/SendCodeScreen'; + static const rePassScreen = '/RePassScreen'; + static const myInfoScreen = '/MyInfoScreen'; + static const testResultAddScreen = '/TestResultAddScreen'; + static const testDetailsScreen = '/TestDetailsScreen'; + static const testFilterScreen = '/TestFilterScreen'; + static const testResultScreen = '/TestResultScreen'; + static const testVerifyScreen = '/TestVerifyScreen'; + static const testScanScreen = '/TestScanScreen'; + static const captureImageScreen = '/captureImageScreen'; + static const packageAddScreen = '/PackageAddScreen'; + static const packageResultScreen = '/PackageResultScreen'; + static const packageFilterScreen = '/PackageFilterScreen'; + static const packageDetailScreen = '/PackageDetailScreen'; + static const itemAddScreen = '/ItemAddScreen'; + static const itemResultScreen = '/ItemResultScreen'; + static const itemFilterScreen = '/ItemFilterScreen'; + static const itemDetailScreen = '/ItemDetailScreen'; + static const formTestResultScreen = '/FormTestResultScreen'; + static const cycleUpdateScreen = '/CycleUpdateScreen'; + static const packageUpdateScreen = '/PackageUpdateScreen'; + static const itemUpdateScreen = '/ItemUpdateScreen'; + static const itemScanScreen = '/ItemScanScreen'; + static const packageScanScreen = '/PackageScanScreen'; + static const myItemsResultScreen = '/MyItemsResultScreen'; + static const myItemsFilterScreen = '/MyItemsFilterScreen'; + static const myItemsDetailScreen = '/MyItemsDetailScreen'; + static const itemsTransferScreen = '/ItemsTransferScreen'; + static const myItemsHistoryScreen = '/MyItemsHistoryScreen'; + static const myPackagesResultScreen = '/MyPackagesResultScreen'; + static const myPackagesFilterScreen = '/MyPackagesFilterScreen'; + static const myPackagesDetailScreen = '/MyPackagesDetailScreen'; + static const packagesTransferScreen = '/PackagesTransferScreen'; + static const myPackagesHistoryScreen = '/MyPackagesHistoryScreen'; +} diff --git a/lib/config/urls.dart b/lib/config/urls.dart index 806507d..4d220dc 100644 --- a/lib/config/urls.dart +++ b/lib/config/urls.dart @@ -1,81 +1,166 @@ -class Url { - static const String baseUrl = 'https://www.cssd-doc.com/api'; - - static const String login = '$baseUrl/login'; - - static const String getInputs = '$baseUrl/GetInputs'; - - static const String getUserInfo = '$baseUrl/GetInfo'; - - // static const String testResults = '$baseUrl/TestResults'; - - static const String filterItems = '$baseUrl/TestResults/ListFilterItems'; - - static const String labelItems = '$baseUrl/GetLabels'; - - static const String packageItems = '$baseUrl/GetPackages'; - - static const String requestResetPass = '$baseUrl/password/phone'; - - static const String verifyResetPass = '$baseUrl/password/verifyCode'; - - static const String sendResetPass = '$baseUrl/password/reset'; - - static const String addImage = '$baseUrl/UploadFile'; - - - - static String testResults(int id) { - return '$baseUrl/TestResults?page=$id'; - } - - static String testResultVerification(String id,String value) { - return '$baseUrl/TestResults/Verify/$id/$value'; - } - - static String labelResults(int id) { - return '$baseUrl/Labels?page=$id'; - } - - static String cycleResults(int id) { - return '$baseUrl/Cycles?page=$id'; - } - - static String verifyTest(int id) { - return '$baseUrl/TestResults/Verify/$id'; - } - - static String testResultFormValues(String id) { - return '$baseUrl/TestResults/$id/edit'; - } - - static String updateTestResult(String id) { - return '$baseUrl/TestResults/$id'; - } - - static const String createTestResult = '$baseUrl/TestResults'; - - static const String createCycleResult = '$baseUrl/Cycles'; - - static const String createLabelResult = '$baseUrl/Labels'; - - static String updateLabelResult(String id) { - return '$baseUrl/Labels/$id'; - } - - static String getTestResult(String id) { - return '$baseUrl/TestResults/$id'; - } - - static String getLabelResult(String id) { - return '$baseUrl/Labels/$id'; - } - - static String getCycleResult(String id) { - return '$baseUrl/Cycles/$id'; - } - - static String removeTestResult(String id) { - return '$baseUrl/TestResults/$id'; - } -} +class Url { + static const String baseUrl = 'https://www.cssd-doc.com/api'; + + // https://app.cssd-doc.com + + static const String login = '$baseUrl/login'; + + static const String logOut = '$baseUrl/logOut'; + + static const String getInputs = '$baseUrl/GetInputs'; + + static const String getUserInfo = '$baseUrl/GetInfo'; + + // static const String testResults = '$baseUrl/TestResults'; + + static const String filterItems = '$baseUrl/TestResults/ListFilterItems'; + + static const String labelItems = '$baseUrl/GetLabels'; + + static const String packageItems = '$baseUrl/GetPackages'; + + static const String itemItems = '$baseUrl/GetItems'; + + static const String requestResetPass = '$baseUrl/password/phone'; + + static const String verifyResetPass = '$baseUrl/password/verifyCode'; + + static const String sendResetPass = '$baseUrl/password/reset'; + + static const String addImage = '$baseUrl/UploadFile'; + + // static String getUserMedicalCenterId(int id) { + // return '$baseUrl/users?medical_center_id=$id'; + // } + + static String testResults(int id) { + return '$baseUrl/TestResults?page=$id'; + } + + static String labelResults(int id) { + return '$baseUrl/Labels?page=$id'; + } + + static String cycleResults(int id) { + return '$baseUrl/Cycles?page=$id'; + } + + static String packageResults(int id) { + return '$baseUrl/Packages?page=$id'; + } + + static String itemResults(int id) { + return '$baseUrl/Items?page=$id'; + } + + static String verifyTest(int id) { + return '$baseUrl/TestResults/Verify/$id'; + } + + static String testResultFormValues(String id) { + return '$baseUrl/TestResults/$id/edit'; + } + + static String updateTestResult(String id) { + return '$baseUrl/TestResults/$id'; + } + + static String updateCycleResult(String id) { + return '$baseUrl/Cycles/$id'; + } + + static String updatePackageResult(String id) { + return '$baseUrl/Packages/$id'; + } + + static String updateItemResult(String id) { + return '$baseUrl/Items/$id'; + } + + static const String createTestResult = '$baseUrl/TestResults'; + + static const String createCycleResult = '$baseUrl/Cycles'; + + static const String createLabelResult = '$baseUrl/Labels'; + + static const String createPackageResult = '$baseUrl/Packages'; + + static const String createItemResult = '$baseUrl/Items'; + + static String getMyItems(int id) { + return '$baseUrl/transfer-my-items?page=$id'; + } + + static String getHospitalItems(int id) { + return '$baseUrl/transfer-items?page=$id'; + } + + static String getMyItemRequests = '$baseUrl/my-suspended-transfer-items'; + + static const String getHospitalItemRequests = + '$baseUrl/suspended-transfer-items'; + + static String transferItems(String id) { + return '$baseUrl/transfer-items/$id'; + } + + static String testResultVerification(String id, String value) { + return '$baseUrl/TestResults/Verify/$id/$value'; + } + + static String verifyItemRequests(String id, String value) { + return '$baseUrl/transfer-items/ChangeStatus/$id'; + } + + static String updateLabelResult(String id) { + return '$baseUrl/Labels/$id'; + } + + static String getTestResult(String id) { + return '$baseUrl/TestResults/$id'; + } + + static String getLabelResult(String id) { + return '$baseUrl/Labels/$id'; + } + + static String getCycleResult(String id) { + return '$baseUrl/Cycles/$id'; + } + + static String removeTestResult(String id) { + return '$baseUrl/TestResults/$id'; + } + + static String removeLabels(String id) { + return '$baseUrl/Labels/$id'; + } + + static String removeCycles(String id) { + return '$baseUrl/Cycles/$id'; + } + + static String getPackageResult(String id) { + return '$baseUrl/Packages/$id'; + } + + static String removePackages(String id) { + return '$baseUrl/Packages/$id'; + } + + static String getItemResult(String id) { + return '$baseUrl/Items/$id'; + } + + static String removeItems(String id) { + return '$baseUrl/Items/$id'; + } + + static String changeItemStatus(String id) { + return '$baseUrl/Items/ChangeStatus/$id'; + } + + static String getUsers(String id) { + return '$baseUrl/Users?medicalCenter_id=$id'; + } +} diff --git a/lib/config/user.dart b/lib/config/user.dart index 24975d3..9caa18b 100644 --- a/lib/config/user.dart +++ b/lib/config/user.dart @@ -1,11 +1,11 @@ -class User { - static String _token; - - static String get token { - return 'Bearer ' + User._token; - } - - static set token (String token) { - User._token = token; - } -} +class User { + static String? _token; + + static String get token { + return 'Bearer ' + User._token!; + } + + static set token(String token) { + User._token = token; + } +} diff --git a/lib/main.dart b/lib/main.dart index 68b14c9..4b17348 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,147 +1,201 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_phoenix/flutter_phoenix.dart'; -import 'package:provider/provider.dart'; - -import 'config/routes.dart'; -import 'pages/cycle_add_screen.dart'; -import 'pages/cycle_detail_screen.dart'; -import 'pages/cycle_filter_screen.dart'; -import 'pages/cycle_result_screen.dart'; -import 'pages/cycle_scan_screen.dart'; -import 'pages/forget_pass_screen.dart'; -import 'pages/home_screen.dart'; -import 'pages/label_add_screen.dart'; -import 'pages/label_detail_screen.dart'; -import 'pages/label_filter_screen.dart'; -import 'pages/label_result_screen.dart'; -import 'pages/label_scan_screen.dart'; -import 'pages/label_update_screen.dart'; -import 'pages/login_screen.dart'; -import 'pages/my_info_screen.dart'; -import 'pages/rePass_screen.dart'; -import 'pages/test_add_screen.dart'; -import 'pages/test_detail_screen.dart'; -import 'pages/test_filter_screen.dart'; -import 'pages/test_result_screen.dart'; -import 'pages/test_scan_screen.dart'; -import 'pages/test_verify_screen.dart'; -import 'pages/verify_pass_screen.dart'; -import 'providers/auth.dart'; -import 'providers/connectivity.dart'; -import 'providers/cycles.dart'; -import 'providers/input.dart'; -import 'providers/labels.dart'; -import 'providers/my_info.dart'; -import 'providers/test_results.dart'; -import 'widgets/Global/splash_screen.dart'; -import 'widgets/TestResultScreens/Add/capture_image.dart'; - -void main() { - runApp(Phoenix(child: MyApp())); - SystemChrome.setPreferredOrientations([ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - ]); - // SystemChrome.setEnabledSystemUIOverlays([]); - // SystemChrome.setSystemUIOverlayStyle( - // const SystemUiOverlayStyle( - // statusBarColor: Colors.red, - // systemNavigationBarColor: Colors.red, - // systemNavigationBarDividerColor: Colors.blue, - // ), - // ); -} - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MultiProvider( - providers: [ - ChangeNotifierProvider.value( - value: Auth(), - ), - ChangeNotifierProvider.value( - value: TestResultsProvider(), - ), - ChangeNotifierProvider.value( - value: Inputs(), - ), - ChangeNotifierProvider.value( - value: MyInfoProvider(), - ), - ChangeNotifierProvider.value( - value: LabelsProvider(), - ), - ChangeNotifierProvider.value( - value: CyclesProvider(), - ), - ChangeNotifierProvider.value( - value: ConnectivityProvider(), - ) - ], - child: Consumer( - builder: (ctx, auth, _) => Consumer( - builder: (ct, connection, _) { - connection.checkConnection(); - print(connection.conStatus); - return MaterialApp( - debugShowCheckedModeBanner: false, - title: 'CSSD-DOC', - theme: ThemeData( - primaryColor: Colors.black, - // cursorColor: Colors.black, - fontFamily: 'montserrat', - // primaryTextTheme: TextTheme( - // body1: TextStyle( - // color: Colors.black, - // ), - // ) - // textTheme: TextTheme( - // body2: TextStyle(color: Colors.white, fontSize: 16), - // ), - ), - home: auth.isAuth - ? HomePage() - : FutureBuilder( - future: auth.tryAutoLogin(), - builder: (ctx, authResultSnapshot) => - authResultSnapshot.connectionState == - ConnectionState.waiting - ? SplashScreen() - : LoginScreen(), - ), - routes: { - Routes.homePage: (ctx) => HomePage(), - Routes.loginScreen: (ctx) => LoginScreen(), - Routes.forgetPassScreen: (ctx) => ForgetPassScreen(), - Routes.myInfoScreen: (ctx) => MyInfoScreen(), - Routes.testResultScreen: (ctx) => TestResultScreen(), - Routes.testDetailsScreen: (ctx) => TestDetailsScreen(), - Routes.testFilterScreen: (ctx) => TestFilterScreen(), - // Routes.register: (ctx) => Register(), - Routes.testResultAddScreen: (ctx) => TestResultAddScreen(), - Routes.labelDetailScreen: (ctx) => LabelDetailScreen(), - Routes.cycleDetailScreen: (ctx) => CycleDetailScreen(), - Routes.labelFilterScreen: (ctx) => LabelFilterScreen(), - Routes.cycleFilterScreen: (ctx) => CycleFilterScreen(), - Routes.cycleScanScreen: (ctx) => CycleScanScreen(), - Routes.labelScanScreen: (ctx) => LabelScanScreen(), - Routes.cycleAddScreen: (ctx) => CycleAddScreen(), - Routes.labelAddScreen: (ctx) => LabelAddScreen(), - Routes.labelUpdateScreen: (ctx) => LabelUpdateScreen(), - Routes.labelResultScreen: (ctx) => LabelResultScreen(), - Routes.cycleResultScreen: (ctx) => CycleResultScreen(), - Routes.testVerifyScreen: (ctx) => TestVerifyScreen(), - Routes.testScanScreen: (ctx) => TestScanScreen(), - Routes.sendCodeScreen: (ctx) => VerifyPassScreen(), - Routes.rePassScreen: (ctx) => RePassScreen(), - Routes.captureImageScreen: (ctx) => CaptureImage(), - }, - ); - }, - ), - ), - ); - } -} +import 'package:cssd/pages/CyclePages/cycle_update_screen.dart'; +import 'package:cssd/pages/ItemPages/item_add_screen.dart'; +import 'package:cssd/pages/ItemPages/item_detail_screen.dart'; +import 'package:cssd/pages/ItemPages/item_filter_screen.dart'; +import 'package:cssd/pages/ItemPages/item_result_screen.dart'; +import 'package:cssd/pages/ItemPages/item_scan_screen.dart'; +import 'package:cssd/pages/ItemPages/item_update_screen.dart'; +import 'package:cssd/pages/LabelPages/label_update_screen.dart'; +import 'package:cssd/pages/MyItemsPages/Result/my_items_result_screen.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_detail_screen.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_filter_screen.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_history_screen.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_transfer_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/Result/my_packages_result_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_detail_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_filter_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_history_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_transfer_screen.dart'; +import 'package:cssd/pages/PackagePages/package_add_screen.dart'; +import 'package:cssd/pages/PackagePages/package_detail_screen.dart'; +import 'package:cssd/pages/PackagePages/package_filter_screen.dart'; +import 'package:cssd/pages/PackagePages/package_result_screen.dart'; +import 'package:cssd/pages/PackagePages/package_scan_screen.dart'; +import 'package:cssd/pages/PackagePages/package_update_screen.dart'; +import 'package:cssd/pages/TestPages/test_form_page.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:cssd/providers/my_packages.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/providers/users.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_phoenix/flutter_phoenix.dart'; +import 'package:provider/provider.dart'; + +import 'config/routes.dart'; +import 'pages/CyclePages/cycle_add_screen.dart'; +import 'pages/CyclePages/cycle_detail_screen.dart'; +import 'pages/CyclePages/cycle_filter_screen.dart'; +import 'pages/CyclePages/cycle_result_screen.dart'; +import 'pages/CyclePages/cycle_scan_screen.dart'; +import 'pages/LoginRegisterPages/forget_pass_screen.dart'; +import 'pages/home_screen.dart'; +import 'pages/LabelPages/label_add_screen.dart'; +import 'pages/LabelPages/label_detail_screen.dart'; +import 'pages/LabelPages/label_filter_screen.dart'; +import 'pages/LabelPages/label_result_screen.dart'; +import 'pages/LabelPages/label_scan_screen.dart'; +import 'pages/LoginRegisterPages/login_screen.dart'; +import 'pages/my_info_screen.dart'; +import 'pages/LoginRegisterPages/rePass_screen.dart'; +import 'pages/TestPages/test_add_screen.dart'; +import 'pages/TestPages/test_detail_screen.dart'; +import 'pages/TestPages/test_filter_screen.dart'; +import 'pages/TestPages/test_result_screen.dart'; +import 'pages/TestPages/test_scan_screen.dart'; +import 'pages/TestPages/test_verify_screen.dart'; +import 'pages/LoginRegisterPages/verify_pass_screen.dart'; +import 'providers/auth.dart'; +import 'providers/connectivity.dart'; +import 'providers/cycles.dart'; +import 'providers/input.dart'; +import 'providers/labels.dart'; +import 'providers/my_info.dart'; +import 'providers/test_results.dart'; +import 'widgets/Global/splash_screen.dart'; +import 'widgets/TestResultScreens/Add/capture_image.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + ]); + runApp(Phoenix(child: MyApp())); +} + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MultiProvider( + providers: [ + ChangeNotifierProvider.value( + value: Auth(), + ), + ChangeNotifierProvider.value( + value: TestResultsProvider(), + ), + ChangeNotifierProvider.value( + value: Inputs(), + ), + ChangeNotifierProvider.value( + value: MyInfoProvider(), + ), + ChangeNotifierProvider.value( + value: LabelsProvider(), + ), + ChangeNotifierProvider.value( + value: CyclesProvider(), + ), + ChangeNotifierProvider.value( + value: ConnectivityProvider(), + ), + ChangeNotifierProvider.value( + value: PackageProvider(), + ), + ChangeNotifierProvider.value( + value: ItemProvider(), + ), + ChangeNotifierProvider.value( + value: MyItemProvider(), + ), + ChangeNotifierProvider.value( + value: MyPackageProvider(), + ), + ChangeNotifierProvider.value( + value: UsersProvider(), + ), + ], + child: Consumer( + builder: (ctx, auth, _) => Consumer( + builder: (ct, connection, _) { + connection.checkConnection(); + print(connection.conStatus); + return MaterialApp( + debugShowCheckedModeBanner: false, + title: 'CSSD-DOC', + theme: ThemeData( + primaryColor: Colors.black, + fontFamily: 'montserrat', + ), + home: auth.isAuth + ? HomePage() + : FutureBuilder( + future: auth.tryAutoLogin(), + builder: (ctx, authResultSnapshot) => + authResultSnapshot.connectionState == + ConnectionState.waiting + ? SplashScreen() + : LoginScreen(), + ), + routes: { + Routes.homePage: (ctx) => HomePage(), + Routes.loginScreen: (ctx) => LoginScreen(), + Routes.forgetPassScreen: (ctx) => ForgetPassScreen(), + Routes.myInfoScreen: (ctx) => MyInfoScreen(), + Routes.testResultScreen: (ctx) => TestResultScreen(), + Routes.testDetailsScreen: (ctx) => TestDetailsScreen(), + Routes.testFilterScreen: (ctx) => TestFilterScreen(), + Routes.testResultAddScreen: (ctx) => TestResultAddScreen(), + Routes.labelDetailScreen: (ctx) => LabelDetailScreen(), + Routes.cycleDetailScreen: (ctx) => CycleDetailScreen(), + Routes.labelFilterScreen: (ctx) => LabelFilterScreen(), + Routes.cycleFilterScreen: (ctx) => CycleFilterScreen(), + Routes.cycleScanScreen: (ctx) => CycleScanScreen(), + Routes.labelScanScreen: (ctx) => LabelScanScreen(), + Routes.labelUpdateScreen: (ctx) => LabelUpdateScreen(), + Routes.cycleAddScreen: (ctx) => CycleAddScreen(), + Routes.labelAddScreen: (ctx) => LabelAddScreen(), + Routes.labelResultScreen: (ctx) => LabelResultScreen(), + Routes.cycleResultScreen: (ctx) => CycleResultScreen(), + Routes.testVerifyScreen: (ctx) => TestVerifyScreen(), + Routes.testScanScreen: (ctx) => TestScanScreen(), + Routes.sendCodeScreen: (ctx) => VerifyPassScreen(), + Routes.rePassScreen: (ctx) => RePassScreen(), + Routes.captureImageScreen: (ctx) => CaptureImage(), + Routes.packageAddScreen: (ctx) => PackageAddScreen(), + Routes.packageResultScreen: (ctx) => PackageResultScreen(), + Routes.packageDetailScreen: (ctx) => PackageDetailScreen(), + Routes.packageFilterScreen: (ctx) => PackageFilterScreen(), + Routes.itemResultScreen: (ctx) => ItemResultScreen(), + Routes.itemAddScreen: (ctx) => ItemAddScreen(), + Routes.itemFilterScreen: (ctx) => ItemFilterScreen(), + Routes.itemDetailScreen: (ctx) => ItemDetailScreen(), + Routes.formTestResultScreen: (ctx) => FormPage(), + Routes.cycleUpdateScreen: (ctx) => CycleUpdateScreen(), + Routes.packageUpdateScreen: (ctx) => PackageUpdateScreen(), + Routes.itemUpdateScreen: (ctx) => ItemUpdateScreen(), + Routes.itemScanScreen: (ctx) => ItemScanScreen(), + Routes.packageScanScreen: (ctx) => PackageScanScreen(), + Routes.myItemsResultScreen: (ctx) => MyItemsResultScreen(), + Routes.myItemsFilterScreen: (ctx) => MyItemsFilterScreen(), + Routes.myItemsDetailScreen: (ctx) => MyItemsDetailScreen(), + Routes.itemsTransferScreen: (ctx) => ItemsTransferScreen(), + Routes.myItemsHistoryScreen: (ctx) => MyItemsHistoryScreen(), + Routes.myPackagesResultScreen: (ctx) => + MyPackagesResultScreen(), + Routes.myPackagesFilterScreen: (ctx) => MyPackageFilterScreen(), + Routes.myPackagesDetailScreen: (ctx) => + MyPackagesDetailScreen(), + Routes.packagesTransferScreen: (ctx) => PackageTransferScreen(), + Routes.myPackagesHistoryScreen: (ctx) => + MyPackagesHistoryScreen(), + }, + ); + }, + ), + ), + ); + } +} diff --git a/lib/models/connection_model.dart b/lib/models/connection_model.dart deleted file mode 100644 index fbc53f4..0000000 --- a/lib/models/connection_model.dart +++ /dev/null @@ -1,5 +0,0 @@ -enum ConnectionStatus{ - Wifi, - Calcular, - Offline -} \ No newline at end of file diff --git a/lib/models/cycles_models.dart b/lib/models/cycles_models.dart index 4d18e2c..26a9bc9 100644 --- a/lib/models/cycles_models.dart +++ b/lib/models/cycles_models.dart @@ -1,52 +1,90 @@ -import 'package:flutter/cupertino.dart'; - -class CycleResultObject { - final String id; - final List label; - final String createdAt; - - CycleResultObject({ - @required this.id, - @required this.label, - @required this.createdAt, - }); -} - -class CycleDetailObject { - final String id; - final String description; - final String createDate; - final String hospitalName; - - final String date; - final String sterileId; - final String cycleNumber; - final List labels; - - CycleDetailObject({ - @required this.id, - @required this.description, - @required this.createDate, - @required this.hospitalName, - @required this.date, - @required this.sterileId, - @required this.cycleNumber, - @required this.labels, - }); -} - -class CycleFilterObject { - final String id; - final String cycleNumber; - final String sterilizerId; - final String hospital; - final String date; - - CycleFilterObject({ - @required this.id, - @required this.cycleNumber, - @required this.sterilizerId, - @required this.hospital, - @required this.date, - }); -} +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class CycleResultObject extends Equatable { + final String id; + final List label; + final String createdAt; + + CycleResultObject({ + required this.id, + required this.label, + required this.createdAt, + }); + + @override + List get props => [id, label, createdAt]; + + @override + bool get stringify => true; +} + +class CycleDetailObject extends Equatable { + final String id; + final String description; + final String createDate; + final String hospitalName; + + final String date; + final String sterileId; + final String cycleNumber; + final List labels; + + CycleDetailObject({ + required this.id, + required this.description, + required this.createDate, + required this.hospitalName, + required this.date, + required this.sterileId, + required this.cycleNumber, + required this.labels, + }); + + @override + List get props { + return [ + id, + description, + createDate, + hospitalName, + date, + sterileId, + cycleNumber, + labels, + ]; + } + + @override + bool get stringify => true; +} + +class CycleFilterObject extends Equatable { + final String id; + final String cycleNumber; + final String sterilizerId; + final String hospital; + final String date; + + CycleFilterObject({ + required this.id, + required this.cycleNumber, + required this.sterilizerId, + required this.hospital, + required this.date, + }); + + @override + List get props { + return [ + id, + cycleNumber, + sterilizerId, + hospital, + date, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/item_model.dart b/lib/models/item_model.dart new file mode 100644 index 0000000..fde73d5 --- /dev/null +++ b/lib/models/item_model.dart @@ -0,0 +1,111 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class ItemResultObject extends Equatable { + final String id; + final String name; + final String size; + final String userName; + final int status; + final String? batchId; + + ItemResultObject({ + required this.id, + required this.name, + required this.size, + required this.userName, + required this.status, + this.batchId, + }); + + @override + List get props => [ + id, + name, + size, + userName, + status, + batchId!, + ]; + + @override + bool get stringify => true; +} + +class ItemDetailObject extends Equatable { + final String id; + final String name; + final String userName; + final String size; + final String specific; + final String hospital; + final String description; + final String createdAt; + final String udi; + final int status; + + ItemDetailObject({ + required this.id, + required this.name, + required this.userName, + required this.size, + required this.specific, + required this.hospital, + required this.description, + required this.createdAt, + required this.udi, + required this.status, + }); + + @override + List get props { + return [ + id, + name, + userName, + size, + specific, + hospital, + description, + createdAt, + udi, + status, + ]; + } + + @override + bool get stringify => true; +} + +class ItemFilterObject extends Equatable { + final String id; + final String name; + final String udi; + final String hospital; + final String size; + final String specific; + + ItemFilterObject({ + required this.id, + required this.name, + required this.udi, + required this.hospital, + required this.size, + required this.specific, + }); + + @override + List get props { + return [ + id, + name, + udi, + hospital, + size, + specific, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/label_models.dart b/lib/models/label_models.dart index 550ca37..5509f5a 100644 --- a/lib/models/label_models.dart +++ b/lib/models/label_models.dart @@ -1,56 +1,88 @@ -import 'package:flutter/cupertino.dart'; - -class LabelResultObject { - final String id; - final String package; - final String packageId; - final String expireDate; - - LabelResultObject({ - @required this.id, - @required this.package, - @required this.packageId, - @required this.expireDate, - }); -} - -class LabelDetailsObject { - final String id; - final String package; - final String packageId; - final String hospitalName; - - final String createDate; - final String expireDate; - final String sterileDate; - final String sterileId; - final String cycleNumber; - final String lotNumber; - - LabelDetailsObject({ - @required this.id, - @required this.package, - @required this.packageId, - @required this.hospitalName, - @required this.createDate, - @required this.expireDate, - @required this.sterileDate, - @required this.sterileId, - @required this.cycleNumber, - @required this.lotNumber, - }); -} - -class LabelFilterObject { - final String id; - final String cycleNumber; - final String sterilizerId; - final String hospital; - - LabelFilterObject({ - @required this.id, - @required this.cycleNumber, - @required this.sterilizerId, - @required this.hospital, - }); -} +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class LabelResultObject extends Equatable { + final String id; + final String package; + final String packageId; + final String expireDate; + + LabelResultObject({ + required this.id, + required this.package, + required this.packageId, + required this.expireDate, + }); + + @override + List get props => [id, package, packageId, expireDate]; + + @override + bool get stringify => true; +} + +class LabelDetailsObject extends Equatable { + final String id; + final String package; + final String packageId; + final String hospitalName; + + final String createDate; + final String expireDate; + final String sterileDate; + final String sterileId; + final String cycleNumber; + final String lotNumber; + + LabelDetailsObject({ + required this.id, + required this.package, + required this.packageId, + required this.hospitalName, + required this.createDate, + required this.expireDate, + required this.sterileDate, + required this.sterileId, + required this.cycleNumber, + required this.lotNumber, + }); + + @override + List get props { + return [ + id, + package, + packageId, + hospitalName, + createDate, + expireDate, + sterileDate, + sterileId, + cycleNumber, + lotNumber, + ]; + } + + @override + bool get stringify => true; +} + +class LabelFilterObject extends Equatable { + final String id; + final String cycleNumber; + final String sterilizerId; + final String hospital; + + LabelFilterObject({ + required this.id, + required this.cycleNumber, + required this.sterilizerId, + required this.hospital, + }); + + @override + List get props => [id, cycleNumber, sterilizerId, hospital]; + + @override + bool get stringify => true; +} diff --git a/lib/models/my_item_model.dart b/lib/models/my_item_model.dart new file mode 100644 index 0000000..fffa481 --- /dev/null +++ b/lib/models/my_item_model.dart @@ -0,0 +1,62 @@ +import 'package:equatable/equatable.dart'; + +class MyItemResultObject extends Equatable { + final String id; + final String name; + final String size; + final String? userName; + final String? fromDate; + final String? toDate; + + MyItemResultObject({ + required this.id, + required this.name, + required this.size, + this.userName, + this.fromDate, + this.toDate, + }); + + @override + List get props => [ + id, + name, + size, + userName!, + fromDate!, + toDate!, + ]; + + @override + bool get stringify => true; +} + +class MyItemFilterObject extends Equatable { + final String id; + final String name; + final String udi; + final String size; + final String specific; + + MyItemFilterObject({ + required this.id, + required this.name, + required this.udi, + required this.size, + required this.specific, + }); + + @override + List get props { + return [ + id, + name, + udi, + size, + specific, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/my_package_model.dart b/lib/models/my_package_model.dart new file mode 100644 index 0000000..f0370d0 --- /dev/null +++ b/lib/models/my_package_model.dart @@ -0,0 +1,53 @@ +import 'package:equatable/equatable.dart'; + +class MyPackageResultObject extends Equatable { + final String id; + final String name; + final String? userName; + final String? fromDate; + final String? toDate; + + MyPackageResultObject({ + required this.id, + required this.name, + this.userName, + this.fromDate, + this.toDate, + }); + + @override + List get props => [ + id, + name, + userName!, + fromDate!, + toDate!, + ]; + + @override + bool get stringify => true; +} + +class MyPackageFilterObject extends Equatable { + final String id; + final String name; + final String udi; + + MyPackageFilterObject({ + required this.id, + required this.name, + required this.udi, + }); + + @override + List get props { + return [ + id, + name, + udi, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/package_model.dart b/lib/models/package_model.dart new file mode 100644 index 0000000..b8d922f --- /dev/null +++ b/lib/models/package_model.dart @@ -0,0 +1,87 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class PackageResultObject extends Equatable { + final String id; + final String createdAt; + final String name; + + PackageResultObject({ + required this.id, + required this.createdAt, + required this.name, + }); + + @override + List get props => [ + id, + createdAt, + name, + ]; + + @override + bool get stringify => true; +} + +class PackageDetailObject extends Equatable { + final String id; + final String name; + final String description; + final String createDate; + final String hospitalName; + final String udi; + final List items; + + PackageDetailObject({ + required this.id, + required this.name, + required this.description, + required this.createDate, + required this.hospitalName, + required this.udi, + required this.items, + }); + + @override + List get props { + return [ + id, + name, + description, + createDate, + hospitalName, + udi, + items, + ]; + } + + @override + bool get stringify => true; +} + +class PackageFilterObject extends Equatable { + final String id; + final String name; + final String hospital; + final String udi; + + PackageFilterObject({ + required this.id, + required this.name, + required this.hospital, + required this.udi, + }); + + @override + List get props { + return [ + id, + name, + hospital, + udi, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/test_result_models.dart b/lib/models/test_result_models.dart index 9a5b30b..3787f73 100644 --- a/lib/models/test_result_models.dart +++ b/lib/models/test_result_models.dart @@ -1,41 +1,74 @@ -import 'package:flutter/material.dart'; - -class TestResultObject { - final String id; - final String name; - final String deviceId; - final String result; - final String date; - final String hospital; - final String verified; - - TestResultObject({ - @required this.id, - @required this.name, - @required this.deviceId, - @required this.result, - @required this.date, - @required this.hospital, - @required this.verified, - }); -} - -class TestResultFilterObject { - final String id; - final String labelID; - final String userName; - final String hospital; - final String testType; - final String fDate; - final String uDate; - - TestResultFilterObject({ - @required this.id, - @required this.labelID, - @required this.userName, - @required this.hospital, - @required this.testType, - @required this.fDate, - @required this.uDate, - }); -} +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class TestResultObject extends Equatable { + final String id; + final String name; + final String deviceId; + final String result; + final String date; + final String hospital; + final String verified; + + TestResultObject({ + required this.id, + required this.name, + required this.deviceId, + required this.result, + required this.date, + required this.hospital, + required this.verified, + }); + + @override + List get props { + return [ + id, + name, + deviceId, + result, + date, + hospital, + verified, + ]; + } + + @override + bool get stringify => true; +} + +class TestResultFilterObject extends Equatable { + final String id; + final String labelID; + final String userName; + final String hospital; + final String testType; + final String fDate; + final String uDate; + + TestResultFilterObject({ + required this.id, + required this.labelID, + required this.userName, + required this.hospital, + required this.testType, + required this.fDate, + required this.uDate, + }); + + @override + List get props { + return [ + id, + labelID, + userName, + hospital, + testType, + fDate, + uDate, + ]; + } + + @override + bool get stringify => true; +} diff --git a/lib/models/users_model.dart b/lib/models/users_model.dart new file mode 100644 index 0000000..ac97b8d --- /dev/null +++ b/lib/models/users_model.dart @@ -0,0 +1,24 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:equatable/equatable.dart'; + +class Users extends Equatable { + final String id; + final String userName; + final String phoneNumber; + + const Users({ + required this.userName, + required this.phoneNumber, + required this.id, + }); + + @override + List get props => [ + userName, + phoneNumber, + id, + ]; + + @override + bool get stringify => true; +} diff --git a/lib/pages/CyclePages/cycle_add_screen.dart b/lib/pages/CyclePages/cycle_add_screen.dart new file mode 100644 index 0000000..01fdb49 --- /dev/null +++ b/lib/pages/CyclePages/cycle_add_screen.dart @@ -0,0 +1,343 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/cycles_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/cycles.dart'; +import '../../widgets/CycleScreens/Add/add_label_box.dart'; +import '../../widgets/CycleScreens/Add/date_picker.dart'; +import '../../widgets/CycleScreens/Add/save_button.dart'; +import '../../widgets/Global/internet_error.dart'; + +class CycleAddScreen extends StatefulWidget { + // static const route = '/CycleAddScreen'; + + @override + _CycleAddScreenState createState() => _CycleAddScreenState(); +} + +class _CycleAddScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + final _descriptionFocosNode = FocusNode(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController dateCTRL = new TextEditingController(); + DateTime? dateTimeFrom; + final _form = GlobalKey(); + + bool isInit = true; + CycleFilterObject? filters; + + List labelsCTRL = [TextEditingController()]; + int curLabelVal = 1; + @override + void initState() { + descriptionCTRL.text = ''; + cycleNumberCTRL.text = ''; + dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + striizerIdCTRL.text = ''; + // dateValue = DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + // var _id = ModalRoute.of(context).settings.arguments; + var cycleProviderObject = Provider.of(context); + cycleProviderObject.resetLabelVals(); + cycleProviderObject.getLabelFilters().then( + (result) { + setState( + () { + // labelValues = + // filters.hospital == '' ? labelVals[0] : filters.hospital; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.cycleResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Add a Cycle', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: + EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: + TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocosNode); + }, + ), + SizedBox( + height: 30, + ), + CycleAddDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 20.0, + ), + Container( + margin: EdgeInsets.symmetric(vertical: 10), + child: Text( + 'Labels included', + style: TextStyle( + color: kPink, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, cycleProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => AddLabelBox( + text: 'Select Labels included', + iconColor: kPinkSub, + deviceBlockSize: _deviceBlockSize, + values: + cycleProvider.labelValues[index], + vals: cycleProvider.labelVals, + initialLabelValue: + cycleProvider.initialLabelValue, + index: index, + ), + itemCount: + cycleProvider.labelValues.length, + ), + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocosNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + CycleAddSaveButton( + form: _form, + labelValues: Provider.of( + context, + listen: false, + ).labelValues, + cycleNumberCTRL: cycleNumberCTRL, + dateValue: dateCTRL.text, + descriptionCTRL: descriptionCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/cycle_detail_screen.dart b/lib/pages/CyclePages/cycle_detail_screen.dart similarity index 76% rename from lib/pages/cycle_detail_screen.dart rename to lib/pages/CyclePages/cycle_detail_screen.dart index 79113a8..08c5201 100644 --- a/lib/pages/cycle_detail_screen.dart +++ b/lib/pages/CyclePages/cycle_detail_screen.dart @@ -1,85 +1,88 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../models/cycles_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/cycles.dart'; -import '../widgets/CycleScreens/Details/datas_box.dart'; -import '../widgets/Global/internet_error.dart'; - -class CycleDetailScreen extends StatefulWidget { - // static const route = '/CycleDetailScreen'; - final String testResultId; - - CycleDetailScreen({this.testResultId}); - - @override - _CycleDetailScreenState createState() => _CycleDetailScreenState(); -} - -class _CycleDetailScreenState extends State { - bool isInit = true; - bool isEmpty = false; - CycleDetailObject datas; - @override - void didChangeDependencies() async { - if (isInit) { - var _id = ModalRoute.of(context).settings.arguments; - await Provider.of(context, listen: false) - .showCycleResult(_id.toString()) - .then( - (result) { - setState( - () { - if (result.id == 'null') { - isEmpty = true; - } - datas = result; - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Cycles'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : isEmpty - ? Center( - child: Text('This Cycle doesnt exists!'), - ) - : CycleDetailsDataBox( - datas: datas, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }), - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../models/cycles_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/cycles.dart'; +import '../../widgets/CycleScreens/Details/datas_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +class CycleDetailScreen extends StatefulWidget { + // static const route = '/CycleDetailScreen'; + final String? testResultId; + + CycleDetailScreen({this.testResultId}); + + @override + _CycleDetailScreenState createState() => _CycleDetailScreenState(); +} + +class _CycleDetailScreenState extends State { + bool isInit = true; + bool isEmpty = false; + CycleDetailObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showCycleResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Cycle doesnt exists!'), + ) + : CycleDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }), + ), + ); + } +} diff --git a/lib/pages/CyclePages/cycle_filter_screen.dart b/lib/pages/CyclePages/cycle_filter_screen.dart new file mode 100644 index 0000000..524d752 --- /dev/null +++ b/lib/pages/CyclePages/cycle_filter_screen.dart @@ -0,0 +1,351 @@ +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/cycles_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/cycles.dart'; +import '../../widgets/CycleScreens/Filter/date_picker.dart'; +import '../../widgets/CycleScreens/Filter/save_button.dart'; +import '../../widgets/CycleScreens/Filter/selector_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +class CycleFilterScreen extends StatefulWidget { + // static const route = '/CycleFilterScreen'; + + @override + _CycleFilterScreenState createState() => _CycleFilterScreenState(); +} + +class _CycleFilterScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + final _strilizerIdFocusNode = FocusNode(); + TextEditingController cycleIdCTRL = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + + TextEditingController dateCTRL = new TextEditingController(); + DateTime? dateTimeFrom; + // String dateValue; + + List> hospitalVals = []; + // String curhospitalVal; + bool isInit = true; + CycleFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + cycleIdCTRL.text = filters!.id; + cycleNumberCTRL.text = filters!.cycleNumber; + // dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + dateCTRL.text = ''; + striizerIdCTRL.text = filters!.sterilizerId; + // dateValue = DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + // var _id = ModalRoute.of(context).settings.arguments; + await Provider.of(context, listen: false) + .getHospitalsFilters() + .then( + (result) { + setState( + () { + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } + filters!.hospital == '' + ? hospitalCTRL.text = hospitalVals[0]['name']! + : hospitalVals.forEach( + //id convert to name + (hospital) { + if (hospital['id'] == filters!.hospital) { + hospitalCTRL.text = hospital['name']!; + } + }, + ); + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.cycleResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter Cycles', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: cycleIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + cycleIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_strilizerIdFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextField( + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Strilizer ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _strilizerIdFocusNode, + keyboardType: + TextInputType.visiblePassword, + textInputAction: TextInputAction.done, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 20, + ), + CycleFilterDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 70, + ), + CycleFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + cycleIdCTRL: cycleIdCTRL, + cycleNumberCTRL: cycleNumberCTRL, + striizerIdCTRL: striizerIdCTRL, + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/CyclePages/cycle_result_screen.dart b/lib/pages/CyclePages/cycle_result_screen.dart new file mode 100644 index 0000000..1c69552 --- /dev/null +++ b/lib/pages/CyclePages/cycle_result_screen.dart @@ -0,0 +1,295 @@ +import 'package:cssd/config/colors.dart'; + +import '../../config/routes.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Result/banner.dart'; +import '../../widgets/CycleScreens/Result/data_box.dart'; +import '../../widgets/CycleScreens/Result/filter_objects.dart'; +import '../../widgets/CycleScreens/Result/search_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +import '../../providers/cycles.dart'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class CycleResultScreen extends StatefulWidget { + // static const route = '/CycleResultScreen'; + final bool? isAdmin; + + CycleResultScreen({this.isAdmin}); + + @override + _CycleResultScreenState createState() => _CycleResultScreenState(); +} + +class _CycleResultScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var testResults = Provider.of(context); + testResults.setLoading(); + testResults.resetPageNumber(); + testResults.getCycleResults().then((_) { + testResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var testResults = Provider.of( + context, + listen: false, + ); + testResults.getCycleResults(); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + floatingActionButton: CycleResultFloatingButton( + deviceBlockSize: _deviceBlockSize, + ), + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, right: 20, bottom: 60, left: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Cycles', + push: Routes.cycleFilterScreen, + ), + Consumer(builder: (ctx, cycle, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + cycle.filters!.id != '' + ? CycleFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + cycleNumber: + cycle.filters!.cycleNumber, + sterilizerId: + cycle.filters!.sterilizerId, + hospital: cycle.filters!.hospital, + date: cycle.filters!.date, + ) + : Container(), + cycle.filters!.cycleNumber != '' + ? CycleFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Cycle Number', + id: cycle.filters!.id, + cycleNumber: '', + sterilizerId: + cycle.filters!.sterilizerId, + hospital: cycle.filters!.hospital, + date: cycle.filters!.date, + ) + : Container(), + cycle.filters!.sterilizerId != '' + ? CycleFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Sterilizer ID', + id: cycle.filters!.id, + cycleNumber: + cycle.filters!.cycleNumber, + sterilizerId: '', + hospital: cycle.filters!.hospital, + date: cycle.filters!.date, + ) + : Container(), + cycle.filters!.hospital != '' + ? CycleFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Hospital', + id: cycle.filters!.id, + cycleNumber: + cycle.filters!.cycleNumber, + sterilizerId: + cycle.filters!.sterilizerId, + hospital: '', + date: cycle.filters!.date, + ) + : Container(), + cycle.filters!.date != '' + ? CycleFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Date', + id: cycle.filters!.id, + cycleNumber: + cycle.filters!.cycleNumber, + sterilizerId: + cycle.filters!.sterilizerId, + hospital: cycle.filters!.hospital, + date: '', + ) + : Container(), + ], + ), + ); + }), + ResultSearchBox( + searchCTRL: searchCTRL, + deviceBlockSize: _deviceBlockSize, + text: 'cycle', + onChanged: (value) { + Provider.of(context, + listen: false) + .search(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, cycleResults, _) { + return cycleResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + String labels = ''; + for (var label in cycleResults + .items![index].label) { + labels += label; + labels += ' , '; + } + if (labels.length >= 3) { + labels = labels.substring( + 0, + labels.length - + 3); // remove extra , + } + return CycleItemBox( + deviceBlockSize: _deviceBlockSize, + item: cycleResults.items?[index], + labels: labels, + ); + }, + itemCount: cycleResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} + +class CycleResultFloatingButton extends StatelessWidget { + const CycleResultFloatingButton({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.cycleScanScreen); + }, + child: Container( + padding: EdgeInsets.all(2.5 * _deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen); + }, + child: Container( + padding: EdgeInsets.all(_deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kPink, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/CyclePages/cycle_scan_screen.dart b/lib/pages/CyclePages/cycle_scan_screen.dart new file mode 100644 index 0000000..a7bdb80 --- /dev/null +++ b/lib/pages/CyclePages/cycle_scan_screen.dart @@ -0,0 +1,197 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class CycleScanScreen extends StatefulWidget { + // static const route = '/cycleScanScreen'; + @override + State createState() { + return _CycleScanScreenState(); + } +} + +class _CycleScanScreenState extends State { + String testCode = ""; + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Cycle?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, + ), + ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Cycle Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + textAlign: TextAlign.center, + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Cycle/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; + } + return null; + }, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a cycle ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, + ), + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Cycle/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPink, kPinkSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/CyclePages/cycle_update_screen.dart b/lib/pages/CyclePages/cycle_update_screen.dart new file mode 100644 index 0000000..abf9076 --- /dev/null +++ b/lib/pages/CyclePages/cycle_update_screen.dart @@ -0,0 +1,281 @@ +import 'package:cssd/models/cycles_models.dart'; +import 'package:cssd/providers/cycles.dart'; +import 'package:cssd/widgets/CycleScreens/Add/cycle_update_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; +import 'package:provider/provider.dart'; +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Add/date_picker.dart'; + +class CycleUpdateScreen extends StatefulWidget { + @override + _CycleUpdateScreenState createState() => _CycleUpdateScreenState(); +} + +class _CycleUpdateScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + final _descriptionFocusNode = FocusNode(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController sterilizerIdCTRL = new TextEditingController(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController dateCTRL = new TextEditingController(); + TextEditingController labelCTRL = new TextEditingController(); + + final _form = GlobalKey(); + + // List> labelVals = []; + // List labelValue = []; + bool isEmpty = false; + bool isInit = true; + CycleDetailObject? datas; + @override + void initState() { + dateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showCycleResult(_id.toString()) + .then( + (result) { + setState( + () { + datas = result; + cycleNumberCTRL.text = datas!.cycleNumber; + sterilizerIdCTRL.text = datas!.sterileId; + descriptionCTRL.text = datas!.description; + dateCTRL.text = datas!.date; + // for (var label in datas!.labels) { + // labelCTRL.text = label; + // } + }, + ); + }, + ); + await Provider.of(context, listen: false) + .getLabelFilters() + .then( + (result) { + setState( + () { + // labelVals = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.cycleResultScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + backgroundColor: Colors.black, + title: Text('Cycles'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(color: Colors.black), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Update a Cycle', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: sterilizerIdCTRL, + decoration: InputDecoration( + icon: Icon(FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_cycleNumberFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 20, + ), + LabelAddDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Date', + ), + // SizedBox( + // height: 20.0, + // ), + // Consumer( + // builder: (ctx, cycleProvider, _) => + // ListView.builder( + // physics: NeverScrollableScrollPhysics(), + // shrinkWrap: true, + // itemBuilder: (ctx, index) => AddLabelBox( + // text: 'Select Labels included', + // iconColor: kPinkSub, + // deviceBlockSize: _deviceBlockSize, + // values: cycleProvider.labelValues[index], + // vals: cycleProvider.labelVals, + // initialLabelValue: labelCTRL.text, + // index: index, + // ), + // itemCount: cycleProvider.labelValues.length, + // ), + // ), + SizedBox( + height: 20, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + CycleUpdateButton( + form: _form, + id: datas!.id, + cycleNumberCTRL: cycleNumberCTRL, + dateCTRL: dateCTRL, + // labelValue: labelCTRL, + striizerIdCTRL: sterilizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + descriptionCTRL: descriptionCTRL, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/ItemPages/item_add_screen.dart b/lib/pages/ItemPages/item_add_screen.dart new file mode 100644 index 0000000..620b82a --- /dev/null +++ b/lib/pages/ItemPages/item_add_screen.dart @@ -0,0 +1,342 @@ +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/ItemScreens/Add/item_save_button.dart'; +import 'package:cssd/widgets/ItemScreens/Add/upload_image.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; +import 'package:random_string/random_string.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ItemAddScreen extends StatefulWidget { + @override + _ItemAddScreenState createState() => _ItemAddScreenState(); +} + +class _ItemAddScreenState extends State { + final _itemSizeFocusNode = FocusNode(); + final _itemSpecificFocusNode = FocusNode(); + final _itemUdiFocusNode = FocusNode(); + final _descriptionFocusNode = FocusNode(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController specificCTRL = new TextEditingController(); + TextEditingController sizeCTRL = new TextEditingController(); + TextEditingController dateCTRL = new TextEditingController(); + final _form = GlobalKey(); + bool isInit = true; + ItemFilterObject? filters; + final batchId = randomString(10); + + int curLabelVal = 1; + @override + void initState() { + descriptionCTRL.text = ''; + udiCTRL.text = ''; + nameCTRL.text = ''; + sizeCTRL.text = ''; + specificCTRL.text = ''; + dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var itemProviderObject = Provider.of(context); + itemProviderObject.getItemResults().then( + (result) { + setState( + () { + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + final itemProviderObject = Provider.of(context); + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.itemResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.itemResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add an Item', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Item Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Size required!'; + } + return null; + }, + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Size', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Specific required!'; + } + return null; + }, + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Specific', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'UDI required!'; + } + return null; + }, + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'UDI', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 30.0, + ), + UploaderImage( + deviceBlockSize: _deviceBlockSize, + providerObject: itemProviderObject, + ), + SizedBox( + height: 70, + ), + ItemAddSaveButton( + form: _form, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + descriptionCTRL: descriptionCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + batchId: batchId, + dateValue: dateCTRL.text, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/ItemPages/item_detail_screen.dart b/lib/pages/ItemPages/item_detail_screen.dart new file mode 100644 index 0000000..0ed55fb --- /dev/null +++ b/lib/pages/ItemPages/item_detail_screen.dart @@ -0,0 +1,90 @@ +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/ItemScreens/Details/item_detail_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ItemDetailScreen extends StatefulWidget { + final String? testResultId; + + ItemDetailScreen({ + this.testResultId, + }); + + @override + _ItemDetailScreenState createState() => _ItemDetailScreenState(); +} + +class _ItemDetailScreenState extends State { + bool isInit = true; + bool isEmpty = false; + ItemDetailObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showItemResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Item does\'nt exists!'), + ) + : ItemDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/ItemPages/item_filter_screen.dart b/lib/pages/ItemPages/item_filter_screen.dart new file mode 100644 index 0000000..922c939 --- /dev/null +++ b/lib/pages/ItemPages/item_filter_screen.dart @@ -0,0 +1,409 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:cssd/widgets/ItemScreens/Filter/item_filter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Filter/selector_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ItemFilterScreen extends StatefulWidget { + @override + _ItemFilterScreenState createState() => _ItemFilterScreenState(); +} + +class _ItemFilterScreenState extends State { + final _itemSizeFocusNode = FocusNode(); + final _itemNameFocusNode = FocusNode(); + final _itemUdiFocusNode = FocusNode(); + final _itemSpecificFocusNode = FocusNode(); + TextEditingController idCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController sizeCTRL = new TextEditingController(); + TextEditingController specificCTRL = new TextEditingController(); + + List> hospitalVals = []; + bool isInit = true; + ItemFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + idCTRL.text = filters!.id; + hospitalCTRL.text = filters!.hospital; + nameCTRL.text = filters!.name; + sizeCTRL.text = filters!.size; + specificCTRL.text = filters!.specific; + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + // var _id = ModalRoute.of(context).settings.arguments; + await Provider.of(context, listen: false) + .getHospitalsFilters() + .then( + (result) { + setState( + () { + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } + filters!.hospital == '' + ? hospitalCTRL.text = hospitalVals[0]['name']! + : hospitalVals.forEach( + //id convert to name + (hospital) { + if (hospital['id'] == filters!.hospital) { + hospitalCTRL.text = hospital['name']!; + } + }, + ); + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.itemResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.itemResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Items', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemNameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemNameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30.0, + ), + TextFormField( + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Size', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Specific', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 30, + ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 90, + ), + ItemFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kBlue, + secondColor: kBlueSub, + push: Routes.itemResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/ItemPages/item_result_screen.dart b/lib/pages/ItemPages/item_result_screen.dart new file mode 100644 index 0000000..e04e6b1 --- /dev/null +++ b/lib/pages/ItemPages/item_result_screen.dart @@ -0,0 +1,294 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/ItemScreens/Filter/item_filter_object.dart'; +import 'package:cssd/widgets/ItemScreens/Result/item_data_box.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Result/banner.dart'; +import '../../widgets/CycleScreens/Result/search_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ItemResultScreen extends StatefulWidget { + final bool? isAdmin; + + ItemResultScreen({this.isAdmin}); + + @override + _ItemResultScreenState createState() => _ItemResultScreenState(); +} + +class _ItemResultScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var testResults = Provider.of(context); + testResults.setLoading(); + testResults.resetPageNumber(); + testResults.getItemResults().then((_) { + testResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var testResults = Provider.of( + context, + listen: false, + ); + testResults.getItemResults(); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + floatingActionButton: ItemResultFloatingButton( + deviceBlockSize: _deviceBlockSize, + ), + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Items', + push: Routes.itemFilterScreen, + ), + Consumer( + builder: (ctx, item, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + item.filters!.id != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + name: item.filters!.name, + udi: item.filters!.udi, + hospital: item.filters!.hospital, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.name != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Item Name', + id: item.filters!.id, + name: '', + udi: item.filters!.udi, + hospital: item.filters!.hospital, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.udi != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'UDI', + id: item.filters!.id, + name: item.filters!.name, + udi: '', + hospital: item.filters!.hospital, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.hospital != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Hospital', + id: item.filters!.id, + name: item.filters!.name, + hospital: '', + udi: item.filters!.udi, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.size != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Size', + id: item.filters!.id, + name: item.filters!.name, + udi: item.filters!.udi, + hospital: item.filters!.hospital, + size: '', + specific: item.filters!.specific, + ) + : Container(), + item.filters!.specific != '' + ? ItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Specific', + id: item.filters!.id, + name: item.filters!.name, + udi: item.filters!.udi, + hospital: item.filters!.hospital, + size: item.filters!.size, + specific: '', + ) + : Container(), + ], + ), + ); + }, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'item', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + Provider.of(context, listen: false) + .search(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, itemResults, _) { + return itemResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + // remove extra , + return ItemItemBox( + deviceBlockSize: _deviceBlockSize, + item: itemResults.items?[index], + ); + }, + itemCount: itemResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} + +class ItemResultFloatingButton extends StatelessWidget { + const ItemResultFloatingButton({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.itemScanScreen); + }, + child: Container( + padding: EdgeInsets.all(2.5 * _deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed(Routes.itemAddScreen); + }, + child: Container( + padding: EdgeInsets.all(_deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kBlue, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/ItemPages/item_scan_screen.dart b/lib/pages/ItemPages/item_scan_screen.dart new file mode 100644 index 0000000..09e86b9 --- /dev/null +++ b/lib/pages/ItemPages/item_scan_screen.dart @@ -0,0 +1,195 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ItemScanScreen extends StatefulWidget { + @override + State createState() { + return _ItemScanScreenState(); + } +} + +class _ItemScanScreenState extends State { + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Item?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, + ), + ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Item Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + textAlign: TextAlign.center, + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Item/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; + } + return null; + }, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Item ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, + ), + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Item/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kBlue, kBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/ItemPages/item_update_screen.dart b/lib/pages/ItemPages/item_update_screen.dart new file mode 100644 index 0000000..0c59ec0 --- /dev/null +++ b/lib/pages/ItemPages/item_update_screen.dart @@ -0,0 +1,316 @@ +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/ItemScreens/Add/item_update_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ItemUpdateScreen extends StatefulWidget { + @override + _ItemUpdateScreenState createState() => _ItemUpdateScreenState(); +} + +class _ItemUpdateScreenState extends State { + final _itemSizeFocusNode = FocusNode(); + final _itemSpecificFocusNode = FocusNode(); + final _itemUdiFocusNode = FocusNode(); + final _descriptionFocusNode = FocusNode(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController specificCTRL = new TextEditingController(); + TextEditingController sizeCTRL = new TextEditingController(); + TextEditingController dateCTRL = new TextEditingController(); + + final _form = GlobalKey(); + + bool isEmpty = false; + bool isInit = true; + ItemDetailObject? datas; + + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showItemResult(_id.toString()) + .then( + (result) { + setState( + () { + datas = result; + nameCTRL.text = datas!.name; + udiCTRL.text = datas!.udi; + descriptionCTRL.text = datas!.description; + sizeCTRL.text = datas!.size; + specificCTRL.text = datas!.specific; + }, + ); + }, + ); + await Provider.of(context, listen: false) + .getItemResults() + .then( + (result) { + setState( + () { + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.itemResultScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + backgroundColor: Colors.black, + title: Text('Items'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.itemResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(color: Colors.black), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Update a Item', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon(FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Item Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Size required!'; + } + return null; + }, + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Size', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + controller: specificCTRL, + validator: (val) { + if (val!.isEmpty) { + return 'Specific required!'; + } + return null; + }, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Specific', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + focusNode: _itemSpecificFocusNode, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + controller: udiCTRL, + validator: (val) { + if (val!.isEmpty) { + return 'UDI required!'; + } + return null; + }, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'UDI', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + focusNode: _itemUdiFocusNode, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + ItemUpdateButton( + form: _form, + id: datas!.id, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + deviceBlockSize: _deviceBlockSize, + descriptionCTRL: descriptionCTRL, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/LabelPages/label_add_screen.dart b/lib/pages/LabelPages/label_add_screen.dart new file mode 100644 index 0000000..64bb010 --- /dev/null +++ b/lib/pages/LabelPages/label_add_screen.dart @@ -0,0 +1,353 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:cssd/widgets/LabelScreens/Add/add_package_box.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/labels.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Add/date_picker.dart'; +import '../../widgets/LabelScreens/Add/save_button.dart'; + +class LabelAddScreen extends StatefulWidget { + @override + _LabelAddScreenState createState() => _LabelAddScreenState(); +} + +class _LabelAddScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + TextEditingController lotNumberCTRL = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController sDateCTRL = new TextEditingController(); + TextEditingController eDateCTRL = new TextEditingController(); + TextEditingController packageCTRL = new TextEditingController(); + + DateTime? dateTimeS; + + final _form = GlobalKey(); + + List> packageVals = []; + List packageValue = []; + bool isInit = true; + + List labelsCTRL = [TextEditingController()]; + int curLabelVal = 1; + @override + void initState() { + sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var labelProviderObject = Provider.of(context); + labelProviderObject.resetPackageVals(); + labelProviderObject.getPackageFilters().then( + (result) { + setState( + () { + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.labelResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add a Label', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + onChanged: (val) { + setState(() { + lotNumberCTRL.text = val + + ' - ' + + cycleNumberCTRL.text; + }); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons + .sortNumericDown, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: + EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: + TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + TextFormField( + onChanged: (val) { + setState( + () { + lotNumberCTRL.text = + striizerIdCTRL.text + ' - ' + val; + }, + ); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + ), + SizedBox( + height: 20, + ), + TextFormField( + readOnly: true, + controller: lotNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Lot Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + ), + SizedBox( + height: 20, + ), + Container( + margin: EdgeInsets.symmetric(vertical: 10), + child: Text( + 'Packages included', + style: TextStyle( + color: kLightBlue, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, labelProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => + AddPackageBox( + text: 'Package ID', + iconColor: kLightBlueSub, + deviceBlockSize: _deviceBlockSize, + values: + labelProvider.packageValues[index], + vals: labelProvider.packageVals, + initialLabelValue: + labelProvider.initialPackageValue, + index: index, + ), + itemCount: + labelProvider.packageValues.length, + ), + ), + SizedBox( + height: 10, + ), + LabelAddDatePicker( + dateCTRL: sDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Sterile Date', + ), + SizedBox( + height: 20, + ), + LabelAddDatePicker( + dateCTRL: eDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Expire Date', + ), + SizedBox( + height: 70, + ), + LabelAddSaveButton( + form: _form, + lotNumberCTRL: lotNumberCTRL, + cycleNumberCTRL: cycleNumberCTRL, + sDateCTRL: sDateCTRL, + packageValue: packageValue, + eDateCTRL: eDateCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/label_detail_screen.dart b/lib/pages/LabelPages/label_detail_screen.dart similarity index 75% rename from lib/pages/label_detail_screen.dart rename to lib/pages/LabelPages/label_detail_screen.dart index fdc09a1..751cf2f 100644 --- a/lib/pages/label_detail_screen.dart +++ b/lib/pages/LabelPages/label_detail_screen.dart @@ -1,85 +1,88 @@ -import '../models/label_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/labels.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/LabelScreens/Detail/datas_box.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class LabelDetailScreen extends StatefulWidget { - // static const route = '/LabelDetailScreen'; - // final String testResultId; - - // LabelDetailScreen({this.testResultId}); - - @override - _LabelDetailScreenState createState() => _LabelDetailScreenState(); -} - -class _LabelDetailScreenState extends State { - bool isEmpty = false; - bool isInit = true; - LabelDetailsObject datas; - @override - void didChangeDependencies() async { - if (isInit) { - var _id = ModalRoute.of(context).settings.arguments; - await Provider.of(context, listen: false) - .showLabelResult(_id.toString()) - .then( - (result) { - setState( - () { - if (result.id == 'null') { - isEmpty = true; - } - datas = result; - isInit = false; - }, - ); - }, - ); - // print(datas); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : isEmpty - ? Center( - child: Text('This Lable doesnt exists!'), - ) - : LabelDetailsDataBox( - datas: datas, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }), - ), - ); - } -} +import '../../models/label_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/labels.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Detail/datas_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class LabelDetailScreen extends StatefulWidget { + // static const route = '/LabelDetailScreen'; + // final String testResultId; + + // LabelDetailScreen({this.testResultId}); + + @override + _LabelDetailScreenState createState() => _LabelDetailScreenState(); +} + +class _LabelDetailScreenState extends State { + bool isEmpty = false; + bool isInit = true; + LabelDetailsObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showLabelResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + // print(datas); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Label dos\'nt exists!'), + ) + : LabelDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }), + ), + ); + } +} diff --git a/lib/pages/LabelPages/label_filter_screen.dart b/lib/pages/LabelPages/label_filter_screen.dart new file mode 100644 index 0000000..8f187bb --- /dev/null +++ b/lib/pages/LabelPages/label_filter_screen.dart @@ -0,0 +1,332 @@ +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/label_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/labels.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Filter/save_button.dart'; +import '../../widgets/LabelScreens/Filter/selector_box.dart'; + +class LabelFilterScreen extends StatefulWidget { + @override + _LabelFilterScreenState createState() => _LabelFilterScreenState(); +} + +class _LabelFilterScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + final _strilizerIdFocusNode = FocusNode(); + + TextEditingController labelIdCTRl = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + + TextEditingController dateCTRL = new TextEditingController(); + DateTime? dateTimeFrom; + + List> hospitalVals = []; + bool isInit = true; + LabelFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + labelIdCTRl.text = filters!.id; + cycleNumberCTRL.text = filters!.cycleNumber; + striizerIdCTRL.text = filters!.sterilizerId; + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + await Provider.of(context, listen: false) + .getHospitalsFilters() + .then( + (result) { + setState( + () { + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } + // hospitalVals = result; + filters!.hospital == '' + ? hospitalCTRL.text = hospitalVals[0]['name']! + : hospitalVals.forEach( + //id convert to name + (hospital) { + if (hospital['id'] == filters!.hospital) + hospitalCTRL.text = hospital['name']!; + }, + ); + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.labelResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Labels', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: labelIdCTRl, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Label ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + labelIdCTRl.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_strilizerIdFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Strilizer ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + keyboardType: + TextInputType.visiblePassword, + focusNode: _strilizerIdFocusNode, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + LabelFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + ), + SizedBox( + height: 70, + ), + LabelFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + labelIdCTRl: labelIdCTRl, + cycleNumberCTRL: cycleNumberCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 50, + ), + // DropDownBox(values: ['Washer ID']), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/LabelPages/label_result_screen.dart b/lib/pages/LabelPages/label_result_screen.dart new file mode 100644 index 0000000..536f9de --- /dev/null +++ b/lib/pages/LabelPages/label_result_screen.dart @@ -0,0 +1,195 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/labels.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/Global/page_header.dart'; +import '../../widgets/LabelScreens/Result/data_box.dart'; +import '../../widgets/LabelScreens/Result/filter_chip_box.dart'; +import '../../widgets/LabelScreens/Result/floating_buttons.dart'; +import '../../widgets/LabelScreens/Result/search_box.dart'; + +class LabelResultScreen extends StatefulWidget { + // static const route = '/LabelResultScreen'; + final bool? isAdmin; + + LabelResultScreen({this.isAdmin}); + + @override + _LabelResultScreenState createState() => _LabelResultScreenState(); +} + +class _LabelResultScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.setLoading(); + labelProviderObject.resetPageNumber(); + labelProviderObject.getLabelResults().then((_) { + labelProviderObject.resetLoading(); + sc!.addListener(() { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.getLabelResults(); + } + }); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + floatingActionButton: + LabelFloatingButtons(deviceBlockSize: _deviceBlockSize), + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, right: 20, bottom: 60, left: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + PageHeader( + deviceBlockSize: _deviceBlockSize, + label: 'Labels', + route: Routes.labelFilterScreen, + ), + Consumer( + builder: (context, label, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + label.filters.id != '' + ? LabelFilterChip( + deviceBlockSize: _deviceBlockSize, + id: '', + cycleNumber: + label.filters.cycleNumber, + sterilizerId: + label.filters.sterilizerId, + hospital: label.filters.hospital, + label: 'ID', + ) + : Container(), + label.filters.cycleNumber != '' + ? LabelFilterChip( + deviceBlockSize: _deviceBlockSize, + id: label.filters.id, + cycleNumber: '', + sterilizerId: + label.filters.sterilizerId, + hospital: label.filters.hospital, + label: 'Cycle Number', + ) + : Container(), + label.filters.sterilizerId != '' + ? LabelFilterChip( + deviceBlockSize: _deviceBlockSize, + id: label.filters.id, + cycleNumber: + label.filters.cycleNumber, + sterilizerId: '', + hospital: label.filters.hospital, + label: 'Sterilizer ID', + ) + : Container(), + label.filters.hospital != '' + ? LabelFilterChip( + deviceBlockSize: _deviceBlockSize, + id: label.filters.id, + cycleNumber: + label.filters.cycleNumber, + sterilizerId: + label.filters.sterilizerId, + hospital: '', + label: 'Hospital', + ) + : Container(), + ], + ), + ); + }, + ), + LabelSearchBox( + searchCTRL: searchCTRL, + deviceBlockSize: _deviceBlockSize), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, labelResults, _) { + return labelResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) => + LabelItemBox( + deviceBlockSize: _deviceBlockSize, + item: labelResults.items?[index], + ), + itemCount: labelResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/LabelPages/label_scan_screen.dart b/lib/pages/LabelPages/label_scan_screen.dart new file mode 100644 index 0000000..69a7cc6 --- /dev/null +++ b/lib/pages/LabelPages/label_scan_screen.dart @@ -0,0 +1,96 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Scan/input_box.dart'; +import '../../widgets/LabelScreens/Scan/save_button.dart'; +import '../../widgets/LabelScreens/Scan/scan_box.dart'; +// import 'package:flutter/services.dart'; +// import 'package:barcode_scan2/barcode_scan2.dart'; + +class LabelScanScreen extends StatefulWidget { + // static const route = '/LabelScanScreen'; + @override + State createState() { + return _LabelScanScreenState(); + } +} + +class _LabelScanScreenState extends State { + String testCode = ""; + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Label?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, + ), + ), + ), + LabelScanBox(), + SizedBox( + height: 10, + ), + Form( + key: _form, + child: LabelScanInputBox( + idCTRL: idCTRL, + deviceBlockSize: _deviceBlockSize, + ), + ), + SizedBox( + height: 70, + ), + FilterScanSaveButton( + form: _form, + idCTRL: idCTRL, + deviceBlockSize: _deviceBlockSize, + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/LabelPages/label_update_screen.dart b/lib/pages/LabelPages/label_update_screen.dart new file mode 100644 index 0000000..9541141 --- /dev/null +++ b/lib/pages/LabelPages/label_update_screen.dart @@ -0,0 +1,309 @@ +import 'package:cssd/widgets/LabelScreens/Add/selector_box.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/label_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/labels.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/LabelScreens/Add/date_picker.dart'; +import '../../widgets/LabelScreens/Add/update_button.dart'; + +class LabelUpdateScreen extends StatefulWidget { + // static const route = '/LabelUpdateScreen'; + + @override + _LabelUpdateScreenState createState() => _LabelUpdateScreenState(); +} + +class _LabelUpdateScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + final _lotNumberFocusNode = FocusNode(); + TextEditingController lotNumberCTRL = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController sDateCTRL = new TextEditingController(); + TextEditingController eDateCTRL = new TextEditingController(); + TextEditingController packageCTRL = new TextEditingController(); + + DateTime? dateTimeS; + // String sDateValue; + // String eDateValue; + + final _form = GlobalKey(); + + List> packageVals = []; + List packageValue = []; + bool isEmpty = false; + bool isInit = true; + LabelDetailsObject? datas; + + @override + void initState() { + sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showLabelResult(_id.toString()) + .then( + (result) { + setState( + () { + // if (result.id == 'null') { + // isEmpty = true; + // } + datas = result; + lotNumberCTRL.text = datas!.lotNumber; + cycleNumberCTRL.text = datas!.cycleNumber; + striizerIdCTRL.text = datas!.sterileId; + sDateCTRL.text = datas!.sterileDate; + eDateCTRL.text = datas!.expireDate; + packageValue.add(datas!.packageId); + packageValue.add(datas!.package); + packageCTRL.text = datas!.package; + }, + ); + }, + ); + await Provider.of(context, listen: false) + .getPackageFilters() + .then( + (result) { + setState( + () { + // packageVals = result.map((value) => {"name": value}).toList(); + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.labelResultScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + backgroundColor: Colors.black, + title: Text('Labels'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(color: Colors.black), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Update a Label', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + onChanged: (val) { + setState(() { + lotNumberCTRL.text = + val + ' - ' + cycleNumberCTRL.text; + }); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon(FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_cycleNumberFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + onChanged: (val) { + setState( + () { + lotNumberCTRL.text = + striizerIdCTRL.text + ' - ' + val; + }, + ); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_lotNumberFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + readOnly: true, + controller: lotNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Lot Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + focusNode: _lotNumberFocusNode, + ), + SizedBox( + height: 20, + ), + LabelAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + packageCTRL: packageCTRL, + packageVals: packageVals, + packageValue: packageValue, + ), + SizedBox( + height: 20, + ), + LabelAddDatePicker( + dateCTRL: sDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Sterile Date', + ), + SizedBox( + height: 20, + ), + LabelAddDatePicker( + dateCTRL: eDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Expire Date', + ), + SizedBox( + height: 70, + ), + LabelUpdateButton( + form: _form, + id: datas!.id, + lotNumberCTRL: lotNumberCTRL, + cycleNumberCTRL: cycleNumberCTRL, + sDateCTRL: sDateCTRL, + packageValue: packageValue, + eDateCTRL: eDateCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/forget_pass_screen.dart b/lib/pages/LoginRegisterPages/forget_pass_screen.dart similarity index 83% rename from lib/pages/forget_pass_screen.dart rename to lib/pages/LoginRegisterPages/forget_pass_screen.dart index 2ba5bce..d1b7944 100644 --- a/lib/pages/forget_pass_screen.dart +++ b/lib/pages/LoginRegisterPages/forget_pass_screen.dart @@ -1,198 +1,196 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/auth.dart'; -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class ForgetPassScreen extends StatefulWidget { - // static const route = '/HomeScreen'; - - @override - State createState() { - return _ForgetPassScreenState(); - } -} - -class _ForgetPassScreenState extends State { - final _form = GlobalKey(); - bool _isLoading = false; - final cellNumberController = TextEditingController(); - - @override - void initState() { - cellNumberController.text = ''; - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - void _showDialog(String message) { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Error'), - content: Text(message), - actions: [ - TextButton( - child: Text('Ok'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ); - } - - void _requestCode() async { - if (!_form.currentState.validate()) { - return; - } - _form.currentState.save(); - setState(() { - _isLoading = true; - }); - // try { - await Provider.of(context, listen: false) - .requestCode( - cellNumberController.text, - ) - .then( - (result) { - if (result == 'NotUser') { - _showDialog('User Not Found!!!'); - setState( - () { - _isLoading = false; - }, - ); - } else { - // _showDialog('User or password incorrect!'); - Navigator.of(context).popAndPushNamed(Routes.sendCodeScreen); - // setState( - // () { - // _isLoading = false; - // }, - // ); - } - }, - ); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('CSSD'), - ), - body: Selector( - builder: (ctx, value, _) => value != 'offline' - ? _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 20), - child: Text( - 'FORGET PASSWORD', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), - ), - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Cell number is required.'; - } - RegExp regExp = - RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); - if (!regExp.hasMatch(value)) { - return 'Enter a valid cell number'; - } - return null; - }, - controller: cellNumberController, - decoration: InputDecoration( - icon: Icon( - Icons.call, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cell Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.phone, - textInputAction: TextInputAction.next, - onSaved: (value) { - cellNumberController.text = value; - }, - ), - SizedBox(height: 40), - Row( - children: [ - InkWell( - onTap: () => _requestCode(), - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Text( - 'Request Code', - style: TextStyle(color: Colors.white), - ), - ), - ), - Spacer(), - ], - ), - SizedBox(height: 10), - ], - ), - ) - : ConnectionErrorBox(), - selector: (_, connectivity) => connectivity.conStatus, - ), - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/auth.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class ForgetPassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _ForgetPassScreenState(); + } +} + +class _ForgetPassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + final cellNumberController = TextEditingController(); + + @override + void initState() { + cellNumberController.text = ''; + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void _showDialog(String message) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Error'), + content: Text(message), + actions: [ + TextButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _requestCode() async { + if (!_form.currentState!.validate()) { + return; + } + _form.currentState!.save(); + setState(() { + _isLoading = true; + }); + // try { + await Provider.of(context, listen: false) + .requestCode( + cellNumberController.text, + ) + .then( + (result) { + if (result == 'NotUser') { + _showDialog('User Not Found!!!'); + setState( + () { + _isLoading = false; + }, + ); + } else { + // _showDialog('User or password incorrect!'); + Navigator.of(context).popAndPushNamed(Routes.sendCodeScreen); + // setState( + // () { + // _isLoading = false; + // }, + // ); + } + }, + ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + backgroundColor: Colors.black, + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'Forget Password', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Cell number is required.'; + } + RegExp regExp = + RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); + if (!regExp.hasMatch(value)) { + return 'Enter a valid cell number'; + } + return null; + }, + controller: cellNumberController, + decoration: InputDecoration( + icon: Icon( + Icons.call, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cell Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.phone, + textInputAction: TextInputAction.next, + onSaved: (value) { + cellNumberController.text = value!; + }, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _requestCode(), + child: Container( + width: 88 * _deviceBlockSize, + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Center( + child: Text( + 'Request Code', + style: TextStyle(color: Colors.white), + ), + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + ), + ), + ); + } +} diff --git a/lib/pages/LoginRegisterPages/login_screen.dart b/lib/pages/LoginRegisterPages/login_screen.dart new file mode 100644 index 0000000..b315034 --- /dev/null +++ b/lib/pages/LoginRegisterPages/login_screen.dart @@ -0,0 +1,289 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/auth.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class LoginScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _LoginScreenState(); + } +} + +class _LoginScreenState extends State { + final _passwordFocusNode = FocusNode(); + final _form = GlobalKey(); + bool _isLoading = false; + final cellNumberController = TextEditingController(); + final passwordController = TextEditingController(); + + bool _hidePass = true; + Map map = Map(); + + @override + void initState() { + if (map['cellNumber'] != null) { + cellNumberController.text = map['cellNumber']; + } + super.initState(); + } + + @override + void dispose() { + _passwordFocusNode.dispose(); + super.dispose(); + } + + void _showDialog(String message) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Error'), + content: Text(message), + actions: [ + TextButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _login() async { + if (!_form.currentState!.validate()) { + return; + } + _form.currentState!.save(); + setState(() { + _isLoading = true; + }); + await Provider.of(context, listen: false) + .login( + map['cellNumber'], + map['password'], + ) + .then( + (result) { + if (result == 'error') { + _showDialog('Something went wrong!'); + setState( + () { + _isLoading = false; + }, + ); + } else if (result == 'badinput') { + _showDialog('User or password incorrect!'); + setState( + () { + _isLoading = false; + }, + ); + } + }, + ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + backgroundColor: Colors.black, + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'Login', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Call number is required.'; + } + RegExp regExp = + RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); + if (!regExp.hasMatch(value)) { + return 'Enter a valid cell number'; + } + return null; + }, + controller: cellNumberController, + decoration: InputDecoration( + icon: Icon( + Icons.call, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Call Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.phone, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_passwordFocusNode); + }, + onSaved: (value) { + map['cellNumber'] = value; + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Password is required.'; + } + if (value.length < 8) { + return 'Password at least is 8 characters.'; + } + return null; + }, + obscureText: _hidePass, + controller: passwordController, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Password', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hidePass = !_hidePass; + }); + }, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _login(); + }, + keyboardType: TextInputType.visiblePassword, + focusNode: _passwordFocusNode, + onSaved: (value) { + map['password'] = value; + }, + ), + SizedBox(height: 40), + InkWell( + onTap: () => _login(), + child: Container( + width: _devicewidth, + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.exit_to_app, + color: Colors.white, + ), + SizedBox( + width: 5.0, + ), + Text( + 'Login', + style: TextStyle( + color: Colors.white, + ), + ), + ], + ), + ), + ), + SizedBox(height: 10), + TextButton( + child: Align( + alignment: Alignment.center, + child: Text( + 'Forgot Password ?', + style: TextStyle( + color: Colors.black54, + decoration: TextDecoration.underline, + ), + ), + ), + onPressed: () => Navigator.of(context) + .pushNamed(Routes.forgetPassScreen), + ), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + )), + ), + ); + } +} diff --git a/lib/pages/rePass_screen.dart b/lib/pages/LoginRegisterPages/rePass_screen.dart similarity index 89% rename from lib/pages/rePass_screen.dart rename to lib/pages/LoginRegisterPages/rePass_screen.dart index f4f1c8d..3415819 100644 --- a/lib/pages/rePass_screen.dart +++ b/lib/pages/LoginRegisterPages/rePass_screen.dart @@ -1,243 +1,239 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../providers/auth.dart'; -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class RePassScreen extends StatefulWidget { - // static const route = '/HomeScreen'; - - @override - State createState() { - return _RePassScreenState(); - } -} - -class _RePassScreenState extends State { - final _form = GlobalKey(); - bool _isLoading = false; - // final cellNumberController = TextEditingController(); - final passwordController = new TextEditingController(); - final rePasswordController = new TextEditingController(); - String token = 'Bearer '; - // String token = 'Bearer '; - - bool _hidePass = true; - bool _hideRePass = true; - bool isInit = true; - - @override - void didChangeDependencies() { - if (isInit) { - token += ModalRoute.of(context).settings.arguments; - isInit = false; - } - super.didChangeDependencies(); - } - - Future _showDialog(String message) async { - await showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text(message), - actions: [ - TextButton( - child: Text('Ok'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ); - } - - void _sendRePass() async { - if (!_form.currentState.validate()) { - return; - } - _form.currentState.save(); - setState(() { - _isLoading = true; - }); - await Provider.of(context, listen: false) - .sendRePass(passwordController.text, token) - .then((value) async { - if (value == 'done') { - await _showDialog( - 'Password changed successfully.Now login to your account.'); - Navigator.of(context).pop(); - } - }); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('CSSD'), - ), - body: Selector( - builder: (ctx, value, _) => value != 'offline' - ? _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 20), - child: Text( - 'CHANGE PASSWORD', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), - ), - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Password is required.'; - } - if (value.length < 8) { - return 'Password at least is 8 characters.'; - } - return null; - }, - obscureText: _hidePass, - controller: passwordController, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.starOfLife, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Password', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - suffixIcon: InkWell( - child: Icon(FontAwesomeIcons.eye), - onTap: () { - setState(() { - _hidePass = !_hidePass; - }); - }, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - textInputAction: TextInputAction.done, - onFieldSubmitted: (_) { - _sendRePass(); - }, - keyboardType: TextInputType.visiblePassword, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (value) { - if (value.length < 8) { - return 'Password at least is 8 characters.'; - } - if (value != passwordController.text) { - return 'Password doesnt match!'; - } - return null; - }, - obscureText: _hideRePass, - controller: rePasswordController, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.starOfLife, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Confirm Password', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - suffixIcon: InkWell( - child: Icon(FontAwesomeIcons.eye), - onTap: () { - setState(() { - _hideRePass = !_hideRePass; - }); - }, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - textInputAction: TextInputAction.done, - onFieldSubmitted: (_) { - _sendRePass(); - }, - keyboardType: TextInputType.visiblePassword, - ), - SizedBox(height: 40), - Row( - children: [ - InkWell( - onTap: () => _sendRePass(), - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Text( - 'Change', - style: TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, - ), - ), - ), - Spacer(), - ], - ), - SizedBox(height: 10), - ], - ), - ) - : ConnectionErrorBox(), - selector: (_, connectivity) => connectivity.conStatus, - )), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/auth.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class RePassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _RePassScreenState(); + } +} + +class _RePassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + // final cellNumberController = TextEditingController(); + final passwordController = new TextEditingController(); + final rePasswordController = new TextEditingController(); + String token = 'Bearer '; + // String token = 'Bearer '; + + bool _hidePass = true; + bool _hideRePass = true; + bool isInit = true; + + @override + void didChangeDependencies() { + if (isInit) { + token += ModalRoute.of(context)!.settings.arguments.toString(); + isInit = false; + } + super.didChangeDependencies(); + } + + Future _showDialog(String message) async { + await showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text(message), + actions: [ + TextButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _sendRePass() async { + if (!_form.currentState!.validate()) { + return; + } + _form.currentState!.save(); + setState(() { + _isLoading = true; + }); + await Provider.of(context, listen: false) + .sendRePass(passwordController.text, token) + .then((value) async { + if (value == 'done') { + await _showDialog( + 'Password changed successfully.Now login to your account.'); + Navigator.of(context).pop(); + } + }); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + backgroundColor: Colors.black, + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'CHANGE PASSWORD', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Password is required.'; + } + if (value.length < 8) { + return 'Password at least is 8 characters.'; + } + return null; + }, + obscureText: _hidePass, + controller: passwordController, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Password', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hidePass = !_hidePass; + }); + }, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _sendRePass(); + }, + keyboardType: TextInputType.visiblePassword, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (value) { + if (value!.length < 8) { + return 'Password at least is 8 characters.'; + } + if (value != passwordController.text) { + return 'Password doesnt match!'; + } + return null; + }, + obscureText: _hideRePass, + controller: rePasswordController, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Confirm Password', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hideRePass = !_hideRePass; + }); + }, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _sendRePass(); + }, + keyboardType: TextInputType.visiblePassword, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _sendRePass(), + child: Container( + width: 88 * _deviceBlockSize, + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Text( + 'Change', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + )), + ); + } +} diff --git a/lib/pages/register.dart b/lib/pages/LoginRegisterPages/register.dart similarity index 94% rename from lib/pages/register.dart rename to lib/pages/LoginRegisterPages/register.dart index 1490ac9..ffbb792 100644 --- a/lib/pages/register.dart +++ b/lib/pages/LoginRegisterPages/register.dart @@ -1,379 +1,381 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class Register extends StatefulWidget { - // static const route = '/RegisterScreen'; - - @override - State createState() { - return _RegisterState(); - } -} - -class _RegisterState extends State { - final _passwordFocusNode = FocusNode(); - final _form = GlobalKey(); - bool _isLoading = false; - final cellNumberController = TextEditingController(); - bool _hidePass = true; - Map map = Map(); - final List hospitalVals = ['Shahid Beheshti', 'None']; - String curhospitalVal; - @override - void initState() { - cellNumberController.text = map['cellNumber']; - curhospitalVal = hospitalVals[0]; - super.initState(); - } - - @override - void dispose() { - _passwordFocusNode.dispose(); - super.dispose(); - } - - // void _showDialog(String message) { - // showDialog( - // context: context, - // builder: (ctx) => AlertDialog( - // title: Text('error occured'), - // content: Text(message), - // actions: [ - // TextButton( - // child: Text('Ok'), - // onPressed: () { - // Navigator.of(ctx).pop(); - // }, - // ), - // ], - // ), - // ); - // } - - void _register() async { - if (!_form.currentState.validate()) { - return; - } - _form.currentState.save(); - // setState(() { - // _isLoading = true; - // }); - // try { - // // await Provider.of(context).register( - // // map['cellNumber'], - // // map['password'], - // // ); - // } catch (error) { - // _showDialog('something went wrong!'); - // setState(() { - // _isLoading = false; - // }); - // } - - // Navigator.pushReplacement( - // context, - // MaterialPageRoute(builder: (context) { - // return HomePage(); - // }), - // ); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Login'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 20), - child: Text( - 'register', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 7 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Cell number is required.'; - } - RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); - if (!regExp.hasMatch(value)) { - return 'Enter a valid cell number'; - } - return null; - }, - style: TextStyle(fontWeight: FontWeight.w700), - keyboardType: TextInputType.phone, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus(_passwordFocusNode); - }, - controller: cellNumberController, - decoration: InputDecoration( - isDense: true, - icon: Icon( - Icons.call, - color: Colors.grey, - ), - border: UnderlineInputBorder(), - fillColor: Colors.red, - labelText: 'Cell Number', - contentPadding: EdgeInsets.symmetric(vertical: 5), - ), - onSaved: (value) { - map['cellNumber'] = value; - }, - ), - SizedBox( - height: 10, - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Password is required.'; - } - if (value.length < 8) { - return 'Password at least is 8 characters.'; - } - return null; - }, - obscureText: _hidePass, - textInputAction: TextInputAction.done, - onFieldSubmitted: (_) { - _register(); - }, - style: TextStyle(fontWeight: FontWeight.w700), - decoration: InputDecoration( - isDense: true, - icon: Icon( - FontAwesomeIcons.starOfLife, - color: Colors.grey, - ), - border: UnderlineInputBorder(), - fillColor: Colors.red, - labelText: 'Password', - contentPadding: EdgeInsets.symmetric(vertical: 5), - suffixIcon: InkWell( - child: Icon(FontAwesomeIcons.eye), - onTap: () { - setState(() { - _hidePass = !_hidePass; - }); - }, - ), - ), - focusNode: _passwordFocusNode, - onSaved: (value) { - map['password'] = value; - }, - ), - SizedBox( - height: 10, - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Full Name is required.'; - } - // RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); - // if (!regExp.hasMatch(value)) { - // return 'Enter a valid cell number'; - // } - return null; - }, - // keyboardType: TextInputType.phone, - // textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context).requestFocus(_passwordFocusNode); - // }, - // controller: cellNumberController, - decoration: InputDecoration( - isDense: true, - icon: Icon( - FontAwesomeIcons.sortNumericDown, - color: Colors.grey, - ), - border: UnderlineInputBorder(), - fillColor: Colors.red, - labelText: 'Full Name', - contentPadding: EdgeInsets.symmetric(vertical: 5), - ), - style: TextStyle(fontWeight: FontWeight.w700), - // onSaved: (value) { - // map['cellNumber'] = value; - // }, - ), - SizedBox( - height: 20, - ), - Row( - // width: double.infinity, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 5 * _deviceBlockSize, - ), - SizedBox( - width: 3 * _deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: DropdownButton( - focusColor: Colors.red, - icon: Icon(FontAwesomeIcons.angleDown), - isExpanded: true, - hint: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Text( - curhospitalVal, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - // color: _mainFontColor, - // fontSize: 5 * _deviceBlockSize, - ), - ), - ), - isDense: true, - items: hospitalVals.map((String value) { - return new DropdownMenuItem( - value: value, - child: Container( - child: Text( - value, - style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * _deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - curhospitalVal = val; - }); - }, - ), - ), - ], - ), - SizedBox(height: 40), - Row( - children: [ - InkWell( - onTap: () => _register(), - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 5, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Spacer(), - Icon( - Icons.add, - color: Colors.white, - ), - Text( - 'register', - style: TextStyle(color: Colors.white), - ), - Spacer() - ], - ) - // TextButton.icon( - // padding: EdgeInsets.all(0), - // onPressed: () { - // _register(); - // }, - // icon: Icon(Icons.exit_to_app, - // color: Colors.white, size: 17), - // label: Text('register', - // style: TextStyle(color: Colors.white)), - // ), - ), - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 5, - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - border: Border.all( - color: Colors.black, - ), - ), - child: Row( - children: [ - Spacer(), - Icon( - Icons.exit_to_app, - // size: 6 * _pixelRatio, - ), - Text( - 'Login', - style: TextStyle( - // fontSize: 5.5, - ), - ), - Spacer(), - ], - ), - ), - ), - ], - ), - ], - ), - ), - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class Register extends StatefulWidget { + // static const route = '/RegisterScreen'; + + @override + State createState() { + return _RegisterState(); + } +} + +class _RegisterState extends State { + final _passwordFocusNode = FocusNode(); + final _form = GlobalKey(); + bool _isLoading = false; + final cellNumberController = TextEditingController(); + bool _hidePass = true; + Map map = Map(); + final List hospitalVals = ['Shahid Beheshti', 'None']; + String? curhospitalVal; + @override + void initState() { + cellNumberController.text = map['cellNumber']; + curhospitalVal = hospitalVals[0]; + super.initState(); + } + + @override + void dispose() { + _passwordFocusNode.dispose(); + super.dispose(); + } + + // void _showDialog(String message) { + // showDialog( + // context: context, + // builder: (ctx) => AlertDialog( + // title: Text('error occured'), + // content: Text(message), + // actions: [ + // TextButton( + // child: Text('Ok'), + // onPressed: () { + // Navigator.of(ctx).pop(); + // }, + // ), + // ], + // ), + // ); + // } + + void _register() async { + if (!_form.currentState!.validate()) { + return; + } + _form.currentState!.save(); + // setState(() { + // _isLoading = true; + // }); + // try { + // // await Provider.of(context).register( + // // map['cellNumber'], + // // map['password'], + // // ); + // } catch (error) { + // _showDialog('something went wrong!'); + // setState(() { + // _isLoading = false; + // }); + // } + + // Navigator.pushReplacement( + // context, + // MaterialPageRoute(builder: (context) { + // return HomePage(); + // }), + // ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Login'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'register', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 7 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Cell number is required.'; + } + RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); + if (!regExp.hasMatch(value)) { + return 'Enter a valid cell number'; + } + return null; + }, + style: TextStyle(fontWeight: FontWeight.w700), + keyboardType: TextInputType.phone, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus(_passwordFocusNode); + }, + controller: cellNumberController, + decoration: InputDecoration( + isDense: true, + icon: Icon( + Icons.call, + color: Colors.grey, + ), + border: UnderlineInputBorder(), + fillColor: Colors.red, + labelText: 'Cell Number', + contentPadding: EdgeInsets.symmetric(vertical: 5), + ), + onSaved: (value) { + map['cellNumber'] = value; + }, + ), + SizedBox( + height: 10, + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Password is required.'; + } + if (value.length < 8) { + return 'Password at least is 8 characters.'; + } + return null; + }, + obscureText: _hidePass, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _register(); + }, + style: TextStyle(fontWeight: FontWeight.w700), + decoration: InputDecoration( + isDense: true, + icon: Icon( + FontAwesomeIcons.starOfLife, + color: Colors.grey, + ), + border: UnderlineInputBorder(), + fillColor: Colors.red, + labelText: 'Password', + contentPadding: EdgeInsets.symmetric(vertical: 5), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hidePass = !_hidePass; + }); + }, + ), + ), + focusNode: _passwordFocusNode, + onSaved: (value) { + map['password'] = value; + }, + ), + SizedBox( + height: 10, + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Full Name is required.'; + } + // RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); + // if (!regExp.hasMatch(value)) { + // return 'Enter a valid cell number'; + // } + return null; + }, + // keyboardType: TextInputType.phone, + // textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context).requestFocus(_passwordFocusNode); + // }, + // controller: cellNumberController, + decoration: InputDecoration( + isDense: true, + icon: Icon( + FontAwesomeIcons.sortNumericDown, + color: Colors.grey, + ), + border: UnderlineInputBorder(), + fillColor: Colors.red, + labelText: 'Full Name', + contentPadding: EdgeInsets.symmetric(vertical: 5), + ), + style: TextStyle(fontWeight: FontWeight.w700), + // onSaved: (value) { + // map['cellNumber'] = value; + // }, + ), + SizedBox( + height: 20, + ), + Row( + // width: double.infinity, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 5 * _deviceBlockSize, + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: DropdownButton( + focusColor: Colors.red, + icon: Icon(FontAwesomeIcons.angleDown), + isExpanded: true, + hint: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Text( + curhospitalVal!, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + // color: _mainFontColor, + // fontSize: 5 * _deviceBlockSize, + ), + ), + ), + isDense: true, + items: hospitalVals.map((String value) { + return new DropdownMenuItem( + value: value, + child: Container( + child: Text( + value, + style: TextStyle( + // color: _mainFontColor, + fontSize: 4 * _deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState(() { + curhospitalVal = val; + }); + }, + ), + ), + ], + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _register(), + child: Container( + width: 40 * _deviceBlockSize, + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 5, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Spacer(), + Icon( + Icons.add, + color: Colors.white, + ), + Text( + 'register', + style: TextStyle(color: Colors.white), + ), + Spacer() + ], + ) + // TextButton.icon( + // padding: EdgeInsets.all(0), + // onPressed: () { + // _register(); + // }, + // icon: Icon(Icons.exit_to_app, + // color: Colors.white, size: 17), + // label: Text('register', + // style: TextStyle(color: Colors.white)), + // ), + ), + ), + Spacer(), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + width: 40 * _deviceBlockSize, + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 5, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: Colors.black, + ), + ), + child: Row( + children: [ + Spacer(), + Icon( + Icons.exit_to_app, + // size: 6 * _pixelRatio, + ), + Text( + 'Login', + style: TextStyle( + // fontSize: 5.5, + ), + ), + Spacer(), + ], + ), + ), + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/verify_pass_screen.dart b/lib/pages/LoginRegisterPages/verify_pass_screen.dart similarity index 87% rename from lib/pages/verify_pass_screen.dart rename to lib/pages/LoginRegisterPages/verify_pass_screen.dart index 5bf8423..deaebe1 100644 --- a/lib/pages/verify_pass_screen.dart +++ b/lib/pages/LoginRegisterPages/verify_pass_screen.dart @@ -1,196 +1,194 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/auth.dart'; -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class VerifyPassScreen extends StatefulWidget { - // static const route = '/HomeScreen'; - - @override - State createState() { - return _VerifyPassScreenState(); - } -} - -class _VerifyPassScreenState extends State { - final _form = GlobalKey(); - bool _isLoading = false; - final codeCTRL = TextEditingController(); - - @override - void initState() { - codeCTRL.text = ''; - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - void _showDialog(String message) { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Error'), - content: Text(message), - actions: [ - TextButton( - child: Text('Ok'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ); - } - - void _sendCode() async { - if (!_form.currentState.validate()) { - return; - } - _form.currentState.save(); - setState(() { - _isLoading = true; - }); - // try { - await Provider.of(context, listen: false) - .sendCode( - codeCTRL.text, - ) - .then( - (result) { - if (result == 'wrong') { - _showDialog('Code is wrong!!!'); - setState( - () { - _isLoading = false; - }, - ); - } else { - Navigator.of(context) - .popAndPushNamed(Routes.rePassScreen, arguments: result); - } - }, - ); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('CSSD'), - ), - body: Selector( - builder: (ctx, value, _) => value != 'offline' - ? _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 20), - child: Text( - 'Send Verification Code', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), - ), - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Code is required.'; - } - if (value.length != 6) { - return 'Code most be 6 characters'; - } - return null; - }, - controller: codeCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.starOfLife, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Code', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - ), - keyboardType: TextInputType.number, - onSaved: (value) { - codeCTRL.text = value; - }, - maxLength: 6, - ), - SizedBox(height: 40), - Row( - children: [ - InkWell( - onTap: () => _sendCode(), - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Text( - 'Send Code', - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), - ), - ), - ), - Spacer(), - ], - ), - SizedBox(height: 10), - ], - ), - ) - : ConnectionErrorBox(), - selector: (_, connectivity) => connectivity.conStatus, - ), - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/auth.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class VerifyPassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _VerifyPassScreenState(); + } +} + +class _VerifyPassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + final codeCTRL = TextEditingController(); + + @override + void initState() { + codeCTRL.text = ''; + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void _showDialog(String message) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Error'), + content: Text(message), + actions: [ + TextButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _sendCode() async { + if (!_form.currentState!.validate()) { + return; + } + _form.currentState!.save(); + setState(() { + _isLoading = true; + }); + // try { + await Provider.of(context, listen: false) + .sendCode( + codeCTRL.text, + ) + .then( + (result) { + if (result == 'wrong') { + _showDialog('Code is wrong!!!'); + setState( + () { + _isLoading = false; + }, + ); + } else { + Navigator.of(context) + .popAndPushNamed(Routes.rePassScreen, arguments: result); + } + }, + ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + backgroundColor: Colors.black, + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'Send Verification Code', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value!.isEmpty) { + return 'Code is required.'; + } + if (value.length != 6) { + return 'Code most be 6 characters'; + } + return null; + }, + controller: codeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Code', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + keyboardType: TextInputType.number, + onSaved: (value) { + codeCTRL.text = value!; + }, + maxLength: 6, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _sendCode(), + child: Container( + width: 88 * _deviceBlockSize, + padding: EdgeInsets.all(10), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Text( + 'Send Code', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white), + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + ), + ), + ); + } +} diff --git a/lib/pages/MyItemsPages/Result/my_items_mine_screen.dart b/lib/pages/MyItemsPages/Result/my_items_mine_screen.dart new file mode 100644 index 0000000..aab3bf2 --- /dev/null +++ b/lib/pages/MyItemsPages/Result/my_items_mine_screen.dart @@ -0,0 +1,257 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:cssd/config/routes.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_history_screen.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/CycleScreens/Result/search_box.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyItemsScreens/Filter/my_items_chip_widget.dart'; +import 'package:cssd/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyItemsMineScreen extends StatefulWidget { + final bool? isAdmin; + const MyItemsMineScreen({ + Key? key, + this.isAdmin, + }) : super(key: key); + + @override + State createState() => _MyItemsMineScreenState(); +} + +class _MyItemsMineScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var myItemResults = Provider.of(context); + final userData = Provider.of(context, listen: false).user; + myItemResults.setLoading(); + myItemResults.resetPageNumber(); + if (userData['roles']?.contains('User')) { + myItemResults.getMyItems().then( + (_) { + myItemResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var myItemResults = Provider.of( + context, + listen: false, + ); + myItemResults.getMyItems(); + } + }, + ); + }, + ); + } else { + myItemResults.getHospitalItems().then((_) { + myItemResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var myItemResults = Provider.of( + context, + listen: false, + ); + myItemResults.getHospitalItems(); + } + }, + ); + }); + } + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + final userData = Provider.of(context, listen: false).user; + return Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'My Items', + push: Routes.myItemsFilterScreen, + ), + Consumer(builder: (ctx, item, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + item.filters!.id != '' + ? MyItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + name: item.filters!.name, + udi: item.filters!.udi, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.name != '' + ? MyItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Item Name', + id: item.filters!.id, + name: '', + udi: item.filters!.udi, + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.udi != '' + ? MyItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'UDI', + id: item.filters!.id, + name: item.filters!.name, + udi: '', + size: item.filters!.size, + specific: item.filters!.specific, + ) + : Container(), + item.filters!.size != '' + ? MyItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Size', + id: item.filters!.id, + name: item.filters!.name, + udi: item.filters!.udi, + size: '', + specific: item.filters!.specific, + ) + : Container(), + item.filters!.specific != '' + ? MyItemFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Specific', + id: item.filters!.id, + name: item.filters!.name, + udi: item.filters!.udi, + size: item.filters!.size, + specific: '', + ) + : Container(), + ], + ), + ); + }), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'item', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + if (userData['roles']?.contains('User')) { + Provider.of(context, listen: false) + .searchMyItems(value); + } else { + Provider.of(context, listen: false) + .searchHospitalItems(value); + } + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, itemResults, _) { + return itemResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + if (userData['roles']?.contains('User')) { + return MyItemsItemDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: false, + items: itemResults.myItems?[index], + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: ((context) => + MyItemsHistoryScreen( + items: itemResults + .myItems?[index], + )), + ), + ); + }, + ); + } else { + return MyItemsItemDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: true, + items: + itemResults.hospitalItems?[index], + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: ((context) => + MyItemsHistoryScreen( + items: itemResults + .myItems?[index], + )), + ), + ); + }, + ); + } + }, + itemCount: userData['roles']?.contains('User') + ? itemResults.myItems?.length + : itemResults.hospitalItems?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ); + } +} diff --git a/lib/pages/MyItemsPages/Result/my_items_requests_screen.dart b/lib/pages/MyItemsPages/Result/my_items_requests_screen.dart new file mode 100644 index 0000000..e56670b --- /dev/null +++ b/lib/pages/MyItemsPages/Result/my_items_requests_screen.dart @@ -0,0 +1,154 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:cssd/config/routes.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyItemsScreens/Result/item_requests_data_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyItemsRequestsScreen extends StatefulWidget { + final bool? isAdmin; + const MyItemsRequestsScreen({ + Key? key, + this.isAdmin, + }) : super(key: key); + + @override + State createState() => _MyItemsRequestsScreenState(); +} + +class _MyItemsRequestsScreenState extends State { + bool _isInit = true; + ScrollController? sc; + + @override + void initState() { + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var itemResults = Provider.of(context); + final userData = Provider.of(context, listen: false).user; + itemResults.setLoading(); + itemResults.resetPageNumber(); + if (userData['roles']?.contains('User')) { + itemResults.getMyItemRequests().then( + (_) { + itemResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var itemResults = Provider.of( + context, + listen: false, + ); + itemResults.getMyItemRequests(); + } + }, + ); + }, + ); + } else { + itemResults.getHospitalItemRequests().then( + (_) { + itemResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var itemResults = Provider.of( + context, + listen: false, + ); + itemResults.getHospitalItemRequests(); + } + }, + ); + }, + ); + } + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + final userData = Provider.of(context, listen: false).user; + return Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'My Requests', + hasFilterObject: false, + push: Routes.myItemsFilterScreen, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, itemResults, _) { + return itemResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + if (userData['roles']?.contains('User')) { + return RequestsDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: false, + item: itemResults + .originalMyItemsRequests?[index], + ); + } else { + return RequestsDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: true, + item: itemResults + .originalHospitalItemsRequests?[ + index], + ); + } + }, + itemCount: userData['roles']?.contains('User') + ? itemResults + .originalMyItemsRequests?.length + : itemResults + .originalHospitalItemsRequests + ?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ); + } +} diff --git a/lib/pages/MyItemsPages/Result/my_items_result_screen.dart b/lib/pages/MyItemsPages/Result/my_items_result_screen.dart new file mode 100644 index 0000000..5e3dcca --- /dev/null +++ b/lib/pages/MyItemsPages/Result/my_items_result_screen.dart @@ -0,0 +1,75 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/pages/MyItemsPages/Result/my_items_mine_screen.dart'; +import 'package:cssd/pages/MyItemsPages/Result/my_items_requests_screen.dart'; +import 'package:flutter/material.dart'; + +class MyItemsResultScreen extends StatefulWidget { + const MyItemsResultScreen({super.key}); + + @override + State createState() => _MyItemsResultScreenState(); +} + +class _MyItemsResultScreenState extends State + with SingleTickerProviderStateMixin { + late final TabController _tabController; + + @override + void initState() { + _tabController = TabController(length: 2, vsync: this); + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: DefaultTabController( + length: 2, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + bottom: TabBar( + controller: _tabController, + indicatorColor: kBlue, + tabs: [ + Tab( + text: 'Mine', + ), + Tab( + text: 'Requests', + ), + ], + ), + ), + body: TabBarView( + controller: _tabController, + children: [ + MyItemsMineScreen(), + MyItemsRequestsScreen(), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/MyItemsPages/my_items_detail_screen.dart b/lib/pages/MyItemsPages/my_items_detail_screen.dart new file mode 100644 index 0000000..6968c30 --- /dev/null +++ b/lib/pages/MyItemsPages/my_items_detail_screen.dart @@ -0,0 +1,101 @@ +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/pages/MyItemsPages/my_items_transfer_screen.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class MyItemsDetailScreen extends StatefulWidget { + final String? testResultId; + + MyItemsDetailScreen({ + this.testResultId, + }); + + @override + _MyItemsDetailScreenState createState() => _MyItemsDetailScreenState(); +} + +class _MyItemsDetailScreenState extends State { + bool isInit = true; + bool isEmpty = false; + ItemDetailObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showItemResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Item does\'nt exists!'), + ) + : MyItemsDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ItemsTransferScreen( + items: datas, + ), + ), + ); + }, + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/MyItemsPages/my_items_filter_screen.dart b/lib/pages/MyItemsPages/my_items_filter_screen.dart new file mode 100644 index 0000000..f101108 --- /dev/null +++ b/lib/pages/MyItemsPages/my_items_filter_screen.dart @@ -0,0 +1,359 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:cssd/widgets/MyItemsScreens/Filter/my_items_filter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class MyItemsFilterScreen extends StatefulWidget { + @override + _MyItemsFilterScreenState createState() => _MyItemsFilterScreenState(); +} + +class _MyItemsFilterScreenState extends State { + final _itemSizeFocusNode = FocusNode(); + final _itemNameFocusNode = FocusNode(); + final _itemUdiFocusNode = FocusNode(); + final _itemSpecificFocusNode = FocusNode(); + TextEditingController idCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController sizeCTRL = new TextEditingController(); + TextEditingController specificCTRL = new TextEditingController(); + + bool isInit = true; + ItemFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + idCTRL.text = filters!.id; + nameCTRL.text = filters!.name; + sizeCTRL.text = filters!.size; + specificCTRL.text = filters!.specific; + super.initState(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.myItemsResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.myItemsResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter My Items', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemNameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemNameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30.0, + ), + TextFormField( + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Size', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Specific', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 90, + ), + MyItemFilterSaveButton( + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + push: Routes.myItemsResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/MyItemsPages/my_items_history_screen.dart b/lib/pages/MyItemsPages/my_items_history_screen.dart new file mode 100644 index 0000000..59089ed --- /dev/null +++ b/lib/pages/MyItemsPages/my_items_history_screen.dart @@ -0,0 +1,168 @@ +import 'package:cssd/models/my_item_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/users.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart'; +import 'package:cssd/widgets/MyItemsScreens/History/my_items_history_date_widget.dart'; +import 'package:cssd/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Result/banner.dart'; +import '../../widgets/Global/internet_error.dart'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyItemsHistoryScreen extends StatefulWidget { + final bool? isAdmin; + final MyItemResultObject? items; + + MyItemsHistoryScreen({this.isAdmin, this.items}); + + @override + _MyItemsHistoryScreenState createState() => _MyItemsHistoryScreenState(); +} + +class _MyItemsHistoryScreenState extends State { + bool _isInit = true; + ScrollController? sc; + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var userResults = Provider.of(context); + userResults.setLoading(); + userResults + .getUsers(userResults.getUserMedicalCenter() as String) + .then((_) { + userResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var userResults = Provider.of( + context, + listen: false, + ); + userResults + .getUsers(userResults.getUserMedicalCenter() as String); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + final userData = Provider.of(context, listen: false).user; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Items'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Item History', + push: Routes.itemFilterScreen, + hasFilterObject: false, + ), + SizedBox( + height: 20, + ), + MyItemsItemDataBox( + deviceBlockSize: _deviceBlockSize, + hasHistoryBtn: false, + items: MyItemsHistoryScreen().items!, + isAdmin: userData['roles']?.contains('User') + ? false + : true, + ), + SizedBox( + height: 10.0, + ), + Divider( + color: Colors.grey, + height: 2.0, + ), + SizedBox( + height: 10.0, + ), + Expanded( + child: Consumer( + builder: (context, userResults, child) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return Column( + children: [ + ItemHistoryDate( + deviceBlockSize: _deviceBlockSize, + items: + MyItemsHistoryScreen().items!, + ), + SizedBox( + height: 20.0, + ), + TransferDataBox( + deviceBlockSize: _deviceBlockSize, + user: + userResults.usersBox?[index], + ), + ], + ); + }, + itemCount: userResults.usersBox?.length, + shrinkWrap: true, + ); + }, + ), + ) + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/MyItemsPages/my_items_transfer_screen.dart b/lib/pages/MyItemsPages/my_items_transfer_screen.dart new file mode 100644 index 0000000..d66dbc2 --- /dev/null +++ b/lib/pages/MyItemsPages/my_items_transfer_screen.dart @@ -0,0 +1,341 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/config/routes.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:cssd/providers/users.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/CycleScreens/Result/search_box.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ItemsTransferScreen extends StatefulWidget { + final bool? isAdmin; + final ItemDetailObject? items; + const ItemsTransferScreen({ + super.key, + this.isAdmin, + this.items, + }); + + @override + State createState() => _ItemsTransferScreenState(); +} + +class _ItemsTransferScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var userResults = Provider.of(context); + userResults.setLoading(); + userResults.getUsers(userResults.getUserMedicalCenter() as String).then( + (_) { + userResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var userResults = Provider.of( + context, + listen: false, + ); + userResults + .getUsers(userResults.getUserMedicalCenter() as String); + } + }, + ); + }, + ); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Item Details'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 40, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Transfer to', + hasFilterObject: false, + push: Routes.myItemsFilterScreen, + ), + SizedBox( + height: 20.0, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'user', + text2: 'name', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + Provider.of(context, listen: false) + .searchUsers(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, userResults, _) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return TransferDataBox( + deviceBlockSize: _deviceBlockSize, + user: userResults.usersBox?[index], + isClicked: + userResults.selectedUserIndex == + index, + onTap: (userId) { + Provider.of( + context, + listen: false, + ).selectUser(index); + print(userId); + Provider.of( + context) + .saveUserId = userId; + }, + ); + }, + itemCount: userResults.usersBox?.length, + shrinkWrap: true, + ); + }, + ), + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to transfer this Item?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 280, + child: Column( + children: [ + Text( + 'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + SizedBox( + height: 10.0, + ), + ItemCard(_deviceBlockSize), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Spacer(), + Text('To'), + SizedBox( + width: 5.0, + ), + ItemCard(_deviceBlockSize), + ], + ), + SizedBox( + height: 20.0, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + onTap: () { + Provider.of( + context, + listen: false, + ).transferItems( + ItemsTransferScreen().items!.id, + Provider.of( + context, + ).saveUserId!, + ); + }, + text: 'Transfer', + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kPink, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }, + ); + }, + text: 'Transfer', + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } + + Container ItemCard(double _deviceBlockSize) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + ItemsTransferScreen().items!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + ItemsTransferScreen().items!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Size: ', + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + Text( + ItemsTransferScreen().items!.size, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + ItemsTransferScreen().items!.userName, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/pages/MyPackagesPages/Result/my_packages_mine_screen.dart b/lib/pages/MyPackagesPages/Result/my_packages_mine_screen.dart new file mode 100644 index 0000000..7353d21 --- /dev/null +++ b/lib/pages/MyPackagesPages/Result/my_packages_mine_screen.dart @@ -0,0 +1,232 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:cssd/config/routes.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_history_screen.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_packages.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/CycleScreens/Result/search_box.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Filter/my_packages_chip_widget.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyPackagesMineScreen extends StatefulWidget { + final bool? isAdmin; + const MyPackagesMineScreen({ + Key? key, + this.isAdmin, + }) : super(key: key); + + @override + State createState() => _MyPackagesMineScreenState(); +} + +class _MyPackagesMineScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var myPackageResults = Provider.of(context); + final userData = Provider.of(context, listen: false).user; + myPackageResults.setLoading(); + myPackageResults.resetPageNumber(); + if (userData['roles']?.contains('User')) { + myPackageResults.getMyPackages().then( + (_) { + myPackageResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var myItemResults = Provider.of( + context, + listen: false, + ); + myItemResults.getMyPackages(); + } + }, + ); + }, + ); + } else { + myPackageResults.getHospitalPackages().then((_) { + myPackageResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var myPackageResults = Provider.of( + context, + listen: false, + ); + myPackageResults.getHospitalPackages(); + } + }, + ); + }); + } + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + final userData = Provider.of(context, listen: false).user; + return Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'My Packages', + push: Routes.myPackagesFilterScreen, + ), + Consumer( + builder: (ctx, package, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + package.filters!.id != '' + ? MyPackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + name: package.filters!.name, + udi: package.filters!.udi, + ) + : Container(), + package.filters!.name != '' + ? MyPackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Package Name', + id: package.filters!.id, + name: '', + udi: package.filters!.udi, + ) + : Container(), + package.filters!.udi != '' + ? MyPackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'UDI', + id: package.filters!.id, + name: package.filters!.name, + udi: '', + ) + : Container(), + ], + ), + ); + }, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'package', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + if (userData['roles']?.contains('User')) { + Provider.of(context, listen: false) + .searchMyPackages(value); + } else { + Provider.of(context, listen: false) + .searchHospitalPackages(value); + } + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, packageResults, _) { + return packageResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + if (userData['roles']?.contains('User')) { + return MyPackagesItemDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: false, + packages: + packageResults.myPackages?[index], + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: ((context) => + MyPackagesHistoryScreen( + packages: packageResults + .myPackages?[index], + )), + ), + ); + }, + ); + } else { + return MyPackagesItemDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: true, + packages: packageResults + .hospitalPackages?[index], + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: ((context) => + MyPackagesHistoryScreen( + packages: packageResults + .myPackages?[index], + )), + ), + ); + }, + ); + } + }, + itemCount: userData['roles']?.contains('User') + ? packageResults.myPackages?.length + : packageResults.hospitalPackages?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ); + } +} diff --git a/lib/pages/MyPackagesPages/Result/my_packages_requests_screen.dart b/lib/pages/MyPackagesPages/Result/my_packages_requests_screen.dart new file mode 100644 index 0000000..7657b89 --- /dev/null +++ b/lib/pages/MyPackagesPages/Result/my_packages_requests_screen.dart @@ -0,0 +1,155 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:cssd/config/routes.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_packages.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Result/package_requests_data_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyPackagesRequestsScreen extends StatefulWidget { + final bool? isAdmin; + const MyPackagesRequestsScreen({ + Key? key, + this.isAdmin, + }) : super(key: key); + + @override + State createState() => + _MyPackagesRequestsScreenState(); +} + +class _MyPackagesRequestsScreenState extends State { + bool _isInit = true; + ScrollController? sc; + + @override + void initState() { + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var packageResults = Provider.of(context); + final userData = Provider.of(context, listen: false).user; + packageResults.setLoading(); + packageResults.resetPageNumber(); + if (userData['roles']?.contains('User')) { + packageResults.getMyPackageRequests().then( + (_) { + packageResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var packageResults = Provider.of( + context, + listen: false, + ); + packageResults.getMyPackageRequests(); + } + }, + ); + }, + ); + } else { + packageResults.getHospitalPackageRequests().then( + (_) { + packageResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var packageResults = Provider.of( + context, + listen: false, + ); + packageResults.getHospitalPackageRequests(); + } + }, + ); + }, + ); + } + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + final userData = Provider.of(context, listen: false).user; + return Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'My Requests', + hasFilterObject: false, + push: Routes.myPackagesFilterScreen, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, packageResults, _) { + return packageResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + if (userData['roles']?.contains('User')) { + return PackageRequestsDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: false, + package: packageResults + .originalMyPackagesRequests?[index], + ); + } else { + return PackageRequestsDataBox( + deviceBlockSize: _deviceBlockSize, + isAdmin: true, + package: packageResults + .originalHospitalPackagesRequests?[ + index], + ); + } + }, + itemCount: userData['roles']?.contains('User') + ? packageResults + .originalMyPackagesRequests?.length + : packageResults + .originalHospitalPackagesRequests + ?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ); + } +} diff --git a/lib/pages/MyPackagesPages/Result/my_packages_result_screen.dart b/lib/pages/MyPackagesPages/Result/my_packages_result_screen.dart new file mode 100644 index 0000000..a9b2102 --- /dev/null +++ b/lib/pages/MyPackagesPages/Result/my_packages_result_screen.dart @@ -0,0 +1,75 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/pages/MyPackagesPages/Result/my_packages_mine_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/Result/my_packages_requests_screen.dart'; +import 'package:flutter/material.dart'; + +class MyPackagesResultScreen extends StatefulWidget { + const MyPackagesResultScreen({super.key}); + + @override + State createState() => _MyPackagesResultScreenState(); +} + +class _MyPackagesResultScreenState extends State + with SingleTickerProviderStateMixin { + late final TabController _tabController; + + @override + void initState() { + _tabController = TabController(length: 2, vsync: this); + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: DefaultTabController( + length: 2, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + bottom: TabBar( + controller: _tabController, + indicatorColor: kPurple, + tabs: [ + Tab( + text: 'Mine', + ), + Tab( + text: 'Requests', + ), + ], + ), + ), + body: TabBarView( + controller: _tabController, + children: [ + MyPackagesMineScreen(), + MyPackagesRequestsScreen(), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/MyPackagesPages/my_packages_detail_screen.dart b/lib/pages/MyPackagesPages/my_packages_detail_screen.dart new file mode 100644 index 0000000..34f32b9 --- /dev/null +++ b/lib/pages/MyPackagesPages/my_packages_detail_screen.dart @@ -0,0 +1,101 @@ +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/pages/MyPackagesPages/my_packages_transfer_screen.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Detail/my_packages_detail_box_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class MyPackagesDetailScreen extends StatefulWidget { + final String? testResultId; + + MyPackagesDetailScreen({ + this.testResultId, + }); + + @override + _MyPackagesDetailScreenState createState() => _MyPackagesDetailScreenState(); +} + +class _MyPackagesDetailScreenState extends State { + bool isInit = true; + bool isEmpty = false; + PackageDetailObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showPackageResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Package does\'nt exists!'), + ) + : MyPackageDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + push: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PackageTransferScreen( + packages: datas, + ), + ), + ); + }, + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/MyPackagesPages/my_packages_filter_screen.dart b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart new file mode 100644 index 0000000..f194cec --- /dev/null +++ b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart @@ -0,0 +1,253 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Filter/my_packages_filter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class MyPackageFilterScreen extends StatefulWidget { + @override + _MyPackageFilterScreenState createState() => _MyPackageFilterScreenState(); +} + +class _MyPackageFilterScreenState extends State { + final _nameFocusNode = FocusNode(); + final _udiFocusNode = FocusNode(); + TextEditingController idCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + + bool isInit = true; + PackageFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + idCTRL.text = filters!.id; + hospitalCTRL.text = filters!.hospital; + nameCTRL.text = filters!.name; + udiCTRL.text = filters!.udi; + super.initState(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.myPackagesResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.myPackagesResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter My Packages', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_nameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _nameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_udiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _udiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 90, + ), + MyPackagesFilterSaveButton( + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + push: Routes.myPackagesResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/MyPackagesPages/my_packages_history_screen.dart b/lib/pages/MyPackagesPages/my_packages_history_screen.dart new file mode 100644 index 0000000..a425f55 --- /dev/null +++ b/lib/pages/MyPackagesPages/my_packages_history_screen.dart @@ -0,0 +1,170 @@ +import 'package:cssd/models/my_package_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/users.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart'; +import 'package:cssd/widgets/MyPackagesScreens/History/my_packages_history_date_widget.dart'; +import 'package:cssd/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Result/banner.dart'; +import '../../widgets/Global/internet_error.dart'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyPackagesHistoryScreen extends StatefulWidget { + final bool? isAdmin; + final MyPackageResultObject? packages; + + MyPackagesHistoryScreen({this.isAdmin, this.packages}); + + @override + _MyPackagesHistoryScreenState createState() => + _MyPackagesHistoryScreenState(); +} + +class _MyPackagesHistoryScreenState extends State { + bool _isInit = true; + ScrollController? sc; + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var userResults = Provider.of(context); + userResults.setLoading(); + userResults + .getUsers(userResults.getUserMedicalCenter() as String) + .then((_) { + userResults.resetLoading(); + sc?.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent) { + var userResults = Provider.of( + context, + listen: false, + ); + userResults + .getUsers(userResults.getUserMedicalCenter() as String); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + final userData = Provider.of(context, listen: false).user; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('My Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Package History', + push: Routes.itemFilterScreen, + hasFilterObject: false, + ), + SizedBox( + height: 20, + ), + MyPackagesItemDataBox( + deviceBlockSize: _deviceBlockSize, + hasHistoryBtn: false, + packages: MyPackagesHistoryScreen().packages!, + isAdmin: userData['roles']?.contains('User') + ? false + : true, + ), + SizedBox( + height: 10.0, + ), + Divider( + color: Colors.grey, + height: 2.0, + ), + SizedBox( + height: 10.0, + ), + Expanded( + child: Consumer( + builder: (context, userResults, child) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return Column( + children: [ + PackageHistoryDate( + deviceBlockSize: _deviceBlockSize, + packages: + MyPackagesHistoryScreen() + .packages!, + ), + SizedBox( + height: 20.0, + ), + TransferDataBox( + deviceBlockSize: _deviceBlockSize, + user: + userResults.usersBox?[index], + ), + ], + ); + }, + itemCount: userResults.usersBox?.length, + shrinkWrap: true, + ); + }, + ), + ) + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart b/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart new file mode 100644 index 0000000..79fc5b3 --- /dev/null +++ b/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart @@ -0,0 +1,343 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/config/routes.dart'; +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/providers/my_packages.dart'; +import 'package:cssd/providers/users.dart'; +import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; +import 'package:cssd/widgets/CycleScreens/Result/search_box.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PackageTransferScreen extends StatefulWidget { + final bool? isAdmin; + final PackageDetailObject? packages; + const PackageTransferScreen({ + super.key, + this.isAdmin, + this.packages, + }); + + @override + State createState() => _PackageTransferScreenState(); +} + +class _PackageTransferScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var userResults = Provider.of(context); + userResults.setLoading(); + userResults + .getUsers(userResults.getUserMedicalCenter() as String) + .then((_) { + userResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var userResults = Provider.of( + context, + listen: false, + ); + userResults + .getUsers(userResults.getUserMedicalCenter() as String); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _deviceWidth = _media.size.width; + final double _deviceBlockSize = _deviceWidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Package Details'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 40, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Transfer to', + hasFilterObject: false, + push: Routes.myItemsFilterScreen, + ), + SizedBox( + height: 20.0, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'user', + text2: 'name', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + Provider.of(context, listen: false) + .searchUsers(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, userResults, _) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return TransferDataBox( + deviceBlockSize: _deviceBlockSize, + user: userResults.usersBox?[index], + isClicked: + userResults.selectedUserIndex == + index, + onTap: (userId) { + Provider.of( + context, + listen: false, + ).selectUser(index); + print(userId); + Provider.of( + context) + .saveUserId = userId; + }, + ); + }, + itemCount: userResults.usersBox?.length, + shrinkWrap: true, + ); + }, + ), + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to transfer this Package?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 280, + child: Column( + children: [ + Text( + 'By approving, all items in your package will be transferred the specified user. it can be undone unless the user reject the transfer.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + SizedBox( + height: 10.0, + ), + PackageCard(_deviceBlockSize), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Spacer(), + Text('To'), + SizedBox( + width: 5.0, + ), + PackageCard(_deviceBlockSize), + ], + ), + SizedBox( + height: 20.0, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + onTap: () { + Provider.of( + context, + listen: false, + ).transferPackage( + PackageTransferScreen() + .packages! + .id, + Provider.of( + context, + ).saveUserId!, + ); + }, + text: 'Transfer', + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kPink, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }, + ); + }, + text: 'Transfer', + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } + + Container PackageCard(double _deviceBlockSize) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + PackageTransferScreen().packages!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + PackageTransferScreen().packages!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + // Container( + // width: 30 * _deviceBlockSize, + // child: Row( + // children: [ + // Text( + // 'Size: ', + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // fontSize: 3 * _deviceBlockSize, + // color: Colors.grey, + // ), + // ), + // Text( + // PackageTransferScreen().packages!.size, + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // fontWeight: FontWeight.w700, + // fontSize: 3 * _deviceBlockSize, + // ), + // ), + // ], + // ), + // ), + // Container( + // width: 30 * _deviceBlockSize, + // child: Row( + // children: [ + // Text( + // 'User: ', + // style: TextStyle( + // color: Colors.grey, + // fontSize: 3 * _deviceBlockSize, + // ), + // ), + // Text( + // PackageTransferScreen().packages!.userName, + // style: TextStyle( + // fontSize: 3 * _deviceBlockSize, + // fontWeight: FontWeight.w700, + // ), + // ), + // ], + // ), + // ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/pages/PackagePages/package_add_screen.dart b/lib/pages/PackagePages/package_add_screen.dart new file mode 100644 index 0000000..502623d --- /dev/null +++ b/lib/pages/PackagePages/package_add_screen.dart @@ -0,0 +1,281 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/PackageScreens/Add/package_save_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Add/add_label_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +class PackageAddScreen extends StatefulWidget { + @override + _PackageAddScreenState createState() => _PackageAddScreenState(); +} + +class _PackageAddScreenState extends State { + final _packageUdiFocusNode = FocusNode(); + final _descriptionFocusNode = FocusNode(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController dateCTRL = new TextEditingController(); + final _form = GlobalKey(); + bool isInit = true; + PackageFilterObject? filters; + + int curLabelVal = 1; + @override + void initState() { + descriptionCTRL.text = ''; + udiCTRL.text = ''; + nameCTRL.text = ''; + dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var packageProviderObject = Provider.of(context); + packageProviderObject.resetItemVals(); + packageProviderObject.getItemFilters().then( + (result) { + setState( + () { + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.packageResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add a Package', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Package Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_packageUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'UDI required!'; + } + return null; + }, + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'UDI', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _packageUdiFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 20, + ), + Container( + margin: EdgeInsets.symmetric(vertical: 5), + child: Text( + 'Items included', + style: TextStyle( + color: kPurple, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, packageProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => AddLabelBox( + text: 'Select Items Included', + iconColor: kPurpleSub, + deviceBlockSize: _deviceBlockSize, + values: + packageProvider.itemValues[index], + vals: packageProvider.itemVals, + initialLabelValue: + packageProvider.initialItemValue, + index: index, + ), + itemCount: + packageProvider.itemValues.length, + ), + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + PackageAddSaveButton( + form: _form, + itemValues: Provider.of( + context, + listen: false, + ).itemValues, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + dateValue: dateCTRL.text, + descriptionCTRL: descriptionCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/PackagePages/package_detail_screen.dart b/lib/pages/PackagePages/package_detail_screen.dart new file mode 100644 index 0000000..856c096 --- /dev/null +++ b/lib/pages/PackagePages/package_detail_screen.dart @@ -0,0 +1,90 @@ +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/PackageScreens/Details/package_detail_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class PackageDetailScreen extends StatefulWidget { + final String? testResultId; + + PackageDetailScreen({ + this.testResultId, + }); + + @override + _PackageDetailScreenState createState() => _PackageDetailScreenState(); +} + +class _PackageDetailScreenState extends State { + bool isInit = true; + bool isEmpty = false; + PackageDetailObject? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showPackageResult(_id.toString()) + .then( + (result) { + setState( + () { + if (result.id == 'null') { + isEmpty = true; + } + datas = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Package does\'nt exists!'), + ) + : PackageDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/PackagePages/package_filter_screen.dart b/lib/pages/PackagePages/package_filter_screen.dart new file mode 100644 index 0000000..7b796b4 --- /dev/null +++ b/lib/pages/PackagePages/package_filter_screen.dart @@ -0,0 +1,296 @@ +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:cssd/widgets/PackageScreens/Filter/filter_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Filter/selector_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +class PackageFilterScreen extends StatefulWidget { + @override + _PackageFilterScreenState createState() => _PackageFilterScreenState(); +} + +class _PackageFilterScreenState extends State { + final _nameFocusNode = FocusNode(); + final _udiFocusNode = FocusNode(); + TextEditingController idCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + + List> hospitalVals = []; + bool isInit = true; + PackageFilterObject? filters; + @override + void initState() { + filters = Provider.of(context, listen: false).filters; + idCTRL.text = filters!.id; + hospitalCTRL.text = filters!.hospital; + nameCTRL.text = filters!.name; + udiCTRL.text = filters!.udi; + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + await Provider.of(context, listen: false) + .getHospitalsFilters() + .then( + (result) { + setState( + () { + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } + filters!.hospital == '' + ? hospitalCTRL.text = hospitalVals[0]['name']! + : hospitalVals.forEach( + //id convert to name + (hospital) { + if (hospital['id'] == filters!.hospital) { + hospitalCTRL.text = hospital['name']!; + } + }, + ); + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.packageResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter Packages', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_nameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _nameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_udiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _udiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 30.0, + ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 90, + ), + PackageFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/PackagePages/package_result_screen.dart b/lib/pages/PackagePages/package_result_screen.dart new file mode 100644 index 0000000..6aa969e --- /dev/null +++ b/lib/pages/PackagePages/package_result_screen.dart @@ -0,0 +1,269 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/PackageScreens/Filter/package_filter_object.dart'; +import 'package:cssd/widgets/PackageScreens/Result/package_data_box.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/CycleScreens/Result/banner.dart'; +import '../../widgets/CycleScreens/Result/search_box.dart'; +import '../../widgets/Global/internet_error.dart'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PackageResultScreen extends StatefulWidget { + final bool? isAdmin; + + PackageResultScreen({this.isAdmin}); + + @override + _PackageResultScreenState createState() => _PackageResultScreenState(); +} + +class _PackageResultScreenState extends State { + bool _isInit = true; + ScrollController? sc; + TextEditingController searchCTRL = new TextEditingController(); + + @override + void initState() { + sc = new ScrollController(); + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var testResults = Provider.of(context); + testResults.setLoading(); + testResults.resetPageNumber(); + testResults.getPackageResults().then((_) { + testResults.resetLoading(); + sc!.addListener( + () { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var testResults = Provider.of( + context, + listen: false, + ); + testResults.getPackageResults(); + } + }, + ); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + floatingActionButton: PackageResultFloatingButton( + deviceBlockSize: _deviceBlockSize, + ), + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 60, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Packages', + push: Routes.packageFilterScreen, + ), + Consumer( + builder: (ctx, package, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + package.filters!.id != '' + ? PackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + name: package.filters!.name, + hospital: package.filters!.hospital, + udi: package.filters!.udi, + ) + : Container(), + package.filters!.name != '' + ? PackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Package Name', + id: package.filters!.id, + name: '', + udi: package.filters!.udi, + hospital: package.filters!.hospital, + ) + : Container(), + package.filters!.hospital != '' + ? PackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'Hospital', + id: package.filters!.id, + name: package.filters!.name, + udi: package.filters!.udi, + hospital: '', + ) + : Container(), + package.filters!.udi != '' + ? PackageFilterChip( + deviceBlockSize: _deviceBlockSize, + label: 'UDI', + id: package.filters!.id, + name: package.filters!.name, + udi: '', + hospital: package.filters!.hospital, + ) + : Container(), + ], + ), + ); + }, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'package', + deviceBlockSize: _deviceBlockSize, + onChanged: (value) { + Provider.of(context, listen: false) + .search(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, packageResults, _) { + return packageResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + // String items = ''; + // for (var item in packageResults + // .items![index].items) { + // items += item; + // items += ' , '; + // } + // items = items.substring( + // 0, + // items.length - 3, + // ); // remove extra , + return PackageItemBox( + deviceBlockSize: _deviceBlockSize, + item: packageResults.items?[index], + ); + }, + itemCount: packageResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }), + ), + ), + ); + } +} + +class PackageResultFloatingButton extends StatelessWidget { + const PackageResultFloatingButton({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.packageScanScreen); + }, + child: Container( + padding: EdgeInsets.all(2.5 * _deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed(Routes.packageAddScreen); + }, + child: Container( + padding: EdgeInsets.all(_deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kPurple, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ); + } +} diff --git a/lib/pages/PackagePages/package_scan_screen.dart b/lib/pages/PackagePages/package_scan_screen.dart new file mode 100644 index 0000000..5f8598d --- /dev/null +++ b/lib/pages/PackagePages/package_scan_screen.dart @@ -0,0 +1,195 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class PackageScanScreen extends StatefulWidget { + @override + State createState() { + return _PackageScanScreenState(); + } +} + +class _PackageScanScreenState extends State { + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Packages'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Package?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, + ), + ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Package Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + textAlign: TextAlign.center, + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Package/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; + } + return null; + }, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Package ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, + ), + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Package/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPurple, kPurpleSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/PackagePages/package_update_screen.dart b/lib/pages/PackagePages/package_update_screen.dart new file mode 100644 index 0000000..c5f56c2 --- /dev/null +++ b/lib/pages/PackagePages/package_update_screen.dart @@ -0,0 +1,240 @@ +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/PackageScreens/Add/package_update_button.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class PackageUpdateScreen extends StatefulWidget { + @override + _PackageUpdateScreenState createState() => _PackageUpdateScreenState(); +} + +class _PackageUpdateScreenState extends State { + final _udiFocusNode = FocusNode(); + final _descriptionFocusNode = FocusNode(); + TextEditingController nameCTRL = new TextEditingController(); + TextEditingController udiCTRL = new TextEditingController(); + TextEditingController descriptionCTRL = new TextEditingController(); + TextEditingController itemCTRL = new TextEditingController(); + + final _form = GlobalKey(); + + bool isEmpty = false; + bool isInit = true; + PackageDetailObject? datas; + + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showPackageResult(_id.toString()) + .then( + (result) { + setState( + () { + datas = result; + nameCTRL.text = datas!.name; + udiCTRL.text = datas!.udi; + descriptionCTRL.text = datas!.description; + for (String item in datas!.items) { + itemCTRL.text = item; + } + }, + ); + }, + ); + await Provider.of(context, listen: false) + .getItemFilters() + .then( + (result) { + setState( + () { + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.packageResultScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + backgroundColor: Colors.black, + title: Text('Packages'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(color: Colors.black), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Update a Package', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon(FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Package Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_udiFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'UDI required!'; + } + return null; + }, + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'UDI', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _udiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 20, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + PackageUpdateButton( + form: _form, + id: datas!.id, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + itemCTRL: itemCTRL, + deviceBlockSize: _deviceBlockSize, + descriptionCTRL: descriptionCTRL, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/TestPages/test_add_screen.dart b/lib/pages/TestPages/test_add_screen.dart new file mode 100644 index 0000000..6fe14f5 --- /dev/null +++ b/lib/pages/TestPages/test_add_screen.dart @@ -0,0 +1,292 @@ +import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/test_results.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/TestResultScreens/Add/selector_box.dart'; + +class TestResultAddScreen extends StatefulWidget { + // static const route = '/TestResultAddScreen'; + @override + State createState() { + return _TestResultAddScreenState(); + } +} + +class _TestResultAddScreenState extends State { + TextEditingController testTypeCTRL = new TextEditingController(); + final List testTypeVals = []; + + TextEditingController testCodeCTRL = new TextEditingController(); + bool isInit = true; + @override + void didChangeDependencies() { + if (isInit) { + var testResultProviderObject = + Provider.of(context, listen: false); + testResultProviderObject.getFilterItems().then((result) { + for (var testType in result[1].keys) { + testTypeVals.add(testType); + } + testTypeCTRL.text = testTypeVals[0]; + setState(() { + isInit = false; + }); + }); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Test Results'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + // padding: EdgeInsets.all(0), + onPressed: () => Navigator.of(context) + .popAndPushNamed(Routes.testResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView( + padding: EdgeInsets.symmetric( + horizontal: 20, vertical: 20), + children: [ + Container( + padding: EdgeInsets.only( + top: 10, + ), + child: Text( + 'Add a Test Result', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.only(top: 5, bottom: 30), + padding: EdgeInsets.all(10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'PLease Scan The Test Barcode', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.grey, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + Navigator.pushNamed( + context, + Routes.formTestResultScreen, + arguments: result, + ); + } + }, + ); + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 70 * _deviceBlockSize, + child: TestResultAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Choose a Test Type', + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + 'OR', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 7 * _deviceBlockSize, + ), + ), + SizedBox( + width: 8 * _deviceBlockSize, + ), + Container( + width: 50 * _deviceBlockSize, + child: TextFormField( + onChanged: (val) { + if (val != '') { + setState(() { + testTypeCTRL.text = ''; + }); + } else { + setState(() { + testTypeCTRL.text = + testTypeVals[0]; + }); + } + }, + controller: testCodeCTRL, + decoration: InputDecoration( + isDense: true, + icon: Icon( + FontAwesomeIcons + .sortNumericDown, + ), + labelText: 'Enter a Test Code', + labelStyle: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + contentPadding: EdgeInsets.only( + bottom: 5, + top: 5, + ), + ), + keyboardType: + TextInputType.visiblePassword, + ), + ), + ], + ), + SizedBox( + height: 40.0, + ), + Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + width: 50 * _deviceBlockSize, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: TextButton( + child: Text( + 'Select', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + onPressed: () { + if (testCodeCTRL.text != '') { + Provider.of( + context, + listen: false, + ).testCode = testCodeCTRL.text; + Navigator.pushNamed( + context, + Routes.formTestResultScreen, + arguments: testCodeCTRL.text, + ); + } else if (testTypeCTRL.text != + '') { + Provider.of( + context, + listen: false, + ).testType = testTypeCTRL.text; + Navigator.pushReplacementNamed( + context, + Routes.formTestResultScreen, + arguments: testTypeCTRL.text, + ); + } + // print(testCode); + }, + ), + ), + ), + ], + ), + SizedBox( + width: 5 * _deviceBlockSize, + ), + ], + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } + + Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + return barcode.rawContent; + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } + } +} diff --git a/lib/pages/test_detail_screen.dart b/lib/pages/TestPages/test_detail_screen.dart similarity index 71% rename from lib/pages/test_detail_screen.dart rename to lib/pages/TestPages/test_detail_screen.dart index 5870770..50a6169 100644 --- a/lib/pages/test_detail_screen.dart +++ b/lib/pages/TestPages/test_detail_screen.dart @@ -1,75 +1,78 @@ -import '../providers/connectivity.dart'; -import '../providers/test_results.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/TestResultScreens/Details/datas_box.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class TestDetailsScreen extends StatefulWidget { - // static const route = '/TestDetailsScreen'; - final String testResultId; - - TestDetailsScreen({this.testResultId}); - - @override - _TestDetailsScreenState createState() => _TestDetailsScreenState(); -} - -class _TestDetailsScreenState extends State { - bool isInit = true; - Map datas; - @override - void didChangeDependencies() async { - if (isInit) { - var _id = ModalRoute.of(context).settings.arguments; - await Provider.of(context, listen: false) - .showTestResult(_id.toString()) - .then((result) { - setState(() { - datas = result; - isInit = false; - }); - }); - // print(datas); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - // print(datas); - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Test Result Detail'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : DatasBox( - datas: datas, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }, - ), - ), - ); - } -} +import '../../providers/connectivity.dart'; +import '../../providers/test_results.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/TestResultScreens/Details/datas_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class TestDetailsScreen extends StatefulWidget { + // static const route = '/TestDetailsScreen'; + final String? testResultId; + + TestDetailsScreen({this.testResultId}); + + @override + _TestDetailsScreenState createState() => _TestDetailsScreenState(); +} + +class _TestDetailsScreenState extends State { + bool isInit = true; + Map? datas; + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context)!.settings.arguments; + await Provider.of(context, listen: false) + .showTestResult(_id.toString()) + .then((result) { + setState(() { + datas = result.cast(); + isInit = false; + }); + }); + // print(datas); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + // print(datas); + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Test Results'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : DatasBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/TestPages/test_filter_screen.dart b/lib/pages/TestPages/test_filter_screen.dart new file mode 100644 index 0000000..8231709 --- /dev/null +++ b/lib/pages/TestPages/test_filter_screen.dart @@ -0,0 +1,431 @@ +import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/test_result_models.dart'; +import '../../providers/connectivity.dart'; +import '../../providers/test_results.dart'; +import '../../widgets/Global/internet_error.dart'; +import '../../widgets/TestResultScreens/Filter/date_picker.dart'; +import '../../widgets/TestResultScreens/Filter/selector_box.dart'; + +class TestFilterScreen extends StatefulWidget { + // static const route = '/TestFilterScreen'; + + @override + _TestFilterScreenState createState() => _TestFilterScreenState(); +} + +class _TestFilterScreenState extends State { + TextEditingController idCTRL = new TextEditingController(); + TextEditingController labelIdCTRL = new TextEditingController(); + TextEditingController testTypeCTRL = new TextEditingController(); + TextEditingController hospitalCTRL = new TextEditingController(); + TextEditingController fDateCTRL = new TextEditingController(); + TextEditingController uDateCTRL = new TextEditingController(); + + TextEditingController usernameCTRL = new TextEditingController(); + // TextEditingController dateFrom = new TextEditingController(); + // TextEditingController dateUntil = new TextEditingController(); + DateTime? dateTimeFrom; + DateTime? dateTimeUntil; + + final List labelIDVals = [ + '', + 'Washer ID', + 'Autoclave ID', + 'Sterilizer ID', + 'Seal Machine ID', + 'Patiant ID', + 'Set/Pack ID', + 'Medical Device ID', + 'OR ID', + 'Insrtument ID', + 'Basket ID', + 'Implant ID', + // 'None', + ]; + // String curLabelIDVal; + + final List testTypeVals = []; + Map? testTypes; + + final List hospitalVals = []; + Map hospitals = {}; + // String curhospitalVal; + + bool isInit = true; + // final List labelIDVals = ['Washer ID']; + // String curLabelIDVal; + + // final List labelIDVals = ['Washer ID']; + // String curLabelIDVal; + + // @override + // void initState() { + // super.initState(); + // } + + @override + void didChangeDependencies() { + if (isInit) { + // fDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + // uDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + fDateCTRL.text = ''; + uDateCTRL.text = ''; + var testResultProviderObject = + Provider.of(context, listen: false); + TestResultFilterObject filters = testResultProviderObject.filters; + idCTRL.text = filters.id; + usernameCTRL.text = filters.userName; + labelIdCTRL.text = + filters.labelID == '' ? labelIDVals[0] : filters.labelID; + idCTRL.text = filters.id; + usernameCTRL.text = filters.userName; + testResultProviderObject.getFilterItems().then((result) { + hospitals = result[0]; + testTypes = result[1]; + hospitalVals.add(''); + for (var hospital in result[0].keys) { + hospitalVals.add(hospital); + } + testTypeVals.add(''); + for (var testType in result[1].keys) { + testTypeVals.add(testType); + } + var testTypeKey = testTypes!.keys.firstWhere( + (k) => testTypes![k] == filters.testType, + orElse: () => ''); // recent testtype name + var hospitalKey = hospitals.keys.firstWhere( + (k) => hospitals[k] == filters.hospital, + orElse: () => ''); // recent testtype name + testTypeCTRL.text = + filters.testType == '' ? testTypeVals[0] : testTypeKey; + hospitalCTRL.text = + filters.hospital == '' ? hospitalVals[0] : hospitalKey; + // print(result[0]); + // print(result[1]); + setState(() { + isInit = false; + }); + }); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultScreen, + ); + return true; + }, + child: SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Test Results'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Test Results', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_cycleNumberFocusNode); + // }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + // Navigator.of(context).pushNamed( + // CycleDetailScreen.route, + // arguments: result, + // ); + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: labelIdCTRL, + dataVals: labelIDVals, + label: 'Label ID', + ), + SizedBox( + height: 25, + ), + + TextFormField( + controller: usernameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Username', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_cycleNumberFocusNode); + // }, + ), + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Test Type', + ), + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: hospitalCTRL, + dataVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 25, + ), + + TestResultFilterDatePicker( + dateCTRL: fDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Date From', + ), + SizedBox( + height: 25, + ), + TestResultFilterDatePicker( + dateCTRL: uDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Date Until', + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + Provider.of(context, + listen: false) + .setFilters( + idCTRL.text, + labelIdCTRL.text != '' + ? labelIdCTRL.text + : '', + usernameCTRL.text, + testTypeCTRL.text != '' + ? testTypes![testTypeCTRL.text] + : '', + hospitalCTRL.text != '' + ? hospitals[hospitalCTRL.text] + : '', + fDateCTRL.text, + uDateCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + // Navigator.of(context).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then( + (_) => + Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ), + ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.black87], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + SizedBox( + height: 70, + ), + // DropDownBox(values: ['Washer ID']), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ), + ); + } +} + +Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + try { + var id = barcode.rawContent.contains('www.cssd-doc.com') + ? barcode.rawContent.split('/')[5] + : barcode.rawContent; + + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } +} diff --git a/lib/pages/test_form_page.dart b/lib/pages/TestPages/test_form_page.dart similarity index 61% rename from lib/pages/test_form_page.dart rename to lib/pages/TestPages/test_form_page.dart index 44edd76..902dde4 100644 --- a/lib/pages/test_form_page.dart +++ b/lib/pages/TestPages/test_form_page.dart @@ -1,195 +1,204 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:random_string/random_string.dart'; - -import '../config/routes.dart'; -import '../providers/input.dart'; -import '../providers/test_results.dart'; -import '../widgets/TestResultScreens/Add/form_creator.dart'; - -class FormPage extends StatefulWidget { - final String name; - final String uniqueCode; - final String testResultId; - final String testTypeId; - - FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId}); - - @override - _FormPageState createState() => _FormPageState(); -} - -class _FormPageState extends State { - bool _isInit = true; - bool _isLoading = false; - bool isAdding = false; - final _form = GlobalKey(); - Map values = {}; - List> formInputs; - - void _saveForm() { - final batchId = randomString(10); - formatData(formInputs); - var prvObject = Provider.of(context, listen: false); - if (this.widget.testResultId != null && this.widget.testResultId != '') { - values['_method'] = 'put'; - TestResultsProvider.updateTestResult(this.widget.testResultId, values) - .then((_) { - Navigator.of(context).pop(); - }); - } else { - setState(() { - _isLoading = true; - }); - prvObject.createTestResult(values, batchId).then((result) { - setState(() { - _isLoading = false; - }); - if (result == 'done') { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Test added.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((value) => - Navigator.of(context).popAndPushNamed(Routes.testResultScreen)); - } - }); - } - } - - @override - void didChangeDependencies() { - if (_isInit) { - setState(() { - _isLoading = true; - }); - Provider.of(context, listen: false) - .getInputs( - testResultId: this.widget.testResultId ?? "", - name: this.widget.name ?? "", - uniqueCode: this.widget.uniqueCode ?? "", - testTypeId: this.widget.testTypeId ?? "") - .then((_) { - setState(() { - _isLoading = false; - }); - }); - } - _isInit = false; - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultAddScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('Add Test Result'), - actions: [ - IconButton( - icon: Icon(Icons.save), - onPressed: () { - _saveForm(); - }, - ) - ], - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () { - Navigator.of(context) - .popAndPushNamed(Routes.testResultScreen); - }, - ), - ), - body: Column( - children: [ - Expanded( - child: _isLoading - ? Center(child: CircularProgressIndicator()) - : Form( - key: _form, - child: Consumer( - builder: (context, inputs, _) { - formInputs = inputs.inputItems; - return formInputs.length != 0 - ? FormCreator( - form: inputs.inputItems, - onChanged: (value) { - formInputs = value; - }, - ) - : Center( - child: Text('An error happen!!!'), - ); - }, - ), - ), - ), - // https://www.cssd-doc.com/api/GetInfo - // InkWell( - // onTap: () { - // _saveForm(); - // }, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15), - // margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50), - // decoration: BoxDecoration( - // gradient: LinearGradient(colors: [Colors.blue, Colors.green]), - // borderRadius: BorderRadius.circular(10), - // ), - // child: Text( - // 'Save', - // style: TextStyle(color: Colors.white, fontSize: 17), - // textAlign: TextAlign.center, - // ), - // ), - // ), - ], - )), - ), - ); - } - - void formatData(inputs) { - for (var input in inputs) { - if (input['type'] != 'Form') { - if (input['key'] == 'result') { - values[input["key"]] = input["value"] ? "Accept" : "Reject"; - // print('${input["key"]} : ${input["value"] ? "Accept" : "Reject"}'); - } else if (input['key'] == 'date') { - var date = input["value"]; - - values[input["key"]] = "${date.year}-${date.month}-${date.day}"; - } else { - values[input["key"]] = input["value"]; - // print('${input["key"]} : ${input["value"]}'); - } - } - if (input['children'] != null && input['children'].isNotEmpty) { - formatData(input['children']); - } - } - // print(values); - } -} +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:random_string/random_string.dart'; + +import '../../config/routes.dart'; +import '../../providers/input.dart'; +import '../../providers/test_results.dart'; +import '../../widgets/TestResultScreens/Add/form_creator.dart'; + +class FormPage extends StatefulWidget { + final String? name; + final String? uniqueCode; + final String? testResultId; + final String? testTypeId; + + FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId}); + + @override + _FormPageState createState() => _FormPageState(); +} + +class _FormPageState extends State { + bool _isInit = true; + bool _isLoading = false; + bool isAdding = false; + final _form = GlobalKey(); + Map values = {}; + List> formInputs = []; + + void _saveForm() { + final batchId = randomString(10); + formatData(formInputs); + var prvObject = Provider.of(context, listen: false); + if (this.widget.testResultId != null && this.widget.testResultId != '') { + values['_method'] = 'put'; + TestResultsProvider.updateTestResult(this.widget.testResultId!, values) + .then((_) { + Navigator.of(context).pop(); + }); + } else { + setState(() { + _isLoading = true; + }); + prvObject.createTestResult(values, batchId).then((result) { + setState(() { + _isLoading = false; + }); + if (result == 'done') { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Test added.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((value) => + Navigator.of(context).popAndPushNamed(Routes.testResultScreen)); + } + }); + } + } + + @override + void didChangeDependencies() { + if (_isInit) { + setState(() { + _isLoading = true; + }); + String testTypeName = Provider.of(context).testType; + String testCode = Provider.of(context).testCode; + Provider.of(context, listen: false) + .getInputs( + testResultId: '', + name: testTypeName, + uniqueCode: testCode, + testTypeId: '', + ) + .then((_) { + setState(() { + _isLoading = false; + }); + }); + } + _isInit = false; + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultAddScreen, + ); + return true; + }, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('Add Test Result'), + backgroundColor: Colors.black, + actions: [ + IconButton( + icon: Icon(Icons.save), + onPressed: () { + _saveForm(); + }, + ) + ], + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () { + Navigator.of(context).popAndPushNamed(Routes.testResultScreen); + }, + ), + ), + body: SingleChildScrollView( + child: Column( + children: [ + _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Consumer( + builder: (context, inputs, _) { + formInputs = inputs.inputItems; + print(formInputs); + return formInputs.length != 0 + ? FormCreator( + form: formInputs, + onChanged: (value) { + formInputs = value; + }, + ) + : Center( + child: Text('Something went wrong!!!'), + ); + }, + ), + ), + // https://www.cssd-doc.com/api/GetInfo + // InkWell( + // onTap: () { + // _saveForm(); + // }, + // child: Container( + // padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15), + // margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50), + // decoration: BoxDecoration( + // gradient: LinearGradient(colors: [Colors.blue, Colors.green]), + // borderRadius: BorderRadius.circular(10), + // ), + // child: Text( + // 'Save', + // style: TextStyle(color: Colors.white, fontSize: 17), + // textAlign: TextAlign.center, + // ), + // ), + // ), + ], + ), + ), + ), + ), + ); + } + + void formatData(inputs) { + for (var input in inputs) { + if (input['type'] != 'Form') { + if (input['key'] == 'result') { + values[input["key"]] = input["value"] ? "Accept" : "Reject"; + // print('${input["key"]} : ${input["value"] ? "Accept" : "Reject"}'); + } else if (input['key'] == 'date') { + var date = input["value"]; + + values[input["key"]] = "${date.year}-${date.month}-${date.day}"; + } else { + values[input["key"]] = input["value"]; + // print('${input["key"]} : ${input["value"]}'); + } + } + if (input['children'] != null && input['children'].isNotEmpty) { + formatData(input['children']); + } + } + // print(values); + } +} diff --git a/lib/pages/TestPages/test_result_screen.dart b/lib/pages/TestPages/test_result_screen.dart new file mode 100644 index 0000000..55ecbb5 --- /dev/null +++ b/lib/pages/TestPages/test_result_screen.dart @@ -0,0 +1,449 @@ +// import 'package:cssd/providers/test_result.dart'; +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/test_results.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart'; +import 'package:cssd/widgets/TestResultScreens/Main/floating_button.dart'; +import 'package:cssd/widgets/TestResultScreens/Main/search_box.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/test_result_models.dart'; +import '../../providers/connectivity.dart'; + +class TestResultScreen extends StatefulWidget { + // static const route = '/TestResultScreen'; + final bool? isAdmin; + + TestResultScreen({this.isAdmin}); + + @override + _TestResultScreenState createState() => _TestResultScreenState(); +} + +class _TestResultScreenState extends State { + TextEditingController searchCTRL = new TextEditingController(); + ScrollController? sc; + + bool _isInit = true; + // List _data = []; + + @override + void initState() { + sc = new ScrollController(); + + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + var testResults = + Provider.of(context, listen: false); + // testResults.resetFilters(); + testResults.setLoading(); + testResults.resetPageNumber(); + testResults.getTestResults().then((_) { + testResults.resetLoading(); + sc!.addListener(() { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.getTestResults(); + } + }); + + // setState(() { + // _isLoading = false; + // }); + }); + _isInit = false; + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + floatingActionButton: + TestResultFloatingButton(deviceBlockSize: _deviceBlockSize), + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, left: 20, right: 20, bottom: 60), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + // padding: EdgeInsets.only(top: 20, bottom: 40), + child: Text( + 'My Test Results', + // textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 6 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + ), + Spacer(), + InkWell( + onTap: () { + Navigator.of(context) + .popAndPushNamed(Routes.testFilterScreen); + }, + child: Container( + padding: EdgeInsets.all(7), + child: Icon( + FontAwesomeIcons.filter, + size: 7 * _deviceBlockSize, + ), + ), + ), + ], + ), + Consumer( + builder: (context, testResult, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + testResult.filters.id != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + labelID: testResult.filters.labelID, + testType: + testResult.filters.testType, + hospital: + testResult.filters.hospital, + username: + testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.labelID != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Label ID', + id: testResult.filters.id, + labelID: '', + testType: + testResult.filters.testType, + hospital: + testResult.filters.hospital, + username: + testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.testType != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Test Type', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: '', + hospital: + testResult.filters.hospital, + username: + testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.hospital != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Hospital', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: + testResult.filters.testType, + hospital: '', + username: + testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.userName != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Username', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: + testResult.filters.testType, + hospital: + testResult.filters.hospital, + username: '', + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.fDate != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'From Date', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: + testResult.filters.testType, + hospital: + testResult.filters.hospital, + username: + testResult.filters.userName, + fDate: '', + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.uDate != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Until Date', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: + testResult.filters.testType, + hospital: + testResult.filters.hospital, + username: + testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: '', + ) + : Container(), + ], + ), + ); + }, + ), + TestResultSearchBox( + searchCTRL: searchCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, testResults, _) { + return testResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) => + TestItemBox( + deviceBlockSize: _deviceBlockSize, + item: testResults.items![index], + ), + itemCount: testResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} + +class TestItemBox extends StatelessWidget { + final TestResultObject? item; + const TestItemBox({ + Key? key, + required double deviceBlockSize, + required this.item, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + // print(item.result); + final userData = Provider.of(context, listen: false).user; + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.testDetailsScreen, + arguments: item!.id, + ), + child: Card( + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 57 * _deviceBlockSize, + child: Text( + item!.name, + overflow: TextOverflow.ellipsis, + // style: TextStyle(fontSize: 20), + ), + ), + Container( + width: 57 * _deviceBlockSize, + child: Text( + item!.hospital, + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + ), + SizedBox( + height: 15, + ), + item!.result == 'Accepted' + ? Text( + 'Accepted', + style: TextStyle( + color: kLightBlue, + ), + ) + : Text( + 'Rejected', + style: TextStyle( + color: kPink, + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text(item!.date), + SizedBox( + height: 15, + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Test?'), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of( + context, + listen: false) + .removeTestResult(item!.id); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: Icon( + Icons.delete, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 7.5, + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed( + Routes.testDetailsScreen, + arguments: item!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ) + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/TestPages/test_scan_screen.dart b/lib/pages/TestPages/test_scan_screen.dart new file mode 100644 index 0000000..5e576ae --- /dev/null +++ b/lib/pages/TestPages/test_scan_screen.dart @@ -0,0 +1,187 @@ +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../providers/connectivity.dart'; +import '../../widgets/Global/internet_error.dart'; + +class TestScanScreen extends StatefulWidget { + // static const route = '/TestScanScreen'; + @override + State createState() { + return _TestScanScreenState(); + } +} + +class _TestScanScreenState extends State { + String testCode = ""; + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Test Results'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Test Result?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, + ), + ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Test Result Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + textAlign: TextAlign.center, + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/TestResult/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; + } + return null; + }, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Test Result ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, + ), + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/TestResult/${idCTRL.text}', + ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.black87], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} diff --git a/lib/pages/test_verify_screen.dart b/lib/pages/TestPages/test_verify_screen.dart similarity index 55% rename from lib/pages/test_verify_screen.dart rename to lib/pages/TestPages/test_verify_screen.dart index 2b1a570..a0a1e8f 100644 --- a/lib/pages/test_verify_screen.dart +++ b/lib/pages/TestPages/test_verify_screen.dart @@ -1,515 +1,466 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/test_result_models.dart'; -import '../providers/auth.dart'; -import '../providers/test_results.dart'; -import '../widgets/TestResultScreens/Main/search_box.dart'; - -class TestVerifyScreen extends StatefulWidget { - // static const route = '/TestVerifyScreen'; - // final bool isAdmin; - - // TestVerifyScreen({this.isAdmin}); - - @override - _TestVerifyScreenState createState() => _TestVerifyScreenState(); -} - -class _TestVerifyScreenState extends State { - TextEditingController searchCTRL = new TextEditingController(); - ScrollController sc; - - bool _isInit = true; - // List _data = []; - - @override - void initState() { - sc = new ScrollController(); - - super.initState(); - } - - @override - void didChangeDependencies() { - if (_isInit) { - // setState(() { - // _isLoading = true; - // }); - var testResults = - Provider.of(context, listen: false); - testResults.setLoading(); - testResults.resetFilters(); - testResults.resetPageNumber(); - testResults.getTestResults().then((_) { - testResults.resetLoading(); - sc.addListener(() { - if (sc.position.pixels == sc.position.maxScrollExtent && - searchCTRL.text == '') { - var labelProviderObject = - Provider.of(context, listen: false); - labelProviderObject.getTestResults(); - } - }); - - // setState(() { - // _isLoading = false; - // }); - }); - _isInit = false; - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final userData = Provider.of(context, listen: false).user; - - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Home'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Padding( - padding: EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 60), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - // padding: EdgeInsets.only(top: 20, bottom: 40), - child: Text( - 'TESTS TO VERIFY', - // textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 6 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 2, - ), - ), - ), - // Spacer(), - // InkWell( - // onTap: () { - // Navigator.of(context) - // .popAndPushNamed(Routes.testFilterScreen); - // }, - // child: Container( - // padding: EdgeInsets.all(7), - // child: Icon( - // FontAwesomeIcons.filter, - // size: 7 * _deviceBlockSize, - // ), - // ), - // ), - ], - ), - SizedBox( - height: 20, - ), - // Consumer( - // builder: (context, testResult, _) { - // return Container( - // height: 50, - // child: ListView( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // children: [ - // InkWell( - // onTap: () { - // Navigator.of(context) - // .popAndPushNamed(Routes.testFilterScreen); - // }, - // child: Chip( - // backgroundColor: Colors.black, - // label: Text( - // 'Filters', - // style: TextStyle( - // color: Colors.white, - // ), - // ), - // deleteIcon: Icon( - // FontAwesomeIcons.filter, - // color: Colors.white, - // size: 4 * _deviceBlockSize, - // ), - // onDeleted: () { - // Navigator.of(context) - // .popAndPushNamed(Routes.testFilterScreen); - // }, - // ), - // ), - // testResult.filters.id != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'ID', - // id: '', - // labelID: testResult.filters.labelID, - // testType: testResult.filters.testType, - // hospital: testResult.filters.hospital, - // username: testResult.filters.userName, - // fDate: testResult.filters.fDate, - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.labelID != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'Label ID', - // id: testResult.filters.id, - // labelID: '', - // testType: testResult.filters.testType, - // hospital: testResult.filters.hospital, - // username: testResult.filters.userName, - // fDate: testResult.filters.fDate, - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.testType != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'Test Type', - // id: testResult.filters.id, - // labelID: testResult.filters.labelID, - // testType: '', - // hospital: testResult.filters.hospital, - // username: testResult.filters.userName, - // fDate: testResult.filters.fDate, - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.hospital != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'Hospital', - // id: testResult.filters.id, - // labelID: testResult.filters.labelID, - // testType: testResult.filters.testType, - // hospital: '', - // username: testResult.filters.userName, - // fDate: testResult.filters.fDate, - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.userName != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'Username', - // id: testResult.filters.id, - // labelID: testResult.filters.labelID, - // testType: testResult.filters.testType, - // hospital: testResult.filters.hospital, - // username: '', - // fDate: testResult.filters.fDate, - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.fDate != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'From Date', - // id: testResult.filters.id, - // labelID: testResult.filters.labelID, - // testType: testResult.filters.testType, - // hospital: testResult.filters.hospital, - // username: testResult.filters.userName, - // fDate: '', - // uDate: testResult.filters.uDate, - // ) - // : Container(), - // testResult.filters.uDate != '' - // ? TestResultChip( - // deviceBlockSize: _deviceBlockSize, - // label: 'Until Date', - // id: testResult.filters.id, - // labelID: testResult.filters.labelID, - // testType: testResult.filters.testType, - // hospital: testResult.filters.hospital, - // username: testResult.filters.userName, - // fDate: testResult.filters.fDate, - // uDate: '', - // ) - // : Container(), - // ], - // ), - // ); - // }, - // ), - TestResultSearchBox( - searchCTRL: searchCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, testResults, _) { - return testResults.isloading - ? Center( - child: CircularProgressIndicator(), - ) - : ListView.builder( - controller: sc, - itemBuilder: (context, index) => - (testResults.items[index].verified == 'None' && - userData['roles'] - .contains('Supervisor')) || - userData['roles'].contains('Admin') - ? TestItemBox( - deviceBlockSize: _deviceBlockSize, - item: testResults.items[index], - id: testResults.items[index].id, - userData: userData, - ) - : Container(), - // Column( - // children: [ - // Text(testResults.items[index].name), - // Text(testResults.items[index].isVerified.toString()), - // Text(testResults.items[index].hospital), - // Text(testResults.items[index].date), - - // ], - // ), - // ChangeNotifierProvider.value( - // value: testResults.items[index], - // child: ResultCard( - // isAdmin: widget.isAdmin, - // ), - // ), - itemCount: testResults.items.length, - shrinkWrap: true, - ); - }, - ), - ), - ], - ), - ), - ), - ); - } -} - -class TestItemBox extends StatelessWidget { - final TestResultObject item; - const TestItemBox({ - Key key, - @required String id, - @required double deviceBlockSize, - @required this.item, - @required this.userData, - }) : _deviceBlockSize = deviceBlockSize, - // _id = id, - super(key: key); - final Map userData; - final double _deviceBlockSize; - // final String _id; - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - Routes.testDetailsScreen, - arguments: item.id, - ), - child: Card( - child: Container( - padding: EdgeInsets.all(10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 57 * _deviceBlockSize, - child: Text( - item.name, - overflow: TextOverflow.ellipsis, - // style: TextStyle(fontSize: 20), - ), - ), - Container( - width: 57 * _deviceBlockSize, - child: Text( - item.hospital, - style: TextStyle( - color: Colors.grey, - fontSize: 3 * _deviceBlockSize, - ), - ), - ), - SizedBox( - height: 15, - ), - item.verified == 'None' - ? Text( - 'Awaiting Verification', - style: TextStyle(color: Colors.orange), - ) - : item.verified == 'Verified' - ? Text( - 'Verified', - style: TextStyle( - color: Colors.blueAccent, - ), - ) - : Text( - 'Rejected', - style: TextStyle( - color: Colors.red, - ), - ), - ], - ), - Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text(item.date), - SizedBox( - height: 15, - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Verify'), - content: Text( - 'Are you sure for verify this test?'), - actions: [ - TextButton( - onPressed: () async { - Provider.of( - context) - .changeVerification( - item.id, 'Verified') - .then((result) { - if (result) { - print('true'); - } - Navigator.of(ctx).pop(); - Navigator.of(context).popAndPushNamed( - Routes.testVerifyScreen); - }); - }, - child: Text('Yes'), - ), - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('No'), - ), - ], - ), - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color.fromRGBO(0, 190, 190, 1), - ), - child: Icon( - Icons.check, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - SizedBox( - width: 3, - ), - InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Reject'), - content: Text( - 'Are you sure for reject this test?'), - actions: [ - TextButton( - onPressed: () async { - await Provider.of( - context) - .changeVerification( - item.id, 'NotVerified') - .then((result) { - if (result) { - print('true'); - } - Navigator.of(ctx).pop(); - Navigator.of(context).popAndPushNamed( - Routes.testVerifyScreen); - }); - }, - child: Text('Yes'), - ), - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('No'), - ), - ], - ), - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.close, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ), - SizedBox( - width: _deviceBlockSize, - ), - ], - ) - ], - ), - ], - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; +import '../../models/test_result_models.dart'; +import '../../providers/auth.dart'; +import '../../providers/test_results.dart'; +import '../../widgets/TestResultScreens/Main/search_box.dart'; + +class TestVerifyScreen extends StatefulWidget { + // static const route = '/TestVerifyScreen'; + // final bool isAdmin; + + // TestVerifyScreen({this.isAdmin}); + + @override + _TestVerifyScreenState createState() => _TestVerifyScreenState(); +} + +class _TestVerifyScreenState extends State { + TextEditingController searchCTRL = new TextEditingController(); + ScrollController? sc; + + bool _isInit = true; + // List _data = []; + + @override + void initState() { + sc = new ScrollController(); + + super.initState(); + } + + @override + void didChangeDependencies() { + if (_isInit) { + // setState(() { + // _isLoading = true; + // }); + var testResults = + Provider.of(context, listen: false); + testResults.setLoading(); + testResults.resetFilters(); + testResults.resetPageNumber(); + testResults.getTestResults().then((_) { + testResults.resetLoading(); + sc!.addListener(() { + if (sc!.position.pixels == sc!.position.maxScrollExtent && + searchCTRL.text == '') { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.getTestResults(); + } + }); + + // setState(() { + // _isLoading = false; + // }); + }); + _isInit = false; + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Home'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Padding( + padding: EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 60), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + // padding: EdgeInsets.only(top: 20, bottom: 40), + child: Text( + 'Tests To Verify', + // textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 6 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + ), + ], + ), + Consumer( + builder: (context, testResult, _) { + return Container( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + children: [ + testResult.filters.id != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'ID', + id: '', + labelID: testResult.filters.labelID, + testType: testResult.filters.testType, + hospital: testResult.filters.hospital, + username: testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.labelID != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Label ID', + id: testResult.filters.id, + labelID: '', + testType: testResult.filters.testType, + hospital: testResult.filters.hospital, + username: testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.testType != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Test Type', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: '', + hospital: testResult.filters.hospital, + username: testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.hospital != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Hospital', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: testResult.filters.testType, + hospital: '', + username: testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.userName != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Username', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: testResult.filters.testType, + hospital: testResult.filters.hospital, + username: '', + fDate: testResult.filters.fDate, + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.fDate != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'From Date', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: testResult.filters.testType, + hospital: testResult.filters.hospital, + username: testResult.filters.userName, + fDate: '', + uDate: testResult.filters.uDate, + ) + : Container(), + testResult.filters.uDate != '' + ? TestResultChip( + deviceBlockSize: _deviceBlockSize, + label: 'Until Date', + id: testResult.filters.id, + labelID: testResult.filters.labelID, + testType: testResult.filters.testType, + hospital: testResult.filters.hospital, + username: testResult.filters.userName, + fDate: testResult.filters.fDate, + uDate: '', + ) + : Container(), + ], + ), + ); + }, + ), + TestResultSearchBox( + searchCTRL: searchCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, testResults, _) { + return testResults.isloading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) => + (testResults.items![index].verified == 'None' && + userData['roles'] + .contains('Supervisor')) || + userData['roles'].contains('Admin') + ? TestItemBox( + deviceBlockSize: _deviceBlockSize, + item: testResults.items![index], + id: testResults.items![index].id, + userData: userData, + ) + : Container(), + itemCount: testResults.items?.length, + shrinkWrap: true, + ); + }, + ), + ), + ], + ), + ), + ), + ); + } +} + +class TestItemBox extends StatelessWidget { + final TestResultObject item; + const TestItemBox({ + Key? key, + required String id, + required double deviceBlockSize, + required this.item, + required this.userData, + }) : _deviceBlockSize = deviceBlockSize, + // _id = id, + super(key: key); + final Map userData; + final double _deviceBlockSize; + // final String _id; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.testDetailsScreen, + arguments: item.id, + ), + child: Card( + child: Container( + padding: EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 57 * _deviceBlockSize, + child: Text( + item.name, + overflow: TextOverflow.ellipsis, + // style: TextStyle(fontSize: 20), + ), + ), + Container( + width: 57 * _deviceBlockSize, + child: Text( + item.hospital, + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + ), + SizedBox( + height: 15, + ), + item.verified == 'None' + ? Text( + 'Awaiting Verification', + style: TextStyle(color: Colors.orange), + ) + : item.verified == 'Verified' + ? Text( + 'Verified', + style: TextStyle( + color: kBlue, + ), + ) + : Text( + 'Rejected', + style: TextStyle( + color: kPink, + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text(item.date), + SizedBox( + height: 15, + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Verify'), + content: Text( + 'Are you sure for verify this test?'), + actions: [ + TextButton( + onPressed: () async { + Provider.of( + context, + listen: false) + .changeVerification( + item.id, 'Verified') + .then((result) { + if (result) { + print('true'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.testVerifyScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 10 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kBlue, + ), + child: Icon( + Icons.check, + size: 6 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 3, + ), + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Reject'), + content: Text( + 'Are you sure for reject this test?'), + actions: [ + TextButton( + onPressed: () async { + await Provider.of( + context, + listen: false) + .changeVerification( + item.id, 'NotVerified') + .then((result) { + if (result) { + print('true'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.testVerifyScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 10 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kPink, + ), + child: Icon( + Icons.close, + size: 6 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + SizedBox( + width: _deviceBlockSize, + ), + ], + ) + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/cycle_add_screen.dart b/lib/pages/cycle_add_screen.dart deleted file mode 100644 index 1ad572a..0000000 --- a/lib/pages/cycle_add_screen.dart +++ /dev/null @@ -1,291 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/cycles_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/cycles.dart'; -import '../widgets/CycleScreens/Add/add_label_box.dart'; -import '../widgets/CycleScreens/Add/date_picker.dart'; -import '../widgets/CycleScreens/Add/save_button.dart'; -import '../widgets/Global/internet_error.dart'; - -class CycleAddScreen extends StatefulWidget { - // static const route = '/CycleAddScreen'; - - @override - _CycleAddScreenState createState() => _CycleAddScreenState(); -} - -class _CycleAddScreenState extends State { - final _cycleNumberFocusNode = FocusNode(); - final _descriptionFocosNode = FocusNode(); - TextEditingController descriptionCTRL = new TextEditingController(); - TextEditingController cycleNumberCTRL = new TextEditingController(); - TextEditingController striizerIdCTRL = new TextEditingController(); - TextEditingController dateCTRL = new TextEditingController(); - // String initialLabelValue = ''; - DateTime dateTimeFrom; - // String dateValue; - final _form = GlobalKey(); - - // List labelVals = []; - // List labelValues = []; - bool isInit = true; - CycleFilterObject filters; - - List labelsCTRL = [TextEditingController()]; - int curLabelVal = 1; - @override - void initState() { - descriptionCTRL.text = ''; - cycleNumberCTRL.text = ''; - dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); - striizerIdCTRL.text = ''; - // dateValue = DateFormat('y-M-d').format(DateTime.now()); - super.initState(); - } - - @override - void didChangeDependencies() async { - if (isInit) { - // var _id = ModalRoute.of(context).settings.arguments; - var cycleProviderObject = Provider.of(context); - cycleProviderObject.resetLabelVals(); - cycleProviderObject.getLabelFilters().then( - (result) { - setState( - () { - // labelValues = - // filters.hospital == '' ? labelVals[0] : filters.hospital; - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.cycleResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Cycles'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.cycleResultScreen), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'ADD A CYCLE', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - - TextFormField( - validator: (val) { - if (val.isEmpty) { - return 'Strilizer ID required!'; - } - return null; - }, - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Strilizer ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_cycleNumberFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (val) { - if (val.isEmpty) { - return 'Cycle number required!'; - } - return null; - }, - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_descriptionFocosNode); - }, - ), - - SizedBox( - height: 20, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 10), - child: Text( - 'LABELS INCLUDED', - style: TextStyle( - color: Colors.deepOrange, - letterSpacing: 2, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - Consumer( - builder: (ctx, cycleProvider, _) => - ListView.builder( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (ctx, index) => CycleAddLabelBox( - deviceBlockSize: _deviceBlockSize, - labelValues: - cycleProvider.labelValues[index], - labelVals: cycleProvider.labelVals, - initialLabelValue: - cycleProvider.initialLabelValue, - index: index, - ), - itemCount: cycleProvider.labelValues.length, - ), - ), - - CycleAddDatePicker( - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize), - SizedBox( - height: 30, - ), - TextFormField( - controller: descriptionCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Description', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.multiline, - focusNode: _descriptionFocosNode, - minLines: 1, - maxLines: 5, - ), - SizedBox( - height: 70, - ), - CycleAddSaveButton( - form: _form, - labelValues: Provider.of( - context, - listen: false) - .labelValues, - cycleNumberCTRL: cycleNumberCTRL, - dateValue: dateCTRL.text, - descriptionCTRL: descriptionCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - - // DropDownBox(values: ['Washer ID']), - ], - ), - ), - ) - : ConnectionErrorBox(); - }), - ), - ), - ); - } -} diff --git a/lib/pages/cycle_filter_screen.dart b/lib/pages/cycle_filter_screen.dart deleted file mode 100644 index f078850..0000000 --- a/lib/pages/cycle_filter_screen.dart +++ /dev/null @@ -1,330 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/cycles_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/cycles.dart'; -import '../widgets/CycleScreens/Filter/date_picker.dart'; -import '../widgets/CycleScreens/Filter/save_button.dart'; -import '../widgets/CycleScreens/Filter/selector_box.dart'; -import '../widgets/Global/internet_error.dart'; - -class CycleFilterScreen extends StatefulWidget { - // static const route = '/CycleFilterScreen'; - - @override - _CycleFilterScreenState createState() => _CycleFilterScreenState(); -} - -class _CycleFilterScreenState extends State { - final _cycleNumberFocusNode = FocusNode(); - final _strilizerIdFocusNode = FocusNode(); - TextEditingController cycleIdCTRL = new TextEditingController(); - TextEditingController cycleNumberCTRL = new TextEditingController(); - TextEditingController striizerIdCTRL = new TextEditingController(); - TextEditingController hospitalCTRL = new TextEditingController(); - - TextEditingController dateCTRL = new TextEditingController(); - DateTime dateTimeFrom; - // String dateValue; - - List> hospitalVals = []; - // String curhospitalVal; - bool isInit = true; - CycleFilterObject filters; - @override - void initState() { - filters = Provider.of(context, listen: false).filters; - cycleIdCTRL.text = filters.id; - cycleNumberCTRL.text = filters.cycleNumber; - // dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); - dateCTRL.text = ''; - striizerIdCTRL.text = filters.sterilizerId; - // dateValue = DateFormat('y-M-d').format(DateTime.now()); - super.initState(); - } - - @override - void didChangeDependencies() async { - if (isInit) { - // var _id = ModalRoute.of(context).settings.arguments; - await Provider.of(context, listen: false) - .getHospitalsFilters() - .then( - (result) { - setState( - () { - hospitalVals = [ - {'id': '', 'name': ''} - ]; - for (var hospital in result) { - hospitalVals.add(hospital); - } - filters.hospital == '' - ? hospitalCTRL.text = hospitalVals[0]['name'] - : hospitalVals.forEach( - //id convert to name - (hospital) { - if (hospital['id'] == filters.hospital) { - hospitalCTRL.text = hospital['name']; - } - }, - ); - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.cycleResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Cycles'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.cycleResultScreen), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: cycleIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_cycleNumberFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - cycleIdCTRL.text = result; - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_strilizerIdFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextField( - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Strilizer ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _strilizerIdFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.done, - ), - SizedBox( - height: 20, - ), - CycleFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 20, - ), - CycleFilterDatePicker( - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 70, - ), - CycleFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - cycleIdCTRL: cycleIdCTRL, - cycleNumberCTRL: cycleNumberCTRL, - striizerIdCTRL: striizerIdCTRL, - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }), - ), - ), - ); - } -} - -Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } -} diff --git a/lib/pages/cycle_result_screen.dart b/lib/pages/cycle_result_screen.dart deleted file mode 100644 index ad13c07..0000000 --- a/lib/pages/cycle_result_screen.dart +++ /dev/null @@ -1,264 +0,0 @@ -import '../config/routes.dart'; - -import '../providers/connectivity.dart'; -import '../widgets/CycleScreens/Result/banner.dart'; -import '../widgets/CycleScreens/Result/data_box.dart'; -import '../widgets/CycleScreens/Result/filter_objects.dart'; -import '../widgets/CycleScreens/Result/search_box.dart'; -import '../widgets/Global/internet_error.dart'; - -import '../providers/cycles.dart'; - -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -class CycleResultScreen extends StatefulWidget { - // static const route = '/CycleResultScreen'; - final bool isAdmin; - - CycleResultScreen({this.isAdmin}); - - @override - _CycleResultScreenState createState() => _CycleResultScreenState(); -} - -class _CycleResultScreenState extends State { - bool _isInit = true; - ScrollController sc; - TextEditingController searchCTRL = new TextEditingController(); - - @override - void initState() { - sc = new ScrollController(); - super.initState(); - } - - @override - void didChangeDependencies() { - if (_isInit) { - var testResults = Provider.of(context); - testResults.setLoading(); - testResults.resetPageNumber(); - testResults.getCycleResults().then((_) { - testResults.resetLoading(); - sc.addListener( - () { - if (sc.position.pixels == sc.position.maxScrollExtent && - searchCTRL.text == '') { - var testResults = Provider.of(context); - testResults.getCycleResults(); - } - }, - ); - }); - } - _isInit = false; - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - floatingActionButton: CycleResultFloatingButton( - deviceBlockSize: _deviceBlockSize, - ), - appBar: AppBar( - titleSpacing: -10, - title: Text('Home'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? Padding( - padding: - EdgeInsets.only(top: 20, right: 20, bottom: 60, left: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CycleResultBanner(deviceBlockSize: _deviceBlockSize), - SizedBox( - height: 10, - ), - Consumer(builder: (ctx, cycle, _) { - return Container( - height: 50, - child: ListView( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - children: [ - CycleFilterBaner( - deviceBlockSize: _deviceBlockSize), - cycle.filters.id != '' - ? CycleFilterChip( - deviceBlockSize: _deviceBlockSize, - label: 'ID', - id: '', - cycleNumber: cycle.filters.cycleNumber, - sterilizerId: cycle.filters.sterilizerId, - hospital: cycle.filters.hospital, - date: cycle.filters.date, - ) - : Container(), - cycle.filters.cycleNumber != '' - ? CycleFilterChip( - deviceBlockSize: _deviceBlockSize, - label: 'Cycle Number', - id: cycle.filters.id, - cycleNumber: '', - sterilizerId: cycle.filters.sterilizerId, - hospital: cycle.filters.hospital, - date: cycle.filters.date, - ) - : Container(), - cycle.filters.sterilizerId != '' - ? CycleFilterChip( - deviceBlockSize: _deviceBlockSize, - label: 'Sterilizer ID', - id: cycle.filters.id, - cycleNumber: cycle.filters.cycleNumber, - sterilizerId: '', - hospital: cycle.filters.hospital, - date: cycle.filters.date, - ) - : Container(), - cycle.filters.hospital != '' - ? CycleFilterChip( - deviceBlockSize: _deviceBlockSize, - label: 'Hospital', - id: cycle.filters.id, - cycleNumber: cycle.filters.cycleNumber, - sterilizerId: cycle.filters.sterilizerId, - hospital: '', - date: cycle.filters.date, - ) - : Container(), - cycle.filters.date != '' - ? CycleFilterChip( - deviceBlockSize: _deviceBlockSize, - label: 'Date', - id: cycle.filters.id, - cycleNumber: cycle.filters.cycleNumber, - sterilizerId: cycle.filters.sterilizerId, - hospital: cycle.filters.hospital, - date: '', - ) - : Container(), - ], - ), - ); - }), - CycleResultSearchBox( - searchCTRL: searchCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, cycleResults, _) { - return cycleResults.isloading - ? Center( - child: CircularProgressIndicator(), - ) - : ListView.builder( - controller: sc, - itemBuilder: (context, index) { - String labels = ''; - for (var label - in cycleResults.items[index].label) { - labels += label; - labels += ' , '; - } - labels = labels.substring(0, - labels.length - 3); // remove extra , - return CycleItemBox( - deviceBlockSize: _deviceBlockSize, - item: cycleResults.items[index], - labels: labels, - ); - }, - itemCount: cycleResults.items.length, - shrinkWrap: true, - ); - }, - ), - ), - ], - ), - ) - : ConnectionErrorBox(); - }), - ), - ); - } -} - -class CycleResultFloatingButton extends StatelessWidget { - const CycleResultFloatingButton({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed(Routes.cycleScanScreen); - }, - child: Container( - padding: EdgeInsets.all(2.5 * _deviceBlockSize), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 7.1 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - SizedBox( - width: 2 * _deviceBlockSize, - ), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen); - }, - child: Container( - padding: EdgeInsets.all(_deviceBlockSize), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color.fromRGBO(0, 190, 190, 1), - ), - child: Icon( - Icons.add, - size: 10 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ); - } -} diff --git a/lib/pages/cycle_scan_screen.dart b/lib/pages/cycle_scan_screen.dart deleted file mode 100644 index c2da146..0000000 --- a/lib/pages/cycle_scan_screen.dart +++ /dev/null @@ -1,220 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class CycleScanScreen extends StatefulWidget { - // static const route = '/cycleScanScreen'; - @override - State createState() { - return _CycleScanScreenState(); - } -} - -class _CycleScanScreenState extends State { - String testCode = ""; - TextEditingController idCTRL = new TextEditingController(); - final _form = GlobalKey(); - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - titleSpacing: -10, - title: Text('CSSD'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'LOOKING FOR A CYCLE?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), - ), - ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Cycle Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Cycle/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a cycle ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - ), - ), - SizedBox( - height: 40, - ), - Divider( - color: Colors.black, - thickness: 3, - ), - SizedBox( - height: 30, - ), - InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - launch( - 'https://cssd-doc.com/Show/Cycle/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - margin: - EdgeInsets.only(bottom: 50, left: 20, right: 20), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.red, Colors.orange], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'GO!', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ), - ], - ) - : ConnectionErrorBox(); - }), - ), - ); - } - - Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } - } -} diff --git a/lib/pages/home_screen.dart b/lib/pages/home_screen.dart index 4499903..d538108 100644 --- a/lib/pages/home_screen.dart +++ b/lib/pages/home_screen.dart @@ -1,462 +1,484 @@ -import 'package:barcode_scan2/platform_wrapper.dart'; -import 'package:double_back_to_close_app/double_back_to_close_app.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_phoenix/flutter_phoenix.dart'; -import 'package:provider/provider.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../providers/auth.dart'; -import '../providers/connectivity.dart'; -import '../widgets/Global/drawer.dart'; -import '../widgets/Global/internet_error.dart'; -import 'cycle_result_screen.dart'; -import 'label_result_screen.dart'; -import 'my_info_screen.dart'; -import 'test_result_screen.dart'; -import 'test_verify_screen.dart'; - -class HomePage extends StatelessWidget { - // 09338736511 - - // static const route = '/HomeScreen'; - @override - Widget build(BuildContext context) { - final userData = Provider.of(context, listen: false).user; - - // print(userData['roles']); - return SafeArea( - child: Scaffold( - // resizeToAvoidBottomPadding: false, - drawer: Selector( - builder: (ctx, value, _) => - value != 'offline' ? AppDrawer() : Container(), - selector: (_, connctivity) => connctivity.conStatus, - ) - // Consumer(builder: (ct, connection, _) { - // return connection.conStatus != 'offline' ? AppDrawer() : Container(); - // }) - , - appBar: AppBar( - centerTitle: true, - title: Text('CSSD'), - actions: [ - Padding( - padding: const EdgeInsets.only(right: 10.0), - child: IconButton( - icon: Icon( - Icons.power_settings_new, - ), - onPressed: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('LogOut'), - content: Text('Are you sure for logout?'), - actions: [ - TextButton( - child: Text('Yes'), - onPressed: () { - Navigator.of(ctx).pop(); - Provider.of(context, listen: false).logout(); - Phoenix.rebirth(context); - }, - ), - TextButton( - child: Text('No'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ); - }, - ), - ) - ], - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? DoubleBackToCloseApp( - snackBar: SnackBar( - duration: Duration(seconds: 2), - backgroundColor: Colors.black, - content: Text( - 'Double tap for exit . . .', - style: TextStyle(color: Colors.white), - ), - ), - child: Container( - margin: EdgeInsets.only( - top: 0, bottom: 10, left: 20, right: 20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(top: 20, bottom: 10), - child: Text( - 'WELCOME HOME', - style: TextStyle( - color: Colors.black, - fontSize: 20, - letterSpacing: 3.5, - fontWeight: FontWeight.w700, - ), - ), - ), - SelectionItem( - startColor: Color(0xFFFCB8A2), - endColor: Color(0xFFFFECD2), - firstLine: 'My INFO', - secondLine: 'List, Details & Add a one', - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return Consumer( - builder: (ctx, auth, _) { - return MyInfoScreen(); - }, - ); - }, - ), - ), - ), - SelectionItem( - startColor: Color(0xFFD5F5FD), - endColor: Color(0xFFE9FFF7), - firstLine: 'TEST RESULTS', - secondLine: 'List, Details & Add a one', - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return Consumer( - builder: (ctx, auth, _) { - return TestResultScreen(); - }, - ); - }, - ), - ), - // MyTestResult( - // isAdmin: false, - // ), - ), - SelectionItem( - startColor: Color(0xFFE2D2C4), - endColor: Color(0xFFFAF7F5), - firstLine: 'LABELS', - secondLine: 'List, Details & Add a one', - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return Consumer( - builder: (ctx, auth, _) { - return LabelResultScreen(); - }, - ); - }, - ), - ), - ), - SelectionItem( - startColor: Color(0xFFA7CCE1), - endColor: Color(0xFFECF7ED), - firstLine: 'CYCLES', - secondLine: 'List, Details & Add a one', - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return Consumer( - builder: (ctx, auth, _) { - return CycleResultScreen(); - }, - ); - }, - ), - ), - ), - // SelectionItem( - // startColor: Color(0xFFA7CCE1), - // endColor: Color(0xFFECF7ED), - // firstLine: 'image', - // secondLine: 'image', - // onTap: CaptureImage(), - // ), - userData['roles'].contains('User') - ? Container() - : SelectionItem( - startColor: Color(0xFFA7CCE1), - endColor: Color(0xFFECF7ED), - firstLine: 'TEST TO VERIFY', - secondLine: 'Verify and reject Test Results', - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return Consumer( - builder: (ctx, auth, _) { - return TestVerifyScreen(); - }, - ); - }, - ), - ), - ), - BarcodeSelectionItem(), - ], - ), - ), - ) - : ConnectionErrorBox(); - }, - ), - ), - ); - } -} - -Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent; - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } -} - -class SelectionItem extends StatelessWidget { - final Color startColor; - final Color endColor; - final String firstLine; - final String secondLine; - final Function onTap; - - SelectionItem( - {this.startColor, - this.endColor, - this.firstLine, - this.secondLine, - this.onTap}); - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return Container( - margin: EdgeInsets.symmetric(vertical: 10), - padding: EdgeInsets.symmetric(vertical: 5), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [startColor, endColor], - ), - borderRadius: BorderRadius.all( - Radius.circular(3), - ), - ), - child: InkWell( - splashColor: Colors.red, - onTap: onTap, - child: ListTile( - title: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - firstLine, - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3.5, - ), - ), - Text( - secondLine, - style: TextStyle( - color: Colors.grey, - fontSize: 3.5 * _deviceBlockSize, - ), - ), - ], - ), - trailing: Icon( - Icons.arrow_forward_ios, - color: Colors.black, - ), - ), - // Column( - // children: [ - // ListTile( - // title: Text( - // firstLine, - // textAlign: TextAlign.start, - // style: TextStyle(color: Colors.black), - // ), - // ), - // ListTile( - // title: Text( - // secondLine, - // style: TextStyle(color: Colors.black, fontSize: 20), - // ), - // trailing: Icon( - // Icons.arrow_forward_ios, - // color: Colors.black, - // ), - // ), - // ], - // ), - ), - ); - } -} - -class BarcodeSelectionItem extends StatelessWidget { - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return Container( - margin: EdgeInsets.symmetric(vertical: 10), - padding: EdgeInsets.symmetric(vertical: 5), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.black, Colors.black87], - ), - borderRadius: BorderRadius.all( - Radius.circular(3), - ), - ), - child: InkWell( - splashColor: Colors.red, - onTap: () => scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - showDialog( - context: context, - builder: (_) => AlertDialog( - title: Text( - 'نتیجه ی اسکن', - textDirection: TextDirection.rtl, - textAlign: TextAlign.right, - style: TextStyle( - fontSize: 2.75 * _deviceBlockSize, - ), - ), - content: Text( - result, - textDirection: TextDirection.rtl, - style: TextStyle( - fontSize: 4 * _deviceBlockSize, - ), - ), - actions: [ - TextButton( - onPressed: () async { - await launch(result); - Navigator.of(context).pop(); - }, - child: Text( - 'بازکردن در مرورگر', - style: TextStyle( - fontFamily: 'montserrat', - ), - ), - ) - ], - ), - ); - } - }, - ), - child: ListTile( - title: Row( - children: [ - Icon( - Icons.qr_code_scanner, - color: Colors.white, - size: 8 * _deviceBlockSize, - ), - SizedBox( - width: 2 * _deviceBlockSize, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'SCANNER', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3.5, - ), - ), - Text( - 'Scan a Bar or QR code', - style: TextStyle( - color: Colors.white, - fontSize: 3.5 * _deviceBlockSize, - ), - ), - ], - ) - ], - ), - trailing: Icon( - Icons.arrow_forward_ios, - color: Colors.white, - ), - ), - // Column( - // children: [ - // ListTile( - // title: Text( - // firstLine, - // textAlign: TextAlign.start, - // style: TextStyle(color: Colors.black), - // ), - // ), - // ListTile( - // title: Text( - // secondLine, - // style: TextStyle(color: Colors.black, fontSize: 20), - // ), - // trailing: Icon( - // Icons.arrow_forward_ios, - // color: Colors.black, - // ), - // ), - // ], - // ), - ), - ); - } -} +import 'package:barcode_scan2/platform_wrapper.dart'; +import 'package:cssd/config/colors.dart'; +import 'package:cssd/pages/ItemPages/item_result_screen.dart'; +import 'package:cssd/pages/MyItemsPages/Result/my_items_result_screen.dart'; +import 'package:cssd/pages/MyPackagesPages/Result/my_packages_result_screen.dart'; +import 'package:cssd/pages/PackagePages/package_result_screen.dart'; +import 'package:double_back_to_close_app/double_back_to_close_app.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_phoenix/flutter_phoenix.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../providers/auth.dart'; +import '../providers/connectivity.dart'; +import '../widgets/Global/drawer.dart'; +import '../widgets/Global/internet_error.dart'; +import 'CyclePages/cycle_result_screen.dart'; +import 'LabelPages/label_result_screen.dart'; +import 'my_info_screen.dart'; +import 'TestPages/test_result_screen.dart'; +import 'TestPages/test_verify_screen.dart'; + +class HomePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return SafeArea( + child: Scaffold( + drawer: Selector( + builder: (ctx, value, _) => + value != 'offline' ? AppDrawer() : Container(), + selector: (_, connectivity) => connectivity.conStatus, + ), + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + backgroundColor: Colors.black, + actions: [ + Padding( + padding: const EdgeInsets.only(right: 10.0), + child: IconButton( + icon: Icon( + Icons.power_settings_new, + ), + onPressed: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('LogOut'), + content: Text('Are you sure for logout?'), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(ctx).pop(); + Provider.of(context, listen: false).logout(); + Phoenix.rebirth(context); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + }, + ), + ) + ], + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? DoubleBackToCloseApp( + snackBar: SnackBar( + duration: Duration(seconds: 2), + backgroundColor: Colors.black, + content: Text( + 'Double tap for exit . . .', + style: TextStyle(color: Colors.white), + ), + ), + child: Container( + margin: EdgeInsets.only( + top: 0, bottom: 10, left: 20, right: 20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(top: 20, bottom: 10), + child: Text( + 'WELCOME HOME', + style: TextStyle( + color: Colors.black, + fontSize: 20, + letterSpacing: 3.5, + fontWeight: FontWeight.w700, + ), + ), + ), + SelectionItem( + firstLine: 'MY INFO', + secondLine: 'Personal Details', + firstLineColor: Colors.black, + secondLineColor: Colors.grey, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return MyInfoScreen(); + }, + ); + }, + ), + ), + ), + SelectionItem( + firstLine: 'TEST RESULTS', + secondLine: 'List, Details & Add a one', + firstLineColor: Colors.black, + secondLineColor: Colors.grey, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return TestResultScreen(); + }, + ); + }, + ), + ), + ), + Divider( + height: 2, + ), + SelectionItem( + firstLine: 'LABELS', + secondLine: 'List, Details & Add a one', + firstLineColor: kLightBlue, + secondLineColor: kLightBlueSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return LabelResultScreen(); + }, + ); + }, + ), + ), + ), + SelectionItem( + firstLine: 'CYCLES', + secondLine: 'List, Details & Add a one', + firstLineColor: kPink, + secondLineColor: kPinkSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return CycleResultScreen(); + }, + ); + }, + ), + ), + ), + Divider( + height: 2, + ), + SelectionItem( + firstLine: 'PACKAGES', + secondLine: 'List, Details & Add a one', + firstLineColor: kPurple, + secondLineColor: kPurpleSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return PackageResultScreen(); + }, + ); + }, + ), + ), + ), + SelectionItem( + firstLine: 'MY PACKAGES', + secondLine: 'The Package that i possess', + firstLineColor: kDarkPurple, + secondLineColor: kDarkPurpleSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return MyPackagesResultScreen(); + }, + ); + }, + ), + ), + ), + Divider( + height: 2, + ), + SelectionItem( + firstLine: 'ITEMS', + secondLine: 'List, Details & Add a one', + firstLineColor: kBlue, + secondLineColor: kBlueSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return ItemResultScreen(); + }, + ); + }, + ), + ), + ), + SelectionItem( + firstLine: 'MY ITEMS', + secondLine: 'The Items that i possess', + firstLineColor: kDarkBlue, + secondLineColor: kDarkBlueSub, + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return MyItemsResultScreen(); + }, + ); + }, + ), + ), + ), + Divider(height: 2), + userData['roles']?.contains('User') ?? false + ? Container() + : SelectionItem( + firstLine: 'TEST TO VERIFY', + secondLine: 'Verify and reject Test Results', + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return Consumer( + builder: (ctx, auth, _) { + return TestVerifyScreen(); + }, + ); + }, + ), + ), + ), + BarcodeSelectionItem(), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), + ), + ); + } +} + +Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + try { + var id = barcode.rawContent; + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } +} + +class SelectionItem extends StatelessWidget { + final String? firstLine; + final String? secondLine; + final Color? firstLineColor; + final Color? secondLineColor; + final VoidCallback? onTap; + + SelectionItem({ + this.firstLine, + this.secondLine, + this.onTap, + this.firstLineColor, + this.secondLineColor, + }); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Container( + margin: EdgeInsets.symmetric(vertical: 10), + padding: EdgeInsets.symmetric(vertical: 5), + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.all( + Radius.circular(3), + ), + ), + child: InkWell( + splashColor: Colors.grey[350], + onTap: onTap, + child: ListTile( + title: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + firstLine!, + style: TextStyle( + color: firstLineColor, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3.5, + ), + ), + Text( + secondLine!, + style: TextStyle( + color: secondLineColor, + fontSize: 3.5 * _deviceBlockSize, + ), + ), + ], + ), + trailing: Icon( + Icons.arrow_forward_ios, + color: Colors.black, + ), + ), + ), + ); + } +} + +class BarcodeSelectionItem extends StatelessWidget { + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Container( + margin: EdgeInsets.symmetric(vertical: 10), + padding: EdgeInsets.symmetric(vertical: 5), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.black87], + ), + borderRadius: BorderRadius.all( + Radius.circular(3), + ), + ), + child: InkWell( + splashColor: Colors.red, + onTap: () => scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + showDialog( + context: context, + builder: (_) => AlertDialog( + title: Text( + 'نتیجه ی اسکن', + textDirection: TextDirection.rtl, + textAlign: TextAlign.right, + style: TextStyle( + fontSize: 2.75 * _deviceBlockSize, + ), + ), + content: Text( + result, + textDirection: TextDirection.rtl, + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + actions: [ + TextButton( + onPressed: () async { + await launch(result); + Navigator.of(context).pop(); + }, + child: Text( + 'بازکردن در مرورگر', + style: TextStyle( + fontFamily: 'montserrat', + ), + ), + ), + ], + ), + ); + } + }, + ), + child: ListTile( + title: Row( + children: [ + Icon( + Icons.qr_code_scanner, + color: Colors.white, + size: 8 * _deviceBlockSize, + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'SCANNER', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3.5, + ), + ), + Text( + 'Scan a Bar or QR code', + style: TextStyle( + color: Colors.white, + fontSize: 3.5 * _deviceBlockSize, + ), + ), + ], + ) + ], + ), + trailing: Icon( + Icons.arrow_forward_ios, + color: Colors.white, + ), + ), + ), + ); + } +} diff --git a/lib/pages/label_add_screen.dart b/lib/pages/label_add_screen.dart deleted file mode 100644 index f887d59..0000000 --- a/lib/pages/label_add_screen.dart +++ /dev/null @@ -1,281 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart' as DateEditor; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/connectivity.dart'; -import '../providers/labels.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/LabelScreens/Add/date_picker.dart'; -import '../widgets/LabelScreens/Add/save_button.dart'; -import '../widgets/LabelScreens/Add/selector_box.dart'; - -class LabelAddScreen extends StatefulWidget { - // static const route = '/LabelAddScreen'; - - @override - _LabelAddScreenState createState() => _LabelAddScreenState(); -} - -class _LabelAddScreenState extends State { - final _cycleNumberFocusNode = FocusNode(); - TextEditingController lotNumberCTRL = new TextEditingController(); - TextEditingController cycleNumberCTRL = new TextEditingController(); - TextEditingController striizerIdCTRL = new TextEditingController(); - TextEditingController sDateCTRL = new TextEditingController(); - TextEditingController eDateCTRL = new TextEditingController(); - TextEditingController packageCTRL = new TextEditingController(); - - DateTime dateTimeS; - // String sDateValue; - // String eDateValue; - - final _form = GlobalKey(); - - List> packageVals = []; - List packageValue = []; - bool isInit = true; - // CycleFilterObject filters; - - List labelsCTRL = [TextEditingController()]; - int curLabelVal = 1; - @override - void initState() { - sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - // sDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - // eDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - super.initState(); - } - - @override - void didChangeDependencies() async { - if (isInit) { - Provider.of(context, listen: false) - .getPackageFilters() - .then( - (result) { - setState( - () { - packageVals = result; - packageValue.add(result[0]['id']); - packageValue.add(result[0]['name']); - packageCTRL.text = result[0]['name']; - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.labelResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.labelResultScreen), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'ADD A LABEL', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState(() { - lotNumberCTRL.text = - val + ' - ' + cycleNumberCTRL.text; - }); - }, - validator: (val) { - if (val.isEmpty) { - return 'Strilizer ID required!'; - } - return null; - }, - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon(FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize), - isDense: true, - labelText: 'Strilizer ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_cycleNumberFocusNode); - }, - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState( - () { - lotNumberCTRL.text = - striizerIdCTRL.text + ' - ' + val; - }, - ); - }, - validator: (val) { - if (val.isEmpty) { - return 'Cycle number required!'; - } - return null; - }, - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.done, - ), - SizedBox( - height: 20, - ), - TextFormField( - readOnly: true, - controller: lotNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Lot Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - ), - SizedBox( - height: 20, - ), - LabelAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - packageCTRL: packageCTRL, - packageVals: packageVals, - packageValue: packageValue, - ), - SizedBox( - height: 10, - ), - LabelAddDatePicker( - dateCTRL: sDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Sterile Date', - ), - SizedBox( - height: 20, - ), - LabelAddDatePicker( - dateCTRL: eDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Expire Date', - ), - SizedBox( - height: 70, - ), - LabelAddSaveButton( - form: _form, - lotNumberCTRL: lotNumberCTRL, - cycleNumberCTRL: cycleNumberCTRL, - sDateCTRL: sDateCTRL, - packageValue: packageValue, - eDateCTRL: eDateCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); - }), - ), - ), - ); - } -} diff --git a/lib/pages/label_filter_screen.dart b/lib/pages/label_filter_screen.dart deleted file mode 100644 index 8c8c211..0000000 --- a/lib/pages/label_filter_screen.dart +++ /dev/null @@ -1,316 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/label_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/labels.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/LabelScreens/Filter/save_button.dart'; -import '../widgets/LabelScreens/Filter/selector_box.dart'; - -class LabelFilterScreen extends StatefulWidget { - // static const route = '/LabelFilterScreen'; - - @override - _LabelFilterScreenState createState() => _LabelFilterScreenState(); -} - -class _LabelFilterScreenState extends State { - final _cycleNumberFocusNode = FocusNode(); - final _strilizerIdFocusNode = FocusNode(); - - TextEditingController labelIdCTRl = new TextEditingController(); - TextEditingController cycleNumberCTRL = new TextEditingController(); - TextEditingController striizerIdCTRL = new TextEditingController(); - TextEditingController hospitalCTRL = new TextEditingController(); - - TextEditingController dateCTRL = new TextEditingController(); - DateTime dateTimeFrom; - - List> hospitalVals = []; - bool isInit = true; - LabelFilterObject filters; - @override - void initState() { - filters = Provider.of(context, listen: false).filters; - labelIdCTRl.text = filters.id; - cycleNumberCTRL.text = filters.cycleNumber; - striizerIdCTRL.text = filters.sterilizerId; - super.initState(); - } - - @override - void didChangeDependencies() async { - if (isInit) { - await Provider.of(context, listen: false) - .getHospitalsFilters() - .then( - (result) { - setState( - () { - hospitalVals = [ - {'id': '', 'name': ''} - ]; - for (var hospital in result) { - hospitalVals.add(hospital); - } - // hospitalVals = result; - filters.hospital == '' - ? hospitalCTRL.text = hospitalVals[0]['name'] - : hospitalVals.forEach( - //id convert to name - (hospital) { - if (hospital['id'] == filters.hospital) - hospitalCTRL.text = hospital['name']; - }, - ); - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.labelResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.labelResultScreen), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: labelIdCTRl, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Label ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus( - _cycleNumberFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - labelIdCTRl.text = result; - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_strilizerIdFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Strilizer ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - textInputAction: TextInputAction.done, - keyboardType: TextInputType.visiblePassword, - focusNode: _strilizerIdFocusNode, - ), - SizedBox( - height: 30, - ), - - LabelFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - ), - SizedBox( - height: 70, - ), - LabelFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - labelIdCTRl: labelIdCTRl, - cycleNumberCTRL: cycleNumberCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 50, - ), - // DropDownBox(values: ['Washer ID']), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), - ), - ), - ); - } -} - -Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } -} diff --git a/lib/pages/label_result_screen.dart b/lib/pages/label_result_screen.dart deleted file mode 100644 index ea3426b..0000000 --- a/lib/pages/label_result_screen.dart +++ /dev/null @@ -1,217 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/connectivity.dart'; -import '../providers/labels.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/Global/page_header.dart'; -import '../widgets/LabelScreens/Result/data_box.dart'; -import '../widgets/LabelScreens/Result/filter_chip_box.dart'; -import '../widgets/LabelScreens/Result/floating_buttons.dart'; -import '../widgets/LabelScreens/Result/search_box.dart'; - -class LabelResultScreen extends StatefulWidget { - // static const route = '/LabelResultScreen'; - final bool isAdmin; - - LabelResultScreen({this.isAdmin}); - - @override - _LabelResultScreenState createState() => _LabelResultScreenState(); -} - -class _LabelResultScreenState extends State { - bool _isInit = true; - ScrollController sc; - TextEditingController searchCTRL = new TextEditingController(); - - @override - void initState() { - sc = new ScrollController(); - - super.initState(); - } - - @override - void didChangeDependencies() { - if (_isInit) { - var labelProviderObject = - Provider.of(context, listen: false); - labelProviderObject.setLoading(); - labelProviderObject.resetPageNumber(); - labelProviderObject.getLabelResults().then((_) { - labelProviderObject.resetLoading(); - sc.addListener(() { - if (sc.position.pixels == sc.position.maxScrollExtent && - searchCTRL.text == '') { - var labelProviderObject = - Provider.of(context, listen: false); - labelProviderObject.getLabelResults(); - } - }); - }); - } - _isInit = false; - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - floatingActionButton: - LabelFloatingButtons(deviceBlockSize: _deviceBlockSize), - appBar: AppBar( - titleSpacing: -10, - title: Text('Home'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? Padding( - padding: EdgeInsets.only( - top: 20, right: 20, bottom: 60, left: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - PageHeader( - deviceBlockSize: _deviceBlockSize, - label: 'LABELS', - route: Routes.labelFilterScreen, - ), - SizedBox( - height: 10, - ), - Consumer( - builder: (context, label, _) { - return Container( - height: 50, - child: ListView( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - children: [ - InkWell( - onTap: () { - Navigator.of(context).popAndPushNamed( - Routes.labelFilterScreen, - ); - }, - child: Chip( - backgroundColor: Colors.black, - label: Text( - 'Filters', - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - FontAwesomeIcons.filter, - color: Colors.white, - size: 4 * _deviceBlockSize, - ), - onDeleted: () { - Navigator.of(context).popAndPushNamed( - Routes.labelFilterScreen, - ); - }, - ), - ), - label.filters.id != '' - ? LabelFilterChip( - deviceBlockSize: _deviceBlockSize, - id: '', - cycleNumber: - label.filters.cycleNumber, - sterilizerId: - label.filters.sterilizerId, - hospital: label.filters.hospital, - label: 'ID', - ) - : Container(), - label.filters.cycleNumber != '' - ? LabelFilterChip( - deviceBlockSize: _deviceBlockSize, - id: label.filters.id, - cycleNumber: '', - sterilizerId: - label.filters.sterilizerId, - hospital: label.filters.hospital, - label: 'Cycle Number', - ) - : Container(), - label.filters.sterilizerId != '' - ? LabelFilterChip( - deviceBlockSize: _deviceBlockSize, - id: label.filters.id, - cycleNumber: - label.filters.cycleNumber, - sterilizerId: '', - hospital: label.filters.hospital, - label: 'Sterilizer ID', - ) - : Container(), - label.filters.hospital != '' - ? LabelFilterChip( - deviceBlockSize: _deviceBlockSize, - id: label.filters.id, - cycleNumber: - label.filters.cycleNumber, - sterilizerId: - label.filters.sterilizerId, - hospital: '', - label: 'Hospital', - ) - : Container(), - ], - ), - ); - }, - ), - LabelSearchBox( - searchCTRL: searchCTRL, - deviceBlockSize: _deviceBlockSize), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, labelResults, _) { - return labelResults.isloading - ? Center( - child: CircularProgressIndicator(), - ) - : ListView.builder( - controller: sc, - itemBuilder: (context, index) => - LabelItemBox( - deviceBlockSize: _deviceBlockSize, - item: labelResults.items[index], - ), - itemCount: labelResults.items.length, - shrinkWrap: true, - ); - }, - ), - ), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), - ), - ); - } -} diff --git a/lib/pages/label_scan_screen.dart b/lib/pages/label_scan_screen.dart deleted file mode 100644 index 9a82d71..0000000 --- a/lib/pages/label_scan_screen.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/LabelScreens/Scan/input_box.dart'; -import '../widgets/LabelScreens/Scan/save_button.dart'; -import '../widgets/LabelScreens/Scan/scan_box.dart'; -// import 'package:flutter/services.dart'; -// import 'package:barcode_scan2/barcode_scan2.dart'; - -class LabelScanScreen extends StatefulWidget { - // static const route = '/LabelScanScreen'; - @override - State createState() { - return _LabelScanScreenState(); - } -} - -class _LabelScanScreenState extends State { - String testCode = ""; - TextEditingController idCTRL = new TextEditingController(); - final _form = GlobalKey(); - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - titleSpacing: -10, - title: Text('CSSD'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'LOOKING FOR A Label?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), - ), - ), - LabelScanBox(), - Form( - key: _form, - child: LabelScanInputBox( - idCTRL: idCTRL, deviceBlockSize: _deviceBlockSize), - ), - SizedBox( - height: 40, - ), - Divider( - color: Colors.black, - thickness: 3, - ), - SizedBox( - height: 30, - ), - FilterScanSaveButton( - form: _form, - idCTRL: idCTRL, - deviceBlockSize: _deviceBlockSize, - ), - ], - ) - : ConnectionErrorBox(); - }, - ), - ), - ); - } -} diff --git a/lib/pages/label_update_screen.dart b/lib/pages/label_update_screen.dart deleted file mode 100644 index 82c5670..0000000 --- a/lib/pages/label_update_screen.dart +++ /dev/null @@ -1,305 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart' as DateEditor; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/label_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/labels.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/LabelScreens/Add/date_picker.dart'; -import '../widgets/LabelScreens/Add/selector_box.dart'; -import '../widgets/LabelScreens/Add/update_button.dart'; - -class LabelUpdateScreen extends StatefulWidget { - // static const route = '/LabelUpdateScreen'; - - @override - _LabelUpdateScreenState createState() => _LabelUpdateScreenState(); -} - -class _LabelUpdateScreenState extends State { - final _cycleNumberFocusNode = FocusNode(); - TextEditingController lotNumberCTRL = new TextEditingController(); - TextEditingController cycleNumberCTRL = new TextEditingController(); - TextEditingController striizerIdCTRL = new TextEditingController(); - TextEditingController sDateCTRL = new TextEditingController(); - TextEditingController eDateCTRL = new TextEditingController(); - TextEditingController packageCTRL = new TextEditingController(); - - DateTime dateTimeS; - // String sDateValue; - // String eDateValue; - - final _form = GlobalKey(); - - List> packageVals = []; - List packageValue = []; - bool isEmpty = false; - bool isInit = true; - LabelDetailsObject datas; - // CycleFilterObject filters; - - List labelsCTRL = [TextEditingController()]; - int curLabelVal = 1; - @override - void initState() { - sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - // sDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - // eDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); - super.initState(); - } - - @override - void didChangeDependencies() async { - if (isInit) { - var _id = ModalRoute.of(context).settings.arguments; - await Provider.of(context, listen: false) - .showLabelResult(_id.toString()) - .then( - (result) { - setState( - () { - // if (result.id == 'null') { - // isEmpty = true; - // } - datas = result; - lotNumberCTRL.text = datas.lotNumber; - cycleNumberCTRL.text = datas.cycleNumber; - striizerIdCTRL.text = datas.sterileId; - sDateCTRL.text = datas.sterileDate; - eDateCTRL.text = datas.expireDate; - packageValue.add(datas.packageId); - packageValue.add(datas.package); - packageCTRL.text = datas.package; - }, - ); - }, - ); - Provider.of(context, listen: false) - .getPackageFilters() - .then( - (result) { - setState( - () { - packageVals = result; - isInit = false; - }, - ); - }, - ); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.labelResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.labelResultScreen), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Update A LABEL', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState(() { - lotNumberCTRL.text = - val + ' - ' + cycleNumberCTRL.text; - }); - }, - validator: (val) { - if (val.isEmpty) { - return 'Strilizer ID required!'; - } - return null; - }, - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon(FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize), - isDense: true, - labelText: 'Strilizer ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_cycleNumberFocusNode); - }, - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState( - () { - lotNumberCTRL.text = - striizerIdCTRL.text + ' - ' + val; - }, - ); - }, - validator: (val) { - if (val.isEmpty) { - return 'Cycle number required!'; - } - return null; - }, - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.done, - ), - SizedBox( - height: 20, - ), - TextFormField( - readOnly: true, - controller: lotNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Lot Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - ), - SizedBox( - height: 20, - ), - LabelAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - packageCTRL: packageCTRL, - packageVals: packageVals, - packageValue: packageValue, - ), - SizedBox( - height: 10, - ), - LabelAddDatePicker( - dateCTRL: sDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Sterile Date', - ), - SizedBox( - height: 20, - ), - LabelAddDatePicker( - dateCTRL: eDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Expire Date', - ), - SizedBox( - height: 70, - ), - LabelUpdateButton( - form: _form, - id: datas.id, - lotNumberCTRL: lotNumberCTRL, - cycleNumberCTRL: cycleNumberCTRL, - sDateCTRL: sDateCTRL, - packageValue: packageValue, - eDateCTRL: eDateCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); - }), - ), - ), - ); - } -} diff --git a/lib/pages/login_screen.dart b/lib/pages/login_screen.dart deleted file mode 100644 index 5663167..0000000 --- a/lib/pages/login_screen.dart +++ /dev/null @@ -1,297 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/auth.dart'; -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class LoginScreen extends StatefulWidget { - // static const route = '/HomeScreen'; - - @override - State createState() { - return _LoginScreenState(); - } -} - -class _LoginScreenState extends State { - final _passwordFocusNode = FocusNode(); - final _form = GlobalKey(); - bool _isLoading = false; - final cellNumberController = TextEditingController(); - final passwordController = TextEditingController(); - - bool _hidePass = true; - Map map = Map(); - - @override - void initState() { - cellNumberController.text = map['cellNumber']; - super.initState(); - } - - @override - void dispose() { - _passwordFocusNode.dispose(); - super.dispose(); - } - - void _showDialog(String message) { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Error'), - content: Text(message), - actions: [ - TextButton( - child: Text('Ok'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ); - } - - void _login() async { - if (!_form.currentState.validate()) { - return; - } - _form.currentState.save(); - setState(() { - _isLoading = true; - }); - // try { - await Provider.of(context, listen: false) - .login( - map['cellNumber'], - map['password'], - ) - .then( - (result) { - if (result == 'error') { - _showDialog('Something went wrong!'); - setState( - () { - _isLoading = false; - }, - ); - } else if (result == 'badinput') { - _showDialog('User or password incorrect!'); - setState( - () { - _isLoading = false; - }, - ); - } - }, - ); - // } - // } catch (error) { - // _showDialog('something went wrong!'); - // setState(() { - // _isLoading = false; - // }); - // } - - // Navigator.pushReplacement( - // context, - // MaterialPageRoute(builder: (context) { - // return HomePage(); - // }), - // ); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('CSSD'), - ), - body: Selector( - builder: (ctx, value, _) => value != 'offline' - ? _isLoading - ? Center( - child: CircularProgressIndicator(), - ) - : Form( - key: _form, - child: ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 20), - child: Text( - 'LOGIN', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), - ), - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Cell number is required.'; - } - RegExp regExp = - RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); - if (!regExp.hasMatch(value)) { - return 'Enter a valid cell number'; - } - return null; - }, - controller: cellNumberController, - decoration: InputDecoration( - icon: Icon( - Icons.call, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cell Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.phone, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_passwordFocusNode); - }, - onSaved: (value) { - map['cellNumber'] = value; - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (value) { - if (value.isEmpty) { - return 'Password is required.'; - } - if (value.length < 8) { - return 'Password at least is 8 characters.'; - } - return null; - }, - obscureText: _hidePass, - controller: passwordController, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.starOfLife, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Password', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - suffixIcon: InkWell( - child: Icon(FontAwesomeIcons.eye), - onTap: () { - setState(() { - _hidePass = !_hidePass; - }); - }, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - textInputAction: TextInputAction.done, - onFieldSubmitted: (_) { - _login(); - }, - keyboardType: TextInputType.visiblePassword, - focusNode: _passwordFocusNode, - onSaved: (value) { - map['password'] = value; - }, - ), - SizedBox(height: 40), - Row( - children: [ - InkWell( - onTap: () => _login(), - child: Container( - width: 40 * _deviceBlockSize, - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Spacer(), - Icon( - Icons.exit_to_app, - color: Colors.white, - ), - Text( - 'Login', - style: TextStyle(color: Colors.white), - ), - Spacer() - ], - )), - ), - Spacer(), - ], - ), - SizedBox(height: 10), - TextButton( - child: Align( - alignment: Alignment.centerLeft, - child: Text( - 'Forgot Password ?', - style: TextStyle( - color: Colors.black54, - decoration: TextDecoration.underline, - ), - ), - ), - onPressed: () => Navigator.of(context) - .pushNamed(Routes.forgetPassScreen), - ), - ], - ), - ) - : ConnectionErrorBox(), - selector: (_, connectivity) => connectivity.conStatus, - )), - ); - } -} diff --git a/lib/pages/my_info_screen.dart b/lib/pages/my_info_screen.dart index 4d6d2b7..68f15a3 100644 --- a/lib/pages/my_info_screen.dart +++ b/lib/pages/my_info_screen.dart @@ -1,180 +1,189 @@ -// import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart'; -import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/internet_error.dart'; -import 'package:cssd/widgets/LabelScreens/Detail/header.dart'; -import 'package:cssd/widgets/MyInfo/input_box.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import '../providers/auth.dart'; - -class MyInfoScreen extends StatefulWidget { - // static const route = '/MyInfoScreenRoute'; - - @override - State createState() { - return _MyInfoScreenState(); - } -} - -class _MyInfoScreenState extends State { - Map user; - TextEditingController usernameCTRL = new TextEditingController(); - TextEditingController emailCTRL = new TextEditingController(); - - bool isInit = true; - @override - void didChangeDependencies() async { - if (isInit) { - var authObj = Provider.of(context, listen: false); - user = await authObj.getUserData(); - usernameCTRL.text = user['name'] != null ? user['name'] : ''; - emailCTRL.text = user['email'] != null ? user['email'] : ''; - isInit = false; - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Dashboard'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : ListView( - children: [ - InfoHeader( - deviceBlockSize: _deviceBlockSize, - label: 'MY INFO', - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - children: [ - InfoInputBox( - controller: usernameCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Full Name', - icon: FontAwesomeIcons.sortNumericDown, - inputType: TextInputType.text, - ), - SizedBox( - height: 20, - ), - TextFormField( - readOnly: true, - initialValue: user['cell_number'], - decoration: InputDecoration( - icon: Icon( - Icons.call, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cell Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.grey, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - ), - SizedBox( - height: 20, - ), - InfoInputBox( - controller: emailCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Email Address', - icon: FontAwesomeIcons.envelope, - inputType: TextInputType.emailAddress, - ), - SizedBox( - height: 40, - ), - InkWell( - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 60, vertical: 10), - margin: EdgeInsets.only(top: 50, bottom: 20), - width: double.infinity, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(5), - ), - child: Text( - 'Save', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - textAlign: TextAlign.center, - ), - ), - onTap: () async { - await Provider.of(context, - listen: false) - .setUserData( - user['id'], - usernameCTRL.text, - emailCTRL.text, - ) - .then( - (value) async => await showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text( - 'Info changed successfully.', - ), - actions: [ - TextButton( - child: Text('Ok'), - onPressed: () { - Navigator.of(ctx).pop(); - }, - ), - ], - ), - ), - ); - Navigator.of(context).pop(); - }, - ), - ], - ), - ), - ], - ) - : ConnectionErrorBox(); - }), - ), - ); - } -} +// import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:cssd/widgets/LabelScreens/Detail/header.dart'; +import 'package:cssd/widgets/MyInfo/input_box.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import '../providers/auth.dart'; + +class MyInfoScreen extends StatefulWidget { + // static const route = '/MyInfoScreenRoute'; + + @override + State createState() { + return _MyInfoScreenState(); + } +} + +class _MyInfoScreenState extends State { + Map? user; + TextEditingController usernameCTRL = new TextEditingController(); + TextEditingController emailCTRL = new TextEditingController(); + + bool isInit = true; + @override + void didChangeDependencies() async { + if (isInit) { + var authObj = Provider.of(context, listen: false); + user = await authObj.getUserData(); + usernameCTRL.text = user!['name'] != null ? user!['name'] : ''; + emailCTRL.text = user!['email'] != null ? user!['email'] : ''; + isInit = false; + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Dashboard'), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView( + children: [ + InfoHeader( + deviceBlockSize: _deviceBlockSize, + label: 'My Info', + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 20), + child: Column( + children: [ + InfoInputBox( + controller: usernameCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Full Name', + icon: FontAwesomeIcons.alignLeft, + inputType: TextInputType.text, + ), + SizedBox( + height: 20, + ), + TextFormField( + readOnly: true, + initialValue: user!['cell_number'], + decoration: InputDecoration( + icon: Icon( + Icons.call, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cell Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.grey, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 20, + ), + InfoInputBox( + controller: emailCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Email Address', + icon: FontAwesomeIcons.envelope, + inputType: TextInputType.emailAddress, + ), + SizedBox( + height: 40, + ), + InkWell( + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 60, vertical: 10), + margin: + EdgeInsets.only(top: 50, bottom: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(5), + ), + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + textAlign: TextAlign.center, + ), + ), + onTap: () async { + await Provider.of(context, + listen: false) + .setUserData( + user!['id'], + usernameCTRL.text, + emailCTRL.text, + ) + .then( + (value) async => await showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text( + 'Info changed successfully.', + ), + actions: [ + TextButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ), + ); + Navigator.of(context).pop(); + }, + ), + ], + ), + ), + ], + ) + : ConnectionErrorBox(); + }, + ), + ), + ), + ); + } +} diff --git a/lib/pages/test_add_screen.dart b/lib/pages/test_add_screen.dart deleted file mode 100644 index 9db3125..0000000 --- a/lib/pages/test_add_screen.dart +++ /dev/null @@ -1,283 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -// import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart'; - -import 'package:cssd/pages/test_form_page.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../providers/connectivity.dart'; -import '../providers/test_results.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/TestResultScreens/Add/selector_box.dart'; - -class TestResultAddScreen extends StatefulWidget { - // static const route = '/TestResultAddScreen'; - @override - State createState() { - return _TestResultAddScreenState(); - } -} - -class _TestResultAddScreenState extends State { - String testCode = ""; - TextEditingController testTypeCTRL = new TextEditingController(); - final List testTypeVals = []; - - TextEditingController testIdCTRL = new TextEditingController(); - bool isInit = true; - @override - void didChangeDependencies() { - if (isInit) { - var testResultProviderObject = - Provider.of(context, listen: false); - testResultProviderObject.getFilterItems().then((result) { - for (var testType in result[1].keys) { - testTypeVals.add(testType); - } - testTypeCTRL.text = testTypeVals[0]; - setState(() { - isInit = false; - }); - }); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Test Results'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - // padding: EdgeInsets.all(0), - onPressed: () => Navigator.of(context) - .popAndPushNamed(Routes.testResultScreen), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : ListView( - padding: - EdgeInsets.symmetric(horizontal: 20, vertical: 20), - children: [ - Container( - padding: EdgeInsets.only( - top: 10, - ), - child: Text( - 'ADD A TEST RESULT', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), - ), - ), - GestureDetector( - child: Container( - margin: EdgeInsets.only(top: 5, bottom: 30), - padding: EdgeInsets.all(10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'PLEASE SCAN THE TEST BARCODE', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.grey, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - uniqueCode: result, - ); - }, - ), - ); - } - }, - ); - }, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 70 * _deviceBlockSize, - child: TestResultAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: testTypeCTRL, - dataVals: testTypeVals, - label: 'Choose a Test Type'), - ), - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - 'OR', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 7 * _deviceBlockSize, - ), - ), - SizedBox( - width: 8 * _deviceBlockSize, - ), - Container( - width: 50 * _deviceBlockSize, - child: TextFormField( - onChanged: (val) { - if (val != '') { - setState(() { - testTypeCTRL.text = ''; - }); - } else { - setState(() { - testTypeCTRL.text = - testTypeVals[0]; - }); - } - }, - controller: testIdCTRL, - decoration: InputDecoration( - isDense: true, - icon: Icon( - FontAwesomeIcons.sortNumericDown, - ), - labelText: 'Enter a Test Code', - labelStyle: TextStyle( - fontSize: 3 * _deviceBlockSize), - contentPadding: EdgeInsets.only( - bottom: 5, top: 5), - ), - keyboardType: TextInputType.number, - ), - ), - ], - ) - ], - ), - SizedBox( - width: 5 * _deviceBlockSize, - ), - Expanded( - child: Container( - height: 100, - margin: EdgeInsets.only(bottom: 50), - decoration: BoxDecoration( - color: Color(0xFFEB4A64), - borderRadius: BorderRadius.circular(10), - ), - child: TextButton( - child: Text( - 'GO', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 6 * _deviceBlockSize, - fontWeight: FontWeight.w700), - ), - onPressed: () { - if (testIdCTRL.text != '') { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - uniqueCode: testIdCTRL.text); - }, - ), - ); - } else if (testTypeCTRL.text != '') { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - name: testTypeCTRL.text, - ); - }, - ), - ); - } - // print(testCode); - }, - ), - ), - ) - ], - ), - ], - ) - : ConnectionErrorBox(); - }), - ), - ), - ); - } - - Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - return barcode.rawContent; - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } - } -} diff --git a/lib/pages/test_filter_screen.dart b/lib/pages/test_filter_screen.dart deleted file mode 100644 index 21df194..0000000 --- a/lib/pages/test_filter_screen.dart +++ /dev/null @@ -1,423 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/test_result_models.dart'; -import '../providers/connectivity.dart'; -import '../providers/test_results.dart'; -import '../widgets/Global/internet_error.dart'; -import '../widgets/TestResultScreens/Filter/date_picker.dart'; -import '../widgets/TestResultScreens/Filter/selector_box.dart'; - -class TestFilterScreen extends StatefulWidget { - // static const route = '/TestFilterScreen'; - - @override - _TestFilterScreenState createState() => _TestFilterScreenState(); -} - -class _TestFilterScreenState extends State { - TextEditingController idCTRL = new TextEditingController(); - TextEditingController labelIdCTRL = new TextEditingController(); - TextEditingController testTypeCTRL = new TextEditingController(); - TextEditingController hospitalCTRL = new TextEditingController(); - TextEditingController fDateCTRL = new TextEditingController(); - TextEditingController uDateCTRL = new TextEditingController(); - - TextEditingController usernameCTRL = new TextEditingController(); - // TextEditingController dateFrom = new TextEditingController(); - // TextEditingController dateUntil = new TextEditingController(); - DateTime dateTimeFrom; - DateTime dateTimeUntil; - - final List labelIDVals = [ - '', - 'Washer ID', - 'Autoclave ID', - 'Sterilizer ID', - 'Seal Machine ID', - 'Patiant ID', - 'Set/Pack ID', - 'Medical Device ID', - 'OR ID', - 'Insrtument ID', - 'Basket ID', - 'Implant ID', - // 'None', - ]; - // String curLabelIDVal; - - final List testTypeVals = []; - Map testTypes; - - final List hospitalVals = []; - Map hospitals = {}; - // String curhospitalVal; - - bool isInit = true; - // final List labelIDVals = ['Washer ID']; - // String curLabelIDVal; - - // final List labelIDVals = ['Washer ID']; - // String curLabelIDVal; - - // @override - // void initState() { - // super.initState(); - // } - - @override - void didChangeDependencies() { - if (isInit) { - // fDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); - // uDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); - fDateCTRL.text = ''; - uDateCTRL.text = ''; - var testResultProviderObject = - Provider.of(context, listen: false); - TestResultFilterObject filters = testResultProviderObject.filters; - idCTRL.text = filters.id; - usernameCTRL.text = filters.userName; - labelIdCTRL.text = - filters.labelID == '' ? labelIDVals[0] : filters.labelID; - idCTRL.text = filters.id; - usernameCTRL.text = filters.userName; - testResultProviderObject.getFilterItems().then((result) { - hospitals = result[0]; - testTypes = result[1]; - hospitalVals.add(''); - for (var hospital in result[0].keys) { - hospitalVals.add(hospital); - } - testTypeVals.add(''); - for (var testType in result[1].keys) { - testTypeVals.add(testType); - } - var testTypeKey = testTypes.keys.firstWhere( - (k) => testTypes[k] == filters.testType, - orElse: () => ''); // recent testtype name - var hospitalKey = hospitals.keys.firstWhere( - (k) => hospitals[k] == filters.hospital, - orElse: () => ''); // recent testtype name - testTypeCTRL.text = - filters.testType == '' ? testTypeVals[0] : testTypeKey; - hospitalCTRL.text = - filters.hospital == '' ? hospitalVals[0] : hospitalKey; - // print(result[0]); - // print(result[1]); - setState(() { - isInit = false; - }); - }); - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultScreen, - ); - return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Tests'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).popAndPushNamed( - Routes.testResultScreen, - ), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_cycleNumberFocusNode); - // }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - - SizedBox( - height: 25, - ), - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: labelIdCTRL, - dataVals: labelIDVals, - label: 'Label ID', - ), - SizedBox( - height: 25, - ), - - TextFormField( - controller: usernameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Username', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_cycleNumberFocusNode); - // }, - ), - SizedBox( - height: 25, - ), - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: testTypeCTRL, - dataVals: testTypeVals, - label: 'Test Type', - ), - SizedBox( - height: 25, - ), - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: hospitalCTRL, - dataVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 25, - ), - - TestResultFilterDatePicker( - dateCTRL: fDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Date From', - ), - SizedBox( - height: 25, - ), - TestResultFilterDatePicker( - dateCTRL: uDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Date Until', - ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - Provider.of(context) - .setFilters( - idCTRL.text, - labelIdCTRL.text != '' - ? labelIdCTRL.text - : '', - usernameCTRL.text, - testTypeCTRL.text != '' - ? testTypes[testTypeCTRL.text] - : '', - hospitalCTRL.text != '' - ? hospitals[hospitalCTRL.text] - : '', - fDateCTRL.text, - uDateCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Filters changed.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - // Navigator.of(context).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then( - (_) => - Navigator.of(context).popAndPushNamed( - Routes.testResultScreen, - ), - ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'FILTER', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ), - SizedBox( - height: 70, - ), - // DropDownBox(values: ['Washer ID']), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), - ), - ), - ); - } -} - -Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } -} diff --git a/lib/pages/test_result_screen.dart b/lib/pages/test_result_screen.dart deleted file mode 100644 index 15819f8..0000000 --- a/lib/pages/test_result_screen.dart +++ /dev/null @@ -1,454 +0,0 @@ -// import 'package:cssd/providers/test_result.dart'; -import 'package:cssd/providers/test_results.dart'; -import 'package:cssd/widgets/Global/internet_error.dart'; -import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart'; -import 'package:cssd/widgets/TestResultScreens/Main/floating_button.dart'; -import 'package:cssd/widgets/TestResultScreens/Main/search_box.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../config/routes.dart'; -import '../models/test_result_models.dart'; -import '../providers/connectivity.dart'; - -class TestResultScreen extends StatefulWidget { - // static const route = '/TestResultScreen'; - final bool isAdmin; - - TestResultScreen({this.isAdmin}); - - @override - _TestResultScreenState createState() => _TestResultScreenState(); -} - -class _TestResultScreenState extends State { - TextEditingController searchCTRL = new TextEditingController(); - ScrollController sc; - - bool _isInit = true; - // List _data = []; - - @override - void initState() { - sc = new ScrollController(); - - super.initState(); - } - - @override - void didChangeDependencies() { - if (_isInit) { - var testResults = - Provider.of(context, listen: false); - // testResults.resetFilters(); - testResults.setLoading(); - testResults.resetPageNumber(); - testResults.getTestResults().then((_) { - testResults.resetLoading(); - sc.addListener(() { - if (sc.position.pixels == sc.position.maxScrollExtent && - searchCTRL.text == '') { - var labelProviderObject = - Provider.of(context, listen: false); - labelProviderObject.getTestResults(); - } - }); - - // setState(() { - // _isLoading = false; - // }); - }); - _isInit = false; - } - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - floatingActionButton: - TestResultFloatingButton(deviceBlockSize: _deviceBlockSize), - appBar: AppBar( - titleSpacing: -10, - title: Text('Home'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? Padding( - padding: EdgeInsets.only( - top: 20, left: 20, right: 20, bottom: 60), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - // padding: EdgeInsets.only(top: 20, bottom: 40), - child: Text( - 'MY TEST RESULTS', - // textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 6 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 2, - ), - ), - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context) - .popAndPushNamed(Routes.testFilterScreen); - }, - child: Container( - padding: EdgeInsets.all(7), - child: Icon( - FontAwesomeIcons.filter, - size: 7 * _deviceBlockSize, - ), - ), - ), - ], - ), - SizedBox( - height: 20, - ), - Consumer( - builder: (context, testResult, _) { - return Container( - height: 50, - child: ListView( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - children: [ - InkWell( - onTap: () { - Navigator.of(context).popAndPushNamed( - Routes.testFilterScreen); - }, - child: Chip( - backgroundColor: Colors.black, - label: Text( - 'Filters', - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - FontAwesomeIcons.filter, - color: Colors.white, - size: 4 * _deviceBlockSize, - ), - onDeleted: () { - Navigator.of(context).popAndPushNamed( - Routes.testFilterScreen, - ); - }, - ), - ), - testResult.filters.id != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'ID', - id: '', - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.labelID != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Label ID', - id: testResult.filters.id, - labelID: '', - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.testType != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Test Type', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: '', - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.hospital != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Hospital', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: '', - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.userName != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Username', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: '', - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.fDate != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'From Date', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: '', - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.uDate != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Until Date', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: '', - ) - : Container(), - ], - ), - ); - }, - ), - TestResultSearchBox( - searchCTRL: searchCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, testResults, _) { - return testResults.isloading - ? Center( - child: CircularProgressIndicator(), - ) - : ListView.builder( - controller: sc, - itemBuilder: (context, index) => - TestItemBox( - deviceBlockSize: _deviceBlockSize, - item: testResults.items[index], - ), - itemCount: testResults.items.length, - shrinkWrap: true, - ); - }, - ), - ), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), - ), - ); - } -} - -class TestItemBox extends StatelessWidget { - final TestResultObject item; - const TestItemBox({ - Key key, - @required double deviceBlockSize, - this.item, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - // print(item.result); - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - Routes.testDetailsScreen, - arguments: item.id, - ), - child: Card( - child: Container( - padding: EdgeInsets.all(10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 57 * _deviceBlockSize, - child: Text( - item.name, - overflow: TextOverflow.ellipsis, - // style: TextStyle(fontSize: 20), - ), - ), - Container( - width: 57 * _deviceBlockSize, - child: Text( - item.hospital, - style: TextStyle( - color: Colors.grey, - fontSize: 3 * _deviceBlockSize, - ), - ), - ), - SizedBox( - height: 15, - ), - item.result == 'Accepted' - ? Text( - 'Accepted', - style: TextStyle(color: Colors.green), - ) - : Text( - 'Rejected', - style: TextStyle( - color: Colors.red, - ), - ), - ], - ), - Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text(item.date), - SizedBox( - height: 15, - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - // item.result != 'Accepted' - // ? InkWell( - // onTap: () { - // showDialog( - // context: context, - // builder: (ctx) => AlertDialog( - // title: Text('Delete'), - // content: Text( - // 'Are you sure for delete this test?'), - // actions: [ - // TextButton( - // onPressed: () { - // Provider.of( - // context) - // .removeTestResult( - // item.id.toString()) - // .then((_) { - // Navigator.of(ctx).pop(); - // }); - // }, - // child: Text('Yes'), - // ), - // TextButton( - // onPressed: () { - // Navigator.of(ctx).pop(); - // }, - // child: Text('No'), - // ), - // ], - // ), - // ); - // }, - // child: Container( - // padding: EdgeInsets.all(7), - // width: 10 * _deviceBlockSize, - // decoration: BoxDecoration( - // shape: BoxShape.circle, - // color: Colors.red, - // ), - // child: Icon( - // Icons.delete, - // size: 6 * _deviceBlockSize, - // color: Colors.white, - // ), - // ), - // ) - // : Container(), - // SizedBox( - // width: _deviceBlockSize, - // ), - InkWell( - onTap: () { - Navigator.of(context).pushNamed( - Routes.testDetailsScreen, - arguments: item.id, - ); - // TestDetail(testResultId: item.id.toString()); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.fileAlt, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/pages/test_scan_screen.dart b/lib/pages/test_scan_screen.dart deleted file mode 100644 index 1a32696..0000000 --- a/lib/pages/test_scan_screen.dart +++ /dev/null @@ -1,216 +0,0 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../providers/connectivity.dart'; -import '../widgets/Global/internet_error.dart'; - -class TestScanScreen extends StatefulWidget { - // static const route = '/TestScanScreen'; - @override - State createState() { - return _TestScanScreenState(); - } -} - -class _TestScanScreenState extends State { - String testCode = ""; - TextEditingController idCTRL = new TextEditingController(); - final _form = GlobalKey(); - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - titleSpacing: -10, - title: Text('CSSD'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).pop(), - ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'LOOKING FOR A Test Result?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), - ), - ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Test Result Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/TestResult/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a Test Result ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - ), - ), - SizedBox( - height: 40, - ), - Divider( - color: Colors.black, - thickness: 3, - ), - SizedBox( - height: 30, - ), - InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - launch( - 'https://cssd-doc.com/Show/TestResult/${idCTRL.text}', - ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - margin: - EdgeInsets.only(bottom: 50, left: 20, right: 20), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.red, Colors.orange], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'GO!', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ), - ], - ) - : ConnectionErrorBox(); - }), - ), - ); - } - - Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } - } -} diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index 8ca040b..ab56d89 100644 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -1,249 +1,255 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'package:shared_preferences/shared_preferences.dart'; - -import '../config/urls.dart'; -import '../config/user.dart'; - -class Auth with ChangeNotifier { - String _token; - DateTime _expiaryDate; - - Map _user = {}; - - bool get isAuth { - return token != null; - } - - String get token { - if (_expiaryDate != null && - _expiaryDate.isAfter(DateTime.now()) && - _token != null) { - return _token; - } - return null; - } - - Map get user { - return {..._user}; - } - - Future requestCode(String cellNumber) async { - final response = await http.post( - Uri.parse(Url.requestResetPass), - body: { - 'cell_number': cellNumber, - }, - // headers: {'X-Requested-With': 'XMLHttpRequest'}, - ); - final responseData = json.decode(response.body); - if (responseData['status'] == 'Faild') { - return 'NotUser'; - } else { - return 'Done'; - } - // print(responseData); - } - - Future sendCode(String code) async { - final response = await http.post( - Uri.parse(Url.verifyResetPass), - body: { - 'code': code, - }, - // headers: {'X-Requested-With': 'XMLHttpRequest'}, - ); - final responseData = json.decode(response.body); - // if (responseData['status']=='Faild') { - // return 'NotUser'; - // } else { - // return 'Done'; - // } - print(responseData); - if (responseData['status'] == 'Faild') { - return 'wrong'; - } else { - return responseData['access_token']; - } - } - - Future sendRePass(String password, String token) async { - print(password); - print(token); - - final response = await http.post( - Uri.parse(Url.sendResetPass), - body: { - 'password': password, - 'password_confirmation': password, - }, - headers: {'Authorization': token, 'X-Requested-With': 'XMLHttpRequest'}, - // headers: {'X-Requested-With': 'XMLHttpRequest'}, - ); - final responseData = json.decode(response.body); - // if (responseData['status']=='Faild') { - // return 'NotUser'; - // } else { - // return 'Done'; - // } - print(responseData); - if (responseData['status'] == 'Success') { - return 'done'; - } else { - return 'error'; - } - } - - Future login(String cellNumber, String password) async { - final response = await http.post( - Uri.parse(Url.login), - body: { - 'cell_number': cellNumber, - 'password': password, - }, - // headers: {'X-Requested-With': 'XMLHttpRequest'}, - ); - final responseData = json.decode(response.body); - print(responseData); - if (response.statusCode == 401) { - if (responseData['message'] == 'The user credentials were incorrect.') { - return 'badinput'; // incorrect user or pass - } else { - return 'error'; - } - } - _token = responseData['access_token']; - _expiaryDate = DateTime.now().add( - Duration( - seconds: responseData['expires_in'], - ), - ); - User.token = _token; - // print(isAuth); - - // print(User.token); - var localUser = await getUserData(); - // print("------ in auth ==========="); - print(localUser); - - final prefs = await SharedPreferences.getInstance(); - final userData = json.encode({ - 'token': _token, - 'expiaryDate': _expiaryDate.toIso8601String(), - 'user': user - }); - prefs.setString('userData', userData); - notifyListeners(); - return 'true'; - } - - Future tryAutoLogin() async { - final prefs = await SharedPreferences.getInstance(); - if (!prefs.containsKey('userData')) { - return false; - } - final userData = - json.decode(prefs.getString('userData')) as Map; - final expiaryDate = DateTime.parse(userData['expiaryDate']); - if (expiaryDate.isBefore(DateTime.now())) { - return false; - } - _token = userData['token']; - _expiaryDate = expiaryDate; - _user = userData['user']; - User.token = _token; - notifyListeners(); - return true; - } - - Future> getUserData() async { - final response = await http.get( - Uri.parse(Url.getUserInfo), - headers: {'Authorization': 'Bearer ' + token}, - ); - // print(response.body); - if (response.statusCode == 200) { - var data = json.decode(response.body)['data']; - _user.addAll( - { - 'id': data['user']['id'], - 'name': data['user']['name'], - 'email': data['user']['email'], - 'cell_number': data['user']['cell_number'], - 'address': data['user']['address'], - 'gender': data['user']['gender'], - 'medical_center': data['user']['medical_center']['name'], - 'roles': data['roles'], - }, - ); - // print(_user); - notifyListeners(); - return _user; - } else { - return {}; - } - } - - Future setUserData(id, name, email) async { - var response = await http.post( - Uri.parse('https://cssd-doc.com/api/UpdateInfo'), - headers: { - 'Authorization': 'Bearer ' + token, - HttpHeaders.contentTypeHeader: 'application/json', - }, - body: json.encode( - { - "id": id, - "name": name, - "email": email, - // "country_code": "0098", - // "cell_number": "09338736511", - // "gender": "Male", - // "verified": "Verified", - // "status": "Active", - // "medical_center_id": 1, - // "address": null, - // "created_at": null, - // "updated_at": "2020-04-23 21:54:52", - // "medical_center": { - // "id": 1, - // "name": "B", - // "address": "1", - // "phone_number": "12345678951", - // "city_id": 1, - // "created_at": null, - // "updated_at": "2020-01-12 05:38:35" - // }, - // "roles": [ - // { - // "id": 1, - // "name": "Admin", - // "guard_name": "web", - // "created_at": null, - // "updated_at": null, - // "pivot": { - // "model_id": 1, - // "role_id": 1, - // "model_type": "App\\User", - // }, - // }, - // ], - }, - ), - ); - print(response.body); - } - - void logout() async { - _token = null; - _expiaryDate = null; - _user = {}; - User.token = null; - final prefs = await SharedPreferences.getInstance(); - prefs.remove('userData'); - notifyListeners(); - } -} +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../config/urls.dart'; +import '../config/user.dart'; + +class Auth with ChangeNotifier { + String? _token; + DateTime? _expiaryDate; + + Map _user = {}; + + bool get isAuth { + return token != null; + } + + String? get token { + if (_expiaryDate != null && + _expiaryDate!.isAfter(DateTime.now()) && + _token != null) { + return _token!; + } + return null; + } + + Map get user { + return {..._user}; + } + + Future requestCode(String cellNumber) async { + final response = await http.post( + Uri.parse(Url.requestResetPass), + body: { + 'cell_number': cellNumber, + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + if (responseData['status'] == 'Faild') { + return 'NotUser'; + } else { + return 'Done'; + } + // print(responseData); + } + + Future sendCode(String code) async { + final response = await http.post( + Uri.parse(Url.verifyResetPass), + body: { + 'code': code, + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + // if (responseData['status']=='Faild') { + // return 'NotUser'; + // } else { + // return 'Done'; + // } + print(responseData); + if (responseData['status'] == 'Faild') { + return 'wrong'; + } else { + return responseData['access_token']; + } + } + + Future sendRePass(String password, String token) async { + print(password); + print(token); + + final response = await http.post( + Uri.parse(Url.sendResetPass), + body: { + 'password': password, + 'password_confirmation': password, + }, + headers: {'Authorization': token, 'X-Requested-With': 'XMLHttpRequest'}, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + // if (responseData['status']=='Faild') { + // return 'NotUser'; + // } else { + // return 'Done'; + // } + print(responseData); + if (responseData['status'] == 'Success') { + return 'done'; + } else { + return 'error'; + } + } + + Future login(String cellNumber, String password) async { + final response = await http.post( + Uri.parse(Url.login), + body: { + 'cell_number': cellNumber, + 'password': password, + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + print(responseData); + if (response.statusCode == 401) { + if (responseData['message'] == 'The user credentials were incorrect.') { + return 'badinput'; // incorrect user or pass + } else { + return 'error'; + } + } + _token = responseData['access_token']; + _expiaryDate = DateTime.now().add( + Duration( + seconds: responseData['expires_in'], + ), + ); + User.token = _token!; + // print(isAuth); + + // print(User.token); + var localUser = await getUserData(); + // print("------ in auth ==========="); + print(localUser); + + final prefs = await SharedPreferences.getInstance(); + final userData = json.encode({ + 'token': _token, + 'expiaryDate': _expiaryDate!.toIso8601String(), + 'user': user + }); + prefs.setString('userData', userData); + notifyListeners(); + return 'true'; + } + + Future tryAutoLogin() async { + final prefs = await SharedPreferences.getInstance(); + if (!prefs.containsKey('userData')) { + return false; + } + final userData = + json.decode(prefs.getString('userData')!) as Map; + final expiaryDate = DateTime.parse(userData['expiaryDate']); + if (expiaryDate.isBefore(DateTime.now())) { + return false; + } + _token = userData['token']; + _expiaryDate = expiaryDate; + _user = userData['user']; + User.token = _token!; + notifyListeners(); + return true; + } + + Future> getUserData() async { + final response = await http.get( + Uri.parse(Url.getUserInfo), + headers: {'Authorization': 'Bearer ' + token!}, + ); + // print(response.body); + if (response.statusCode == 200) { + var data = json.decode(response.body)['data']; + _user.addAll( + { + 'id': data['user']['id'], + 'name': data['user']['name'], + 'email': data['user']['email'], + 'cell_number': data['user']['cell_number'], + 'address': data['user']['address'], + 'gender': data['user']['gender'], + 'medical_center': data['user']['medical_center']['name'], + 'roles': data['roles'], + }, + ); + // print(_user); + notifyListeners(); + return _user; + } else { + return {}; + } + } + + Future setUserData(id, name, email) async { + var response = await http.post( + Uri.parse('https://cssd-doc.com/api/UpdateInfo'), + headers: { + 'Authorization': 'Bearer ' + token!, + HttpHeaders.contentTypeHeader: 'application/json', + }, + body: json.encode( + { + "id": id, + "name": name, + "email": email, + // "country_code": "0098", + // "cell_number": "09338736511", + // "gender": "Male", + // "verified": "Verified", + // "status": "Active", + // "medical_center_id": 1, + // "address": null, + // "created_at": null, + // "updated_at": "2020-04-23 21:54:52", + // "medical_center": { + // "id": 1, + // "name": "B", + // "address": "1", + // "phone_number": "12345678951", + // "city_id": 1, + // "created_at": null, + // "updated_at": "2020-01-12 05:38:35" + // }, + // "roles": [ + // { + // "id": 1, + // "name": "Admin", + // "guard_name": "web", + // "created_at": null, + // "updated_at": null, + // "pivot": { + // "model_id": 1, + // "role_id": 1, + // "model_type": "App\\User", + // }, + // }, + // ], + }, + ), + ); + print(response.body); + } + + void logout() async { + _token = null; + _expiaryDate = null; + _user = {}; + User.token = ''; + final prefs = await SharedPreferences.getInstance(); + prefs.remove('userData'); + var response = await http.post( + Uri.parse( + Url.logOut, + ), + ); + print(response.statusCode); + notifyListeners(); + } +} diff --git a/lib/providers/connectivity.dart b/lib/providers/connectivity.dart index e0976eb..b3250fe 100644 --- a/lib/providers/connectivity.dart +++ b/lib/providers/connectivity.dart @@ -1,31 +1,32 @@ - -import 'package:flutter/material.dart'; -import 'package:connectivity/connectivity.dart'; - -class ConnectivityProvider extends ChangeNotifier { - String conStatus = ''; - - checkConnection() { - Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { - conStatus = _getStatus(result); - notifyListeners(); - }); - } - - String _getStatus(ConnectivityResult result) { - switch (result) { - case ConnectivityResult.wifi: - return 'wifi'; - break; - case ConnectivityResult.mobile: - return 'calcular'; - break; - case ConnectivityResult.none: - return 'offline'; - break; - default: - return 'offline'; - break; - } - } -} +import 'package:flutter/material.dart'; +import 'package:connectivity/connectivity.dart'; + +enum ConnectionStatus { + Wifi, + Cellular, + Offline, +} + +class ConnectivityProvider extends ChangeNotifier { + String conStatus = ''; + + void checkConnection() { + Connectivity().onConnectivityChanged.listen((ConnectivityResult? result) { + conStatus = _getStatus(result); + notifyListeners(); + }); + } + + String _getStatus(ConnectivityResult? result) { + switch (result) { + case ConnectivityResult.wifi: + return 'wifi'; + case ConnectivityResult.mobile: + return 'cellular'; + case ConnectivityResult.none: + return 'offline'; + default: + return 'offline'; + } + } +} diff --git a/lib/providers/cycles.dart b/lib/providers/cycles.dart index abba973..a6319c8 100644 --- a/lib/providers/cycles.dart +++ b/lib/providers/cycles.dart @@ -1,265 +1,310 @@ -import 'dart:convert'; - -import '../config/urls.dart'; -import '../config/user.dart'; -import '../models/cycles_models.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -class CyclesProvider extends ChangeNotifier { - List labelVals = []; - List labelValues = []; - String initialLabelValue = ''; - int curLabelVal = 1; - - resetLabelVals() { - labelVals = []; - labelValues = []; - initialLabelValue = ''; - curLabelVal = 1; - // notifyListeners(); - } - - addLabelVal() { - curLabelVal += 1; - TextEditingController lbl = new TextEditingController(); - lbl.text = initialLabelValue; - labelValues.add(lbl); - notifyListeners(); - } - - changeLabelVal(String value, int index) { - labelValues[index].text = value; - notifyListeners(); - } - - String searchBoxValue = ''; - bool filterOn = false; - List items; - List originalItems; //before do search on results - - CycleDetailObject result; - CycleFilterObject filters = CycleFilterObject( - id: '', - cycleNumber: '', - sterilizerId: '', - hospital: '', - date: '', - ); - int pageNumber = 1; - void resetPageNumber() => pageNumber = 1; - bool isloading = false; - void resetLoading() { - isloading = false; - notifyListeners(); - } - - void setLoading() { - isloading = true; - // notifyListeners(); - } - - Future>> getHospitalsFilters() async { - var response = await http.get( - Uri.parse(Url.filterItems), - headers: { - 'Authorization': User.token, - }, - ); - List> result = []; - var filterDatas = json.decode(response.body); - for (var hospital in filterDatas['data']['MedicalCenters']) { - result.add({ - 'name': hospital['name'].toString(), - 'id': hospital['id'].toString() - }); - // print(hospital['name']); - } - return result; - } - - Future> getLabelFilters() async { - var response = await http.get( - Uri.parse(Url.labelItems), - headers: { - 'Authorization': User.token, - }, - ); - List result = []; - var filterDatas = json.decode(response.body); - for (var label in filterDatas['data']) { - result.add(label['id'].toString()); - // print(hospital['name']); - } - labelVals = result; - initialLabelValue = labelVals[0]; - TextEditingController newLbl = new TextEditingController(); - newLbl.text = initialLabelValue; - labelValues.add(newLbl); - notifyListeners(); - return result; - } - - Future createCycleResult( - cycleNumber, date, labels, note, sterilizerId) async { - List> labs = []; - for (var label in labels) { - labs.add({'name': '', 'id': label}); - } - // print(labs); - var response = await http.post(Uri.parse(Url.createCycleResult), - body: json.encode( - { - 'note': note, - 'labels': labs, - 'cycle_number': cycleNumber, - 'date': date, - 'sterilizer_id': sterilizerId, - }, - ), - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" - }); - - print(response.body); - } - - void setFilters(id, cycleNumber, sterilizerId, hospital, date) { - pageNumber = 1; - filters = CycleFilterObject( - id: id, - cycleNumber: cycleNumber, - sterilizerId: sterilizerId, - hospital: hospital, - date: date, - ); - if (filters.id == '' && - filters.cycleNumber == '' && - filters.sterilizerId == '' && - filters.hospital == '' && - filters.date == '') { - filterOn = false; - } else { - filterOn = true; - } - notifyListeners(); - } - - void search(String value) { - items = []; - searchBoxValue = value; - originalItems.forEach((result) { - if (result.id.toString().contains(searchBoxValue)) { - items.add(result); - } - }); - notifyListeners(); - } - - Future getCycleResults() async { - String url = Url.cycleResults(pageNumber); - if (filterOn) { - items = []; - if (filters.id != '') { - url += '&cycle_id=${filters.id}'; - } - if (filters.cycleNumber != '') { - url += '&cycle_number=${filters.cycleNumber}'; - } - if (filters.sterilizerId != '') { - url += '&sterilizer_id=${filters.sterilizerId}'; - } - if (filters.hospital != '') { - url += '&medical_center_id=${filters.hospital}'; - } - if (filters.date != '') { - url += '&date=${filters.date}'; - } - } - // print(url); - var response = await http.get( - Uri.parse(url), - headers: { - 'Authorization': User.token, - }, - ); - - var testResultData = json.decode(response.body); - List labels = []; - if (pageNumber == 1) { - originalItems = []; - items = []; - } - - for (var item in testResultData['data']['data']) { - // print(item); - labels = []; - for (var label in item['labels']) { - // print(label['id']); - labels.add(label['id'].toString()); - } - originalItems.add( - CycleResultObject( - createdAt: item['date'], - id: item['id'].toString(), - label: labels, - ), - ); - } - pageNumber += 1; - search(''); - } - - Future showCycleResult(String id) async { - var response = await http.get(Uri.parse(Url.getCycleResult(id)), headers: { - 'Authorization': User.token, - }); - if (response.statusCode != 200) { - return CycleDetailObject( - id: 'null', - description: 'null', - createDate: 'null', - hospitalName: 'null', - date: '2020-01-01', - sterileId: 'null', - cycleNumber: 'null', - labels: [], - ); - } - var data = json.decode(response.body)['data']; - List lablesList = []; - for (var label in data['labels']) { - lablesList.add(label['id'].toString()); - } - print(data); - result = CycleDetailObject( - id: data['id'].toString(), - description: data['note'] != null ? data['note'] : '', - createDate: data['created_at'] != null ? data['created_at'] : '', - hospitalName: data['user']['medical_center']['name'], - date: data['date'] != null ? data['date'] : '', - sterileId: data['sterilizer_id'] != null ? data['sterilizer_id'] : '', - cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '', - labels: lablesList, - ); - // result = { - // 'id': data['id'], - // 'auto_cleave_id': data['inputs']['Autoclave ID'], - // 'test_code': data['test_type_id'], - // 'date': data['created_at'], - // 'verified': data['verified'], - // 'description': data['inputs']['Note'], - // 'test_type_name': data['test_type']['name'], - - // // 'device_label': data['device_label'], - // // 'device_id': data['device_id'], - // // 'result': data['result'], - // // 'user_name': data['user']['name'], - // // 'medical_center': data['user']['medical_center']['name'], - // }; - return result; - } -} +import 'dart:convert'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import '../models/cycles_models.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +class CyclesProvider extends ChangeNotifier { + List labelVals = []; + List labelValues = []; + String initialLabelValue = ''; + int curLabelVal = 1; + + resetLabelVals() { + labelVals = []; + labelValues = []; + initialLabelValue = ''; + curLabelVal = 1; + // notifyListeners(); + } + + addLabelVal() { + curLabelVal += 1; + TextEditingController lbl = new TextEditingController(); + lbl.text = initialLabelValue; + labelValues.add(lbl); + notifyListeners(); + } + + changeLabelVal(String value, int index) { + labelValues[index].text = value; + notifyListeners(); + } + + String searchBoxValue = ''; + bool filterOn = false; + List? items; + List? originalItems; + + CycleDetailObject? result; + CycleFilterObject? filters = CycleFilterObject( + id: '', + cycleNumber: '', + sterilizerId: '', + hospital: '', + date: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + Future>> getHospitalsFilters() async { + var response = await http.get( + Uri.parse(Url.filterItems), + headers: { + 'Authorization': User.token, + }, + ); + List> result = []; + var filterDatas = json.decode(response.body); + for (var hospital in filterDatas['data']['MedicalCenters']) { + result.add({ + 'name': hospital['name'].toString(), + 'id': hospital['id'].toString() + }); + // print(hospital['name']); + } + return result; + } + + Future> getLabelFilters() async { + var response = await http.get( + Uri.parse(Url.labelItems), + headers: { + 'Authorization': User.token, + }, + ); + List result = []; + var filterDatas = json.decode(response.body); + for (var label in filterDatas['data']) { + result.add(label['id'].toString()); + // print(hospital['name']); + } + labelVals = result; + initialLabelValue = labelVals[0]; + TextEditingController newLbl = new TextEditingController(); + newLbl.text = initialLabelValue; + labelValues.add(newLbl); + notifyListeners(); + return result; + } + + Future createCycleResult( + cycleNumber, date, labels, note, sterilizerId) async { + List> labs = []; + for (var label in labels) { + labs.add({'name': '', 'id': label}); + } + // print(labs); + var response = await http.post(Uri.parse(Url.createCycleResult), + body: json.encode( + { + 'note': note, + 'labels': labs, + 'cycle_number': cycleNumber, + 'date': date, + 'sterilizer_id': sterilizerId, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future updateCycleResult( + id, + sterilizerId, + cycleNumber, + // label, + date, + description, + ) async { + var response = await http.put(Uri.parse(Url.updateCycleResult(id)), + body: json.encode( + { + 'sterilizer_id': sterilizerId, + 'cycle_number': cycleNumber, + 'note': description, + // 'label_id': label['id'].toString(), + 'date': date, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future removeCycles(String id) async { + var response = await http.post(Uri.parse(Url.removeCycles(id)), body: { + '_method': 'delete' + }, headers: { + 'Authorization': User.token, + }); + + if (response.statusCode == 200) { + items!.removeWhere((item) { + return item.id.toString() == id; + }); + } + + notifyListeners(); + return true; + } + + void setFilters(id, cycleNumber, sterilizerId, hospital, date) { + pageNumber = 1; + filters = CycleFilterObject( + id: id, + cycleNumber: cycleNumber, + sterilizerId: sterilizerId, + hospital: hospital, + date: date, + ); + if (filters!.id == '' && + filters!.cycleNumber == '' && + filters!.sterilizerId == '' && + filters!.hospital == '' && + filters!.date == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + void search(String value) { + items = []; + searchBoxValue = value; + originalItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + items!.add(result); + } + }); + notifyListeners(); + } + + Future getCycleResults() async { + String url = Url.cycleResults(pageNumber); + if (filterOn) { + items = []; + if (filters!.id != '') { + url += '&cycle_id=${filters!.id}'; + } + if (filters!.cycleNumber != '') { + url += '&cycle_number=${filters!.cycleNumber}'; + } + if (filters!.sterilizerId != '') { + url += '&sterilizer_id=${filters!.sterilizerId}'; + } + if (filters!.hospital != '') { + url += '&medical_center_id=${filters!.hospital}'; + } + if (filters!.date != '') { + url += '&date=${filters!.date}'; + } + } + // print(url); + var response = await http.get( + Uri.parse(url), + headers: { + 'Authorization': User.token, + }, + ); + + var testResultData = json.decode(response.body); + List labels = []; + if (pageNumber == 1) { + originalItems = []; + items = []; + } + + for (var item in testResultData['data']['data']) { + // print(item); + labels = []; + for (var label in item['labels']) { + // print(label['id']); + labels.add(label['id'].toString()); + } + originalItems!.add( + CycleResultObject( + createdAt: item['date'], + id: item['id'].toString(), + label: labels, + ), + ); + } + pageNumber += 1; + search(''); + } + + Future showCycleResult(String id) async { + var response = await http.get(Uri.parse(Url.getCycleResult(id)), headers: { + 'Authorization': User.token, + }); + if (response.statusCode != 200) { + return CycleDetailObject( + id: 'null', + description: 'null', + createDate: 'null', + hospitalName: 'null', + date: '2020-01-01', + sterileId: 'null', + cycleNumber: 'null', + labels: [], + ); + } + var data = json.decode(response.body)['data']; + List lablesList = []; + for (var label in data['labels']) { + lablesList.add(label['id'].toString()); + } + print(data); + result = CycleDetailObject( + id: data['id'].toString(), + description: data['note'] != null ? data['note'] : '', + createDate: data['created_at'] != null ? data['created_at'] : '', + hospitalName: data['user']['medical_center']['name'], + date: data['date'] != null ? data['date'] : '', + sterileId: data['sterilizer_id'] != null ? data['sterilizer_id'] : '', + cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '', + labels: lablesList, + ); + // result = { + // 'id': data['id'], + // 'auto_cleave_id': data['inputs']['Autoclave ID'], + // 'test_code': data['test_type_id'], + // 'date': data['created_at'], + // 'verified': data['verified'], + // 'description': data['inputs']['Note'], + // 'test_type_name': data['test_type']['name'], + + // // 'device_label': data['device_label'], + // // 'device_id': data['device_id'], + // // 'result': data['result'], + // // 'user_name': data['user']['name'], + // // 'medical_center': data['user']['medical_center']['name'], + // }; + return result!; + } +} diff --git a/lib/providers/input.dart b/lib/providers/input.dart index 67befe1..f93fe34 100644 --- a/lib/providers/input.dart +++ b/lib/providers/input.dart @@ -1,134 +1,122 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -import '../config/urls.dart'; -import '../config/user.dart'; - -class Inputs with ChangeNotifier { - List> inputItems = []; - - Future getInputs( - {String testResultId = "", - String name = "", - String uniqueCode = "", - String testTypeId = ""}) async { - // print( - // { - // 'test_type_id': testTypeId, - // 'test_result_id': testResultId, - // 'name': name, - // 'unique_code': uniqueCode, - // }, - // ); - var response = await http.post( - Uri.parse(Url.getInputs), - body: { - 'test_type_id': testTypeId, - 'test_result_id': testResultId, - 'name': name, - 'unique_code': uniqueCode, - }, - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - }, - ); - if (response.statusCode != 200) { - inputItems = []; - notifyListeners(); - return false; - } - final responseData = json.decode(response.body); - - // print(responseData['data']['inputs']); - // for (var item in responseData['data']['testType'].keys) { - // print(item); - // } - Map values; - if (testResultId.isNotEmpty) { - response = await http.get(Uri.parse(Url.testResultFormValues(testResultId)), - headers: {'Authorization': User.token}); - values = json.decode(response.body)['data']; - } - - var inputs = responseData['data']['inputs'] as List; - var general = responseData['data']['testType'] as Map; - - clearInputs(); - bool result = false; - DateTime dateTime = DateTime.now(); - String deviceLabel; - if (values != null && values.isNotEmpty) { - result = values['result'] == 'Accept' ? true : false; - dateTime = values['date'] == null - ? DateTime.now() - : DateTime.parse(values['date']); - deviceLabel = values['device_id'] ?? ''; - } - - inputItems.add({ - 'type': 'Label', - 'key': 'test_type_id', - 'name': general['name'], - 'value': general['id'] - }); - - // print(responseData['data']['inputs']); - inputItems.add({ - 'type': 'Text', - 'key': 'device_id', - 'name': general['device_label'], - 'value': deviceLabel, - }); - inputItems.add( - {'type': 'Date', 'key': 'date', 'name': 'date', 'value': dateTime}); - inputItems.add( - {'type': 'Switch', 'key': 'result', 'name': 'Result', 'value': result}); - - setValues(inputs, values); - for (var input in inputs) { - inputItems.add(input as Map); - // print(input); - } - inputItems.add({ - 'type': 'Image', - 'key': 'test_type_id', - 'name': general['name'], - 'value': general['id'] - }); - - notifyListeners(); - return true; - } - - void setValues(inputs, values) { - for (var input in inputs) { - if (input.containsKey('children')) { - setValues(input['children'], values); - } - var key = "${input['name']}_${input['id']}"; - input['key'] = key; - if (values != null && values.isNotEmpty && values.containsKey(key)) { - if (input['type'] == 'Range' || - input['type'] == 'Temperature' || - input['type'] == 'Pressure') { - input['value'] = double.parse(values[key]); - } else if (input['type'] == 'Switch') { - input['value'] = values[key] == "1" ? true : false; - } else if (input['type'] == 'Time') { - input['value'] = values[key] == null - ? '' - : values[key].substring(0, 2) + ":" + values[key].substring(2, 4); - } else { - input['value'] = values[key]; - } - } - } - } - - void clearInputs() { - inputItems.clear(); - } -} +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +import '../config/urls.dart'; +import '../config/user.dart'; + +class Inputs with ChangeNotifier { + List> inputItems = []; + + Future getInputs({ + required String testResultId, + required String name, + required String uniqueCode, + required String testTypeId, + }) async { + var response = await http.post( + Uri.parse(Url.getInputs), + body: { + 'test_type_id': testTypeId, + 'test_result_id': testResultId, + 'name': name, + 'unique_code': uniqueCode, + }, + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + }, + ); + if (response.statusCode != 200) { + inputItems = []; + notifyListeners(); + return false; + } + final responseData = json.decode(response.body); + + Map? values; + if (testResultId.isNotEmpty) { + response = await http.get( + Uri.parse(Url.testResultFormValues(testResultId)), + headers: {'Authorization': User.token}); + values = json.decode(response.body)['data']; + } + + var inputs = responseData['data']['inputs'] as List; + var general = responseData['data']['testType'] as Map; + + clearInputs(); + bool result = false; + DateTime dateTime = DateTime.now(); + String? deviceLabel; + if (values != null && values.isNotEmpty) { + result = values['result'] == 'Accept' ? true : false; + dateTime = values['date'] == null + ? DateTime.now() + : DateTime.parse(values['date']); + deviceLabel = values['device_id'] ?? ''; + } + + inputItems.add({ + 'type': 'Label', + 'key': 'test_type_id', + 'name': general['name'], + 'value': general['id'] + }); + + inputItems.add({ + 'type': 'Text', + 'key': 'device_id', + 'name': general['device_label'], + 'value': deviceLabel, + }); + inputItems.add( + {'type': 'Date', 'key': 'date', 'name': 'date', 'value': dateTime}); + inputItems.add( + {'type': 'Switch', 'key': 'result', 'name': 'Result', 'value': result}); + + setValues(inputs, values); + for (var input in inputs) { + inputItems.add(input as Map); + } + inputItems.add({ + 'type': 'Image', + 'key': 'test_type_id', + 'name': general['name'], + 'value': general['id'] + }); + + notifyListeners(); + return true; + } + + void setValues(inputs, values) { + for (var input in inputs) { + if (input.containsKey('children')) { + setValues(input['children'], values); + } + var key = "${input['name']}_${input['id']}"; + input['key'] = key; + if (values != null && values.isNotEmpty && values.containsKey(key)) { + if (input['type'] == 'Range' || + input['type'] == 'Temperature' || + input['type'] == 'Pressure') { + input['value'] = double.parse(values[key]); + } else if (input['type'] == 'Switch') { + input['value'] = values[key] == "1" ? true : false; + } else if (input['type'] == 'Time') { + input['value'] = values[key] == null + ? '' + : values[key].substring(0, 2) + ":" + values[key].substring(2, 4); + } else { + input['value'] = values[key]; + } + } + } + } + + void clearInputs() { + inputItems.clear(); + } +} diff --git a/lib/providers/items.dart b/lib/providers/items.dart new file mode 100644 index 0000000..a5a2dcf --- /dev/null +++ b/lib/providers/items.dart @@ -0,0 +1,346 @@ +import 'dart:convert'; + +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/models/my_item_model.dart'; +import 'package:dio/dio.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/foundation.dart'; +import 'package:random_string/random_string.dart'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import 'package:http/http.dart' as http; + +class ItemProvider extends ChangeNotifier { + List catchImages = []; + List images = []; + String searchBoxValue = ''; + bool filterOn = false; + List? items; + + List? originalItems; + + ItemDetailObject? result; + ItemFilterObject? filters = ItemFilterObject( + id: '', + hospital: '', + name: '', + udi: '', + size: '', + specific: '', + ); + + MyItemFilterObject? myItemsFilters = MyItemFilterObject( + id: '', + name: '', + udi: '', + size: '', + specific: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + Future>> getHospitalsFilters() async { + var response = await http.get( + Uri.parse(Url.filterItems), + headers: { + 'Authorization': User.token, + }, + ); + List> result = []; + var filterData = json.decode(response.body); + for (var hospital in filterData['data']['MedicalCenters']) { + result.add({ + 'name': hospital['name'].toString(), + 'id': hospital['id'].toString() + }); + // print(hospital['name']); + } + return result; + } + + setImages() async { + images = []; + for (var image in catchImages) { + var result = image.bytes; + // final batchId = randomString(10); + // addImage(batchId, result, image.path); + images.add(result!.buffer + .asUint8List(result.offsetInBytes, result.lengthInBytes)); + } + notifyListeners(); + } + + setCatchImages(List images) { + catchImages = images; + notifyListeners(); + } + + removeImage(int index) { + catchImages.removeAt(index); + notifyListeners(); + } + + Future addImage(String batchId, dynamic file, String fileName) async { + var imageListInt = file.cast(); + var dio = Dio(); + dio.options.headers = { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json', + }; + FormData formData = FormData.fromMap( + { + "batch_id": batchId, + 'model_type': 'Item', + "file": MultipartFile.fromBytes(imageListInt, filename: fileName) + }, + ); + + await dio.post( + Url.addImage, + data: formData, + ); + return 'Added'; + } + + Future createItemResult( + name, + size, + specific, + udi, + note, + batchId, + ) async { + batchId = randomString(10); + + for (var image in catchImages) { + await addImage(batchId, image.bytes, image.path!); + } + var response = await http.post(Uri.parse(Url.createItemResult), + body: json.encode( + { + 'note': note, + 'size': size, + 'specific': specific, + 'name': name, + 'udi': udi, + 'file_batch_id': batchId, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + print(response.body); + } + + Future updateItemResult( + id, + name, + size, + specific, + udi, + description, + ) async { + var response = await http.put(Uri.parse(Url.updateItemResult(id)), + body: json.encode( + { + 'name': name, + 'udi': udi, + 'note': description, + 'size': size, + 'specific': specific, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future removeItems(String id) async { + var response = await http.post(Uri.parse(Url.removeItems(id)), body: { + '_method': 'delete' + }, headers: { + 'Authorization': User.token, + }); + + if (response.statusCode == 200) { + items!.removeWhere((item) { + return item.id.toString() == id; + }); + } + + notifyListeners(); + return true; + } + + void setFilters( + id, + name, + udi, + hospital, + size, + specific, + ) { + pageNumber = 1; + filters = ItemFilterObject( + id: id, + name: name, + udi: udi, + hospital: hospital, + size: size, + specific: specific, + ); + if (filters!.id == '' && + filters!.name == '' && + filters!.hospital == '' && + filters!.size == '' && + filters!.specific != '' && + filters!.udi == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + void search(String value) { + items = []; + searchBoxValue = value; + originalItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + items!.add(result); + } + }); + notifyListeners(); + } + + Future getItemResults() async { + String url = Url.itemResults(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&item_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.hospital != '') { + url += '&medical_center_id=${filters!.hospital}'; + } + if (filters!.size != '') { + url += '&size=${filters!.size}'; + } + if (filters!.specific != '') { + url += '&specific=${filters!.specific}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: { + 'Authorization': User.token, + }, + ); + + var testResultData = json.decode(response.body); + if (pageNumber == 1) { + originalItems = []; + } + + for (var item in testResultData['data']['data']) { + originalItems!.add( + ItemResultObject( + name: item['name'], + id: item['id'].toString(), + size: item['size'].toString(), + userName: item['user'] != null ? item['user']['name'] : '', + status: item['status'], + ), + ); + } + pageNumber += 1; + + search(''); + } + + Future showItemResult(String id) async { + var response = await http.get(Uri.parse(Url.getItemResult(id)), headers: { + 'Authorization': User.token, + }); + if (response.statusCode != 200) { + return ItemDetailObject( + id: 'null', + description: 'null', + name: 'null', + userName: 'null', + specific: 'null', + hospital: 'null', + size: 'null', + createdAt: '2019-09-18 10:02:03', + udi: 'null', + status: 0, + ); + } + var data = json.decode(response.body)['data']; + print(data); + result = ItemDetailObject( + id: data['id'].toString(), + description: data['note'] != null ? data['note'] : '', + name: data['name'] != null ? data['name'] : '', + hospital: + data['user'] != null ? data['user']['medical_center']['name'] : '', + userName: data['user'] != null ? data['user']['name'] : '', + size: data['size'] != null ? data['size'] : '', + specific: data['specific'] != null ? data['specific'] : '', + createdAt: data['created_at'] != null ? data['created_at'] : '', + udi: data['udi'] != null ? data['udi'] : '', + status: data['status'], + ); + return result!; + } + + Future changeStatus(String id) async { + print(id); + var response = await http.post( + Uri.parse(Url.changeItemStatus(id)), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + var itemData = json.decode(response.body); + + try { + if (itemData['status'] == 'Success') { + return true; + } else { + return false; + } + } catch (e) { + return false; + } + } +} diff --git a/lib/providers/labels.dart b/lib/providers/labels.dart index fb91ac7..f47c869 100644 --- a/lib/providers/labels.dart +++ b/lib/providers/labels.dart @@ -1,257 +1,304 @@ -import 'dart:convert'; - -import '../config/urls.dart'; -import '../config/user.dart'; -import '../models/label_models.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -class LabelsProvider extends ChangeNotifier { - String searchBoxValue = ''; - bool filterOn = false; - List items; - List originalItems; - - LabelDetailsObject result; - LabelFilterObject filters = LabelFilterObject( - id: '', - cycleNumber: '', - sterilizerId: '', - hospital: '', - ); - int pageNumber = 1; - void resetPageNumber() => pageNumber = 1; - bool isloading = false; - void resetLoading() { - isloading = false; - notifyListeners(); - } - - void setLoading() { - isloading = true; - // notifyListeners(); - } - - Future>> getHospitalsFilters() async { - var response = await http.get( - Uri.parse(Url.filterItems), - headers: { - 'Authorization': User.token, - }, - ); - List> result = []; - var filterDatas = json.decode(response.body); - for (var hospital in filterDatas['data']['MedicalCenters']) { - result.add({ - 'name': hospital['name'].toString(), - 'id': hospital['id'].toString() - }); - // print(hospital); - } - return result; - } - - Future>> getPackageFilters() async { - var response = await http.get( - Uri.parse(Url.packageItems), - headers: { - 'Authorization': User.token, - }, - ); - List> result = []; - var filterDatas = json.decode(response.body); - // print(filterDatas); - for (var package in filterDatas['data']) { - result.add( - { - 'name': package['name'].toString(), - 'id': package['id'].toString(), - }, - ); - // print(hospital['name']); - } - // print(result); - return result; - } - - Future createLabelResult(lotNumber, cycleNumber, sterileDate, package, - expireDate, sterilizerId) async { - // print(labs); - var response = await http.post(Uri.parse(Url.createLabelResult), - body: json.encode( - { - 'sterile_date': sterileDate, - 'expire_date': expireDate, - 'sterilizer_id': sterilizerId, - 'cycle_number': cycleNumber, - 'lot_number': lotNumber, - 'package_id': package['id'] - // 'package': { - // 'id': package['id'], - // 'name': package['name'], - // }, - }, - ), - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" - }); - - print(response.body); - } - - Future updateLabelResult( - id, - lotNumber, - cycleNumber, - sterileDate, - package, - expireDate, - sterilizerId, - ) async { - // print(labs); - var response = await http.put(Uri.parse(Url.updateLabelResult(id)), - body: json.encode( - { - 'sterile_date': sterileDate, - 'expire_date': expireDate, - 'sterilizer_id': sterilizerId, - 'cycle_number': cycleNumber, - 'lot_number': lotNumber, - 'package_id': package['id'] - // 'package': { - // 'id': package['id'], - // 'name': package['name'], - // }, - }, - ), - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" - }); - - print(response.body); - } - - void setFilters(id, cycleNumber, sterilizerId, hospital) { - pageNumber = 1; - filters = LabelFilterObject( - id: id, - cycleNumber: cycleNumber, - sterilizerId: sterilizerId, - hospital: hospital, - ); - if (filters.id == '' && - filters.cycleNumber == '' && - filters.sterilizerId == '' && - filters.hospital == '') { - filterOn = false; - } else { - filterOn = true; - } - notifyListeners(); - } - - void search(String value) { - items = []; - searchBoxValue = value; - originalItems.forEach((result) { - if (result.id.toString().contains(searchBoxValue)) { - items.add(result); - } - }); - notifyListeners(); - } - - Future getLabelResults() async { - String url = Url.labelResults(pageNumber); - if (filterOn) { - items = []; - // url = Url.labelResults(pNum); - if (filters.id != '') { - url += '&label_id=${filters.id}'; - } - if (filters.hospital != '') { - url += '&medical_center_id=${filters.hospital}'; - } - if (filters.sterilizerId != '') { - url += '&sterilizer_id=${filters.sterilizerId}'; - } - if (filters.cycleNumber != '') { - url += '&cycle_number=${filters.cycleNumber}'; - } - } - - var response = await http.get( - Uri.parse(url), - headers: { - 'Authorization': User.token, - }, - ); - - var testResultData = json.decode(response.body); - if (pageNumber == 1) { - originalItems = []; - items = []; - } - - for (var item in testResultData['data']['data']) { - // print(item); - originalItems.add( - LabelResultObject( - expireDate: item['expire_date'], - id: item['id'].toString(), - package: item['package']['name'], - packageId: item['package']['id'].toString(), - ), - ); - } - pageNumber += 1; - search(''); - } - - Future showLabelResult(String id) async { - var response = await http.get( - Uri.parse(Url.getLabelResult(id)), - headers: { - 'Authorization': User.token, - }, - ); - if (response.statusCode != 200) { - return LabelDetailsObject( - id: 'null', - package: 'null', - packageId: 'null', - hospitalName: 'null', - createDate: 'null', - expireDate: 'null', - sterileDate: 'null', - sterileId: 'null', - cycleNumber: 'null', - lotNumber: 'null', - ); - } - - var data = json.decode(response.body)['data']; - print(data); - result = LabelDetailsObject( - id: data['id'].toString(), - package: data['package']['name'] != null ? data['package']['name'] : '', - packageId: data['package']['id'].toString() != 'null' - ? data['package']['id'].toString() - : '', - hospitalName: data['user']['medical_center']['name'], - createDate: data['created_at'] != null ? data['created_at'] : '', - expireDate: data['expire_date'] != null ? data['expire_date'] : '', - sterileDate: data['sterile_date'] != null ? data['sterile_date'] : '', - sterileId: data['sterilizer_id'] != null ? data['sterilizer_id'] : '', - cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '', - lotNumber: data['lot_number'] != null ? data['lot_number'] : '', - ); - return result; - } -} +import 'dart:convert'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import '../models/label_models.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +class LabelsProvider extends ChangeNotifier { + String searchBoxValue = ''; + bool filterOn = false; + List? items; + List? originalItems; + List packageVals = []; + List packageValues = []; + String initialPackageValue = ''; + int curPackageVal = 1; + + resetPackageVals() { + packageVals = []; + packageValues = []; + initialPackageValue = ''; + curPackageVal = 1; + // notifyListeners(); + } + + addPackageVal() { + curPackageVal += 1; + TextEditingController lbl = new TextEditingController(); + lbl.text = initialPackageValue; + packageValues.add(lbl); + notifyListeners(); + } + + changePackageVal(String value, int index) { + packageValues[index].text = value; + notifyListeners(); + } + + LabelDetailsObject? result; + LabelFilterObject filters = LabelFilterObject( + id: '', + cycleNumber: '', + sterilizerId: '', + hospital: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + Future>> getHospitalsFilters() async { + var response = await http.get( + Uri.parse(Url.filterItems), + headers: { + 'Authorization': User.token, + }, + ); + List> result = []; + var filterDatas = json.decode(response.body); + for (var hospital in filterDatas['data']['MedicalCenters']) { + result.add({ + 'name': hospital['name'].toString(), + 'id': hospital['id'].toString() + }); + // print(hospital); + } + return result; + } + + Future> getPackageFilters() async { + var response = await http.get( + Uri.parse(Url.packageItems), + headers: { + 'Authorization': User.token, + }, + ); + List result = []; + var filterDatas = json.decode(response.body); + for (var package in filterDatas['data']) { + result.add( + "${package['name']} - ${package['udi'] != null ? package['udi'] : ''}"); + } + packageVals = result; + initialPackageValue = packageVals[0]; + TextEditingController newLbl = new TextEditingController(); + newLbl.text = initialPackageValue; + packageValues.add(newLbl); + notifyListeners(); + return result; + } + + Future createLabelResult(lotNumber, cycleNumber, sterileDate, package, + expireDate, sterilizerId) async { + // print(labs); + var response = await http.post(Uri.parse(Url.createLabelResult), + body: json.encode( + { + 'sterile_date': sterileDate, + 'expire_date': expireDate, + 'sterilizer_id': sterilizerId, + 'cycle_number': cycleNumber, + 'lot_number': lotNumber, + 'package_id': package['id'] + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future updateLabelResult( + id, + lotNumber, + cycleNumber, + sterileDate, + package, + expireDate, + sterilizerId, + ) async { + // print(labs); + print( + { + 'sterile_date': sterileDate, + 'expire_date': expireDate, + 'sterilizer_id': sterilizerId, + 'cycle_number': cycleNumber, + 'lot_number': lotNumber, + 'package_id': package['id'], + }, + ); + var response = await http.put(Uri.parse(Url.updateLabelResult(id)), + body: json.encode( + { + 'sterile_date': sterileDate, + 'expire_date': expireDate, + 'sterilizer_id': sterilizerId, + 'cycle_number': cycleNumber, + 'lot_number': lotNumber, + 'package_id': package['id'], + // 'package': { + // 'id': package['id'], + // 'name': package['name'], + // }, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future removeLabels(String id) async { + var response = await http.post(Uri.parse(Url.removeLabels(id)), body: { + '_method': 'delete' + }, headers: { + 'Authorization': User.token, + }); + + if (response.statusCode == 200) { + items!.removeWhere((item) { + return item.id.toString() == id; + }); + } + + notifyListeners(); + return true; + } + + void setFilters(id, cycleNumber, sterilizerId, hospital) { + pageNumber = 1; + filters = LabelFilterObject( + id: id, + cycleNumber: cycleNumber, + sterilizerId: sterilizerId, + hospital: hospital, + ); + if (filters.id == '' && + filters.cycleNumber == '' && + filters.sterilizerId == '' && + filters.hospital == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + void search(String value) { + items = []; + searchBoxValue = value; + originalItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + items!.add(result); + } + }); + notifyListeners(); + } + + Future getLabelResults() async { + String url = Url.labelResults(pageNumber); + if (filterOn) { + items = []; + // url = Url.labelResults(pNum); + if (filters.id != '') { + url += '&label_id=${filters.id}'; + } + if (filters.hospital != '') { + url += '&medical_center_id=${filters.hospital}'; + } + if (filters.sterilizerId != '') { + url += '&sterilizer_id=${filters.sterilizerId}'; + } + if (filters.cycleNumber != '') { + url += '&cycle_number=${filters.cycleNumber}'; + } + } + + var response = await http.get( + Uri.parse(url), + headers: { + 'Authorization': User.token, + }, + ); + + var testResultData = json.decode(response.body); + if (pageNumber == 1) { + originalItems = []; + items = []; + } + + for (var item in testResultData['data']['data']) { + // print(item); + originalItems!.add( + LabelResultObject( + expireDate: item['expire_date'], + id: item['id'].toString(), + package: item['package']['name'], + packageId: item['package']['id'].toString(), + ), + ); + } + pageNumber += 1; + search(''); + } + + Future showLabelResult(String id) async { + var response = await http.get( + Uri.parse(Url.getLabelResult(id)), + headers: { + 'Authorization': User.token, + }, + ); + if (response.statusCode != 200) { + return LabelDetailsObject( + id: 'null', + package: 'null', + packageId: 'null', + hospitalName: 'null', + createDate: 'null', + expireDate: 'null', + sterileDate: 'null', + sterileId: 'null', + cycleNumber: 'null', + lotNumber: 'null', + ); + } + + var data = json.decode(response.body)['data']; + print(data); + result = LabelDetailsObject( + id: data['id'].toString(), + package: data['package']['name'] != null ? data['package']['name'] : '', + packageId: data['package']['id'].toString() != 'null' + ? data['package']['id'].toString() + : '', + hospitalName: data['user']['medical_center']['name'], + createDate: data['created_at'] != null ? data['created_at'] : '', + expireDate: data['expire_date'] != null ? data['expire_date'] : '', + sterileDate: data['sterile_date'] != null ? data['sterile_date'] : '', + sterileId: data['sterilizer_id'] != null ? data['sterilizer_id'] : '', + cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '', + lotNumber: data['lot_number'] != null ? data['lot_number'] : '', + ); + return result!; + } +} diff --git a/lib/providers/my_info.dart b/lib/providers/my_info.dart index 979e6e5..8fb9600 100644 --- a/lib/providers/my_info.dart +++ b/lib/providers/my_info.dart @@ -1,59 +1,58 @@ -import 'dart:convert'; -import 'package:http/http.dart' as http; -import '../config/urls.dart'; - -import 'package:flutter/material.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -class MyInfoProvider extends ChangeNotifier { - Map _user = {}; - Map get user { - return {..._user}; - } - - String _token; - - Future setToken() async { - final prefs = await SharedPreferences.getInstance(); - if (!prefs.containsKey('auth')) { - return false; - } - final auth = json.decode(prefs.getString('auth')) as Map; - _token = auth['token']; - notifyListeners(); - } - - Future> getUserData() async { - final prefs = await SharedPreferences.getInstance(); - final auth = json.decode(prefs.getString('auth')) as Map; - _token = auth['token']; - final response = await http.get( - Uri.parse(Url.getUserInfo), - headers: { - 'Authorization': 'Bearer ' + _token, - }, - ); - print(response.body); - - if (response.statusCode == 200) { - var data = json.decode(response.body)['data']; - _user.addAll( - { - 'id': data['user']['id'], - 'name': data['user']['name'], - 'email': data['user']['email'], - 'cell_number': data['user']['cell_number'], - 'address': data['user']['address'], - 'gender': data['user']['gender'], - 'medical_center': data['user']['medical_center']['name'], - 'roles': data['roles'], - }, - ); - final prefs = await SharedPreferences.getInstance(); - prefs.setString('userData', json.encode(_user)); - return _user; - } else { - return {}; - } - } -} +import 'dart:convert'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../config/urls.dart'; + +class MyInfoProvider with ChangeNotifier { + Map _user = {}; + Map get user { + return {..._user}; + } + + String? _token; + + Future setToken() async { + final prefs = await SharedPreferences.getInstance(); + if (!prefs.containsKey('auth')) { + return; + } + final auth = json.decode(prefs.getString('auth')!) as Map; + _token = auth['token']; + notifyListeners(); + } + + Future> getUserData() async { + final prefs = await SharedPreferences.getInstance(); + final auth = json.decode(prefs.getString('auth')!) as Map; + _token = auth['token']; + final response = await http.get( + Uri.parse(Url.getUserInfo), + headers: { + 'Authorization': 'Bearer $_token', + }, + ); + print(response.body); + if (response.statusCode == 200) { + var data = json.decode(response.body)['data']; + _user.addAll( + { + 'id': data['user']['id'], + 'name': data['user']['name'], + 'email': data['user']['email'], + 'cell_number': data['user']['cell_number'], + 'address': data['user']['address'], + 'gender': data['user']['gender'], + 'medical_center': data['user']['medical_center']['name'], + 'roles': data['roles'], + }, + ); + final prefs = await SharedPreferences.getInstance(); + prefs.setString('userData', json.encode(_user)); + return _user; + } else { + return {}; + } + } +} diff --git a/lib/providers/my_items.dart b/lib/providers/my_items.dart new file mode 100644 index 0000000..5ffb834 --- /dev/null +++ b/lib/providers/my_items.dart @@ -0,0 +1,274 @@ +import 'dart:convert'; + +import 'package:cssd/models/my_item_model.dart'; +import 'package:flutter/foundation.dart'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import 'package:http/http.dart' as http; + +class MyItemProvider extends ChangeNotifier { + String searchBoxValue = ''; + bool filterOn = false; + List? myItems; + List? hospitalItems; + + List? originalMyItems; + List? originalHospitalItems; + + List? originalMyItemsRequests; + List? originalHospitalItemsRequests; + + MyItemFilterObject? filters = MyItemFilterObject( + id: '', + name: '', + udi: '', + size: '', + specific: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + void searchMyItems(String value) { + myItems = []; + searchBoxValue = value; + originalMyItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + myItems!.add(result); + } + }); + notifyListeners(); + } + + void searchHospitalItems(String value) { + hospitalItems = []; + searchBoxValue = value; + originalHospitalItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + hospitalItems!.add(result); + } + }); + notifyListeners(); + } + + void setFilters( + id, + name, + udi, + size, + specific, + ) { + pageNumber = 1; + filters = MyItemFilterObject( + id: id, + name: name, + udi: udi, + size: size, + specific: specific, + ); + if (filters!.id == '' && + filters!.name == '' && + filters!.size == '' && + filters!.specific != '' && + filters!.udi == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + Future getMyItems() async { + String url = Url.getMyItems(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&item_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.size != '') { + url += '&size=${filters!.size}'; + } + if (filters!.specific != '') { + url += '&specific=${filters!.specific}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var itemsData = json.decode(response.body); + + if (pageNumber == 1) { + originalMyItems = []; + } + + for (var item in itemsData['data']) { + originalMyItems!.add( + MyItemResultObject( + name: item['name'], + id: item['id'].toString(), + size: item['size'].toString(), + fromDate: item['transfers']['from_date'], + toDate: item['transfers']['to_date'], + ), + ); + } + pageNumber += 1; + searchMyItems(''); + } + + Future getHospitalItems() async { + String url = Url.getHospitalItems(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&item_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.size != '') { + url += '&size=${filters!.size}'; + } + if (filters!.specific != '') { + url += '&specific=${filters!.specific}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + print(response.body); + print(response.statusCode); + + var itemsData = json.decode(response.body); + + if (pageNumber == 1) { + originalHospitalItems = []; + } + + for (var item in itemsData['data']) { + originalHospitalItems!.add( + MyItemResultObject( + name: item['name'], + id: item['id'].toString(), + size: item['size'].toString(), + userName: item['user'] != null ? item['user']['name'] : '', + // fromDate: item['transfers']['from_date'], + // toDate: item['transfers']['to_date'], + ), + ); + } + pageNumber += 1; + searchHospitalItems(''); + } + + Future getMyItemRequests() async { + String url = Url.getMyItemRequests; + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var itemsData = json.decode(response.body); + + originalMyItemsRequests = []; + + for (var item in itemsData['data']) { + originalMyItemsRequests!.add( + MyItemResultObject( + name: item['name'], + id: item['id'].toString(), + size: item['size'].toString(), + ), + ); + } + } + + Future getHospitalItemRequests() async { + String url = Url.getHospitalItemRequests; + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var itemsData = json.decode(response.body); + + originalHospitalItemsRequests = []; + + for (var item in itemsData['data']) { + originalHospitalItemsRequests!.add( + MyItemResultObject( + name: item['name'], + id: item['id'].toString(), + size: item['size'].toString(), + userName: item['user'] != null ? item['user']['name'] : '', + ), + ); + } + } + + Future transferItems(String itemId, String userId) async { + var response = await http.post( + Uri.parse(Url.transferItems(itemId)), + body: json.encode( + { + 'user_id': userId, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + var itemData = json.decode(response.body); + print(itemData); + } + + Future verifyItemRequests(String id, String value) async { + var response = await http.post( + Uri.parse(Url.verifyItemRequests(id, value)), + body: json.encode({'status': value}), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + var itemData = json.decode(response.body); + + try { + if (itemData['data']['transfers']['status'] == 'approved') { + return true; + } else { + return false; + } + } catch (e) { + return false; + } + } +} diff --git a/lib/providers/my_packages.dart b/lib/providers/my_packages.dart new file mode 100644 index 0000000..d83c007 --- /dev/null +++ b/lib/providers/my_packages.dart @@ -0,0 +1,245 @@ +import 'dart:convert'; + +import 'package:cssd/models/my_package_model.dart'; +import 'package:flutter/foundation.dart'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import 'package:http/http.dart' as http; + +class MyPackageProvider extends ChangeNotifier { + String searchBoxValue = ''; + bool filterOn = false; + List? myPackages; + List? hospitalPackages; + + List? originalMyPackages; + List? originalHospitalPackages; + + List? originalMyPackagesRequests; + List? originalHospitalPackagesRequests; + + MyPackageFilterObject? filters = MyPackageFilterObject( + id: '', + name: '', + udi: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + void searchMyPackages(String value) { + myPackages = []; + searchBoxValue = value; + originalMyPackages!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + myPackages!.add(result); + } + }); + notifyListeners(); + } + + void searchHospitalPackages(String value) { + hospitalPackages = []; + searchBoxValue = value; + originalHospitalPackages!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + hospitalPackages!.add(result); + } + }); + notifyListeners(); + } + + void setFilters( + id, + name, + udi, + ) { + pageNumber = 1; + filters = MyPackageFilterObject( + id: id, + name: name, + udi: udi, + ); + if (filters!.id == '' && filters!.name == '' && filters!.udi == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + Future getMyPackages() async { + String url = Url.getMyItems(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&package_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var packagesData = json.decode(response.body); + + if (pageNumber == 1) { + originalMyPackages = []; + } + + for (var package in packagesData['data']) { + originalMyPackages!.add( + MyPackageResultObject( + name: package['name'], + id: package['id'].toString(), + fromDate: package['transfers']['from_date'], + toDate: package['transfers']['to_date'], + ), + ); + } + pageNumber += 1; + searchMyPackages(''); + } + + Future getHospitalPackages() async { + String url = Url.getHospitalItems(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&package_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var packagesData = json.decode(response.body); + + if (pageNumber == 1) { + originalHospitalPackages = []; + } + + for (var package in packagesData['data']) { + originalHospitalPackages!.add( + MyPackageResultObject( + name: package['name'], + id: package['id'].toString(), + userName: package['user'] != null ? package['user']['name'] : '', + fromDate: package['transfers']['from_date'], + toDate: package['transfers']['to_date'], + ), + ); + } + pageNumber += 1; + searchHospitalPackages(''); + } + + Future getMyPackageRequests() async { + String url = Url.getMyItemRequests; + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var packagesData = json.decode(response.body); + + originalMyPackagesRequests = []; + + for (var package in packagesData['data']) { + originalMyPackagesRequests!.add( + MyPackageResultObject( + name: package['name'], + id: package['id'].toString(), + ), + ); + } + } + + Future getHospitalPackageRequests() async { + String url = Url.getHospitalItemRequests; + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var packagesData = json.decode(response.body); + + originalHospitalPackagesRequests = []; + + for (var package in packagesData['data']) { + originalHospitalPackagesRequests!.add( + MyPackageResultObject( + name: package['name'], + id: package['id'].toString(), + userName: package['user'] != null ? package['user']['name'] : '', + ), + ); + } + } + + Future transferPackage(String packageId, String userId) async { + var response = await http.post( + Uri.parse(Url.transferItems(packageId)), + body: json.encode( + { + 'user_id': userId, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + var packageData = json.decode(response.body); + print(packageData); + } + + Future verifyPackageRequests(String id, String value) async { + var response = await http.post( + Uri.parse(Url.verifyItemRequests(id, value)), + body: json.encode({'status': value}), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + var packageData = json.decode(response.body); + + try { + if (packageData['data']['transfers']['status'] == 'approved') { + return true; + } else { + return false; + } + } catch (e) { + return false; + } + } +} diff --git a/lib/providers/packages.dart b/lib/providers/packages.dart new file mode 100644 index 0000000..245cc1b --- /dev/null +++ b/lib/providers/packages.dart @@ -0,0 +1,295 @@ +import 'dart:convert'; + +import 'package:cssd/models/package_model.dart'; + +import '../config/urls.dart'; +import '../config/user.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; + +class PackageProvider extends ChangeNotifier { + List itemVals = []; + List itemValues = []; + String initialItemValue = ''; + int curItemVal = 1; + + resetItemVals() { + itemVals = []; + itemValues = []; + initialItemValue = ''; + curItemVal = 1; + // notifyListeners(); + } + + addItemVal() { + curItemVal += 1; + TextEditingController lbl = new TextEditingController(); + lbl.text = initialItemValue; + itemValues.add(lbl); + notifyListeners(); + } + + changeItemVal(String value, int index) { + itemValues[index].text = value; + notifyListeners(); + } + + String searchBoxValue = ''; + bool filterOn = false; + List? items; + List? originalItems; + + PackageDetailObject? result; + PackageFilterObject? filters = PackageFilterObject( + id: '', + hospital: '', + name: '', + udi: '', + ); + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + Future>> getHospitalsFilters() async { + var response = await http.get( + Uri.parse(Url.filterItems), + headers: { + 'Authorization': User.token, + }, + ); + List> result = []; + var filterData = json.decode(response.body); + for (var hospital in filterData['data']['MedicalCenters']) { + result.add({ + 'name': hospital['name'].toString(), + 'id': hospital['id'].toString() + }); + } + return result; + } + + Future> getItemFilters() async { + var response = await http.get( + Uri.parse(Url.itemItems), + headers: { + 'Authorization': User.token, + }, + ); + List result = []; + var filterData = json.decode(response.body); + for (var item in filterData['data']) { + result.add(item['id'].toString()); + } + itemVals = result; + initialItemValue = itemVals[0]; + TextEditingController newLbl = new TextEditingController(); + newLbl.text = initialItemValue; + itemValues.add(newLbl); + notifyListeners(); + return result; + } + + Future createPackageResult( + name, + udi, + items, + note, + ) async { + List> items = []; + for (var item in items) { + items.add({'name': '', 'id': item}); + } + var response = await http.post( + Uri.parse(Url.createPackageResult), + body: json.encode( + { + 'note': note, + 'items': items, + 'name': name, + 'udi': udi, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + + print(response.body); + } + + Future updatePackageResult( + id, + name, + udi, + description, + items, + ) async { + // List> items = []; + // for (var item in items) { + // items.add({'name': '', 'id': item}); + // } + print({ + 'note': description, + 'name': name, + 'udi': udi, + 'items': items, + }); + var response = await http.put(Uri.parse(Url.updatePackageResult(id)), + body: json.encode( + { + 'name': name, + 'udi': udi, + 'note': description, + 'items': items, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + + Future removePackages(String id) async { + var response = await http.post(Uri.parse(Url.removePackages(id)), body: { + '_method': 'delete' + }, headers: { + 'Authorization': User.token, + }); + + if (response.statusCode == 200) { + items!.removeWhere((item) { + return item.id.toString() == id; + }); + } + + notifyListeners(); + return true; + } + + void setFilters( + id, + name, + hospital, + udi, + ) { + pageNumber = 1; + filters = PackageFilterObject( + id: id, + name: name, + hospital: hospital, + udi: udi, + ); + if (filters!.id == '' && + filters!.name == '' && + filters!.hospital == '' && + filters!.udi != '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + void search(String value) { + items = []; + searchBoxValue = value; + originalItems!.forEach((result) { + if (result.id.toString().contains(searchBoxValue)) { + items!.add(result); + } + }); + notifyListeners(); + } + + Future getPackageResults() async { + String url = Url.packageResults(pageNumber); + if (filterOn) { + if (filters!.id != '') { + url += '&package_id=${filters!.id}'; + } + if (filters!.name != '') { + url += '&name=${filters!.name}'; + } + if (filters!.hospital != '') { + url += '&medical_center_id=${filters!.hospital}'; + } + if (filters!.udi != '') { + url += '&udi=${filters!.udi}'; + } + } + var response = await http.get( + Uri.parse(url), + headers: { + 'Authorization': User.token, + }, + ); + + var testResultData = json.decode(response.body); + if (pageNumber == 1) { + originalItems = []; + } + + for (var item in testResultData['data']['data']) { + originalItems!.add( + PackageResultObject( + createdAt: item['created_at'], + id: item['id'].toString(), + name: item['name'], + ), + ); + } + pageNumber += 1; + search(''); + } + + Future showPackageResult(String id) async { + var response = + await http.get(Uri.parse(Url.getPackageResult(id)), headers: { + 'Authorization': User.token, + }); + if (response.statusCode != 200) { + return PackageDetailObject( + id: 'null', + name: 'null', + description: 'null', + createDate: '2020-07-14 13:50:42', + hospitalName: 'null', + udi: 'null', + items: [], + ); + } + var data = json.decode(response.body)['data']; + List itemsList = []; + for (var item in data['items']) { + itemsList.add(item['id'].toString()); + } + print(data); + result = PackageDetailObject( + id: data['id'].toString(), + name: data['name'] != null ? data['name'] : '', + description: data['note'] != null ? data['note'] : '', + udi: data['udi'] != null ? data['udi'] : '', + createDate: data['created_at'] != null ? data['created_at'] : '', + hospitalName: + data['user'] != null ? data['user']['medical_center']['name'] : '', + items: itemsList, + ); + return result!; + } +} diff --git a/lib/providers/test_result_old.dart b/lib/providers/test_result_old.dart deleted file mode 100644 index 7be764c..0000000 --- a/lib/providers/test_result_old.dart +++ /dev/null @@ -1,38 +0,0 @@ -import '../config/urls.dart'; -import '../config/user.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; - -class TestResult with ChangeNotifier{ - final int id; - final String name; - final String date; - final String deviceId; - String result; - - bool get isVerified { - return result == 'Verified'; - } - - TestResult({ - this.id, - this.name, - this.date, - this.deviceId, - this.result, - }); - - Future toggleVerify() async { - final response = await http.post( - Uri.parse(Url.verifyTest(id)), headers: { - 'Authorization': User.token - } - ); - - if (response.statusCode == 200) { - result = result == 'Verified' ? 'NotVerified' : 'Verified'; - notifyListeners(); - } - - } -} diff --git a/lib/providers/test_results.dart b/lib/providers/test_results.dart index d4bd42a..e5cf297 100644 --- a/lib/providers/test_results.dart +++ b/lib/providers/test_results.dart @@ -1,375 +1,373 @@ -import 'dart:convert'; -import 'dart:typed_data'; -// import 'dart:typed_data'; -import 'package:dio/dio.dart' as di; - -import 'package:cssd/config/urls.dart'; -import 'package:cssd/config/user.dart'; -import 'package:cssd/models/test_result_models.dart'; -import 'package:file_picker/file_picker.dart'; -// import 'package:cssd/providers/test_result.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'package:random_string/random_string.dart'; -// import 'package:multi_image_picker/multi_image_picker.dart'; - -class TestResultsProvider with ChangeNotifier { - List catchImages = []; - List images = []; - - setImages() async { - images = []; - for (var image in catchImages) { - var result = image.bytes; - // final batchId = randomString(10); - // addImage(batchId, result, image.path); - images.add(result.buffer - .asUint8List(result.offsetInBytes, result.lengthInBytes)); - } - notifyListeners(); - } - - setCatchImages(List images) { - catchImages = images; - notifyListeners(); - } - - removeImage(int index) { - catchImages.removeAt(index); - notifyListeners(); - } - - // Future addImage() async { - // Map imgs = {}; - // var counter = 0; - // for (var image in images) { - // imgs[counter.toString()] = - // di.MultipartFile.fromBytes(image, filename: 'test$counter.jpg'); - // counter += 1; - // } - - // return 'True'; - // } - - String searchBoxValue = ''; - bool filterOn = false; - List items; - List originalItems; - // List items = []; - Map result; - - TestResultFilterObject _filters = TestResultFilterObject( - id: '', - labelID: '', - userName: '', - hospital: '', - testType: '', - fDate: '', - uDate: '', - ); - - void resetFilters() { - filterOn = false; - _filters = TestResultFilterObject( - id: '', - labelID: '', - userName: '', - hospital: '', - testType: '', - fDate: '', - uDate: '', - ); - } - - int pageNumber = 1; - void resetPageNumber() => pageNumber = 1; - bool isloading = false; - void resetLoading() { - isloading = false; - notifyListeners(); - } - - void setLoading() { - isloading = true; - // notifyListeners(); - } - - TestResultFilterObject get filters { - return _filters; - } - - void search(String value) { - print(value); - items = []; - searchBoxValue = value; - originalItems.forEach((result) { - if (result.name.toString().contains(searchBoxValue)) { - items.add(result); - } - }); - notifyListeners(); - } - - void setFilters(id, labelId, username, testType, hospital, fDate, uDate) { - pageNumber = 1; - _filters = TestResultFilterObject( - id: id, - labelID: labelId, - userName: username, - hospital: hospital, - testType: testType, - fDate: fDate, - uDate: uDate); - if (_filters.id == '' && - _filters.labelID == '' && - _filters.testType == '' && - _filters.hospital == '' && - _filters.userName == '' && - _filters.fDate == '' && - _filters.uDate == '') { - filterOn = false; - } else { - filterOn = true; - } - notifyListeners(); - } - - Future>> getFilterItems() async { - var response = await http.get( - Uri.parse(Url.filterItems), - headers: { - 'Authorization': User.token, - }, - ); - List> result = []; - Map hospitals = {}; - Map testTypes = {}; - - var filterDatas = json.decode(response.body); - for (var hospital in filterDatas['data']['MedicalCenters']) { - hospitals.addAll({hospital['name']: hospital['id'].toString()}); - } - result.add(hospitals); - for (var testType in filterDatas['data']['TestTypes']) { - testTypes.addAll({testType['name']: testType['id'].toString()}); - } - result.add(testTypes); - - return result; - } - - Future getTestResults() async { - String url = Url.testResults(pageNumber); - if (filterOn) { - items = []; - if (_filters.id != '') { - url += '&device_id=${_filters.id}'; - } - if (_filters.labelID != '') { - url += '&device_label=${_filters.labelID}'; - } - if (_filters.hospital != '') { - url += '&medicalCenter_id=${_filters.hospital}'; - } - if (_filters.testType != '') { - url += '&testType_id=${_filters.testType}'; - } - if (_filters.userName != '') { - url += '&user_name=${_filters.userName}'; - } - if (_filters.fDate != '') { - url += '&fromPicker=${_filters.fDate}'; - } - if (_filters.uDate != '') { - url += '&upToPicker=${_filters.uDate}'; - } - print(url); - } - //'device_id=3526&testType_id=107&medicalCenter_id=2&user_name=erfan&fromPicker=2020-05-12&upToPicker=2020-05-19&device_label=Instrument%20ID&page=1' - var response = await http.get( - Uri.parse(url), - headers: { - 'Authorization': User.token, - // 'X-Requested-With': 'XMLHttpRequest', - }, - ); - - var testResultData = json.decode(response.body); - - if (pageNumber == 1) { - originalItems = []; - items = []; - } - for (var item in testResultData['data']['data']) { - print(item); - originalItems.add( - TestResultObject( - id: item['id'].toString(), - name: item['test_type'] != null ? item['test_type']['name'] : '', - deviceId: item['device_id'].toString(), - result: item['result'] == 'Accept' ? 'Accepted' : 'Not Accepted', - date: item['created_at'].toString().substring(0, 10), - hospital: item['user']['medical_center']['name'], - verified: item['verified'].toString(), - ), - ); - } - pageNumber += 1; - search(''); - notifyListeners(); - } - - static Future updateTestResult(String id, values) async { - var response = await http.post( - Uri.parse(Url.updateTestResult(id)), - body: json.encode(values), - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" - }, - ); - print(response.body); - } - - Future addImage(String batchId, dynamic file, String fileName) async { - var imageListInt = file.cast(); - var dio = new di.Dio(); - dio.options.headers = { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - 'Content-Type': 'application/json', - }; - di.FormData formData = new di.FormData.fromMap({ - "batch_id": batchId, - 'model_type': 'TestResult', - "file": di.MultipartFile.fromBytes(imageListInt, filename: fileName) - }); - - await dio.post( - Url.addImage, - data: formData, - ); - // print(response.statusCode); - // print(response.statusMessage); - // print(response.data); - - return 'Added'; - } - - Future createTestResult(values, batchId) async { - final batchId = randomString(10); - - for (var image in catchImages) { - await addImage(batchId, image.bytes, image.path); - } - dynamic vals = values; - vals['file_batch_id'] = batchId; - - // int counter = 0; - // if (images.length != 0) { - // for (var image in images) { - // vals['imgs'][counter.toString()] = base64Encode( - // image, - // ); - // counter += 1; - // } - // } - - var dio = new di.Dio(); - dio.options.headers = { - 'Authorization': User.token, - // 'X-Requested-With': 'XMLHttpRequest' - }; - var response = await dio.post( - Url.createTestResult, - data: vals, - ); - print(response.data); - if (response.data['status'] == 'Success') { - catchImages = []; - return 'done'; - } else { - return 'error'; - } - // var response = await http - // .post(Url.createTestResult, body: json.encode(values), headers: { - // 'Authorization': User.token, - // 'X-Requested-With': 'XMLHttpRequest', - // "Content-Type": "application/json", - // "Accept": "application/json" - // }); - - // print(response.body); - } - - Future> showTestResult(String id) async { - var response = await http.get(Uri.parse(Url.getTestResult(id)), headers: { - 'Authorization': User.token, - }); - - var data = json.decode(response.body)['data']; - // print(data); - result = { - 'id': data['id'], - 'auto_cleave_id': data['inputs']['Autoclave ID'] != null - ? data['inputs']['Autoclave ID'] - : '', - 'test_code': data['test_type_id'] != null ? data['test_type_id'] : '', - 'date': data['created_at'] != null ? data['created_at'] : '', - 'accepted': originalItems - .firstWhere((element) => element.id == data['id'].toString()) - .result, //az api safheye asli estefade mishavad - 'description': - data['inputs']['Note'] != null ? data['inputs']['Note'] : '', - 'test_type_name': - data['test_type']['name'] != null ? data['test_type']['name'] : '', - 'hospital': originalItems - .firstWhere((element) => element.id == data['id'].toString()) - .hospital // az api safheye asli estefade mi shavad - }; - return result; - } - - Future removeTestResult(String id) async { - var response = await http.post(Uri.parse(Url.removeTestResult(id)), body: { - '_method': 'delete' - }, headers: { - 'Authorization': User.token, - }); - - if (response.statusCode == 200) { - items.removeWhere((item) { - return item.id.toString() == id; - }); - } - - notifyListeners(); - return true; - } - - Future changeVerification(String id, String value) async { - print(id); - print(value); - var response = await http.post( - Uri.parse(Url.testResultVerification(id, value)), - headers: { - 'Authorization': User.token, - 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" - }, - ); - var testResultData = json.decode(response.body); - // print(response.body); - try { - if (testResultData['status'] == 'Success') { - return true; - } else { - return false; - } - } catch (e) {} - return false; - } -} +import 'dart:convert'; +import 'dart:typed_data'; +// import 'dart:typed_data'; +import 'package:dio/dio.dart' as di; + +import 'package:cssd/config/urls.dart'; +import 'package:cssd/config/user.dart'; +import 'package:cssd/models/test_result_models.dart'; +import 'package:file_picker/file_picker.dart'; +// import 'package:cssd/providers/test_result.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:random_string/random_string.dart'; +// import 'package:multi_image_picker/multi_image_picker.dart'; + +class TestResultsProvider with ChangeNotifier { + List catchImages = []; + List images = []; + String testType = ''; + String testCode = ''; + + setImages() async { + images = []; + for (var image in catchImages) { + var result = image.bytes; + // final batchId = randomString(10); + // addImage(batchId, result, image.path); + images.add(result!.buffer + .asUint8List(result.offsetInBytes, result.lengthInBytes)); + } + notifyListeners(); + } + + setCatchImages(List images) { + catchImages = images; + notifyListeners(); + } + + removeImage(int index) { + catchImages.removeAt(index); + notifyListeners(); + } + + // Future addImage() async { + // Map imgs = {}; + // var counter = 0; + // for (var image in images) { + // imgs[counter.toString()] = + // di.MultipartFile.fromBytes(image, filename: 'test$counter.jpg'); + // counter += 1; + // } + + // return 'True'; + // } + + String searchBoxValue = ''; + bool filterOn = false; + List? items; + List? originalItems; + Map? result; + + TestResultFilterObject _filters = TestResultFilterObject( + id: '', + labelID: '', + userName: '', + hospital: '', + testType: '', + fDate: '', + uDate: '', + ); + + void resetFilters() { + filterOn = false; + _filters = TestResultFilterObject( + id: '', + labelID: '', + userName: '', + hospital: '', + testType: '', + fDate: '', + uDate: '', + ); + } + + int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; + bool isloading = false; + void resetLoading() { + isloading = false; + notifyListeners(); + } + + void setLoading() { + isloading = true; + // notifyListeners(); + } + + TestResultFilterObject get filters { + return _filters; + } + + void search(String value) { + print(value); + items = []; + searchBoxValue = value; + originalItems!.forEach((result) { + if (result.name.toString().contains(searchBoxValue)) { + items!.add(result); + } + }); + notifyListeners(); + } + + void setFilters(id, labelId, username, testType, hospital, fDate, uDate) { + pageNumber = 1; + _filters = TestResultFilterObject( + id: id, + labelID: labelId, + userName: username, + hospital: hospital, + testType: testType, + fDate: fDate, + uDate: uDate); + if (_filters.id == '' && + _filters.labelID == '' && + _filters.testType == '' && + _filters.hospital == '' && + _filters.userName == '' && + _filters.fDate == '' && + _filters.uDate == '') { + filterOn = false; + } else { + filterOn = true; + } + notifyListeners(); + } + + Future>> getFilterItems() async { + var response = await http.get( + Uri.parse(Url.filterItems), + headers: { + 'Authorization': User.token, + }, + ); + List> result = []; + Map hospitals = {}; + Map testTypes = {}; + + var filterDatas = json.decode(response.body); + for (var hospital in filterDatas['data']['MedicalCenters']) { + hospitals.addAll({hospital['name']: hospital['id'].toString()}); + } + result.add(hospitals); + for (var testType in filterDatas['data']['TestTypes']) { + testTypes.addAll({testType['name']: testType['id'].toString()}); + } + result.add(testTypes); + + return result; + } + + Future getTestResults() async { + String url = Url.testResults(pageNumber); + if (filterOn) { + items = []; + if (_filters.id != '') { + url += '&device_id=${_filters.id}'; + } + if (_filters.labelID != '') { + url += '&device_label=${_filters.labelID}'; + } + if (_filters.hospital != '') { + url += '&medicalCenter_id=${_filters.hospital}'; + } + if (_filters.testType != '') { + url += '&testType_id=${_filters.testType}'; + } + if (_filters.userName != '') { + url += '&user_name=${_filters.userName}'; + } + if (_filters.fDate != '') { + url += '&fromPicker=${_filters.fDate}'; + } + if (_filters.uDate != '') { + url += '&upToPicker=${_filters.uDate}'; + } + print(url); + } + //'device_id=3526&testType_id=107&medicalCenter_id=2&user_name=erfan&fromPicker=2020-05-12&upToPicker=2020-05-19&device_label=Instrument%20ID&page=1' + var response = await http.get( + Uri.parse(url), + headers: { + 'Authorization': User.token, + }, + ); + + var testResultData = json.decode(response.body); + if (pageNumber == 1) { + originalItems = []; + } + + for (var item in testResultData['data']['data']) { + originalItems!.add( + TestResultObject( + id: item['id'].toString(), + name: item['test_type'] != null ? item['test_type']['name'] : '', + deviceId: item['device_id'].toString(), + result: item['result'] == 'Accept' ? 'Accepted' : 'Not Accepted', + date: item['created_at'].toString().substring(0, 10), + hospital: item['user']['medical_center']['name'], + verified: item['verified'].toString(), + ), + ); + } + pageNumber += 1; + search(''); + notifyListeners(); + } + + static Future updateTestResult(String id, values) async { + var response = await http.post( + Uri.parse(Url.updateTestResult(id)), + body: json.encode(values), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + print(response.body); + } + + Future addImage(String batchId, dynamic file, String fileName) async { + var imageListInt = file.cast(); + var dio = new di.Dio(); + dio.options.headers = { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json', + }; + di.FormData formData = new di.FormData.fromMap({ + "batch_id": batchId, + 'model_type': 'TestResult', + "file": di.MultipartFile.fromBytes(imageListInt, filename: fileName) + }); + + await dio.post( + Url.addImage, + data: formData, + ); + // print(response.statusCode); + // print(response.statusMessage); + // print(response.data); + + return 'Added'; + } + + Future createTestResult(values, batchId) async { + final batchId = randomString(10); + + for (var image in catchImages) { + await addImage(batchId, image.bytes, image.path!); + } + dynamic vals = values; + vals['file_batch_id'] = batchId; + + // int counter = 0; + // if (images.length != 0) { + // for (var image in images) { + // vals['imgs'][counter.toString()] = base64Encode( + // image, + // ); + // counter += 1; + // } + // } + + var dio = new di.Dio(); + dio.options.headers = { + 'Authorization': User.token, + // 'X-Requested-With': 'XMLHttpRequest' + }; + var response = await dio.post( + Url.createTestResult, + data: vals, + ); + print(response.data); + if (response.data['status'] == 'Success') { + catchImages = []; + return 'done'; + } else { + return 'error'; + } + // var response = await http + // .post(Url.createTestResult, body: json.encode(values), headers: { + // 'Authorization': User.token, + // 'X-Requested-With': 'XMLHttpRequest', + // "Content-Type": "application/json", + // "Accept": "application/json" + // }); + + // print(response.body); + } + + Future> showTestResult(String id) async { + var response = await http.get(Uri.parse(Url.getTestResult(id)), headers: { + 'Authorization': User.token, + }); + + var data = json.decode(response.body)['data']; + // print(data); + result = { + 'id': data['id'], + 'auto_cleave_id': data['inputs']['Autoclave ID'] != null + ? data['inputs']['Autoclave ID'] + : '', + 'test_code': data['test_type_id'] != null ? data['test_type_id'] : '', + 'date': data['created_at'] != null ? data['created_at'] : '', + 'accepted': originalItems! + .firstWhere((element) => element.id == data['id'].toString()) + .result, //az api safheye asli estefade mishavad + 'description': + data['inputs']['Note'] != null ? data['inputs']['Note'] : '', + 'test_type_name': + data['test_type']['name'] != null ? data['test_type']['name'] : '', + 'hospital': originalItems! + .firstWhere((element) => element.id == data['id'].toString()) + .hospital // az api safheye asli estefade mi shavad + }; + return result!; + } + + Future removeTestResult(String id) async { + var response = await http.post(Uri.parse(Url.removeTestResult(id)), body: { + '_method': 'delete' + }, headers: { + 'Authorization': User.token, + }); + + if (response.statusCode == 200) { + items!.removeWhere((item) { + return item.id.toString() == id; + }); + } + + notifyListeners(); + return true; + } + + Future changeVerification(String id, String value) async { + print(id); + print(value); + var response = await http.post( + Uri.parse(Url.testResultVerification(id, value)), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + var testResultData = json.decode(response.body); + // print(response.body); + try { + if (testResultData['status'] == 'Success') { + return true; + } else { + return false; + } + } catch (e) {} + return false; + } +} diff --git a/lib/providers/users.dart b/lib/providers/users.dart new file mode 100644 index 0000000..b459f0c --- /dev/null +++ b/lib/providers/users.dart @@ -0,0 +1,85 @@ +import 'dart:convert'; + +import 'package:cssd/config/urls.dart'; +import 'package:cssd/config/user.dart'; +import 'package:cssd/models/users_model.dart'; +import 'package:flutter/foundation.dart'; + +import 'package:http/http.dart' as http; + +class UsersProvider extends ChangeNotifier { + String searchBoxValue = ''; + + List? usersBox; + List? originalUsersBox; + + String? medicalCenterId; + + int? selectedUserIndex; + + String? saveUserId; + + bool isLoading = false; + void resetLoading() { + isLoading = false; + notifyListeners(); + } + + void setLoading() { + isLoading = true; + } + + void selectUser(int index) { + selectedUserIndex = index; + notifyListeners(); + } + + void searchUsers(String value) { + usersBox = []; + searchBoxValue = value; + originalUsersBox!.forEach((result) { + if (result.id.toString().contains(searchBoxValue) || + result.userName.toString().contains(searchBoxValue)) { + usersBox!.add(result); + } + }); + notifyListeners(); + } + + Future getUsers(String medicalCenterId) async { + String url = Url.getUsers(medicalCenterId); + var response = await http.get( + Uri.parse(url), + headers: {'Authorization': User.token, "Accept": "application/json"}, + ); + + var usersData = json.decode(response.body); + + originalUsersBox = []; + + for (var user in usersData['data']['data']) { + originalUsersBox!.add( + Users( + userName: user['name'], + id: user['id'].toString(), + phoneNumber: user['cell_number'].toString(), + ), + ); + } + } + + Future getUserMedicalCenter() async { + final response = await http.get( + Uri.parse(Url.getUserInfo), + headers: {'Authorization': User.token}, + ); + if (response.statusCode == 200) { + var data = json.decode(response.body)['data']; + medicalCenterId = data['user']['medical_center_id'].toString(); + notifyListeners(); + return medicalCenterId; + } else { + return ''; + } + } +} diff --git a/lib/utils/scan.dart b/lib/utils/scan.dart new file mode 100644 index 0000000..0accaf6 --- /dev/null +++ b/lib/utils/scan.dart @@ -0,0 +1,26 @@ +import 'package:barcode_scan2/platform_wrapper.dart'; +import 'package:flutter/services.dart'; + +Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + try { + var id = barcode.rawContent.contains('www.cssd-doc.com') + ? barcode.rawContent.split('/')[5] + : barcode.rawContent; + + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } +} diff --git a/lib/widgets/CycleScreens/Add/add_label_box.dart b/lib/widgets/CycleScreens/Add/add_label_box.dart index d4ff237..efcb524 100644 --- a/lib/widgets/CycleScreens/Add/add_label_box.dart +++ b/lib/widgets/CycleScreens/Add/add_label_box.dart @@ -1,251 +1,212 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/cycles.dart'; - -class CycleAddLabelBox extends StatelessWidget { - const CycleAddLabelBox({ - Key key, - @required double deviceBlockSize, - @required this.labelValues, - @required this.labelVals, - @required this.initialLabelValue, - @required this.index, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController labelValues; - final List labelVals; - final String initialLabelValue; - final int index; - - @override - Widget build(BuildContext context) { - return Container( - // color: Colors.blue, - height: 150, - child: Stack( - children: [ - Container( - padding: EdgeInsets.only( - right: 10, - bottom: 30, - left: 10, - top: 10, - ), - decoration: BoxDecoration( - border: Border( - left: BorderSide(color: Colors.black, width: 2), - right: BorderSide(color: Colors.grey), - bottom: BorderSide(color: Colors.grey), - top: BorderSide(color: Colors.grey), - ), - ), - height: 120, - child: Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 7 * _deviceBlockSize, - ), - SizedBox( - width: 4 * _deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - SizedBox( - width: _deviceBlockSize, - ), - Text( - 'Select Labels Included', - style: TextStyle( - fontSize: 3.5 * _deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w100, - ), - ), - ], - ), - Row( - children: [ - Container( - width: MediaQuery.of(context).size.width - - (40 * _deviceBlockSize), - // height: 30, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: EdgeInsets.only( - left: _deviceBlockSize, - ), - border: InputBorder.none, - ), - iconSize: 7 * _deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric( - horizontal: 0), - child: TextFormField( - controller: labelValues, - decoration: InputDecoration( - contentPadding: EdgeInsets.only( - bottom: 12, - ), - isDense: true, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - isDense: true, - items: labelVals.map((val) { - return new DropdownMenuItem( - value: val, - child: Container( - child: Text( - val, - style: TextStyle( - fontSize: 4 * _deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - Provider.of(context, - listen: false) - .changeLabelVal(val, index); - // setState(() { - // labelValues[index] - // .text = val; - // }); - }, - ), - ), - Spacer(), - InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - Provider.of(context, - listen: false) - .changeLabelVal(result, index); - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ) - ], - ), - ]), - ), - ], - ), - ), - ), - Positioned( - bottom: 15, - right: 0, - child: InkWell( - onTap: () { - Provider.of(context).addLabelVal(); - // setState( - // () { - // curLabelVal += 1; - // TextEditingController lbl = - // new TextEditingController(); - // lbl.text = initialLabelValue; - // labelValues.add(lbl); - // }, - // ); - }, - child: Container( - padding: EdgeInsets.all(3), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.deepOrange, - ), - child: Icon( - Icons.add, - color: Colors.white, - ), - ), - ), - ), - ], - ), - ); - } - - Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } - } -} +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/cycles.dart'; + +class AddLabelBox extends StatelessWidget { + const AddLabelBox({ + Key? key, + required double deviceBlockSize, + required this.values, + required this.vals, + required this.initialLabelValue, + required this.index, + required this.text, + this.iconColor, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController values; + final List vals; + final String initialLabelValue; + final int index; + final String text; + final Color? iconColor; + + @override + Widget build(BuildContext context) { + return Container( + height: 150, + child: Stack( + children: [ + Container( + padding: EdgeInsets.only( + right: 10, + bottom: 25, + left: 10, + top: 10, + ), + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.black, width: 2), + right: BorderSide(color: Colors.grey), + bottom: BorderSide(color: Colors.grey), + top: BorderSide(color: Colors.grey), + ), + ), + height: 120, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * _deviceBlockSize, + ), + SizedBox( + width: 4 * _deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Text( + text, + style: TextStyle( + fontSize: 3.5 * _deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w100, + ), + ), + ], + ), + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width - + (40 * _deviceBlockSize), + // height: 30, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only( + left: _deviceBlockSize, + ), + border: InputBorder.none, + ), + iconSize: 7 * _deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric( + horizontal: 0), + child: TextFormField( + controller: values, + decoration: InputDecoration( + contentPadding: EdgeInsets.only( + bottom: 12, + ), + isDense: true, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + isDense: true, + items: vals.map((val) { + return new DropdownMenuItem( + value: val, + child: Container( + child: Text( + val, + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + Provider.of(context, + listen: false) + .changeLabelVal(val!, index); + }, + ), + ), + Spacer(), + InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + Provider.of(context, + listen: false) + .changeLabelVal(result, index); + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ) + ], + ), + ]), + ), + ], + ), + ), + ), + Positioned( + bottom: 15, + right: 0, + child: InkWell( + onTap: () { + Provider.of(context).addLabelVal(); + }, + child: Container( + padding: EdgeInsets.all(3), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: iconColor, + ), + child: Icon( + Icons.add, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Add/cycle_update_button.dart b/lib/widgets/CycleScreens/Add/cycle_update_button.dart new file mode 100644 index 0000000..0212211 --- /dev/null +++ b/lib/widgets/CycleScreens/Add/cycle_update_button.dart @@ -0,0 +1,94 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/cycles.dart'; + +import '../../../config/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class CycleUpdateButton extends StatelessWidget { + const CycleUpdateButton({ + Key? key, + required GlobalKey form, + required this.id, + required this.descriptionCTRL, + required this.cycleNumberCTRL, + required this.dateCTRL, + // required this.labelValue, + required this.striizerIdCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final String id; + final TextEditingController descriptionCTRL; + final TextEditingController cycleNumberCTRL; + final TextEditingController dateCTRL; + // final TextEditingController labelValue; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + // List labels = []; + // for (TextEditingController label in labelValue) { + // labels.add(label.text); + // } + Provider.of(context, listen: false).updateCycleResult( + id, + striizerIdCTRL.text, + cycleNumberCTRL.text, + // labelValue.text, + dateCTRL.text, + descriptionCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Cycle updated.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.cycleResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPink, kPinkSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Update', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Add/date_picker.dart b/lib/widgets/CycleScreens/Add/date_picker.dart index 45857f8..f21e877 100644 --- a/lib/widgets/CycleScreens/Add/date_picker.dart +++ b/lib/widgets/CycleScreens/Add/date_picker.dart @@ -1,77 +1,79 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; -class CycleAddDatePicker extends StatefulWidget { - const CycleAddDatePicker({ - Key key, - @required this.dateCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, super(key: key); - - final TextEditingController dateCTRL; - final double _deviceBlockSize; - - @override - _CycleAddDatePickerState createState() => _CycleAddDatePickerState(); -} - -class _CycleAddDatePickerState extends State { - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () async { - var res = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2010, 1), - lastDate: DateTime(2101), - ); - if (res != null) { - // dateTimeFrom = res; - setState( - () { - widget.dateCTRL.text = DateFormat('y-M-d').format(res); - // dateValue = DateFormat('y-M-d').format( - // dateTimeFrom, - // ); // baraye tavize makane gharar giri baraye api - }, - ); - } - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: TextField( - enabled: false, - controller: widget.dateCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * widget._deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * widget._deviceBlockSize, - ), - labelText: 'Date', - isDense: true, - contentPadding: EdgeInsets.only( - bottom: 7, - right: 3, - left: 3, - ), - // border: InputBorder.none, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - Icon(FontAwesomeIcons.angleDown) - ], - ), - ); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; + +class CycleAddDatePicker extends StatefulWidget { + const CycleAddDatePicker({ + Key? key, + required this.dateCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController dateCTRL; + final double _deviceBlockSize; + + @override + _CycleAddDatePickerState createState() => _CycleAddDatePickerState(); +} + +class _CycleAddDatePickerState extends State { + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () async { + var res = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2010, 1), + lastDate: DateTime(2101), + ); + if (res != null) { + // dateTimeFrom = res; + setState( + () { + widget.dateCTRL.text = DateFormat('y-M-d').format(res); + // dateValue = DateFormat('y-M-d').format( + // dateTimeFrom, + // ); // baraye tavize makane gharar giri baraye api + }, + ); + } + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: TextField( + enabled: false, + controller: widget.dateCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * widget._deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * widget._deviceBlockSize, + ), + labelText: 'Date', + isDense: true, + contentPadding: EdgeInsets.only( + bottom: 7, + right: 3, + left: 3, + ), + // border: InputBorder.none, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + Icon(FontAwesomeIcons.angleDown) + ], + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Add/save_button.dart b/lib/widgets/CycleScreens/Add/save_button.dart index 60a5c72..573fbf2 100644 --- a/lib/widgets/CycleScreens/Add/save_button.dart +++ b/lib/widgets/CycleScreens/Add/save_button.dart @@ -1,91 +1,92 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/cycles.dart'; - -class CycleAddSaveButton extends StatelessWidget { - const CycleAddSaveButton({ - Key key, - @required GlobalKey form, - @required this.labelValues, - @required this.cycleNumberCTRL, - @required this.dateValue, - @required this.descriptionCTRL, - @required this.striizerIdCTRL, - @required double deviceBlockSize, - }) : _form = form, - _deviceBlockSize = deviceBlockSize, - super(key: key); - - final GlobalKey _form; - final List labelValues; - final TextEditingController cycleNumberCTRL; - final String dateValue; - final TextEditingController descriptionCTRL; - final TextEditingController striizerIdCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - - List labels = []; - for (TextEditingController label in labelValues) { - labels.add(label.text); - } - Provider.of(context).createCycleResult( - cycleNumberCTRL.text, - dateValue, - labels, - descriptionCTRL.text, - striizerIdCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Cycle added.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).pushReplacementNamed(Routes.cycleResultScreen); - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.red, Colors.orange], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'SAVE', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../providers/cycles.dart'; + +class CycleAddSaveButton extends StatelessWidget { + const CycleAddSaveButton({ + Key? key, + required GlobalKey form, + required this.labelValues, + required this.cycleNumberCTRL, + required this.dateValue, + required this.descriptionCTRL, + required this.striizerIdCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final List labelValues; + final TextEditingController cycleNumberCTRL; + final String dateValue; + final TextEditingController descriptionCTRL; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + + List labels = []; + for (TextEditingController label in labelValues) { + labels.add(label.text); + } + Provider.of(context, listen: false).createCycleResult( + cycleNumberCTRL.text, + dateValue, + labels, + descriptionCTRL.text, + striizerIdCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Cycle added.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.cycleResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPink, kPinkSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Details/datas_box.dart b/lib/widgets/CycleScreens/Details/datas_box.dart index e6a62ec..d5e9cb3 100644 --- a/lib/widgets/CycleScreens/Details/datas_box.dart +++ b/lib/widgets/CycleScreens/Details/datas_box.dart @@ -1,291 +1,296 @@ -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../../../models/cycles_models.dart'; - -class CycleDetailsDataBox extends StatelessWidget { - const CycleDetailsDataBox({ - Key key, - @required this.datas, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final CycleDetailObject datas; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - SizedBox( - height: 10, - ), - Text( - 'CYCLE DETAILS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(235, 235, 235, 1), - border: Border( - left: BorderSide( - color: Colors.black54, - width: 2, - ), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas.createDate, - ), - ), - style: TextStyle( - color: Colors.red, - ), - ), - Divider(), - Text( - 'ID: ${datas.id}', - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterilizer ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.sterileId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Cycle Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.cycleNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('d-M-y').format( - DateTime.parse( - datas.date, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Description', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.description.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Hospital Name', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.hospitalName, - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 30, - ), - Text( - 'LABELS INCLUDED', - style: TextStyle( - color: Colors.orange, - letterSpacing: 3, - fontWeight: FontWeight.w700, - fontSize: 4.5 * _deviceBlockSize, - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - border: Border.all( - color: Colors.grey, - ), - ), - child: ListView.separated( - shrinkWrap: true, - itemBuilder: (ctx, index) => RichText( - text: TextSpan( - text: 'Label ID ', - style: TextStyle( - color: Colors.grey, - fontFamily: 'montserrat', - ), - // style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: datas.labels[index], - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.orange, - ), - ), - ], - ), - ), - separatorBuilder: (ctx, index) => Divider(), - itemCount: datas.labels.length, - ), - ), - SizedBox( - height: 50, - ) - ], - ), - ), - SizedBox(height: 20,), - InkWell( - onTap: () async=> await launch( - 'https://cssd-doc.com/Show/Cycle/${datas.id.toString()}', - // forceSafariVC: true, - // forceWebView: true, - // headers: {'my_header_key': 'my_header_value'}, - // child: Text('Show Full Details'), - ), - child: Container( - padding: EdgeInsets.symmetric(vertical: 20), - width: double.infinity, - decoration: BoxDecoration( - color: Color.fromRGBO(230, 230, 230, 1), - borderRadius: BorderRadius.circular(25), - ), - child: Center( - child: Text( - 'Show More Details', - style: TextStyle(fontWeight: FontWeight.w700), - ), - ), - ), - ), - SizedBox(height: 30,) - ], - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../../models/cycles_models.dart'; + +class CycleDetailsDataBox extends StatelessWidget { + const CycleDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final CycleDetailObject datas; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Cycle Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kPink, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: kPink, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kPink, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterilizer ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.sterileId.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Cycle Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.cycleNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.date, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 30, + ), + Text( + 'Labels included', + style: TextStyle( + color: kPink, + letterSpacing: 3, + fontWeight: FontWeight.w700, + fontSize: 4.5 * _deviceBlockSize, + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: Colors.grey, + ), + ), + child: ListView.separated( + shrinkWrap: true, + itemBuilder: (ctx, index) => RichText( + text: TextSpan( + text: 'Label ID ', + style: TextStyle( + color: Colors.grey, + fontFamily: 'montserrat', + ), + // style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: datas.labels[index], + style: TextStyle( + fontWeight: FontWeight.bold, + color: kPink, + ), + ), + ], + ), + ), + separatorBuilder: (ctx, index) => Divider(), + itemCount: datas.labels.length, + ), + ), + SizedBox( + height: 50, + ) + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/Cycle/${datas.id.toString()}', + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ), + SizedBox( + height: 30, + ) + ], + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Filter/date_picker.dart b/lib/widgets/CycleScreens/Filter/date_picker.dart index 641bf22..a0c5670 100644 --- a/lib/widgets/CycleScreens/Filter/date_picker.dart +++ b/lib/widgets/CycleScreens/Filter/date_picker.dart @@ -1,85 +1,86 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; -class CycleFilterDatePicker extends StatefulWidget { - const CycleFilterDatePicker({ - Key key, - @required this.dateCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final TextEditingController dateCTRL; - final double _deviceBlockSize; - - @override - _CycleFilterDatePickerState createState() => _CycleFilterDatePickerState(); -} - -class _CycleFilterDatePickerState extends State { - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () async { - var res = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2010, 1), - lastDate: DateTime(2101), - ); - if (res != null) { - // dateTimeFrom = res; - setState( - () { - widget.dateCTRL.text = DateFormat('y-M-d').format(res); - // dateValue = DateFormat('y-M-d').format( - // dateTimeFrom, - // ); // baraye tavize makane gharar giri baraye api - }, - ); - } - }, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: TextField( - enabled: false, - controller: widget.dateCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.calendarAlt, - size: 7 * widget._deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * widget._deviceBlockSize, - ), - labelText: 'Date', - isDense: true, - contentPadding: EdgeInsets.only( - bottom: 5, - left: 2, - ), - // border: InputBorder.none, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - Icon(FontAwesomeIcons.angleDown) - ], - ), - // Divider( - // color: Colors.grey, - // ) - ], - ), - ); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; + +class CycleFilterDatePicker extends StatefulWidget { + const CycleFilterDatePicker({ + Key? key, + required this.dateCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController dateCTRL; + final double _deviceBlockSize; + + @override + _CycleFilterDatePickerState createState() => _CycleFilterDatePickerState(); +} + +class _CycleFilterDatePickerState extends State { + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () async { + var res = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2010, 1), + lastDate: DateTime(2101), + ); + if (res != null) { + // dateTimeFrom = res; + setState( + () { + widget.dateCTRL.text = DateFormat('y-M-d').format(res); + // dateValue = DateFormat('y-M-d').format( + // dateTimeFrom, + // ); // baraye tavize makane gharar giri baraye api + }, + ); + } + }, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: TextField( + enabled: false, + controller: widget.dateCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.calendarAlt, + size: 7 * widget._deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * widget._deviceBlockSize, + ), + labelText: 'Date', + isDense: true, + contentPadding: EdgeInsets.only( + bottom: 5, + left: 2, + ), + // border: InputBorder.none, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + Icon(FontAwesomeIcons.angleDown) + ], + ), + // Divider( + // color: Colors.grey, + // ) + ], + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Filter/save_button.dart b/lib/widgets/CycleScreens/Filter/save_button.dart index c6bb674..da628c5 100644 --- a/lib/widgets/CycleScreens/Filter/save_button.dart +++ b/lib/widgets/CycleScreens/Filter/save_button.dart @@ -1,90 +1,89 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/cycles.dart'; - -class CycleFilterSaveButton extends StatelessWidget { - const CycleFilterSaveButton({ - Key key, - @required this.hospitalVals, - @required this.hospitalCTRL, - @required this.cycleIdCTRL, - @required this.cycleNumberCTRL, - @required this.striizerIdCTRL, - @required this.dateCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final List> hospitalVals; - final TextEditingController hospitalCTRL; - final TextEditingController cycleIdCTRL; - final TextEditingController cycleNumberCTRL; - final TextEditingController striizerIdCTRL; - final TextEditingController dateCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - String hospitalID; - hospitalVals.forEach( - (hospital) { - if (hospital['name'] == hospitalCTRL.text) { - hospitalID = hospital['id']; - } - }, - ); - Provider.of(context).setFilters( - cycleIdCTRL.text, - cycleNumberCTRL.text, - striizerIdCTRL.text, - hospitalID, - dateCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Filters changed.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).popAndPushNamed(Routes.cycleResultScreen); - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 5, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.red, Colors.orange], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'FILTER', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../providers/cycles.dart'; + +class CycleFilterSaveButton extends StatelessWidget { + const CycleFilterSaveButton({ + Key? key, + required this.hospitalVals, + required this.hospitalCTRL, + required this.cycleIdCTRL, + required this.cycleNumberCTRL, + required this.striizerIdCTRL, + required this.dateCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final List> hospitalVals; + final TextEditingController hospitalCTRL; + final TextEditingController cycleIdCTRL; + final TextEditingController cycleNumberCTRL; + final TextEditingController striizerIdCTRL; + final TextEditingController dateCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + String? hospitalID; + hospitalVals.forEach( + (hospital) { + if (hospital['name'] == hospitalCTRL.text) { + hospitalID = hospital['id']!; + } + }, + ); + Provider.of(context, listen: false).setFilters( + cycleIdCTRL.text, + cycleNumberCTRL.text, + striizerIdCTRL.text, + hospitalID, + dateCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(Routes.cycleResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPink, kPinkSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Filter/selector_box.dart b/lib/widgets/CycleScreens/Filter/selector_box.dart index 8d92960..9247967 100644 --- a/lib/widgets/CycleScreens/Filter/selector_box.dart +++ b/lib/widgets/CycleScreens/Filter/selector_box.dart @@ -1,131 +1,126 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class CycleFilterSelectorBox extends StatefulWidget { - const CycleFilterSelectorBox( - {Key key, - @required double deviceBlockSize, - @required this.hospitalCTRL, - @required this.hospitalVals, - @required String label}) - : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController hospitalCTRL; - final List> hospitalVals; - final String _label; - - @override - _CycleFilterSelectorBoxState createState() => _CycleFilterSelectorBoxState(); -} - -class _CycleFilterSelectorBoxState extends State { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 7 * widget._deviceBlockSize, - ), - SizedBox( - width: 4 * widget._deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - SizedBox( - width: widget._deviceBlockSize, - ), - Text( - widget._label, - style: TextStyle( - fontSize: 3.5 * widget._deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w100, - ), - ), - ], - ), - Container( - // height: 30, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: EdgeInsets.only( - left: widget._deviceBlockSize, - ), - border: InputBorder.none, - ), - iconSize: 7 * widget._deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric( - horizontal: 0, - ), - child: TextFormField( - controller: widget.hospitalCTRL, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(bottom: 15), - isDense: true, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - ), - ), - ), - isDense: true, - items: widget.hospitalVals.map((val) { - return new DropdownMenuItem( - value: val['name'], - child: Container( - child: Text( - val['name'], - style: TextStyle( - // color: _mainFontColor, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - widget.hospitalCTRL.text = val; - // packageValue[1] = val; - // packageCTRL.text = val; - // packageVals.forEach((package) { - // if (package['name'] == val) { - // packageValue[0] = package['id']; - // } - // }); - }); - }, - ), - ), - ]), - ), - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class FilterHospitalBox extends StatefulWidget { + const FilterHospitalBox( + {Key? key, + required double deviceBlockSize, + required this.hospitalCTRL, + required this.hospitalVals, + required String label}) + : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController hospitalCTRL; + final List> hospitalVals; + final String _label; + + @override + _FilterHospitalBoxState createState() => _FilterHospitalBoxState(); +} + +class _FilterHospitalBoxState extends State { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * widget._deviceBlockSize, + ), + SizedBox( + width: 4 * widget._deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + SizedBox( + width: widget._deviceBlockSize, + ), + Text( + widget._label, + style: TextStyle( + fontSize: 3.5 * widget._deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w100, + ), + ), + ], + ), + Container( + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only( + left: widget._deviceBlockSize, + ), + border: InputBorder.none, + ), + iconSize: 7 * widget._deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric( + horizontal: 0, + ), + child: TextFormField( + controller: widget.hospitalCTRL, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(bottom: 15), + isDense: true, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + ), + ), + ), + isDense: true, + items: widget.hospitalVals.map((val) { + return new DropdownMenuItem( + value: val['name'], + child: Container( + child: Text( + val['name']!, + style: TextStyle( + // color: _mainFontColor, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState( + () { + widget.hospitalCTRL.text = val!; + }, + ); + }, + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Result/banner.dart b/lib/widgets/CycleScreens/Result/banner.dart index 2a9d3c1..d8499d6 100644 --- a/lib/widgets/CycleScreens/Result/banner.dart +++ b/lib/widgets/CycleScreens/Result/banner.dart @@ -1,46 +1,50 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../../config/routes.dart'; - -class CycleResultBanner extends StatelessWidget { - const CycleResultBanner({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Row( - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - 'CYCLES', - style: TextStyle( - color: Colors.black, - fontSize: 7 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 2, - ), - ), - Spacer(), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).popAndPushNamed(Routes.cycleFilterScreen); - }, - child: Container( - padding: EdgeInsets.all(5), - child: Icon( - FontAwesomeIcons.filter, - size: 7 * _deviceBlockSize, - ), - ), - ), - ], - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class ResultBanner extends StatelessWidget { + const ResultBanner({ + Key? key, + required double deviceBlockSize, + required this.text, + required this.push, + this.hasFilterObject = true, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final String text; + final String push; + final bool hasFilterObject; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Text( + text, + style: TextStyle( + color: Colors.black, + fontSize: 7 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + Spacer(), + if (hasFilterObject) + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).popAndPushNamed(push); + }, + child: Container( + padding: EdgeInsets.all(5), + child: Icon( + FontAwesomeIcons.filter, + size: 7 * _deviceBlockSize, + ), + ), + ), + ], + ); + } +} diff --git a/lib/widgets/CycleScreens/Result/data_box.dart b/lib/widgets/CycleScreens/Result/data_box.dart index 8bc3f0f..ad91b2c 100644 --- a/lib/widgets/CycleScreens/Result/data_box.dart +++ b/lib/widgets/CycleScreens/Result/data_box.dart @@ -1,140 +1,205 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; - -import '../../../config/routes.dart'; -import '../../../models/cycles_models.dart'; - -class CycleItemBox extends StatelessWidget { - final CycleResultObject item; - final String labels; - - const CycleItemBox({ - Key key, - @required double deviceBlockSize, - this.item, - this.labels, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - Routes.cycleDetailScreen, - arguments: item.id, - ), - child: Card( - elevation: 1, - child: Container( - padding: EdgeInsets.all(10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.all(8.0), - child: Text( - item.id, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - SizedBox( - width: 3 * _deviceBlockSize, - ), - // Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 50 * _deviceBlockSize, - child: Text( - 'Label Included:', - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - color: Colors.grey, - ), - ), - ), - Container( - width: 50 * _deviceBlockSize, - child: Text( - labels, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 3 * _deviceBlockSize, - ), - ), - ), - Container( - width: 50 * _deviceBlockSize, - child: Row( - children: [ - Text( - 'Date:', - style: TextStyle( - color: Colors.grey, - fontSize: 3 * _deviceBlockSize, - ), - ), - Text( - DateFormat('y-M-d').format( - DateTime.parse( - item.createdAt, - ), - ), - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - ), - ), - ], - ), - ) - ], - ), - Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed( - Routes.cycleDetailScreen, - arguments: item.id, - ); - // TestDetail(testResultId: item.id.toString()); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.fileAlt, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ], - ), - ), - ), - ); - } -} +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/cycles.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../models/cycles_models.dart'; + +class CycleItemBox extends StatelessWidget { + final CycleResultObject? item; + final String? labels; + + const CycleItemBox({ + Key? key, + required double deviceBlockSize, + this.item, + this.labels, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.cycleDetailScreen, + arguments: item!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6), + child: Text( + item!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 30 * _deviceBlockSize, + child: Text( + 'Label Included:', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + ), + Container( + width: 40 * _deviceBlockSize, + child: Text( + labels!, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Date:', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + DateFormat('y-M-d').format( + DateTime.parse( + item!.createdAt, + ), + ), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ) + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.cycleUpdateScreen, + arguments: item!.id, + ); + }, + child: Icon( + Icons.edit, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Cycle?', + ), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of(context, + listen: false) + .removeCycles(item!.id); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: Icon( + Icons.delete, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.cycleDetailScreen, + arguments: item!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/CycleScreens/Result/filter_objects.dart b/lib/widgets/CycleScreens/Result/filter_objects.dart index 76c3d9c..08c3ebd 100644 --- a/lib/widgets/CycleScreens/Result/filter_objects.dart +++ b/lib/widgets/CycleScreens/Result/filter_objects.dart @@ -1,115 +1,109 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/cycles.dart'; - -class CycleFilterBaner extends StatelessWidget { - const CycleFilterBaner({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - Navigator.of(context).popAndPushNamed(Routes.cycleFilterScreen); - }, - child: Chip( - backgroundColor: Colors.black, - label: Text( - 'Filters', - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - FontAwesomeIcons.filter, - color: Colors.white, - size: 4 * _deviceBlockSize, - ), - onDeleted: () { - Navigator.of(context).popAndPushNamed(Routes.cycleFilterScreen); - }, - ), - ); - } -} - -class CycleFilterChip extends StatelessWidget { - const CycleFilterChip({ - Key key, - @required double deviceBlockSize, - @required String label, - @required String id, - @required String cycleNumber, - @required String sterilizerId, - @required String hospital, - @required String date, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - _id = id, - _cycleNumber = cycleNumber, - _sterilizerId = sterilizerId, - _hospital = hospital, - _date = date, - super(key: key); - - final double _deviceBlockSize; - final String _label; - final String _id; - final String _cycleNumber; - final String _sterilizerId; - final String _hospital; - final String _date; - - @override - Widget build(BuildContext context) { - return Row(children: [ - SizedBox( - width: _deviceBlockSize, - ), - Chip( - backgroundColor: Colors.black, - label: Text( - _label, - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - Icons.close, - color: Colors.white, - ), - onDeleted: () { - var cycleProvider = Provider.of(context); - cycleProvider.setFilters( - _id, - _cycleNumber, - _sterilizerId, - _hospital, - _date, - ); - // cycle.resetPageNumber(); - // cycle.setFilters( - // '', - // cycle.filters.cycleNumber, - // cycle.filters.sterilizerId, - // cycle.filters.hospital, - // cycle.filters.date, - // ); - cycleProvider.setLoading(); - cycleProvider.getCycleResults().then((_) { - cycleProvider.resetLoading(); - }); - // _reloadItems(); - }, - ), - ]); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/cycles.dart'; + +class FilterBanner extends StatelessWidget { + const FilterBanner({ + Key? key, + required double deviceBlockSize, + required this.push, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final String push; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + Navigator.of(context).popAndPushNamed(push); + }, + child: Chip( + backgroundColor: Colors.black, + label: Text( + 'Filters', + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + FontAwesomeIcons.filter, + color: Colors.white, + size: 4 * _deviceBlockSize, + ), + onDeleted: () { + Navigator.of(context).popAndPushNamed(push); + }, + ), + ); + } +} + +class CycleFilterChip extends StatelessWidget { + const CycleFilterChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String cycleNumber, + required String sterilizerId, + required String hospital, + required String date, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _id = id, + _cycleNumber = cycleNumber, + _sterilizerId = sterilizerId, + _hospital = hospital, + _date = date, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _id; + final String _cycleNumber; + final String _sterilizerId; + final String _hospital; + final String _date; + + @override + Widget build(BuildContext context) { + return Row(children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var cycleProvider = + Provider.of(context, listen: false); + cycleProvider.setFilters( + _id, + _cycleNumber, + _sterilizerId, + _hospital, + _date, + ); + cycleProvider.setLoading(); + cycleProvider.getCycleResults().then((_) { + cycleProvider.resetLoading(); + }); + // _reloadItems(); + }, + ), + ]); + } +} diff --git a/lib/widgets/CycleScreens/Result/search_box.dart b/lib/widgets/CycleScreens/Result/search_box.dart index 98159b5..e2a4a5f 100644 --- a/lib/widgets/CycleScreens/Result/search_box.dart +++ b/lib/widgets/CycleScreens/Result/search_box.dart @@ -1,47 +1,49 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/cycles.dart'; -class CycleResultSearchBox extends StatelessWidget { - const CycleResultSearchBox({ - Key key, - @required this.searchCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final TextEditingController searchCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return TextField( - onEditingComplete: () { - FocusScope.of(context).unfocus(); - }, - controller: searchCTRL, - onChanged: (value) { - Provider.of(context, listen: false).search(value); - }, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.search, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Search by cycle ID', - isDense: true, - contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - ); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class ResultSearchBox extends StatelessWidget { + const ResultSearchBox({ + Key? key, + required this.searchCTRL, + required double deviceBlockSize, + required this.text, + required this.onChanged, + this.text2 = 'ID', + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController searchCTRL; + final double _deviceBlockSize; + final String text; + final String text2; + final dynamic onChanged; + + @override + Widget build(BuildContext context) { + return TextField( + onEditingComplete: () { + FocusScope.of(context).unfocus(); + }, + controller: searchCTRL, + onChanged: onChanged, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.search, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Search by $text $text2', + isDense: true, + contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ); + } +} diff --git a/lib/widgets/Global/drawer.dart b/lib/widgets/Global/drawer.dart index 574209a..fe7b3b8 100644 --- a/lib/widgets/Global/drawer.dart +++ b/lib/widgets/Global/drawer.dart @@ -1,183 +1,343 @@ -// import 'package:cssd/pages/test_result_screen.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../config/routes.dart'; - -class AppDrawer extends StatelessWidget { - @override - Widget build(BuildContext context) { - return SafeArea( - child: SizedBox( - width: 250, - child: Drawer( - child: Container( - padding: EdgeInsets.all(20), - decoration: BoxDecoration( - color: Colors.black, - ), - child: Column( - children: [ - ListTile( - leading: CircleAvatar( - backgroundColor: Colors.white, - ), - title: Text( - 'CSSD', - style: TextStyle( - color: Colors.white, - ), - ), - ), - Divider( - color: Colors.white, - ), - InkWell( - onTap: () => - Navigator.of(context).pushNamed(Routes.myInfoScreen), - child: Container( - padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), - margin: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - gradient: - LinearGradient(colors: [Colors.blue, Colors.green]), - borderRadius: BorderRadius.circular(5), - ), - child: Row( - children: [ - Icon( - Icons.person_outline, - color: Colors.white, - ), - SizedBox( - width: 10, - ), - Text( - 'My Info', - style: TextStyle( - color: Colors.white, - ), - ) - ], - ), - ), - ), - InkWell( - onTap: () => - Navigator.of(context).pushNamed(Routes.testResultScreen), - child: Container( - padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), - margin: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - ), - child: Row( - children: [ - Icon( - Icons.assignment, - color: Colors.white, - ), - SizedBox( - width: 10, - ), - Text( - 'Test Results', - style: TextStyle( - color: Colors.white, - ), - ) - ], - ), - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pushNamed(Routes.labelResultScreen); - }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), - margin: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - ), - child: Row( - children: [ - Icon( - FontAwesomeIcons.tag, - color: Colors.white, - ), - SizedBox( - width: 10, - ), - Text( - 'Labels', - style: TextStyle( - color: Colors.white, - ), - ) - ], - ), - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pushNamed(Routes.cycleResultScreen); - }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), - margin: EdgeInsets.only(top: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - ), - child: Row( - children: [ - Icon( - Icons.refresh, - color: Colors.white, - ), - SizedBox( - width: 10, - ), - Text( - 'Circles', - style: TextStyle( - color: Colors.white, - ), - ) - ], - ), - ), - ), - Container( - margin: EdgeInsets.only(left: 20), - child: ListTile( - leading: Icon(Icons.phone_bluetooth_speaker), - title: Text('All Test Result'), - dense: true, - ), - ), - Container( - margin: EdgeInsets.only(left: 20), - child: ListTile( - leading: Icon(Icons.settings), - title: Text('Manage Users'), - dense: true, - ), - ), - Container( - margin: EdgeInsets.only(left: 20), - child: ListTile( - leading: Icon(Icons.label), - title: Text('Manage Medical Center'), - dense: true, - ), - ), - ], - ), - ), - elevation: 0, - ), - ), - ); - } -} +// import 'package:cssd/pages/test_result_screen.dart'; +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../config/routes.dart'; + +class AppDrawer extends StatefulWidget { + @override + State createState() => _AppDrawerState(); +} + +class _AppDrawerState extends State { + Map? user; + + @override + void didChangeDependencies() async { + var authObj = Provider.of(context, listen: false); + user = await authObj.getUserData(); + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: SizedBox( + width: 250, + child: Drawer( + child: Container( + padding: EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.black, + ), + child: Column( + children: [ + ListTile( + leading: CircleAvatar( + backgroundColor: kLightBlue, + child: Icon( + Icons.person, + color: Colors.white, + ), + ), + title: Text( + user?['name'] != null ? user!['name'] : '', + style: TextStyle( + color: Colors.white, + ), + ), + ), + Divider( + color: Colors.white, + ), + Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: kLightBlue, + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.dashboard, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Dashboard', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + InkWell( + onTap: () => + Navigator.of(context).pushNamed(Routes.myInfoScreen), + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.person_outline, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'My Info', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () => + Navigator.of(context).pushNamed(Routes.testResultScreen), + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.assignment, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Test Results', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.labelResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + FontAwesomeIcons.tag, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Labels', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.cycleResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.refresh, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Cycles', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.packageResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.all_inbox_rounded, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Packages', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.myItemsResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.inbox_rounded, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'My Packages', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.itemResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.book, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Items', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pushNamed(Routes.myItemsResultScreen); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5, horizontal: 15), + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + Icons.my_library_books, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'My Items', + style: TextStyle( + color: Colors.white, + ), + ) + ], + ), + ), + ), + // Container( + // margin: EdgeInsets.only(left: 20), + // child: ListTile( + // leading: Icon(Icons.phone_bluetooth_speaker), + // title: Text('All Test Result'), + // dense: true, + // ), + // ), + // Container( + // margin: EdgeInsets.only(left: 20), + // child: ListTile( + // leading: Icon(Icons.settings), + // title: Text('Manage Users'), + // dense: true, + // ), + // ), + // Container( + // margin: EdgeInsets.only(left: 20), + // child: ListTile( + // leading: Icon(Icons.label), + // title: Text('Manage Medical Center'), + // dense: true, + // ), + // ), + ], + ), + ), + elevation: 0, + ), + ), + ); + } +} diff --git a/lib/widgets/Global/input_box.dart b/lib/widgets/Global/input_box.dart index e655ef7..119fd0c 100644 --- a/lib/widgets/Global/input_box.dart +++ b/lib/widgets/Global/input_box.dart @@ -1,50 +1,51 @@ -import 'package:flutter/material.dart'; - -class InputBox extends StatelessWidget { - const InputBox({ - Key key, - @required double deviceBlockSize, - this.lable, - this.initialValue, - this.ico, this.isPass, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - final String lable; - final String initialValue; - final IconData ico; - final bool isPass; - - @override - Widget build(BuildContext context) { - return Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - ico, - color: Colors.grey, - ), - SizedBox( - width: _deviceBlockSize, - ), - Expanded( - child: TextFormField( - decoration: InputDecoration( - isDense: false, - // border: UnderlineInputBorder(), - fillColor: Colors.red, - labelText: lable, - contentPadding: EdgeInsets.all(0), - ), - style: TextStyle( - fontSize: 6 * _deviceBlockSize, - ), - initialValue: initialValue, - ), - ), - ], - ); - } -} +import 'package:flutter/material.dart'; + +class InputBox extends StatelessWidget { + const InputBox({ + Key? key, + required double deviceBlockSize, + this.lable, + this.initialValue, + this.ico, + this.isPass, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final String? lable; + final String? initialValue; + final IconData? ico; + final bool? isPass; + + @override + Widget build(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + ico, + color: Colors.grey, + ), + SizedBox( + width: _deviceBlockSize, + ), + Expanded( + child: TextFormField( + decoration: InputDecoration( + isDense: false, + // border: UnderlineInputBorder(), + fillColor: Colors.red, + labelText: lable, + contentPadding: EdgeInsets.all(0), + ), + style: TextStyle( + fontSize: 6 * _deviceBlockSize, + ), + initialValue: initialValue, + ), + ), + ], + ); + } +} diff --git a/lib/widgets/Global/internet_error.dart b/lib/widgets/Global/internet_error.dart index 8bca2f5..aa2b144 100644 --- a/lib/widgets/Global/internet_error.dart +++ b/lib/widgets/Global/internet_error.dart @@ -1,10 +1,10 @@ -import 'package:flutter/material.dart'; - -class ConnectionErrorBox extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Center( - child: Text('Please connect to the Internet ! !'), - ); - } -} +import 'package:flutter/material.dart'; + +class ConnectionErrorBox extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Center( + child: Text('Please connect to the Internet ! !'), + ); + } +} diff --git a/lib/widgets/Global/page_header.dart b/lib/widgets/Global/page_header.dart index 7acaac8..935def4 100644 --- a/lib/widgets/Global/page_header.dart +++ b/lib/widgets/Global/page_header.dart @@ -1,51 +1,51 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class PageHeader extends StatelessWidget { - const PageHeader({ - Key key, - @required double deviceBlockSize, - @required String label, - @required String route, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - _route = route, - super(key: key); - - final double _deviceBlockSize; - final String _label; - final String _route; - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Container( - child: Text( - _label, - style: TextStyle( - color: Colors.black, - fontSize: 7 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 2, - ), - ), - ), - Spacer(), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).popAndPushNamed(_route); - }, - child: Container( - padding: EdgeInsets.all(5), - child: Icon( - FontAwesomeIcons.filter, - size: 7 * _deviceBlockSize, - ), - ), - ), - ], - ); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class PageHeader extends StatelessWidget { + const PageHeader({ + Key? key, + required double deviceBlockSize, + required String label, + required String route, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _route = route, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _route; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Container( + child: Text( + _label, + style: TextStyle( + color: Colors.black, + fontSize: 7 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + ), + Spacer(), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).popAndPushNamed(_route); + }, + child: Container( + padding: EdgeInsets.all(5), + child: Icon( + FontAwesomeIcons.filter, + size: 7 * _deviceBlockSize, + ), + ), + ), + ], + ); + } +} diff --git a/lib/widgets/Global/splash_screen.dart b/lib/widgets/Global/splash_screen.dart index e287656..ddfa57a 100644 --- a/lib/widgets/Global/splash_screen.dart +++ b/lib/widgets/Global/splash_screen.dart @@ -1,12 +1,23 @@ -import 'package:flutter/material.dart'; - -class SplashScreen extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Text('Loading...'), - ), - ); - } -} +import 'package:flutter/material.dart'; + +class SplashScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator( + color: Colors.black, + ), + SizedBox( + width: 5.0, + ), + Text('Loading...'), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Add/item_save_button.dart b/lib/widgets/ItemScreens/Add/item_save_button.dart new file mode 100644 index 0000000..5928c8f --- /dev/null +++ b/lib/widgets/ItemScreens/Add/item_save_button.dart @@ -0,0 +1,90 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class ItemAddSaveButton extends StatelessWidget { + const ItemAddSaveButton({ + Key? key, + required GlobalKey form, + this.batchId, + required this.nameCTRL, + required this.descriptionCTRL, + required this.udiCTRL, + required double deviceBlockSize, + required this.sizeCTRL, + required this.specificCTRL, + required this.dateValue, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final TextEditingController nameCTRL; + final TextEditingController descriptionCTRL; + final TextEditingController udiCTRL; + final TextEditingController sizeCTRL; + final TextEditingController specificCTRL; + final String dateValue; + final String? batchId; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + Provider.of(context, listen: false).createItemResult( + nameCTRL.text, + sizeCTRL.text, + specificCTRL.text, + udiCTRL.text, + descriptionCTRL.text, + batchId, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Item added.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.itemResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kBlue, kBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Add/item_update_button.dart b/lib/widgets/ItemScreens/Add/item_update_button.dart new file mode 100644 index 0000000..0ad4783 --- /dev/null +++ b/lib/widgets/ItemScreens/Add/item_update_button.dart @@ -0,0 +1,90 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/items.dart'; + +import '../../../config/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ItemUpdateButton extends StatelessWidget { + const ItemUpdateButton({ + Key? key, + required GlobalKey form, + required this.id, + required this.descriptionCTRL, + required this.nameCTRL, + required this.udiCTRL, + required this.sizeCTRL, + required this.specificCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final String id; + final TextEditingController descriptionCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final TextEditingController sizeCTRL; + final TextEditingController specificCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + Provider.of(context, listen: false).updateItemResult( + id, + nameCTRL.text, + sizeCTRL.text, + specificCTRL.text, + udiCTRL.text, + descriptionCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Item updated.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.itemResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kBlue, kBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Update', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Add/upload_image.dart b/lib/widgets/ItemScreens/Add/upload_image.dart new file mode 100644 index 0000000..f3a4395 --- /dev/null +++ b/lib/widgets/ItemScreens/Add/upload_image.dart @@ -0,0 +1,186 @@ +import 'package:cssd/providers/items.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class UploaderImage extends StatelessWidget { + final double deviceBlockSize; + final ItemProvider providerObject; + const UploaderImage({ + super.key, + required this.deviceBlockSize, + required this.providerObject, + }); + + @override + Widget build(BuildContext context) { + return Container( + child: Directionality( + textDirection: TextDirection.rtl, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 20), + height: providerObject.catchImages.length != 0 ? 60 : 0, + child: ImageBox( + deviceBlockSize: deviceBlockSize, + itemProvider: providerObject, + ), + ), + SizedBox( + height: providerObject.catchImages.length != 0 ? 10 : 0, + ), + InkWell( + onTap: () async { + await loadAssets(context); + }, + child: Container( + width: MediaQuery.of(context).size.width - 40, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '+ Add an image or file from device', + textDirection: TextDirection.ltr, + style: TextStyle(color: Colors.white), + textAlign: TextAlign.center, + ), + ), + ), + ], + ), + ), + ); + } + + Future loadAssets(BuildContext context) async { + var providerObject = Provider.of(context, listen: false); + List files = providerObject.catchImages; + try { + var datas = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['jpg', 'png', 'bmp', 'jpeg', 'pdf', 'docx', 'doc'], + withData: true, + withReadStream: true, + ); + files += datas!.files; + } catch (_) {} + + providerObject.setCatchImages(files); + providerObject.setImages(); + } +} + +class ImageBox extends StatelessWidget { + const ImageBox({ + Key? key, + required double deviceBlockSize, + required ItemProvider itemProvider, + }) : _deviceBlockSize = deviceBlockSize, + _providerObject = itemProvider, + super(key: key); + + final double _deviceBlockSize; + final ItemProvider _providerObject; + + @override + Widget build(BuildContext context) { + return ListView.separated( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemBuilder: (ctx, index) { + bool isPdf = _providerObject.catchImages[index].path!.endsWith('pdf'); + bool isWord = + _providerObject.catchImages[index].path!.endsWith('docx') || + _providerObject.catchImages[index].path!.endsWith('doc'); + + // print(_providerObject.catchImages[index].path.endsWith('jpg')); + // .substring(_providerObject.catchImages[index].path.length - 4)); + return ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Container( + width: 60, + height: 60, + child: Stack( + children: [ + Positioned( + top: 10, + left: 0, + child: GestureDetector( + onTap: () => isPdf + ? print('pdf') + : isWord + ? print('word') + : Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => Container( + color: Colors.white, + child: Center( + child: Image.memory( + _providerObject + .catchImages[index].bytes!, + fit: BoxFit.contain, + ), + ), + ), + ), + ), + child: isPdf + ? Image.asset( + 'assets/Images/pdf.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : isWord + ? Image.asset( + 'assets/Images/word.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : Image.memory( + _providerObject.catchImages[index].bytes!, + // asset: _images[index], + width: 60, + height: 60, + fit: BoxFit.contain, + ), + ), + ), + Positioned( + top: 0, + right: 0, + child: GestureDetector( + onTap: () { + // setState(() { + _providerObject.removeImage(index); + // }); + }, + child: CircleAvatar( + backgroundColor: Colors.red, + radius: 10, + child: Icon( + Icons.close, + size: 12, + color: Colors.white, + ), + ), + ), + ) + ], + ), + ), + ); + }, + itemCount: _providerObject.catchImages.length, + separatorBuilder: (BuildContext context, int index) => SizedBox( + width: 3 * _deviceBlockSize, + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Details/item_detail_box.dart b/lib/widgets/ItemScreens/Details/item_detail_box.dart new file mode 100644 index 0000000..aacbeff --- /dev/null +++ b/lib/widgets/ItemScreens/Details/item_detail_box.dart @@ -0,0 +1,351 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class ItemDetailsDataBox extends StatelessWidget { + const ItemDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final ItemDetailObject datas; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + print(datas.status); + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Item Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kBlue, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createdAt, + ), + ), + style: TextStyle( + color: kBlue, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kBlue, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Item Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.name.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Size', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.size.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Specific', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.specific.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'User', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.userName.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'UDI', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.udi.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.createdAt, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospital, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Status', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.status == 1 ? 'Success' : 'Failure', + style: TextStyle( + fontWeight: FontWeight.w700, + color: datas.status == 1 ? kBlue : kPink, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/Item/${datas.id.toString()}', + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Filter/item_filter_button.dart b/lib/widgets/ItemScreens/Filter/item_filter_button.dart new file mode 100644 index 0000000..cca49f6 --- /dev/null +++ b/lib/widgets/ItemScreens/Filter/item_filter_button.dart @@ -0,0 +1,98 @@ +import 'package:cssd/providers/items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ItemFilterSaveButton extends StatelessWidget { + const ItemFilterSaveButton({ + Key? key, + this.hospitalVals, + this.hospitalCTRL, + required this.idCTRL, + required this.nameCTRL, + required this.udiCTRL, + required this.sizeCTRL, + required this.specificCTRL, + required this.firstColor, + required this.secondColor, + required this.push, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final List>? hospitalVals; + final TextEditingController? hospitalCTRL; + final TextEditingController idCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final TextEditingController sizeCTRL; + final TextEditingController specificCTRL; + final Color firstColor; + final Color secondColor; + final String push; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + String? hospitalID; + hospitalVals!.forEach( + (hospital) { + if (hospital['name'] == hospitalCTRL!.text) { + hospitalID = hospital['id']!; + } + }, + ); + Provider.of(context, listen: false).setFilters( + idCTRL.text, + nameCTRL.text, + udiCTRL.text, + hospitalID, + sizeCTRL.text, + specificCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(push); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + firstColor, + secondColor, + ], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/ItemScreens/Filter/item_filter_object.dart b/lib/widgets/ItemScreens/Filter/item_filter_object.dart new file mode 100644 index 0000000..b325043 --- /dev/null +++ b/lib/widgets/ItemScreens/Filter/item_filter_object.dart @@ -0,0 +1,76 @@ +import 'package:cssd/providers/items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class ItemFilterChip extends StatelessWidget { + const ItemFilterChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String name, + required String udi, + required String hospital, + required String size, + required String specific, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _id = id, + _name = name, + _udi = udi, + _hospital = hospital, + _size = size, + _specific = specific, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _id; + final String _name; + final String _udi; + final String _hospital; + final String _size; + final String _specific; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var itemProvider = + Provider.of(context, listen: false); + itemProvider.setFilters( + _id, + _name, + _udi, + _hospital, + _size, + _specific, + ); + itemProvider.setLoading(); + itemProvider.getItemResults().then( + (_) { + itemProvider.resetLoading(); + }, + ); + }, + ), + ], + ); + } +} diff --git a/lib/widgets/ItemScreens/Result/item_data_box.dart b/lib/widgets/ItemScreens/Result/item_data_box.dart new file mode 100644 index 0000000..9384606 --- /dev/null +++ b/lib/widgets/ItemScreens/Result/item_data_box.dart @@ -0,0 +1,244 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class ItemItemBox extends StatelessWidget { + final ItemResultObject? item; + + const ItemItemBox({ + Key? key, + required double deviceBlockSize, + this.item, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.itemDetailScreen, + arguments: item!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + item!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + item!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Size: ', + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + Text( + item!.size, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + item!.userName, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + Provider.of(context, + listen: false) + .changeStatus(item!.id) + .then( + (value) { + if (value) { + print('true'); + } + Navigator.of(context).popAndPushNamed( + Routes.itemResultScreen); + }, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 6 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: item!.status == 1 ? kPink : kBlue, + ), + child: Icon( + item!.status == 1 ? Icons.close : Icons.check, + size: 2 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 5.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + onTap: () { + Navigator.of(context).pushNamed( + Routes.itemUpdateScreen, + arguments: item!.id, + ); + }, + child: Icon( + Icons.edit, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Item?'), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of(context, + listen: false) + .removeItems(item!.id); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: Icon( + Icons.delete, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.itemDetailScreen, + arguments: item!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Add/add_package_box.dart b/lib/widgets/LabelScreens/Add/add_package_box.dart new file mode 100644 index 0000000..51f4b03 --- /dev/null +++ b/lib/widgets/LabelScreens/Add/add_package_box.dart @@ -0,0 +1,212 @@ +import 'package:cssd/providers/labels.dart'; +import 'package:cssd/utils/scan.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +class AddPackageBox extends StatelessWidget { + const AddPackageBox({ + Key? key, + required double deviceBlockSize, + required this.values, + required this.vals, + required this.initialLabelValue, + required this.index, + required this.text, + this.iconColor, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController values; + final List vals; + final String initialLabelValue; + final int index; + final String text; + final Color? iconColor; + + @override + Widget build(BuildContext context) { + return Container( + height: 150, + child: Stack( + children: [ + Container( + padding: EdgeInsets.only( + right: 10, + bottom: 25, + left: 10, + top: 10, + ), + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.black, width: 2), + right: BorderSide(color: Colors.grey), + bottom: BorderSide(color: Colors.grey), + top: BorderSide(color: Colors.grey), + ), + ), + height: 120, + child: Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * _deviceBlockSize, + ), + SizedBox( + width: 4 * _deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Text( + text, + style: TextStyle( + fontSize: 3.5 * _deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w100, + ), + ), + ], + ), + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width - + (40 * _deviceBlockSize), + // height: 30, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only( + left: _deviceBlockSize, + ), + border: InputBorder.none, + ), + iconSize: 7 * _deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: + const EdgeInsets.symmetric(horizontal: 0), + child: TextFormField( + controller: values, + decoration: InputDecoration( + contentPadding: EdgeInsets.only( + bottom: 12, + ), + isDense: true, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + isDense: true, + items: vals.map((val) { + return new DropdownMenuItem( + value: val, + child: Container( + child: Text( + val, + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + Provider.of(context, + listen: false) + .changePackageVal(val!, index); + }, + ), + ), + Spacer(), + InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + Provider.of(context, + listen: false) + .changePackageVal(result, index); + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ) + ], + ), + ], + ), + ), + ], + ), + ), + ), + Positioned( + bottom: 15, + right: 0, + child: InkWell( + onTap: () { + Provider.of(context).addPackageVal(); + }, + child: Container( + padding: EdgeInsets.all(3), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: iconColor, + ), + child: Icon( + Icons.add, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Add/date_picker.dart b/lib/widgets/LabelScreens/Add/date_picker.dart index 6777aee..ea09309 100644 --- a/lib/widgets/LabelScreens/Add/date_picker.dart +++ b/lib/widgets/LabelScreens/Add/date_picker.dart @@ -1,73 +1,73 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart' as DateEditor; - -class LabelAddDatePicker extends StatefulWidget { - LabelAddDatePicker({ - Key key, - @required this.dateCTRL, - @required double deviceBlockSize, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final TextEditingController dateCTRL; - final double _deviceBlockSize; - final String _label; - - @override - _LabelAddDatePickerState createState() => _LabelAddDatePickerState(); -} - -class _LabelAddDatePickerState extends State { - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () async { - var res = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2010, 1), - lastDate: DateTime(2101), - ); - if (res != null) { - setState( - () { - widget.dateCTRL.text = DateEditor.DateFormat('y-M-d').format(res); - // sDateValue = - // DateEditor.DateFormat('y-M-d').format( - // dateTimeS, - // ); // baraye tavize makane gharar giri baraye api - }, - ); - } - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: TextField( - enabled: false, - controller: widget.dateCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.calendarAlt, - size: 7 * widget._deviceBlockSize, - ), - labelText: widget._label, - isDense: true, - contentPadding: EdgeInsets.only(bottom: 7, right: 3, left: 3), - // border: InputBorder.none, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - ), - ), - Icon(FontAwesomeIcons.angleDown) - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; + +class LabelAddDatePicker extends StatefulWidget { + LabelAddDatePicker({ + Key? key, + required this.dateCTRL, + required double deviceBlockSize, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final TextEditingController dateCTRL; + final double _deviceBlockSize; + final String _label; + + @override + _LabelAddDatePickerState createState() => _LabelAddDatePickerState(); +} + +class _LabelAddDatePickerState extends State { + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () async { + var res = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2010, 1), + lastDate: DateTime(2101), + ); + if (res != null) { + setState( + () { + widget.dateCTRL.text = DateEditor.DateFormat('y-M-d').format(res); + // sDateValue = + // DateEditor.DateFormat('y-M-d').format( + // dateTimeS, + // ); // baraye tavize makane gharar giri baraye api + }, + ); + } + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: TextField( + enabled: false, + controller: widget.dateCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.calendarAlt, + size: 7 * widget._deviceBlockSize, + ), + labelText: widget._label, + isDense: true, + contentPadding: EdgeInsets.only(bottom: 7, right: 3, left: 3), + // border: InputBorder.none, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + ), + ), + Icon(FontAwesomeIcons.angleDown) + ], + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Add/save_button.dart b/lib/widgets/LabelScreens/Add/save_button.dart index 002a869..dcb2241 100644 --- a/lib/widgets/LabelScreens/Add/save_button.dart +++ b/lib/widgets/LabelScreens/Add/save_button.dart @@ -1,91 +1,92 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/labels.dart'; - -class LabelAddSaveButton extends StatelessWidget { - const LabelAddSaveButton({ - Key key, - @required GlobalKey form, - @required this.lotNumberCTRL, - @required this.cycleNumberCTRL, - @required this.sDateCTRL, - @required this.packageValue, - @required this.eDateCTRL, - @required this.striizerIdCTRL, - @required double deviceBlockSize, - }) : _form = form, - _deviceBlockSize = deviceBlockSize, - super(key: key); - - final GlobalKey _form; - final TextEditingController lotNumberCTRL; - final TextEditingController cycleNumberCTRL; - final TextEditingController sDateCTRL; - final List packageValue; - final TextEditingController eDateCTRL; - final TextEditingController striizerIdCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - Provider.of(context).createLabelResult( - lotNumberCTRL.text, - cycleNumberCTRL.text, - sDateCTRL.text, - // sDateValue, - {'id': packageValue[0], 'name': packageValue[1]}, - eDateCTRL.text, - // eDateValue, - striizerIdCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Label added.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen); - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'SAVE', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../providers/labels.dart'; + +class LabelAddSaveButton extends StatelessWidget { + const LabelAddSaveButton({ + Key? key, + required GlobalKey form, + required this.lotNumberCTRL, + required this.cycleNumberCTRL, + required this.sDateCTRL, + required this.packageValue, + required this.eDateCTRL, + required this.striizerIdCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final TextEditingController lotNumberCTRL; + final TextEditingController cycleNumberCTRL; + final TextEditingController sDateCTRL; + final List packageValue; + final TextEditingController eDateCTRL; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + Provider.of(context, listen: false).createLabelResult( + lotNumberCTRL.text, + cycleNumberCTRL.text, + sDateCTRL.text, + // sDateValue, + {'id': packageValue[0], 'name': packageValue[1]}, + eDateCTRL.text, + // eDateValue, + striizerIdCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Label added.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kLightBlue, kLightBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Add/selector_box.dart b/lib/widgets/LabelScreens/Add/selector_box.dart index 0aba8c1..560735d 100644 --- a/lib/widgets/LabelScreens/Add/selector_box.dart +++ b/lib/widgets/LabelScreens/Add/selector_box.dart @@ -1,144 +1,149 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class LabelAddSelectorBox extends StatefulWidget { - const LabelAddSelectorBox({ - Key key, - @required double deviceBlockSize, - @required this.packageCTRL, - @required this.packageVals, - @required this.packageValue, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController packageCTRL; - final List> packageVals; - final List packageValue; - - @override - _LabelAddSelectorBoxState createState() => _LabelAddSelectorBoxState(); -} - -class _LabelAddSelectorBoxState extends State { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 7 * widget._deviceBlockSize, - ), - SizedBox( - width: 4 * widget._deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - SizedBox( - width: widget._deviceBlockSize, - ), - Text( - 'Package', - style: TextStyle( - fontSize: 3.5 * widget._deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w700), - ), - ], - ), - Container( - // height: 30, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: - EdgeInsets.only(left: widget._deviceBlockSize), - // border: InputBorder.none, - ), - iconSize: 7 * widget._deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric(horizontal: 0), - child: Text( - widget.packageCTRL.text, - textDirection: TextDirection.rtl, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - // Container( - // // width: 100, - // height: 70, - // padding: const EdgeInsets.symmetric(horizontal: 0), - // child: TextFormField( - // controller: widget.packageCTRL, - // decoration: InputDecoration( - // contentPadding: EdgeInsets.only(bottom: 15), - // isDense: true, - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // color: Colors.black, - // fontSize: 5 * widget._deviceBlockSize, - // ), - // ), - // ), - isDense: true, - items: widget.packageVals.map((val) { - return new DropdownMenuItem( - value: val['name'], - child: Container( - child: Text( - val['name'], - textDirection: TextDirection.rtl, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - widget.packageValue[1] = val; - widget.packageCTRL.text = val; - widget.packageVals.forEach((package) { - if (package['name'] == val) { - widget.packageValue[0] = package['id']; - } - }); - }); - }, - ), - ), - ]), - ), - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class LabelAddSelectorBox extends StatefulWidget { + const LabelAddSelectorBox({ + Key? key, + required double deviceBlockSize, + required this.packageCTRL, + required this.packageVals, + required this.packageValue, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController packageCTRL; + final List> packageVals; + final List packageValue; + + @override + _LabelAddSelectorBoxState createState() => _LabelAddSelectorBoxState(); +} + +class _LabelAddSelectorBoxState extends State { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * widget._deviceBlockSize, + ), + SizedBox( + width: 4 * widget._deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + SizedBox( + width: widget._deviceBlockSize, + ), + Text( + 'Package', + style: TextStyle( + fontSize: 3.5 * widget._deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w700), + ), + ], + ), + Container( + // height: 30, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: + EdgeInsets.only(left: widget._deviceBlockSize), + // border: InputBorder.none, + ), + iconSize: 7 * widget._deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric(horizontal: 0), + child: Text( + widget.packageCTRL.text, + textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + // Container( + // // width: 100, + // height: 70, + // padding: const EdgeInsets.symmetric(horizontal: 0), + // child: TextFormField( + // controller: widget.packageCTRL, + // decoration: InputDecoration( + // contentPadding: EdgeInsets.only(bottom: 15), + // isDense: true, + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // color: Colors.black, + // fontSize: 5 * widget._deviceBlockSize, + // ), + // ), + // ), + isDense: true, + items: widget.packageVals.map((val) { + return new DropdownMenuItem( + value: val['name'], + child: Container( + child: Text( + val['name'] ?? '', + textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState( + () { + widget.packageValue[1] = val!; + widget.packageCTRL.text = val; + widget.packageVals.forEach( + (package) { + if (package['name'] == val) { + widget.packageValue[0] = package['id'] ?? ''; + } + }, + ); + }, + ); + }, + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Add/update_button.dart b/lib/widgets/LabelScreens/Add/update_button.dart index ea67a90..1196e2a 100644 --- a/lib/widgets/LabelScreens/Add/update_button.dart +++ b/lib/widgets/LabelScreens/Add/update_button.dart @@ -1,93 +1,93 @@ -import '../../../config/routes.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import '../../../providers/labels.dart'; - -class LabelUpdateButton extends StatelessWidget { - const LabelUpdateButton({ - Key key, - @required GlobalKey form, - @required this.id, - @required this.lotNumberCTRL, - @required this.cycleNumberCTRL, - @required this.sDateCTRL, - @required this.packageValue, - @required this.eDateCTRL, - @required this.striizerIdCTRL, - @required double deviceBlockSize, - }) : _form = form, - _deviceBlockSize = deviceBlockSize, - super(key: key); - - final GlobalKey _form; - final String id; - final TextEditingController lotNumberCTRL; - final TextEditingController cycleNumberCTRL; - final TextEditingController sDateCTRL; - final List packageValue; - final TextEditingController eDateCTRL; - final TextEditingController striizerIdCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - Provider.of(context).updateLabelResult( - id, - lotNumberCTRL.text, - cycleNumberCTRL.text, - sDateCTRL.text, - // sDateValue, - {'id': packageValue[0], 'name': packageValue[1]}, - eDateCTRL.text, - // eDateValue, - striizerIdCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Label updated.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen); - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'UPDATE', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import 'package:flutter/material.dart'; +import '../../../providers/labels.dart'; + +class LabelUpdateButton extends StatelessWidget { + const LabelUpdateButton({ + Key? key, + required GlobalKey form, + required this.id, + required this.lotNumberCTRL, + required this.cycleNumberCTRL, + required this.sDateCTRL, + required this.packageValue, + required this.eDateCTRL, + required this.striizerIdCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final String id; + final TextEditingController lotNumberCTRL; + final TextEditingController cycleNumberCTRL; + final TextEditingController sDateCTRL; + final List packageValue; + final TextEditingController eDateCTRL; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + Provider.of(context, listen: false).updateLabelResult( + id, + lotNumberCTRL.text, + cycleNumberCTRL.text, + sDateCTRL.text, + {'id': packageValue[0]}, + eDateCTRL.text, + striizerIdCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Label updated.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kLightBlue, kLightBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Update', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Detail/datas_box.dart b/lib/widgets/LabelScreens/Detail/datas_box.dart index ffd110e..7f00b55 100644 --- a/lib/widgets/LabelScreens/Detail/datas_box.dart +++ b/lib/widgets/LabelScreens/Detail/datas_box.dart @@ -1,300 +1,302 @@ -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../../../models/label_models.dart'; - -class LabelDetailsDataBox extends StatelessWidget { - const LabelDetailsDataBox({ - Key key, - @required this.datas, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final LabelDetailsObject datas; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - SizedBox( - height: 10, - ), - Text( - 'LABEL DETAILS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(235, 235, 235, 1), - border: Border( - left: BorderSide( - color: Colors.black54, - width: 2, - ), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas.createDate, - ), - ), - style: TextStyle( - color: Colors.red, - ), - ), - Divider(), - Text( - 'ID: ${datas.id}', - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterilizer ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.sterileId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Cycle Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.cycleNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Lot Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.lotNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterile Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('y-M-d').format( - DateTime.parse( - datas.sterileDate, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Expire Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('y-M-d').format( - DateTime.parse( - datas.expireDate, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, color: Colors.red), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Package', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.package.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Hospital Name', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.hospitalName, - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - ], - ), - ), - SizedBox( - height: 20, - ), - InkWell( - onTap: () => launch( - 'https://cssd-doc.com/Show/Label/${datas.id.toString()}', - // forceSafariVC: true, - // forceWebView: true, - // headers: {'my_header_key': 'my_header_value'}, - // child: Text('Show Full Details'), - ), - child: Container( - padding: EdgeInsets.symmetric(vertical: 20), - width: double.infinity, - decoration: BoxDecoration( - color: Color.fromRGBO(230, 230, 230, 1), - borderRadius: BorderRadius.circular(25), - ), - child: Center( - child: Text( - 'Show More Details', - style: TextStyle(fontWeight: FontWeight.w700), - ), - ), - ), - ) - ], - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../../models/label_models.dart'; + +class LabelDetailsDataBox extends StatelessWidget { + const LabelDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final LabelDetailsObject datas; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Label Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kLightBlue, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: kLightBlue, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kLightBlue, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterilizer ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.sterileId.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Cycle Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.cycleNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Lot Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.lotNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterile Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('y-M-d').format( + DateTime.parse( + datas.sterileDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Expire Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('y-M-d').format( + DateTime.parse( + datas.expireDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: kPink, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Package', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.package.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () => launch( + 'https://cssd-doc.com/Show/Label/${datas.id.toString()}', + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ) + ], + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Detail/header.dart b/lib/widgets/LabelScreens/Detail/header.dart index 9cdebb3..8dcbdc3 100644 --- a/lib/widgets/LabelScreens/Detail/header.dart +++ b/lib/widgets/LabelScreens/Detail/header.dart @@ -1,36 +1,36 @@ -import 'package:flutter/material.dart'; - -class InfoHeader extends StatelessWidget { - const InfoHeader({ - Key key, - @required double deviceBlockSize, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final double _deviceBlockSize; - final String _label; - - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.only( - left: 20, - top: 20, - bottom: 10, - right: 20, - ), - child: Text( - _label, - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 7 * _deviceBlockSize, - letterSpacing: _deviceBlockSize, - fontWeight: FontWeight.w700, - ), - ), - ); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; + +class InfoHeader extends StatelessWidget { + const InfoHeader({ + Key? key, + required double deviceBlockSize, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final double _deviceBlockSize; + final String _label; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only( + left: 20, + top: 20, + bottom: 10, + right: 20, + ), + child: Text( + _label, + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 7 * _deviceBlockSize, + letterSpacing: _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Filter/save_button.dart b/lib/widgets/LabelScreens/Filter/save_button.dart index 2642d13..787cbd9 100644 --- a/lib/widgets/LabelScreens/Filter/save_button.dart +++ b/lib/widgets/LabelScreens/Filter/save_button.dart @@ -1,87 +1,88 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/labels.dart'; - -class LabelFilterSaveButton extends StatelessWidget { - const LabelFilterSaveButton({ - Key key, - @required this.hospitalVals, - @required this.hospitalCTRL, - @required this.labelIdCTRl, - @required this.cycleNumberCTRL, - @required this.striizerIdCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final List> hospitalVals; - final TextEditingController hospitalCTRL; - final TextEditingController labelIdCTRl; - final TextEditingController cycleNumberCTRL; - final TextEditingController striizerIdCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - String hospitalID; - hospitalVals.forEach( - (hospital) { - if (hospital['name'] == hospitalCTRL.text) { - hospitalID = hospital['id']; - } - }, - ); - Provider.of(context).setFilters( - labelIdCTRl.text, - cycleNumberCTRL.text, - striizerIdCTRL.text, - hospitalID, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Filters changed.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).popAndPushNamed(Routes.labelResultScreen); - }); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 5, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'FILTER', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../providers/labels.dart'; + +class LabelFilterSaveButton extends StatelessWidget { + const LabelFilterSaveButton({ + Key? key, + required this.hospitalVals, + required this.hospitalCTRL, + required this.labelIdCTRl, + required this.cycleNumberCTRL, + required this.striizerIdCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final List> hospitalVals; + final TextEditingController hospitalCTRL; + final TextEditingController labelIdCTRl; + final TextEditingController cycleNumberCTRL; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + String? hospitalID; + hospitalVals.forEach( + (hospital) { + if (hospital['name'] == hospitalCTRL.text) { + hospitalID = hospital['id']!; + } + }, + ); + Provider.of(context, listen: false).setFilters( + labelIdCTRl.text, + cycleNumberCTRL.text, + striizerIdCTRL.text, + hospitalID, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(Routes.labelResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kLightBlue, kLightBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Filter/selector_box.dart b/lib/widgets/LabelScreens/Filter/selector_box.dart index c0f9792..efc909a 100644 --- a/lib/widgets/LabelScreens/Filter/selector_box.dart +++ b/lib/widgets/LabelScreens/Filter/selector_box.dart @@ -1,114 +1,114 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class LabelFilterSelectorBox extends StatefulWidget { - const LabelFilterSelectorBox({ - Key key, - @required double deviceBlockSize, - @required this.hospitalCTRL, - @required this.hospitalVals, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController hospitalCTRL; - final List> hospitalVals; - - @override - _LabelFilterSelectorBoxState createState() => _LabelFilterSelectorBoxState(); -} - -class _LabelFilterSelectorBoxState extends State { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 7 * widget._deviceBlockSize, - ), - SizedBox( - width: 4 * widget._deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - 'Hospital', - style: TextStyle( - fontSize: 3.5 * widget._deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w700, - ), - ), - ], - ), - Container( - // height: 30, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: EdgeInsets.only(left: 0), - border: InputBorder.none, - ), - iconSize: 7 * widget._deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric(horizontal: 0), - child: TextFormField( - controller: widget.hospitalCTRL, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(bottom: 15), - isDense: true, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - ), - ), - ), - isDense: true, - items: widget.hospitalVals.map((val) { - return new DropdownMenuItem( - value: val['name'], - child: Container( - child: Text( - val['name'], - style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * widget._deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - widget.hospitalCTRL.text = val; - }); - }, - ), - ), - ]), - ), - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class LabelFilterSelectorBox extends StatefulWidget { + const LabelFilterSelectorBox({ + Key? key, + required double deviceBlockSize, + required this.hospitalCTRL, + required this.hospitalVals, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController hospitalCTRL; + final List> hospitalVals; + + @override + _LabelFilterSelectorBoxState createState() => _LabelFilterSelectorBoxState(); +} + +class _LabelFilterSelectorBoxState extends State { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * widget._deviceBlockSize, + ), + SizedBox( + width: 4 * widget._deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + 'Hospital', + style: TextStyle( + fontSize: 3.5 * widget._deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + Container( + // height: 30, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only(left: 0), + border: InputBorder.none, + ), + iconSize: 7 * widget._deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric(horizontal: 0), + child: TextFormField( + controller: widget.hospitalCTRL, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(bottom: 15), + isDense: true, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + ), + ), + ), + isDense: true, + items: widget.hospitalVals.map((val) { + return new DropdownMenuItem( + value: val['name'], + child: Container( + child: Text( + val['name']!, + style: TextStyle( + // color: _mainFontColor, + fontSize: 4 * widget._deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState(() { + widget.hospitalCTRL.text = val!; + }); + }, + ), + ), + ]), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Result/data_box.dart b/lib/widgets/LabelScreens/Result/data_box.dart index d30146e..7bae2d9 100644 --- a/lib/widgets/LabelScreens/Result/data_box.dart +++ b/lib/widgets/LabelScreens/Result/data_box.dart @@ -1,150 +1,192 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../../config/routes.dart'; -import '../../../models/label_models.dart'; - -class LabelItemBox extends StatelessWidget { - final LabelResultObject item; - const LabelItemBox({ - Key key, - @required double deviceBlockSize, - this.item, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () => Navigator.of(context).pushNamed( - Routes.labelDetailScreen, - arguments: item.id, - ), - child: Card( - elevation: 1, - child: Container( - padding: EdgeInsets.all(10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.all(8.0), - child: Text( - item.id, - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - SizedBox( - width: 3 * _deviceBlockSize, - ), - // Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 30 * _deviceBlockSize, - child: Text( - 'Package:', - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - color: Colors.grey, - ), - ), - ), - Container( - width: 40 * _deviceBlockSize, - child: Text( - item.package, - overflow: TextOverflow.ellipsis, - ), - ), - Container( - width: 30 * _deviceBlockSize, - child: Row( - children: [ - Text( - 'Exp:', - style: TextStyle( - color: Colors.grey, - fontSize: 3 * _deviceBlockSize, - ), - ), - Text( - item.expireDate, - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - ), - ), - ], - ), - ) - ], - ), - Spacer(), - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushReplacementNamed( - Routes.labelUpdateScreen, - arguments: item.id, - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.edit, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - SizedBox(width: _deviceBlockSize,), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed( - Routes.labelDetailScreen, - arguments: item.id, - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.fileAlt, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ) - ], - ), - ], - ), - ), - ), - ); - } -} +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/labels.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../models/label_models.dart'; + +class LabelItemBox extends StatelessWidget { + final LabelResultObject? item; + const LabelItemBox({ + Key? key, + required double deviceBlockSize, + this.item, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.labelDetailScreen, + arguments: item!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6), + child: Text( + item!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 30 * _deviceBlockSize, + child: Text( + 'Package:', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + ), + Container( + width: 40 * _deviceBlockSize, + child: Text( + item!.package, + overflow: TextOverflow.ellipsis, + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Exp:', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + item!.expireDate, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ) + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.labelUpdateScreen, + arguments: item!.id, + ); + }, + child: Icon( + Icons.edit, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Label?'), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of(context, + listen: false) + .removeLabels(item!.id); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: Icon( + Icons.delete, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.labelDetailScreen, + arguments: item!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Result/filter_chip_box.dart b/lib/widgets/LabelScreens/Result/filter_chip_box.dart index 54180fd..0760230 100644 --- a/lib/widgets/LabelScreens/Result/filter_chip_box.dart +++ b/lib/widgets/LabelScreens/Result/filter_chip_box.dart @@ -1,63 +1,65 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/labels.dart'; -class LabelFilterChip extends StatelessWidget { - const LabelFilterChip({ - Key key, - @required double deviceBlockSize, - @required String id, - @required String cycleNumber, - @required String sterilizerId, - @required String hospital, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _id = id, - _cycleNumber = cycleNumber, - _sterilizerId = sterilizerId, - _hispotal = hospital, - _label = label, - super(key: key); - - final double _deviceBlockSize; - final String _id; - final String _cycleNumber; - final String _sterilizerId; - final String _hispotal; - final String _label; - - @override - Widget build(BuildContext context) { - return Row(children: [ - SizedBox( - width: _deviceBlockSize, - ), - Chip( - backgroundColor: Colors.black, - label: Text( - _label, - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - Icons.close, - color: Colors.white, - ), - onDeleted: () { - var labelProviderObject = Provider.of(context); - labelProviderObject.setFilters( - _id, - _cycleNumber, - _sterilizerId, - _hispotal, - ); - labelProviderObject.setLoading(); - labelProviderObject.getLabelResults().then((_) { - labelProviderObject.resetLoading(); - }); - }, - ), - ]); - } -} \ No newline at end of file +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/labels.dart'; + +class LabelFilterChip extends StatelessWidget { + const LabelFilterChip({ + Key? key, + required double deviceBlockSize, + required String id, + required String cycleNumber, + required String sterilizerId, + required String hospital, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _id = id, + _cycleNumber = cycleNumber, + _sterilizerId = sterilizerId, + _hispotal = hospital, + _label = label, + super(key: key); + + final double _deviceBlockSize; + final String _id; + final String _cycleNumber; + final String _sterilizerId; + final String _hispotal; + final String _label; + + @override + Widget build(BuildContext context) { + return Row(children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.setFilters( + _id, + _cycleNumber, + _sterilizerId, + _hispotal, + ); + labelProviderObject.setLoading(); + labelProviderObject.getLabelResults().then((_) { + labelProviderObject.resetLoading(); + }); + }, + ), + ]); + } +} diff --git a/lib/widgets/LabelScreens/Result/floating_buttons.dart b/lib/widgets/LabelScreens/Result/floating_buttons.dart index 80f91dd..79aa5c5 100644 --- a/lib/widgets/LabelScreens/Result/floating_buttons.dart +++ b/lib/widgets/LabelScreens/Result/floating_buttons.dart @@ -1,62 +1,62 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../../config/routes.dart'; - -class LabelFloatingButtons extends StatelessWidget { - const LabelFloatingButtons({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed(Routes.labelScanScreen); - }, - child: Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 7.1 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - SizedBox( - width: 2 * _deviceBlockSize, - ), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.labelAddScreen); - }, - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.redAccent, - ), - child: Icon( - Icons.add, - size: 10 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; + +import '../../../config/routes.dart'; + +class LabelFloatingButtons extends StatelessWidget { + const LabelFloatingButtons({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.labelScanScreen); + }, + child: Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed(Routes.labelAddScreen); + }, + child: Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kLightBlue, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ); + } +} diff --git a/lib/widgets/LabelScreens/Result/search_box.dart b/lib/widgets/LabelScreens/Result/search_box.dart index aa6b271..92ce288 100644 --- a/lib/widgets/LabelScreens/Result/search_box.dart +++ b/lib/widgets/LabelScreens/Result/search_box.dart @@ -1,48 +1,48 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/labels.dart'; - -class LabelSearchBox extends StatelessWidget { - const LabelSearchBox({ - Key key, - @required this.searchCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final TextEditingController searchCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return TextField( - onEditingComplete: () { - FocusScope.of(context).unfocus(); - }, - onChanged: (value) { - Provider.of(context, listen: false).search(value); - }, - controller: searchCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.search, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Search by lable ID', - isDense: true, - contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/labels.dart'; + +class LabelSearchBox extends StatelessWidget { + const LabelSearchBox({ + Key? key, + required this.searchCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController searchCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return TextField( + onEditingComplete: () { + FocusScope.of(context).unfocus(); + }, + onChanged: (value) { + Provider.of(context, listen: false).search(value); + }, + controller: searchCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.search, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Search by label ID', + isDense: true, + contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ); + } +} diff --git a/lib/widgets/LabelScreens/Scan/input_box.dart b/lib/widgets/LabelScreens/Scan/input_box.dart index 67085e4..a19d202 100644 --- a/lib/widgets/LabelScreens/Scan/input_box.dart +++ b/lib/widgets/LabelScreens/Scan/input_box.dart @@ -1,54 +1,54 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class LabelScanInputBox extends StatelessWidget { - const LabelScanInputBox({ - Key key, - @required this.idCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final TextEditingController idCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return TextFormField( - validator: (val) { - if (val.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Or enter a label ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class LabelScanInputBox extends StatelessWidget { + const LabelScanInputBox({ + Key? key, + required this.idCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController idCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; + } + return null; + }, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Or enter a label ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, + ), + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ); + } +} diff --git a/lib/widgets/LabelScreens/Scan/save_button.dart b/lib/widgets/LabelScreens/Scan/save_button.dart index a1843c4..c788b77 100644 --- a/lib/widgets/LabelScreens/Scan/save_button.dart +++ b/lib/widgets/LabelScreens/Scan/save_button.dart @@ -1,58 +1,58 @@ -import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class FilterScanSaveButton extends StatelessWidget { - const FilterScanSaveButton({ - Key key, - @required GlobalKey form, - @required this.idCTRL, - @required double deviceBlockSize, - }) : _form = form, - _deviceBlockSize = deviceBlockSize, - super(key: key); - - final GlobalKey _form; - final TextEditingController idCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - if (!_form.currentState.validate()) { - return; - } - launch( - 'https://cssd-doc.com/Show/Label/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.labelDetailScreen, - // arguments: idCTRL.text, - // ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - margin: EdgeInsets.only(bottom: 50,left: 20,right: 20), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'GO!', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class FilterScanSaveButton extends StatelessWidget { + const FilterScanSaveButton({ + Key? key, + required GlobalKey form, + required this.idCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final TextEditingController idCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Label/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.labelDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kLightBlue, kLightBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Scan/scan_box.dart b/lib/widgets/LabelScreens/Scan/scan_box.dart index 51a5d53..2296bab 100644 --- a/lib/widgets/LabelScreens/Scan/scan_box.dart +++ b/lib/widgets/LabelScreens/Scan/scan_box.dart @@ -1,88 +1,88 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class LabelScanBox extends StatelessWidget { - const LabelScanBox({ - Key key, - }) : super(key: key); - Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } // print(barcode.split('/')); - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } - - // } on FormatException { - // setState(() => this.testCode = - // 'null (User returned using the "back"-button before scanning anything. Result)'); - // } catch (e) { - // setState(() => this.testCode = 'Unknown error: $e'); - // } - // return null; - } - - @override - Widget build(BuildContext context) { - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Label Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Label/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.labelDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ); - } -} +import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class LabelScanBox extends StatelessWidget { + const LabelScanBox({ + Key? key, + }) : super(key: key); + Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } // print(barcode.split('/')); + try { + var id = barcode.rawContent.contains('www.cssd-doc.com') + ? barcode.rawContent.split('/')[5] + : barcode.rawContent; + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } + + // } on FormatException { + // setState(() => this.testCode = + // 'null (User returned using the "back"-button before scanning anything. Result)'); + // } catch (e) { + // setState(() => this.testCode = 'Unknown error: $e'); + // } + // return null; + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Label Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, + ), + textAlign: TextAlign.center, + ), + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Label/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.labelDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ); + } +} diff --git a/lib/widgets/MyInfo/input_box.dart b/lib/widgets/MyInfo/input_box.dart index 643ade7..a2b4d2b 100644 --- a/lib/widgets/MyInfo/input_box.dart +++ b/lib/widgets/MyInfo/input_box.dart @@ -1,48 +1,48 @@ -import 'package:flutter/material.dart'; - -class InfoInputBox extends StatelessWidget { - const InfoInputBox({ - Key key, - @required this.controller, - @required double deviceBlockSize, - @required String label, - @required IconData icon, - @required TextInputType inputType, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - _icon = icon, - _inputType = inputType, - super(key: key); - - final TextEditingController controller; - final double _deviceBlockSize; - final String _label; - final IconData _icon; - final TextInputType _inputType; - - @override - Widget build(BuildContext context) { - return TextFormField( - controller: controller, - decoration: InputDecoration( - icon: Icon( - _icon, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: _label, - isDense: true, - contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: _inputType, - textInputAction: TextInputAction.next, - ); - } -} +import 'package:flutter/material.dart'; + +class InfoInputBox extends StatelessWidget { + const InfoInputBox({ + Key? key, + required this.controller, + required double deviceBlockSize, + required String label, + required IconData icon, + required TextInputType inputType, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _icon = icon, + _inputType = inputType, + super(key: key); + + final TextEditingController controller; + final double _deviceBlockSize; + final String _label; + final IconData _icon; + final TextInputType _inputType; + + @override + Widget build(BuildContext context) { + return TextFormField( + controller: controller, + decoration: InputDecoration( + icon: Icon( + _icon, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: _label, + isDense: true, + contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: _inputType, + textInputAction: TextInputAction.next, + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart b/lib/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart new file mode 100644 index 0000000..de646ad --- /dev/null +++ b/lib/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; + +class CancelTransferButton extends StatelessWidget { + const CancelTransferButton( + {Key? key, + required double deviceBlockSize, + required this.color, + required this.onTap}) + : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final Color color; + final VoidCallback onTap; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.close, + color: color, + ), + SizedBox( + width: 5.0, + ), + Text( + 'Let me think again', + style: TextStyle( + color: color, + fontSize: 4 * _deviceBlockSize, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart b/lib/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart new file mode 100644 index 0000000..026df36 --- /dev/null +++ b/lib/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart @@ -0,0 +1,536 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/config/routes.dart'; +import 'package:cssd/models/item_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/items.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class MyItemsDetailsDataBox extends StatelessWidget { + const MyItemsDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + required this.push, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final ItemDetailObject datas; + final double _deviceBlockSize; + final VoidCallback push; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + print(datas.status); + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Item Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kDarkBlue, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createdAt, + ), + ), + style: TextStyle( + color: kDarkBlue, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kDarkBlue, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Item Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.name.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Size', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.size.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Specific', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.specific.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'User', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.userName.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'UDI', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.udi.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.createdAt, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospital, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Status', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.status == 1 ? 'Success' : 'Failure', + style: TextStyle( + fontWeight: FontWeight.w700, + color: datas.status == 1 ? kDarkBlue : kPink, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + ], + ), + ), + SizedBox( + height: 20, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + text: 'Transfer', + onTap: () { + push(); + }, + ), + SizedBox( + height: 10.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kPink, + secondColor: kPinkSub, + text: 'Destroy', + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to destroy this Item?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 220, + child: Column( + children: [ + Text( + 'By approving, your item will be removed and it can not be used any more.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + SizedBox( + height: 10.0, + ), + ItemCard(_deviceBlockSize), + SizedBox( + height: 20.0, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kPink, + secondColor: kPinkSub, + onTap: () { + Provider.of(context, + listen: false) + .removeItems(datas.id) + .then( + (value) { + Navigator.of(context).pop(); + Navigator.pushReplacementNamed( + context, + Routes.myItemsResultScreen, + ); + }, + ); + }, + text: 'Destroy', + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kDarkBlue, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }, + ); + }, + ), + SizedBox( + height: 20.0, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/Item/${datas.id.toString()}', + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ], + ), + ); + } + + Container ItemCard(double _deviceBlockSize) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + datas.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + datas.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Size:', + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + Text( + datas.size, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User:', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + datas.userName, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Detail/transfer_data_box.dart b/lib/widgets/MyItemsScreens/Detail/transfer_data_box.dart new file mode 100644 index 0000000..fe6440b --- /dev/null +++ b/lib/widgets/MyItemsScreens/Detail/transfer_data_box.dart @@ -0,0 +1,88 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/users_model.dart'; +import 'package:flutter/material.dart'; + +class TransferDataBox extends StatelessWidget { + final Users? user; + final Function(String)? onTap; + final bool isClicked; + + const TransferDataBox({ + Key? key, + required double deviceBlockSize, + this.user, + this.onTap, + this.isClicked = false, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () { + onTap!(user!.id); + }, + child: Card( + elevation: 1, + child: Container( + decoration: isClicked + ? BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all(color: kDarkBlue, width: 2.0), + ) + : BoxDecoration(), + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + user!.id.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 30 * _deviceBlockSize, + child: Text( + user!.userName, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Text( + user!.phoneNumber, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + color: Colors.grey, + ), + ), + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart b/lib/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart new file mode 100644 index 0000000..cca5b33 --- /dev/null +++ b/lib/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; + +class TransferDestroyButton extends StatelessWidget { + const TransferDestroyButton({ + Key? key, + required double deviceBlockSize, + required this.firstColor, + required this.secondColor, + required this.onTap, + required this.text, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + final double _deviceBlockSize; + final Color firstColor; + final Color secondColor; + final String text; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [firstColor, secondColor], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + text, + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Filter/my_items_chip_widget.dart b/lib/widgets/MyItemsScreens/Filter/my_items_chip_widget.dart new file mode 100644 index 0000000..f52a7c9 --- /dev/null +++ b/lib/widgets/MyItemsScreens/Filter/my_items_chip_widget.dart @@ -0,0 +1,72 @@ +import 'package:cssd/providers/my_items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyItemFilterChip extends StatelessWidget { + const MyItemFilterChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String name, + required String udi, + required String size, + required String specific, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _id = id, + _name = name, + _udi = udi, + _size = size, + _specific = specific, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _id; + final String _name; + final String _udi; + final String _size; + final String _specific; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var itemProvider = + Provider.of(context, listen: false); + itemProvider.setFilters( + _id, + _name, + _udi, + _size, + _specific, + ); + itemProvider.setLoading(); + itemProvider.getMyItems().then( + (_) { + itemProvider.resetLoading(); + }, + ); + }, + ), + ], + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Filter/my_items_filter_button.dart b/lib/widgets/MyItemsScreens/Filter/my_items_filter_button.dart new file mode 100644 index 0000000..914bee0 --- /dev/null +++ b/lib/widgets/MyItemsScreens/Filter/my_items_filter_button.dart @@ -0,0 +1,85 @@ +import 'package:cssd/providers/my_items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyItemFilterSaveButton extends StatelessWidget { + const MyItemFilterSaveButton({ + Key? key, + required this.idCTRL, + required this.nameCTRL, + required this.udiCTRL, + required this.sizeCTRL, + required this.specificCTRL, + required this.firstColor, + required this.secondColor, + required this.push, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController idCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final TextEditingController sizeCTRL; + final TextEditingController specificCTRL; + final Color firstColor; + final Color secondColor; + final String push; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + Provider.of(context, listen: false).setFilters( + idCTRL.text, + nameCTRL.text, + udiCTRL.text, + sizeCTRL.text, + specificCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(push); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + firstColor, + secondColor, + ], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/History/my_items_history_date_widget.dart b/lib/widgets/MyItemsScreens/History/my_items_history_date_widget.dart new file mode 100644 index 0000000..a52dae2 --- /dev/null +++ b/lib/widgets/MyItemsScreens/History/my_items_history_date_widget.dart @@ -0,0 +1,61 @@ +import 'package:cssd/models/my_item_model.dart'; +import 'package:flutter/material.dart'; + +class ItemHistoryDate extends StatelessWidget { + const ItemHistoryDate({ + super.key, + required double deviceBlockSize, + required this.items, + }) : _deviceBlockSize = deviceBlockSize; + + final double _deviceBlockSize; + final MyItemResultObject items; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Text( + 'From', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + SizedBox( + width: 6.0, + ), + Text( + items.fromDate!.toString(), + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + Spacer(), + Icon( + Icons.keyboard_arrow_right, + color: Colors.grey, + ), + Spacer(), + Text( + 'To', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + SizedBox( + width: 6.0, + ), + Text( + items.toDate!.toString(), + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Result/item_requests_data_box.dart b/lib/widgets/MyItemsScreens/Result/item_requests_data_box.dart new file mode 100644 index 0000000..a8d32cc --- /dev/null +++ b/lib/widgets/MyItemsScreens/Result/item_requests_data_box.dart @@ -0,0 +1,236 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/my_item_model.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class RequestsDataBox extends StatelessWidget { + final MyItemResultObject? item; + + const RequestsDataBox({ + Key? key, + required double deviceBlockSize, + required this.isAdmin, + this.item, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final bool isAdmin; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.myItemsDetailScreen, + arguments: item!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + item!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + item!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Size: ', + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + Text( + item!.size, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ), + if (isAdmin) + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + item!.userName.toString(), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Accept'), + content: Text( + 'Are you sure for approve this item?', + ), + actions: [ + TextButton( + onPressed: () async { + Provider.of(context, + listen: false) + .verifyItemRequests( + item!.id, 'approved') + .then((result) { + if (result) { + print('true'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.myItemsResultScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 8 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kDarkBlue, + ), + child: Icon( + Icons.check, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 3, + ), + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Reject'), + content: Text( + 'Are you sure for reject this item?', + ), + actions: [ + TextButton( + onPressed: () async { + Provider.of(context, + listen: false) + .verifyItemRequests( + item!.id, 'rejected') + .then((result) { + if (result) { + print('false'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.myItemsResultScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 8 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kPink, + ), + child: Icon( + Icons.close, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: _deviceBlockSize, + ), + ], + ) + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart b/lib/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart new file mode 100644 index 0000000..bda34a6 --- /dev/null +++ b/lib/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart @@ -0,0 +1,176 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/my_item_model.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../../../config/routes.dart'; + +class MyItemsItemDataBox extends StatelessWidget { + final MyItemResultObject? items; + final bool hasHistoryBtn; + final VoidCallback? push; + + const MyItemsItemDataBox({ + Key? key, + required double deviceBlockSize, + this.push, + required this.isAdmin, + this.items, + this.hasHistoryBtn = true, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final bool isAdmin; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.myItemsDetailScreen, + arguments: items!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + items!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + items!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Size: ', + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + Text( + items!.size, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ), + if (isAdmin) + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + items!.userName.toString(), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (hasHistoryBtn) + InkWell( + customBorder: CircleBorder(), + onTap: () { + push!(); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kDarkBlue, + ), + child: Icon( + FontAwesomeIcons.history, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.myItemsDetailScreen, + arguments: items!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/Detail/my_packages_detail_box_widget.dart b/lib/widgets/MyPackagesScreens/Detail/my_packages_detail_box_widget.dart new file mode 100644 index 0000000..5a979de --- /dev/null +++ b/lib/widgets/MyPackagesScreens/Detail/my_packages_detail_box_widget.dart @@ -0,0 +1,449 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/config/routes.dart'; +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart'; +import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class MyPackageDetailsDataBox extends StatelessWidget { + const MyPackageDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + required this.push, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final PackageDetailObject datas; + final double _deviceBlockSize; + final VoidCallback push; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Package Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kDarkPurple, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: kDarkPurple, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kDarkPurple, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Package Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.name.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'UDI', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.udi.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 30, + ), + Text( + 'Items included', + style: TextStyle( + color: kPurple, + letterSpacing: 3, + fontWeight: FontWeight.w700, + fontSize: 4.5 * _deviceBlockSize, + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: Colors.grey, + ), + ), + child: ListView.separated( + shrinkWrap: true, + itemBuilder: (ctx, index) => RichText( + text: TextSpan( + text: 'Item ID ', + style: TextStyle( + color: Colors.grey, + fontFamily: 'montserrat', + ), + children: [ + TextSpan( + text: datas.items[index], + style: TextStyle( + fontWeight: FontWeight.bold, + color: kDarkPurple, + ), + ), + ], + ), + ), + separatorBuilder: (ctx, index) => Divider(), + itemCount: datas.items.length, + ), + ), + ], + ), + ), + SizedBox( + height: 20, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + text: 'Transfer', + onTap: () { + push(); + }, + ), + SizedBox( + height: 10.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kPink, + secondColor: kPinkSub, + text: 'Destroy', + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to destroy this Package?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 220, + child: Column( + children: [ + Text( + 'By approving, your package will be removed and it can not be used any more.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + SizedBox( + height: 10.0, + ), + PackageCard(_deviceBlockSize), + SizedBox( + height: 20.0, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kPink, + secondColor: kPinkSub, + onTap: () { + Provider.of(context, + listen: false) + .removePackages(datas.id) + .then( + (value) { + Navigator.of(context).pop(); + Navigator.pushReplacementNamed( + context, + Routes.myPackagesResultScreen, + ); + }, + ); + }, + text: 'Destroy', + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kDarkPurple, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }, + ); + }, + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/Package/${datas.id.toString()}', + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ], + ), + ); + } + + Container PackageCard(double _deviceBlockSize) { + return Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey), + borderRadius: BorderRadius.circular(5), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + datas.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + datas.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + // Container( + // width: 30 * _deviceBlockSize, + // child: Row( + // children: [ + // Text( + // 'User:', + // style: TextStyle( + // color: Colors.grey, + // fontSize: 3 * _deviceBlockSize, + // ), + // ), + // Text( + // datas.userName, + // style: TextStyle( + // fontSize: 3 * _deviceBlockSize, + // fontWeight: FontWeight.w700, + // ), + // ), + // ], + // ), + // ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/Filter/my_packages_chip_widget.dart b/lib/widgets/MyPackagesScreens/Filter/my_packages_chip_widget.dart new file mode 100644 index 0000000..af655af --- /dev/null +++ b/lib/widgets/MyPackagesScreens/Filter/my_packages_chip_widget.dart @@ -0,0 +1,64 @@ +import 'package:cssd/providers/my_packages.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyPackageFilterChip extends StatelessWidget { + const MyPackageFilterChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String name, + required String udi, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _id = id, + _name = name, + _udi = udi, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _id; + final String _name; + final String _udi; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var packageProvider = + Provider.of(context, listen: false); + packageProvider.setFilters( + _id, + _name, + _udi, + ); + packageProvider.setLoading(); + packageProvider.getMyPackages().then( + (_) { + packageProvider.resetLoading(); + }, + ); + }, + ), + ], + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/Filter/my_packages_filter_button.dart b/lib/widgets/MyPackagesScreens/Filter/my_packages_filter_button.dart new file mode 100644 index 0000000..c87774d --- /dev/null +++ b/lib/widgets/MyPackagesScreens/Filter/my_packages_filter_button.dart @@ -0,0 +1,79 @@ +import 'package:cssd/providers/my_packages.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyPackagesFilterSaveButton extends StatelessWidget { + const MyPackagesFilterSaveButton({ + Key? key, + required this.idCTRL, + required this.nameCTRL, + required this.udiCTRL, + required this.firstColor, + required this.secondColor, + required this.push, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController idCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final Color firstColor; + final Color secondColor; + final String push; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + Provider.of(context, listen: false).setFilters( + idCTRL.text, + nameCTRL.text, + udiCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(push); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + firstColor, + secondColor, + ], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/History/my_packages_history_date_widget.dart b/lib/widgets/MyPackagesScreens/History/my_packages_history_date_widget.dart new file mode 100644 index 0000000..20a9e12 --- /dev/null +++ b/lib/widgets/MyPackagesScreens/History/my_packages_history_date_widget.dart @@ -0,0 +1,61 @@ +import 'package:cssd/models/my_package_model.dart'; +import 'package:flutter/material.dart'; + +class PackageHistoryDate extends StatelessWidget { + const PackageHistoryDate({ + super.key, + required double deviceBlockSize, + required this.packages, + }) : _deviceBlockSize = deviceBlockSize; + + final double _deviceBlockSize; + final MyPackageResultObject packages; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Text( + 'From', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + SizedBox( + width: 6.0, + ), + Text( + packages.fromDate!, + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + Spacer(), + Icon( + Icons.keyboard_arrow_right, + color: Colors.grey, + ), + Spacer(), + Text( + 'To', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + SizedBox( + width: 6.0, + ), + Text( + packages.toDate!, + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart b/lib/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart new file mode 100644 index 0000000..082675b --- /dev/null +++ b/lib/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart @@ -0,0 +1,153 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/my_package_model.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../../../../config/routes.dart'; + +class MyPackagesItemDataBox extends StatelessWidget { + final MyPackageResultObject? packages; + final bool hasHistoryBtn; + final VoidCallback? push; + + const MyPackagesItemDataBox({ + Key? key, + required double deviceBlockSize, + this.push, + required this.isAdmin, + this.packages, + this.hasHistoryBtn = true, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final bool isAdmin; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.myPackagesDetailScreen, + arguments: packages!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + packages!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + packages!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + if (isAdmin) + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + packages!.userName.toString(), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + if (hasHistoryBtn) + InkWell( + customBorder: CircleBorder(), + onTap: () { + push!(); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kDarkBlue, + ), + child: Icon( + FontAwesomeIcons.history, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.myPackagesDetailScreen, + arguments: packages!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/MyPackagesScreens/Result/package_requests_data_box.dart b/lib/widgets/MyPackagesScreens/Result/package_requests_data_box.dart new file mode 100644 index 0000000..58278f2 --- /dev/null +++ b/lib/widgets/MyPackagesScreens/Result/package_requests_data_box.dart @@ -0,0 +1,213 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/my_package_model.dart'; +import 'package:cssd/providers/my_items.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class PackageRequestsDataBox extends StatelessWidget { + final MyPackageResultObject? package; + + const PackageRequestsDataBox({ + Key? key, + required double deviceBlockSize, + required this.isAdmin, + this.package, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + final bool isAdmin; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.myPackagesDetailScreen, + arguments: package!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + package!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40 * _deviceBlockSize, + child: Text( + package!.name, + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ), + if (isAdmin) + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'User: ', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + package!.userName.toString(), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Accept'), + content: Text( + 'Are you sure for approve this item?', + ), + actions: [ + TextButton( + onPressed: () async { + Provider.of(context, + listen: false) + .verifyItemRequests( + package!.id, 'approved') + .then((result) { + if (result) { + print('true'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.myItemsResultScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 8 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kDarkBlue, + ), + child: Icon( + Icons.check, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 3, + ), + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Reject'), + content: Text( + 'Are you sure for reject this item?', + ), + actions: [ + TextButton( + onPressed: () async { + Provider.of(context, + listen: false) + .verifyItemRequests( + package!.id, 'rejected') + .then((result) { + if (result) { + print('false'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.myItemsResultScreen); + }); + }, + child: Text('Yes'), + ), + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 8 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kPink, + ), + child: Icon( + Icons.close, + size: 4 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: _deviceBlockSize, + ), + ], + ) + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/PackageScreens/Add/package_save_button.dart b/lib/widgets/PackageScreens/Add/package_save_button.dart new file mode 100644 index 0000000..29786ac --- /dev/null +++ b/lib/widgets/PackageScreens/Add/package_save_button.dart @@ -0,0 +1,93 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class PackageAddSaveButton extends StatelessWidget { + const PackageAddSaveButton({ + Key? key, + required GlobalKey form, + required this.itemValues, + required this.nameCTRL, + required this.descriptionCTRL, + required this.udiCTRL, + required this.dateValue, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final List itemValues; + final TextEditingController nameCTRL; + final TextEditingController descriptionCTRL; + final TextEditingController udiCTRL; + final String dateValue; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + + List items = []; + for (TextEditingController item in itemValues) { + items.add(item.text); + } + Provider.of(context, listen: false) + .createPackageResult( + nameCTRL.text, + udiCTRL.text, + items, + descriptionCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Package added.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPurple, kPurpleSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Save', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/PackageScreens/Add/package_update_button.dart b/lib/widgets/PackageScreens/Add/package_update_button.dart new file mode 100644 index 0000000..4058810 --- /dev/null +++ b/lib/widgets/PackageScreens/Add/package_update_button.dart @@ -0,0 +1,89 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/packages.dart'; + +import '../../../config/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PackageUpdateButton extends StatelessWidget { + const PackageUpdateButton({ + Key? key, + required GlobalKey form, + required this.id, + required this.descriptionCTRL, + required this.nameCTRL, + required this.udiCTRL, + required this.itemCTRL, + required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final String id; + final TextEditingController descriptionCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final TextEditingController itemCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + Provider.of(context, listen: false) + .updatePackageResult( + id, + nameCTRL.text, + udiCTRL.text, + descriptionCTRL.text, + int.parse(itemCTRL.text), + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Package updated.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPurple, kPurpleSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Update', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/PackageScreens/Details/package_detail_box.dart b/lib/widgets/PackageScreens/Details/package_detail_box.dart new file mode 100644 index 0000000..d87dd90 --- /dev/null +++ b/lib/widgets/PackageScreens/Details/package_detail_box.dart @@ -0,0 +1,290 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/models/package_model.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class PackageDetailsDataBox extends StatelessWidget { + const PackageDetailsDataBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final PackageDetailObject datas; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Package Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: kPurple, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: kPurple, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: kPurple, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Package Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.name.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'UDI', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.udi.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 30, + ), + Text( + 'Items included', + style: TextStyle( + color: kPurple, + letterSpacing: 3, + fontWeight: FontWeight.w700, + fontSize: 4.5 * _deviceBlockSize, + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: Colors.grey, + ), + ), + child: ListView.separated( + shrinkWrap: true, + itemBuilder: (ctx, index) => RichText( + text: TextSpan( + text: 'Item ID ', + style: TextStyle( + color: Colors.grey, + fontFamily: 'montserrat', + ), + children: [ + TextSpan( + text: datas.items[index], + style: TextStyle( + fontWeight: FontWeight.bold, + color: kPurple, + ), + ), + ], + ), + ), + separatorBuilder: (ctx, index) => Divider(), + itemCount: datas.items.length, + ), + ), + SizedBox( + height: 50, + ) + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/Package/${datas.id.toString()}', + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ), + SizedBox( + height: 30, + ), + ], + ), + ); + } +} diff --git a/lib/widgets/PackageScreens/Filter/filter_button.dart b/lib/widgets/PackageScreens/Filter/filter_button.dart new file mode 100644 index 0000000..be226da --- /dev/null +++ b/lib/widgets/PackageScreens/Filter/filter_button.dart @@ -0,0 +1,89 @@ +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class PackageFilterSaveButton extends StatelessWidget { + const PackageFilterSaveButton({ + Key? key, + required this.hospitalVals, + required this.hospitalCTRL, + required this.idCTRL, + required this.nameCTRL, + required this.udiCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final List> hospitalVals; + final TextEditingController hospitalCTRL; + final TextEditingController idCTRL; + final TextEditingController nameCTRL; + final TextEditingController udiCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + String? hospitalID; + hospitalVals.forEach( + (hospital) { + if (hospital['name'] == hospitalCTRL.text) { + hospitalID = hospital['id']!; + } + }, + ); + Provider.of(context, listen: false).setFilters( + idCTRL.text, + nameCTRL.text, + hospitalID, + udiCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Filters changed.'), + actions: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).popAndPushNamed(Routes.packageResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + kPurple, + kPurpleSub, + ], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/PackageScreens/Filter/package_filter_object.dart b/lib/widgets/PackageScreens/Filter/package_filter_object.dart new file mode 100644 index 0000000..4d4ff6a --- /dev/null +++ b/lib/widgets/PackageScreens/Filter/package_filter_object.dart @@ -0,0 +1,68 @@ +import 'package:cssd/providers/packages.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PackageFilterChip extends StatelessWidget { + const PackageFilterChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String name, + required String hospital, + required String udi, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + _id = id, + _name = name, + _hospital = hospital, + _udi = udi, + super(key: key); + + final double _deviceBlockSize; + final String _label; + final String _id; + final String _name; + final String _hospital; + final String _udi; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var packageProvider = + Provider.of(context, listen: false); + packageProvider.setFilters( + _id, + _name, + _hospital, + _udi, + ); + packageProvider.setLoading(); + packageProvider.getPackageResults().then( + (_) { + packageProvider.resetLoading(); + }, + ); + }, + ), + ], + ); + } +} diff --git a/lib/widgets/PackageScreens/Result/package_data_box.dart b/lib/widgets/PackageScreens/Result/package_data_box.dart new file mode 100644 index 0000000..42d9a85 --- /dev/null +++ b/lib/widgets/PackageScreens/Result/package_data_box.dart @@ -0,0 +1,204 @@ +import 'package:cssd/models/package_model.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/packages.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; + +class PackageItemBox extends StatelessWidget { + final PackageResultObject? item; + + const PackageItemBox({ + Key? key, + required double deviceBlockSize, + this.item, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + return GestureDetector( + onTap: () => Navigator.of(context).pushNamed( + Routes.packageDetailScreen, + arguments: item!.id, + ), + child: Card( + elevation: 1, + child: Container( + padding: EdgeInsets.all(8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: const EdgeInsets.all(6.0), + child: Text( + item!.id, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + SizedBox( + width: 3 * _deviceBlockSize, + ), + // Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 30 * _deviceBlockSize, + child: Text( + 'Package Name:', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + color: Colors.grey, + ), + ), + ), + Container( + width: 40 * _deviceBlockSize, + child: Text( + item!.name, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 3 * _deviceBlockSize, + ), + ), + ), + Container( + width: 30 * _deviceBlockSize, + child: Row( + children: [ + Text( + 'Date:', + style: TextStyle( + color: Colors.grey, + fontSize: 3 * _deviceBlockSize, + ), + ), + Text( + DateFormat('y-M-d').format( + DateTime.parse( + item!.createdAt, + ), + ), + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + ], + ), + ) + ], + ), + Spacer(), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.packageUpdateScreen, + arguments: item!.id, + ); + }, + child: Icon( + Icons.edit, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : InkWell( + customBorder: CircleBorder(), + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('Delete'), + content: Text( + 'Are you sure you want delete this Package?', + ), + actions: [ + TextButton( + child: Text('Yes'), + onPressed: () { + Navigator.of(context).pop(); + Provider.of( + context, + listen: false) + .removePackages(item!.id); + }, + ), + TextButton( + child: Text('No'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + }, + child: Icon( + Icons.delete, + size: 5 * _deviceBlockSize, + color: Colors.black, + ), + ), + SizedBox( + width: 5.0, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed( + Routes.packageDetailScreen, + arguments: item!.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 9 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.fileAlt, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), + ], + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Add/capture_image.dart b/lib/widgets/TestResultScreens/Add/capture_image.dart index 877c82f..25ffab8 100644 --- a/lib/widgets/TestResultScreens/Add/capture_image.dart +++ b/lib/widgets/TestResultScreens/Add/capture_image.dart @@ -1,320 +1,328 @@ -import 'dart:async'; -import 'dart:io'; - -import 'package:camera/camera.dart'; -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/material.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/test_results.dart'; - -class CaptureImage extends StatefulWidget { - @override - _CaptureImageState createState() { - return _CaptureImageState(); - } -} - -/// Returns a suitable camera icon for [direction]. -IconData getCameraLensIcon(CameraLensDirection direction) { - switch (direction) { - case CameraLensDirection.back: - return Icons.camera_rear; - case CameraLensDirection.front: - return Icons.camera_front; - case CameraLensDirection.external: - return Icons.camera; - } - throw ArgumentError('Unknown lens direction'); -} - -void logError(String code, String message) => - print('Error: $code\nError Message: $message'); - -class _CaptureImageState extends State - with WidgetsBindingObserver { - CameraController controller; - String imagePath; - // String videoPath; - VoidCallback videoPlayerListener; - bool isInit = true; - int curCamera = 0; - var cameras; - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addObserver(this); - } - - @override - void didChangeDependencies() async { - if (isInit) { - cameras = await availableCameras(); - onNewCameraSelected(cameras[curCamera]); - setState(() { - isInit = false; - }); - } - super.didChangeDependencies(); - } - - @override - void dispose() { - WidgetsBinding.instance.removeObserver(this); - super.dispose(); - } - - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - // App state changed before we got the chance to initialize. - if (controller == null || !controller.value.isInitialized) { - return; - } - if (state == AppLifecycleState.inactive) { - controller?.dispose(); - } else if (state == AppLifecycleState.resumed) { - if (controller != null) { - onNewCameraSelected(controller.description); - } - } - } - - final GlobalKey _scaffoldKey = GlobalKey(); - - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - key: _scaffoldKey, - // appBar: AppBar( - // title: const Text('Take Picture'), - // ), - body: isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Stack(children: [ - _cameraPreviewWidget(), - Positioned( - bottom: 100, left: 100, child: _captureControlRowWidget()), - Positioned( - bottom: 100, - right: 100, - child: InkWell( - onTap: () { - if (curCamera == 0) { - try { - onNewCameraSelected(cameras[1]); - setState(() { - curCamera = 1; - }); - } catch (e) {} - } else { - onNewCameraSelected(cameras[0]); - setState(() { - curCamera = 0; - }); - } - }, - child: Icon( - curCamera == 0 ? Icons.camera_rear : Icons.camera_front, - size: 40, - color: Colors.white, - ), - ), - ), - // _cameraTogglesRowWidget(cameras), - ]), - ), - ); - } - - /// Display the preview from the camera (or a message if the preview is not available). - Widget _cameraPreviewWidget() { - if (controller == null || !controller.value.isInitialized) { - return const Text( - 'Tap a camera', - style: TextStyle( - color: Colors.white, - fontSize: 24.0, - fontWeight: FontWeight.w900, - ), - ); - } else { - return Container( - width: double.infinity, - child: CameraPreview(controller), - ); - } - } - - /// Toggle recording audio - - /// Display the control bar with buttons to take pictures and record videos. - Widget _captureControlRowWidget() { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - children: [ - IconButton( - icon: const Icon( - Icons.camera_alt, - size: 40, - color: Colors.white, - ), - // color: Colors.blue, - onPressed: controller != null && - controller.value.isInitialized && - !controller.value.isRecordingVideo - ? onTakePictureButtonPressed - : null, - ), - ], - ); - } - - getCameras() async { - return await availableCameras(); - } - - /// Display a row of toggle to select the camera (or a message if no camera is available). - // Widget _cameraTogglesRowWidget(var cameras) { - // final List toggles = []; - - // if (cameras.isEmpty) { - // return const Text('No camera found'); - // } else { - // for (CameraDescription cameraDescription in cameras) { - // print("${cameraDescription.name}"); - // toggles.add( - // SizedBox( - // width: 90.0, - // child: RadioListTile( - // title: Icon(getCameraLensIcon(cameraDescription.lensDirection)), - // groupValue: controller?.description, - // value: cameraDescription, - // onChanged: controller != null && controller.value.isRecordingVideo - // ? null - // : onNewCameraSelected, - // ), - // ), - // ); - // } - // } - - // return Row(children: toggles); - // } - - String timestamp() => DateTime.now().millisecondsSinceEpoch.toString(); - - void showInSnackBar(String message) { - _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message))); - } - - void onNewCameraSelected(CameraDescription cameraDescription) async { - print(cameraDescription.lensDirection.toString()); - if (controller != null) { - await controller.dispose(); - } - controller = CameraController( - cameraDescription, - ResolutionPreset.medium, - // enableAudio: enableAudio, - ); - - // If the controller is updated then update the UI. - controller.addListener(() { - if (mounted) setState(() {}); - if (controller.value.hasError) { - showInSnackBar('Camera error ${controller.value.errorDescription}'); - } - }); - - try { - await controller.initialize(); - } on CameraException catch (e) { - _showCameraException(e); - } - - if (mounted) { - setState(() {}); - } - } - - void onTakePictureButtonPressed() { - takePicture().then((String filePath) { - if (mounted) { - setState(() { - imagePath = filePath; - var profileProviderObject = - Provider.of(context, listen: false); - List files = profileProviderObject.catchImages; - print(imagePath); - files.add(PlatformFile( - name: 'test', - size: 0, - path: imagePath, - bytes: File(imagePath).readAsBytesSync())); - profileProviderObject.setCatchImages(files); - profileProviderObject.setImages(); - print(imagePath); - }); - if (filePath != null) { - Navigator.of(context).pop(); - // showInSnackBar('Picture saved to $filePath'); - } - } - }); - } - - Future takePicture() async { - if (!controller.value.isInitialized) { - showInSnackBar('Error: select a camera first.'); - return null; - } - final Directory extDir = await getApplicationDocumentsDirectory(); - final String dirPath = '${extDir.path}/Pictures/flutter_test'; - await Directory(dirPath).create(recursive: true); - final String filePath = '$dirPath/${timestamp()}.jpg'; - - if (controller.value.isTakingPicture) { - // A capture is already pending, do nothing. - return null; - } - - try { - await controller.takePicture(filePath); - } on CameraException catch (e) { - _showCameraException(e); - return null; - } - return filePath; - } - - void _showCameraException(CameraException e) { - logError(e.code, e.description); - showInSnackBar('Error: ${e.code}\n${e.description}'); - } -} - -// class CameraApp extends StatelessWidget { -// @override -// Widget build(BuildContext context) { -// return MaterialApp( -// home: CaptureImage(), -// ); -// } -// } - -// List cameras = []; - -// Future main() async { -// // Fetch the available cameras before initializing the app. -// try { -// WidgetsFlutterBinding.ensureInitialized(); -// } on CameraException catch (e) { -// logError(e.code, e.description); -// } -// runApp(CameraApp()); -// } +// ignore_for_file: dead_code + +import 'dart:async'; +import 'dart:io'; + +import 'package:camera/camera.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/test_results.dart'; + +class CaptureImage extends StatefulWidget { + @override + _CaptureImageState createState() { + return _CaptureImageState(); + } +} + +/// Returns a suitable camera icon for [direction]. +IconData getCameraLensIcon(CameraLensDirection direction) { + switch (direction) { + case CameraLensDirection.back: + return Icons.camera_rear; + case CameraLensDirection.front: + return Icons.camera_front; + case CameraLensDirection.external: + return Icons.camera; + } + throw ArgumentError('Unknown lens direction'); +} + +void logError(String code, String message) => + print('Error: $code\nError Message: $message'); + +class _CaptureImageState extends State + with WidgetsBindingObserver { + CameraController? controller; + String? imagePath; + // String videoPath; + VoidCallback? videoPlayerListener; + bool isInit = true; + int curCamera = 0; + var cameras; + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + } + + @override + void didChangeDependencies() async { + if (isInit) { + cameras = await availableCameras(); + onNewCameraSelected(cameras[curCamera]); + setState(() { + isInit = false; + }); + } + super.didChangeDependencies(); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + // App state changed before we got the chance to initialize. + if (controller == null || !controller!.value.isInitialized) { + return; + } + if (state == AppLifecycleState.inactive) { + controller?.dispose(); + } else if (state == AppLifecycleState.resumed) { + if (controller != null) { + onNewCameraSelected(controller!.description); + } + } + } + + final GlobalKey _scaffoldKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + key: _scaffoldKey, + // appBar: AppBar( + // title: const Text('Take Picture'), + // ), + body: isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Stack(children: [ + _cameraPreviewWidget(), + Positioned( + bottom: 100, left: 100, child: _captureControlRowWidget()), + Positioned( + bottom: 100, + right: 100, + child: InkWell( + onTap: () { + if (curCamera == 0) { + try { + onNewCameraSelected(cameras[1]); + setState(() { + curCamera = 1; + }); + } catch (e) {} + } else { + onNewCameraSelected(cameras[0]); + setState(() { + curCamera = 0; + }); + } + }, + child: Icon( + curCamera == 0 ? Icons.camera_rear : Icons.camera_front, + size: 40, + color: Colors.white, + ), + ), + ), + // _cameraTogglesRowWidget(cameras), + ]), + ), + ); + } + + /// Display the preview from the camera (or a message if the preview is not available). + Widget _cameraPreviewWidget() { + if (controller == null || !controller!.value.isInitialized) { + return const Text( + 'Tap a camera', + style: TextStyle( + color: Colors.white, + fontSize: 24.0, + fontWeight: FontWeight.w900, + ), + ); + } else { + return Container( + width: double.infinity, + child: CameraPreview(controller!), + ); + } + } + + /// Toggle recording audio + + /// Display the control bar with buttons to take pictures and record videos. + Widget _captureControlRowWidget() { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + IconButton( + icon: const Icon( + Icons.camera_alt, + size: 40, + color: Colors.white, + ), + // color: Colors.blue, + onPressed: controller != null && + controller!.value.isInitialized && + !controller!.value.isRecordingVideo + ? onTakePictureButtonPressed + : null, + ), + ], + ); + } + + getCameras() async { + return await availableCameras(); + } + + /// Display a row of toggle to select the camera (or a message if no camera is available). + // Widget _cameraTogglesRowWidget(var cameras) { + // final List toggles = []; + + // if (cameras.isEmpty) { + // return const Text('No camera found'); + // } else { + // for (CameraDescription cameraDescription in cameras) { + // print("${cameraDescription.name}"); + // toggles.add( + // SizedBox( + // width: 90.0, + // child: RadioListTile( + // title: Icon(getCameraLensIcon(cameraDescription.lensDirection)), + // groupValue: controller?.description, + // value: cameraDescription, + // onChanged: controller != null && controller.value.isRecordingVideo + // ? null + // : onNewCameraSelected, + // ), + // ), + // ); + // } + // } + + // return Row(children: toggles); + // } + + String timestamp() => DateTime.now().millisecondsSinceEpoch.toString(); + + void showInSnackBar(String message) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + ), + ); + } + + void onNewCameraSelected(CameraDescription cameraDescription) async { + print(cameraDescription.lensDirection.toString()); + if (controller != null) { + await controller!.dispose(); + } + controller = CameraController( + cameraDescription, + ResolutionPreset.medium, + // enableAudio: enableAudio, + ); + + // If the controller is updated then update the UI. + controller!.addListener(() { + if (mounted) setState(() {}); + if (controller!.value.hasError) { + showInSnackBar('Camera error ${controller!.value.errorDescription}'); + } + }); + + try { + await controller!.initialize(); + } on CameraException catch (e) { + _showCameraException(e); + } + + if (mounted) { + setState(() {}); + } + } + + void onTakePictureButtonPressed() { + takePicture().then((String? filePath) { + if (mounted) { + setState(() { + imagePath = filePath; + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + print(imagePath); + files.add(PlatformFile( + name: 'test', + size: 0, + path: imagePath, + bytes: File(imagePath!).readAsBytesSync())); + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + print(imagePath); + }); + if (filePath != null) { + Navigator.of(context).pop(); + // showInSnackBar('Picture saved to $filePath'); + } + } + }); + } + + Future takePicture() async { + if (!controller!.value.isInitialized) { + showInSnackBar('Error: select a camera first.'); + return null; + } + final Directory extDir = await getApplicationDocumentsDirectory(); + final String dirPath = '${extDir.path}/Pictures/flutter_test'; + await Directory(dirPath).create(recursive: true); + final String filePath = '$dirPath/${timestamp()}.jpg'; + + if (controller!.value.isTakingPicture) { + // A capture is already pending, do nothing. + return null; + } + + try { + await controller!.takePicture(); + } on CameraException catch (e) { + _showCameraException(e); + return null; + } + return filePath; + } + + void _showCameraException(CameraException e) { + logError(e.code, e.description!); + showInSnackBar('Error: ${e.code}\n${e.description}'); + } +} + +// class CameraApp extends StatelessWidget { +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// home: CaptureImage(), +// ); +// } +// } + +// List cameras = []; + +// Future main() async { +// // Fetch the available cameras before initializing the app. +// try { +// WidgetsFlutterBinding.ensureInitialized(); +// } on CameraException catch (e) { +// logError(e.code, e.description); +// } +// runApp(CameraApp()); +// } diff --git a/lib/widgets/TestResultScreens/Add/form_creator.dart b/lib/widgets/TestResultScreens/Add/form_creator.dart index 5181356..24cce32 100644 --- a/lib/widgets/TestResultScreens/Add/form_creator.dart +++ b/lib/widgets/TestResultScreens/Add/form_creator.dart @@ -1,724 +1,744 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart'; -import 'package:meta/meta.dart'; -import 'package:multiselect_formfield/multiselect_formfield.dart'; -import 'package:provider/provider.dart'; - -import '../../../config/routes.dart'; -import '../../../providers/test_results.dart'; - -class FormCreator extends StatefulWidget { - const FormCreator({ - @required this.form, - @required this.onChanged, - this.padding, - }); - - final dynamic form; - final double padding; - final ValueChanged onChanged; - - @override - _FormCreatorState createState() => _FormCreatorState(form); -} - -class _FormCreatorState extends State { - final dynamic formItems; - DateTime selectedDate = DateTime.now(); - - int rangeValue; - String selectValue; - - Future _selectDate() async { - final DateTime picked = await showDatePicker( - context: context, - initialDate: selectedDate, - firstDate: DateTime(2015, 8), - lastDate: DateTime(2101)); - if (picked != null && picked != selectedDate) - setState(() { - selectedDate = picked; - }); - } - - List jsonToForm() { - List listWidgets = List(); - - for (var count = 0; count < formItems.length; count++) { - Map item = formItems[count]; - - if (item['type'] == "Date") { - selectedDate = formItems[count]['value']; - listWidgets.add( - OutlineButton( - onPressed: () { - _selectDate().then((_) { - formItems[count]['value'] = selectedDate; - _handleChanged(); - }); - }, - child: Text( - 'Date: ${selectedDate.year}/${selectedDate.month}/${selectedDate.day}'), - padding: EdgeInsets.symmetric(vertical: 20), - ), - ); - } - if (item['type'] == 'Image') { - final testProviderObject = Provider.of(context); - final mediaData = MediaQuery.of(context); - final deviceWidth = mediaData.size.width; - final _deviceBlockSize = deviceWidth / 100; - listWidgets.insert( - 3, - Container( - // height: 70, - child: Directionality( - textDirection: TextDirection.rtl, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Container( - margin: EdgeInsets.only(top: 20), - height: testProviderObject.catchImages.length != 0 ? 60 : 0, - child: ImageBox( - deviceBlockSize: _deviceBlockSize, - testProvider: testProviderObject, - ), - ), - SizedBox( - height: testProviderObject.catchImages.length != 0 ? 10 : 0, - ), - InkWell( - onTap: () async { - await loadAssets(context); - }, - child: Container( - width: MediaQuery.of(context).size.width - 40, - padding: - EdgeInsets.symmetric(vertical: 10, horizontal: 30), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: Colors.black, - ), - child: Text( - '+ Add an image or file from device', - textDirection: TextDirection.ltr, - style: TextStyle(color: Colors.white), - textAlign: TextAlign.center, - ), - ), - ), - SizedBox( - height: 10, - ), - InkWell( - onTap: () async { - await Navigator.of(context) - .pushNamed(Routes.captureImageScreen); - // await captureImage(context); - }, - child: Container( - width: MediaQuery.of(context).size.width - 40, - padding: - EdgeInsets.symmetric(vertical: 10, horizontal: 30), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: Colors.black, - ), - child: Text( - '+ Add an image from camera', - textDirection: TextDirection.ltr, - style: TextStyle(color: Colors.white), - textAlign: TextAlign.center, - ), - ), - ), - ], - ), - ), - ), - ); - } - if (item['type'] == "Label") { - listWidgets.add( - Container( - decoration: BoxDecoration( - border: Border.all(), - borderRadius: BorderRadius.circular(30), - color: Colors.black, - ), - padding: EdgeInsets.only(top: 20, bottom: 20), - margin: EdgeInsets.only(bottom: 20), - child: Text( - item['name'], - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white, fontSize: 20), - ), - ), - ); - } - - if (item['type'] == "Text") { - // print(item['require_scanner'].toString()); - TextEditingController idCTRL = new TextEditingController(); - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - listWidgets.add( - Padding( - padding: const EdgeInsets.all(8.0), - child: item['require_scanner'].toString() != '1' - ? TextFormField( - controller: idCTRL, - decoration: InputDecoration( - labelText: item['name'] ?? "", - border: UnderlineInputBorder(), - contentPadding: EdgeInsets.all(0), - ), - // initialValue: item['value'] ?? '', - onChanged: (String value) { - formItems[count]['value'] = value; - _handleChanged(); - }, - ) - : Container( - child: Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - labelText: item['name'] ?? "", - border: UnderlineInputBorder(), - contentPadding: EdgeInsets.all(0), - ), - // initialValue: item['value'] ?? '', - onChanged: (String value) { - formItems[count]['value'] = value; - _handleChanged(); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - formItems[count]['value'] = result; - _handleChanged(); - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - ), - ), - ); - } - - if (item['type'] == "Range" || - item['type'] == "Temperature" || - item['type'] == "Pressure") { - double startValue, endValue; - if (item['type'] == "Range") { - startValue = double.parse(item['options'][0]['title']); - endValue = double.parse(item['options'][1]['title']); - } else { - startValue = item['type'] == "Temperature" ? 0.0 : -1.0; - endValue = item['type'] == "Temperature" ? 200.0 : 3.0; - } - - formItems[count]['value'] = formItems[count]['value'] ?? startValue; - // int divisions = (endValue - startValue).round(); - listWidgets.add( - Padding( - padding: EdgeInsets.only(top: 35, left: 10, right: 10), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(item['type']), - Text(formItems[count]['value'].toString()), - ], - ), - Slider( - min: startValue, - max: endValue, - value: formItems[count]['value'], - // label: '${formItems[count]['value'].round()}', - // divisions: divisions, - onChanged: (double value) { - setState(() { - formItems[count]['value'] = - double.parse(value.toStringAsFixed(2)); - }); - // print(formItems[count]['value']); - }, - // semanticFormatterCallback: (double newValue) { - // return '${newValue.round()}'; - // }, - ), - ], - )), - ); - } - - if (item['type'] == "Time") { - listWidgets.add( - Padding( - padding: const EdgeInsets.all(8.0), - child: TextFormField( - inputFormatters: [ - LengthLimitingTextInputFormatter(5), - WhitelistingTextInputFormatter.digitsOnly, - // BlacklistingTextInputFormatter.singleLineFormatter, - TextInputFormatter.withFunction( - (TextEditingValue oldValue, TextEditingValue newValue) { - final int newTextLength = newValue.text.length; - int selectionIndex = newValue.selection.end; - int usedSubstringIndex = 0; - final StringBuffer newText = StringBuffer(); - if (newTextLength >= 2) { - newText.write( - newValue.text.substring(0, usedSubstringIndex = 2) + - ':'); - if (newValue.selection.end >= 2) selectionIndex++; - } - // Dump the rest. - if (newTextLength >= usedSubstringIndex) - newText.write(newValue.text.substring(usedSubstringIndex)); - return TextEditingValue( - text: newText.toString(), - selection: TextSelection.collapsed(offset: selectionIndex), - ); - }) - ], - keyboardType: TextInputType.datetime, - decoration: InputDecoration( - labelText: item['name'] ?? "", - border: UnderlineInputBorder(), - contentPadding: EdgeInsets.all(0), - ), - // initialValue: item['value'] ?? '', - onChanged: (String value) { - formItems[count]['value'] = value; - _handleChanged(); - }, - ), - ), - ); - } - - if (item['type'] == "Select") { - var listItems = item['options'] as List; - listWidgets.add(MultiSelectFormField( - autovalidate: false, - titleText: item['name'], - dataSource: listItems, - textField: 'title', - valueField: 'id', - okButtonLabel: 'OK', - cancelButtonLabel: 'CANCEL', - hintText: 'Please choose one or more', - value: item['value'], - onSaved: (value) { - if (value == null) return; - setState(() { - item['value'] = value; - }); - _handleChanged(); - }, - )); - - // listWidgets.add( - // DropdownButtonFormField( - // items: listItems.map((dynamic value) { - // String stringValue = value['id'].toString(); - // String textValue = value['title'].toString(); - // return DropdownMenuItem( - // value: stringValue, - // child: Text(textValue), - // ); - // }).toList(), - // isDense: true, - // value: item['value'], - // hint: Text(item['name']), - - // onChanged: (String value) { - // this.setState( - // () { - // _setInput(item['name'], value); - // formItems[count]['value'] = value; - // _handleChanged(); - // }, - // ); - // }, - // ), - // ); - } - - if (item['type'] == "Radiobutton") { - listWidgets.add( - Container( - margin: EdgeInsets.only(top: 14.0, bottom: 0), - child: Text( - item['name'], - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), - ), - ), - ); - var valueOrFirst = - formItems[count]['value'] ?? formItems[count]['options'][0]['id']; - for (var i = 0; i < item['options'].length; i++) { - var isSelected = formItems[count]['options'][i]['id'] == valueOrFirst; - formItems[count]['value'] = valueOrFirst; - listWidgets.add( - RadioListTile( - dense: true, - controlAffinity: ListTileControlAffinity.trailing, - title: Text(formItems[count]['options'][i]['title']), - value: formItems[count]['options'][i]['id'], - selected: isSelected, - groupValue: formItems[count]['value'], - onChanged: (int value) { - this.setState( - () { - _setInput(item['name'], value.toString()); - formItems[count]['value'] = value; - _handleChanged(); - }, - ); - }, - ), - ); - } - } - - if (item['type'] == "Switch") { - listWidgets.add(SwitchListTile( - activeColor: Colors.green, - inactiveTrackColor: Colors.red.withAlpha(150), - inactiveThumbColor: Colors.red, - title: Text(item['name']), - value: item['value'] ?? false, - onChanged: (bool value) { - this.setState(() { - formItems[count]['value'] = value; - _handleChanged(); - }); - })); - } - - if (item['type'] == "Form") { - listWidgets.add( - Container( - margin: EdgeInsets.symmetric(vertical: 10), - decoration: BoxDecoration(border: Border.all()), - child: Column( - children: [ - Container( - margin: EdgeInsets.only(top: 10), - child: Text( - item['name'], - style: - TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), - ), - ), - FormCreator( - form: item['children'], - padding: 4, - onChanged: (value) { - // _handleChanged(); - }, - ), - ], - ), - ), - ); - } - - if (item['type'] == "Checkbox") { - formItems[count]['value'] = formItems[count]['value'] ?? []; - listWidgets.add( - Container( - margin: EdgeInsets.only(top: 14.0, bottom: 0), - child: Text( - item['name'], - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), - ), - ), - ); - for (var i = 0; i < item['options'].length; i++) { - listWidgets.add( - CheckboxListTile( - title: Text(formItems[count]['options'][i]['title']), - value: (formItems[count]['value'] ?? []) - .contains(formItems[count]['options'][i]['id']), - onChanged: (bool value) { - this.setState( - () { - setState(() { - if (value) { - (formItems[count]['value'] as List) - .add(formItems[count]['options'][i]['id']); - } else { - (formItems[count]['value'] as List) - .remove(formItems[count]['options'][i]['id']); - } - }); - _handleChanged(); - }, - ); - }, - ), - ); - } - } - // listWidgets.add( - // TestResultAddSaveButton( - // deviceBlockSize: null, - // ), - // ); - } - - return listWidgets; - } - - Future captureImage(BuildContext context) async { - var profileProviderObject = - Provider.of(context, listen: false); - List files = profileProviderObject.catchImages; - try { - files.add( - await ImagePickerGC.pickImage( - context: context, - source: ImgSource.Camera, - cameraIcon: Icon( - Icons.camera_alt, - color: Colors.red, - ), //cameraIcon and galleryIcon can change. If no icon provided default icon will be present - cameraText: Text( - "From Camera", - style: TextStyle(color: Colors.red), - ), - ), - ); - } catch (e) {} - profileProviderObject.setCatchImages(files); - profileProviderObject.setImages(); - } - - Future loadAssets(BuildContext context) async { - var profileProviderObject = - Provider.of(context, listen: false); - List files = profileProviderObject.catchImages; - try { - var datas = await FilePicker.platform.pickFiles( - type: FileType.custom, - allowedExtensions: ['jpg', 'png', 'bmp', 'jpeg', 'pdf', 'docx', 'doc'], - withData: true, - withReadStream: true, - ); - files += datas.files; - // files += - - // print(files); - } catch (_) {} - - profileProviderObject.setCatchImages(files); - profileProviderObject.setImages(); - // profileProviderObject.addImage(); - } - - _FormCreatorState(this.formItems); - - void _handleChanged() { - widget.onChanged(formItems); - } - - void _setInput(String key, String value) {} - - @override - Widget build(BuildContext context) { - return ListView.builder( - padding: EdgeInsets.all(widget.padding ?? 16.0), - itemCount: jsonToForm().length, - itemBuilder: (context, index) { - return jsonToForm()[index]; - }, - shrinkWrap: true, - controller: ScrollController(keepScrollOffset: false), - ); - } -} - -class ImageBox extends StatelessWidget { - const ImageBox({ - Key key, - @required double deviceBlockSize, - @required TestResultsProvider testProvider, - }) : _deviceBlockSize = deviceBlockSize, - _testProvider = testProvider, - super(key: key); - - final double _deviceBlockSize; - final TestResultsProvider _testProvider; - - @override - Widget build(BuildContext context) { - return ListView.separated( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - itemBuilder: (ctx, index) { - bool isPdf = _testProvider.catchImages[index].path.endsWith('pdf'); - bool isWord = _testProvider.catchImages[index].path.endsWith('docx') || - _testProvider.catchImages[index].path.endsWith('doc'); - - // print(_testProvider.catchImages[index].path.endsWith('jpg')); - // .substring(_testProvider.catchImages[index].path.length - 4)); - return ClipRRect( - borderRadius: BorderRadius.circular(5), - child: Container( - width: 60, - height: 60, - child: Stack( - children: [ - Positioned( - top: 10, - left: 0, - child: GestureDetector( - onTap: () => isPdf - ? print('pdf') - : isWord - ? print('word') - : Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => Container( - color: Colors.white, - child: Center( - child: Image.memory( - _testProvider.catchImages[index].bytes, - fit: BoxFit.contain, - ), - ), - ), - ), - ), - child: isPdf - ? Image.asset( - 'assets/Images/pdf.png', - width: 60, - height: 60, - fit: BoxFit.fill, - ) - : isWord - ? Image.asset( - 'assets/Images/word.png', - width: 60, - height: 60, - fit: BoxFit.fill, - ) - : Image.memory( - _testProvider.catchImages[index].bytes, - // asset: _images[index], - width: 60, - height: 60, - fit: BoxFit.contain, - ), - ), - ), - Positioned( - top: 0, - right: 0, - child: GestureDetector( - onTap: () { - // setState(() { - _testProvider.removeImage(index); - // }); - }, - child: CircleAvatar( - backgroundColor: Colors.red, - radius: 10, - child: Icon( - Icons.close, - size: 12, - color: Colors.white, - ), - ), - ), - ) - ], - ), - ), - ); - }, - itemCount: _testProvider.catchImages.length, - separatorBuilder: (BuildContext context, int index) => SizedBox( - width: 3 * _deviceBlockSize, - ), - ); - } -} - -Future scan() async { - try { - var barcode = await BarcodeScanner.scan(); - if (barcode.type.name == 'Cancelled') { - return 'cancel'; - } else if (barcode.type.name == 'Failed') { - return 'error'; - } - try { - var id = barcode.rawContent.contains('www.cssd-doc.com') - ? barcode.rawContent.split('/')[5] - : barcode.rawContent; - - return id; - } catch (_) { - return 'null'; - } - } on PlatformException catch (_) { - return 'access'; - } catch (_) { - return 'error'; - } -} +import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:cssd/config/colors.dart'; +import 'package:cssd/providers/input.dart'; +import 'package:file_picker/file_picker.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart'; +import 'package:multiselect_formfield/multiselect_formfield.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/routes.dart'; +import '../../../providers/test_results.dart'; + +class FormCreator extends StatefulWidget { + const FormCreator({ + required this.form, + required this.onChanged, + this.padding, + }); + + final dynamic form; + final double? padding; + final ValueChanged onChanged; + + @override + _FormCreatorState createState() => _FormCreatorState(form); +} + +class _FormCreatorState extends State { + List formItems = []; + DateTime selectedDate = DateTime.now(); + + int? rangeValue; + String? selectValue; + + _FormCreatorState(form); + + Future _selectDate() async { + final DateTime? picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: DateTime(2015, 8), + lastDate: DateTime(2101)); + if (picked != null && picked != selectedDate) + setState(() { + selectedDate = picked; + }); + } + + List jsonToForm() { + var items = Provider.of(context).inputItems; + List listWidgets = []; + formItems = items; + + for (var count = 0; count < formItems.length; count++) { + Map item = formItems[count]; + + if (item['type'] == "Date") { + selectedDate = formItems[count]['value']; + listWidgets.add( + Padding( + padding: const EdgeInsets.symmetric(vertical: 20), + child: OutlinedButton( + onPressed: () { + _selectDate().then((_) { + formItems[count]['value'] = selectedDate; + _handleChanged(); + }); + }, + child: Text( + 'Date: ${selectedDate.year}/${selectedDate.month}/${selectedDate.day}'), + ), + ), + ); + } + if (item['type'] == 'Image') { + final testProviderObject = Provider.of(context); + final mediaData = MediaQuery.of(context); + final deviceWidth = mediaData.size.width; + final _deviceBlockSize = deviceWidth / 100; + listWidgets.insert( + 3, + Container( + // height: 70, + child: Directionality( + textDirection: TextDirection.rtl, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 20), + height: testProviderObject.catchImages.length != 0 ? 60 : 0, + child: ImageBox( + deviceBlockSize: _deviceBlockSize, + testProvider: testProviderObject, + ), + ), + SizedBox( + height: testProviderObject.catchImages.length != 0 ? 10 : 0, + ), + InkWell( + onTap: () async { + await loadAssets(context); + }, + child: Container( + width: MediaQuery.of(context).size.width - 40, + padding: + EdgeInsets.symmetric(vertical: 10, horizontal: 30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '+ Add an image or file from device', + textDirection: TextDirection.ltr, + style: TextStyle(color: Colors.white), + textAlign: TextAlign.center, + ), + ), + ), + SizedBox( + height: 10, + ), + InkWell( + onTap: () async { + await Navigator.of(context) + .pushNamed(Routes.captureImageScreen); + // await captureImage(context); + }, + child: Container( + width: MediaQuery.of(context).size.width - 40, + padding: + EdgeInsets.symmetric(vertical: 10, horizontal: 30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '+ Add an image from camera', + textDirection: TextDirection.ltr, + style: TextStyle(color: Colors.white), + textAlign: TextAlign.center, + ), + ), + ), + ], + ), + ), + ), + ); + } + if (item['type'] == "Label") { + listWidgets.add( + Container( + decoration: BoxDecoration( + border: Border.all(), + borderRadius: BorderRadius.circular(30), + color: Colors.black, + ), + padding: EdgeInsets.only(top: 20, bottom: 20), + margin: EdgeInsets.only(bottom: 20), + child: Text( + item['name'], + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white, fontSize: 20), + ), + ), + ); + } + + if (item['type'] == "Text") { + // print(item['require_scanner'].toString()); + TextEditingController idCTRL = new TextEditingController(); + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + listWidgets.add( + Padding( + padding: const EdgeInsets.all(8.0), + child: item['require_scanner'].toString() != '1' + ? TextFormField( + controller: idCTRL, + decoration: InputDecoration( + labelText: item['name'] ?? "", + border: UnderlineInputBorder(), + contentPadding: EdgeInsets.all(0), + ), + // initialValue: item['value'] ?? '', + onChanged: (String value) { + formItems[count]['value'] = value; + _handleChanged(); + }, + ) + : Container( + child: Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + labelText: item['name'] ?? "", + border: UnderlineInputBorder(), + contentPadding: EdgeInsets.all(0), + ), + // initialValue: item['value'] ?? '', + onChanged: (String value) { + formItems[count]['value'] = value; + _handleChanged(); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + formItems[count]['value'] = result; + _handleChanged(); + // Navigator.of(context).pushNamed( + // CycleDetailScreen.route, + // arguments: result, + // ); + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + ), + ), + ); + } + + if (item['type'] == "Range" || + item['type'] == "Temperature" || + item['type'] == "Pressure") { + double startValue, endValue; + if (item['type'] == "Range") { + startValue = double.parse(item['options'][0]['title']); + endValue = double.parse(item['options'][1]['title']); + } else { + startValue = item['type'] == "Temperature" ? 0.0 : -1.0; + endValue = item['type'] == "Temperature" ? 200.0 : 3.0; + } + + formItems[count]['value'] = formItems[count]['value'] ?? startValue; + // int divisions = (endValue - startValue).round(); + listWidgets.add( + Padding( + padding: EdgeInsets.only(top: 35, left: 10, right: 10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(item['type']), + Text(formItems[count]['value'].toString()), + ], + ), + Slider( + min: startValue, + max: endValue, + value: formItems[count]['value'], + // label: '${formItems[count]['value'].round()}', + // divisions: divisions, + onChanged: (double value) { + setState(() { + formItems[count]['value'] = + double.parse(value.toStringAsFixed(2)); + }); + // print(formItems[count]['value']); + }, + // semanticFormatterCallback: (double newValue) { + // return '${newValue.round()}'; + // }, + ), + ], + ), + ), + ); + } + + if (item['type'] == "Time") { + listWidgets.add( + Padding( + padding: const EdgeInsets.all(8.0), + child: TextFormField( + inputFormatters: [ + LengthLimitingTextInputFormatter(5), + FilteringTextInputFormatter.digitsOnly, + // BlacklistingTextInputFormatter.singleLineFormatter, + TextInputFormatter.withFunction( + (TextEditingValue oldValue, TextEditingValue newValue) { + final int newTextLength = newValue.text.length; + int selectionIndex = newValue.selection.end; + int usedSubstringIndex = 0; + final StringBuffer newText = StringBuffer(); + if (newTextLength >= 2) { + newText.write( + newValue.text.substring(0, usedSubstringIndex = 2) + + ':'); + if (newValue.selection.end >= 2) selectionIndex++; + } + // Dump the rest. + if (newTextLength >= usedSubstringIndex) + newText.write(newValue.text.substring(usedSubstringIndex)); + return TextEditingValue( + text: newText.toString(), + selection: TextSelection.collapsed(offset: selectionIndex), + ); + }) + ], + keyboardType: TextInputType.datetime, + decoration: InputDecoration( + labelText: item['name'] ?? "", + border: UnderlineInputBorder(), + contentPadding: EdgeInsets.all(0), + ), + // initialValue: item['value'] ?? '', + onChanged: (String value) { + formItems[count]['value'] = value; + _handleChanged(); + }, + ), + ), + ); + } + + if (item['type'] == "Select") { + var listItems = item['options'] as List; + listWidgets.add(MultiSelectFormField( + autovalidate: AutovalidateMode.disabled, + title: Text(item['name']), + dataSource: listItems, + textField: 'title', + valueField: 'id', + okButtonLabel: 'OK', + cancelButtonLabel: 'CANCEL', + errorText: 'Please choose one or more', + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please choose one or more options.'; + } + return null; // Return null if validation succeeds + }, + onSaved: (value) { + if (value == null) return; + setState(() { + item['value'] = value; + }); + _handleChanged(); + }, + )); + + // listWidgets.add( + // DropdownButtonFormField( + // items: listItems.map((dynamic value) { + // String stringValue = value['id'].toString(); + // String textValue = value['title'].toString(); + // return DropdownMenuItem( + // value: stringValue, + // child: Text(textValue), + // ); + // }).toList(), + // isDense: true, + // value: item['value'], + // hint: Text(item['name']), + + // onChanged: (String? value) { + // this.setState( + // () { + // _setInput(item['name'], value!); + // formItems[count]['value'] = value; + // _handleChanged(); + // }, + // ); + // }, + // ), + // ); + } + + if (item['type'] == "Radiobutton") { + listWidgets.add( + Container( + margin: EdgeInsets.only(top: 14.0, bottom: 0), + child: Text( + item['name'], + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), + ), + ), + ); + var valueOrFirst = + formItems[count]['value'] ?? formItems[count]['options'][0]['id']; + for (var i = 0; i < item['options'].length; i++) { + var isSelected = formItems[count]['options'][i]['id'] == valueOrFirst; + formItems[count]['value'] = valueOrFirst; + listWidgets.add( + RadioListTile( + dense: true, + controlAffinity: ListTileControlAffinity.trailing, + title: Text(formItems[count]['options'][i]['title']), + value: formItems[count]['options'][i]['id'], + selected: isSelected, + groupValue: formItems[count]['value'], + onChanged: (int? value) { + this.setState( + () { + _setInput(item['name'], value.toString()); + formItems[count]['value'] = value; + _handleChanged(); + }, + ); + }, + ), + ); + } + } + + if (item['type'] == "Switch") { + listWidgets.add( + SwitchListTile( + activeColor: kBlue, + inactiveTrackColor: kPink.withAlpha(150), + inactiveThumbColor: kPink, + title: Text(item['name']), + value: item['value'] ?? false, + onChanged: (bool value) { + this.setState(() { + formItems[count]['value'] = value; + _handleChanged(); + }); + }, + ), + ); + } + + // if (item['type'] == "Form") { + // List children = item['children']; + // print(children); + // listWidgets.add( + // Container( + // margin: EdgeInsets.symmetric(vertical: 10), + // decoration: BoxDecoration(border: Border.all()), + // child: Column( + // children: [ + // Container( + // margin: EdgeInsets.only(top: 10), + // child: Text( + // item['name'], + // style: + // TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), + // ), + // ), + // Container( + // height: 200, + // width: double.infinity, + // child: FormCreator( + // form: item['children'], + // padding: 4, + // onChanged: (value) { + // // _handleChanged(); + // }, + // ), + // ), + // ], + // ), + // ), + // ); + // } + + if (item['type'] == "Checkbox") { + formItems[count]['value'] = formItems[count]['value'] ?? []; + listWidgets.add( + Container( + margin: EdgeInsets.only(top: 14.0, bottom: 0), + child: Text( + item['name'], + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), + ), + ), + ); + for (var i = 0; i < item['options'].length; i++) { + listWidgets.add( + CheckboxListTile( + title: Text(formItems[count]['options'][i]['title']), + value: (formItems[count]['value'] ?? []) + .contains(formItems[count]['options'][i]['id']), + onChanged: (bool? value) { + this.setState( + () { + setState(() { + if (value!) { + (formItems[count]['value'] as List) + .add(formItems[count]['options'][i]['id']); + } else { + (formItems[count]['value'] as List) + .remove(formItems[count]['options'][i]['id']); + } + }); + _handleChanged(); + }, + ); + }, + ), + ); + } + } + // listWidgets.add( + // TestResultAddSaveButton( + // deviceBlockSize: null, + // ), + // ); + } + + return listWidgets; + } + + Future captureImage(BuildContext context) async { + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + try { + files.add( + await ImagePickerGC.pickImage( + context: context, + source: ImgSource.Camera, + cameraIcon: Icon( + Icons.camera_alt, + color: Colors.red, + ), //cameraIcon and galleryIcon can change. If no icon provided default icon will be present + cameraText: Text( + "From Camera", + style: TextStyle(color: Colors.red), + ), + ), + ); + } catch (e) {} + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + } + + Future loadAssets(BuildContext context) async { + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + try { + var datas = await FilePicker.platform.pickFiles( + type: FileType.custom, + allowedExtensions: ['jpg', 'png', 'bmp', 'jpeg', 'pdf', 'docx', 'doc'], + withData: true, + withReadStream: true, + ); + files += datas!.files; + // files += + + // print(files); + } catch (_) {} + + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + // profileProviderObject.addImage(); + } + + // _FormCreatorState(this.formItems); + + void _handleChanged() { + widget.onChanged(formItems); + } + + void _setInput(String key, String value) {} + + @override + Widget build(BuildContext context) { + return ListView.builder( + padding: EdgeInsets.all(widget.padding ?? 16.0), + itemCount: jsonToForm().length, + itemBuilder: (context, index) { + return jsonToForm()[index]; + }, + shrinkWrap: true, + controller: ScrollController(keepScrollOffset: false), + ); + } +} + +class ImageBox extends StatelessWidget { + const ImageBox({ + Key? key, + required double deviceBlockSize, + required TestResultsProvider testProvider, + }) : _deviceBlockSize = deviceBlockSize, + _testProvider = testProvider, + super(key: key); + + final double _deviceBlockSize; + final TestResultsProvider _testProvider; + + @override + Widget build(BuildContext context) { + return ListView.separated( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemBuilder: (ctx, index) { + bool isPdf = _testProvider.catchImages[index].path!.endsWith('pdf'); + bool isWord = _testProvider.catchImages[index].path!.endsWith('docx') || + _testProvider.catchImages[index].path!.endsWith('doc'); + + // print(_testProvider.catchImages[index].path.endsWith('jpg')); + // .substring(_testProvider.catchImages[index].path.length - 4)); + return ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Container( + width: 60, + height: 60, + child: Stack( + children: [ + Positioned( + top: 10, + left: 0, + child: GestureDetector( + onTap: () => isPdf + ? print('pdf') + : isWord + ? print('word') + : Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => Container( + color: Colors.white, + child: Center( + child: Image.memory( + _testProvider.catchImages[index].bytes!, + fit: BoxFit.contain, + ), + ), + ), + ), + ), + child: isPdf + ? Image.asset( + 'assets/Images/pdf.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : isWord + ? Image.asset( + 'assets/Images/word.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : Image.memory( + _testProvider.catchImages[index].bytes!, + // asset: _images[index], + width: 60, + height: 60, + fit: BoxFit.contain, + ), + ), + ), + Positioned( + top: 0, + right: 0, + child: GestureDetector( + onTap: () { + // setState(() { + _testProvider.removeImage(index); + // }); + }, + child: CircleAvatar( + backgroundColor: Colors.red, + radius: 10, + child: Icon( + Icons.close, + size: 12, + color: Colors.white, + ), + ), + ), + ) + ], + ), + ), + ); + }, + itemCount: _testProvider.catchImages.length, + separatorBuilder: (BuildContext context, int index) => SizedBox( + width: 3 * _deviceBlockSize, + ), + ); + } +} + +Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + try { + var id = barcode.rawContent.contains('www.cssd-doc.com') + ? barcode.rawContent.split('/')[5] + : barcode.rawContent; + + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } +} diff --git a/lib/widgets/TestResultScreens/Add/save_button.dart b/lib/widgets/TestResultScreens/Add/save_button.dart index ce0537e..005e26d 100644 --- a/lib/widgets/TestResultScreens/Add/save_button.dart +++ b/lib/widgets/TestResultScreens/Add/save_button.dart @@ -1,57 +1,57 @@ -import 'package:flutter/material.dart'; - -import '../../../config/routes.dart'; - -class TestResultAddSaveButton extends StatelessWidget { - const TestResultAddSaveButton({ - Key key, - // @required GlobalKey form, - // @required this.idCTRL, - @required double deviceBlockSize, - }) : - // _form = form, - _deviceBlockSize = deviceBlockSize, - super(key: key); - - // final GlobalKey _form; - // final TextEditingController idCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () { - // if (! _form.currentState.validate()) { - // return; - // } - Navigator.of(context).pushNamed( - Routes.labelDetailScreen, - // arguments: idCTRL.text, - ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - margin: EdgeInsets.symmetric(horizontal: 20), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'GO!', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - ), - ); - } -} +// import 'package:flutter/material.dart'; + +// import '../../../config/routes.dart'; + +// class TestResultAddSaveButton extends StatelessWidget { +// const TestResultAddSaveButton({ +// Key? key, +// // @required GlobalKey form, +// // @required this.idCTRL, +// required double deviceBlockSize, +// }) : +// // _form = form, +// _deviceBlockSize = deviceBlockSize, +// super(key: key); + +// // final GlobalKey _form; +// // final TextEditingController idCTRL; +// final double _deviceBlockSize; + +// @override +// Widget build(BuildContext context) { +// return InkWell( +// onTap: () { +// // if (! _form.currentState.validate()) { +// // return; +// // } +// Navigator.of(context).pushNamed( +// Routes.labelDetailScreen, +// // arguments: idCTRL.text, +// ); +// }, +// child: Container( +// padding: EdgeInsets.symmetric( +// horizontal: 5 * _deviceBlockSize, +// vertical: 10, +// ), +// margin: EdgeInsets.symmetric(horizontal: 20), +// decoration: BoxDecoration( +// gradient: LinearGradient( +// colors: [Colors.blue, Colors.green], +// ), +// borderRadius: BorderRadius.circular(7), +// ), +// child: Align( +// alignment: Alignment.center, +// child: Text( +// 'GO!', +// style: TextStyle( +// color: Colors.white, +// fontSize: 5 * _deviceBlockSize, +// ), +// ), +// ), +// ), +// ); +// } +// } diff --git a/lib/widgets/TestResultScreens/Add/selector_box.dart b/lib/widgets/TestResultScreens/Add/selector_box.dart index 477ad5a..a8e65f5 100644 --- a/lib/widgets/TestResultScreens/Add/selector_box.dart +++ b/lib/widgets/TestResultScreens/Add/selector_box.dart @@ -1,132 +1,137 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class TestResultAddSelectorBox extends StatefulWidget { - const TestResultAddSelectorBox({ - Key key, - @required double deviceBlockSize, - @required this.dataCTRL, - @required this.dataVals, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController dataCTRL; - final List dataVals; - final String _label; - - @override - _TestResultAddSelectorBoxState createState() => - _TestResultAddSelectorBoxState(); -} - -class _TestResultAddSelectorBoxState extends State { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 6 * widget._deviceBlockSize, - ), - SizedBox( - width: 4 * widget._deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - widget._label, - style: TextStyle( - fontSize: 3 * widget._deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w100, - ), - ), - ], - ), - Container( - height: 40, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: EdgeInsets.only(left: 0), - // border: InputBorder.none, - ), - iconSize: 7 * widget._deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric(horizontal: 0), - child: Text( - widget.dataCTRL.text, - // textDirection: TextDirection.rtl, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 3 * widget._deviceBlockSize, - ), - ), - // TextFormField( - // controller: widget.dataCTRL, - // decoration: InputDecoration( - // contentPadding: EdgeInsets.only(bottom: 15), - // isDense: true, - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // color: Colors.black, - // ), - // // minLines: 1, - // // maxLines: 3, - // ), - ), - isDense: true, - items: widget.dataVals.map((val) { - return new DropdownMenuItem( - value: val, - child: Container( - child: Text( - val, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 3 * widget._deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - widget.dataCTRL.text = val; - }); - }, - ), - ), - ]), - ), - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class TestResultAddSelectorBox extends StatefulWidget { + const TestResultAddSelectorBox({ + Key? key, + required double deviceBlockSize, + required this.dataCTRL, + required this.dataVals, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController dataCTRL; + final List dataVals; + final String _label; + + @override + _TestResultAddSelectorBoxState createState() => + _TestResultAddSelectorBoxState(); +} + +class _TestResultAddSelectorBoxState extends State { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 6 * widget._deviceBlockSize, + ), + SizedBox( + width: 4 * widget._deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + widget._label, + style: TextStyle( + fontSize: 3 * widget._deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w100, + ), + ), + ], + ), + Container( + height: 40, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only(left: 0), + // border: InputBorder.none, + ), + iconSize: 7 * widget._deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric(horizontal: 0), + child: Text( + widget.dataCTRL.text, + // textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 3 * widget._deviceBlockSize, + ), + ), + // TextFormField( + // controller: widget.dataCTRL, + // decoration: InputDecoration( + // contentPadding: EdgeInsets.only(bottom: 15), + // isDense: true, + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // color: Colors.black, + // ), + // // minLines: 1, + // // maxLines: 3, + // ), + ), + isDense: true, + items: widget.dataVals.map( + (val) { + return new DropdownMenuItem( + value: val, + child: Container( + child: Text( + val, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 3 * widget._deviceBlockSize, + ), + ), + ), + ); + }, + ).toList(), + onChanged: (val) { + setState( + () { + widget.dataCTRL.text = val!; + }, + ); + }, + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Details/datas_box.dart b/lib/widgets/TestResultScreens/Details/datas_box.dart index 0f1edf8..53b861c 100644 --- a/lib/widgets/TestResultScreens/Details/datas_box.dart +++ b/lib/widgets/TestResultScreens/Details/datas_box.dart @@ -1,259 +1,276 @@ -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class DatasBox extends StatelessWidget { - const DatasBox({ - Key key, - @required this.datas, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final Map datas; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(230, 230, 230, 1), - border: Border( - left: BorderSide( - color: Colors.pink, - width: 2, - ), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas['date'], - ), - ), - style: TextStyle( - color: Colors.red, - ), - ), - Divider(), - Text( - datas['test_type_name'], - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Test Register ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['id'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Autoclave ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['auto_cleave_id'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Hospital', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['hospital'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('d-M-y').format( - DateTime.parse( - datas['date'], - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Status', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['accepted'] == 'Accepted' - ? 'Accepted' - : 'Rejected', - style: TextStyle( - fontWeight: FontWeight.w700, - color: datas['accepted'] == 'Accepted' - ? Colors.green - : Colors.red, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Description', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['description'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - ], - ), - ), - SizedBox(height: 20,), - InkWell( - onTap: () async=> await launch( - 'https://cssd-doc.com/Show/TestResult/${datas['id'].toString()}', - // 'https://cssd-doc.com/api/TestResults/${datas['id'].toString()}', - - // forceSafariVC: true, - // forceWebView: true, - // headers: {'my_header_key': 'my_header_value'}, - // child: Text('Show Full Details'), - ), - child: Container( - padding: EdgeInsets.symmetric(vertical: 20), - width: double.infinity, - decoration: BoxDecoration( - color: Color.fromRGBO(230, 230, 230, 1), - borderRadius: BorderRadius.circular(25), - ), - child: Center( - child: Text( - 'Show More Details', - style: TextStyle(fontWeight: FontWeight.w700), - ), - ), - ), - ) - ], - ), - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class DatasBox extends StatelessWidget { + const DatasBox({ + Key? key, + required this.datas, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final Map datas; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + SizedBox( + height: 10, + ), + Text( + 'Test Result Details', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + border: Border( + left: BorderSide( + color: datas['accepted'] == 'Accepted' ? kLightBlue : kPink, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas['date'], + ), + ), + style: TextStyle( + color: datas['accepted'] == 'Accepted' ? kLightBlue : kPink, + ), + ), + Divider(), + Text( + datas['test_type_name'], + style: TextStyle( + color: datas['accepted'] == 'Accepted' ? kLightBlue : kPink, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Test Register ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['id'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Autoclave ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['auto_cleave_id'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['hospital'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas['date'], + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Status', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['accepted'] == 'Accepted' || + datas['verified'] == 'Verified' + ? 'Accepted' + : 'Rejected', + style: TextStyle( + fontWeight: FontWeight.w700, + color: datas['accepted'] == 'Accepted' + ? kLightBlue + : kPink, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['description'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () async => await launch( + 'https://cssd-doc.com/Show/TestResult/${datas['id'].toString()}', + // 'https://cssd-doc.com/api/TestResults/${datas['id'].toString()}', + + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ) + ], + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Filter/date_picker.dart b/lib/widgets/TestResultScreens/Filter/date_picker.dart index f7d7de7..6683532 100644 --- a/lib/widgets/TestResultScreens/Filter/date_picker.dart +++ b/lib/widgets/TestResultScreens/Filter/date_picker.dart @@ -1,74 +1,76 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart' as DateEditor; - -class TestResultFilterDatePicker extends StatefulWidget { - TestResultFilterDatePicker({ - Key key, - @required this.dateCTRL, - @required double deviceBlockSize, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final TextEditingController dateCTRL; - final double _deviceBlockSize; - final String _label; - - @override - _TestResultFilterDatePickerState createState() => _TestResultFilterDatePickerState(); -} - -class _TestResultFilterDatePickerState extends State { - @override - Widget build(BuildContext context) { - return InkWell( - onTap: () async { - var res = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2010, 1), - lastDate: DateTime(2101), - ); - if (res != null) { - setState( - () { - widget.dateCTRL.text = DateEditor.DateFormat('y-M-d').format(res); - // sDateValue = - // DateEditor.DateFormat('y-M-d').format( - // dateTimeS, - // ); // baraye tavize makane gharar giri baraye api - }, - ); - } - }, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded( - child: TextField( - enabled: false, - controller: widget.dateCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.calendarAlt, - size: 7 * widget._deviceBlockSize, - ), - labelText: widget._label, - isDense: true, - contentPadding: EdgeInsets.only(bottom: 12, right: 3, left: 3), - // border: InputBorder.none, - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * widget._deviceBlockSize, - ), - ), - ), - Icon(FontAwesomeIcons.angleDown) - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; + +class TestResultFilterDatePicker extends StatefulWidget { + TestResultFilterDatePicker({ + Key? key, + required this.dateCTRL, + required double deviceBlockSize, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final TextEditingController dateCTRL; + final double _deviceBlockSize; + final String _label; + + @override + _TestResultFilterDatePickerState createState() => + _TestResultFilterDatePickerState(); +} + +class _TestResultFilterDatePickerState + extends State { + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () async { + var res = await showDatePicker( + context: context, + initialDate: DateTime.now(), + firstDate: DateTime(2010, 1), + lastDate: DateTime(2101), + ); + if (res != null) { + setState( + () { + widget.dateCTRL.text = DateEditor.DateFormat('y-M-d').format(res); + // sDateValue = + // DateEditor.DateFormat('y-M-d').format( + // dateTimeS, + // ); // baraye tavize makane gharar giri baraye api + }, + ); + } + }, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Expanded( + child: TextField( + enabled: false, + controller: widget.dateCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.calendarAlt, + size: 7 * widget._deviceBlockSize, + ), + labelText: widget._label, + isDense: true, + contentPadding: EdgeInsets.only(bottom: 12, right: 3, left: 3), + // border: InputBorder.none, + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * widget._deviceBlockSize, + ), + ), + ), + Icon(FontAwesomeIcons.angleDown) + ], + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Filter/drop_down_box.dart b/lib/widgets/TestResultScreens/Filter/drop_down_box.dart index ba41556..340ed67 100644 --- a/lib/widgets/TestResultScreens/Filter/drop_down_box.dart +++ b/lib/widgets/TestResultScreens/Filter/drop_down_box.dart @@ -1,88 +1,87 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class DropDownBox extends StatefulWidget { - - DropDownBox({ - Key key, - @required this.values, - }) : super(key: key); - - final List values; - - @override - _DropDownBoxState createState() => _DropDownBoxState(); -} - -class _DropDownBoxState extends State { - String _curValue; - - @override - void initState() { - _curValue = widget.values[0]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - // _curValue = widget.values[0]; - // final ThemeData _theme = Theme.of(context); - // final Color _mainFontColor = _theme.textSelectionColor; - final _media = MediaQuery.of(context); - // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); - final double _devicewidth = _media.size.width; - final double _deviceBlockSize = _devicewidth / 100; - return Row( - // width: double.infinity, - children: [ - Icon( - FontAwesomeIcons.sortNumericDown, - color: Colors.grey, - size: 4 * _deviceBlockSize, - ), - SizedBox( - width: _deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: DropdownButton( - focusColor: Colors.red, - icon: Icon(FontAwesomeIcons.angleDown), - isExpanded: true, - hint: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Text( - _curValue, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - // color: _mainFontColor, - fontSize: 3.5 * _deviceBlockSize, - ), - ), - ), - isDense: true, - items: widget.values.map((String value) { - return new DropdownMenuItem( - value: value, - child: Container( - child: Text( - value, - style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * _deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - _curValue = val; - }); - }, - ), - ), - ]); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class DropDownBox extends StatefulWidget { + DropDownBox({ + Key? key, + required this.values, + }) : super(key: key); + + final List values; + + @override + _DropDownBoxState createState() => _DropDownBoxState(); +} + +class _DropDownBoxState extends State { + String? _curValue; + + @override + void initState() { + _curValue = widget.values[0]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + // _curValue = widget.values[0]; + // final ThemeData _theme = Theme.of(context); + // final Color _mainFontColor = _theme.textSelectionColor; + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Row( + // width: double.infinity, + children: [ + Icon( + FontAwesomeIcons.sortNumericDown, + color: Colors.grey, + size: 4 * _deviceBlockSize, + ), + SizedBox( + width: _deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: DropdownButton( + focusColor: Colors.red, + icon: Icon(FontAwesomeIcons.angleDown), + isExpanded: true, + hint: Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Text( + _curValue!, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + // color: _mainFontColor, + fontSize: 3.5 * _deviceBlockSize, + ), + ), + ), + isDense: true, + items: widget.values.map((String value) { + return new DropdownMenuItem( + value: value, + child: Container( + child: Text( + value, + style: TextStyle( + // color: _mainFontColor, + fontSize: 4 * _deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState(() { + _curValue = val; + }); + }, + ), + ), + ]); + } +} diff --git a/lib/widgets/TestResultScreens/Filter/selector_box.dart b/lib/widgets/TestResultScreens/Filter/selector_box.dart index 56a3507..81c3b03 100644 --- a/lib/widgets/TestResultScreens/Filter/selector_box.dart +++ b/lib/widgets/TestResultScreens/Filter/selector_box.dart @@ -1,130 +1,130 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -class TestResultFilterSelectorBox extends StatefulWidget { - const TestResultFilterSelectorBox({ - Key key, - @required double deviceBlockSize, - @required this.dataCTRL, - @required this.dataVals, - @required String label, - }) : _deviceBlockSize = deviceBlockSize, - _label = label, - super(key: key); - - final double _deviceBlockSize; - final TextEditingController dataCTRL; - final List dataVals; - final String _label; - - @override - _TestResultFilterSelectorBoxState createState() => - _TestResultFilterSelectorBoxState(); -} - -class _TestResultFilterSelectorBoxState - extends State { - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.symmetric(vertical: 5), - // height: 65, - child: Row( - // width: double.infinity, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - FontAwesomeIcons.alignLeft, - color: Colors.grey, - size: 7 * widget._deviceBlockSize, - ), - SizedBox( - width: 4 * widget._deviceBlockSize, - ), - Expanded( - // width: MediaQuery.of(context).size.width - 70, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - widget._label, - style: TextStyle( - fontSize: 3.5 * widget._deviceBlockSize, - color: Colors.grey, - fontWeight: FontWeight.w100, - ), - ), - ], - ), - Container( - // height: 30, - child: DropdownButtonFormField( - decoration: InputDecoration( - contentPadding: EdgeInsets.only(left: 0), - // border: InputBorder.none, - ), - iconSize: 7 * widget._deviceBlockSize, - icon: Icon( - FontAwesomeIcons.angleDown, - color: Colors.black, - ), - isExpanded: true, - hint: Container( - // width: 100, - height: 70, - padding: const EdgeInsets.symmetric(horizontal: 0), - child: Text( - widget.dataCTRL.text, - // textDirection: TextDirection.rtl, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontWeight: FontWeight.w700, - color: Colors.black, - fontSize: 5 * widget._deviceBlockSize), - ), - // TextFormField( - // controller: widget.dataCTRL, - // decoration: InputDecoration( - // contentPadding: EdgeInsets.only(bottom: 15), - // isDense: true, - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // color: Colors.black, - // ), - // // minLines: 1, - // // maxLines: 3, - // ), - ), - isDense: true, - items: widget.dataVals.map((val) { - return new DropdownMenuItem( - value: val, - child: Container( - child: Text( - val, - style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * widget._deviceBlockSize, - ), - ), - ), - ); - }).toList(), - onChanged: (val) { - setState(() { - widget.dataCTRL.text = val; - }); - }, - ), - ), - ]), - ), - ], - ), - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class TestResultFilterSelectorBox extends StatefulWidget { + const TestResultFilterSelectorBox({ + Key? key, + required double deviceBlockSize, + required this.dataCTRL, + required this.dataVals, + required String label, + }) : _deviceBlockSize = deviceBlockSize, + _label = label, + super(key: key); + + final double _deviceBlockSize; + final TextEditingController dataCTRL; + final List dataVals; + final String _label; + + @override + _TestResultFilterSelectorBoxState createState() => + _TestResultFilterSelectorBoxState(); +} + +class _TestResultFilterSelectorBoxState + extends State { + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 5), + // height: 65, + child: Row( + // width: double.infinity, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + FontAwesomeIcons.alignLeft, + color: Colors.grey, + size: 7 * widget._deviceBlockSize, + ), + SizedBox( + width: 4 * widget._deviceBlockSize, + ), + Expanded( + // width: MediaQuery.of(context).size.width - 70, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + widget._label, + style: TextStyle( + fontSize: 3.5 * widget._deviceBlockSize, + color: Colors.grey, + fontWeight: FontWeight.w100, + ), + ), + ], + ), + Container( + // height: 30, + child: DropdownButtonFormField( + decoration: InputDecoration( + contentPadding: EdgeInsets.only(left: 0), + // border: InputBorder.none, + ), + iconSize: 7 * widget._deviceBlockSize, + icon: Icon( + FontAwesomeIcons.angleDown, + color: Colors.black, + ), + isExpanded: true, + hint: Container( + // width: 100, + height: 70, + padding: const EdgeInsets.symmetric(horizontal: 0), + child: Text( + widget.dataCTRL.text, + // textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * widget._deviceBlockSize), + ), + // TextFormField( + // controller: widget.dataCTRL, + // decoration: InputDecoration( + // contentPadding: EdgeInsets.only(bottom: 15), + // isDense: true, + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // color: Colors.black, + // ), + // // minLines: 1, + // // maxLines: 3, + // ), + ), + isDense: true, + items: widget.dataVals.map((val) { + return new DropdownMenuItem( + value: val, + child: Container( + child: Text( + val, + style: TextStyle( + // color: _mainFontColor, + fontSize: 4 * widget._deviceBlockSize, + ), + ), + ), + ); + }).toList(), + onChanged: (val) { + setState(() { + widget.dataCTRL.text = val!; + }); + }, + ), + ), + ]), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Main/add_button.dart b/lib/widgets/TestResultScreens/Main/add_button.dart index 150e83d..f60f716 100644 --- a/lib/widgets/TestResultScreens/Main/add_button.dart +++ b/lib/widgets/TestResultScreens/Main/add_button.dart @@ -1,35 +1,35 @@ -import 'package:flutter/material.dart'; - -import '../../../config/routes.dart'; - -class TestResultAddButton extends StatelessWidget { - const TestResultAddButton({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed(Routes.testResultAddScreen); - }, - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.redAccent, - ), - child: Icon( - Icons.add, - size: 10 * _deviceBlockSize, - color: Colors.white, - ), - ), - ); - } -} +import 'package:flutter/material.dart'; + +import '../../../config/routes.dart'; + +class TestResultAddButton extends StatelessWidget { + const TestResultAddButton({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.testResultAddScreen); + }, + child: Container( + padding: EdgeInsets.all(5), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.redAccent, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Main/filter_chip_box.dart b/lib/widgets/TestResultScreens/Main/filter_chip_box.dart index 864af12..2c1316e 100644 --- a/lib/widgets/TestResultScreens/Main/filter_chip_box.dart +++ b/lib/widgets/TestResultScreens/Main/filter_chip_box.dart @@ -1,76 +1,77 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/test_results.dart'; - -class TestResultChip extends StatelessWidget { - const TestResultChip({ - Key key, - @required double deviceBlockSize, - @required String label, - @required String id, - @required String labelID, - @required String testType, - @required String hospital, - @required String username, - @required String fDate, - @required String uDate, - }) : _deviceBlockSize = deviceBlockSize, - _id = id, - _labelID = labelID, - _testType = testType, - _hispotal = hospital, - _label = label, - _username = username, - _fDate = fDate, - _uDate = uDate, - super(key: key); - - final double _deviceBlockSize; - final String _id; - final String _labelID; - final String _testType; - final String _hispotal; - final String _label; - final String _username; - final String _fDate; - final String _uDate; - - @override - Widget build(BuildContext context) { - return Row(children: [ - SizedBox( - width: _deviceBlockSize, - ), - Chip( - backgroundColor: Colors.black, - label: Text( - _label, - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - Icons.close, - color: Colors.white, - ), - onDeleted: () { - var labelProviderObject = Provider.of(context); - labelProviderObject.setFilters( - _id, - _labelID, - _username, - _testType, - _hispotal, - _fDate, - _uDate, - ); - labelProviderObject.setLoading(); - labelProviderObject.getTestResults().then((_) { - labelProviderObject.resetLoading(); - }); - }, - ), - ]); - } -} +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/test_results.dart'; + +class TestResultChip extends StatelessWidget { + const TestResultChip({ + Key? key, + required double deviceBlockSize, + required String label, + required String id, + required String labelID, + required String testType, + required String hospital, + required String username, + required String fDate, + required String uDate, + }) : _deviceBlockSize = deviceBlockSize, + _id = id, + _labelID = labelID, + _testType = testType, + _hispotal = hospital, + _label = label, + _username = username, + _fDate = fDate, + _uDate = uDate, + super(key: key); + + final double _deviceBlockSize; + final String _id; + final String _labelID; + final String _testType; + final String _hispotal; + final String _label; + final String _username; + final String _fDate; + final String _uDate; + + @override + Widget build(BuildContext context) { + return Row(children: [ + SizedBox( + width: _deviceBlockSize, + ), + Chip( + backgroundColor: Colors.black, + label: Text( + _label, + style: TextStyle( + color: Colors.white, + ), + ), + deleteIcon: Icon( + Icons.close, + color: Colors.white, + ), + onDeleted: () { + var labelProviderObject = + Provider.of(context, listen: false); + labelProviderObject.setFilters( + _id, + _labelID, + _username, + _testType, + _hispotal, + _fDate, + _uDate, + ); + labelProviderObject.setLoading(); + labelProviderObject.getTestResults().then((_) { + labelProviderObject.resetLoading(); + }); + }, + ), + ]); + } +} diff --git a/lib/widgets/TestResultScreens/Main/floating_button.dart b/lib/widgets/TestResultScreens/Main/floating_button.dart index 968d5eb..f9056d3 100644 --- a/lib/widgets/TestResultScreens/Main/floating_button.dart +++ b/lib/widgets/TestResultScreens/Main/floating_button.dart @@ -1,93 +1,63 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../../config/routes.dart'; - -// class TestResultFloatingButton extends StatelessWidget { -// const TestResultFloatingButton({ -// Key key, -// @required double deviceBlockSize, -// }) : _deviceBlockSize = deviceBlockSize, -// super(key: key); - -// final double _deviceBlockSize; - -// @override -// Widget build(BuildContext context) { -// return InkWell( -// onTap: () { -// Navigator.of(context).popAndPushNamed(Routes.testResultAddScreen); -// }, -// child: Container( -// padding: EdgeInsets.all(5), -// decoration: BoxDecoration( -// shape: BoxShape.circle, -// color: Color.fromRGBO(0, 190, 190, 1), -// ), -// child: Icon( -// Icons.add, -// size: 10 * _deviceBlockSize, -// color: Colors.white, -// ), -// ), -// ); -// } -// } - -class TestResultFloatingButton extends StatelessWidget { - const TestResultFloatingButton({ - Key key, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushNamed(Routes.testScanScreen); - }, - child: Container( - padding: EdgeInsets.all(2.5 * _deviceBlockSize), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.barcode, - size: 7.1 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - SizedBox( - width: 2 * _deviceBlockSize, - ), - InkWell( - customBorder: CircleBorder(), - onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.testResultAddScreen); - }, - child: Container( - padding: EdgeInsets.all(_deviceBlockSize), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color.fromRGBO(0, 190, 190, 1), - ), - child: Icon( - Icons.add, - size: 10 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ], - ); - } -} +import 'package:cssd/config/colors.dart'; +import 'package:flutter/material.dart'; + +import '../../../config/routes.dart'; + +class TestResultFloatingButton extends StatelessWidget { + const TestResultFloatingButton({ + Key? key, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.testScanScreen); + }, + child: Container( + padding: EdgeInsets.all(2.5 * _deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 2 * _deviceBlockSize, + ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context) + .pushReplacementNamed(Routes.testResultAddScreen); + }, + child: Container( + padding: EdgeInsets.all(_deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: kLightBlue, + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ); + } +} diff --git a/lib/widgets/TestResultScreens/Main/search_box.dart b/lib/widgets/TestResultScreens/Main/search_box.dart index dba563c..0113011 100644 --- a/lib/widgets/TestResultScreens/Main/search_box.dart +++ b/lib/widgets/TestResultScreens/Main/search_box.dart @@ -1,48 +1,48 @@ -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../../providers/test_results.dart'; - -class TestResultSearchBox extends StatelessWidget { - const TestResultSearchBox({ - Key key, - @required this.searchCTRL, - @required double deviceBlockSize, - }) : _deviceBlockSize = deviceBlockSize, - super(key: key); - - final TextEditingController searchCTRL; - final double _deviceBlockSize; - - @override - Widget build(BuildContext context) { - return TextField( - onEditingComplete: () { - FocusScope.of(context).unfocus(); - }, - onChanged: (value) { - Provider.of(context, listen: false).search(value); - }, - controller: searchCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.search, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Search by test name', - isDense: true, - contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - ); - } -} +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/test_results.dart'; + +class TestResultSearchBox extends StatelessWidget { + const TestResultSearchBox({ + Key? key, + required this.searchCTRL, + required double deviceBlockSize, + }) : _deviceBlockSize = deviceBlockSize, + super(key: key); + + final TextEditingController searchCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return TextField( + onEditingComplete: () { + FocusScope.of(context).unfocus(); + }, + onChanged: (value) { + Provider.of(context, listen: false).search(value); + }, + controller: searchCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.search, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Search by test name', + isDense: true, + contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.visiblePassword, + ); + } +} diff --git a/macos/.gitignore b/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..4b81f9b --- /dev/null +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..5caa9d1 --- /dev/null +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..7fd61bc --- /dev/null +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,18 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import connectivity_macos +import path_provider_foundation +import shared_preferences_foundation +import url_launcher_macos + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) +} diff --git a/macos/Podfile b/macos/Podfile new file mode 100644 index 0000000..c795730 --- /dev/null +++ b/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# 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', 'ephemeral', '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 Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_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_macos_build_settings(target) + end +end diff --git a/macos/Podfile.lock b/macos/Podfile.lock new file mode 100644 index 0000000..76d2a42 --- /dev/null +++ b/macos/Podfile.lock @@ -0,0 +1,49 @@ +PODS: + - connectivity_macos (0.0.1): + - FlutterMacOS + - Reachability + - FlutterMacOS (1.0.0) + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS + - Reachability (3.2) + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS + +DEPENDENCIES: + - connectivity_macos (from `Flutter/ephemeral/.symlinks/plugins/connectivity_macos/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) + - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) + - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) + +SPEC REPOS: + trunk: + - Reachability + +EXTERNAL SOURCES: + connectivity_macos: + :path: Flutter/ephemeral/.symlinks/plugins/connectivity_macos/macos + FlutterMacOS: + :path: Flutter/ephemeral + path_provider_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin + shared_preferences_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos + +SPEC CHECKSUMS: + connectivity_macos: 5dae6ee11d320fac7c05f0d08bd08fc32b5514d9 + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 + shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 + +PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 + +COCOAPODS: 1.13.0 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..64d9ba4 --- /dev/null +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,791 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 01882A8F1B03AA37E8F134D9 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E49B7937AB78ECF1C85FAC3C /* Pods_Runner.framework */; }; + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 72DAF9C82785A4E248FEF6B3 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659CE87A2DF6C2B4D8AE5741 /* Pods_RunnerTests.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* cssd.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = cssd.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 4624B36C291F9CEBB36776B6 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; + 4CAC533A880473CE5F2EF1FA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 659CE87A2DF6C2B4D8AE5741 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 65DB3E62D2B2F9A21F94EA87 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + A949F98DEA319FA1D427C5C0 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; + E49B7937AB78ECF1C85FAC3C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + EA2D22D937799F6D7C2F48FE /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + EDDB523B0E8A982104154610 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 72DAF9C82785A4E248FEF6B3 /* Pods_RunnerTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 01882A8F1B03AA37E8F134D9 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + 69724AF2FBD7540CCD08568D /* Pods */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* cssd.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + 69724AF2FBD7540CCD08568D /* Pods */ = { + isa = PBXGroup; + children = ( + 4CAC533A880473CE5F2EF1FA /* Pods-Runner.debug.xcconfig */, + EDDB523B0E8A982104154610 /* Pods-Runner.release.xcconfig */, + 65DB3E62D2B2F9A21F94EA87 /* Pods-Runner.profile.xcconfig */, + A949F98DEA319FA1D427C5C0 /* Pods-RunnerTests.debug.xcconfig */, + 4624B36C291F9CEBB36776B6 /* Pods-RunnerTests.release.xcconfig */, + EA2D22D937799F6D7C2F48FE /* Pods-RunnerTests.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + E49B7937AB78ECF1C85FAC3C /* Pods_Runner.framework */, + 659CE87A2DF6C2B4D8AE5741 /* Pods_RunnerTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + B5DEC323D3581BB6443C1D42 /* [CP] Check Pods Manifest.lock */, + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 2FADE5A4EF50582361027EB3 /* [CP] Check Pods Manifest.lock */, + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + 4501F9D449D460C52F0B20B7 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* cssd.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2FADE5A4EF50582361027EB3 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; + 4501F9D449D460C52F0B20B7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + B5DEC323D3581BB6443C1D42 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A949F98DEA319FA1D427C5C0 /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/cssd.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/cssd"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4624B36C291F9CEBB36776B6 /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/cssd.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/cssd"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = EA2D22D937799F6D7C2F48FE /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/cssd.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/cssd"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..d7a5670 --- /dev/null +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..5a23593 --- /dev/null +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = cssd + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.cssd + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. diff --git a/macos/Runner/Configs/Debug.xcconfig b/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Release.xcconfig b/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/macos/Runner/Configs/Warnings.xcconfig b/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..c946719 --- /dev/null +++ b/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + com.apple.security.network.client + + + diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/macos/Runner/MainFlutterWindow.swift b/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements new file mode 100644 index 0000000..48271ac --- /dev/null +++ b/macos/Runner/Release.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/macos/RunnerTests/RunnerTests.swift b/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..5418c9f --- /dev/null +++ b/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/pubspec.lock b/pubspec.lock index 335d9be..e3d122a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,579 +1,802 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.6.1" - barcode_scan2: - dependency: "direct main" - description: - name: barcode_scan2 - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.3" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - camera: - dependency: "direct main" - description: - name: camera - url: "https://pub.dartlang.org" - source: hosted - version: "0.5.8+2" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.15.0" - connectivity: - dependency: "direct main" - description: - name: connectivity - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.6" - connectivity_for_web: - dependency: transitive - description: - name: connectivity_for_web - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.0" - connectivity_macos: - dependency: transitive - description: - name: connectivity_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" - connectivity_platform_interface: - dependency: transitive - description: - name: connectivity_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.5" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - dio: - dependency: "direct main" - description: - name: dio - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - double_back_to_close_app: - dependency: "direct main" - description: - name: double_back_to_close_app - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.2" - file_picker: - dependency: "direct main" - description: - name: file_picker - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.2+2" - fixnum: - dependency: transitive - description: - name: fixnum - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_launcher_icons: - dependency: "direct dev" - description: - name: flutter_launcher_icons - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.5" - flutter_phoenix: - dependency: "direct main" - description: - name: flutter_phoenix - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - flutter_plugin_android_lifecycle: - dependency: transitive - description: - name: flutter_plugin_android_lifecycle - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - flutter_web_plugins: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - font_awesome_flutter: - dependency: "direct main" - description: - name: font_awesome_flutter - url: "https://pub.dartlang.org" - source: hosted - version: "8.8.1" - http: - dependency: "direct main" - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.13.3" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.14" - image_picker: - dependency: transitive - description: - name: image_picker - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.5+4" - image_picker_for_web: - dependency: transitive - description: - name: image_picker_for_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - image_picker_gallery_camera: - dependency: "direct main" - description: - name: image_picker_gallery_camera - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.2" - image_picker_platform_interface: - dependency: transitive - description: - name: image_picker_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - intl: - dependency: "direct main" - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" - source: hosted - version: "0.6.3" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.10" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - multiselect_formfield: - dependency: "direct main" - description: - name: multiselect_formfield - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.2" - nested: - dependency: transitive - description: - name: nested - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - path_provider: - dependency: "direct main" - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.2" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.4" - platform: - dependency: transitive - description: - name: platform - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.1" - protobuf: - dependency: transitive - description: - name: protobuf - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - provider: - dependency: "direct main" - description: - name: provider - url: "https://pub.dartlang.org" - source: hosted - version: "5.0.0" - random_string: - dependency: "direct main" - description: - name: random_string - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - shared_preferences: - dependency: "direct main" - description: - name: shared_preferences - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.6" - shared_preferences_linux: - dependency: transitive - description: - name: shared_preferences_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - shared_preferences_platform_interface: - dependency: transitive - description: - name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - shared_preferences_web: - dependency: transitive - description: - name: shared_preferences_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - shared_preferences_windows: - dependency: transitive - description: - name: shared_preferences_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.0" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - url_launcher: - dependency: "direct main" - description: - name: url_launcher - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.6" - url_launcher_linux: - dependency: transitive - description: - name: url_launcher_linux - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - url_launcher_macos: - dependency: transitive - description: - name: url_launcher_macos - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - url_launcher_platform_interface: - dependency: transitive - description: - name: url_launcher_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.3" - url_launcher_web: - dependency: transitive - description: - name: url_launcher_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.1" - url_launcher_windows: - dependency: transitive - description: - name: url_launcher_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.0" - yaml: - dependency: transitive - description: - name: yaml - url: "https://pub.dartlang.org" - source: hosted - version: "2.2.1" -sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + archive: + dependency: transitive + description: + name: archive + sha256: e0902a06f0e00414e4e3438a084580161279f137aeb862274710f29ec10cf01e + url: "https://pub.dev" + source: hosted + version: "3.3.9" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + barcode_scan2: + dependency: "direct main" + description: + name: barcode_scan2 + sha256: "0b0625d27841a21e36e896195d86b2aada335e3c486f63647cce701495718e16" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + camera: + dependency: "direct main" + description: + name: camera + sha256: f63f2687fb1795c36f7c57b18a03071880eabb0fd8b5291b0fcd3fb979cb0fb1 + url: "https://pub.dev" + source: hosted + version: "0.10.5+4" + camera_android: + dependency: transitive + description: + name: camera_android + sha256: ed4f645848074166fc3b8e20350f83ca07e09a2becc1e185040ee561f955d4df + url: "https://pub.dev" + source: hosted + version: "0.10.8+8" + camera_avfoundation: + dependency: transitive + description: + name: camera_avfoundation + sha256: "718b60ed2e22b4067fe6e2c0e9ebe2856c2de5c8b1289ba95d10db85b0b00bc2" + url: "https://pub.dev" + source: hosted + version: "0.9.13+4" + camera_platform_interface: + dependency: transitive + description: + name: camera_platform_interface + sha256: "8734d1c682f034bdb12d0d6ff379b0535a9b8e44266b530025bf8266d6a62f28" + url: "https://pub.dev" + source: hosted + version: "2.5.2" + camera_web: + dependency: transitive + description: + name: camera_web + sha256: d4c2c571c7af04f8b10702ca16bb9ed2a26e64534171e8f75c9349b2c004d8f1 + url: "https://pub.dev" + source: hosted + version: "0.3.2+3" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + url: "https://pub.dev" + source: hosted + version: "0.4.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" + source: hosted + version: "1.17.2" + connectivity: + dependency: "direct main" + description: + name: connectivity + sha256: a8e91263cf3e25fb5cc95e19dfde4999e32a648ac3b9e8a558a28165731678f8 + url: "https://pub.dev" + source: hosted + version: "3.0.6" + connectivity_for_web: + dependency: transitive + description: + name: connectivity_for_web + sha256: "01a390c1d5adc2ed1fa1f52d120c07fe9fd01166a93f965a832fd6cfc0ea6482" + url: "https://pub.dev" + source: hosted + version: "0.4.0+1" + connectivity_macos: + dependency: transitive + description: + name: connectivity_macos + sha256: "51ae08d5162eca9669b9d8951ed83ce19c5355a81149f94e4dee2740beb93628" + url: "https://pub.dev" + source: hosted + version: "0.2.1+2" + connectivity_platform_interface: + dependency: transitive + description: + name: connectivity_platform_interface + sha256: "2d82e942df9d49f29a24bb07fb5ce085d4a53e47818c62364d2b6deb9e0d7a8e" + url: "https://pub.dev" + source: hosted + version: "2.0.1" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: fd832b5384d0d6da4f6df60b854d33accaaeb63aa9e10e736a87381f08dee2cb + url: "https://pub.dev" + source: hosted + version: "0.3.3+5" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + dio: + dependency: "direct main" + description: + name: dio + sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197 + url: "https://pub.dev" + source: hosted + version: "5.3.2" + double_back_to_close_app: + dependency: "direct main" + description: + name: double_back_to_close_app + sha256: d19ce4e2f8d2cb9f35bdbc90eecd5c731cc0e6216f5e8f14e7d1e076dafb344a + url: "https://pub.dev" + source: hosted + version: "2.1.0" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + file_picker: + dependency: "direct main" + description: + name: file_picker + sha256: be325344c1f3070354a1d84a231a1ba75ea85d413774ec4bdf444c023342e030 + url: "https://pub.dev" + source: hosted + version: "5.5.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_launcher_icons: + dependency: "direct dev" + description: + name: flutter_launcher_icons + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" + source: hosted + version: "0.13.1" + flutter_lints: + dependency: "direct main" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_phoenix: + dependency: "direct main" + description: + name: flutter_phoenix + sha256: "39589dac934ea476d0e43fb60c1ddfba58f14960743640c8250dea11c4333378" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: f185ac890306b5779ecbd611f52502d8d4d63d27703ef73161ca0407e815f02c + url: "https://pub.dev" + source: hosted + version: "2.0.16" + 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" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + sha256: "5fb789145cae1f4c3245c58b3f8fb287d055c26323879eab57a7bf0cfd1e45f3" + url: "https://pub.dev" + source: hosted + version: "10.5.0" + http: + dependency: "direct main" + description: + name: http + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + image: + dependency: transitive + description: + name: image + sha256: a72242c9a0ffb65d03de1b7113bc4e189686fc07c7147b8b41811d0dd0e0d9bf + url: "https://pub.dev" + source: hosted + version: "4.0.17" + image_picker: + dependency: transitive + description: + name: image_picker + sha256: b4f02353277b39f350093a2460b32b43eafaa3bfc4f92e8d90926698d8d78df6 + url: "https://pub.dev" + source: hosted + version: "0.7.5+4" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "869fe8a64771b7afbc99fc433a5f7be2fea4d1cb3d7c11a48b6b579eb9c797f0" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + image_picker_gallery_camera: + dependency: "direct main" + description: + name: image_picker_gallery_camera + sha256: "8fedbb3ed82f5bf39c1370234b092ccedf0e01a741cc68a36ba9ea2982d8ca01" + url: "https://pub.dev" + source: hosted + version: "0.2.2" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: ed9b00e63977c93b0d2d2b343685bed9c324534ba5abafbb3dfbd6a780b1b514 + url: "https://pub.dev" + source: hosted + version: "2.9.1" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + multiselect_formfield: + dependency: "direct main" + description: + name: multiselect_formfield + sha256: "3a28c41093a53b4dc30ee0e4f73f67169a8be883dd3b17a4561467185ce1adf8" + url: "https://pub.dev" + source: hosted + version: "0.1.7" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" + platform: + dependency: transitive + description: + name: platform + sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + url: "https://pub.dev" + source: hosted + version: "2.1.6" + pointycastle: + dependency: transitive + description: + name: pointycastle + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + url: "https://pub.dev" + source: hosted + version: "3.7.3" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + provider: + dependency: "direct main" + description: + name: provider + sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + url: "https://pub.dev" + source: hosted + version: "6.0.5" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" + random_string: + dependency: "direct main" + description: + name: random_string + sha256: "03b52435aae8cbdd1056cf91bfc5bf845e9706724dd35ae2e99fa14a1ef79d02" + url: "https://pub.dev" + source: hosted + version: "2.3.1" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: b7f41bad7e521d205998772545de63ff4e6c97714775902c199353f8bf1511ac + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" + url: "https://pub.dev" + source: hosted + version: "2.3.4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a + url: "https://pub.dev" + source: hosted + version: "2.3.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a + url: "https://pub.dev" + source: hosted + version: "2.3.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf + url: "https://pub.dev" + source: hosted + version: "2.2.1" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f + url: "https://pub.dev" + source: hosted + version: "2.3.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" + url: "https://pub.dev" + source: hosted + version: "6.1.14" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330 + url: "https://pub.dev" + source: hosted + version: "6.1.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f" + url: "https://pub.dev" + source: hosted + version: "6.1.5" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e + url: "https://pub.dev" + source: hosted + version: "3.0.6" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88 + url: "https://pub.dev" + source: hosted + version: "3.0.7" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5" + url: "https://pub.dev" + source: hosted + version: "2.0.20" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069" + url: "https://pub.dev" + source: hosted + version: "3.0.8" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" + win32: + dependency: transitive + description: + name: win32 + sha256: "9e82a402b7f3d518fb9c02d0e9ae45952df31b9bf34d77baf19da2de03fc2aaa" + url: "https://pub.dev" + source: hosted + version: "5.0.7" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + xml: + dependency: transitive + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index 35e1b9b..610e444 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,93 +1,94 @@ -name: cssd -description: A new Flutter project. - -# 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 used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.7.1+7 - -environment: - sdk: ">=2.7.0 <3.0.0" - -dependencies: - flutter: - sdk: flutter - barcode_scan2: ^4.1.3 - camera: ^0.5.8+2 - connectivity: ^3.0.6 - cupertino_icons: ^1.0.3 - dio: ^4.0.0 - double_back_to_close_app: ^2.0.1 - file_picker: ^3.0.2+2 - flutter_phoenix: ^1.0.0 - font_awesome_flutter: ^8.8.1 - http: ^0.13.3 - image_picker_gallery_camera: ^0.2.2 - intl: ^0.16.1 - multiselect_formfield: ^0.1.2 - path_provider: ^2.0.2 - provider: ^5.0.0 - random_string: ^2.0.1 - shared_preferences: ^2.0.6 - url_launcher: ^6.0.6 - # video_player: ^0.10.11+2 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_launcher_icons: ^0.7.5 - -flutter_icons: - image_path: "assets/Images/icon.png" - android: true - ios: true -# 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. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - assets: - - assets/Images/ - # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - fonts: - - family: montserrat - fonts: - - asset: assets/Fonts/Montserrat-Regular.ttf - - asset: assets/Fonts/Montserrat-Bold.ttf - weight: 700 - - family: montserratlight - fonts: - - asset: assets/Fonts/Montserrat-Light.ttf - - asset: assets/Fonts/Montserrat-Bold.ttf - weight: 700 - - family: montserratmedium - fonts: - - asset: assets/Fonts/Montserrat-Medium.ttf - - asset: assets/Fonts/Montserrat-Bold.ttf - weight: 700 - # - asset: assets/Fonts/Montserrat-Light.ttf - # - asset: assets/Fonts/Montserrat-Italic.ttf - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages +name: cssd +description: A new Flutter project. + +# 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 used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +version: 1.7.1+7 + +environment: + sdk: ">=3.0.5 <4.0.0" + +dependencies: + flutter: + sdk: flutter + barcode_scan2: ^4.1.3 + camera: ^0.10.5+4 + connectivity: ^3.0.6 + cupertino_icons: ^1.0.3 + dio: ^5.3.2 + double_back_to_close_app: ^2.0.1 + file_picker: ^5.5.0 + flutter_phoenix: ^1.0.0 + font_awesome_flutter: ^10.5.0 + http: ^1.1.0 + image_picker_gallery_camera: ^0.2.2 + intl: ^0.18.1 + multiselect_formfield: ^0.1.2 + path_provider: ^2.0.2 + provider: ^6.0.5 + random_string: ^2.0.1 + shared_preferences: ^2.0.6 + url_launcher: ^6.0.6 + equatable: ^2.0.5 + flutter_lints: ^2.0.3 + # video_player: ^0.10.11+2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_launcher_icons: ^0.13.1 + +flutter_icons: + image_path: "assets/Images/icon.png" + android: true + ios: true +# 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. +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + assets: + - assets/Images/ + # - images/a_dot_ham.jpeg + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + fonts: + - family: montserrat + fonts: + - asset: assets/Fonts/Montserrat-Regular.ttf + - asset: assets/Fonts/Montserrat-Bold.ttf + weight: 700 + - family: montserratlight + fonts: + - asset: assets/Fonts/Montserrat-Light.ttf + - asset: assets/Fonts/Montserrat-Bold.ttf + weight: 700 + - family: montserratmedium + fonts: + - asset: assets/Fonts/Montserrat-Medium.ttf + - asset: assets/Fonts/Montserrat-Bold.ttf + weight: 700 + # - asset: assets/Fonts/Montserrat-Light.ttf + # - asset: assets/Fonts/Montserrat-Italic.ttf + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/test/widget_test.dart b/test/widget_test.dart index f0d60ac..63b4df0 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,30 +1,30 @@ -// // This is a basic Flutter widget test. -// // -// // To perform an interaction with a widget in your test, use the WidgetTester -// // utility that Flutter provides. 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:cssd/main.dart'; - -// void main() { -// testWidgets('Counter increments smoke test', (WidgetTester tester) async { -// // Build our app and trigger a frame. -// await tester.pumpWidget(MyApp()); - -// // Verify that our counter starts at 0. -// expect(find.text('0'), findsOneWidget); -// expect(find.text('1'), findsNothing); - -// // Tap the '+' icon and trigger a frame. -// await tester.tap(find.byIcon(Icons.add)); -// await tester.pump(); - -// // Verify that our counter has incremented. -// expect(find.text('0'), findsNothing); -// expect(find.text('1'), findsOneWidget); -// }); -// } +// // This is a basic Flutter widget test. +// // +// // To perform an interaction with a widget in your test, use the WidgetTester +// // utility that Flutter provides. 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:cssd/main.dart'; + +// void main() { +// testWidgets('Counter increments smoke test', (WidgetTester tester) async { +// // Build our app and trigger a frame. +// await tester.pumpWidget(MyApp()); + +// // Verify that our counter starts at 0. +// expect(find.text('0'), findsOneWidget); +// expect(find.text('1'), findsNothing); + +// // Tap the '+' icon and trigger a frame. +// await tester.tap(find.byIcon(Icons.add)); +// await tester.pump(); + +// // Verify that our counter has incremented. +// expect(find.text('0'), findsNothing); +// expect(find.text('1'), findsOneWidget); +// }); +// } diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/web/icons/Icon-maskable-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..d1ca6f1 --- /dev/null +++ b/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + cssd + + + + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..a6d5072 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "cssd", + "short_name": "cssd", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/windows/.gitignore b/windows/.gitignore new file mode 100644 index 0000000..ec4098a --- /dev/null +++ b/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt new file mode 100644 index 0000000..67ca5d2 --- /dev/null +++ b/windows/CMakeLists.txt @@ -0,0 +1,102 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(cssd LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "cssd") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..3f71e17 --- /dev/null +++ b/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..4f78848 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,14 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); +} diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..88b22e5 --- /dev/null +++ b/windows/flutter/generated_plugins.cmake @@ -0,0 +1,24 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..2041a04 --- /dev/null +++ b/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc new file mode 100644 index 0000000..30c3f56 --- /dev/null +++ b/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "cssd" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "cssd" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "cssd.exe" "\0" + VALUE "ProductName", "cssd" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..c819cb0 --- /dev/null +++ b/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h new file mode 100644 index 0000000..28c2383 --- /dev/null +++ b/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp new file mode 100644 index 0000000..86db046 --- /dev/null +++ b/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"cssd", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/windows/runner/resource.h b/windows/runner/resource.h new file mode 100644 index 0000000..ddc7f3e --- /dev/null +++ b/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..157e871 --- /dev/null +++ b/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp new file mode 100644 index 0000000..fc55c57 --- /dev/null +++ b/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length <= 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h new file mode 100644 index 0000000..3f0e05c --- /dev/null +++ b/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp new file mode 100644 index 0000000..b5ba2a0 --- /dev/null +++ b/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h new file mode 100644 index 0000000..49b847f --- /dev/null +++ b/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_