diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 9ef94647..7fbd7d1f 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -16,6 +16,9 @@ class PatientSearchViewModel extends BaseViewModel{ List filterData = []; + DateTime selectedFromDate; + DateTime selectedToDate; + searchData(String str) { var strExist = str.length > 0 ? true : false; if (strExist) { @@ -83,14 +86,19 @@ class PatientSearchViewModel extends BaseViewModel{ String dateTo; String dateFrom; if (item == 'Previous') { + + selectedFromDate = DateTime(DateTime.now().year, DateTime.now().month-1, + DateTime.now().day); + selectedToDate = DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day-1); dateTo = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, - DateTime.now().day-1), + selectedToDate, 'yyyy-MM-dd'); dateFrom = DateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month-3, - DateTime.now().day), + selectedFromDate, 'yyyy-MM-dd'); + + } else if (item == 'Next Week') { diff --git a/lib/screens/patients/out_patient/filter_date_page.dart b/lib/screens/patients/out_patient/filter_date_page.dart index 034f6136..a8f7904d 100644 --- a/lib/screens/patients/out_patient/filter_date_page.dart +++ b/lib/screens/patients/out_patient/filter_date_page.dart @@ -16,6 +16,7 @@ class FilterDatePage extends StatefulWidget { final OutPatientFilterType outPatientFilterType; final PatientSearchViewModel patientSearchViewModel; + const FilterDatePage( {Key key, this.outPatientFilterType, this.patientSearchViewModel}) : super(key: key); @@ -30,6 +31,8 @@ class _FilterDatePageState extends State { @override Widget build(BuildContext context) { + DateTime selectedFromDate = widget.patientSearchViewModel.selectedFromDate; + DateTime selectedToDate= widget.patientSearchViewModel.selectedToDate; var screenSize; return AppScaffold( isShowAppBar: false, @@ -235,9 +238,9 @@ class _FilterDatePageState extends State { return DateTime( DateTime .now() - .year, DateTime + .year -20, DateTime .now() - .month - 3, DateTime + .month, DateTime .now() .day); } else { @@ -257,7 +260,7 @@ class _FilterDatePageState extends State { return DateTime( DateTime .now() - .year, DateTime + .year +20, DateTime .now() .month, (DateTime .now() diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index f99f791b..953e7722 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -199,7 +199,7 @@ class _OutPatientsScreenState extends State { , prefix: IconButton( icon: Icon( - _activeLocation == 1 + _activeLocation !=0 ? DoctorApp.filter_1 : FontAwesomeIcons.slidersH, color: Colors.black, @@ -208,7 +208,7 @@ class _OutPatientsScreenState extends State { padding: EdgeInsets.only( bottom: 30), - onPressed: _activeLocation == 1 ? null : () { + onPressed: _activeLocation !=0 ? null : () { Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) => FilterDatePage(outPatientFilterType: outPatientFilterType,patientSearchViewModel: model,)));