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.
doctor_app_flutter/lib/screens/home/home_screen.dart

316 lines
12 KiB
Dart

import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
5 years ago
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/home/dashboard_slider-item-widget.dart';
import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart';
import 'package:doctor_app_flutter/screens/home/home_patient_card.dart';
import 'package:doctor_app_flutter/screens/live_care/live_care_patient_screen.dart';
import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart';
import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart';
5 years ago
import 'package:doctor_app_flutter/screens/patients/out_patient/out_patient_screen.dart';
import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen.dart';
5 years ago
import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
5 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'home_screen_header.dart';
4 years ago
import 'label.dart';
5 years ago
class HomeScreen extends StatefulWidget {
HomeScreen({Key? key, this.title}) : super(key: key);
5 years ago
final String? title;
5 years ago
final String iconURL = 'assets/images/dashboard_icon/';
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
bool isLoading = false;
ProjectViewModel projectsProvider;
DoctorProfileModel profile;
bool isExpanded = false;
5 years ago
bool isInpatient = false;
5 years ago
int sliderActiveIndex = 0;
String clinicId;
late AuthenticationViewModel authenticationViewModel;
int colorIndex = 0;
4 years ago
final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
5 years ago
@override
Widget build(BuildContext context) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
5 years ago
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
return BaseView<DashboardViewModel>(
4 years ago
onModelReady: (model) async {
await model.setFirebaseNotification(projectsProvider, authenticationViewModel);
await model.getDashboard();
await model.getDoctorProfile(isGetProfile: true);
await model.checkDoctorHasLiveCare();
// await model.getSpecialClinicalCareList();
},
5 years ago
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: true,
appBar: HomeScreenHeader(
model: model,
4 years ago
onOpenDrawer: (){
Scaffold.of(context).openDrawer();
},
),
5 years ago
body: ListView(children: [
5 years ago
Column(children: <Widget>[
// SizedBox(
// height: SizeConfig.heightMultiplier * 1.4,
// ),
model.dashboardItemsList.length > 0
? DashboardSwipeWidget(
model.dashboardItemsList,
model,
(sliderIndex) {
setState(() {
sliderActiveIndex = sliderIndex;
});
},
)
: SizedBox(),
// SizedBox(
// height: SizeConfig.heightMultiplier * 1.4,
// ),
model.dashboardItemsList.length > 0
? FractionallySizedBox(
widthFactor: 0.94,
5 years ago
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
5 years ago
children: <Widget>[
5 years ago
SizedBox(
height: SizeConfig.heightMultiplier * 3,
5 years ago
),
sliderActiveIndex == 1
? DashboardSliderItemWidget(
model.dashboardItemsList[4])
: sliderActiveIndex == 0
? DashboardSliderItemWidget(
model.dashboardItemsList[3])
: DashboardSliderItemWidget(
model.dashboardItemsList[6]),
5 years ago
],
),
5 years ago
),
)
: SizedBox(),
SizedBox(
height: SizeConfig.heightMultiplier * 1.4,
),
FractionallySizedBox(
// widthFactor: 0.90,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(70),
)),
padding: EdgeInsets.only(left: SizeConfig.widthMultiplier * 3.1, top: 10, right: SizeConfig.widthMultiplier * 3.1),
margin: EdgeInsets.only(top: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: SizeConfig.heightMultiplier * 1,
),
Container(
child: Label(
firstLine: TranslationBase.of(context).patients,
secondLine: TranslationBase.of(context).services,
)),
SizedBox(
height: SizeConfig.heightMultiplier * .6,
),
Container(
height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort
? 16
: SizeConfig.isHeightShort
? 14
4 years ago
: SizeConfig.isHeightLarge?15:13),
child: ListView(
scrollDirection: Axis.horizontal,
children: [
...homePatientsCardsWidget(model, projectsProvider),
5 years ago
],
),
5 years ago
),
SizedBox(height: SizeConfig.heightMultiplier* (SizeConfig.isHeightVeryShort?3:SizeConfig.isHeightShort?4:2))
],
),
5 years ago
),
),
5 years ago
]),
5 years ago
]),
),
);
}
List<Widget> homePatientsCardsWidget(DashboardViewModel model,projectsProvider) {
colorIndex = 0;
List<Color> backgroundColors = List(3);
backgroundColors[0] = Color(0xffD02127);
backgroundColors[1] = Colors.grey[300];
backgroundColors[2] = Color(0xff2B353E);
List<Color> backgroundIconColors = List(3);
backgroundIconColors[0] = Colors.white12;
backgroundIconColors[1] = Colors.white38;
backgroundIconColors[2] = Colors.white10;
List<Color> textColors = List(3);
textColors[0] = Colors.white;
textColors[1] = Color(0xFF353E47);
textColors[2] = Colors.white;
List<HomePatientCard> patientCards = List();
if (model.hasVirtualClinic) {
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.livecare,
textColor: textColors[colorIndex],
iconSize: 21,
text: "${TranslationBase.of(context).liveCare}\n${TranslationBase.of(context).patients}",
onTap: () {
Navigator.push(
context,
FadePage(
page: LiveCarePatientScreen(),
),
);
},
));
changeColorIndex();
}
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.inpatient,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).myInPatient!,
onTap: () {
Navigator.push(
context,
FadePage(
page: PatientInPatientScreen(specialClinic: model.getSpecialClinic(clinicId??projectsProvider
.doctorClinicsList[0].clinicID),),
),
);
},
));
changeColorIndex();
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.arrival_patients,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).myOutPatient_2lines!,
onTap: () {
String date = AppDateUtils.convertDateToFormat(
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), 'yyyy-MM-dd');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OutPatientsScreen(
patientSearchRequestModel: PatientSearchRequestModel(
from: date, to: date, doctorID: authenticationViewModel.doctorProfile!.doctorID)),
));
},
));
changeColorIndex();
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.referral_1,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).myPatientsReferral!,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PatientReferralScreen(),
),
);
},
));
changeColorIndex();
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.search,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).searchPatientDashBoard!,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PatientSearchScreen(),
));
},
));
changeColorIndex();
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIcon: DoctorApp.search_medicines,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).searchMedicineDashboard!,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MedicineSearchScreen(),
));
},
));
changeColorIndex();
return [...List.generate(patientCards.length, (index) => patientCards[index]).toList()];
}
changeColorIndex() {
colorIndex++;
if (colorIndex > 2) {
colorIndex = 0;
}
}
5 years ago
}