You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/screens/patients/In_patient/in_patient_screen.dart

209 lines
8.6 KiB
Dart

import 'package:doctor_app_flutter/config/config.dart';
4 years ago
import 'package:doctor_app_flutter/core/enum/view_state.dart';
3 years ago
import 'package:doctor_app_flutter/core/model/dashboard/get_special_clinical_care_List_Respose_Model.dart';
5 years ago
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
5 years ago
import 'package:doctor_app_flutter/screens/patients/In_patient/InPatientHeader.dart';
4 years ago
import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart';
4 years ago
import 'package:doctor_app_flutter/utils/tab_utils.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
3 years ago
import 'package:doctor_app_flutter/utils/utils.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
3 years ago
import '../DischargedPatientPage.dart';
import 'in_patient_list_page.dart';
class InPatientScreen extends StatefulWidget {
3 years ago
GetSpecialClinicalCareListResponseModel? specialClinic;
bool isAllClinic = true;
bool showBottomSheet = false;
String selectedClinicName = "";
5 years ago
InPatientScreen({Key? key, required this.specialClinic});
@override
_InPatientScreenState createState() => _InPatientScreenState();
}
3 years ago
class _InPatientScreenState extends State<InPatientScreen> with SingleTickerProviderStateMixin {
late TabController _tabController;
int _activeTab = 0;
3 years ago
int selectedMapId = 0;
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
_tabController.addListener(_handleTabSelection);
}
@override
void dispose() {
super.dispose();
_tabController.dispose();
}
_handleTabSelection() {
4 years ago
Utils.hideKeyboard(context);
setState(() {
widget.showBottomSheet = false;
_activeTab = _tabController.index;
});
}
@override
Widget build(BuildContext context) {
5 years ago
final screenSize = MediaQuery.of(context).size;
5 years ago
PatientSearchRequestModel requestModel = PatientSearchRequestModel();
return BaseView<PatientSearchViewModel>(
5 years ago
onModelReady: (model) async {
model.clearPatientList();
3 years ago
if (widget.specialClinic != null && widget.specialClinic!.clinicID != null) {
print(widget.specialClinic!.toJson());
await model.getSpecialClinicalCareMappingList(widget.specialClinic!.clinicID);
// requestModel.nursingStationID =
// model.specialClinicalCareMappingList[0].nursingStationID;
}
requestModel.clinicID = 0;
await model.getInPatientList(requestModel);
5 years ago
},
5 years ago
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
5 years ago
isShowAppBar: true,
appBar: InPatientHeader(
model: model,
selectedMapId: selectedMapId,
3 years ago
specialClinic: widget.specialClinic!,
activeTab: _activeTab,
onChangeFunc: (newValue) async {
setState(() {
selectedMapId = newValue;
});
model.clearPatientList();
GifLoaderDialogUtils.showMyDialog(context);
3 years ago
PatientSearchRequestModel requestModel = PatientSearchRequestModel(nursingStationID: selectedMapId, clinicID: 0);
await model.getInPatientList(requestModel, isLocalBusy: true);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
} else {
3 years ago
onChangeState(isAllClinic: true, showBottomSheet: false, selectedClinicName: null);
}
}),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Scaffold(
extendBodyBehindAppBar: false,
appBar: PreferredSize(
3 years ago
preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.070),
child: Container(
height: MediaQuery.of(context).size.height * 0.070,
decoration: BoxDecoration(
border: Border(
3 years ago
bottom: BorderSide(color: Theme.of(context).dividerColor, width: 0.5), //width: 0.7
),
color: Colors.white),
5 years ago
child: Container(
margin: EdgeInsets.only(top: 9),
color: TabUtils.getBgTabColor(),
child: TabBar(
isScrollable: false,
controller: _tabController,
indicatorColor: AppGlobal.appRedColor,
5 years ago
indicatorWeight: 0.001,
5 years ago
indicator: BoxDecoration(),
5 years ago
// indicatorSize: TabBarIndicatorSize.tab,
// labelColor: Theme.of(context).primaryColor,
3 years ago
labelPadding: EdgeInsets.only(top: 0, left: 0, right: 0, bottom: 0),
5 years ago
// unselectedLabelColor: Colors.grey[800],
tabs: [
3 years ago
tabWidget(screenSize, _activeTab == 0, TranslationBase.of(context).inPatientAll, context: context, counter: model.inPatientList.length, isFirst: true),
5 years ago
tabWidget(
screenSize,
_activeTab == 1,
TranslationBase.of(context).myInPatientTitle,
counter: model.myIinPatientList.length,
isMiddle: true,
context: context,
),
tabWidget(
screenSize,
_activeTab == 2,
TranslationBase.of(context).discharged,
isLast: true,
context: context,
),
],
),
),
),
),
body: Column(
children: [
Expanded(
child: TabBarView(
physics: BouncingScrollPhysics(),
controller: _tabController,
children: [
InPatientListPage(
isMyInPatient: false,
patientSearchViewModel: model,
isAllClinic: widget.isAllClinic,
showBottomSheet: widget.showBottomSheet,
selectedClinicName: widget.selectedClinicName,
onChangeValue: onChangeState),
InPatientListPage(
isMyInPatient: true,
patientSearchViewModel: model,
isAllClinic: widget.isAllClinic,
showBottomSheet: widget.showBottomSheet,
selectedClinicName: widget.selectedClinicName,
onChangeValue: onChangeState),
DischargedPatient(),
],
),
),
],
),
),
),
],
),
),
);
}
onChangeState({isAllClinic, showBottomSheet, selectedClinicName}) {
setState(() {
widget.isAllClinic = isAllClinic;
widget.showBottomSheet = showBottomSheet;
widget.selectedClinicName = selectedClinicName;
});
}
3 years ago
Widget tabWidget(Size screenSize, bool isActive, String title, {int counter = -1, bool isFirst = false, bool isMiddle = false, bool isLast = false, BuildContext? context}) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context!);
return Center(
child: Container(
height: TabUtils.getTabHeight(context!),
3 years ago
decoration: TabUtils.getBoxTabsBoxDecoration(isActive: isActive, isFirst: isFirst, isMiddle: isMiddle, isLast: isLast, projectViewModel: projectsProvider),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
3 years ago
children: [TabUtils.getTabText(title: title, isActive: isActive), if (counter != -1) TabUtils.getTabCounter(isActive: isActive, counter: counter)],
),
),
);
}
}