From 8a8b55d2de45efff498f06890d12335c4a156670 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 7 Jun 2021 17:12:54 +0300 Subject: [PATCH] move show timer to its own file --- .../live_care/live_care_patient_screen.dart | 2 +- lib/screens/patients/InPatientPage.dart | 3 +- .../out_patient/out_patient_screen.dart | 4 +- .../patient_search_result_screen.dart | 4 +- .../{ => patient_card}/PatientCard.dart | 58 +----------------- .../patients/patient_card/ShowTimer.dart | 59 +++++++++++++++++++ 6 files changed, 66 insertions(+), 64 deletions(-) rename lib/widgets/patients/{ => patient_card}/PatientCard.dart (96%) create mode 100644 lib/widgets/patients/patient_card/ShowTimer.dart diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index 51757bf0..0b741989 100644 --- a/lib/screens/live_care/live_care_patient_screen.dart +++ b/lib/screens/live_care/live_care_patient_screen.dart @@ -6,7 +6,7 @@ import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart' import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/screens/base/base_view.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/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; diff --git a/lib/screens/patients/InPatientPage.dart b/lib/screens/patients/InPatientPage.dart index 1b42d305..e9e2c2d1 100644 --- a/lib/screens/patients/InPatientPage.dart +++ b/lib/screens/patients/InPatientPage.dart @@ -1,10 +1,9 @@ import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/screens/base/base_view.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/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index 30400c65..0a85ff26 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -1,10 +1,8 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/patient_type.dart'; - import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; - import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; @@ -14,7 +12,7 @@ import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.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/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; diff --git a/lib/screens/patients/patient_search/patient_search_result_screen.dart b/lib/screens/patients/patient_search/patient_search_result_screen.dart index 02bde8d0..8044e991 100644 --- a/lib/screens/patients/patient_search/patient_search_result_screen.dart +++ b/lib/screens/patients/patient_search/patient_search_result_screen.dart @@ -10,13 +10,11 @@ import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.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/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart similarity index 96% rename from lib/widgets/patients/PatientCard.dart rename to lib/widgets/patients/patient_card/PatientCard.dart index 6f218263..b90eecd3 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -9,6 +9,8 @@ import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'ShowTimer.dart'; + class PatientCard extends StatelessWidget { final PatiantInformtion patientInfo; final Function onTap; @@ -530,58 +532,4 @@ class PatientCard extends StatelessWidget { } -} - -class ShowTimer extends StatefulWidget { - final PatiantInformtion patientInfo; - - - const ShowTimer({ - Key key, this.patientInfo, - }) : super(key: key); - - @override - _ShowTimerState createState() => _ShowTimerState(); -} - -class _ShowTimerState extends State { - - int remainingTime = 600; - String displayTime = ''; - - @override - Widget build(BuildContext context) { - if (displayTime.isEmpty) { - startShowTimer(); - } - return AppText( - "$displayTime", - color: Colors.red, - textAlign: TextAlign.start, - fontWeight: FontWeight.bold, - fontSize: 11, - ); - } - - startShowTimer() { - // this.remainingTime--; - setState(() { - displayTime = this.generateShowTimerString(); - }); - - Future.delayed(Duration(seconds: 1), () { - if (this.remainingTime > 0) { - startShowTimer(); - } - }); - } - - generateShowTimerString() { - DateTime now = DateTime.now(); - DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime); - String timer = AppDateUtils.differenceBetweenDateAndCurrent( - liveCareDate, context, isShowSecond: true, isShowDays: false); - - return timer; - } -} +} \ No newline at end of file diff --git a/lib/widgets/patients/patient_card/ShowTimer.dart b/lib/widgets/patients/patient_card/ShowTimer.dart new file mode 100644 index 00000000..b769588b --- /dev/null +++ b/lib/widgets/patients/patient_card/ShowTimer.dart @@ -0,0 +1,59 @@ + +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/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class ShowTimer extends StatefulWidget { + final PatiantInformtion patientInfo; + + + const ShowTimer({ + Key key, this.patientInfo, + }) : super(key: key); + + @override + _ShowTimerState createState() => _ShowTimerState(); +} + +class _ShowTimerState extends State { + + int remainingTime = 600; + String displayTime = ''; + + @override + Widget build(BuildContext context) { + if (displayTime.isEmpty) { + startShowTimer(); + } + return AppText( + "$displayTime", + color: Colors.red, + textAlign: TextAlign.start, + fontWeight: FontWeight.bold, + fontSize: 11, + ); + } + + startShowTimer() { + // this.remainingTime--; + setState(() { + displayTime = this.generateShowTimerString(); + }); + + Future.delayed(Duration(seconds: 1), () { + if (this.remainingTime > 0) { + startShowTimer(); + } + }); + } + + generateShowTimerString() { + DateTime now = DateTime.now(); + DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime); + String timer = AppDateUtils.differenceBetweenDateAndCurrent( + liveCareDate, context, isShowSecond: true, isShowDays: false); + + return timer; + } +}