diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 74c4c363..45b73329 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -121,16 +121,20 @@ class PatientSearchViewModel extends BaseViewModel{ List filteredInPatientItems = List(); Future getInPatientList(PatientSearchRequestModel requestModel, - {bool isMyInpatient = false}) async { - setState(ViewState.Busy); + {bool isMyInpatient = false, bool isFirstTime = true}) async { + if (isFirstTime) + setState(ViewState.Busy); + else + setState(ViewState.BusyLocal); await _inPatientService.getInPatientList(requestModel, isMyInpatient); if (_inPatientService.hasError) { error = _inPatientService.error; setState(ViewState.Error); } else { - setState(ViewState.Idle); filteredInPatientItems.clear(); - filteredInPatientItems.addAll(_inPatientList); + if (_inPatientList.length > 0) + filteredInPatientItems.addAll(_inPatientList); + setState(ViewState.Idle); } } @@ -153,7 +157,9 @@ class PatientSearchViewModel extends BaseViewModel{ } notifyListeners(); } else { - filteredInPatientItems = _inPatientList; + if (_inPatientList.length > 0) + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(_inPatientList); notifyListeners(); } } diff --git a/lib/screens/patients/PatientsInPatientScreen.dart b/lib/screens/patients/PatientsInPatientScreen.dart index e46055d5..ba8b5f0a 100644 --- a/lib/screens/patients/PatientsInPatientScreen.dart +++ b/lib/screens/patients/PatientsInPatientScreen.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/helpers.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/shared/app_scaffold_widget.dart'; @@ -71,32 +72,35 @@ class _PatientInPatientScreenState extends State { ), ), tabsBar(context, screenSize, model), + Container( + margin: EdgeInsets.all(16.0), + child: AppTextFieldCustom( + hintText: TranslationBase.of(context) + .searchPatientName, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.search, + color: Colors.black, + ), + onPressed: () {}, + ), + controller: _searchController, + onChanged: (value) { + model.filterSearchResults(value); + }), + ), model.filteredInPatientItems.length > 0 ? Expanded( child: Container( - margin: EdgeInsets.all(16.0), + margin: EdgeInsets.symmetric(horizontal: 16.0), child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppTextFieldCustom( - hintText: TranslationBase.of(context) - .searchPatientName, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.black, - ), - onPressed: () {}, - ), - controller: _searchController, - onChanged: (value) { - model.filterSearchResults(value); - }), - const SizedBox( - height: 16, - ), + // const SizedBox( + // height: 16, + // ), ...model.filteredInPatientItems.map((item) { return PatientCard( patientInfo: item, @@ -104,6 +108,11 @@ class _PatientInPatientScreenState extends State { arrivalType: "1", isInpatient: true, onTap: () { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + Navigator.of(context) .pushNamed(PATIENTS_PROFILE, arguments: { "patient": item, @@ -122,9 +131,13 @@ class _PatientInPatientScreenState extends State { ), ), ) - : Container( - child: ErrorMessage( - error: TranslationBase.of(context).noDataAvailable)), + : Expanded( + child: SingleChildScrollView( + child: Container( + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable)), + ), + ), ], ), ), @@ -155,10 +168,16 @@ class _PatientInPatientScreenState extends State { setState(() { _activeTab = _tabs.indexOf(item); }); - // GifLoaderDialogUtils.showMyDialog( - // context); + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + GifLoaderDialogUtils.showMyDialog( + context); await model.getInPatientList(requestModel, - isMyInpatient: _activeTab == 1); + isMyInpatient: _activeTab == 1, isFirstTime: false); + GifLoaderDialogUtils.hideDialog( + context); }, child: Center( child: Container(