From 3d608131464c6fbe629e2c10458085ecb8be1632 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Feb 2021 15:12:26 +0200 Subject: [PATCH 1/7] bug fixing --- .../prescription/add_prescription_form.dart | 143 ++++++++++++------ .../procedures/add-procedure-form.dart | 2 +- lib/screens/procedures/procedure_screen.dart | 12 +- lib/screens/procedures/update-procedure.dart | 2 +- 4 files changed, 102 insertions(+), 57 deletions(-) diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 80d77f3e..b1e79ae2 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -543,56 +543,101 @@ class _PrescriptionFormWidgetState extends State { ), ), SizedBox(height: spaceBetweenTextFileds), - //model.patientAssessmentList.forEach((element) { }). - Column( - children: model.patientAssessmentList - .map((element) { - return Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: indicationList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: indicationList, - attributeName: 'name', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: (selectedValue) { - setState(() { - indication = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - element.icdCode10ID - .toString(), - indication != null - ? indication['name'] - : null, - true), - enabled: true, - readOnly: true, - ), + + if (model.patientAssessmentList.isNotEmpty) + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: indicationList != null + ? () { + ListSelectDialog dialog = + ListSelectDialog( + list: indicationList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + indication = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0] + .icdCode10ID + .toString(), + indication != null + ? indication['name'] + : null, + true), + enabled: true, + readOnly: true, ), - ); - }).toList(), - ), + ), + ), + //model.patientAssessmentList.forEach((element) { }). + // Column( + // children: model.patientAssessmentList + // .map((element) { + // return Container( + // height: screenSize.height * 0.070, + // child: InkWell( + // onTap: indicationList != null + // ? () { + // ListSelectDialog dialog = + // ListSelectDialog( + // list: indicationList, + // attributeName: 'name', + // attributeValueId: 'id', + // okText: TranslationBase.of( + // context) + // .ok, + // okFunction: (selectedValue) { + // setState(() { + // indication = + // selectedValue; + // }); + // }, + // ); + // showDialog( + // barrierDismissible: false, + // context: context, + // builder: + // (BuildContext context) { + // return dialog; + // }, + // ); + // } + // : null, + // child: TextField( + // decoration: + // textFieldSelectorDecoration( + // element.icdCode10ID + // .toString(), + // indication != null + // ? indication['name'] + // : null, + // true), + // enabled: true, + // readOnly: true, + // ), + // ), + // ); + // }).toList(), + // ), SizedBox(height: spaceBetweenTextFileds), Container( diff --git a/lib/screens/procedures/add-procedure-form.dart b/lib/screens/procedures/add-procedure-form.dart index 81452c63..0d34da6b 100644 --- a/lib/screens/procedures/add-procedure-form.dart +++ b/lib/screens/procedures/add-procedure-form.dart @@ -221,7 +221,7 @@ class _AddSelectedProcedureState extends State { setSelectedType(value); }, ), - Text(TranslationBase.of(context).regular), + Text('routine'), Radio( activeColor: Color(0xFFB9382C), groupValue: selectedType, diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 28906d07..dd5c2952 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -259,11 +259,11 @@ class _ProcedureScreenState extends State { ), Expanded( child: Container( - height: MediaQuery.of( - context) - .size - .height * - 0.21, + // height: MediaQuery.of( + // context) + // .size + // .height * + // 0.21, width: MediaQuery.of( context) .size @@ -312,7 +312,7 @@ class _ProcedureScreenState extends State { AppText( model.procedureList[0].entityList[index].orderType == 1 - ? 'Regular' + ? 'Routine' : 'Urgent', fontSize: 13.0, diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index 3e567c1f..9239527c 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -212,7 +212,7 @@ class _UpdateProcedureWidgetState extends State { setSelectedType(value); }, ), - Text(TranslationBase.of(context).regular), + Text('routine'), ], ), ), From 498c6c00af3c62a818ef69c899432137c3af97f0 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 10 Feb 2021 15:13:14 +0200 Subject: [PATCH 2/7] fix minor issue bugs (DA-273, DA-361, DA-362, DA-363) --- lib/core/service/patient-doctor-referral-service.dart | 6 +++--- lib/core/service/patient-ucaf-service.dart | 4 ++-- lib/models/patient/patiant_info_model.dart | 6 +++++- .../profile/referral/my-referral-detail-screen.dart | 2 ++ .../patients/profile/PatientHeaderWidgetNoAvatar.dart | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/core/service/patient-doctor-referral-service.dart b/lib/core/service/patient-doctor-referral-service.dart index 77af017c..813fef35 100644 --- a/lib/core/service/patient-doctor-referral-service.dart +++ b/lib/core/service/patient-doctor-referral-service.dart @@ -198,9 +198,9 @@ class PatientReferralService extends LookupService { Map body = Map(); body['PatientMRN'] = pendingReferral.patientID; - body['AppointmentNo'] = pendingReferral.sourceAppointmentNo; - body['SetupID'] = pendingReferral.sourceSetupID; - body['ProjectID'] = pendingReferral.sourceProjectId; + body['AppointmentNo'] = pendingReferral.targetAppointmentNo; + body['SetupID'] = pendingReferral.targetSetupID; + body['ProjectID'] = pendingReferral.targetProjectId; body['IsAccepted'] = isAccepted; body['PatientName'] = pendingReferral.patientName; body['ReferralResponse'] = pendingReferral.remarksFromSource; diff --git a/lib/core/service/patient-ucaf-service.dart b/lib/core/service/patient-ucaf-service.dart index 429e78a9..90a45ee2 100644 --- a/lib/core/service/patient-ucaf-service.dart +++ b/lib/core/service/patient-ucaf-service.dart @@ -106,8 +106,8 @@ class UcafService extends LookupService { hasError = false; Map body = Map(); body['PatientMRN'] = patient.patientMRN; - // body['AppointmentNo'] = patient.appointmentNo; - // body['EpisodeID'] = patient.episodeNo; + body['AppointmentNo'] = patient.appointmentNo; + body['EpisodeID'] = patient.episodeNo; await baseAppClient.post (GET_ORDER_PROCEDURE, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/models/patient/patiant_info_model.dart b/lib/models/patient/patiant_info_model.dart index 3547a73d..ceb84175 100644 --- a/lib/models/patient/patiant_info_model.dart +++ b/lib/models/patient/patiant_info_model.dart @@ -54,6 +54,7 @@ class PatiantInformtion { String genderDescription; String nursingStationName; String startTime; + String visitType; PatiantInformtion({ this.list, @@ -105,7 +106,9 @@ class PatiantInformtion { this.genderInt, this.isSigned, this.medicationOrders, - this.nationality,this.patientMRN + this.nationality, + this.patientMRN, + this.visitType, }); factory PatiantInformtion.fromJson(Map json) => @@ -159,6 +162,7 @@ class PatiantInformtion { medicationOrders :json['medicationOrders'], nationality :json['nationality']??json['NationalityNameN'], patientMRN :json['patientMRN'] ?? json['PatientMRN'], + visitType :json['visitType'] ?? json['visitType'], ); } diff --git a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart index f1f3c918..8a919709 100644 --- a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart +++ b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart @@ -157,6 +157,7 @@ class MyReferralDetailScreen extends StatelessWidget { } else { DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsgAccept); Navigator.pop(context); + Navigator.pop(context); } }, ), @@ -180,6 +181,7 @@ class MyReferralDetailScreen extends StatelessWidget { } else { DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsgReject); Navigator.pop(context); + Navigator.pop(context); } }, ), diff --git a/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart b/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart index 1f1c4079..aef7a161 100644 --- a/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart +++ b/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart @@ -43,7 +43,7 @@ class PatientHeaderWidgetNoAvatar extends StatelessWidget { ], ), AppText( - "NEW VISIT", + patient.visitType ?? "", fontWeight: FontWeight.bold, fontSize: SizeConfig.textMultiplier * 2.0, ), From c8e5a7eeef7551d873627f11c25e8cd5c058a321 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Feb 2021 17:00:50 +0200 Subject: [PATCH 3/7] fix PatientCard --- ios/Podfile.lock | 4 +- .../ClingoVideoCallViewController.swift | 446 +++++++++++++++ lib/screens/patients/patients_screen.dart | 527 +++--------------- lib/widgets/patients/PatientCard.dart | 244 ++++++++ 4 files changed, 774 insertions(+), 447 deletions(-) create mode 100644 ios/Runner/ClingoVideoCallViewController.swift create mode 100644 lib/widgets/patients/PatientCard.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index fb65ae25..9c86879d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -18,7 +18,7 @@ PODS: - Firebase/Messaging (6.33.0): - Firebase/CoreOnly - FirebaseMessaging (~> 4.7.0) - - firebase_core (0.5.2): + - firebase_core (0.5.3): - Firebase/CoreOnly (~> 6.33.0) - Flutter - firebase_core_web (0.1.0): @@ -250,7 +250,7 @@ SPEC CHECKSUMS: connectivity_macos: e2e9731b6b22dda39eb1b128f6969d574460e191 device_info: d7d233b645a32c40dfdc212de5cf646ca482f175 Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5 - firebase_core: 350ba329d1641211bc6183a3236893cafdacfea7 + firebase_core: 5d6a02f3d85acd5f8321c2d6d62877626a670659 firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 firebase_messaging: 0aea2cd5885b65e19ede58ee3507f485c992cc75 FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd diff --git a/ios/Runner/ClingoVideoCallViewController.swift b/ios/Runner/ClingoVideoCallViewController.swift new file mode 100644 index 00000000..b1bacdae --- /dev/null +++ b/ios/Runner/ClingoVideoCallViewController.swift @@ -0,0 +1,446 @@ +// +// ViewController.swift +// Lets-Build-OTPublisher +// +// Created by Roberto Perez Cubero on 11/08/16. +// Copyright © 2016 tokbox. All rights reserved. +// + +import UIKit +import OpenTok + +// The converted code is limited to 2 KB. +// Refill your credit or upgrade your plan to remove this limitation. +// +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +// +// ClingoVideoCallViewController.m +// Runner +// +// Created by Mohammad Aljammal & Elham on 23/6/20. +// Copyright © 2020 The Chromium Authors. All rights reserved. +// + + + + +import AVFoundation + +var dateFormatter: DateFormatter? + + +class ClingoVideoCallViewController : UIViewController, OTSessionDelegate, OTSubscriberDelegate, OTPublisherDelegate{ + + var kApiKey: String? + var kSessionId: String? + var kToken: String? + var session: OTSession? + var publisher: OTPublisher? + var subscriber: OTSubscriber? + var callDuration: String? + var warningDuration: String? + var appLang: String? + + + + @IBOutlet weak var localVideo: UIView! + @IBOutlet weak var remoteVideo: UIView! + @IBOutlet weak var controlButtons: UIView! + @IBOutlet weak var remoteVideoMutedIndicator: UIImageView! + @IBOutlet weak var localVideoMutedBg: UIImageView! + @IBOutlet weak var localVideoMutedIndicator: UIImageView! + @IBOutlet weak var remainingTimeLBL: UILabel! + @IBOutlet weak var pgView: UIProgressView! + var timer: Timer? + + + + + func viewDidLoad() { + super.viewDidLoad() + dateFormatter = DateFormatter() + + setupButtons() + askForMicrophonePermission() + requestCameraPermissionsIfNeeded() + hideVideoMuted() + setupSession() + // Do any additional setup after loading the view. + } + + func viewDidDisappear(_ animated: Bool) { + sessionDisconnect() + timer.invalidate() + timer = nil + PgView.hidden = true + remainingTimeLBL.hidden = true + } + +// MARK: -Microphone Camera and Permission Request + func askForMicrophonePermission() { + switch AVAudioSession.sharedInstance().recordPermission { + case AVAudioSessionRecordPermissionGranted: + break + case AVAudioSessionRecordPermissionDenied: + break + case AVAudioSessionRecordPermissionUndetermined: + // This is the initial state before a user has made any choice + // You can use this spot to request permission here if you want + AVAudioSession.sharedInstance().requestRecordPermission({ granted in + // Check for granted + }) + default: + break + } + } + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +func requestCameraPermissionsIfNeeded() { + + // check camera authorization status + let authStatus: AVAuthorizationStatus = AVCaptureDevice.authorizationStatus(for: .video) + switch authStatus { + case .authorized: break + // camera authorized + // do camera intensive stuff + case .notDetermined: + // request authorization + + AVCaptureDevice.requestAccess(for: .video, completionHandler: { granted in + DispatchQueue.main.async(execute: { + + if granted { + // do camera intensive stuff + } else { + self.notifyUserOfCameraAccessDenial() + } + }) + }) + case .restricted, .denied: + DispatchQueue.main.async(execute: { + self.notifyUserOfCameraAccessDenial() + }) + default: + break + } +} + +func notifyUserOfCameraAccessDenial() { + // display a useful message asking the user to grant permissions from within Settings > Privacy > Camera +} + +// MARK: - OpenTok methods +func showAlert(_ string: String?) { + // show alertview on main UI + DispatchQueue.main.async(execute: { + let alertVC = UIAlertController( + title: "OTError", + message: string, + preferredStyle: .alert) + self.present(alertVC, animated: true) + }) +} + +// MARK: - OpenTok methods +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +/// Asynchronously begins the session connect process. Some time later, we will +/// expect a delegate method to call us back with the results of this action. +func setupSession() { + //setup one time session + if session { + session = nil + } + session = OTSession( + apiKey: kApiKey, + sessionId: kSessionId, + delegate: self) + do { + try session.connect(withToken: kToken) + } catch { + } + +} + +/// Sets up an instance of OTPublisher to use with this session. OTPubilsher +/// binds to the device camera and microphone, and will provide A/V streams +/// to the OpenTok session. +func setupPublisher() { + let settings = OTPublisherSettings() + settings.name = UIDevice.current.name + publisher = OTPublisher(delegate: self, settings: settings) + + var error: OTError? = nil + session.publish(publisher, error: &error) + if error != nil { + showAlert(error?.localizedDescription()) + } + localVideo.addSubview(publisher.view) + publisher.view.frame = CGRect(x: localVideo.bounds.origin.x, y: localVideo.bounds.origin.y, width: localVideo.bounds.size.width, height: localVideo.bounds.size.height) + +} + +/// Cleans up the publisher and its view. At this point, the publisher should not +/// be attached to the session any more. +func cleanupPublisher() { + publisher?.view.removeFromSuperview() + publisher = nil + // this is a good place to notify the end-user that publishing has stopped. +} + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +/// Instantiates a subscriber for the given stream and asynchronously begins the +/// process to begin receiving A/V content for this stream. Unlike doPublish, +/// this method does not add the subscriber to the view hierarchy. Instead, we +/// add the subscriber only after it has connected and begins receiving data. +func setupSubscribe(_ stream: OTStream?) { + subscriber = OTSubscriber(stream: stream, delegate: self) + + var error: OTError? = nil + session.subscribe(subscriber, error: &error) + if error != nil { + showAlert(error?.localizedDescription()) + } +} + +/// Cleans the subscriber from the view hierarchy, if any. +/// NB: You do *not* have to call unsubscribe in your controller in response to +/// a streamDestroyed event. Any subscribers (or the publisher) for a stream will +/// be automatically removed from the session during cleanup of the stream. +func cleanupSubscriber() { + subscriber.view.removeFromSuperview() + subscriber = nil +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +// MARK: - OTSession delegate callbacks +func sessionDidConnect(_ session: OTSession?) { + if let sessionId = session?.sessionId { + print("sessionDidConnect (\(sessionId))") + } + + // Step 2: We have successfully connected, now instantiate a publisher and + // begin pushing A/V streams into OpenTok. + setupPublisher() +} + +func sessionDidDisconnect(_ session: OTSession?) { + var alertMessage: String? = nil + if let sessionId = session?.sessionId { + alertMessage = "Session disconnected: (\(sessionId))" + } + print("sessionDidDisconnect (\(alertMessage ?? ""))") +} + +func session( + _ mySession: OTSession?, + streamCreated stream: OTStream? +) { + if let streamId = stream?.streamId { + print("session streamCreated (\(streamId))") + } + + if nil == subscriber { + setupSubscribe(stream) + } +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +func session( + _ session: OTSession?, + streamDestroyed stream: OTStream? +) { + if let streamId = stream?.streamId { + print("session streamDestroyed (\(streamId))") + } + + if subscriber.stream.streamId == stream?.streamId { + cleanupSubscriber() + } +} + +func session( + _ session: OTSession?, + connectionCreated connection: OTConnection? +) { + startTimer(callDuration, warningDuration) + if let connectionId = connection?.connectionId { + print("session connectionCreated (\(connectionId))") + } +} + +func session( + _ session: OTSession?, + connectionDestroyed connection: OTConnection? +) { + if let connectionId = connection?.connectionId { + print("session connectionDestroyed (\(connectionId))") + } + if subscriber.stream.connection.connectionId == connection?.connectionId { + cleanupSubscriber() + } + sessionDisconnect() +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +func session( + _ session: ARSession, + didFailWithError error: Error +) { + print("didFailWithError: (\(error))") +} + +func session(_ session: OTSession, receivedSignalType type: String?, from connection: OTConnection?, with string: String?) { + print("\(session)") +} + +func sessionDisconnect() { + if session && session.sessionConnectionStatus == OTSessionConnectionStatusConnected { + print("disconnecting....") + session.disconnect(nil) + dismiss(animated: true) + return + } + dismiss(animated: true) +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +//do { +// print( +// "subscriberDidConnectToStream (\(subscriber.stream.connection.connectionId))") +// assert(subscriber == subscriber) +// remoteVideo.addSubview(subscriber.view) +// subscriber.view.frame = remoteVideo.bounds +// // self.remoteVideo=_publisher.view; +//} + +- +do { + print( + "subscriber \(subscriber.stream.streamId) didFailWithError \(error)") +} + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +// MARK: - OTPublisher delegate callbacks +func publisher( + _ publisher: OTPublisherKit?, + streamCreated stream: OTStream? +) { + print("Publishing") +} + +func publisher( + _ publisher: OTPublisherKit?, + streamDestroyed stream: OTStream? +) { + if subscriber.stream.streamId == stream?.streamId { + cleanupSubscriber() + } + + cleanupPublisher() +} + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +func publisher( + _ publisher: OTPublisherKit?, + didFailWithError error: OTError? +) { + if let error = error { + print("publisher didFailWithError \(error)") + } + cleanupPublisher() +} + +// MARK: - Ui Handel +func hideVideoMuted() { + remoteVideoMutedIndicator.hidden = true + localVideoMutedBg.hidden = true + localVideoMutedIndicator.hidden = true +} + +func setupButtons() { + perform(#selector(hideControlButtons), with: nil, afterDelay: 3) + let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(remoteVideoTapped(_:))) + view.addGestureRecognizer(tapGestureRecognizer) + view.isUserInteractionEnabled = true +} + + // Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +@objc func hideControlButtons() { + controlButtons.hidden = true +} + +func remoteVideoTapped(_ recognizer: UITapGestureRecognizer?) { + if controlButtons.hidden { + controlButtons.hidden = false + perform(#selector(hideControlButtons), with: nil, afterDelay: 3) + } +} + +func resetHideButtonsTimer() { + ClingoVideoCallViewController.cancelPreviousPerformRequests(withTarget: self) + perform(#selector(hideControlButtons), with: nil, afterDelay: 3) +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +@IBAction func didClickMuteButton(_ sender: UIButton) { + sender.isSelected = !sender.isSelected + publisher.publishAudio = !sender.isSelected + resetHideButtonsTimer() +} + +@IBAction func didClickSpeakerButton(_ sender: UIButton) { + sender.isSelected = !sender.isSelected + subscriber.subscribeToAudio = !sender.isSelected + resetHideButtonsTimer() +} + +@IBAction func didClickVideoMuteButton(_ sender: UIButton) { + sender.isSelected = !sender.isSelected + if publisher.publishVideo { + publisher.publishVideo = false + } else { + publisher.publishVideo = true + } + localVideo.hidden = sender.isSelected + localVideoMutedBg.hidden = !sender.isSelected + localVideoMutedIndicator.hidden = !sender.isSelected + resetHideButtonsTimer() +} + + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +@IBAction func didClickSwitchCameraButton(_ sender: UIButton) { + sender.isSelected = !sender.isSelected + if sender.isSelected { + publisher.cameraPosition = RPCameraPosition(rawValue: AVCaptureDevice.Position.back.rawValue) + } else { + publisher.cameraPosition = RPCameraPosition(rawValue: AVCaptureDevice.Position.front.rawValue) + } + resetHideButtonsTimer() +} + +@IBAction func hangUp(_ sender: UIButton) { + sessionDisconnect() +} + +// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ +func startTimer(_ callDuration: String?, _ warningTime: String?) { +} + + func -currentTime as? Date! +do { + let startCallTime = Date() + dateFormatter.dateFormat = "yyyyMMddHHmmss" + let resultString = dateFormatter.string(from: startCallTime) + let date = dateFormatter.date(from: resultString) + return date +} + + +} diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 50b89148..733a1b9c 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -1,12 +1,3 @@ -/* - *@author: Amjad Amireh Merge to Elham rababah - *@Date:27/4/2020 - *@param: - *@return:PatientsScreen - - *@desc: - */ - import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; @@ -19,6 +10,7 @@ import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; @@ -93,14 +85,6 @@ class _PatientsScreenState extends State { } } -/* - *@author: Amjad Amireh - *@Date:5/5/2020 - *@param: - *@return:Convert time from Milesecond to date with time - - *@desc: - */ convertDate(String str) { String timeConvert; const start = "/Date("; @@ -129,14 +113,6 @@ class _PatientsScreenState extends State { return newDateformat.toString(); } -/* - *@author: Amjad Amireh - *@Date:5/5/2020 - *@param: - *@return:Convert time from Milesecond to date - - *@desc: - */ convertDateFormat(String str) { String timeConvert; const start = "/Date("; @@ -156,24 +132,6 @@ class _PatientsScreenState extends State { return newDate.toString(); } - convertDateFormat2(String str) { - String timeConvert; - const start = "/Date("; - const end = "+0300)"; - - final startIndex = str.indexOf(start); - final endIndex = str.indexOf(end, startIndex + start.length); - - var date = new DateTime.fromMillisecondsSinceEpoch( - int.parse(str.substring(startIndex + start.length, endIndex))); - String newDate = date.year.toString() + - "/" + - date.month.toString().padLeft(2, '0') + - "/" + - date.day.toString().padLeft(2, '0'); - - return newDate.toString(); - } filterBooking(String str) { this.responseModelList = this.responseModelList2; @@ -228,14 +186,6 @@ class _PatientsScreenState extends State { return TranslationBase.of(context).all; } -/* - *@author: Amjad Amireh Modified New design - *@Date:21/5/2020 - *@param: - *@return:PatientsScreen - - *@desc: - */ @override Widget build(BuildContext context) { _locations = [ @@ -401,322 +351,19 @@ class _PatientsScreenState extends State { children: responseModelList .map((PatiantInformtion item) { - return Container( - decoration: - myBoxDecoration(), - child: InkWell( - child: Row( - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: < - Widget>[ - Padding( - padding: EdgeInsets - .only( - left: - 12.0), - child: - Container( - decoration: - BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color.fromRGBO( - 0, - 0, - 0, - 0.08), - offset: Offset(0.0, - 5.0), - blurRadius: - 16.0) - ], - borderRadius: - BorderRadius.all( - Radius.circular(35.0)), - color: Color( - 0xffCCCCCC), - ), - width: 70, - height: 70, - child: Icon( - item.genderDescription == - "Male" - ? DoctorApp - .male - : DoctorApp - .female_icon, - size: 70, - color: Colors - .white, - ), - ), - ), - ], - ), - - SizedBox( - width: 10, - ), - - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Column( - children: [ - SizedBox( - height: - 10.0, - ), - AppText( - item.firstName + - " " + - item.lastName, - fontSize: - 2.0 * SizeConfig.textMultiplier, - fontWeight: - FontWeight.bold, - backGroundcolor: - Colors.white, - ), - SizedBox( - height: - 5, - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: < - Widget>[ - Wrap( - children: [ - AppText( - TranslationBase.of(context).fileNo, - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - backGroundcolor: Colors.white, - ), - AppText( - item.patientId.toString(), - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - backGroundcolor: Colors.white, - ), - SizedBox( - width: 10, - ), - ], - ), - SizedBox( - height: - 2.5, - ), - Container( - child: - AppText( - TranslationBase.of(context).nationality + " : " + (item.nationalityName ?? item.nationality), - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - backGroundcolor: Colors.white, - ), - margin: - EdgeInsets.only(right: projectsProvider.isArabic ? 0 : 10, left: projectsProvider.isArabic ? 10 : 0), - ), - SizedBox( - width: - 10, - ), - SizedBox( - height: - 15.5, - ), - SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient" - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - height: 15, - width: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(25), - color: HexColor("#20A169"), - ), - child: AppText( - item.startTime, - color: Colors.white, - fontSize: 1.5 * SizeConfig.textMultiplier, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, - ), - ), - SizedBox( - width: 3.5, - ), - Container( - child: AppText( - convertDateFormat2(item.appointmentDate.toString()), - fontSize: 1.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - ), - SizedBox( - height: 0.5, - ) - ], - ) - : SizedBox( - height: 5, - ), - ], - ), - Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - // mainAxisAlignment: - // MainAxisAlignment - // .spaceBetween, - children: < - Widget>[ - SizedBox( - height: - 0.5, - ), - SizedBox( - height: - 0, - ), - Wrap( - children: [ - AppText( - TranslationBase - .of( - context) - .age2, - fontSize: 1.8 * - SizeConfig - .textMultiplier, - fontWeight: FontWeight - .bold, - backGroundcolor: Colors - .white, - ), - AppText( - " ${DateUtils.getAgeByBirthday(item.dateofBirth, context)}", - - fontSize: 1.8 * - SizeConfig - .textMultiplier, - fontWeight: FontWeight - .w300, - backGroundcolor: Colors - .white, - ), - SizedBox( - width: 10, - ), - ], - ), - SizedBox( - height: - 2.5, - ), - - Wrap( - children: [ - AppText( - TranslationBase.of(context).gender2, - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - backGroundcolor: Colors.white, - ), - AppText( - item.gender.toString() == '1' ? 'Male' : 'Female', - fontSize: 1.8 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - backGroundcolor: Colors.white, - ), - ], - ), - SizedBox( - height: - 8, - ), - SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient" - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - height: 15, - width: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(25), - color: HexColor("#20A169"), - ), - child: AppText( - item.startTime, - color: Colors.white, - fontSize: 1.5 * SizeConfig.textMultiplier, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, - ), - ), - SizedBox( - width: 3.5, - ), - Container( - child: AppText( - convertDateFormat2(item.appointmentDate.toString()), - fontSize: 1.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - ), - SizedBox( - height: 25.5, - ), - ], - ) - : SizedBox( - height: 15, - ), - ], - ), - ), - ], - ), - ], - ), - ), - // Divider(color: Colors.grey) - ], - ), - onTap: () { - Navigator.of(context) - .pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": item, - "patientType":patientType, - "from" : patient.getFrom, - "to" : patient.getTo, - }); - }, - ), - ); + return PatientCard(patientInfo: item, + patientType: patientType, + onTap: () { + Navigator.of(context) + .pushNamed( + PATIENTS_PROFILE, + arguments: { + "patient": item, + "patientType":patientType, + "from" : patient.getFrom, + "to" : patient.getTo, + }); + },); }).toList(), ) : Center( @@ -754,88 +401,78 @@ class _PatientsScreenState extends State { } Widget _locationBar(BuildContext _context) { - return Expanded( - child: Container( - height: MediaQuery.of(context).size.height * 0.0619, - width: SizeConfig.screenWidth * 0.94, - decoration: BoxDecoration( - color: Color(0Xffffffff), - borderRadius: BorderRadius.circular(12.5), - border: Border.all( - width: 0.5, - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: _locations.map((item) { - bool _isActive = _locations[_activeLocation] == item ? true : false; - return Column(mainAxisSize: MainAxisSize.min, children: [ - InkWell( - child: Center( - child: Expanded( - child: Container( - height: MediaQuery.of(context).size.height * 0.058, - width: SizeConfig.screenWidth * 0.2334, - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(12.5), - topRight: Radius.circular(12.5), - topLeft: Radius.circular(9.5), - bottomLeft: Radius.circular(9.5)), - color: - _isActive ? HexColor("#B8382B") : Colors.white, - ), - child: Center( - child: Text( - item, - style: TextStyle( - fontSize: 12, - color: _isActive - ? Colors.white - : Colors.black, //Colors.black, - - fontWeight: FontWeight.normal, - ), - ), - )), - ), - ), - onTap: () { - filterBooking(item.toString()); - - setState(() { - _activeLocation = _locations.indexOf(item); - }); - }), - _isActive - ? Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(10), - topRight: Radius.circular(10)), - color: Colors.white), - alignment: Alignment.center, - height: 1, - width: SizeConfig.screenWidth * 0.23, - ) - : Container() - ]); - }).toList(), + return Container( + height: MediaQuery.of(context).size.height * 0.0619, + width: SizeConfig.screenWidth * 0.94, + decoration: BoxDecoration( + color: Color(0Xffffffff), + borderRadius: BorderRadius.circular(12.5), + border: Border.all( + width: 0.5, ), ), - ); - } + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: _locations.map((item) { + bool _isActive = _locations[_activeLocation] == item ? true : false; + return Column(mainAxisSize: MainAxisSize.min, children: [ + InkWell( + child: Center( + child: Container( + height: MediaQuery.of(context).size.height * 0.058, + width: SizeConfig.screenWidth * 0.2334, + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(12.5), + topRight: Radius.circular(12.5), + topLeft: Radius.circular(9.5), + bottomLeft: Radius.circular(9.5)), + color: + _isActive ? HexColor("#B8382B") : Colors.white, + ), + child: Center( + child: Text( + item, + style: TextStyle( + fontSize: 12, + color: _isActive + ? Colors.white + : Colors.black, //Colors.black, + + fontWeight: FontWeight.normal, + ), + ), + )), + ), + onTap: () { + filterBooking(item.toString()); - myBoxDecoration() { - return BoxDecoration( - border: Border( - bottom: BorderSide( - color: Color(0xffCCCCCC), - width: 0.5, - ), + setState(() { + _activeLocation = _locations.indexOf(item); + }); + }), + _isActive + ? Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomRight: Radius.circular(10), + topRight: Radius.circular(10)), + color: Colors.white), + alignment: Alignment.center, + height: 1, + width: SizeConfig.screenWidth * 0.23, + ) + : Container() + ]); + }).toList(), ), ); } + + } + + + diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart new file mode 100644 index 00000000..5ccae18f --- /dev/null +++ b/lib/widgets/patients/PatientCard.dart @@ -0,0 +1,244 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class PatientCard extends StatelessWidget { + final PatiantInformtion patientInfo; + final Function onTap; + final String patientType; + const PatientCard({Key key, this.patientInfo, this.onTap, this.patientType}) : super(key: key); + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(10), + decoration: myBoxDecoration(), + margin: EdgeInsets.only(bottom: 12), + child: InkWell( + child: Row( + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + children: < + Widget>[ + Padding( + padding: EdgeInsets + .only( + left: + 12.0), + child: + Container( + decoration: + BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color.fromRGBO( + 0, + 0, + 0, + 0.08), + offset: Offset(0.0, + 5.0), + blurRadius: + 16.0) + ], + borderRadius: + BorderRadius.all( + Radius.circular(35.0)), + color: Color( + 0xffCCCCCC), + ), + width: 70, + height: 70, + child: Icon( + patientInfo.genderDescription == + "Male" + ? DoctorApp + .male + : DoctorApp + .female_icon, + size: 70, + color: Colors + .white, + ), + ), + ), + ], + ), + + SizedBox( + width: 10, + ), + Expanded( + child: Column( + crossAxisAlignment:CrossAxisAlignment.start, + children: [ + AppText( + patientInfo.firstName + + " " + + patientInfo.lastName, + fontSize: + 2.0 * SizeConfig.textMultiplier, + fontWeight: + FontWeight.bold, + backGroundcolor: + Colors.white, + ), + SizedBox(height: 12,), + Table( + border: TableBorder.symmetric( + // inside: BorderSide(width: 2.0, color: Colors.white), + ), + // defaultVerticalAlignment:TableCellVerticalAlignment.middle , + children: [ + TableRow(children: [ + Container( + child: RichText( + text: new TextSpan( + style: new TextStyle( + fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black), + children: [ + new TextSpan( + text: TranslationBase.of(context).fileNo, + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 2.2 * SizeConfig.textMultiplier)), + new TextSpan(text: patientInfo.patientId.toString()), + ],),), + ), + Container( + child: RichText( + text: new TextSpan( + style: new TextStyle( + fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black), + children: [ + new TextSpan( + text: TranslationBase.of(context).age+ " : ", + style: TextStyle(fontWeight: FontWeight.w700, )), + new TextSpan(text: "${DateUtils.getAgeByBirthday(patientInfo.dateofBirth, context)}"), + ],),), + ), + ] + ), + TableRow(children: [ + SizedBox(height: 5,), + SizedBox(height: 5,) + ]), + TableRow(children: [ + Container( + child: RichText( + text: new TextSpan( + style: new TextStyle( + fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black), + children: [ + new TextSpan( + text: TranslationBase.of(context).nationality + " : ", + style: TextStyle(fontWeight: FontWeight.w700, fontSize: 2.2 * SizeConfig.textMultiplier)), + new TextSpan(text: (patientInfo.nationalityName ?? patientInfo.nationality)), + ],),), + ), + + + Container( + child: RichText( + text: new TextSpan( + style: new TextStyle( + fontSize: 2.0 * SizeConfig.textMultiplier, color: Colors.black), + children: [ + new TextSpan( + text: TranslationBase.of(context).gender + " : ", + style: TextStyle(fontWeight: FontWeight.w700, )), + new TextSpan(text: patientInfo.gender.toString() == '1' ? 'Male' : 'Female'), + ],),), + ), + ] + ), + + ], + ), + if(SERVICES_PATIANT2[int.parse(patientType)] == "List_MyOutPatient") + Container( + + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + height: 15, + width: 60, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: HexColor("#20A169"), + ), + child: AppText( + patientInfo.startTime, + color: Colors.white, + fontSize: 1.5 * SizeConfig.textMultiplier, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + ), + ), + SizedBox( + width: 3.5, + ), + Container( + child: AppText( + convertDateFormat2(patientInfo.appointmentDate.toString()), + fontSize: 1.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + ), + SizedBox( + height: 0.5, + ) + ], + ), + margin: EdgeInsets.only(top: 8,), + ) + ], + ), + ), + + // Divider(color: Colors.grey) + ], + ), + onTap: onTap, + ), + ); + } + + convertDateFormat2(String str) { + String timeConvert; + const start = "/Date("; + const end = "+0300)"; + + final startIndex = str.indexOf(start); + final endIndex = str.indexOf(end, startIndex + start.length); + + var date = new DateTime.fromMillisecondsSinceEpoch( + int.parse(str.substring(startIndex + start.length, endIndex))); + String newDate = date.year.toString() + + "/" + + date.month.toString().padLeft(2, '0') + + "/" + + date.day.toString().padLeft(2, '0'); + + return newDate.toString(); + } + + myBoxDecoration() { + return BoxDecoration( + border: Border( + bottom: BorderSide( + color: Color(0xffCCCCCC), + width: 0.5, + ), + ), + ); + } +} \ No newline at end of file From dcac240ae4e44c76309e57ad9ec388bbe300a030 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Feb 2021 17:15:05 +0200 Subject: [PATCH 4/7] remove files --- .../ClingoVideoCallViewController.swift | 446 ------------------ 1 file changed, 446 deletions(-) delete mode 100644 ios/Runner/ClingoVideoCallViewController.swift diff --git a/ios/Runner/ClingoVideoCallViewController.swift b/ios/Runner/ClingoVideoCallViewController.swift deleted file mode 100644 index b1bacdae..00000000 --- a/ios/Runner/ClingoVideoCallViewController.swift +++ /dev/null @@ -1,446 +0,0 @@ -// -// ViewController.swift -// Lets-Build-OTPublisher -// -// Created by Roberto Perez Cubero on 11/08/16. -// Copyright © 2016 tokbox. All rights reserved. -// - -import UIKit -import OpenTok - -// The converted code is limited to 2 KB. -// Refill your credit or upgrade your plan to remove this limitation. -// -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -// -// ClingoVideoCallViewController.m -// Runner -// -// Created by Mohammad Aljammal & Elham on 23/6/20. -// Copyright © 2020 The Chromium Authors. All rights reserved. -// - - - - -import AVFoundation - -var dateFormatter: DateFormatter? - - -class ClingoVideoCallViewController : UIViewController, OTSessionDelegate, OTSubscriberDelegate, OTPublisherDelegate{ - - var kApiKey: String? - var kSessionId: String? - var kToken: String? - var session: OTSession? - var publisher: OTPublisher? - var subscriber: OTSubscriber? - var callDuration: String? - var warningDuration: String? - var appLang: String? - - - - @IBOutlet weak var localVideo: UIView! - @IBOutlet weak var remoteVideo: UIView! - @IBOutlet weak var controlButtons: UIView! - @IBOutlet weak var remoteVideoMutedIndicator: UIImageView! - @IBOutlet weak var localVideoMutedBg: UIImageView! - @IBOutlet weak var localVideoMutedIndicator: UIImageView! - @IBOutlet weak var remainingTimeLBL: UILabel! - @IBOutlet weak var pgView: UIProgressView! - var timer: Timer? - - - - - func viewDidLoad() { - super.viewDidLoad() - dateFormatter = DateFormatter() - - setupButtons() - askForMicrophonePermission() - requestCameraPermissionsIfNeeded() - hideVideoMuted() - setupSession() - // Do any additional setup after loading the view. - } - - func viewDidDisappear(_ animated: Bool) { - sessionDisconnect() - timer.invalidate() - timer = nil - PgView.hidden = true - remainingTimeLBL.hidden = true - } - -// MARK: -Microphone Camera and Permission Request - func askForMicrophonePermission() { - switch AVAudioSession.sharedInstance().recordPermission { - case AVAudioSessionRecordPermissionGranted: - break - case AVAudioSessionRecordPermissionDenied: - break - case AVAudioSessionRecordPermissionUndetermined: - // This is the initial state before a user has made any choice - // You can use this spot to request permission here if you want - AVAudioSession.sharedInstance().requestRecordPermission({ granted in - // Check for granted - }) - default: - break - } - } - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -func requestCameraPermissionsIfNeeded() { - - // check camera authorization status - let authStatus: AVAuthorizationStatus = AVCaptureDevice.authorizationStatus(for: .video) - switch authStatus { - case .authorized: break - // camera authorized - // do camera intensive stuff - case .notDetermined: - // request authorization - - AVCaptureDevice.requestAccess(for: .video, completionHandler: { granted in - DispatchQueue.main.async(execute: { - - if granted { - // do camera intensive stuff - } else { - self.notifyUserOfCameraAccessDenial() - } - }) - }) - case .restricted, .denied: - DispatchQueue.main.async(execute: { - self.notifyUserOfCameraAccessDenial() - }) - default: - break - } -} - -func notifyUserOfCameraAccessDenial() { - // display a useful message asking the user to grant permissions from within Settings > Privacy > Camera -} - -// MARK: - OpenTok methods -func showAlert(_ string: String?) { - // show alertview on main UI - DispatchQueue.main.async(execute: { - let alertVC = UIAlertController( - title: "OTError", - message: string, - preferredStyle: .alert) - self.present(alertVC, animated: true) - }) -} - -// MARK: - OpenTok methods -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -/// Asynchronously begins the session connect process. Some time later, we will -/// expect a delegate method to call us back with the results of this action. -func setupSession() { - //setup one time session - if session { - session = nil - } - session = OTSession( - apiKey: kApiKey, - sessionId: kSessionId, - delegate: self) - do { - try session.connect(withToken: kToken) - } catch { - } - -} - -/// Sets up an instance of OTPublisher to use with this session. OTPubilsher -/// binds to the device camera and microphone, and will provide A/V streams -/// to the OpenTok session. -func setupPublisher() { - let settings = OTPublisherSettings() - settings.name = UIDevice.current.name - publisher = OTPublisher(delegate: self, settings: settings) - - var error: OTError? = nil - session.publish(publisher, error: &error) - if error != nil { - showAlert(error?.localizedDescription()) - } - localVideo.addSubview(publisher.view) - publisher.view.frame = CGRect(x: localVideo.bounds.origin.x, y: localVideo.bounds.origin.y, width: localVideo.bounds.size.width, height: localVideo.bounds.size.height) - -} - -/// Cleans up the publisher and its view. At this point, the publisher should not -/// be attached to the session any more. -func cleanupPublisher() { - publisher?.view.removeFromSuperview() - publisher = nil - // this is a good place to notify the end-user that publishing has stopped. -} - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -/// Instantiates a subscriber for the given stream and asynchronously begins the -/// process to begin receiving A/V content for this stream. Unlike doPublish, -/// this method does not add the subscriber to the view hierarchy. Instead, we -/// add the subscriber only after it has connected and begins receiving data. -func setupSubscribe(_ stream: OTStream?) { - subscriber = OTSubscriber(stream: stream, delegate: self) - - var error: OTError? = nil - session.subscribe(subscriber, error: &error) - if error != nil { - showAlert(error?.localizedDescription()) - } -} - -/// Cleans the subscriber from the view hierarchy, if any. -/// NB: You do *not* have to call unsubscribe in your controller in response to -/// a streamDestroyed event. Any subscribers (or the publisher) for a stream will -/// be automatically removed from the session during cleanup of the stream. -func cleanupSubscriber() { - subscriber.view.removeFromSuperview() - subscriber = nil -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -// MARK: - OTSession delegate callbacks -func sessionDidConnect(_ session: OTSession?) { - if let sessionId = session?.sessionId { - print("sessionDidConnect (\(sessionId))") - } - - // Step 2: We have successfully connected, now instantiate a publisher and - // begin pushing A/V streams into OpenTok. - setupPublisher() -} - -func sessionDidDisconnect(_ session: OTSession?) { - var alertMessage: String? = nil - if let sessionId = session?.sessionId { - alertMessage = "Session disconnected: (\(sessionId))" - } - print("sessionDidDisconnect (\(alertMessage ?? ""))") -} - -func session( - _ mySession: OTSession?, - streamCreated stream: OTStream? -) { - if let streamId = stream?.streamId { - print("session streamCreated (\(streamId))") - } - - if nil == subscriber { - setupSubscribe(stream) - } -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -func session( - _ session: OTSession?, - streamDestroyed stream: OTStream? -) { - if let streamId = stream?.streamId { - print("session streamDestroyed (\(streamId))") - } - - if subscriber.stream.streamId == stream?.streamId { - cleanupSubscriber() - } -} - -func session( - _ session: OTSession?, - connectionCreated connection: OTConnection? -) { - startTimer(callDuration, warningDuration) - if let connectionId = connection?.connectionId { - print("session connectionCreated (\(connectionId))") - } -} - -func session( - _ session: OTSession?, - connectionDestroyed connection: OTConnection? -) { - if let connectionId = connection?.connectionId { - print("session connectionDestroyed (\(connectionId))") - } - if subscriber.stream.connection.connectionId == connection?.connectionId { - cleanupSubscriber() - } - sessionDisconnect() -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -func session( - _ session: ARSession, - didFailWithError error: Error -) { - print("didFailWithError: (\(error))") -} - -func session(_ session: OTSession, receivedSignalType type: String?, from connection: OTConnection?, with string: String?) { - print("\(session)") -} - -func sessionDisconnect() { - if session && session.sessionConnectionStatus == OTSessionConnectionStatusConnected { - print("disconnecting....") - session.disconnect(nil) - dismiss(animated: true) - return - } - dismiss(animated: true) -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -//do { -// print( -// "subscriberDidConnectToStream (\(subscriber.stream.connection.connectionId))") -// assert(subscriber == subscriber) -// remoteVideo.addSubview(subscriber.view) -// subscriber.view.frame = remoteVideo.bounds -// // self.remoteVideo=_publisher.view; -//} - -- -do { - print( - "subscriber \(subscriber.stream.streamId) didFailWithError \(error)") -} - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -// MARK: - OTPublisher delegate callbacks -func publisher( - _ publisher: OTPublisherKit?, - streamCreated stream: OTStream? -) { - print("Publishing") -} - -func publisher( - _ publisher: OTPublisherKit?, - streamDestroyed stream: OTStream? -) { - if subscriber.stream.streamId == stream?.streamId { - cleanupSubscriber() - } - - cleanupPublisher() -} - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -func publisher( - _ publisher: OTPublisherKit?, - didFailWithError error: OTError? -) { - if let error = error { - print("publisher didFailWithError \(error)") - } - cleanupPublisher() -} - -// MARK: - Ui Handel -func hideVideoMuted() { - remoteVideoMutedIndicator.hidden = true - localVideoMutedBg.hidden = true - localVideoMutedIndicator.hidden = true -} - -func setupButtons() { - perform(#selector(hideControlButtons), with: nil, afterDelay: 3) - let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(remoteVideoTapped(_:))) - view.addGestureRecognizer(tapGestureRecognizer) - view.isUserInteractionEnabled = true -} - - // Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -@objc func hideControlButtons() { - controlButtons.hidden = true -} - -func remoteVideoTapped(_ recognizer: UITapGestureRecognizer?) { - if controlButtons.hidden { - controlButtons.hidden = false - perform(#selector(hideControlButtons), with: nil, afterDelay: 3) - } -} - -func resetHideButtonsTimer() { - ClingoVideoCallViewController.cancelPreviousPerformRequests(withTarget: self) - perform(#selector(hideControlButtons), with: nil, afterDelay: 3) -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -@IBAction func didClickMuteButton(_ sender: UIButton) { - sender.isSelected = !sender.isSelected - publisher.publishAudio = !sender.isSelected - resetHideButtonsTimer() -} - -@IBAction func didClickSpeakerButton(_ sender: UIButton) { - sender.isSelected = !sender.isSelected - subscriber.subscribeToAudio = !sender.isSelected - resetHideButtonsTimer() -} - -@IBAction func didClickVideoMuteButton(_ sender: UIButton) { - sender.isSelected = !sender.isSelected - if publisher.publishVideo { - publisher.publishVideo = false - } else { - publisher.publishVideo = true - } - localVideo.hidden = sender.isSelected - localVideoMutedBg.hidden = !sender.isSelected - localVideoMutedIndicator.hidden = !sender.isSelected - resetHideButtonsTimer() -} - - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -@IBAction func didClickSwitchCameraButton(_ sender: UIButton) { - sender.isSelected = !sender.isSelected - if sender.isSelected { - publisher.cameraPosition = RPCameraPosition(rawValue: AVCaptureDevice.Position.back.rawValue) - } else { - publisher.cameraPosition = RPCameraPosition(rawValue: AVCaptureDevice.Position.front.rawValue) - } - resetHideButtonsTimer() -} - -@IBAction func hangUp(_ sender: UIButton) { - sessionDisconnect() -} - -// Converted to Swift 5.2 by Swiftify v5.2.26743 - https://swiftify.com/ -func startTimer(_ callDuration: String?, _ warningTime: String?) { -} - - func -currentTime as? Date! -do { - let startCallTime = Date() - dateFormatter.dateFormat = "yyyyMMddHHmmss" - let resultString = dateFormatter.string(from: startCallTime) - let date = dateFormatter.date(from: resultString) - return date -} - - -} From d4ea9019061a1d17050b50a6cecb35dd906f8ee8 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Feb 2021 17:35:55 +0200 Subject: [PATCH 5/7] bugs fix --- lib/screens/prescription/add_prescription_form.dart | 4 +++- lib/screens/prescription/prescription_screen.dart | 10 +++++++++- lib/screens/prescription/update_prescription_form.dart | 4 +++- lib/screens/procedures/procedure_screen.dart | 8 ++++---- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index b1e79ae2..0b9750fc 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -338,7 +338,9 @@ class _PrescriptionFormWidgetState extends State { 0.550, child: TextFields( inputFormatters: [ - LengthLimitingTextInputFormatter(4) + LengthLimitingTextInputFormatter(4), + WhitelistingTextInputFormatter + .digitsOnly ], hintText: TranslationBase.of(context) .strength, diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index 11541e39..216ffa05 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -375,7 +375,7 @@ class _NewPrescriptionScreenState extends State { FontWeight .w700, fontSize: - 17.0, + 15.0, ), Expanded( child: AppText( @@ -417,6 +417,14 @@ class _NewPrescriptionScreenState extends State { ), Row( children: [ + AppText( + 'Doctor Remarks : ', + fontWeight: + FontWeight + .w700, + fontSize: + 13.0, + ), Expanded( child: Container( diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 714659ac..885386a6 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -214,7 +214,9 @@ class _UpdatePrescriptionFormState extends State { 0.55, child: TextFields( inputFormatters: [ - LengthLimitingTextInputFormatter(4) + LengthLimitingTextInputFormatter(4), + WhitelistingTextInputFormatter + .digitsOnly ], hintText: widget.doseStreangth, fontSize: 15.0, diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index dd5c2952..1e225ce9 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -281,7 +281,7 @@ class _ProcedureScreenState extends State { FontWeight .w700, fontSize: - 15.0, + 13.0, ), AppText( model @@ -292,7 +292,7 @@ class _ProcedureScreenState extends State { .procedureId .toString(), fontSize: - 13.0, + 12.0, ), SizedBox( width: 12.0, @@ -305,7 +305,7 @@ class _ProcedureScreenState extends State { FontWeight .w700, fontSize: - 14.0, + 13.0, ), Expanded( child: @@ -315,7 +315,7 @@ class _ProcedureScreenState extends State { ? 'Routine' : 'Urgent', fontSize: - 13.0, + 11.5, color: Color( 0xFFB9382C), ), From 28370e7492831c8fa8c9a93ce69262bb5f8bf326 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Feb 2021 19:49:41 +0200 Subject: [PATCH 6/7] fix bugs --- .../model/procedure/get_procedure_req_model.dart | 8 ++++---- lib/core/service/procedure_service.dart | 9 +++++---- lib/core/viewModel/procedure_View_model.dart | 7 ++++--- lib/screens/procedures/add-procedure-form.dart | 12 +++++++++++- .../entity_list_checkbox_search_widget.dart | 7 +++++++ lib/screens/procedures/update-procedure.dart | 12 +++++++++++- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/lib/core/model/procedure/get_procedure_req_model.dart b/lib/core/model/procedure/get_procedure_req_model.dart index 1769f43f..6202a520 100644 --- a/lib/core/model/procedure/get_procedure_req_model.dart +++ b/lib/core/model/procedure/get_procedure_req_model.dart @@ -4,7 +4,7 @@ class GetProcedureReqModel { int pageSize; int pageIndex; List search; - dynamic categoryId; + dynamic category; String vidaAuthTokenID; GetProcedureReqModel( @@ -13,7 +13,7 @@ class GetProcedureReqModel { this.pageSize, this.pageIndex, this.search, - this.categoryId, + this.category, this.vidaAuthTokenID}); GetProcedureReqModel.fromJson(Map json) { @@ -22,7 +22,7 @@ class GetProcedureReqModel { pageSize = json['PageSize']; pageIndex = json['PageIndex']; search = json['Search'].cast(); - categoryId = json['CategoryId']; + category = json['Category']; vidaAuthTokenID = json['VidaAuthTokenID']; } @@ -33,7 +33,7 @@ class GetProcedureReqModel { data['PageSize'] = this.pageSize; data['PageIndex'] = this.pageIndex; data['Search'] = this.search; - data['CategoryId'] = this.categoryId; + data['Category'] = this.category; data['VidaAuthTokenID'] = this.vidaAuthTokenID; return data; } diff --git a/lib/core/service/procedure_service.dart b/lib/core/service/procedure_service.dart index 515e0e50..1ec996fb 100644 --- a/lib/core/service/procedure_service.dart +++ b/lib/core/service/procedure_service.dart @@ -73,13 +73,14 @@ class ProcedureService extends BaseService { }, body: Map()); } - Future getProcedureCategory({String categoryName}) async { + Future getProcedureCategory({String categoryName, String categoryID}) async { _getProcedureCategoriseReqModel = GetProcedureReqModel( - search: [categoryName], + search: [""], patientMRN: 0, - pageIndex: 1, + pageIndex: 0, clinicId: 0, - pageSize: 300, + pageSize: 0, + category: categoryID, ); hasError = false; _categoriesList.clear(); diff --git a/lib/core/viewModel/procedure_View_model.dart b/lib/core/viewModel/procedure_View_model.dart index 440724b7..a753052c 100644 --- a/lib/core/viewModel/procedure_View_model.dart +++ b/lib/core/viewModel/procedure_View_model.dart @@ -29,11 +29,12 @@ class ProcedureViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getProcedureCategory({String categoryName}) async { + Future getProcedureCategory({String categoryName, String categoryID}) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); - setState(ViewState.BusyLocal); - await _procedureService.getProcedureCategory(categoryName: categoryName); + setState(ViewState.Busy); + await _procedureService.getProcedureCategory( + categoryName: categoryName, categoryID: categoryID); if (_procedureService.hasError) { error = _procedureService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/procedures/add-procedure-form.dart b/lib/screens/procedures/add-procedure-form.dart index 0d34da6b..11eadbb0 100644 --- a/lib/screens/procedures/add-procedure-form.dart +++ b/lib/screens/procedures/add-procedure-form.dart @@ -147,7 +147,17 @@ class _AddSelectedProcedureState extends State { selectedCategory = selectedValue; model.getProcedureCategory( categoryName: selectedCategory[ - 'categoryName']); + 'categoryName'], + categoryID: selectedCategory[ + 'categoryId'] <= + 9 + ? "0" + + selectedCategory[ + 'categoryId'] + .toString() + : selectedCategory[ + 'categoryId'] + .toString()); }); }, ); diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 7036bc0d..a29100f5 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -37,6 +37,13 @@ class EntityListCheckboxSearchWidget extends StatefulWidget { class _EntityListCheckboxSearchWidgetState extends State { + int selectedType; + setSelectedType(int val) { + setState(() { + selectedType = val; + }); + } + List items = List(); @override diff --git a/lib/screens/procedures/update-procedure.dart b/lib/screens/procedures/update-procedure.dart index 9239527c..2c502334 100644 --- a/lib/screens/procedures/update-procedure.dart +++ b/lib/screens/procedures/update-procedure.dart @@ -135,7 +135,17 @@ class _UpdateProcedureWidgetState extends State { model.getProcedureCategory( categoryName: selectedCategory[ - 'categoryName']); + 'categoryName'], + categoryID: selectedCategory[ + 'categoryId'] <= + 9 + ? "0" + + selectedCategory[ + 'categoryId'] + .toString() + : selectedCategory[ + 'categoryId'] + .toString()); }); }, ); From 60e416e63272d4f2bfe3fc7f6bb38f3d7b4eafb5 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 11 Feb 2021 11:34:32 +0200 Subject: [PATCH 7/7] add done button in all pages user keyboard and hide the keyboard when the user click on background --- ios/Podfile.lock | 2 +- .../patients/patient_search_screen.dart | 697 ++++----- .../prescription/add_prescription_form.dart | 1135 +++++++------- .../update_prescription_form.dart | 905 +++++------ .../reschedule-leaves/reschedule_leave.dart | 1329 +++++++++-------- lib/screens/sick-leave/sick_leave.dart | 575 +++---- lib/util/helpers.dart | 5 + lib/widgets/shared/TextFields.dart | 2 +- lib/widgets/shared/app_text_form_field.dart | 10 +- pubspec.lock | 6 +- 10 files changed, 2359 insertions(+), 2307 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9c86879d..46d7599e 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -292,4 +292,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69 -COCOAPODS: 1.10.0.rc.1 +COCOAPODS: 1.10.1 diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 0b13bd2d..994048a7 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -46,6 +46,10 @@ class _PatientSearchScreenState extends State { bool isFormSubmitted = false; + FocusNode _nodeText1 = FocusNode(); + FocusNode _nodeText2 = FocusNode(); + FocusNode _nodeText3 = FocusNode(); + var _patientSearchFormValues = PatientModel( FirstName: "0", MiddleName: "0", @@ -110,374 +114,383 @@ class _PatientSearchScreenState extends State { @override Widget build(BuildContext context) { projectsProvider = Provider.of(context); - return AppScaffold( - appBarTitle: TranslationBase.of(context).searchPatient, - body: ListView( - children: [ - RoundedContainer( - child: Column( - children: [ - Column( - children: [ - Container( - child: Icon( - DoctorApp.search_patient_1, - size: 100, - color: Colors.black, - ), - margin: EdgeInsets.only(top: 10), - ), - Padding( - padding: const EdgeInsets.only(top: 12.0), - child: AppText( - TranslationBase.of(context) - .searchPatientImageCaptionTitle - .toUpperCase(), - fontWeight: FontWeight.bold, - fontSize: SizeConfig.heightMultiplier * 2.5, + return GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( + appBarTitle: TranslationBase.of(context).searchPatient, + body: ListView( + children: [ + RoundedContainer( + child: Column( + children: [ + Column( + children: [ + Container( + child: Icon( + DoctorApp.search_patient_1, + size: 100, + color: Colors.black, + ), + margin: EdgeInsets.only(top: 10), ), - ), - Padding( - padding: const EdgeInsets.only(top: 5.0), - child: AppText( - TranslationBase.of(context) - .searchPatientImageCaptionBody, - fontSize: SizeConfig.heightMultiplier * 2, + Padding( + padding: const EdgeInsets.only(top: 12.0), + child: AppText( + TranslationBase.of(context) + .searchPatientImageCaptionTitle + .toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: SizeConfig.heightMultiplier * 2.5, + ), ), - ) - ], - ), - Container( - padding: EdgeInsets.all(15), - width: SizeConfig.screenWidth * 1, - child: Form( - key: _formKey, - autovalidate: _autoValidate, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 5, + Padding( + padding: const EdgeInsets.only(top: 5.0), + child: AppText( + TranslationBase.of(context) + .searchPatientImageCaptionBody, + fontSize: SizeConfig.heightMultiplier * 2, ), - Container( - height: 40.0, - decoration: ShapeDecoration( - shape: RoundedRectangleBorder( - side: BorderSide( - width: 1.0, - style: BorderStyle.solid, - color: HexColor("#CCCCCC")), - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - ), + ) + ], + ), + Container( + padding: EdgeInsets.all(15), + width: SizeConfig.screenWidth * 1, + child: Form( + key: _formKey, + autovalidate: _autoValidate, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 5, ), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: _selectedType, - iconSize: 25, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return PATIENT_TYPE.map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - !projectsProvider.isArabic - ? AppText( - item['text'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - ) - : AppText( - item['text_ar'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - ), - ], + Container( + height: 40.0, + decoration: ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide( + width: 1.0, + style: BorderStyle.solid, + color: HexColor("#CCCCCC")), + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + ), + ), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: _selectedType, + iconSize: 25, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return PATIENT_TYPE.map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + !projectsProvider.isArabic + ? AppText( + item['text'], + fontSize: SizeConfig + .textMultiplier * + 2.1, + ) + : AppText( + item['text_ar'], + fontSize: SizeConfig + .textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (String newValue) => { + setState(() { + _selectedType = newValue; + selectedPatientType = + int.parse(_selectedType); + }) + }, + items: PATIENT_TYPE.map((item) { + !projectsProvider.isArabic + ? itemText = item['text'] + : itemText = item['text_ar']; + return DropdownMenuItem( + child: Text( + itemText, + textAlign: TextAlign.end, + ), + value: item['val'], ); - }).toList(); - }, - onChanged: (String newValue) => { - setState(() { - _selectedType = newValue; - selectedPatientType = - int.parse(_selectedType); - }) - }, - items: PATIENT_TYPE.map((item) { - !projectsProvider.isArabic - ? itemText = item['text'] - : itemText = item['text_ar']; - return DropdownMenuItem( - child: Text( - itemText, - textAlign: TextAlign.end, - ), - value: item['val'], - ); - }).toList(), - )), - ), - ], + }).toList(), + )), + ), + ], + ), ), ), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( - labelText: - TranslationBase.of(context).firstName, - borderColor: Colors.white, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues.setFirstName = - "0" - : _patientSearchFormValues.setFirstName = - value; + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( + labelText: + TranslationBase.of(context).firstName, + borderColor: Colors.white, + onSaved: (value) { + value == null || value == '' + ? _patientSearchFormValues.setFirstName = + "0" + : _patientSearchFormValues.setFirstName = + value; - if (value != null && - value.toString().trim().isEmpty) { - _patientSearchFormValues.setFirstName = "0"; - } - }, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( + if (value != null && + value.toString().trim().isEmpty) { + _patientSearchFormValues.setFirstName = "0"; + } + }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_LETTERS), + ), + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( + labelText: + TranslationBase.of(context).middleName, + borderColor: Colors.white, + onSaved: (value) { + value == null || value == '' + ? _patientSearchFormValues.setMiddleName = + "0" + : _patientSearchFormValues.setMiddleName = + value; + if (value != null && value + .toString() + .trim() + .isEmpty) { + _patientSearchFormValues.setMiddleName = + "0"; + } + }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_LETTERS), + ), + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( + labelText: TranslationBase.of(context).lastName, + borderColor: Colors.white, + onSaved: (value) { + value == null || value == '' + ? _patientSearchFormValues.setLastName = + "0" + : _patientSearchFormValues.setLastName = + value; + if (value != null && value + .toString() + .trim() + .isEmpty) { + _patientSearchFormValues.setLastName = "0"; + } + }, + inputFormatter: ONLY_LETTERS), + ), + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( labelText: - TranslationBase.of(context).middleName, - borderColor: Colors.white, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues.setMiddleName = - "0" - : _patientSearchFormValues.setMiddleName = - value; - if (value != null && value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues.setMiddleName = - "0"; - } - }, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( - labelText: TranslationBase.of(context).lastName, + TranslationBase.of(context).phoneNumber, borderColor: Colors.white, + textInputType: TextInputType.number, + textInputAction: TextInputAction.done, + inputFormatter: ONLY_NUMBERS, + focusNode: _nodeText1, onSaved: (value) { value == null || value == '' - ? _patientSearchFormValues.setLastName = - "0" - : _patientSearchFormValues.setLastName = - value; + ? _patientSearchFormValues + .setPatientMobileNumber = "0" + : _patientSearchFormValues + .setPatientMobileNumber = value; + if (value != null && value .toString() .trim() .isEmpty) { - _patientSearchFormValues.setLastName = "0"; + _patientSearchFormValues + .setPatientMobileNumber = "0"; } }, - inputFormatter: ONLY_LETTERS), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( - labelText: - TranslationBase.of(context).phoneNumber, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - onSaved: (value) { - value == null || value == '' - ? _patientSearchFormValues - .setPatientMobileNumber = "0" - : _patientSearchFormValues - .setPatientMobileNumber = value; - - if (value != null && value - .toString() - .trim() - .isEmpty) { - _patientSearchFormValues - .setPatientMobileNumber = "0"; - } - }, + ), ), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( + labelText: + TranslationBase.of(context).patientID, + borderColor: Colors.white, + textInputType: TextInputType.number, + inputFormatter: ONLY_NUMBERS, + focusNode: _nodeText2, + onSaved: (value) { + value == null || value=='' + ? _patientSearchFormValues.setPatientID = + 0 + : _patientSearchFormValues.setPatientID = + int.parse(value); + if (value != null && value + .trim() + .toString() + .isEmpty) { + _patientSearchFormValues.setPatientID = 0; + } + }), + ), + SizedBox( + height: 10, + ), + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.only(top: 5), + child: AppTextFormField( labelText: - TranslationBase.of(context).patientID, + TranslationBase.of(context).patientFile, borderColor: Colors.white, textInputType: TextInputType.number, + focusNode: _nodeText3, inputFormatter: ONLY_NUMBERS, - onSaved: (value) { - value == null || value=='' - ? _patientSearchFormValues.setPatientID = - 0 - : _patientSearchFormValues.setPatientID = - int.parse(value); - if (value != null && value - .trim() - .toString() - .isEmpty) { - _patientSearchFormValues.setPatientID = 0; - } - }), - ), - SizedBox( - height: 10, - ), - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.only(top: 5), - child: AppTextFormField( - labelText: - TranslationBase.of(context).patientFile, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - onSaved: (value) {}, + onSaved: (value) {}, + ), ), - ), - (!(_selectedType == '2' || _selectedType == '4')) - ? DynamicElements(_patientSearchFormValues, isFormSubmitted) - : SizedBox( - height: 0, - ), - SizedBox( - height: 10, - ), - SizedBox( - height: 10, - ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - height: 25, - width: 25, - child: Checkbox( - value: onlyArrived, - checkColor: HexColor("#2A930A"), - activeColor: Colors.white, - onChanged: (bool newValue) { - setState(() { - onlyArrived = newValue; - }); - }), - ), - SizedBox( - width: 12, - ), - AppText( - TranslationBase.of(context) - .onlyArrivedPatient, - fontSize: SizeConfig.textMultiplier * 2), - ])), - SizedBox( - height: 10, - ), - ], + (!(_selectedType == '2' || _selectedType == '4')) + ? DynamicElements(_patientSearchFormValues, isFormSubmitted) + : SizedBox( + height: 0, + ), + SizedBox( + height: 10, + ), + SizedBox( + height: 10, + ), + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + height: 25, + width: 25, + child: Checkbox( + value: onlyArrived, + checkColor: HexColor("#2A930A"), + activeColor: Colors.white, + onChanged: (bool newValue) { + setState(() { + onlyArrived = newValue; + }); + }), + ), + SizedBox( + width: 12, + ), + AppText( + TranslationBase.of(context) + .onlyArrivedPatient, + fontSize: SizeConfig.textMultiplier * 2), + ])), + SizedBox( + height: 10, + ), + ], + ), ), - ), - ) - ], + ) + ], + ), ), - ), - Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context).search, - onPressed: () { - _validateInputs(); - }, - ), - ], + Container( + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context).search, + onPressed: () { + _validateInputs(); + }, + ), + ], + ), ), - ), - ], - )); + ], + )), + ); } } diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 0b9750fc..0f681c4d 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -209,368 +209,334 @@ class _PrescriptionFormWidgetState extends State { ) => NetworkBaseView( baseViewModel: model, - child: DraggableScrollableSheet( - initialChildSize: 0.90, - maxChildSize: 0.90, - minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { - return SingleChildScrollView( - child: Container( - height: 1010, - child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - AppText( - TranslationBase.of(context).medicines.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: spaceBetweenTextFileds, - ), - Container( - child: Form( - key: formKey, - child: Column( - //mainAxisAlignment: MainAxisAlignment.end, - children: [ - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.allMedicationList != null - ? () { - setState(() { - _selectedMedication = null; - }); - } - : null, - child: _selectedMedication == null - ? AutoCompleteTextField< - GetMedicationResponseModel>( - decoration: - textFieldSelectorDecoration( - TranslationBase.of(context) - .searchMedicineNameHere, - _selectedMedication != null - ? _selectedMedication - .genericName - : null, - true, - ), - itemSubmitted: (item) => setState( - () => - _selectedMedication = item), - key: key, - suggestions: - model.allMedicationList, - itemBuilder: (context, - suggestion) => - new Padding( - child: Texts(suggestion + child: GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: DraggableScrollableSheet( + initialChildSize: 0.90, + maxChildSize: 0.90, + minChildSize: 0.9, + builder: (BuildContext context, ScrollController scrollController) { + return SingleChildScrollView( + child: Container( + height: 1010, + child: Padding( + padding: + EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + //mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + AppText( + TranslationBase.of(context).medicines.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: spaceBetweenTextFileds, + ), + Container( + child: Form( + key: formKey, + child: Column( + //mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.allMedicationList != null + ? () { + Helpers.hideKeyboard(context); + setState(() { + _selectedMedication = null; + }); + } + : null, + child: _selectedMedication == null + ? AutoCompleteTextField< + GetMedicationResponseModel>( + decoration: + textFieldSelectorDecoration( + TranslationBase.of(context) + .searchMedicineNameHere, + _selectedMedication != null + ? _selectedMedication + .genericName + : null, + true, + ), + itemSubmitted: (item) => setState( + () => + _selectedMedication = item), + key: key, + suggestions: + model.allMedicationList, + itemBuilder: (context, + suggestion) => + new Padding( + child: Texts(suggestion + .description + + '/' + + suggestion.genericName), + padding: + EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.genericName + .toLowerCase() + .startsWith( + input.toLowerCase()) || + suggestion.description + .toLowerCase() + .startsWith( + input.toLowerCase()) || + suggestion.keywords + .toLowerCase() + .startsWith( + input.toLowerCase()), + ) + : TextField( + decoration: + textFieldSelectorDecoration( + TranslationBase.of(context) + .searchMedicineNameHere, + _selectedMedication != null + ? _selectedMedication .description + - '/' + - suggestion.genericName), - padding: - EdgeInsets.all(8.0)), - itemSorter: (a, b) => 1, - itemFilter: (suggestion, input) => - suggestion.genericName - .toLowerCase() - .startsWith( - input.toLowerCase()) || - suggestion.description - .toLowerCase() - .startsWith( - input.toLowerCase()) || - suggestion.keywords - .toLowerCase() - .startsWith( - input.toLowerCase()), - ) - : TextField( - decoration: - textFieldSelectorDecoration( - TranslationBase.of(context) - .searchMedicineNameHere, - _selectedMedication != null - ? _selectedMedication - .description + - ('${_selectedMedication.genericName}') - : null, - true, + ('${_selectedMedication.genericName}') + : null, + true, + ), + enabled: false, ), - enabled: false, - ), + ), ), - ), - SizedBox( - height: spaceBetweenTextFileds, - ), - Container( - child: Row( - children: [ - AppText('Order Type'), - Radio( - activeColor: Color(0xFFB9382C), - value: 1, - groupValue: selectedType, - onChanged: (value) { - setSelectedType(value); - }, - ), - Text('Regular'), - ], + SizedBox( + height: spaceBetweenTextFileds, ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - width: double.infinity, - child: Row( - children: [ - Container( - width: - MediaQuery.of(context).size.width * - 0.550, - child: TextFields( - inputFormatters: [ - LengthLimitingTextInputFormatter(4), - WhitelistingTextInputFormatter - .digitsOnly - ], - hintText: TranslationBase.of(context) - .strength, - controller: strengthController, - keyboardType: TextInputType.number, - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 4) { - DrAppToastMsg.showErrorToast( - "Only 4 Digits allowed for strength"); - } + Container( + child: Row( + children: [ + AppText('Order Type'), + Radio( + activeColor: Color(0xFFB9382C), + value: 1, + groupValue: selectedType, + onChanged: (value) { + setSelectedType(value); }, - // validator: (value) { - // if (value.isEmpty && - // strengthController.text.length > - // 4) - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }, ), - ), - SizedBox( - width: 10.0, - ), - Container( - width: - MediaQuery.of(context).size.width * - 0.350, - child: InkWell( - onTap: model.medicationStrengthList != - null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: model - .medicationStrengthList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - units = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'UNIT Type', - units != null - ? units['nameEn'] - : null, - true), - enabled: false, + Text('Regular'), + ], + ), + ), + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + width: double.infinity, + child: Row( + children: [ + Container( + width: + MediaQuery.of(context).size.width * + 0.550, + child: TextFields( + inputFormatters: [ + LengthLimitingTextInputFormatter(4), + WhitelistingTextInputFormatter + .digitsOnly + ], + hintText: TranslationBase.of(context) + .strength, + controller: strengthController, + keyboardType: TextInputType.number, + onChanged: (String value) { + setState(() { + strengthChar = value.length; + }); + if (strengthChar >= 4) { + DrAppToastMsg.showErrorToast( + "Only 4 Digits allowed for strength"); + } + }, + // validator: (value) { + // if (value.isEmpty && + // strengthController.text.length > + // 4) + // return TranslationBase.of(context) + // .emptyMessage; + // else + // return null; + // }, ), ), - ), - ], - ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.medicationRouteList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: model.medicationRouteList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - }); - if (route == null) { - helpers.showErrorToast( - 'plase fill'); - } - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).route, - route != null - ? route['nameEn'] - : null, - true), - enabled: false, + SizedBox( + width: 10.0, + ), + Container( + width: + MediaQuery.of(context).size.width * + 0.350, + child: InkWell( + onTap: model.medicationStrengthList != + null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: model + .medicationStrengthList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + units = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: + textFieldSelectorDecoration( + 'UNIT Type', + units != null + ? units['nameEn'] + : null, + true), + enabled: false, + ), + ), + ), + ], ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.medicationFrequencyList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationFrequencyList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - frequency = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).frequency, - frequency != null - ? frequency['nameEn'] - : null, - true), - enabled: false, + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.medicationRouteList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: model.medicationRouteList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + }); + if (route == null) { + helpers.showErrorToast( + 'plase fill'); + } + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).route, + route != null + ? route['nameEn'] + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.medicationDoseTimeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationDoseTimeList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).doseTime, - doseTime != null - ? doseTime['nameEn'] - : null, - true), - enabled: false, + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.medicationFrequencyList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationFrequencyList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + frequency = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).frequency, + frequency != null + ? frequency['nameEn'] + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - - if (model.patientAssessmentList.isNotEmpty) + SizedBox(height: spaceBetweenTextFileds), Container( height: screenSize.height * 0.070, child: InkWell( - onTap: indicationList != null + onTap: model.medicationDoseTimeList != null ? () { - ListSelectDialog dialog = + Helpers.hideKeyboard(context); + ListSelectDialog dialog = ListSelectDialog( - list: indicationList, - attributeName: 'name', + list: + model.medicationDoseTimeList, + attributeName: 'nameEn', attributeValueId: 'id', okText: TranslationBase.of(context) .ok, okFunction: (selectedValue) { setState(() { - indication = selectedValue; + doseTime = selectedValue; }); }, ); showDialog( barrierDismissible: false, context: context, - builder: - (BuildContext context) { + builder: (BuildContext context) { return dialog; }, ); @@ -578,262 +544,309 @@ class _PrescriptionFormWidgetState extends State { : null, child: TextField( decoration: textFieldSelectorDecoration( - model.patientAssessmentList[0] - .icdCode10ID - .toString(), - indication != null - ? indication['name'] + TranslationBase.of(context).doseTime, + doseTime != null + ? doseTime['nameEn'] : null, true), - enabled: true, - readOnly: true, + enabled: false, ), ), ), - //model.patientAssessmentList.forEach((element) { }). - // Column( - // children: model.patientAssessmentList - // .map((element) { - // return Container( - // height: screenSize.height * 0.070, - // child: InkWell( - // onTap: indicationList != null - // ? () { - // ListSelectDialog dialog = - // ListSelectDialog( - // list: indicationList, - // attributeName: 'name', - // attributeValueId: 'id', - // okText: TranslationBase.of( - // context) - // .ok, - // okFunction: (selectedValue) { - // setState(() { - // indication = - // selectedValue; - // }); - // }, - // ); - // showDialog( - // barrierDismissible: false, - // context: context, - // builder: - // (BuildContext context) { - // return dialog; - // }, - // ); - // } - // : null, - // child: TextField( - // decoration: - // textFieldSelectorDecoration( - // element.icdCode10ID - // .toString(), - // indication != null - // ? indication['name'] - // : null, - // true), - // enabled: true, - // readOnly: true, - // ), - // ), - // ); - // }).toList(), - // ), + SizedBox(height: spaceBetweenTextFileds), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: () => - selectDate(context, widget.model), - child: TextField( - decoration: - Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).date, - selectedDate != null - ? "${DateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + if (model.patientAssessmentList.isNotEmpty) + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: indicationList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: indicationList, + attributeName: 'name', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + indication = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + model.patientAssessmentList[0] + .icdCode10ID + .toString(), + indication != null + ? indication['name'] : null, - true, - suffixIcon: Icon( - Icons.calendar_today, - color: Colors.black, - )), - enabled: false, + true), + enabled: true, + readOnly: true, + ), + ), + ), + //model.patientAssessmentList.forEach((element) { }). + // Column( + // children: model.patientAssessmentList + // .map((element) { + // return Container( + // height: screenSize.height * 0.070, + // child: InkWell( + // onTap: indicationList != null + // ? () { + // ListSelectDialog dialog = + // ListSelectDialog( + // list: indicationList, + // attributeName: 'name', + // attributeValueId: 'id', + // okText: TranslationBase.of( + // context) + // .ok, + // okFunction: (selectedValue) { + // setState(() { + // indication = + // selectedValue; + // }); + // }, + // ); + // showDialog( + // barrierDismissible: false, + // context: context, + // builder: + // (BuildContext context) { + // return dialog; + // }, + // ); + // } + // : null, + // child: TextField( + // decoration: + // textFieldSelectorDecoration( + // element.icdCode10ID + // .toString(), + // indication != null + // ? indication['name'] + // : null, + // true), + // enabled: true, + // readOnly: true, + // ), + // ), + // ); + // }).toList(), + // ), + + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: () => + selectDate(context, widget.model), + child: TextField( + decoration: + Helpers.textFieldSelectorDecoration( + TranslationBase.of(context).date, + selectedDate != null + ? "${DateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), + enabled: false, + ), ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - height: screenSize.height * 0.070, - child: InkWell( - onTap: model.medicationDurationList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationDurationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - duration = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).duration, - duration != null - ? duration['nameEn'] - : null, - true), - enabled: false, + SizedBox(height: spaceBetweenTextFileds), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.medicationDurationList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationDurationList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + duration = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).duration, + duration != null + ? duration['nameEn'] + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - child: TextFields( - maxLines: 6, - minLines: 4, - hintText: - TranslationBase.of(context).instruction, - controller: instructionController, - //keyboardType: TextInputType.number, - validator: (value) { - if (value.isEmpty) - return TranslationBase.of(context) - .emptyMessage; - else - return null; - }, + SizedBox(height: spaceBetweenTextFileds), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + maxLines: 6, + minLines: 4, + hintText: + TranslationBase.of(context).instruction, + controller: instructionController, + //keyboardType: TextInputType.number, + validator: (value) { + if (value.isEmpty) + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }, + ), ), - ), - SizedBox(height: spaceBetweenTextFileds), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: TranslationBase.of(context) - .addMedication, - onPressed: () { - // formKey.currentState.save(); - // Navigator.pop(context); - // openDrugToDrug(); - if (route == null || - frequency == null || - doseTime == null || - duration == null || - selectedDate == null || - units == null) { - DrAppToastMsg.showErrorToast( - "Please Fill All Fields"); - return; - } + SizedBox(height: spaceBetweenTextFileds), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: TranslationBase.of(context) + .addMedication, + onPressed: () { + // formKey.currentState.save(); + // Navigator.pop(context); + // openDrugToDrug(); + if (route == null || + frequency == null || + doseTime == null || + duration == null || + selectedDate == null || + units == null) { + DrAppToastMsg.showErrorToast( + "Please Fill All Fields"); + return; + } - if (formKey.currentState.validate()) { - Navigator.pop(context); - { - // var x = model - // .patientAssessmentList - // .map((value) => - // value.icdCode10ID) - // .toList() - // .join(','); - postProcedure( - icdCode: model - .patientAssessmentList[ - 0] - .icdCode10ID - .isEmpty - ? "test" - : model - .patientAssessmentList[ - 0] - .icdCode10ID - .toString(), - // icdCode: model + if (formKey.currentState.validate()) { + Navigator.pop(context); + { + // var x = model // .patientAssessmentList - // .map((value) => value - // .icdCode10ID - // .trim()) + // .map((value) => + // value.icdCode10ID) // .toList() - // .join(' '), - dose: strengthController.text, - doseUnit: - units['id'].toString(), - patient: widget.patient, - doseTimeIn: - doseTime['id'].toString(), - model: widget.model, - duration: - duration['id'].toString(), - frequency: - frequency['id'].toString(), - route: route['id'].toString(), - drugId: _selectedMedication - .itemId - .toString(), - strength: - strengthController.text, - indication: - indicationController.text, - instruction: - instructionController.text, - doseTime: selectedDate, - ); + // .join(','); + postProcedure( + icdCode: model + .patientAssessmentList[ + 0] + .icdCode10ID + .isEmpty + ? "test" + : model + .patientAssessmentList[ + 0] + .icdCode10ID + .toString(), + // icdCode: model + // .patientAssessmentList + // .map((value) => value + // .icdCode10ID + // .trim()) + // .toList() + // .join(' '), + dose: strengthController.text, + doseUnit: + units['id'].toString(), + patient: widget.patient, + doseTimeIn: + doseTime['id'].toString(), + model: widget.model, + duration: + duration['id'].toString(), + frequency: + frequency['id'].toString(), + route: route['id'].toString(), + drugId: _selectedMedication + .itemId + .toString(), + strength: + strengthController.text, + indication: + indicationController.text, + instruction: + instructionController.text, + doseTime: selectedDate, + ); + } } - } - { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => - // NewPrescriptionScreen()), - // ); - } - }, - ), - ], + { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // NewPrescriptionScreen()), + // ); + } + }, + ), + ], + ), ), - ), - ], + ], + ), ), ), - ), - ], + ], + ), ), ), - ), - ); - }), + ); + }), + ), ), ); } selectDate(BuildContext context, PrescriptionViewModel model) async { + Helpers.hideKeyboard(context); DateTime selectedDate; selectedDate = DateTime.now(); final DateTime picked = await showDatePicker( diff --git a/lib/screens/prescription/update_prescription_form.dart b/lib/screens/prescription/update_prescription_form.dart index 885386a6..0f48f5c1 100644 --- a/lib/screens/prescription/update_prescription_form.dart +++ b/lib/screens/prescription/update_prescription_form.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; @@ -103,469 +104,479 @@ class _UpdatePrescriptionFormState extends State { (BuildContext context, MedicineViewModel model, Widget child) => NetworkBaseView( baseViewModel: model, - child: DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.99, - minChildSize: 0.6, - builder: - (BuildContext context, ScrollController scrollController) { - return Container( - height: MediaQuery.of(context).size.height * 1.3, - child: Form( - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: 20.0, vertical: 12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - widget.drugName.toUpperCase(), - fontWeight: FontWeight.w900, - ), - SizedBox( - height: 10.0, - ), - Column( - children: [ - // Container( - // height: MediaQuery.of(context).size.height * - // 0.070, - // child: InkWell( - // onTap: model.allMedicationList != null - // ? () { - // setState(() { - // newSelectedMedication = null; - // }); - // } - // : null, - // child: newSelectedMedication == null - // ? AutoCompleteTextField< - // GetMedicationResponseModel>( - // decoration: - // textFieldSelectorDecoration( - // widget.drugNameGeneric, - // newSelectedMedication != null - // ? newSelectedMedication - // .genericName - // : null, - // true, - // ), - // itemSubmitted: (item) => setState( - // () => newSelectedMedication = - // item), - // key: key, - // suggestions: - // model.allMedicationList, - // itemBuilder: (context, - // suggestion) => - // new Padding( - // child: Texts(suggestion - // .description + - // '/' + - // suggestion.genericName), - // padding: - // EdgeInsets.all(8.0)), - // itemSorter: (a, b) => 1, - // itemFilter: (suggestion, input) => - // suggestion.genericName - // .toLowerCase() - // .startsWith( - // input.toLowerCase()) || - // suggestion.description - // .toLowerCase() - // .startsWith( - // input.toLowerCase()) || - // suggestion.keywords - // .toLowerCase() - // .startsWith( - // input.toLowerCase()), - // ) - // : TextField( - // decoration: - // textFieldSelectorDecoration( - // TranslationBase.of(context) - // .searchMedicineNameHere, - // newSelectedMedication != null - // ? newSelectedMedication - // .description + - // ('${newSelectedMedication.genericName}') - // : null, - // true, - // ), - // enabled: false, - // ), - // ), - // ), - // SizedBox( - // height: 12, - // ), - Container( - height: MediaQuery.of(context).size.height * - 0.060, - width: double.infinity, - child: Row( - children: [ - Container( - width: - MediaQuery.of(context).size.width * - 0.4900, - height: - MediaQuery.of(context).size.height * - 0.55, - child: TextFields( - inputFormatters: [ - LengthLimitingTextInputFormatter(4), - WhitelistingTextInputFormatter - .digitsOnly - ], - hintText: widget.doseStreangth, - fontSize: 15.0, - controller: strengthController, - keyboardType: TextInputType.number, - onChanged: (String value) { - setState(() { - strengthChar = value.length; - }); - if (strengthChar >= 4) { - DrAppToastMsg.showErrorToast( - "Only 4 Digits allowed for strength"); - } - }, - // validator: (value) { - // if (value.isEmpty && - // strengthController.text.length > - // 4) - // return TranslationBase.of(context) - // .emptyMessage; - // else - // return null; - // }, + child: GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.99, + minChildSize: 0.6, + builder: + (BuildContext context, ScrollController scrollController) { + return Container( + height: MediaQuery.of(context).size.height * 1.3, + child: Form( + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 20.0, vertical: 12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.drugName.toUpperCase(), + fontWeight: FontWeight.w900, + ), + SizedBox( + height: 10.0, + ), + Column( + children: [ + // Container( + // height: MediaQuery.of(context).size.height * + // 0.070, + // child: InkWell( + // onTap: model.allMedicationList != null + // ? () { + // setState(() { + // newSelectedMedication = null; + // }); + // } + // : null, + // child: newSelectedMedication == null + // ? AutoCompleteTextField< + // GetMedicationResponseModel>( + // decoration: + // textFieldSelectorDecoration( + // widget.drugNameGeneric, + // newSelectedMedication != null + // ? newSelectedMedication + // .genericName + // : null, + // true, + // ), + // itemSubmitted: (item) => setState( + // () => newSelectedMedication = + // item), + // key: key, + // suggestions: + // model.allMedicationList, + // itemBuilder: (context, + // suggestion) => + // new Padding( + // child: Texts(suggestion + // .description + + // '/' + + // suggestion.genericName), + // padding: + // EdgeInsets.all(8.0)), + // itemSorter: (a, b) => 1, + // itemFilter: (suggestion, input) => + // suggestion.genericName + // .toLowerCase() + // .startsWith( + // input.toLowerCase()) || + // suggestion.description + // .toLowerCase() + // .startsWith( + // input.toLowerCase()) || + // suggestion.keywords + // .toLowerCase() + // .startsWith( + // input.toLowerCase()), + // ) + // : TextField( + // decoration: + // textFieldSelectorDecoration( + // TranslationBase.of(context) + // .searchMedicineNameHere, + // newSelectedMedication != null + // ? newSelectedMedication + // .description + + // ('${newSelectedMedication.genericName}') + // : null, + // true, + // ), + // enabled: false, + // ), + // ), + // ), + // SizedBox( + // height: 12, + // ), + Container( + height: MediaQuery.of(context).size.height * + 0.060, + width: double.infinity, + child: Row( + children: [ + Container( + width: + MediaQuery.of(context).size.width * + 0.4900, + height: + MediaQuery.of(context).size.height * + 0.55, + child: TextFields( + inputFormatters: [ + LengthLimitingTextInputFormatter(4), + WhitelistingTextInputFormatter + .digitsOnly + ], + hintText: widget.doseStreangth, + fontSize: 15.0, + controller: strengthController, + keyboardType: TextInputType.number, + onChanged: (String value) { + setState(() { + strengthChar = value.length; + }); + if (strengthChar >= 4) { + DrAppToastMsg.showErrorToast( + "Only 4 Digits allowed for strength"); + } + }, + // validator: (value) { + // if (value.isEmpty && + // strengthController.text.length > + // 4) + // return TranslationBase.of(context) + // .emptyMessage; + // else + // return null; + // }, + ), ), - ), - SizedBox( - width: 10.0, - ), - Container( - width: - MediaQuery.of(context).size.width * - 0.3700, - child: InkWell( - onTap: model.medicationStrengthList != - null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: model - .medicationStrengthList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - units = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: - (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: - textFieldSelectorDecoration( - 'UNIT Type', - units != null - ? units['nameEn'] - : null, - true), - enabled: false, + SizedBox( + width: 10.0, + ), + Container( + width: + MediaQuery.of(context).size.width * + 0.3700, + child: InkWell( + onTap: model.medicationStrengthList != + null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: model + .medicationStrengthList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: TranslationBase.of( + context) + .ok, + okFunction: + (selectedValue) { + setState(() { + units = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: + (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: + textFieldSelectorDecoration( + 'UNIT Type', + units != null + ? units['nameEn'] + : null, + true), + enabled: false, + ), ), ), + ], + ), + ), + SizedBox( + height: 12, + ), + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationRouteList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: model.medicationRouteList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + route = selectedValue; + }); + if (route == null) { + route = route['id']; + } + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + 'Route', + route != null + ? route['nameEn'] + : null, + true), + enabled: false, ), - ], + ), + ), + SizedBox( + height: 12.0, ), - ), - SizedBox( - height: 12, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationRouteList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: model.medicationRouteList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - route = selectedValue; - }); - if (route == null) { - route = route['id']; - } - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - 'Route', - route != null - ? route['nameEn'] - : null, - true), - enabled: false, + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationDoseTimeList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationDoseTimeList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + doseTime = selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).doseTime, + doseTime != null + ? doseTime['nameEn'] + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationDoseTimeList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationDoseTimeList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - doseTime = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).doseTime, - doseTime != null - ? doseTime['nameEn'] - : null, - true), - enabled: false, + SizedBox( + height: 12.0, + ), + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationFrequencyList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationFrequencyList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + frequencyUpdate = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).frequency, + frequencyUpdate != null + ? frequencyUpdate['nameEn'] + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationFrequencyList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationFrequencyList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - frequencyUpdate = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).frequency, - frequencyUpdate != null - ? frequencyUpdate['nameEn'] - : null, - true), - enabled: false, + SizedBox( + height: 12.0, + ), + Container( + height: MediaQuery.of(context).size.height * + 0.070, + child: InkWell( + onTap: model.medicationDurationList != null + ? () { + Helpers.hideKeyboard(context); + ListSelectDialog dialog = + ListSelectDialog( + list: + model.medicationDurationList, + attributeName: 'nameEn', + attributeValueId: 'id', + okText: + TranslationBase.of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + updatedDuration = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).duration, + updatedDuration != null + ? updatedDuration['nameEn'] + .toString() + : null, + true), + enabled: false, + ), ), ), - ), - SizedBox( - height: 12.0, - ), - Container( - height: MediaQuery.of(context).size.height * - 0.070, - child: InkWell( - onTap: model.medicationDurationList != null - ? () { - ListSelectDialog dialog = - ListSelectDialog( - list: - model.medicationDurationList, - attributeName: 'nameEn', - attributeValueId: 'id', - okText: - TranslationBase.of(context) - .ok, - okFunction: (selectedValue) { - setState(() { - updatedDuration = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - child: TextField( - decoration: textFieldSelectorDecoration( - TranslationBase.of(context).duration, - updatedDuration != null - ? updatedDuration['nameEn'] - .toString() - : null, - true), - enabled: false, + SizedBox( + height: 12.0, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + child: TextFields( + hintText: widget.remarks, + controller: remarksController, + maxLines: 7, + minLines: 4, ), ), - ), - SizedBox( - height: 12.0, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - child: TextFields( - hintText: widget.remarks, - controller: remarksController, - maxLines: 7, - minLines: 4, + SizedBox( + height: 12.0, ), - ), - SizedBox( - height: 12.0, - ), - SizedBox( - height: - MediaQuery.of(context).size.height * 0.12, - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 2), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: - 'update prescription'.toUpperCase(), - onPressed: () { - updatePrescription( - newDoseStreangth: - strengthController - .text.isNotEmpty - ? strengthController.text - : widget.doseStreangth, - newUnit: units != - null - ? units['id'].toString() - : widget.doseUnit, - doseUnit: widget.doseUnit, - doseStreangth: widget - .doseStreangth, - duration: widget.duration, - startDate: widget.startDate, - doseId: widget.dose, - frequencyId: widget.frequency, - routeId: widget.route, - patient: widget.patient, - model: widget.model, - newDuration: - updatedDuration != - null - ? updatedDuration[ - 'id'] - .toString() - : widget.duration, - drugId: widget.drugId, - remarks: remarksController.text, - route: route != - null - ? route['id'].toString() - : widget.route, - frequency: - frequencyUpdate != - null - ? frequencyUpdate['id'] - .toString() - : widget.frequency, - dose: doseTime != null - ? doseTime['id'].toString() - : widget.dose, - enteredRemarks: - widget.enteredRemarks); - Navigator.pop(context); - }, - ), - ], + SizedBox( + height: + MediaQuery.of(context).size.height * 0.12, + ), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 2), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: + 'update prescription'.toUpperCase(), + onPressed: () { + updatePrescription( + newDoseStreangth: + strengthController + .text.isNotEmpty + ? strengthController.text + : widget.doseStreangth, + newUnit: units != + null + ? units['id'].toString() + : widget.doseUnit, + doseUnit: widget.doseUnit, + doseStreangth: widget + .doseStreangth, + duration: widget.duration, + startDate: widget.startDate, + doseId: widget.dose, + frequencyId: widget.frequency, + routeId: widget.route, + patient: widget.patient, + model: widget.model, + newDuration: + updatedDuration != + null + ? updatedDuration[ + 'id'] + .toString() + : widget.duration, + drugId: widget.drugId, + remarks: remarksController.text, + route: route != + null + ? route['id'].toString() + : widget.route, + frequency: + frequencyUpdate != + null + ? frequencyUpdate['id'] + .toString() + : widget.frequency, + dose: doseTime != null + ? doseTime['id'].toString() + : widget.dose, + enteredRemarks: + widget.enteredRemarks); + Navigator.pop(context); + }, + ), + ], + ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - )); - }), + )); + }), + ), ), ); }); diff --git a/lib/screens/reschedule-leaves/reschedule_leave.dart b/lib/screens/reschedule-leaves/reschedule_leave.dart index d5daf67c..7b034431 100644 --- a/lib/screens/reschedule-leaves/reschedule_leave.dart +++ b/lib/screens/reschedule-leaves/reschedule_leave.dart @@ -113,360 +113,242 @@ class _RescheduleLeaveScreen extends State { model2.getReasons(18), model2.getCoveringDoctors() }, - builder: (_, model2, w) => AppScaffold( - baseViewModel: model2, - isShowAppBar: false, - body: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - Container( + builder: (_, model2, w) => GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( + baseViewModel: model2, + isShowAppBar: false, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButtonHideUnderline( + child: new IgnorePointer( + ignoring: true, + child: DropdownButton( + focusColor: Colors.grey, + isExpanded: true, + dropdownColor: + Colors.grey, + value: getClinicName( + model) ?? + "", + iconSize: 0, + elevation: 16, + selectedItemBuilder: + (BuildContext + context) { + return model + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: + MainAxisSize + .max, + children: [ + AppText( + item, + fontSize: SizeConfig + .textMultiplier * + 2.1, + color: Colors + .grey[500], + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => + {}, + items: model + .getClinicNameList() + .map((item) { + return DropdownMenuItem( + value: + item.toString(), + child: Text( + item, + textAlign: + TextAlign.end, + ), + ); + }).toList(), + ))), + ), + ], + ) + ], + ), + )), + + Container( margin: EdgeInsets.all(8), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - focusColor: Colors.grey, + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + new IgnorePointer( + ignoring: true, + child: AppTextFormField( + readOnly: true, + hintText: profile != null + ? profile['DoctorName'] + : "", + borderColor: Colors.white, + onSaved: (value) {}, + inputFormatter: ONLY_NUMBERS)) + ], + ), + ), + + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + model2.allOffTime.length > 0 + ? Expanded( + // add Expanded to have your dropdown button fill remaining space + child: + DropdownButtonHideUnderline( + child: DropdownButton( + // focusColor: Colors.grey, isExpanded: true, - dropdownColor: - Colors.grey, - value: getClinicName( - model) ?? - "", - iconSize: 0, + value: offTime == null + ? model2.allOffTime[0] + ['code'] + : offTime, + iconSize: 40, elevation: 16, selectedItemBuilder: - (BuildContext - context) { - return model - .getClinicNameList() + (BuildContext context) { + return model2.allOffTime .map((item) { return Row( mainAxisSize: - MainAxisSize - .max, + MainAxisSize.max, children: [ AppText( - item, + item[ + 'description'], fontSize: SizeConfig .textMultiplier * 2.1, - color: Colors - .grey[500], + // color: + // Colors.grey, ), ], ); }).toList(); }, - onChanged: (newValue) => - {}, - items: model - .getClinicNameList() + onChanged: (newValue) => { + setState(() { + offTime = newValue; + }), + if (offTime == '1') + {model2.getReasons(18)} + else if (offTime == '2') + {model2.getReasons(19)} + else if (offTime == '3' || + offTime == '5') + {model2.getReasons(102)} + }, + items: model2.allOffTime .map((item) { - return DropdownMenuItem( - value: - item.toString(), + return DropdownMenuItem< + String>( + value: item['code'] + .toString(), child: Text( - item, + item['description'], textAlign: TextAlign.end, ), ); }).toList(), - ))), - ), - ], - ) - ], - ), - )), - - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - new IgnorePointer( - ignoring: true, - child: AppTextFormField( - readOnly: true, - hintText: profile != null - ? profile['DoctorName'] - : "", - borderColor: Colors.white, - onSaved: (value) {}, - inputFormatter: ONLY_NUMBERS)) - ], - ), - ), - - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - model2.allOffTime.length > 0 - ? Expanded( - // add Expanded to have your dropdown button fill remaining space - child: - DropdownButtonHideUnderline( - child: DropdownButton( - // focusColor: Colors.grey, - isExpanded: true, - value: offTime == null - ? model2.allOffTime[0] - ['code'] - : offTime, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return model2.allOffTime - .map((item) { - return Row( - mainAxisSize: - MainAxisSize.max, - children: [ - AppText( - item[ - 'description'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - // color: - // Colors.grey, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - offTime = newValue; - }), - if (offTime == '1') - {model2.getReasons(18)} - else if (offTime == '2') - {model2.getReasons(19)} - else if (offTime == '3' || - offTime == '5') - {model2.getReasons(102)} - }, - items: model2.allOffTime - .map((item) { - return DropdownMenuItem< - String>( - value: item['code'] - .toString(), - child: Text( - item['description'], - textAlign: - TextAlign.end, - ), - ); - }).toList(), - )), - ) - : SizedBox(), - ], - ) - ], - ), - )), - offTime == '1' - ? Column( - children: [ - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppTextFormField( - hintText: - TranslationBase.of(context) - .fromDate, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon( - Icons.calendar_today)), - textInputType: - TextInputType.number, - controller: _toDateController, - onTap: () { - _presentDatePicker( - 'fromDate'); - }, - inputFormatter: ONLY_DATE, - onChanged: (val) => - fromDate = val, - onSaved: (val) => - fromDate = val, - ) - ], - )), - Row( - children: [ - Expanded( - child: Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: - HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - DateTimePicker( - timeHintText: - TranslationBase.of( - context) - .fromTime, - type: - DateTimePickerType.time, - controller: _controller4, - onChanged: (val) => - fromTime = val, - validator: (val) { - print(val); - // setState( - // () => _valueToValidate4 = val); - return null; - }, - onSaved: (val) => - fromTime = val, + )), ) - ], - ), - ), - ), - Expanded( - child: Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: - HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - DateTimePicker( - timeHintText: - TranslationBase.of( - context) - .toTime, - type: - DateTimePickerType.time, - controller: _controller5, - onChanged: (val) => - toTime = val, - validator: (val) { - print(val); - // setState( - // () => _valueToValidate4 = val); - return null; - }, - onSaved: (val) => - toTime = val, - ) - ], - ), - ), - ) - ], - ) - ], - ) - : Column( - children: [ - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppTextFormField( - hintText: TranslationBase.of( - context) - .fromDate, + : SizedBox(), + ], + ) + ], + ), + )), + offTime == '1' + ? Column( + children: [ + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppTextFormField( + hintText: + TranslationBase.of(context) + .fromDate, borderColor: Colors.white, prefix: IconButton( - icon: Icon(Icons - .calendar_today)), + icon: Icon( + Icons.calendar_today)), textInputType: TextInputType.number, controller: _toDateController, @@ -475,364 +357,487 @@ class _RescheduleLeaveScreen extends State { 'fromDate'); }, inputFormatter: ONLY_DATE, - onChanged: (value) { - setState(() { - toDate = value; - }); - }), - ], - )), - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppTextFormField( - hintText: TranslationBase - .of(context) - .toDate, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon( - Icons - .calendar_today)), - textInputType: - TextInputType.number, - controller: - _toDateController2, - onTap: () { - _presentDatePicker( - 'toDate'); - }, - inputFormatter: ONLY_DATE, - onChanged: (value) { - setState(() { - toDate = value; - }); - }), - ], - )) - ], - ), - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - model2.allReasons.length > 0 - ? Expanded( - // add Expanded to have your dropdown button fill remaining space - child: - DropdownButtonHideUnderline( - child: DropdownButton( - focusColor: Colors.grey, - isExpanded: true, - value: reason == null - ? model2.allReasons[0] - ['id'] - .toString() - : reason, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return model2.allReasons - .map((item) { - return Row( - mainAxisSize: - MainAxisSize.max, - children: [ - AppText( - projectsProvider - .isArabic - ? item[ - 'nameAr'] - : item[ - 'nameEn'], - fontSize: SizeConfig - .textMultiplier * - 2.1, - // color: - // Colors.grey, - ), - ], - ); - }).toList(); + onChanged: (val) => + fromDate = val, + onSaved: (val) => + fromDate = val, + ) + ], + )), + Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: + HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + DateTimePicker( + timeHintText: + TranslationBase.of( + context) + .fromTime, + type: + DateTimePickerType.time, + controller: _controller4, + onChanged: (val) => + fromTime = val, + validator: (val) { + print(val); + // setState( + // () => _valueToValidate4 = val); + return null; + }, + onSaved: (val) => + fromTime = val, + ) + ], + ), + ), + ), + Expanded( + child: Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: + HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + DateTimePicker( + timeHintText: + TranslationBase.of( + context) + .toTime, + type: + DateTimePickerType.time, + controller: _controller5, + onChanged: (val) => + toTime = val, + validator: (val) { + print(val); + // setState( + // () => _valueToValidate4 = val); + return null; + }, + onSaved: (val) => + toTime = val, + ) + ], + ), + ), + ) + ], + ) + ], + ) + : Column( + children: [ + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppTextFormField( + hintText: TranslationBase.of( + context) + .fromDate, + borderColor: Colors.white, + prefix: IconButton( + icon: Icon(Icons + .calendar_today)), + textInputType: + TextInputType.number, + controller: _toDateController, + onTap: () { + _presentDatePicker( + 'fromDate'); }, - onChanged: (newValue) => { + inputFormatter: ONLY_DATE, + onChanged: (value) { setState(() { - reason = newValue; - }) + toDate = value; + }); + }), + ], + )), + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppTextFormField( + hintText: TranslationBase + .of(context) + .toDate, + borderColor: Colors.white, + prefix: IconButton( + icon: Icon( + Icons + .calendar_today)), + textInputType: + TextInputType.number, + controller: + _toDateController2, + onTap: () { + _presentDatePicker( + 'toDate'); }, - items: model2.allReasons - .map((item) { - return DropdownMenuItem< - String>( - value: item['id'] - .toString(), - child: Text( - projectsProvider - .isArabic - ? item['nameAr'] - : item['nameEn'], - textAlign: - TextAlign.end, - ), - ); - }).toList(), - )), - ) - : SizedBox(), - ], - ) - ], - ), - )), + inputFormatter: ONLY_DATE, + onChanged: (value) { + setState(() { + toDate = value; + }); + }), + ], + )) + ], + ), + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + model2.allReasons.length > 0 + ? Expanded( + // add Expanded to have your dropdown button fill remaining space + child: + DropdownButtonHideUnderline( + child: DropdownButton( + focusColor: Colors.grey, + isExpanded: true, + value: reason == null + ? model2.allReasons[0] + ['id'] + .toString() + : reason, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return model2.allReasons + .map((item) { + return Row( + mainAxisSize: + MainAxisSize.max, + children: [ + AppText( + projectsProvider + .isArabic + ? item[ + 'nameAr'] + : item[ + 'nameEn'], + fontSize: SizeConfig + .textMultiplier * + 2.1, + // color: + // Colors.grey, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + reason = newValue; + }) + }, + items: model2.allReasons + .map((item) { + return DropdownMenuItem< + String>( + value: item['id'] + .toString(), + child: Text( + projectsProvider + .isArabic + ? item['nameAr'] + : item['nameEn'], + textAlign: + TextAlign.end, + ), + ); + }).toList(), + )), + ) + : SizedBox(), + ], + ) + ], + ), + )), - Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - model2.coveringDoctors.length > 0 - ? Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownSearch( - mode: Mode.BOTTOM_SHEET, + Container( + margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.max, + children: [ + model2.coveringDoctors.length > 0 + ? Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownSearch( + mode: Mode.BOTTOM_SHEET, - dropdownSearchDecoration: - InputDecoration( - contentPadding: - EdgeInsets.all( - 0), - border: InputBorder - .none), - //maxHeight: 300, - items: model2 - .coveringDoctors - .map((item) { - return projectsProvider - .isArabic - ? item['doctorNameN'] - : item['doctorName']; - }).toList(), - // label: "Doctor List", - onChanged: (item) { - model2.coveringDoctors - .forEach((newVal) => { - if (newVal['doctorName'] == - item || - newVal['doctorName'] == - item) - { - doctorID = - newVal[ - 'DoctorID'] - } - }); - }, - selectedItem: - getSelectedDoctor( - model2), - showSearchBox: true, - searchBoxDecoration: - InputDecoration( - border: - OutlineInputBorder(), - contentPadding: - EdgeInsets.fromLTRB( - 12, 12, 8, 0), - labelText: - "Search Doctor", - ), - popupTitle: Container( - height: 50, - decoration: BoxDecoration( - color: Theme.of(context) - .primaryColorDark, + dropdownSearchDecoration: + InputDecoration( + contentPadding: + EdgeInsets.all( + 0), + border: InputBorder + .none), + //maxHeight: 300, + items: model2 + .coveringDoctors + .map((item) { + return projectsProvider + .isArabic + ? item['doctorNameN'] + : item['doctorName']; + }).toList(), + // label: "Doctor List", + onChanged: (item) { + model2.coveringDoctors + .forEach((newVal) => { + if (newVal['doctorName'] == + item || + newVal['doctorName'] == + item) + { + doctorID = + newVal[ + 'DoctorID'] + } + }); + }, + selectedItem: + getSelectedDoctor( + model2), + showSearchBox: true, + searchBoxDecoration: + InputDecoration( + border: + OutlineInputBorder(), + contentPadding: + EdgeInsets.fromLTRB( + 12, 12, 8, 0), + labelText: + "Search Doctor", + ), + popupTitle: Container( + height: 50, + decoration: BoxDecoration( + color: Theme.of(context) + .primaryColorDark, + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular( + 20), + topRight: + Radius.circular( + 20), + ), + ), + child: Center( + child: Text( + '', + style: TextStyle( + fontSize: 24, + fontWeight: + FontWeight.bold, + color: Colors.white, + ), + ), + ), + ), + popupShape: + RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: - Radius.circular( - 20), + Radius.circular(24), topRight: - Radius.circular( - 20), - ), - ), - child: Center( - child: Text( - '', - style: TextStyle( - fontSize: 24, - fontWeight: - FontWeight.bold, - color: Colors.white, - ), + Radius.circular(24), ), ), ), - popupShape: - RoundedRectangleBorder( - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular(24), - topRight: - Radius.circular(24), - ), - ), - ), - // DropdownButtonHideUnderline( - // child: DropdownButton( - // focusColor: Colors.grey, - // isExpanded: true, - // value: doctorID == null - // ? model2 - // .coveringDoctors[0] - // ['doctorID'] - // .toString() - // : doctorID, - // iconSize: 40, - // elevation: 16, - // selectedItemBuilder: - // (BuildContext context) { - // return model2 - // .coveringDoctors - // .map((item) { - // return Row( - // mainAxisSize: - // MainAxisSize.max, - // children: [ - // AppText( - // projectsProvider - // .isArabic - // ? item[ - // 'doctorNameN'] - // : item[ - // 'doctorName'], - // fontSize: SizeConfig - // .textMultiplier * - // 2.1, - // ), - // ], - // ); - // }).toList(); - // }, - // onChanged: (newValue) => { - // setState(() { - // doctorID = newValue; - // }) - // }, - // items: model2 - // .coveringDoctors - // .map((item) { - // return DropdownMenuItem< - // String>( - // value: item['doctorID'] - // .toString(), - // child: Text( - // projectsProvider - // .isArabic - // ? item[ - // 'doctorNameN'] - // : item[ - // 'doctorName'], - // textAlign: - // TextAlign.start, - // ), - // ); - // }).toList(), - // )), - ) - : SizedBox(), - ], - ) - ], - ), - )), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.isUpdate == true - ? TranslationBase.of(context).update - : TranslationBase.of(context).add, - onPressed: () { - if (offTime == '1' || offTime == '2') { - if (widget.isUpdate == true) { - updateRecheduleLeave(model2); + // DropdownButtonHideUnderline( + // child: DropdownButton( + // focusColor: Colors.grey, + // isExpanded: true, + // value: doctorID == null + // ? model2 + // .coveringDoctors[0] + // ['doctorID'] + // .toString() + // : doctorID, + // iconSize: 40, + // elevation: 16, + // selectedItemBuilder: + // (BuildContext context) { + // return model2 + // .coveringDoctors + // .map((item) { + // return Row( + // mainAxisSize: + // MainAxisSize.max, + // children: [ + // AppText( + // projectsProvider + // .isArabic + // ? item[ + // 'doctorNameN'] + // : item[ + // 'doctorName'], + // fontSize: SizeConfig + // .textMultiplier * + // 2.1, + // ), + // ], + // ); + // }).toList(); + // }, + // onChanged: (newValue) => { + // setState(() { + // doctorID = newValue; + // }) + // }, + // items: model2 + // .coveringDoctors + // .map((item) { + // return DropdownMenuItem< + // String>( + // value: item['doctorID'] + // .toString(), + // child: Text( + // projectsProvider + // .isArabic + // ? item[ + // 'doctorNameN'] + // : item[ + // 'doctorName'], + // textAlign: + // TextAlign.start, + // ), + // ); + // }).toList(), + // )), + ) + : SizedBox(), + ], + ) + ], + ), + )), + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: widget.isUpdate == true + ? TranslationBase.of(context).update + : TranslationBase.of(context).add, + onPressed: () { + if (offTime == '1' || offTime == '2') { + if (widget.isUpdate == true) { + updateRecheduleLeave(model2); + } else { + addRecheduleLeave(model2); + } } else { - addRecheduleLeave(model2); + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .onlyOfftimeHoliday); } - } else { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .onlyOfftimeHoliday); - } - }, - ), - ], + }, + ), + ], + ), ), - ), - // Column( - // children: [ - // Texts(TranslationBase.of(context) - // .previousSickLeaveIssue + - // ' ') - // ], - // ) - ], + // Column( + // children: [ + // Texts(TranslationBase.of(context) + // .previousSickLeaveIssue + + // ' ') + // ], + // ) + ], + ), ), ), ), ), - ))); + ))); } getProfile() async { diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index b4ee3ace..103c133b 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -83,315 +83,320 @@ class _SickLeaveScreenState extends State { builder: (_, model, w) => BaseView( onModelReady: (model2) => model2.preSickLeaveStatistics( widget.appointmentNo, widget.patientMRN), - builder: (_, model2, w) => AppScaffold( - baseViewModel: model2, - isShowAppBar: false, - body: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - child: FractionallySizedBox( - widthFactor: 0.9, - child: ListView( - children: [ - Padding( - child: AppText( - widget.isExtended == true - ? TranslationBase.of(context) - .extendSickLeave - : TranslationBase.of(context) - .addSickLeave, - fontWeight: FontWeight.bold, - ), - padding: EdgeInsets.all(10)), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppTextFormField( - borderColor: Colors.white, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = - int.parse(value); - } - }, - hintText: widget.extendedData != null - ? widget.extendedData.noOfDays - .toString() - : TranslationBase.of(context) - .sickLeaveDays, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS) - ]), - ), - SizedBox( - height: 10, - ), - Container( + builder: (_, model2, w) => GestureDetector( + onTap: (){ + FocusScope.of(context).requestFocus(new FocusNode()); + }, + child: AppScaffold( + baseViewModel: model2, + isShowAppBar: false, + body: Center( + child: Container( + margin: EdgeInsets.only(top: 10), + child: FractionallySizedBox( + widthFactor: 0.9, + child: ListView( + children: [ + Padding( + child: AppText( + widget.isExtended == true + ? TranslationBase.of(context) + .extendSickLeave + : TranslationBase.of(context) + .addSickLeave, + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10)), + Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), + width: 1.0, color: HexColor("#CCCCCC"))), padding: EdgeInsets.all(5), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context).sickLeaveDate, - // fontSize: 10, - // ), - AppTextFormField( - hintText: widget.extendedData != null - ? widget.extendedData.startDate - : TranslationBase.of(context) - .sickLeaveDate, - borderColor: Colors.white, - prefix: IconButton( - icon: Icon(Icons.calendar_today)), - textInputType: TextInputType.number, - controller: _toDateController, - onTap: () { - _presentDatePicker('_selectedToDate'); - }, - inputFormatter: ONLY_DATE, - onChanged: (value) { - addSickLeave.startDate = value; - if (widget.extendedData != null) { - widget.extendedData.startDate = - value; - } - }), - ], - )), - Container( - margin: EdgeInsets.only( - top: 10, left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppTextFormField( + borderColor: Colors.white, + onChanged: (value) { + addSickLeave.noOfDays = value; + if (widget.extendedData != null) { + widget.extendedData.noOfDays = + int.parse(value); + } + }, + hintText: widget.extendedData != null + ? widget.extendedData.noOfDays + .toString() + : TranslationBase.of(context) + .sickLeaveDays, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_NUMBERS) + ]), + ), + SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ // AppText( - // TranslationBase.of(context).clinicName, + // TranslationBase.of(context).sickLeaveDate, // fontSize: 10, // ), - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - isExpanded: true, - value: getClinicName( - model) ?? - "", - iconSize: 0, - elevation: 16, - selectedItemBuilder: - (BuildContext - context) { - return model + AppTextFormField( + hintText: widget.extendedData != null + ? widget.extendedData.startDate + : TranslationBase.of(context) + .sickLeaveDate, + borderColor: Colors.white, + prefix: IconButton( + icon: Icon(Icons.calendar_today)), + textInputType: TextInputType.number, + controller: _toDateController, + onTap: () { + _presentDatePicker('_selectedToDate'); + }, + inputFormatter: ONLY_DATE, + onChanged: (value) { + addSickLeave.startDate = value; + if (widget.extendedData != null) { + widget.extendedData.startDate = + value; + } + }), + ], + )), + Container( + margin: EdgeInsets.only( + top: 10, left: 10, right: 10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context).clinicName, + // fontSize: 10, + // ), + Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButtonHideUnderline( + child: new IgnorePointer( + ignoring: true, + child: DropdownButton( + isExpanded: true, + value: getClinicName( + model) ?? + "", + iconSize: 0, + elevation: 16, + selectedItemBuilder: + (BuildContext + context) { + return model + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: + MainAxisSize + .max, + children: [ + AppText( + item, + fontSize: SizeConfig + .textMultiplier * + 2.1, + color: + Colors.grey, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => + {}, + items: model .getClinicNameList() .map((item) { - return Row( - mainAxisSize: - MainAxisSize - .max, - children: [ - AppText( - item, - fontSize: SizeConfig - .textMultiplier * - 2.1, - color: - Colors.grey, - ), - ], + return DropdownMenuItem( + value: + item.toString(), + child: Text( + item, + textAlign: + TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => - {}, - items: model - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: - item.toString(), - child: Text( - item, - textAlign: - TextAlign.end, - ), - ); - }).toList(), - ))), - ), - ], - ) - ], - ), - )), - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'] != - null - ? Padding( - child: AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], - fontWeight: FontWeight.bold, - textAlign: TextAlign.start, + }).toList(), + ))), + ), + ], + ) + ], ), - padding: EdgeInsets.all(10), - ) - : SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context).doctorName, - // fontSize: 10, - // ), - new IgnorePointer( - ignoring: true, - child: AppTextFormField( - readOnly: true, - hintText: profile['DoctorName'], - borderColor: Colors.white, - onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_NUMBERS)) - ], + )), + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'] != + null + ? Padding( + child: AppText( + model2.sickLeaveStatistics[ + 'recommendedSickLeaveDays'], + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + padding: EdgeInsets.all(10), + ) + : SizedBox( + height: 10, + ), + Container( + margin: EdgeInsets.only(left: 10, right: 10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context).doctorName, + // fontSize: 10, + // ), + new IgnorePointer( + ignoring: true, + child: AppTextFormField( + readOnly: true, + hintText: profile['DoctorName'], + borderColor: Colors.white, + onSaved: (value) {}, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_NUMBERS)) + ], + ), + ), + SizedBox( + height: 10, ), - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context).remarks, - // fontSize: 10, - // ), - TextField( - maxLines: 3, - decoration: InputDecoration( - contentPadding: EdgeInsets.all(20.0), - border: InputBorder.none, - hintText: widget.extendedData != null - ? widget.extendedData.remarks - : TranslationBase.of(context) - .remarks), - onChanged: (value) { - addSickLeave.remarks = value; - if (widget.extendedData != null) { - widget.extendedData.remarks = value; - } - }, - ) - ], + Container( + margin: EdgeInsets.only(left: 10, right: 10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(6.0)), + border: Border.all( + width: 1.0, color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context).remarks, + // fontSize: 10, + // ), + TextField( + maxLines: 3, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(20.0), + border: InputBorder.none, + hintText: widget.extendedData != null + ? widget.extendedData.remarks + : TranslationBase.of(context) + .remarks), + onChanged: (value) { + addSickLeave.remarks = value; + if (widget.extendedData != null) { + widget.extendedData.remarks = value; + } + }, + ) + ], + ), ), - ), - Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: widget.isExtended == true - ? TranslationBase.of(context).extend - : TranslationBase.of(context).add, - onPressed: () async { - if (widget.isExtended) { - await model2.extendSickLeave( - widget.extendedData); + Container( + margin: EdgeInsets.all( + SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: widget.isExtended == true + ? TranslationBase.of(context).extend + : TranslationBase.of(context).add, + onPressed: () async { + if (widget.isExtended) { + await model2.extendSickLeave( + widget.extendedData); - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse[ - 'ListSickLeavesToExtent'] - ['success']); - Navigator.of(context).popUntil((route) { - return route.settings.name == - PATIENTS_PROFILE; - }); - Navigator.of(context).pushNamed( - ADD_SICKLEAVE, - arguments: { - 'patient': widget.patient - }); - //print(value); - //}); - } else { - _validateInputs(model2); - } - }, - ), - ], + DrAppToastMsg.showSuccesToast( + model2.sickleaveResponse[ + 'ListSickLeavesToExtent'] + ['success']); + Navigator.of(context).popUntil((route) { + return route.settings.name == + PATIENTS_PROFILE; + }); + Navigator.of(context).pushNamed( + ADD_SICKLEAVE, + arguments: { + 'patient': widget.patient + }); + //print(value); + //}); + } else { + _validateInputs(model2); + } + }, + ), + ], + ), ), - ), - // Column( - // children: [ - // Texts(TranslationBase.of(context) - // .previousSickLeaveIssue + - // ' ') - // ], - // ) - ], + // Column( + // children: [ + // Texts(TranslationBase.of(context) + // .previousSickLeaveIssue + + // ' ') + // ], + // ) + ], + ), ), ), ), ), - ))); + ))); } void _validateInputs(model2) async { diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 07709fc9..9ae35747 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -408,4 +408,9 @@ class Helpers { )), ); } + + /// hides the keyboard if its already open + static hideKeyboard(BuildContext context) { + FocusScope.of(context).unfocus(); + } } diff --git a/lib/widgets/shared/TextFields.dart b/lib/widgets/shared/TextFields.dart index 4972d854..706c65b7 100644 --- a/lib/widgets/shared/TextFields.dart +++ b/lib/widgets/shared/TextFields.dart @@ -54,7 +54,7 @@ class TextFields extends StatefulWidget { this.focus = false, this.maxLengthEnforced = true, this.suffixIconColor, - this.inputAction, + this.inputAction = TextInputAction.done, this.onSubmit, this.keepPadding = true, this.textCapitalization = TextCapitalization.none, diff --git a/lib/widgets/shared/app_text_form_field.dart b/lib/widgets/shared/app_text_form_field.dart index 82a273bb..8fed3cd8 100644 --- a/lib/widgets/shared/app_text_form_field.dart +++ b/lib/widgets/shared/app_text_form_field.dart @@ -17,7 +17,7 @@ class AppTextFormField extends FormField { TextInputType textInputType, String hintText, FocusNode focusNode, - TextInputAction textInputAction, + TextInputAction textInputAction=TextInputAction.done, ValueChanged onFieldSubmitted, IconButton prefix, String labelText, @@ -38,10 +38,10 @@ class AppTextFormField extends FormField { focusNode: focusNode, keyboardType: textInputType, readOnly: readOnly, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(inputFormatter)), - ], + // inputFormatters: [ + // FilteringTextInputFormatter.allow( + // RegExp(inputFormatter)), + // ], onChanged: onChanged ?? (value) { state.didChange(value); diff --git a/pubspec.lock b/pubspec.lock index addef845..94f07eea 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -559,7 +559,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -830,7 +830,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: @@ -965,5 +965,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0"