move clinic list to its own file

merge-requests/354/head
Elham Rababah 4 years ago
parent e2e92c1c59
commit 42666e2200

@ -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<PatientsScreen> {
: _isError
? DrAppEmbeddedError(error: error)
: lItems == null || lItems.length == 0
? DrAppEmbeddedError(
? 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)
TranslationBase.of(context).youDontHaveAnyPatient),
],
)
: Container(
child: ListView(
scrollDirection: Axis.vertical,
@ -591,96 +605,5 @@ class _PatientsScreenState extends State<PatientsScreen> {
}
}
// 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: <Widget>[
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),
);
}
}

@ -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: <Widget>[
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),
);
}
}
Loading…
Cancel
Save