From 6a96a9cb283195b001908d6589e952a31a42358b Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 9 Sep 2021 12:08:10 +0300 Subject: [PATCH 1/2] fix bug sick leave --- lib/screens/patients/InPatientPage.dart | 0 lib/screens/sick-leave/add-sickleave.dart | 124 ++++++++++++++++------ 2 files changed, 89 insertions(+), 35 deletions(-) delete mode 100644 lib/screens/patients/InPatientPage.dart diff --git a/lib/screens/patients/InPatientPage.dart b/lib/screens/patients/InPatientPage.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index db8dd3c2..3cdeb180 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -22,6 +22,7 @@ import 'package:provider/provider.dart'; class AddSickLeavScreen extends StatelessWidget { PatiantInformtion patient; + @override Widget build(BuildContext context) { ProjectViewModel projectsProvider = Provider.of(context); @@ -31,8 +32,10 @@ class AddSickLeavScreen extends StatelessWidget { bool isInpatient = routeArgs['isInpatient']; return BaseView( onModelReady: (model) async { - await model.getSickLeavePatient(patient.patientMRN ?? patient.patientId); - await model.getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); + await model + .getSickLeavePatient(patient.patientMRN ?? patient.patientId); + await model + .getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -79,17 +82,21 @@ class AddSickLeavScreen extends StatelessWidget { }, child: Container( width: SizeConfig.screenWidth, - margin: EdgeInsets.only(left: 20, right: 20, top: 10, bottom: 10), + margin: EdgeInsets.only( + left: 20, right: 20, top: 10, bottom: 10), padding: EdgeInsets.all(20), - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(10), color: HexColor('#EAEAEA')), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: HexColor('#EAEAEA')), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ Container( child: Container( - decoration: - BoxDecoration(color: Colors.grey, borderRadius: BorderRadius.circular(10)), + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: + BorderRadius.circular(10)), padding: EdgeInsets.all(3), child: IconButton( icon: Icon( @@ -106,7 +113,9 @@ class AddSickLeavScreen extends StatelessWidget { ), )), Padding( - child: AppText(TranslationBase.of(context).noSickLeaveApplied, + child: AppText( + TranslationBase.of(context) + .noSickLeaveApplied, fontWeight: FontWeight.bold, fontFamily: 'Poppins', fontSize: 16, @@ -122,7 +131,8 @@ class AddSickLeavScreen extends StatelessWidget { : SizedBox(), model.getAllSIckLeavePatient.length > 0 ? Column( - children: model.getAllSIckLeavePatient.map((SickLeavePatientModel item) { + children: model.getAllSIckLeavePatient + .map((SickLeavePatientModel item) { return RoundedContainer( margin: EdgeInsets.all(10), child: Column( @@ -141,7 +151,8 @@ class AddSickLeavScreen extends StatelessWidget { // ))), padding: EdgeInsets.all(10), child: Row( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ Expanded( flex: 4, @@ -150,7 +161,8 @@ class AddSickLeavScreen extends StatelessWidget { // MainAxisAlignment.start, children: [ Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Container( padding: EdgeInsets.all(3), @@ -168,7 +180,8 @@ class AddSickLeavScreen extends StatelessWidget { // : TranslationBase // .of(context) // .all, - fontWeight: FontWeight.bold, + fontWeight: + FontWeight.bold, // color: item.status == 1 // ? Colors.yellow[800] // : item.status == 2 @@ -179,25 +192,48 @@ class AddSickLeavScreen extends StatelessWidget { ), Row( children: [ - AppText(TranslationBase.of(context).daysSickleave + ": "), + AppText(TranslationBase + .of(context) + .daysSickleave + + ": "), AppText( - item.sickLeaveDays.toString() ?? item.noOfDays.toString(), - fontWeight: FontWeight.bold, + (item.sickLeaveDays + .toString() != + null && + item.sickLeaveDays + .toString() != + "null") + ? item.sickLeaveDays + .toString() + : item.noOfDays + .toString(), + fontWeight: + FontWeight.bold, ), ], ), Row( children: [ AppText( - TranslationBase.of(context).startDate + ' ' ?? "", + TranslationBase.of( + context) + .startDate + + ' ' ?? + "", ), Flexible( child: AppText( - AppDateUtils.getDayMonthYearDateFormatted( - item.startDate.contains("/Date(") - ? AppDateUtils.convertStringToDate(item.startDate) - : DateTime.parse(item.startDate)), - fontWeight: FontWeight.bold, + AppDateUtils.getDayMonthYearDateFormatted(item + .startDate + .contains( + "/Date(") + ? AppDateUtils + .convertStringToDate(item + .startDate) + : DateTime.parse( + item.startDate)), + fontWeight: + FontWeight.bold, ), ) ], @@ -205,18 +241,30 @@ class AddSickLeavScreen extends StatelessWidget { Row( children: [ AppText( - TranslationBase.of(context).endDate + ' ' ?? "", + TranslationBase.of( + context) + .endDate + + ' ' ?? + "", ), Flexible( child: AppText( - AppDateUtils.getDayMonthYearDateFormatted( - item.startDate.contains("/Date(") - ? AppDateUtils.convertStringToDate(item.endDate ?? "") - .add(Duration( - days: item.noOfDays ?? item.sickLeaveDays)) - : DateTime.parse(item.startDate ?? "") - .add(Duration(days: item.noOfDays ?? ""))), - fontWeight: FontWeight.bold, + AppDateUtils.getDayMonthYearDateFormatted(item + .startDate + .contains( + "/Date(") + ? AppDateUtils.convertStringToDate( + item.endDate ?? + "") + .add(Duration( + days: item.noOfDays ?? + item + .sickLeaveDays)) + : DateTime.parse( + item.startDate ?? "") + .add(Duration(days: item.noOfDays ?? ""))), + fontWeight: + FontWeight.bold, ), ) ], @@ -246,7 +294,8 @@ class AddSickLeavScreen extends StatelessWidget { Image.asset('assets/images/no-data.png'), Padding( padding: const EdgeInsets.all(8.0), - child: AppText(TranslationBase.of(context).noSickLeave), + child: AppText( + TranslationBase.of(context).noSickLeave), ) ], ), @@ -255,7 +304,8 @@ class AddSickLeavScreen extends StatelessWidget { ])))); } - openSickLeave(BuildContext context, isExtend, {GetAllSickLeaveResponse extendedData}) { + openSickLeave(BuildContext context, isExtend, + {GetAllSickLeaveResponse extendedData}) { // showModalBottomSheet( // context: context, // builder: (context) { @@ -265,9 +315,13 @@ class AddSickLeavScreen extends StatelessWidget { context, FadePage( page: SickLeaveScreen( - appointmentNo: - isExtend == true ? extendedData.appointmentNo : patient.appointmentNo, //extendedData.appointmentNo, - patientMRN: isExtend == true ? extendedData.patientMRN : patient.patientMRN, + appointmentNo: isExtend == true + ? extendedData.appointmentNo + : patient.appointmentNo, + //extendedData.appointmentNo, + patientMRN: isExtend == true + ? extendedData.patientMRN + : patient.patientMRN, isExtended: isExtend, extendedData: extendedData, patient: patient))); From 9598c09ea265028baa7355d4da7c0b77556195bd Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 9 Sep 2021 13:11:25 +0300 Subject: [PATCH 2/2] scroll problem --- .../In_patient/in_patient_list_page.dart | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index 80acb88d..c7b99200 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -32,13 +32,21 @@ class _InPatientListPageState extends State { bool isAllClinic = true; bool showBottomSheet = false; String selectedClinicName; + ScrollController _scrollController; @override void dispose() { _searchController.dispose(); + _scrollController.dispose(); super.dispose(); } + @override + void initState() { + _scrollController = new ScrollController(); + super.initState(); + } + @override Widget build(BuildContext context) { return AppScaffold( @@ -167,13 +175,14 @@ class _InPatientListPageState extends State { : Expanded( child: Container( margin: EdgeInsets.symmetric(horizontal: 16.0), - child: NotificationListener( + child: NotificationListener( child: ListView.builder( itemCount: widget.patientSearchViewModel .filteredInPatientItems.length, scrollDirection: Axis.vertical, // physics: ScrollPhysics(), shrinkWrap: true, + controller: _scrollController, itemBuilder: (context, index) { if (!widget.isMyInPatient) return PatientCard( @@ -276,14 +285,19 @@ class _InPatientListPageState extends State { else return SizedBox(); }), - onNotification: (t) { - if (isAllClinic) if (t + onNotification: (notification) { + if (isAllClinic) if (notification is ScrollUpdateNotification && - t.metrics.pixels >= - t.metrics.maxScrollExtent - 50) { + notification.metrics.pixels >= + notification.metrics.maxScrollExtent - 50) { widget.patientSearchViewModel .addOnFilteredList(); } + // print("scroll position scroll ${_scrollController.position.pixels}"); + // if(_scrollController.position.pixels > widget.patientSearchViewModel + // .filteredInPatientItems.length / 4){ + // _scrollController.jumpTo(0); + // } return; }, ),