mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 12:18:56 +03:30
beta commit
This commit is contained in:
@@ -4,7 +4,27 @@
|
|||||||
# This file should be version controlled and should not be manually edited.
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: 9f5ff2306bb3e30b2b98eee79cd231b1336f41f4
|
revision: "ead455963c12b453cdb2358cad34969c76daf180"
|
||||||
channel: stable
|
channel: "stable"
|
||||||
|
|
||||||
project_type: app
|
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'
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {
|
|||||||
|
|
||||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
if (flutterRoot == null) {
|
if (flutterRoot == null) {
|
||||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
}
|
}
|
||||||
|
|
||||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
@@ -26,14 +26,15 @@ apply plugin: 'kotlin-android'
|
|||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 33
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
disable 'InvalidPackage'
|
// disable 'InvalidPackage'
|
||||||
|
baseline(file("lint-baseline.xml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<issues format="6" by="lint 7.3.0" type="baseline" client="gradle" dependencies="false" name="AGP (7.3.0)" variant="fatal" version="7.3.0">
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="ExpiredTargetSdkVersion"
|
||||||
|
message="Google Play requires that apps target API level 31 or higher.
"
|
||||||
|
errorLine1=" targetSdkVersion 28"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle"
|
||||||
|
line="44"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
</issues>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
additional functionality it is fine to subclass or reimplement
|
additional functionality it is fine to subclass or reimplement
|
||||||
FlutterApplication and put your custom class here. -->
|
FlutterApplication and put your custom class here. -->
|
||||||
<application
|
<application
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
android:name="${applicationName}"
|
||||||
android:label="CSSD-DOC"
|
android:label="CSSD-DOC"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.61'
|
ext.kotlin_version = '1.7.10'
|
||||||
repositories {
|
repositories {
|
||||||
// google()
|
// google()
|
||||||
maven {
|
maven {
|
||||||
@@ -10,7 +10,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,6 @@ subprojects {
|
|||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(':app')
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||||
#include "Generated.xcconfig"
|
#include "Generated.xcconfig"
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||||
#include "Generated.xcconfig"
|
#include "Generated.xcconfig"
|
||||||
|
|||||||
+44
@@ -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
|
||||||
@@ -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);
|
||||||
+24
-1
@@ -23,5 +23,28 @@ class Routes {
|
|||||||
static const testVerifyScreen = '/TestVerifyScreen';
|
static const testVerifyScreen = '/TestVerifyScreen';
|
||||||
static const testScanScreen = '/TestScanScreen';
|
static const testScanScreen = '/TestScanScreen';
|
||||||
static const captureImageScreen = '/captureImageScreen';
|
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';
|
||||||
}
|
}
|
||||||
|
|||||||
+90
-5
@@ -1,8 +1,12 @@
|
|||||||
class Url {
|
class Url {
|
||||||
static const String baseUrl = 'https://www.cssd-doc.com/api';
|
static const String baseUrl = 'https://www.cssd-doc.com/api';
|
||||||
|
|
||||||
|
// https://app.cssd-doc.com
|
||||||
|
|
||||||
static const String login = '$baseUrl/login';
|
static const String login = '$baseUrl/login';
|
||||||
|
|
||||||
|
static const String logOut = '$baseUrl/logOut';
|
||||||
|
|
||||||
static const String getInputs = '$baseUrl/GetInputs';
|
static const String getInputs = '$baseUrl/GetInputs';
|
||||||
|
|
||||||
static const String getUserInfo = '$baseUrl/GetInfo';
|
static const String getUserInfo = '$baseUrl/GetInfo';
|
||||||
@@ -15,6 +19,8 @@ class Url {
|
|||||||
|
|
||||||
static const String packageItems = '$baseUrl/GetPackages';
|
static const String packageItems = '$baseUrl/GetPackages';
|
||||||
|
|
||||||
|
static const String itemItems = '$baseUrl/GetItems';
|
||||||
|
|
||||||
static const String requestResetPass = '$baseUrl/password/phone';
|
static const String requestResetPass = '$baseUrl/password/phone';
|
||||||
|
|
||||||
static const String verifyResetPass = '$baseUrl/password/verifyCode';
|
static const String verifyResetPass = '$baseUrl/password/verifyCode';
|
||||||
@@ -23,16 +29,14 @@ class Url {
|
|||||||
|
|
||||||
static const String addImage = '$baseUrl/UploadFile';
|
static const String addImage = '$baseUrl/UploadFile';
|
||||||
|
|
||||||
|
// static String getUserMedicalCenterId(int id) {
|
||||||
|
// return '$baseUrl/users?medical_center_id=$id';
|
||||||
|
// }
|
||||||
|
|
||||||
static String testResults(int id) {
|
static String testResults(int id) {
|
||||||
return '$baseUrl/TestResults?page=$id';
|
return '$baseUrl/TestResults?page=$id';
|
||||||
}
|
}
|
||||||
|
|
||||||
static String testResultVerification(String id,String value) {
|
|
||||||
return '$baseUrl/TestResults/Verify/$id/$value';
|
|
||||||
}
|
|
||||||
|
|
||||||
static String labelResults(int id) {
|
static String labelResults(int id) {
|
||||||
return '$baseUrl/Labels?page=$id';
|
return '$baseUrl/Labels?page=$id';
|
||||||
}
|
}
|
||||||
@@ -41,6 +45,14 @@ class Url {
|
|||||||
return '$baseUrl/Cycles?page=$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) {
|
static String verifyTest(int id) {
|
||||||
return '$baseUrl/TestResults/Verify/$id';
|
return '$baseUrl/TestResults/Verify/$id';
|
||||||
}
|
}
|
||||||
@@ -53,12 +65,53 @@ class Url {
|
|||||||
return '$baseUrl/TestResults/$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 createTestResult = '$baseUrl/TestResults';
|
||||||
|
|
||||||
static const String createCycleResult = '$baseUrl/Cycles';
|
static const String createCycleResult = '$baseUrl/Cycles';
|
||||||
|
|
||||||
static const String createLabelResult = '$baseUrl/Labels';
|
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) {
|
static String updateLabelResult(String id) {
|
||||||
return '$baseUrl/Labels/$id';
|
return '$baseUrl/Labels/$id';
|
||||||
}
|
}
|
||||||
@@ -78,4 +131,36 @@ class Url {
|
|||||||
static String removeTestResult(String id) {
|
static String removeTestResult(String id) {
|
||||||
return '$baseUrl/TestResults/$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';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
class User {
|
class User {
|
||||||
static String _token;
|
static String? _token;
|
||||||
|
|
||||||
static String get token {
|
static String get token {
|
||||||
return 'Bearer ' + User._token;
|
return 'Bearer ' + User._token!;
|
||||||
}
|
}
|
||||||
|
|
||||||
static set token(String token) {
|
static set token(String token) {
|
||||||
|
|||||||
+96
-42
@@ -1,32 +1,61 @@
|
|||||||
|
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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'config/routes.dart';
|
import 'config/routes.dart';
|
||||||
import 'pages/cycle_add_screen.dart';
|
import 'pages/CyclePages/cycle_add_screen.dart';
|
||||||
import 'pages/cycle_detail_screen.dart';
|
import 'pages/CyclePages/cycle_detail_screen.dart';
|
||||||
import 'pages/cycle_filter_screen.dart';
|
import 'pages/CyclePages/cycle_filter_screen.dart';
|
||||||
import 'pages/cycle_result_screen.dart';
|
import 'pages/CyclePages/cycle_result_screen.dart';
|
||||||
import 'pages/cycle_scan_screen.dart';
|
import 'pages/CyclePages/cycle_scan_screen.dart';
|
||||||
import 'pages/forget_pass_screen.dart';
|
import 'pages/LoginRegisterPages/forget_pass_screen.dart';
|
||||||
import 'pages/home_screen.dart';
|
import 'pages/home_screen.dart';
|
||||||
import 'pages/label_add_screen.dart';
|
import 'pages/LabelPages/label_add_screen.dart';
|
||||||
import 'pages/label_detail_screen.dart';
|
import 'pages/LabelPages/label_detail_screen.dart';
|
||||||
import 'pages/label_filter_screen.dart';
|
import 'pages/LabelPages/label_filter_screen.dart';
|
||||||
import 'pages/label_result_screen.dart';
|
import 'pages/LabelPages/label_result_screen.dart';
|
||||||
import 'pages/label_scan_screen.dart';
|
import 'pages/LabelPages/label_scan_screen.dart';
|
||||||
import 'pages/label_update_screen.dart';
|
import 'pages/LoginRegisterPages/login_screen.dart';
|
||||||
import 'pages/login_screen.dart';
|
|
||||||
import 'pages/my_info_screen.dart';
|
import 'pages/my_info_screen.dart';
|
||||||
import 'pages/rePass_screen.dart';
|
import 'pages/LoginRegisterPages/rePass_screen.dart';
|
||||||
import 'pages/test_add_screen.dart';
|
import 'pages/TestPages/test_add_screen.dart';
|
||||||
import 'pages/test_detail_screen.dart';
|
import 'pages/TestPages/test_detail_screen.dart';
|
||||||
import 'pages/test_filter_screen.dart';
|
import 'pages/TestPages/test_filter_screen.dart';
|
||||||
import 'pages/test_result_screen.dart';
|
import 'pages/TestPages/test_result_screen.dart';
|
||||||
import 'pages/test_scan_screen.dart';
|
import 'pages/TestPages/test_scan_screen.dart';
|
||||||
import 'pages/test_verify_screen.dart';
|
import 'pages/TestPages/test_verify_screen.dart';
|
||||||
import 'pages/verify_pass_screen.dart';
|
import 'pages/LoginRegisterPages/verify_pass_screen.dart';
|
||||||
import 'providers/auth.dart';
|
import 'providers/auth.dart';
|
||||||
import 'providers/connectivity.dart';
|
import 'providers/connectivity.dart';
|
||||||
import 'providers/cycles.dart';
|
import 'providers/cycles.dart';
|
||||||
@@ -38,19 +67,12 @@ import 'widgets/Global/splash_screen.dart';
|
|||||||
import 'widgets/TestResultScreens/Add/capture_image.dart';
|
import 'widgets/TestResultScreens/Add/capture_image.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(Phoenix(child: MyApp()));
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
SystemChrome.setPreferredOrientations([
|
SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
DeviceOrientation.portraitDown,
|
DeviceOrientation.portraitDown,
|
||||||
]);
|
]);
|
||||||
// SystemChrome.setEnabledSystemUIOverlays([]);
|
runApp(Phoenix(child: MyApp()));
|
||||||
// SystemChrome.setSystemUIOverlayStyle(
|
|
||||||
// const SystemUiOverlayStyle(
|
|
||||||
// statusBarColor: Colors.red,
|
|
||||||
// systemNavigationBarColor: Colors.red,
|
|
||||||
// systemNavigationBarDividerColor: Colors.blue,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@@ -78,7 +100,22 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
ChangeNotifierProvider.value(
|
ChangeNotifierProvider.value(
|
||||||
value: ConnectivityProvider(),
|
value: ConnectivityProvider(),
|
||||||
)
|
),
|
||||||
|
ChangeNotifierProvider.value(
|
||||||
|
value: PackageProvider(),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider.value(
|
||||||
|
value: ItemProvider(),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider.value(
|
||||||
|
value: MyItemProvider(),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider.value(
|
||||||
|
value: MyPackageProvider(),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider.value(
|
||||||
|
value: UsersProvider(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: Consumer<Auth>(
|
child: Consumer<Auth>(
|
||||||
builder: (ctx, auth, _) => Consumer<ConnectivityProvider>(
|
builder: (ctx, auth, _) => Consumer<ConnectivityProvider>(
|
||||||
@@ -90,16 +127,7 @@ class MyApp extends StatelessWidget {
|
|||||||
title: 'CSSD-DOC',
|
title: 'CSSD-DOC',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primaryColor: Colors.black,
|
primaryColor: Colors.black,
|
||||||
// cursorColor: Colors.black,
|
|
||||||
fontFamily: 'montserrat',
|
fontFamily: 'montserrat',
|
||||||
// primaryTextTheme: TextTheme(
|
|
||||||
// body1: TextStyle(
|
|
||||||
// color: Colors.black,
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// textTheme: TextTheme(
|
|
||||||
// body2: TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
home: auth.isAuth
|
home: auth.isAuth
|
||||||
? HomePage()
|
? HomePage()
|
||||||
@@ -119,7 +147,6 @@ class MyApp extends StatelessWidget {
|
|||||||
Routes.testResultScreen: (ctx) => TestResultScreen(),
|
Routes.testResultScreen: (ctx) => TestResultScreen(),
|
||||||
Routes.testDetailsScreen: (ctx) => TestDetailsScreen(),
|
Routes.testDetailsScreen: (ctx) => TestDetailsScreen(),
|
||||||
Routes.testFilterScreen: (ctx) => TestFilterScreen(),
|
Routes.testFilterScreen: (ctx) => TestFilterScreen(),
|
||||||
// Routes.register: (ctx) => Register(),
|
|
||||||
Routes.testResultAddScreen: (ctx) => TestResultAddScreen(),
|
Routes.testResultAddScreen: (ctx) => TestResultAddScreen(),
|
||||||
Routes.labelDetailScreen: (ctx) => LabelDetailScreen(),
|
Routes.labelDetailScreen: (ctx) => LabelDetailScreen(),
|
||||||
Routes.cycleDetailScreen: (ctx) => CycleDetailScreen(),
|
Routes.cycleDetailScreen: (ctx) => CycleDetailScreen(),
|
||||||
@@ -127,9 +154,9 @@ class MyApp extends StatelessWidget {
|
|||||||
Routes.cycleFilterScreen: (ctx) => CycleFilterScreen(),
|
Routes.cycleFilterScreen: (ctx) => CycleFilterScreen(),
|
||||||
Routes.cycleScanScreen: (ctx) => CycleScanScreen(),
|
Routes.cycleScanScreen: (ctx) => CycleScanScreen(),
|
||||||
Routes.labelScanScreen: (ctx) => LabelScanScreen(),
|
Routes.labelScanScreen: (ctx) => LabelScanScreen(),
|
||||||
|
Routes.labelUpdateScreen: (ctx) => LabelUpdateScreen(),
|
||||||
Routes.cycleAddScreen: (ctx) => CycleAddScreen(),
|
Routes.cycleAddScreen: (ctx) => CycleAddScreen(),
|
||||||
Routes.labelAddScreen: (ctx) => LabelAddScreen(),
|
Routes.labelAddScreen: (ctx) => LabelAddScreen(),
|
||||||
Routes.labelUpdateScreen: (ctx) => LabelUpdateScreen(),
|
|
||||||
Routes.labelResultScreen: (ctx) => LabelResultScreen(),
|
Routes.labelResultScreen: (ctx) => LabelResultScreen(),
|
||||||
Routes.cycleResultScreen: (ctx) => CycleResultScreen(),
|
Routes.cycleResultScreen: (ctx) => CycleResultScreen(),
|
||||||
Routes.testVerifyScreen: (ctx) => TestVerifyScreen(),
|
Routes.testVerifyScreen: (ctx) => TestVerifyScreen(),
|
||||||
@@ -137,6 +164,33 @@ class MyApp extends StatelessWidget {
|
|||||||
Routes.sendCodeScreen: (ctx) => VerifyPassScreen(),
|
Routes.sendCodeScreen: (ctx) => VerifyPassScreen(),
|
||||||
Routes.rePassScreen: (ctx) => RePassScreen(),
|
Routes.rePassScreen: (ctx) => RePassScreen(),
|
||||||
Routes.captureImageScreen: (ctx) => CaptureImage(),
|
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(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
enum ConnectionStatus{
|
|
||||||
Wifi,
|
|
||||||
Calcular,
|
|
||||||
Offline
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,25 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
class CycleResultObject {
|
class CycleResultObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final List<String> label;
|
final List<String> label;
|
||||||
final String createdAt;
|
final String createdAt;
|
||||||
|
|
||||||
CycleResultObject({
|
CycleResultObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.label,
|
required this.label,
|
||||||
@required this.createdAt,
|
required this.createdAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [id, label, createdAt];
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CycleDetailObject {
|
class CycleDetailObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String description;
|
final String description;
|
||||||
final String createDate;
|
final String createDate;
|
||||||
@@ -24,18 +31,35 @@ class CycleDetailObject {
|
|||||||
final List<String> labels;
|
final List<String> labels;
|
||||||
|
|
||||||
CycleDetailObject({
|
CycleDetailObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.description,
|
required this.description,
|
||||||
@required this.createDate,
|
required this.createDate,
|
||||||
@required this.hospitalName,
|
required this.hospitalName,
|
||||||
@required this.date,
|
required this.date,
|
||||||
@required this.sterileId,
|
required this.sterileId,
|
||||||
@required this.cycleNumber,
|
required this.cycleNumber,
|
||||||
@required this.labels,
|
required this.labels,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
description,
|
||||||
|
createDate,
|
||||||
|
hospitalName,
|
||||||
|
date,
|
||||||
|
sterileId,
|
||||||
|
cycleNumber,
|
||||||
|
labels,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class CycleFilterObject {
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CycleFilterObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String cycleNumber;
|
final String cycleNumber;
|
||||||
final String sterilizerId;
|
final String sterilizerId;
|
||||||
@@ -43,10 +67,24 @@ class CycleFilterObject {
|
|||||||
final String date;
|
final String date;
|
||||||
|
|
||||||
CycleFilterObject({
|
CycleFilterObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.cycleNumber,
|
required this.cycleNumber,
|
||||||
@required this.sterilizerId,
|
required this.sterilizerId,
|
||||||
@required this.hospital,
|
required this.hospital,
|
||||||
@required this.date,
|
required this.date,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
cycleNumber,
|
||||||
|
sterilizerId,
|
||||||
|
hospital,
|
||||||
|
date,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<Object> 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<Object> 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<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
udi,
|
||||||
|
hospital,
|
||||||
|
size,
|
||||||
|
specific,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
@@ -1,20 +1,27 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
class LabelResultObject {
|
class LabelResultObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String package;
|
final String package;
|
||||||
final String packageId;
|
final String packageId;
|
||||||
final String expireDate;
|
final String expireDate;
|
||||||
|
|
||||||
LabelResultObject({
|
LabelResultObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.package,
|
required this.package,
|
||||||
@required this.packageId,
|
required this.packageId,
|
||||||
@required this.expireDate,
|
required this.expireDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [id, package, packageId, expireDate];
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LabelDetailsObject {
|
class LabelDetailsObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String package;
|
final String package;
|
||||||
final String packageId;
|
final String packageId;
|
||||||
@@ -28,29 +35,54 @@ class LabelDetailsObject {
|
|||||||
final String lotNumber;
|
final String lotNumber;
|
||||||
|
|
||||||
LabelDetailsObject({
|
LabelDetailsObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.package,
|
required this.package,
|
||||||
@required this.packageId,
|
required this.packageId,
|
||||||
@required this.hospitalName,
|
required this.hospitalName,
|
||||||
@required this.createDate,
|
required this.createDate,
|
||||||
@required this.expireDate,
|
required this.expireDate,
|
||||||
@required this.sterileDate,
|
required this.sterileDate,
|
||||||
@required this.sterileId,
|
required this.sterileId,
|
||||||
@required this.cycleNumber,
|
required this.cycleNumber,
|
||||||
@required this.lotNumber,
|
required this.lotNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
package,
|
||||||
|
packageId,
|
||||||
|
hospitalName,
|
||||||
|
createDate,
|
||||||
|
expireDate,
|
||||||
|
sterileDate,
|
||||||
|
sterileId,
|
||||||
|
cycleNumber,
|
||||||
|
lotNumber,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class LabelFilterObject {
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LabelFilterObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String cycleNumber;
|
final String cycleNumber;
|
||||||
final String sterilizerId;
|
final String sterilizerId;
|
||||||
final String hospital;
|
final String hospital;
|
||||||
|
|
||||||
LabelFilterObject({
|
LabelFilterObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.cycleNumber,
|
required this.cycleNumber,
|
||||||
@required this.sterilizerId,
|
required this.sterilizerId,
|
||||||
@required this.hospital,
|
required this.hospital,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [id, cycleNumber, sterilizerId, hospital];
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<Object> 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<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
udi,
|
||||||
|
size,
|
||||||
|
specific,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
@@ -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<Object> 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<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
udi,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
@@ -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<Object> 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<String> 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<Object> 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<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
hospital,
|
||||||
|
udi,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
class TestResultObject {
|
class TestResultObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
@@ -10,17 +11,33 @@ class TestResultObject {
|
|||||||
final String verified;
|
final String verified;
|
||||||
|
|
||||||
TestResultObject({
|
TestResultObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.name,
|
required this.name,
|
||||||
@required this.deviceId,
|
required this.deviceId,
|
||||||
@required this.result,
|
required this.result,
|
||||||
@required this.date,
|
required this.date,
|
||||||
@required this.hospital,
|
required this.hospital,
|
||||||
@required this.verified,
|
required this.verified,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
deviceId,
|
||||||
|
result,
|
||||||
|
date,
|
||||||
|
hospital,
|
||||||
|
verified,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestResultFilterObject {
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestResultFilterObject extends Equatable {
|
||||||
final String id;
|
final String id;
|
||||||
final String labelID;
|
final String labelID;
|
||||||
final String userName;
|
final String userName;
|
||||||
@@ -30,12 +47,28 @@ class TestResultFilterObject {
|
|||||||
final String uDate;
|
final String uDate;
|
||||||
|
|
||||||
TestResultFilterObject({
|
TestResultFilterObject({
|
||||||
@required this.id,
|
required this.id,
|
||||||
@required this.labelID,
|
required this.labelID,
|
||||||
@required this.userName,
|
required this.userName,
|
||||||
@required this.hospital,
|
required this.hospital,
|
||||||
@required this.testType,
|
required this.testType,
|
||||||
@required this.fDate,
|
required this.fDate,
|
||||||
@required this.uDate,
|
required this.uDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props {
|
||||||
|
return [
|
||||||
|
id,
|
||||||
|
labelID,
|
||||||
|
userName,
|
||||||
|
hospital,
|
||||||
|
testType,
|
||||||
|
fDate,
|
||||||
|
uDate,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<Object?> get props => [
|
||||||
|
userName,
|
||||||
|
phoneNumber,
|
||||||
|
id,
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get stringify => true;
|
||||||
|
}
|
||||||
@@ -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<CycleAddScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
bool isInit = true;
|
||||||
|
CycleFilterObject? filters;
|
||||||
|
|
||||||
|
List<TextEditingController> 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<CyclesProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<CyclesProvider>(
|
||||||
|
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<CyclesProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).labelValues,
|
||||||
|
cycleNumberCTRL: cycleNumberCTRL,
|
||||||
|
dateValue: dateCTRL.text,
|
||||||
|
descriptionCTRL: descriptionCTRL,
|
||||||
|
striizerIdCTRL: striizerIdCTRL,
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 100,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ConnectionErrorBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-10
@@ -1,15 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../models/cycles_models.dart';
|
import '../../models/cycles_models.dart';
|
||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../providers/cycles.dart';
|
import '../../providers/cycles.dart';
|
||||||
import '../widgets/CycleScreens/Details/datas_box.dart';
|
import '../../widgets/CycleScreens/Details/datas_box.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
|
|
||||||
class CycleDetailScreen extends StatefulWidget {
|
class CycleDetailScreen extends StatefulWidget {
|
||||||
// static const route = '/CycleDetailScreen';
|
// static const route = '/CycleDetailScreen';
|
||||||
final String testResultId;
|
final String? testResultId;
|
||||||
|
|
||||||
CycleDetailScreen({this.testResultId});
|
CycleDetailScreen({this.testResultId});
|
||||||
|
|
||||||
@@ -20,11 +20,11 @@ class CycleDetailScreen extends StatefulWidget {
|
|||||||
class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
||||||
bool isInit = true;
|
bool isInit = true;
|
||||||
bool isEmpty = false;
|
bool isEmpty = false;
|
||||||
CycleDetailObject datas;
|
CycleDetailObject? datas;
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() async {
|
void didChangeDependencies() async {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
var _id = ModalRoute.of(context).settings.arguments;
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
await Provider.of<CyclesProvider>(context, listen: false)
|
await Provider.of<CyclesProvider>(context, listen: false)
|
||||||
.showCycleResult(_id.toString())
|
.showCycleResult(_id.toString())
|
||||||
.then(
|
.then(
|
||||||
@@ -55,6 +55,7 @@ class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Cycles'),
|
title: Text('Cycles'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_left,
|
Icons.keyboard_arrow_left,
|
||||||
@@ -67,14 +68,16 @@ class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
|||||||
return connection.conStatus != 'offline'
|
return connection.conStatus != 'offline'
|
||||||
? isInit
|
? isInit
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: isEmpty
|
: isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text('This Cycle doesnt exists!'),
|
child: Text('This Cycle doesnt exists!'),
|
||||||
)
|
)
|
||||||
: CycleDetailsDataBox(
|
: CycleDetailsDataBox(
|
||||||
datas: datas,
|
datas: datas!,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
)
|
)
|
||||||
: ConnectionErrorBox();
|
: ConnectionErrorBox();
|
||||||
@@ -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<CycleFilterScreen> {
|
||||||
|
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<Map<String, String>> hospitalVals = [];
|
||||||
|
// String curhospitalVal;
|
||||||
|
bool isInit = true;
|
||||||
|
CycleFilterObject? filters;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
filters = Provider.of<CyclesProvider>(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<CyclesProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<CycleResultScreen> {
|
||||||
|
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<CyclesProvider>(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<CyclesProvider>(
|
||||||
|
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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'Cycles',
|
||||||
|
push: Routes.cycleFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<CyclesProvider>(builder: (ctx, cycle, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<CyclesProvider>(context,
|
||||||
|
listen: false)
|
||||||
|
.search(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<CyclesProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _CycleScanScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CycleScanScreenState extends State<CycleScanScreen> {
|
||||||
|
String testCode = "";
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<CycleUpdateScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
// List<Map<String, String>> labelVals = [];
|
||||||
|
// List<String> 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<CyclesProvider>(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<CyclesProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<CyclesProvider>(
|
||||||
|
// 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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemAddScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
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<ItemProvider>(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<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemDetailScreen> {
|
||||||
|
bool isInit = true;
|
||||||
|
bool isEmpty = false;
|
||||||
|
ItemDetailObject? datas;
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemFilterScreen> {
|
||||||
|
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<Map<String, String>> hospitalVals = [];
|
||||||
|
bool isInit = true;
|
||||||
|
ItemFilterObject? filters;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
filters = Provider.of<ItemProvider>(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<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? isInit
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemResultScreen> {
|
||||||
|
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<ItemProvider>(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<ItemProvider>(
|
||||||
|
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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'Items',
|
||||||
|
push: Routes.itemFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<ItemProvider>(
|
||||||
|
builder: (ctx, item, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<ItemProvider>(context, listen: false)
|
||||||
|
.search(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<ItemProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _ItemScanScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ItemScanScreenState extends State<ItemScanScreen> {
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemUpdateScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
bool isEmpty = false;
|
||||||
|
bool isInit = true;
|
||||||
|
ItemDetailObject? datas;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<ItemProvider>(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<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<LabelAddScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
List<Map<String, String>> packageVals = [];
|
||||||
|
List<String> packageValue = [];
|
||||||
|
bool isInit = true;
|
||||||
|
|
||||||
|
List<TextEditingController> 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<LabelsProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<LabelsProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-10
@@ -1,8 +1,8 @@
|
|||||||
import '../models/label_models.dart';
|
import '../../models/label_models.dart';
|
||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../providers/labels.dart';
|
import '../../providers/labels.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
import '../widgets/LabelScreens/Detail/datas_box.dart';
|
import '../../widgets/LabelScreens/Detail/datas_box.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
@@ -19,11 +19,11 @@ class LabelDetailScreen extends StatefulWidget {
|
|||||||
class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
||||||
bool isEmpty = false;
|
bool isEmpty = false;
|
||||||
bool isInit = true;
|
bool isInit = true;
|
||||||
LabelDetailsObject datas;
|
LabelDetailsObject? datas;
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() async {
|
void didChangeDependencies() async {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
var _id = ModalRoute.of(context).settings.arguments;
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
await Provider.of<LabelsProvider>(context, listen: false)
|
await Provider.of<LabelsProvider>(context, listen: false)
|
||||||
.showLabelResult(_id.toString())
|
.showLabelResult(_id.toString())
|
||||||
.then(
|
.then(
|
||||||
@@ -55,6 +55,7 @@ class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Labels'),
|
title: Text('Labels'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_left,
|
Icons.keyboard_arrow_left,
|
||||||
@@ -67,14 +68,16 @@ class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
|||||||
return connection.conStatus != 'offline'
|
return connection.conStatus != 'offline'
|
||||||
? isInit
|
? isInit
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: isEmpty
|
: isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text('This Lable doesnt exists!'),
|
child: Text('This Label dos\'nt exists!'),
|
||||||
)
|
)
|
||||||
: LabelDetailsDataBox(
|
: LabelDetailsDataBox(
|
||||||
datas: datas,
|
datas: datas!,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
)
|
)
|
||||||
: ConnectionErrorBox();
|
: ConnectionErrorBox();
|
||||||
@@ -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<LabelFilterScreen> {
|
||||||
|
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<Map<String, String>> hospitalVals = [];
|
||||||
|
bool isInit = true;
|
||||||
|
LabelFilterObject? filters;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
filters = Provider.of<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? isInit
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<LabelResultScreen> {
|
||||||
|
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<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
PageHeader(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
label: 'Labels',
|
||||||
|
route: Routes.labelFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<LabelsProvider>(
|
||||||
|
builder: (context, label, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<LabelsProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _LabelScanScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LabelScanScreenState extends State<LabelScanScreen> {
|
||||||
|
String testCode = "";
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<LabelUpdateScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
List<Map<String, String>> packageVals = [];
|
||||||
|
List<String> 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<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-20
@@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../config/routes.dart';
|
import '../../config/routes.dart';
|
||||||
import '../providers/auth.dart';
|
import '../../providers/auth.dart';
|
||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
|
|
||||||
class ForgetPassScreen extends StatefulWidget {
|
class ForgetPassScreen extends StatefulWidget {
|
||||||
// static const route = '/HomeScreen';
|
// static const route = '/HomeScreen';
|
||||||
@@ -50,10 +50,10 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _requestCode() async {
|
void _requestCode() async {
|
||||||
if (!_form.currentState.validate()) {
|
if (!_form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_form.currentState.save();
|
_form.currentState!.save();
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
@@ -95,12 +95,15 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text('CSSD'),
|
title: Text('CSSD'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
),
|
),
|
||||||
body: Selector<ConnectivityProvider, String>(
|
body: Selector<ConnectivityProvider, String>(
|
||||||
builder: (ctx, value, _) => value != 'offline'
|
builder: (ctx, value, _) => value != 'offline'
|
||||||
? _isLoading
|
? _isLoading
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Form(
|
: Form(
|
||||||
key: _form,
|
key: _form,
|
||||||
@@ -110,7 +113,7 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(vertical: 20),
|
padding: EdgeInsets.symmetric(vertical: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
'FORGET PASSWORD',
|
'Forget Password',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@@ -122,7 +125,7 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Cell number is required.';
|
return 'Cell number is required.';
|
||||||
}
|
}
|
||||||
RegExp regExp =
|
RegExp regExp =
|
||||||
@@ -154,7 +157,7 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
keyboardType: TextInputType.phone,
|
keyboardType: TextInputType.phone,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
onSaved: (value) {
|
onSaved: (value) {
|
||||||
cellNumberController.text = value;
|
cellNumberController.text = value!;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 40),
|
SizedBox(height: 40),
|
||||||
@@ -163,25 +166,20 @@ class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => _requestCode(),
|
onTap: () => _requestCode(),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 40 * _deviceBlockSize,
|
width: 88 * _deviceBlockSize,
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.all(10),
|
||||||
horizontal: 5 * _deviceBlockSize,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
// margin:
|
|
||||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Colors.black,
|
||||||
colors: [Colors.blue, Colors.green],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
),
|
),
|
||||||
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Request Code',
|
'Request Code',
|
||||||
style: TextStyle(color: Colors.white),
|
style: TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _LoginScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginScreenState extends State<LoginScreen> {
|
||||||
|
final _passwordFocusNode = FocusNode();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
bool _isLoading = false;
|
||||||
|
final cellNumberController = TextEditingController();
|
||||||
|
final passwordController = TextEditingController();
|
||||||
|
|
||||||
|
bool _hidePass = true;
|
||||||
|
Map<String, dynamic> map = Map<String, dynamic>();
|
||||||
|
|
||||||
|
@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: <Widget>[
|
||||||
|
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<Auth>(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<ConnectivityProvider, String>(
|
||||||
|
builder: (ctx, value, _) => value != 'offline'
|
||||||
|
? _isLoading
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Form(
|
||||||
|
key: _form,
|
||||||
|
child: ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../providers/auth.dart';
|
import '../../providers/auth.dart';
|
||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
|
|
||||||
class RePassScreen extends StatefulWidget {
|
class RePassScreen extends StatefulWidget {
|
||||||
// static const route = '/HomeScreen';
|
// static const route = '/HomeScreen';
|
||||||
@@ -31,7 +31,7 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
token += ModalRoute.of(context).settings.arguments;
|
token += ModalRoute.of(context)!.settings.arguments.toString();
|
||||||
isInit = false;
|
isInit = false;
|
||||||
}
|
}
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
@@ -55,10 +55,10 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _sendRePass() async {
|
void _sendRePass() async {
|
||||||
if (!_form.currentState.validate()) {
|
if (!_form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_form.currentState.save();
|
_form.currentState!.save();
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
@@ -84,12 +84,15 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text('CSSD'),
|
title: Text('CSSD'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
),
|
),
|
||||||
body: Selector<ConnectivityProvider, String>(
|
body: Selector<ConnectivityProvider, String>(
|
||||||
builder: (ctx, value, _) => value != 'offline'
|
builder: (ctx, value, _) => value != 'offline'
|
||||||
? _isLoading
|
? _isLoading
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Form(
|
: Form(
|
||||||
key: _form,
|
key: _form,
|
||||||
@@ -111,7 +114,7 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Password is required.';
|
return 'Password is required.';
|
||||||
}
|
}
|
||||||
if (value.length < 8) {
|
if (value.length < 8) {
|
||||||
@@ -158,7 +161,7 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.length < 8) {
|
if (value!.length < 8) {
|
||||||
return 'Password at least is 8 characters.';
|
return 'Password at least is 8 characters.';
|
||||||
}
|
}
|
||||||
if (value != passwordController.text) {
|
if (value != passwordController.text) {
|
||||||
@@ -206,17 +209,10 @@ class _RePassScreenState extends State<RePassScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => _sendRePass(),
|
onTap: () => _sendRePass(),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 40 * _deviceBlockSize,
|
width: 88 * _deviceBlockSize,
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.all(10),
|
||||||
horizontal: 5 * _deviceBlockSize,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
// margin:
|
|
||||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Colors.black,
|
||||||
colors: [Colors.blue, Colors.green],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -18,7 +18,7 @@ class _RegisterState extends State<Register> {
|
|||||||
bool _hidePass = true;
|
bool _hidePass = true;
|
||||||
Map<String, dynamic> map = Map<String, dynamic>();
|
Map<String, dynamic> map = Map<String, dynamic>();
|
||||||
final List<String> hospitalVals = ['Shahid Beheshti', 'None'];
|
final List<String> hospitalVals = ['Shahid Beheshti', 'None'];
|
||||||
String curhospitalVal;
|
String? curhospitalVal;
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
cellNumberController.text = map['cellNumber'];
|
cellNumberController.text = map['cellNumber'];
|
||||||
@@ -51,10 +51,10 @@ class _RegisterState extends State<Register> {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
void _register() async {
|
void _register() async {
|
||||||
if (!_form.currentState.validate()) {
|
if (!_form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_form.currentState.save();
|
_form.currentState!.save();
|
||||||
// setState(() {
|
// setState(() {
|
||||||
// _isLoading = true;
|
// _isLoading = true;
|
||||||
// });
|
// });
|
||||||
@@ -99,7 +99,9 @@ class _RegisterState extends State<Register> {
|
|||||||
),
|
),
|
||||||
body: _isLoading
|
body: _isLoading
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Form(
|
: Form(
|
||||||
key: _form,
|
key: _form,
|
||||||
@@ -120,7 +122,7 @@ class _RegisterState extends State<Register> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Cell number is required.';
|
return 'Cell number is required.';
|
||||||
}
|
}
|
||||||
RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
|
RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
|
||||||
@@ -156,7 +158,7 @@ class _RegisterState extends State<Register> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Password is required.';
|
return 'Password is required.';
|
||||||
}
|
}
|
||||||
if (value.length < 8) {
|
if (value.length < 8) {
|
||||||
@@ -199,7 +201,7 @@ class _RegisterState extends State<Register> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Full Name is required.';
|
return 'Full Name is required.';
|
||||||
}
|
}
|
||||||
// RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
|
// RegExp regExp = RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$');
|
||||||
@@ -254,7 +256,7 @@ class _RegisterState extends State<Register> {
|
|||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 4),
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
curhospitalVal,
|
curhospitalVal!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
+15
-17
@@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../config/routes.dart';
|
import '../../config/routes.dart';
|
||||||
import '../providers/auth.dart';
|
import '../../providers/auth.dart';
|
||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
|
|
||||||
class VerifyPassScreen extends StatefulWidget {
|
class VerifyPassScreen extends StatefulWidget {
|
||||||
// static const route = '/HomeScreen';
|
// static const route = '/HomeScreen';
|
||||||
@@ -51,10 +51,10 @@ class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _sendCode() async {
|
void _sendCode() async {
|
||||||
if (!_form.currentState.validate()) {
|
if (!_form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_form.currentState.save();
|
_form.currentState!.save();
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
@@ -91,12 +91,15 @@ class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text('CSSD'),
|
title: Text('CSSD'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
),
|
),
|
||||||
body: Selector<ConnectivityProvider, String>(
|
body: Selector<ConnectivityProvider, String>(
|
||||||
builder: (ctx, value, _) => value != 'offline'
|
builder: (ctx, value, _) => value != 'offline'
|
||||||
? _isLoading
|
? _isLoading
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Form(
|
: Form(
|
||||||
key: _form,
|
key: _form,
|
||||||
@@ -118,7 +121,7 @@ class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return 'Code is required.';
|
return 'Code is required.';
|
||||||
}
|
}
|
||||||
if (value.length != 6) {
|
if (value.length != 6) {
|
||||||
@@ -150,7 +153,7 @@ class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
|||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
onSaved: (value) {
|
onSaved: (value) {
|
||||||
codeCTRL.text = value;
|
codeCTRL.text = value!;
|
||||||
},
|
},
|
||||||
maxLength: 6,
|
maxLength: 6,
|
||||||
),
|
),
|
||||||
@@ -160,17 +163,12 @@ class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => _sendCode(),
|
onTap: () => _sendCode(),
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 40 * _deviceBlockSize,
|
width: 88 * _deviceBlockSize,
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.all(10),
|
||||||
horizontal: 5 * _deviceBlockSize,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
// margin:
|
// margin:
|
||||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Colors.black,
|
||||||
colors: [Colors.blue, Colors.green],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -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<MyItemsMineScreen> createState() => _MyItemsMineScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyItemsMineScreenState extends State<MyItemsMineScreen> {
|
||||||
|
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<MyItemProvider>(context);
|
||||||
|
final userData = Provider.of<Auth>(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<MyItemProvider>(
|
||||||
|
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<MyItemProvider>(
|
||||||
|
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<Auth>(context, listen: false).user;
|
||||||
|
return Consumer<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'My Items',
|
||||||
|
push: Routes.myItemsFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<MyItemProvider>(builder: (ctx, item, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<MyItemProvider>(context, listen: false)
|
||||||
|
.searchMyItems(value);
|
||||||
|
} else {
|
||||||
|
Provider.of<MyItemProvider>(context, listen: false)
|
||||||
|
.searchHospitalItems(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<MyItemProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyItemsRequestsScreen> createState() => _MyItemsRequestsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyItemsRequestsScreenState extends State<MyItemsRequestsScreen> {
|
||||||
|
bool _isInit = true;
|
||||||
|
ScrollController? sc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (_isInit) {
|
||||||
|
var itemResults = Provider.of<MyItemProvider>(context);
|
||||||
|
final userData = Provider.of<Auth>(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<MyItemProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
);
|
||||||
|
itemResults.getMyItemRequests();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
itemResults.getHospitalItemRequests().then(
|
||||||
|
(_) {
|
||||||
|
itemResults.resetLoading();
|
||||||
|
sc?.addListener(
|
||||||
|
() {
|
||||||
|
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||||
|
var itemResults = Provider.of<MyItemProvider>(
|
||||||
|
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<Auth>(context, listen: false).user;
|
||||||
|
return Consumer<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'My Requests',
|
||||||
|
hasFilterObject: false,
|
||||||
|
push: Routes.myItemsFilterScreen,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<MyItemProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyItemsResultScreen> createState() => _MyItemsResultScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyItemsResultScreenState extends State<MyItemsResultScreen>
|
||||||
|
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(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyItemsDetailScreen> {
|
||||||
|
bool isInit = true;
|
||||||
|
bool isEmpty = false;
|
||||||
|
ItemDetailObject? datas;
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyItemsFilterScreen> {
|
||||||
|
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<ItemProvider>(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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? isInit
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyItemsHistoryScreen> {
|
||||||
|
bool _isInit = true;
|
||||||
|
ScrollController? sc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
sc = new ScrollController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (_isInit) {
|
||||||
|
var userResults = Provider.of<UsersProvider>(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<UsersProvider>(
|
||||||
|
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<Auth>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<UsersProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ItemsTransferScreen> createState() => _ItemsTransferScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ItemsTransferScreenState extends State<ItemsTransferScreen> {
|
||||||
|
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<UsersProvider>(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<UsersProvider>(
|
||||||
|
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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<UsersProvider>(context, listen: false)
|
||||||
|
.searchUsers(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<UsersProvider>(
|
||||||
|
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<UsersProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).selectUser(index);
|
||||||
|
print(userId);
|
||||||
|
Provider.of<UsersProvider>(
|
||||||
|
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<MyItemProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).transferItems(
|
||||||
|
ItemsTransferScreen().items!.id,
|
||||||
|
Provider.of<UsersProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
Text(
|
||||||
|
'User: ',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: 3 * _deviceBlockSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
ItemsTransferScreen().items!.userName,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 3 * _deviceBlockSize,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackagesMineScreen> createState() => _MyPackagesMineScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyPackagesMineScreenState extends State<MyPackagesMineScreen> {
|
||||||
|
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<MyPackageProvider>(context);
|
||||||
|
final userData = Provider.of<Auth>(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<MyPackageProvider>(
|
||||||
|
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<MyPackageProvider>(
|
||||||
|
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<Auth>(context, listen: false).user;
|
||||||
|
return Consumer<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'My Packages',
|
||||||
|
push: Routes.myPackagesFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<MyPackageProvider>(
|
||||||
|
builder: (ctx, package, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<MyPackageProvider>(context, listen: false)
|
||||||
|
.searchMyPackages(value);
|
||||||
|
} else {
|
||||||
|
Provider.of<MyPackageProvider>(context, listen: false)
|
||||||
|
.searchHospitalPackages(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<MyPackageProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackagesRequestsScreen> createState() =>
|
||||||
|
_MyPackagesRequestsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyPackagesRequestsScreenState extends State<MyPackagesRequestsScreen> {
|
||||||
|
bool _isInit = true;
|
||||||
|
ScrollController? sc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (_isInit) {
|
||||||
|
var packageResults = Provider.of<MyPackageProvider>(context);
|
||||||
|
final userData = Provider.of<Auth>(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<MyPackageProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
);
|
||||||
|
packageResults.getMyPackageRequests();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
packageResults.getHospitalPackageRequests().then(
|
||||||
|
(_) {
|
||||||
|
packageResults.resetLoading();
|
||||||
|
sc?.addListener(
|
||||||
|
() {
|
||||||
|
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||||
|
var packageResults = Provider.of<MyPackageProvider>(
|
||||||
|
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<Auth>(context, listen: false).user;
|
||||||
|
return Consumer<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'My Requests',
|
||||||
|
hasFilterObject: false,
|
||||||
|
push: Routes.myPackagesFilterScreen,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<MyPackageProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackagesResultScreen> createState() => _MyPackagesResultScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyPackagesResultScreenState extends State<MyPackagesResultScreen>
|
||||||
|
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(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackagesDetailScreen> {
|
||||||
|
bool isInit = true;
|
||||||
|
bool isEmpty = false;
|
||||||
|
PackageDetailObject? datas;
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackageFilterScreen> {
|
||||||
|
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<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackagesHistoryScreen> {
|
||||||
|
bool _isInit = true;
|
||||||
|
ScrollController? sc;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
sc = new ScrollController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (_isInit) {
|
||||||
|
var userResults = Provider.of<UsersProvider>(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<UsersProvider>(
|
||||||
|
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<Auth>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<UsersProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageTransferScreen> createState() => _PackageTransferScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PackageTransferScreenState extends State<PackageTransferScreen> {
|
||||||
|
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<UsersProvider>(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<UsersProvider>(
|
||||||
|
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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<UsersProvider>(context, listen: false)
|
||||||
|
.searchUsers(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<UsersProvider>(
|
||||||
|
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<UsersProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).selectUser(index);
|
||||||
|
print(userId);
|
||||||
|
Provider.of<UsersProvider>(
|
||||||
|
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<MyPackageProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).transferPackage(
|
||||||
|
PackageTransferScreen()
|
||||||
|
.packages!
|
||||||
|
.id,
|
||||||
|
Provider.of<UsersProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
// Text(
|
||||||
|
// 'User: ',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.grey,
|
||||||
|
// fontSize: 3 * _deviceBlockSize,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// Text(
|
||||||
|
// PackageTransferScreen().packages!.userName,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 3 * _deviceBlockSize,
|
||||||
|
// fontWeight: FontWeight.w700,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageAddScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
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<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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<PackageProvider>(
|
||||||
|
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<PackageProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).itemValues,
|
||||||
|
nameCTRL: nameCTRL,
|
||||||
|
udiCTRL: udiCTRL,
|
||||||
|
dateValue: dateCTRL.text,
|
||||||
|
descriptionCTRL: descriptionCTRL,
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 100,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ConnectionErrorBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageDetailScreen> {
|
||||||
|
bool isInit = true;
|
||||||
|
bool isEmpty = false;
|
||||||
|
PackageDetailObject? datas;
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageFilterScreen> {
|
||||||
|
final _nameFocusNode = FocusNode();
|
||||||
|
final _udiFocusNode = FocusNode();
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
TextEditingController hospitalCTRL = new TextEditingController();
|
||||||
|
TextEditingController nameCTRL = new TextEditingController();
|
||||||
|
TextEditingController udiCTRL = new TextEditingController();
|
||||||
|
|
||||||
|
List<Map<String, String>> hospitalVals = [];
|
||||||
|
bool isInit = true;
|
||||||
|
PackageFilterObject? filters;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
filters = Provider.of<PackageProvider>(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<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageResultScreen> {
|
||||||
|
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<PackageProvider>(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<PackageProvider>(
|
||||||
|
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<ConnectivityProvider>(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: <Widget>[
|
||||||
|
ResultBanner(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
text: 'Packages',
|
||||||
|
push: Routes.packageFilterScreen,
|
||||||
|
),
|
||||||
|
Consumer<PackageProvider>(
|
||||||
|
builder: (ctx, package, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<PackageProvider>(context, listen: false)
|
||||||
|
.search(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Consumer<PackageProvider>(
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _PackageScanScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PackageScanScreenState extends State<PackageScanScreen> {
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<PackageUpdateScreen> {
|
||||||
|
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<FormState>();
|
||||||
|
|
||||||
|
bool isEmpty = false;
|
||||||
|
bool isInit = true;
|
||||||
|
PackageDetailObject? datas;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() async {
|
||||||
|
if (isInit) {
|
||||||
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
|
await Provider.of<PackageProvider>(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<PackageProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _TestResultAddScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TestResultAddScreenState extends State<TestResultAddScreen> {
|
||||||
|
TextEditingController testTypeCTRL = new TextEditingController();
|
||||||
|
final List<String> testTypeVals = [];
|
||||||
|
|
||||||
|
TextEditingController testCodeCTRL = new TextEditingController();
|
||||||
|
bool isInit = true;
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (isInit) {
|
||||||
|
var testResultProviderObject =
|
||||||
|
Provider.of<TestResultsProvider>(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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? isInit
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: 70 * _deviceBlockSize,
|
||||||
|
child: TestResultAddSelectorBox(
|
||||||
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
dataCTRL: testTypeCTRL,
|
||||||
|
dataVals: testTypeVals,
|
||||||
|
label: 'Choose a Test Type',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
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<TestResultsProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).testCode = testCodeCTRL.text;
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
Routes.formTestResultScreen,
|
||||||
|
arguments: testCodeCTRL.text,
|
||||||
|
);
|
||||||
|
} else if (testTypeCTRL.text !=
|
||||||
|
'') {
|
||||||
|
Provider.of<TestResultsProvider>(
|
||||||
|
context,
|
||||||
|
listen: false,
|
||||||
|
).testType = testTypeCTRL.text;
|
||||||
|
Navigator.pushReplacementNamed(
|
||||||
|
context,
|
||||||
|
Routes.formTestResultScreen,
|
||||||
|
arguments: testTypeCTRL.text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// print(testCode);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 5 * _deviceBlockSize,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: ConnectionErrorBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> 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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import '../providers/connectivity.dart';
|
import '../../providers/connectivity.dart';
|
||||||
import '../providers/test_results.dart';
|
import '../../providers/test_results.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../../widgets/Global/internet_error.dart';
|
||||||
import '../widgets/TestResultScreens/Details/datas_box.dart';
|
import '../../widgets/TestResultScreens/Details/datas_box.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class TestDetailsScreen extends StatefulWidget {
|
class TestDetailsScreen extends StatefulWidget {
|
||||||
// static const route = '/TestDetailsScreen';
|
// static const route = '/TestDetailsScreen';
|
||||||
final String testResultId;
|
final String? testResultId;
|
||||||
|
|
||||||
TestDetailsScreen({this.testResultId});
|
TestDetailsScreen({this.testResultId});
|
||||||
|
|
||||||
@@ -17,16 +17,16 @@ class TestDetailsScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
||||||
bool isInit = true;
|
bool isInit = true;
|
||||||
Map<String, dynamic> datas;
|
Map<String, Object>? datas;
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() async {
|
void didChangeDependencies() async {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
var _id = ModalRoute.of(context).settings.arguments;
|
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||||
await Provider.of<TestResultsProvider>(context, listen: false)
|
await Provider.of<TestResultsProvider>(context, listen: false)
|
||||||
.showTestResult(_id.toString())
|
.showTestResult(_id.toString())
|
||||||
.then((result) {
|
.then((result) {
|
||||||
setState(() {
|
setState(() {
|
||||||
datas = result;
|
datas = result.cast<String, Object>();
|
||||||
isInit = false;
|
isInit = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -46,7 +46,8 @@ class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Test Result Detail'),
|
title: Text('Test Results'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_left,
|
Icons.keyboard_arrow_left,
|
||||||
@@ -60,10 +61,12 @@ class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
|||||||
return connection.conStatus != 'offline'
|
return connection.conStatus != 'offline'
|
||||||
? isInit
|
? isInit
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: DatasBox(
|
: DatasBox(
|
||||||
datas: datas,
|
datas: datas!,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
)
|
)
|
||||||
: ConnectionErrorBox();
|
: ConnectionErrorBox();
|
||||||
@@ -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<TestFilterScreen> {
|
||||||
|
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<String> 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<String> testTypeVals = [];
|
||||||
|
Map<String, String>? testTypes;
|
||||||
|
|
||||||
|
final List<String> hospitalVals = [];
|
||||||
|
Map<String, String> hospitals = {};
|
||||||
|
// String curhospitalVal;
|
||||||
|
|
||||||
|
bool isInit = true;
|
||||||
|
// final List<String> labelIDVals = ['Washer ID'];
|
||||||
|
// String curLabelIDVal;
|
||||||
|
|
||||||
|
// final List<String> 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<TestResultsProvider>(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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? isInit
|
||||||
|
? Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
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<TestResultsProvider>(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: <Widget>[
|
||||||
|
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<String> 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';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,16 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:random_string/random_string.dart';
|
import 'package:random_string/random_string.dart';
|
||||||
|
|
||||||
import '../config/routes.dart';
|
import '../../config/routes.dart';
|
||||||
import '../providers/input.dart';
|
import '../../providers/input.dart';
|
||||||
import '../providers/test_results.dart';
|
import '../../providers/test_results.dart';
|
||||||
import '../widgets/TestResultScreens/Add/form_creator.dart';
|
import '../../widgets/TestResultScreens/Add/form_creator.dart';
|
||||||
|
|
||||||
class FormPage extends StatefulWidget {
|
class FormPage extends StatefulWidget {
|
||||||
final String name;
|
final String? name;
|
||||||
final String uniqueCode;
|
final String? uniqueCode;
|
||||||
final String testResultId;
|
final String? testResultId;
|
||||||
final String testTypeId;
|
final String? testTypeId;
|
||||||
|
|
||||||
FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId});
|
FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId});
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ class _FormPageState extends State<FormPage> {
|
|||||||
bool isAdding = false;
|
bool isAdding = false;
|
||||||
final _form = GlobalKey<FormState>();
|
final _form = GlobalKey<FormState>();
|
||||||
Map<String, dynamic> values = {};
|
Map<String, dynamic> values = {};
|
||||||
List<Map<String, dynamic>> formInputs;
|
List<Map<String, dynamic>> formInputs = [];
|
||||||
|
|
||||||
void _saveForm() {
|
void _saveForm() {
|
||||||
final batchId = randomString(10);
|
final batchId = randomString(10);
|
||||||
@@ -33,7 +33,7 @@ class _FormPageState extends State<FormPage> {
|
|||||||
var prvObject = Provider.of<TestResultsProvider>(context, listen: false);
|
var prvObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||||
if (this.widget.testResultId != null && this.widget.testResultId != '') {
|
if (this.widget.testResultId != null && this.widget.testResultId != '') {
|
||||||
values['_method'] = 'put';
|
values['_method'] = 'put';
|
||||||
TestResultsProvider.updateTestResult(this.widget.testResultId, values)
|
TestResultsProvider.updateTestResult(this.widget.testResultId!, values)
|
||||||
.then((_) {
|
.then((_) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
});
|
});
|
||||||
@@ -72,12 +72,15 @@ class _FormPageState extends State<FormPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
|
String testTypeName = Provider.of<TestResultsProvider>(context).testType;
|
||||||
|
String testCode = Provider.of<TestResultsProvider>(context).testCode;
|
||||||
Provider.of<Inputs>(context, listen: false)
|
Provider.of<Inputs>(context, listen: false)
|
||||||
.getInputs(
|
.getInputs(
|
||||||
testResultId: this.widget.testResultId ?? "",
|
testResultId: '',
|
||||||
name: this.widget.name ?? "",
|
name: testTypeName,
|
||||||
uniqueCode: this.widget.uniqueCode ?? "",
|
uniqueCode: testCode,
|
||||||
testTypeId: this.widget.testTypeId ?? "")
|
testTypeId: '',
|
||||||
|
)
|
||||||
.then((_) {
|
.then((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
@@ -103,6 +106,7 @@ class _FormPageState extends State<FormPage> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text('Add Test Result'),
|
title: Text('Add Test Result'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.save),
|
icon: Icon(Icons.save),
|
||||||
@@ -117,35 +121,38 @@ class _FormPageState extends State<FormPage> {
|
|||||||
size: 35,
|
size: 35,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context)
|
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
|
||||||
.popAndPushNamed(Routes.testResultScreen);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
_isLoading
|
||||||
child: _isLoading
|
? Center(
|
||||||
? Center(child: CircularProgressIndicator())
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)
|
||||||
: Form(
|
: Form(
|
||||||
key: _form,
|
key: _form,
|
||||||
child: Consumer<Inputs>(
|
child: Consumer<Inputs>(
|
||||||
builder: (context, inputs, _) {
|
builder: (context, inputs, _) {
|
||||||
formInputs = inputs.inputItems;
|
formInputs = inputs.inputItems;
|
||||||
|
print(formInputs);
|
||||||
return formInputs.length != 0
|
return formInputs.length != 0
|
||||||
? FormCreator(
|
? FormCreator(
|
||||||
form: inputs.inputItems,
|
form: formInputs,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
formInputs = value;
|
formInputs = value;
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: Center(
|
: Center(
|
||||||
child: Text('An error happen!!!'),
|
child: Text('Something went wrong!!!'),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
// https://www.cssd-doc.com/api/GetInfo
|
// https://www.cssd-doc.com/api/GetInfo
|
||||||
// InkWell(
|
// InkWell(
|
||||||
// onTap: () {
|
// onTap: () {
|
||||||
@@ -166,7 +173,9 @@ class _FormPageState extends State<FormPage> {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -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<TestResultScreen> {
|
||||||
|
TextEditingController searchCTRL = new TextEditingController();
|
||||||
|
ScrollController? sc;
|
||||||
|
|
||||||
|
bool _isInit = true;
|
||||||
|
// List<TestResult> _data = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
sc = new ScrollController();
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
if (_isInit) {
|
||||||
|
var testResults =
|
||||||
|
Provider.of<TestResultsProvider>(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<TestResultsProvider>(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<ConnectivityProvider>(
|
||||||
|
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: <Widget>[
|
||||||
|
Row(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
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<TestResultsProvider>(
|
||||||
|
builder: (context, testResult, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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<TestResultsProvider>(
|
||||||
|
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<Auth>(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: <Widget>[
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
Text(item!.date),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
child: Text('Yes'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Provider.of<TestResultsProvider>(
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<StatefulWidget> createState() {
|
||||||
|
return _TestScanScreenState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TestScanScreenState extends State<TestScanScreen> {
|
||||||
|
String testCode = "";
|
||||||
|
TextEditingController idCTRL = new TextEditingController();
|
||||||
|
final _form = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
@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<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
|
return connection.conStatus != 'offline'
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
children: <Widget>[
|
||||||
|
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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
|
import 'package:cssd/config/colors.dart';
|
||||||
|
import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../config/routes.dart';
|
import '../../config/routes.dart';
|
||||||
import '../models/test_result_models.dart';
|
import '../../models/test_result_models.dart';
|
||||||
import '../providers/auth.dart';
|
import '../../providers/auth.dart';
|
||||||
import '../providers/test_results.dart';
|
import '../../providers/test_results.dart';
|
||||||
import '../widgets/TestResultScreens/Main/search_box.dart';
|
import '../../widgets/TestResultScreens/Main/search_box.dart';
|
||||||
|
|
||||||
class TestVerifyScreen extends StatefulWidget {
|
class TestVerifyScreen extends StatefulWidget {
|
||||||
// static const route = '/TestVerifyScreen';
|
// static const route = '/TestVerifyScreen';
|
||||||
@@ -19,7 +21,7 @@ class TestVerifyScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
||||||
TextEditingController searchCTRL = new TextEditingController();
|
TextEditingController searchCTRL = new TextEditingController();
|
||||||
ScrollController sc;
|
ScrollController? sc;
|
||||||
|
|
||||||
bool _isInit = true;
|
bool _isInit = true;
|
||||||
// List<TestResult> _data = [];
|
// List<TestResult> _data = [];
|
||||||
@@ -44,8 +46,8 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
testResults.resetPageNumber();
|
testResults.resetPageNumber();
|
||||||
testResults.getTestResults().then((_) {
|
testResults.getTestResults().then((_) {
|
||||||
testResults.resetLoading();
|
testResults.resetLoading();
|
||||||
sc.addListener(() {
|
sc!.addListener(() {
|
||||||
if (sc.position.pixels == sc.position.maxScrollExtent &&
|
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||||
searchCTRL.text == '') {
|
searchCTRL.text == '') {
|
||||||
var labelProviderObject =
|
var labelProviderObject =
|
||||||
Provider.of<TestResultsProvider>(context, listen: false);
|
Provider.of<TestResultsProvider>(context, listen: false);
|
||||||
@@ -75,6 +77,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Home'),
|
title: Text('Home'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_left,
|
Icons.keyboard_arrow_left,
|
||||||
@@ -94,7 +97,7 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
Container(
|
Container(
|
||||||
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
||||||
child: Text(
|
child: Text(
|
||||||
'TESTS TO VERIFY',
|
'Tests To Verify',
|
||||||
// textAlign: TextAlign.left,
|
// textAlign: TextAlign.left,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@@ -104,153 +107,112 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Spacer(),
|
|
||||||
// InkWell(
|
|
||||||
// onTap: () {
|
|
||||||
// Navigator.of(context)
|
|
||||||
// .popAndPushNamed(Routes.testFilterScreen);
|
|
||||||
// },
|
|
||||||
// child: Container(
|
|
||||||
// padding: EdgeInsets.all(7),
|
|
||||||
// child: Icon(
|
|
||||||
// FontAwesomeIcons.filter,
|
|
||||||
// size: 7 * _deviceBlockSize,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
Consumer<TestResultsProvider>(
|
||||||
height: 20,
|
builder: (context, testResult, _) {
|
||||||
|
return Container(
|
||||||
|
height: 50,
|
||||||
|
child: ListView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: <Widget>[
|
||||||
|
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(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
// Consumer<TestResultsProvider>(
|
|
||||||
// builder: (context, testResult, _) {
|
|
||||||
// return Container(
|
|
||||||
// height: 50,
|
|
||||||
// child: ListView(
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// shrinkWrap: true,
|
|
||||||
// children: <Widget>[
|
|
||||||
// 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(
|
TestResultSearchBox(
|
||||||
searchCTRL: searchCTRL,
|
searchCTRL: searchCTRL,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
@@ -263,38 +225,25 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
builder: (context, testResults, _) {
|
builder: (context, testResults, _) {
|
||||||
return testResults.isloading
|
return testResults.isloading
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
controller: sc,
|
controller: sc,
|
||||||
itemBuilder: (context, index) =>
|
itemBuilder: (context, index) =>
|
||||||
(testResults.items[index].verified == 'None' &&
|
(testResults.items![index].verified == 'None' &&
|
||||||
userData['roles']
|
userData['roles']
|
||||||
.contains('Supervisor')) ||
|
.contains('Supervisor')) ||
|
||||||
userData['roles'].contains('Admin')
|
userData['roles'].contains('Admin')
|
||||||
? TestItemBox(
|
? TestItemBox(
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
item: testResults.items[index],
|
item: testResults.items![index],
|
||||||
id: testResults.items[index].id,
|
id: testResults.items![index].id,
|
||||||
userData: userData,
|
userData: userData,
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
// Column(
|
itemCount: testResults.items?.length,
|
||||||
// children: <Widget>[
|
|
||||||
// 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,
|
shrinkWrap: true,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -311,11 +260,11 @@ class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
|||||||
class TestItemBox extends StatelessWidget {
|
class TestItemBox extends StatelessWidget {
|
||||||
final TestResultObject item;
|
final TestResultObject item;
|
||||||
const TestItemBox({
|
const TestItemBox({
|
||||||
Key key,
|
Key? key,
|
||||||
@required String id,
|
required String id,
|
||||||
@required double deviceBlockSize,
|
required double deviceBlockSize,
|
||||||
@required this.item,
|
required this.item,
|
||||||
@required this.userData,
|
required this.userData,
|
||||||
}) : _deviceBlockSize = deviceBlockSize,
|
}) : _deviceBlockSize = deviceBlockSize,
|
||||||
// _id = id,
|
// _id = id,
|
||||||
super(key: key);
|
super(key: key);
|
||||||
@@ -369,13 +318,13 @@ class TestItemBox extends StatelessWidget {
|
|||||||
? Text(
|
? Text(
|
||||||
'Verified',
|
'Verified',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.blueAccent,
|
color: kBlue,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
'Rejected',
|
'Rejected',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.red,
|
color: kPink,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -406,7 +355,8 @@ class TestItemBox extends StatelessWidget {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Provider.of<TestResultsProvider>(
|
Provider.of<TestResultsProvider>(
|
||||||
context)
|
context,
|
||||||
|
listen: false)
|
||||||
.changeVerification(
|
.changeVerification(
|
||||||
item.id, 'Verified')
|
item.id, 'Verified')
|
||||||
.then((result) {
|
.then((result) {
|
||||||
@@ -435,7 +385,7 @@ class TestItemBox extends StatelessWidget {
|
|||||||
width: 10 * _deviceBlockSize,
|
width: 10 * _deviceBlockSize,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: Color.fromRGBO(0, 190, 190, 1),
|
color: kBlue,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.check,
|
Icons.check,
|
||||||
@@ -459,7 +409,8 @@ class TestItemBox extends StatelessWidget {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await Provider.of<TestResultsProvider>(
|
await Provider.of<TestResultsProvider>(
|
||||||
context)
|
context,
|
||||||
|
listen: false)
|
||||||
.changeVerification(
|
.changeVerification(
|
||||||
item.id, 'NotVerified')
|
item.id, 'NotVerified')
|
||||||
.then((result) {
|
.then((result) {
|
||||||
@@ -488,7 +439,7 @@ class TestItemBox extends StatelessWidget {
|
|||||||
width: 10 * _deviceBlockSize,
|
width: 10 * _deviceBlockSize,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: Colors.red,
|
color: kPink,
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.close,
|
Icons.close,
|
||||||
@@ -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<CycleAddScreen> {
|
|
||||||
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<FormState>();
|
|
||||||
|
|
||||||
// List<String> labelVals = [];
|
|
||||||
// List<TextEditingController> labelValues = [];
|
|
||||||
bool isInit = true;
|
|
||||||
CycleFilterObject filters;
|
|
||||||
|
|
||||||
List<TextEditingController> 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<CyclesProvider>(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<ConnectivityProvider>(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: <Widget>[
|
|
||||||
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<CyclesProvider>(
|
|
||||||
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<CyclesProvider>(
|
|
||||||
context,
|
|
||||||
listen: false)
|
|
||||||
.labelValues,
|
|
||||||
cycleNumberCTRL: cycleNumberCTRL,
|
|
||||||
dateValue: dateCTRL.text,
|
|
||||||
descriptionCTRL: descriptionCTRL,
|
|
||||||
striizerIdCTRL: striizerIdCTRL,
|
|
||||||
deviceBlockSize: _deviceBlockSize,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 100,
|
|
||||||
),
|
|
||||||
|
|
||||||
// DropDownBox(values: ['Washer ID']),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: ConnectionErrorBox();
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<CycleFilterScreen> {
|
|
||||||
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<Map<String, String>> hospitalVals = [];
|
|
||||||
// String curhospitalVal;
|
|
||||||
bool isInit = true;
|
|
||||||
CycleFilterObject filters;
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
filters = Provider.of<CyclesProvider>(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<CyclesProvider>(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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: ListView(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<CycleResultScreen> {
|
|
||||||
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<CyclesProvider>(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<CyclesProvider>(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<ConnectivityProvider>(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: <Widget>[
|
|
||||||
CycleResultBanner(deviceBlockSize: _deviceBlockSize),
|
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Consumer<CyclesProvider>(builder: (ctx, cycle, _) {
|
|
||||||
return Container(
|
|
||||||
height: 50,
|
|
||||||
child: ListView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: <Widget>[
|
|
||||||
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<CyclesProvider>(
|
|
||||||
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: <Widget>[
|
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<StatefulWidget> createState() {
|
|
||||||
return _CycleScanScreenState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CycleScanScreenState extends State<CycleScanScreen> {
|
|
||||||
String testCode = "";
|
|
||||||
TextEditingController idCTRL = new TextEditingController();
|
|
||||||
final _form = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
@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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? ListView(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
children: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+122
-100
@@ -1,4 +1,9 @@
|
|||||||
import 'package:barcode_scan2/platform_wrapper.dart';
|
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:double_back_to_close_app/double_back_to_close_app.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -10,36 +15,27 @@ import '../providers/auth.dart';
|
|||||||
import '../providers/connectivity.dart';
|
import '../providers/connectivity.dart';
|
||||||
import '../widgets/Global/drawer.dart';
|
import '../widgets/Global/drawer.dart';
|
||||||
import '../widgets/Global/internet_error.dart';
|
import '../widgets/Global/internet_error.dart';
|
||||||
import 'cycle_result_screen.dart';
|
import 'CyclePages/cycle_result_screen.dart';
|
||||||
import 'label_result_screen.dart';
|
import 'LabelPages/label_result_screen.dart';
|
||||||
import 'my_info_screen.dart';
|
import 'my_info_screen.dart';
|
||||||
import 'test_result_screen.dart';
|
import 'TestPages/test_result_screen.dart';
|
||||||
import 'test_verify_screen.dart';
|
import 'TestPages/test_verify_screen.dart';
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
// 09338736511
|
|
||||||
|
|
||||||
// static const route = '/HomeScreen';
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||||
|
|
||||||
// print(userData['roles']);
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
// resizeToAvoidBottomPadding: false,
|
|
||||||
drawer: Selector<ConnectivityProvider, String>(
|
drawer: Selector<ConnectivityProvider, String>(
|
||||||
builder: (ctx, value, _) =>
|
builder: (ctx, value, _) =>
|
||||||
value != 'offline' ? AppDrawer() : Container(),
|
value != 'offline' ? AppDrawer() : Container(),
|
||||||
selector: (_, connctivity) => connctivity.conStatus,
|
selector: (_, connectivity) => connectivity.conStatus,
|
||||||
)
|
),
|
||||||
// Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
// return connection.conStatus != 'offline' ? AppDrawer() : Container();
|
|
||||||
// })
|
|
||||||
,
|
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: Text('CSSD'),
|
title: Text('CSSD'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
padding: const EdgeInsets.only(right: 10.0),
|
||||||
@@ -107,10 +103,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SelectionItem(
|
SelectionItem(
|
||||||
startColor: Color(0xFFFCB8A2),
|
firstLine: 'MY INFO',
|
||||||
endColor: Color(0xFFFFECD2),
|
secondLine: 'Personal Details',
|
||||||
firstLine: 'My INFO',
|
firstLineColor: Colors.black,
|
||||||
secondLine: 'List, Details & Add a one',
|
secondLineColor: Colors.grey,
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@@ -125,10 +121,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SelectionItem(
|
SelectionItem(
|
||||||
startColor: Color(0xFFD5F5FD),
|
|
||||||
endColor: Color(0xFFE9FFF7),
|
|
||||||
firstLine: 'TEST RESULTS',
|
firstLine: 'TEST RESULTS',
|
||||||
secondLine: 'List, Details & Add a one',
|
secondLine: 'List, Details & Add a one',
|
||||||
|
firstLineColor: Colors.black,
|
||||||
|
secondLineColor: Colors.grey,
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@@ -141,15 +137,15 @@ class HomePage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// MyTestResult(
|
),
|
||||||
// isAdmin: false,
|
Divider(
|
||||||
// ),
|
height: 2,
|
||||||
),
|
),
|
||||||
SelectionItem(
|
SelectionItem(
|
||||||
startColor: Color(0xFFE2D2C4),
|
|
||||||
endColor: Color(0xFFFAF7F5),
|
|
||||||
firstLine: 'LABELS',
|
firstLine: 'LABELS',
|
||||||
secondLine: 'List, Details & Add a one',
|
secondLine: 'List, Details & Add a one',
|
||||||
|
firstLineColor: kLightBlue,
|
||||||
|
secondLineColor: kLightBlueSub,
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@@ -164,10 +160,10 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SelectionItem(
|
SelectionItem(
|
||||||
startColor: Color(0xFFA7CCE1),
|
|
||||||
endColor: Color(0xFFECF7ED),
|
|
||||||
firstLine: 'CYCLES',
|
firstLine: 'CYCLES',
|
||||||
secondLine: 'List, Details & Add a one',
|
secondLine: 'List, Details & Add a one',
|
||||||
|
firstLineColor: kPink,
|
||||||
|
secondLineColor: kPinkSub,
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@@ -181,18 +177,88 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// SelectionItem(
|
Divider(
|
||||||
// startColor: Color(0xFFA7CCE1),
|
height: 2,
|
||||||
// endColor: Color(0xFFECF7ED),
|
),
|
||||||
// firstLine: 'image',
|
SelectionItem(
|
||||||
// secondLine: 'image',
|
firstLine: 'PACKAGES',
|
||||||
// onTap: CaptureImage(),
|
secondLine: 'List, Details & Add a one',
|
||||||
// ),
|
firstLineColor: kPurple,
|
||||||
userData['roles'].contains('User')
|
secondLineColor: kPurpleSub,
|
||||||
|
onTap: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) {
|
||||||
|
return Consumer<Auth>(
|
||||||
|
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<Auth>(
|
||||||
|
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<Auth>(
|
||||||
|
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<Auth>(
|
||||||
|
builder: (ctx, auth, _) {
|
||||||
|
return MyItemsResultScreen();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(height: 2),
|
||||||
|
userData['roles']?.contains('User') ?? false
|
||||||
? Container()
|
? Container()
|
||||||
: SelectionItem(
|
: SelectionItem(
|
||||||
startColor: Color(0xFFA7CCE1),
|
|
||||||
endColor: Color(0xFFECF7ED),
|
|
||||||
firstLine: 'TEST TO VERIFY',
|
firstLine: 'TEST TO VERIFY',
|
||||||
secondLine: 'Verify and reject Test Results',
|
secondLine: 'Verify and reject Test Results',
|
||||||
onTap: () => Navigator.push(
|
onTap: () => Navigator.push(
|
||||||
@@ -243,38 +309,36 @@ Future<String> scan() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SelectionItem extends StatelessWidget {
|
class SelectionItem extends StatelessWidget {
|
||||||
final Color startColor;
|
final String? firstLine;
|
||||||
final Color endColor;
|
final String? secondLine;
|
||||||
final String firstLine;
|
final Color? firstLineColor;
|
||||||
final String secondLine;
|
final Color? secondLineColor;
|
||||||
final Function onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
SelectionItem(
|
SelectionItem({
|
||||||
{this.startColor,
|
|
||||||
this.endColor,
|
|
||||||
this.firstLine,
|
this.firstLine,
|
||||||
this.secondLine,
|
this.secondLine,
|
||||||
this.onTap});
|
this.onTap,
|
||||||
|
this.firstLineColor,
|
||||||
|
this.secondLineColor,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final _media = MediaQuery.of(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 _devicewidth = _media.size.width;
|
||||||
final double _deviceBlockSize = _devicewidth / 100;
|
final double _deviceBlockSize = _devicewidth / 100;
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.symmetric(vertical: 10),
|
margin: EdgeInsets.symmetric(vertical: 10),
|
||||||
padding: EdgeInsets.symmetric(vertical: 5),
|
padding: EdgeInsets.symmetric(vertical: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Colors.transparent,
|
||||||
colors: [startColor, endColor],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(3),
|
Radius.circular(3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
splashColor: Colors.red,
|
splashColor: Colors.grey[350],
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Column(
|
title: Column(
|
||||||
@@ -282,17 +346,17 @@ class SelectionItem extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
firstLine,
|
firstLine!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: firstLineColor,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
fontSize: 5 * _deviceBlockSize,
|
||||||
letterSpacing: 3.5,
|
letterSpacing: 3.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
secondLine,
|
secondLine!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey,
|
color: secondLineColor,
|
||||||
fontSize: 3.5 * _deviceBlockSize,
|
fontSize: 3.5 * _deviceBlockSize,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -303,27 +367,6 @@ class SelectionItem extends StatelessWidget {
|
|||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Column(
|
|
||||||
// children: <Widget>[
|
|
||||||
// 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,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -389,7 +432,7 @@ class BarcodeSelectionItem extends StatelessWidget {
|
|||||||
fontFamily: 'montserrat',
|
fontFamily: 'montserrat',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -435,27 +478,6 @@ class BarcodeSelectionItem extends StatelessWidget {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Column(
|
|
||||||
// children: <Widget>[
|
|
||||||
// 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,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<LabelAddScreen> {
|
|
||||||
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<FormState>();
|
|
||||||
|
|
||||||
List<Map<String, String>> packageVals = [];
|
|
||||||
List<String> packageValue = [];
|
|
||||||
bool isInit = true;
|
|
||||||
// CycleFilterObject filters;
|
|
||||||
|
|
||||||
List<TextEditingController> 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<LabelsProvider>(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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Form(
|
|
||||||
key: _form,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
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();
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<LabelFilterScreen> {
|
|
||||||
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<Map<String, String>> hospitalVals = [];
|
|
||||||
bool isInit = true;
|
|
||||||
LabelFilterObject filters;
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
filters = Provider.of<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(
|
|
||||||
builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<LabelResultScreen> {
|
|
||||||
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<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(
|
|
||||||
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: <Widget>[
|
|
||||||
PageHeader(
|
|
||||||
deviceBlockSize: _deviceBlockSize,
|
|
||||||
label: 'LABELS',
|
|
||||||
route: Routes.labelFilterScreen,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Consumer<LabelsProvider>(
|
|
||||||
builder: (context, label, _) {
|
|
||||||
return Container(
|
|
||||||
height: 50,
|
|
||||||
child: ListView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: <Widget>[
|
|
||||||
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<LabelsProvider>(
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<StatefulWidget> createState() {
|
|
||||||
return _LabelScanScreenState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LabelScanScreenState extends State<LabelScanScreen> {
|
|
||||||
String testCode = "";
|
|
||||||
TextEditingController idCTRL = new TextEditingController();
|
|
||||||
final _form = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
@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<ConnectivityProvider>(
|
|
||||||
builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? ListView(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
children: <Widget>[
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<LabelUpdateScreen> {
|
|
||||||
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<FormState>();
|
|
||||||
|
|
||||||
List<Map<String, String>> packageVals = [];
|
|
||||||
List<String> packageValue = [];
|
|
||||||
bool isEmpty = false;
|
|
||||||
bool isInit = true;
|
|
||||||
LabelDetailsObject datas;
|
|
||||||
// CycleFilterObject filters;
|
|
||||||
|
|
||||||
List<TextEditingController> 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<LabelsProvider>(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<LabelsProvider>(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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Form(
|
|
||||||
key: _form,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: ListView(
|
|
||||||
children: <Widget>[
|
|
||||||
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();
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<StatefulWidget> createState() {
|
|
||||||
return _LoginScreenState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LoginScreenState extends State<LoginScreen> {
|
|
||||||
final _passwordFocusNode = FocusNode();
|
|
||||||
final _form = GlobalKey<FormState>();
|
|
||||||
bool _isLoading = false;
|
|
||||||
final cellNumberController = TextEditingController();
|
|
||||||
final passwordController = TextEditingController();
|
|
||||||
|
|
||||||
bool _hidePass = true;
|
|
||||||
Map<String, dynamic> map = Map<String, dynamic>();
|
|
||||||
|
|
||||||
@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: <Widget>[
|
|
||||||
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<Auth>(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<ConnectivityProvider, String>(
|
|
||||||
builder: (ctx, value, _) => value != 'offline'
|
|
||||||
? _isLoading
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Form(
|
|
||||||
key: _form,
|
|
||||||
child: ListView(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
children: <Widget>[
|
|
||||||
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: <Widget>[
|
|
||||||
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: <Widget>[
|
|
||||||
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,
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@ class MyInfoScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyInfoScreenState extends State<MyInfoScreen> {
|
class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||||
Map<String, dynamic> user;
|
Map<String, dynamic>? user;
|
||||||
TextEditingController usernameCTRL = new TextEditingController();
|
TextEditingController usernameCTRL = new TextEditingController();
|
||||||
TextEditingController emailCTRL = new TextEditingController();
|
TextEditingController emailCTRL = new TextEditingController();
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
if (isInit) {
|
if (isInit) {
|
||||||
var authObj = Provider.of<Auth>(context, listen: false);
|
var authObj = Provider.of<Auth>(context, listen: false);
|
||||||
user = await authObj.getUserData();
|
user = await authObj.getUserData();
|
||||||
usernameCTRL.text = user['name'] != null ? user['name'] : '';
|
usernameCTRL.text = user!['name'] != null ? user!['name'] : '';
|
||||||
emailCTRL.text = user['email'] != null ? user['email'] : '';
|
emailCTRL.text = user!['email'] != null ? user!['email'] : '';
|
||||||
isInit = false;
|
isInit = false;
|
||||||
}
|
}
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
@@ -41,10 +41,15 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
final double _devicewidth = _media.size.width;
|
final double _devicewidth = _media.size.width;
|
||||||
final double _deviceBlockSize = _devicewidth / 100;
|
final double _deviceBlockSize = _devicewidth / 100;
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||||||
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Dashboard'),
|
title: Text('Dashboard'),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.keyboard_arrow_left,
|
Icons.keyboard_arrow_left,
|
||||||
@@ -53,17 +58,20 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
body: Consumer<ConnectivityProvider>(
|
||||||
|
builder: (ct, connection, _) {
|
||||||
return connection.conStatus != 'offline'
|
return connection.conStatus != 'offline'
|
||||||
? isInit
|
? isInit
|
||||||
? Center(
|
? Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: ListView(
|
: ListView(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
InfoHeader(
|
InfoHeader(
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
label: 'MY INFO',
|
label: 'My Info',
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
@@ -73,7 +81,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
controller: usernameCTRL,
|
controller: usernameCTRL,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
label: 'Full Name',
|
label: 'Full Name',
|
||||||
icon: FontAwesomeIcons.sortNumericDown,
|
icon: FontAwesomeIcons.alignLeft,
|
||||||
inputType: TextInputType.text,
|
inputType: TextInputType.text,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -81,7 +89,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
),
|
),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
initialValue: user['cell_number'],
|
initialValue: user!['cell_number'],
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.call,
|
Icons.call,
|
||||||
@@ -121,12 +129,11 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 60, vertical: 10),
|
horizontal: 60, vertical: 10),
|
||||||
margin: EdgeInsets.only(top: 50, bottom: 20),
|
margin:
|
||||||
|
EdgeInsets.only(top: 50, bottom: 20),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Colors.black,
|
||||||
colors: [Colors.blue, Colors.green],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -142,7 +149,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
await Provider.of<Auth>(context,
|
await Provider.of<Auth>(context,
|
||||||
listen: false)
|
listen: false)
|
||||||
.setUserData(
|
.setUserData(
|
||||||
user['id'],
|
user!['id'],
|
||||||
usernameCTRL.text,
|
usernameCTRL.text,
|
||||||
emailCTRL.text,
|
emailCTRL.text,
|
||||||
)
|
)
|
||||||
@@ -173,7 +180,9 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: ConnectionErrorBox();
|
: ConnectionErrorBox();
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<StatefulWidget> createState() {
|
|
||||||
return _TestResultAddScreenState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TestResultAddScreenState extends State<TestResultAddScreen> {
|
|
||||||
String testCode = "";
|
|
||||||
TextEditingController testTypeCTRL = new TextEditingController();
|
|
||||||
final List<String> testTypeVals = [];
|
|
||||||
|
|
||||||
TextEditingController testIdCTRL = new TextEditingController();
|
|
||||||
bool isInit = true;
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
if (isInit) {
|
|
||||||
var testResultProviderObject =
|
|
||||||
Provider.of<TestResultsProvider>(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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: ListView(
|
|
||||||
padding:
|
|
||||||
EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
|
||||||
children: <Widget>[
|
|
||||||
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: <Widget>[
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
width: 70 * _deviceBlockSize,
|
|
||||||
child: TestResultAddSelectorBox(
|
|
||||||
deviceBlockSize: _deviceBlockSize,
|
|
||||||
dataCTRL: testTypeCTRL,
|
|
||||||
dataVals: testTypeVals,
|
|
||||||
label: 'Choose a Test Type'),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<TestFilterScreen> {
|
|
||||||
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<String> 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<String> testTypeVals = [];
|
|
||||||
Map<String, String> testTypes;
|
|
||||||
|
|
||||||
final List<String> hospitalVals = [];
|
|
||||||
Map<String, String> hospitals = {};
|
|
||||||
// String curhospitalVal;
|
|
||||||
|
|
||||||
bool isInit = true;
|
|
||||||
// final List<String> labelIDVals = ['Washer ID'];
|
|
||||||
// String curLabelIDVal;
|
|
||||||
|
|
||||||
// final List<String> 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<TestResultsProvider>(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<ConnectivityProvider>(
|
|
||||||
builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: Padding(
|
|
||||||
padding: EdgeInsets.all(20),
|
|
||||||
child: ListView(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
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<TestResultsProvider>(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: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<TestResultScreen> {
|
|
||||||
TextEditingController searchCTRL = new TextEditingController();
|
|
||||||
ScrollController sc;
|
|
||||||
|
|
||||||
bool _isInit = true;
|
|
||||||
// List<TestResult> _data = [];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
sc = new ScrollController();
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
if (_isInit) {
|
|
||||||
var testResults =
|
|
||||||
Provider.of<TestResultsProvider>(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<TestResultsProvider>(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<ConnectivityProvider>(
|
|
||||||
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: <Widget>[
|
|
||||||
Row(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
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<TestResultsProvider>(
|
|
||||||
builder: (context, testResult, _) {
|
|
||||||
return Container(
|
|
||||||
height: 50,
|
|
||||||
child: ListView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
shrinkWrap: true,
|
|
||||||
children: <Widget>[
|
|
||||||
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<TestResultsProvider>(
|
|
||||||
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: <Widget>[
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
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: <Widget>[
|
|
||||||
Text(item.date),
|
|
||||||
SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: <Widget>[
|
|
||||||
// item.result != 'Accepted'
|
|
||||||
// ? InkWell(
|
|
||||||
// onTap: () {
|
|
||||||
// showDialog(
|
|
||||||
// context: context,
|
|
||||||
// builder: (ctx) => AlertDialog(
|
|
||||||
// title: Text('Delete'),
|
|
||||||
// content: Text(
|
|
||||||
// 'Are you sure for delete this test?'),
|
|
||||||
// actions: <Widget>[
|
|
||||||
// TextButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Provider.of<TestResultsProvider>(
|
|
||||||
// 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<StatefulWidget> createState() {
|
|
||||||
return _TestScanScreenState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TestScanScreenState extends State<TestScanScreen> {
|
|
||||||
String testCode = "";
|
|
||||||
TextEditingController idCTRL = new TextEditingController();
|
|
||||||
final _form = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
@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<ConnectivityProvider>(builder: (ct, connection, _) {
|
|
||||||
return connection.conStatus != 'offline'
|
|
||||||
? ListView(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
children: <Widget>[
|
|
||||||
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<String> 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';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+18
-12
@@ -9,8 +9,8 @@ import '../config/urls.dart';
|
|||||||
import '../config/user.dart';
|
import '../config/user.dart';
|
||||||
|
|
||||||
class Auth with ChangeNotifier {
|
class Auth with ChangeNotifier {
|
||||||
String _token;
|
String? _token;
|
||||||
DateTime _expiaryDate;
|
DateTime? _expiaryDate;
|
||||||
|
|
||||||
Map<String, dynamic> _user = {};
|
Map<String, dynamic> _user = {};
|
||||||
|
|
||||||
@@ -18,11 +18,11 @@ class Auth with ChangeNotifier {
|
|||||||
return token != null;
|
return token != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String get token {
|
String? get token {
|
||||||
if (_expiaryDate != null &&
|
if (_expiaryDate != null &&
|
||||||
_expiaryDate.isAfter(DateTime.now()) &&
|
_expiaryDate!.isAfter(DateTime.now()) &&
|
||||||
_token != null) {
|
_token != null) {
|
||||||
return _token;
|
return _token!;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ class Auth with ChangeNotifier {
|
|||||||
seconds: responseData['expires_in'],
|
seconds: responseData['expires_in'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
User.token = _token;
|
User.token = _token!;
|
||||||
// print(isAuth);
|
// print(isAuth);
|
||||||
|
|
||||||
// print(User.token);
|
// print(User.token);
|
||||||
@@ -132,7 +132,7 @@ class Auth with ChangeNotifier {
|
|||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final userData = json.encode({
|
final userData = json.encode({
|
||||||
'token': _token,
|
'token': _token,
|
||||||
'expiaryDate': _expiaryDate.toIso8601String(),
|
'expiaryDate': _expiaryDate!.toIso8601String(),
|
||||||
'user': user
|
'user': user
|
||||||
});
|
});
|
||||||
prefs.setString('userData', userData);
|
prefs.setString('userData', userData);
|
||||||
@@ -146,7 +146,7 @@ class Auth with ChangeNotifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final userData =
|
final userData =
|
||||||
json.decode(prefs.getString('userData')) as Map<String, Object>;
|
json.decode(prefs.getString('userData')!) as Map<String, dynamic>;
|
||||||
final expiaryDate = DateTime.parse(userData['expiaryDate']);
|
final expiaryDate = DateTime.parse(userData['expiaryDate']);
|
||||||
if (expiaryDate.isBefore(DateTime.now())) {
|
if (expiaryDate.isBefore(DateTime.now())) {
|
||||||
return false;
|
return false;
|
||||||
@@ -154,7 +154,7 @@ class Auth with ChangeNotifier {
|
|||||||
_token = userData['token'];
|
_token = userData['token'];
|
||||||
_expiaryDate = expiaryDate;
|
_expiaryDate = expiaryDate;
|
||||||
_user = userData['user'];
|
_user = userData['user'];
|
||||||
User.token = _token;
|
User.token = _token!;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ class Auth with ChangeNotifier {
|
|||||||
Future<Map<String, dynamic>> getUserData() async {
|
Future<Map<String, dynamic>> getUserData() async {
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(Url.getUserInfo),
|
Uri.parse(Url.getUserInfo),
|
||||||
headers: {'Authorization': 'Bearer ' + token},
|
headers: {'Authorization': 'Bearer ' + token!},
|
||||||
);
|
);
|
||||||
// print(response.body);
|
// print(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@@ -191,7 +191,7 @@ class Auth with ChangeNotifier {
|
|||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse('https://cssd-doc.com/api/UpdateInfo'),
|
Uri.parse('https://cssd-doc.com/api/UpdateInfo'),
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + token,
|
'Authorization': 'Bearer ' + token!,
|
||||||
HttpHeaders.contentTypeHeader: 'application/json',
|
HttpHeaders.contentTypeHeader: 'application/json',
|
||||||
},
|
},
|
||||||
body: json.encode(
|
body: json.encode(
|
||||||
@@ -241,9 +241,15 @@ class Auth with ChangeNotifier {
|
|||||||
_token = null;
|
_token = null;
|
||||||
_expiaryDate = null;
|
_expiaryDate = null;
|
||||||
_user = {};
|
_user = {};
|
||||||
User.token = null;
|
User.token = '';
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
prefs.remove('userData');
|
prefs.remove('userData');
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse(
|
||||||
|
Url.logOut,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
print(response.statusCode);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,32 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:connectivity/connectivity.dart';
|
import 'package:connectivity/connectivity.dart';
|
||||||
|
|
||||||
|
enum ConnectionStatus {
|
||||||
|
Wifi,
|
||||||
|
Cellular,
|
||||||
|
Offline,
|
||||||
|
}
|
||||||
|
|
||||||
class ConnectivityProvider extends ChangeNotifier {
|
class ConnectivityProvider extends ChangeNotifier {
|
||||||
String conStatus = '';
|
String conStatus = '';
|
||||||
|
|
||||||
checkConnection() {
|
void checkConnection() {
|
||||||
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
Connectivity().onConnectivityChanged.listen((ConnectivityResult? result) {
|
||||||
conStatus = _getStatus(result);
|
conStatus = _getStatus(result);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getStatus(ConnectivityResult result) {
|
String _getStatus(ConnectivityResult? result) {
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case ConnectivityResult.wifi:
|
case ConnectivityResult.wifi:
|
||||||
return 'wifi';
|
return 'wifi';
|
||||||
break;
|
|
||||||
case ConnectivityResult.mobile:
|
case ConnectivityResult.mobile:
|
||||||
return 'calcular';
|
return 'cellular';
|
||||||
break;
|
|
||||||
case ConnectivityResult.none:
|
case ConnectivityResult.none:
|
||||||
return 'offline';
|
return 'offline';
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return 'offline';
|
return 'offline';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-23
@@ -35,11 +35,11 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
String searchBoxValue = '';
|
String searchBoxValue = '';
|
||||||
bool filterOn = false;
|
bool filterOn = false;
|
||||||
List<CycleResultObject> items;
|
List<CycleResultObject>? items;
|
||||||
List<CycleResultObject> originalItems; //before do search on results
|
List<CycleResultObject>? originalItems;
|
||||||
|
|
||||||
CycleDetailObject result;
|
CycleDetailObject? result;
|
||||||
CycleFilterObject filters = CycleFilterObject(
|
CycleFilterObject? filters = CycleFilterObject(
|
||||||
id: '',
|
id: '',
|
||||||
cycleNumber: '',
|
cycleNumber: '',
|
||||||
sterilizerId: '',
|
sterilizerId: '',
|
||||||
@@ -127,6 +127,51 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
print(response.body);
|
print(response.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> 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<bool> 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) {
|
void setFilters(id, cycleNumber, sterilizerId, hospital, date) {
|
||||||
pageNumber = 1;
|
pageNumber = 1;
|
||||||
filters = CycleFilterObject(
|
filters = CycleFilterObject(
|
||||||
@@ -136,11 +181,11 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
hospital: hospital,
|
hospital: hospital,
|
||||||
date: date,
|
date: date,
|
||||||
);
|
);
|
||||||
if (filters.id == '' &&
|
if (filters!.id == '' &&
|
||||||
filters.cycleNumber == '' &&
|
filters!.cycleNumber == '' &&
|
||||||
filters.sterilizerId == '' &&
|
filters!.sterilizerId == '' &&
|
||||||
filters.hospital == '' &&
|
filters!.hospital == '' &&
|
||||||
filters.date == '') {
|
filters!.date == '') {
|
||||||
filterOn = false;
|
filterOn = false;
|
||||||
} else {
|
} else {
|
||||||
filterOn = true;
|
filterOn = true;
|
||||||
@@ -151,9 +196,9 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
void search(String value) {
|
void search(String value) {
|
||||||
items = [];
|
items = [];
|
||||||
searchBoxValue = value;
|
searchBoxValue = value;
|
||||||
originalItems.forEach((result) {
|
originalItems!.forEach((result) {
|
||||||
if (result.id.toString().contains(searchBoxValue)) {
|
if (result.id.toString().contains(searchBoxValue)) {
|
||||||
items.add(result);
|
items!.add(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -163,20 +208,20 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
String url = Url.cycleResults(pageNumber);
|
String url = Url.cycleResults(pageNumber);
|
||||||
if (filterOn) {
|
if (filterOn) {
|
||||||
items = [];
|
items = [];
|
||||||
if (filters.id != '') {
|
if (filters!.id != '') {
|
||||||
url += '&cycle_id=${filters.id}';
|
url += '&cycle_id=${filters!.id}';
|
||||||
}
|
}
|
||||||
if (filters.cycleNumber != '') {
|
if (filters!.cycleNumber != '') {
|
||||||
url += '&cycle_number=${filters.cycleNumber}';
|
url += '&cycle_number=${filters!.cycleNumber}';
|
||||||
}
|
}
|
||||||
if (filters.sterilizerId != '') {
|
if (filters!.sterilizerId != '') {
|
||||||
url += '&sterilizer_id=${filters.sterilizerId}';
|
url += '&sterilizer_id=${filters!.sterilizerId}';
|
||||||
}
|
}
|
||||||
if (filters.hospital != '') {
|
if (filters!.hospital != '') {
|
||||||
url += '&medical_center_id=${filters.hospital}';
|
url += '&medical_center_id=${filters!.hospital}';
|
||||||
}
|
}
|
||||||
if (filters.date != '') {
|
if (filters!.date != '') {
|
||||||
url += '&date=${filters.date}';
|
url += '&date=${filters!.date}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print(url);
|
// print(url);
|
||||||
@@ -201,7 +246,7 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
// print(label['id']);
|
// print(label['id']);
|
||||||
labels.add(label['id'].toString());
|
labels.add(label['id'].toString());
|
||||||
}
|
}
|
||||||
originalItems.add(
|
originalItems!.add(
|
||||||
CycleResultObject(
|
CycleResultObject(
|
||||||
createdAt: item['date'],
|
createdAt: item['date'],
|
||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
@@ -260,6 +305,6 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
// // 'user_name': data['user']['name'],
|
// // 'user_name': data['user']['name'],
|
||||||
// // 'medical_center': data['user']['medical_center']['name'],
|
// // 'medical_center': data['user']['medical_center']['name'],
|
||||||
// };
|
// };
|
||||||
return result;
|
return result!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-22
@@ -9,19 +9,12 @@ import '../config/user.dart';
|
|||||||
class Inputs with ChangeNotifier {
|
class Inputs with ChangeNotifier {
|
||||||
List<Map<String, dynamic>> inputItems = [];
|
List<Map<String, dynamic>> inputItems = [];
|
||||||
|
|
||||||
Future<bool> getInputs(
|
Future<bool> getInputs({
|
||||||
{String testResultId = "",
|
required String testResultId,
|
||||||
String name = "",
|
required String name,
|
||||||
String uniqueCode = "",
|
required String uniqueCode,
|
||||||
String testTypeId = ""}) async {
|
required String testTypeId,
|
||||||
// print(
|
}) async {
|
||||||
// {
|
|
||||||
// 'test_type_id': testTypeId,
|
|
||||||
// 'test_result_id': testResultId,
|
|
||||||
// 'name': name,
|
|
||||||
// 'unique_code': uniqueCode,
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse(Url.getInputs),
|
Uri.parse(Url.getInputs),
|
||||||
body: {
|
body: {
|
||||||
@@ -42,13 +35,10 @@ class Inputs with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
final responseData = json.decode(response.body);
|
final responseData = json.decode(response.body);
|
||||||
|
|
||||||
// print(responseData['data']['inputs']);
|
Map<String, dynamic>? values;
|
||||||
// for (var item in responseData['data']['testType'].keys) {
|
|
||||||
// print(item);
|
|
||||||
// }
|
|
||||||
Map<String, dynamic> values;
|
|
||||||
if (testResultId.isNotEmpty) {
|
if (testResultId.isNotEmpty) {
|
||||||
response = await http.get(Uri.parse(Url.testResultFormValues(testResultId)),
|
response = await http.get(
|
||||||
|
Uri.parse(Url.testResultFormValues(testResultId)),
|
||||||
headers: {'Authorization': User.token});
|
headers: {'Authorization': User.token});
|
||||||
values = json.decode(response.body)['data'];
|
values = json.decode(response.body)['data'];
|
||||||
}
|
}
|
||||||
@@ -59,7 +49,7 @@ class Inputs with ChangeNotifier {
|
|||||||
clearInputs();
|
clearInputs();
|
||||||
bool result = false;
|
bool result = false;
|
||||||
DateTime dateTime = DateTime.now();
|
DateTime dateTime = DateTime.now();
|
||||||
String deviceLabel;
|
String? deviceLabel;
|
||||||
if (values != null && values.isNotEmpty) {
|
if (values != null && values.isNotEmpty) {
|
||||||
result = values['result'] == 'Accept' ? true : false;
|
result = values['result'] == 'Accept' ? true : false;
|
||||||
dateTime = values['date'] == null
|
dateTime = values['date'] == null
|
||||||
@@ -75,7 +65,6 @@ class Inputs with ChangeNotifier {
|
|||||||
'value': general['id']
|
'value': general['id']
|
||||||
});
|
});
|
||||||
|
|
||||||
// print(responseData['data']['inputs']);
|
|
||||||
inputItems.add({
|
inputItems.add({
|
||||||
'type': 'Text',
|
'type': 'Text',
|
||||||
'key': 'device_id',
|
'key': 'device_id',
|
||||||
@@ -90,7 +79,6 @@ class Inputs with ChangeNotifier {
|
|||||||
setValues(inputs, values);
|
setValues(inputs, values);
|
||||||
for (var input in inputs) {
|
for (var input in inputs) {
|
||||||
inputItems.add(input as Map<String, dynamic>);
|
inputItems.add(input as Map<String, dynamic>);
|
||||||
// print(input);
|
|
||||||
}
|
}
|
||||||
inputItems.add({
|
inputItems.add({
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
|
|||||||
@@ -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<PlatformFile> catchImages = [];
|
||||||
|
List<Uint8List> images = [];
|
||||||
|
String searchBoxValue = '';
|
||||||
|
bool filterOn = false;
|
||||||
|
List<ItemResultObject>? items;
|
||||||
|
|
||||||
|
List<ItemResultObject>? 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<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(Url.filterItems),
|
||||||
|
headers: {
|
||||||
|
'Authorization': User.token,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
List<Map<String, String>> 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<PlatformFile> images) {
|
||||||
|
catchImages = images;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
removeImage(int index) {
|
||||||
|
catchImages.removeAt(index);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> addImage(String batchId, dynamic file, String fileName) async {
|
||||||
|
var imageListInt = file.cast<int>();
|
||||||
|
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<void> 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<void> 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<bool> 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<void> 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<ItemDetailObject> 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<bool> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
-22
@@ -9,10 +9,35 @@ import 'package:http/http.dart' as http;
|
|||||||
class LabelsProvider extends ChangeNotifier {
|
class LabelsProvider extends ChangeNotifier {
|
||||||
String searchBoxValue = '';
|
String searchBoxValue = '';
|
||||||
bool filterOn = false;
|
bool filterOn = false;
|
||||||
List<LabelResultObject> items;
|
List<LabelResultObject>? items;
|
||||||
List<LabelResultObject> originalItems;
|
List<LabelResultObject>? originalItems;
|
||||||
|
List<String> packageVals = [];
|
||||||
|
List<TextEditingController> packageValues = [];
|
||||||
|
String initialPackageValue = '';
|
||||||
|
int curPackageVal = 1;
|
||||||
|
|
||||||
LabelDetailsObject result;
|
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(
|
LabelFilterObject filters = LabelFilterObject(
|
||||||
id: '',
|
id: '',
|
||||||
cycleNumber: '',
|
cycleNumber: '',
|
||||||
@@ -51,26 +76,25 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Map<String, String>>> getPackageFilters() async {
|
Future<List<String>> getPackageFilters() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse(Url.packageItems),
|
Uri.parse(Url.packageItems),
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': User.token,
|
'Authorization': User.token,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
List<Map<String, String>> result = [];
|
List<String> result = [];
|
||||||
var filterDatas = json.decode(response.body);
|
var filterDatas = json.decode(response.body);
|
||||||
// print(filterDatas);
|
|
||||||
for (var package in filterDatas['data']) {
|
for (var package in filterDatas['data']) {
|
||||||
result.add(
|
result.add(
|
||||||
{
|
"${package['name']} - ${package['udi'] != null ? package['udi'] : ''}");
|
||||||
'name': package['name'].toString(),
|
|
||||||
'id': package['id'].toString(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// print(hospital['name']);
|
|
||||||
}
|
}
|
||||||
// print(result);
|
packageVals = result;
|
||||||
|
initialPackageValue = packageVals[0];
|
||||||
|
TextEditingController newLbl = new TextEditingController();
|
||||||
|
newLbl.text = initialPackageValue;
|
||||||
|
packageValues.add(newLbl);
|
||||||
|
notifyListeners();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +110,6 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
'cycle_number': cycleNumber,
|
'cycle_number': cycleNumber,
|
||||||
'lot_number': lotNumber,
|
'lot_number': lotNumber,
|
||||||
'package_id': package['id']
|
'package_id': package['id']
|
||||||
// 'package': {
|
|
||||||
// 'id': package['id'],
|
|
||||||
// 'name': package['name'],
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -112,6 +132,16 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
sterilizerId,
|
sterilizerId,
|
||||||
) async {
|
) async {
|
||||||
// print(labs);
|
// 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)),
|
var response = await http.put(Uri.parse(Url.updateLabelResult(id)),
|
||||||
body: json.encode(
|
body: json.encode(
|
||||||
{
|
{
|
||||||
@@ -120,7 +150,7 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
'sterilizer_id': sterilizerId,
|
'sterilizer_id': sterilizerId,
|
||||||
'cycle_number': cycleNumber,
|
'cycle_number': cycleNumber,
|
||||||
'lot_number': lotNumber,
|
'lot_number': lotNumber,
|
||||||
'package_id': package['id']
|
'package_id': package['id'],
|
||||||
// 'package': {
|
// 'package': {
|
||||||
// 'id': package['id'],
|
// 'id': package['id'],
|
||||||
// 'name': package['name'],
|
// 'name': package['name'],
|
||||||
@@ -137,6 +167,23 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
print(response.body);
|
print(response.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> 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) {
|
void setFilters(id, cycleNumber, sterilizerId, hospital) {
|
||||||
pageNumber = 1;
|
pageNumber = 1;
|
||||||
filters = LabelFilterObject(
|
filters = LabelFilterObject(
|
||||||
@@ -159,9 +206,9 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
void search(String value) {
|
void search(String value) {
|
||||||
items = [];
|
items = [];
|
||||||
searchBoxValue = value;
|
searchBoxValue = value;
|
||||||
originalItems.forEach((result) {
|
originalItems!.forEach((result) {
|
||||||
if (result.id.toString().contains(searchBoxValue)) {
|
if (result.id.toString().contains(searchBoxValue)) {
|
||||||
items.add(result);
|
items!.add(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -201,7 +248,7 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
for (var item in testResultData['data']['data']) {
|
for (var item in testResultData['data']['data']) {
|
||||||
// print(item);
|
// print(item);
|
||||||
originalItems.add(
|
originalItems!.add(
|
||||||
LabelResultObject(
|
LabelResultObject(
|
||||||
expireDate: item['expire_date'],
|
expireDate: item['expire_date'],
|
||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
@@ -252,6 +299,6 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '',
|
cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '',
|
||||||
lotNumber: data['lot_number'] != null ? data['lot_number'] : '',
|
lotNumber: data['lot_number'] != null ? data['lot_number'] : '',
|
||||||
);
|
);
|
||||||
return result;
|
return result!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,39 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import '../config/urls.dart';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class MyInfoProvider extends ChangeNotifier {
|
import '../config/urls.dart';
|
||||||
|
|
||||||
|
class MyInfoProvider with ChangeNotifier {
|
||||||
Map<String, dynamic> _user = {};
|
Map<String, dynamic> _user = {};
|
||||||
Map<String, dynamic> get user {
|
Map<String, dynamic> get user {
|
||||||
return {..._user};
|
return {..._user};
|
||||||
}
|
}
|
||||||
|
|
||||||
String _token;
|
String? _token;
|
||||||
|
|
||||||
Future<void> setToken() async {
|
Future<void> setToken() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
if (!prefs.containsKey('auth')) {
|
if (!prefs.containsKey('auth')) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
final auth = json.decode(prefs.getString('auth')) as Map<String, Object>;
|
final auth = json.decode(prefs.getString('auth')!) as Map<String, dynamic>;
|
||||||
_token = auth['token'];
|
_token = auth['token'];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> getUserData() async {
|
Future<Map<String, dynamic>> getUserData() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final auth = json.decode(prefs.getString('auth')) as Map<String, Object>;
|
final auth = json.decode(prefs.getString('auth')!) as Map<String, dynamic>;
|
||||||
_token = auth['token'];
|
_token = auth['token'];
|
||||||
final response = await http.get(
|
final response = await http.get(
|
||||||
Uri.parse(Url.getUserInfo),
|
Uri.parse(Url.getUserInfo),
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + _token,
|
'Authorization': 'Bearer $_token',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
print(response.body);
|
print(response.body);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var data = json.decode(response.body)['data'];
|
var data = json.decode(response.body)['data'];
|
||||||
_user.addAll(
|
_user.addAll(
|
||||||
|
|||||||
@@ -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<MyItemResultObject>? myItems;
|
||||||
|
List<MyItemResultObject>? hospitalItems;
|
||||||
|
|
||||||
|
List<MyItemResultObject>? originalMyItems;
|
||||||
|
List<MyItemResultObject>? originalHospitalItems;
|
||||||
|
|
||||||
|
List<MyItemResultObject>? originalMyItemsRequests;
|
||||||
|
List<MyItemResultObject>? 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<void> 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<void> 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<void> 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<void> 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<void> 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<bool> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<MyPackageResultObject>? myPackages;
|
||||||
|
List<MyPackageResultObject>? hospitalPackages;
|
||||||
|
|
||||||
|
List<MyPackageResultObject>? originalMyPackages;
|
||||||
|
List<MyPackageResultObject>? originalHospitalPackages;
|
||||||
|
|
||||||
|
List<MyPackageResultObject>? originalMyPackagesRequests;
|
||||||
|
List<MyPackageResultObject>? 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<void> 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<void> 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<void> 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<void> 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<void> 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<bool> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<String> itemVals = [];
|
||||||
|
List<TextEditingController> 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<PackageResultObject>? items;
|
||||||
|
List<PackageResultObject>? 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<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(Url.filterItems),
|
||||||
|
headers: {
|
||||||
|
'Authorization': User.token,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
List<Map<String, String>> 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<List<String>> getItemFilters() async {
|
||||||
|
var response = await http.get(
|
||||||
|
Uri.parse(Url.itemItems),
|
||||||
|
headers: {
|
||||||
|
'Authorization': User.token,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
List<String> 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<void> createPackageResult(
|
||||||
|
name,
|
||||||
|
udi,
|
||||||
|
items,
|
||||||
|
note,
|
||||||
|
) async {
|
||||||
|
List<Map<String, Object>> 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<void> updatePackageResult(
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
udi,
|
||||||
|
description,
|
||||||
|
items,
|
||||||
|
) async {
|
||||||
|
// List<Map<String, Object>> 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<bool> 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<void> 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<PackageDetailObject> 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<String> 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!;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user