From 42666e2200f9ceaed32249999c47fef0072000b4 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 21 Mar 2021 09:36:01 +0200 Subject: [PATCH] move clinic list to its own file --- lib/screens/patients/patients_screen.dart | 111 +++--------------- .../patients/clinic_list_dropdwon.dart | 99 ++++++++++++++++ 2 files changed, 116 insertions(+), 94 deletions(-) create mode 100644 lib/widgets/patients/clinic_list_dropdwon.dart diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index ac91050e..e0f3fe0e 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/routes.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/clinic_list_dropdwon.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'; @@ -312,9 +313,22 @@ class _PatientsScreenState extends State { : _isError ? DrAppEmbeddedError(error: error) : lItems == null || lItems.length == 0 - ? DrAppEmbeddedError( - error: - TranslationBase.of(context).youDontHaveAnyPatient) + ? Column( + children: [ + if(int.parse(patientType)==7) + ClinicList(clinicId: clinicId,onClinicChange: (newValue) { + clinicId = newValue; + changeClinic(newValue, context, model); + },), + Divider( + thickness: 0.8, + color: Color(0xffCCCCCC), + ), + DrAppEmbeddedError( + error: + TranslationBase.of(context).youDontHaveAnyPatient), + ], + ) : Container( child: ListView( scrollDirection: Axis.vertical, @@ -591,96 +605,5 @@ class _PatientsScreenState extends State { } } -// ignore: must_be_immutable -class ClinicList extends StatelessWidget { - - ProjectViewModel projectsProvider; - final int clinicId; - final Function (int value) onClinicChange; - - ClinicList({Key key, this.clinicId, this.onClinicChange}) : super(key: key); - - @override - Widget build(BuildContext context) { - // authProvider = Provider.of(context); - projectsProvider = Provider.of(context); - return Container( - child: - projectsProvider - .doctorClinicsList.length > - 0 - ? FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width *0.8, - child: Center( - child: DropdownButtonHideUnderline( - child: DropdownButton( - dropdownColor: - Colors.white, - iconEnabledColor: - Colors.black, - isExpanded: true, - value: clinicId == null - ? projectsProvider - .doctorClinicsList[ - 0] - .clinicID - : clinicId, - iconSize: 25, - elevation: 16, - selectedItemBuilder: - (BuildContext - context) { - return projectsProvider - .doctorClinicsList - .map((item) { - return Row( - mainAxisSize: - MainAxisSize - .max, - children: [ - AppText( - item.clinicName, - fontSize: SizeConfig - .textMultiplier * - 2.1, - color: Colors - .black, - ), - ], - ); - }).toList(); - }, - onChanged: (newValue){ - onClinicChange(newValue); - }, - items: projectsProvider - .doctorClinicsList - .map((item) { - return DropdownMenuItem( - child: Text( - item.clinicName, - textAlign: - TextAlign.end, - ), - value: item.clinicID, - ); - }).toList(), - )), - ), - ), - ], - ), - ) - : AppText( - TranslationBase - .of(context) - .noClinic), - ); - } -} diff --git a/lib/widgets/patients/clinic_list_dropdwon.dart b/lib/widgets/patients/clinic_list_dropdwon.dart new file mode 100644 index 00000000..c903bd7b --- /dev/null +++ b/lib/widgets/patients/clinic_list_dropdwon.dart @@ -0,0 +1,99 @@ +// ignore: must_be_immutable +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.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/material.dart'; +import 'package:provider/provider.dart'; + +class ClinicList extends StatelessWidget { + + ProjectViewModel projectsProvider; + final int clinicId; + final Function (int value) onClinicChange; + + ClinicList({Key key, this.clinicId, this.onClinicChange}) : super(key: key); + + @override + Widget build(BuildContext context) { + // authProvider = Provider.of(context); + + projectsProvider = Provider.of(context); + return Container( + child: + projectsProvider + .doctorClinicsList.length > + 0 + ? FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + Container( + width: MediaQuery.of(context).size.width *0.8, + child: Center( + child: DropdownButtonHideUnderline( + child: DropdownButton( + dropdownColor: + Colors.white, + iconEnabledColor: + Colors.black, + isExpanded: true, + value: clinicId == null + ? projectsProvider + .doctorClinicsList[ + 0] + .clinicID + : clinicId, + iconSize: 25, + elevation: 16, + selectedItemBuilder: + (BuildContext + context) { + return projectsProvider + .doctorClinicsList + .map((item) { + return Row( + mainAxisSize: + MainAxisSize + .max, + children: [ + AppText( + item.clinicName, + fontSize: SizeConfig + .textMultiplier * + 2.1, + color: Colors + .black, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue){ + onClinicChange(newValue); + }, + items: projectsProvider + .doctorClinicsList + .map((item) { + return DropdownMenuItem( + child: Text( + item.clinicName, + textAlign: + TextAlign.end, + ), + value: item.clinicID, + ); + }).toList(), + )), + ), + ), + ], + ), + ) + : AppText( + TranslationBase + .of(context) + .noClinic), + ); + } +} \ No newline at end of file