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/dashboard_screen.dart

1257 lines
61 KiB
Dart

import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/hospital_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/referral/my-referral-patient-screen.dart';
import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.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/profile/profile-welcome-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:provider/provider.dart';
import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
import '../routes.dart';
import '../widgets/shared/app_texts_widget.dart';
import 'doctor/doctor_reply_screen.dart';
import 'doctor/my_referral_patient_screen.dart';
import 'doctor/my_referred_patient_screen.dart';
import 'medicine/medicine_search_screen.dart';
import 'patients/profile/referral/referred-patient-screen.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
class DashboardScreen extends StatefulWidget {
DashboardScreen({Key key, this.title}) : super(key: key);
final String title;
final String iconURL = 'assets/images/dashboard_icon/';
@override
_DashboardScreenState createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
HospitalViewModel hospitalProvider;
AuthViewModel authProvider;
bool isLoading = false;
ProjectViewModel projectsProvider;
var _isInit = true;
DoctorProfileModel profile;
bool isExpanded = false;
String isInpatient = "";
void didChangeDependencies() async {
super.didChangeDependencies();
if (_isInit) {
projectsProvider = Provider.of<ProjectViewModel>(context);
projectsProvider.getDoctorClinicsList();
_firebaseMessaging.setAutoInitEnabled(true);
_firebaseMessaging.getToken().then((String token) async {
if (token != '') {
DEVICE_TOKEN = token;
var request = await sharedPref.getObj(DOCTOR_PROFILE);
authProvider.insertDeviceImei(request).then((value) {
print(value);
changeIsLoading(false);
});
}
});
}
_isInit = false;
}
BuildContext myContext;
GlobalKey _one = GlobalKey();
@override
Widget build(BuildContext context) {
myContext = context;
hospitalProvider = Provider.of(context);
authProvider = Provider.of(context);
projectsProvider = Provider.of(context);
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
var _patientSearchFormValues = PatientModel(
FirstName: "0",
MiddleName: "0",
LastName: "0",
PatientMobileNumber: "0",
PatientIdentificationID: "0",
PatientID: 0,
From: DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd')
.toString(),
To: DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd')
.toString(),
LanguageID: 2,
stamp: "2020-03-02T13:56:39.170Z",
IPAdress: "11.11.11.11",
VersionID: 1.2,
Channel: 9,
TokenID: "2Fi7HoIHB0eDyekVa6tCJg==",
SessionID: "5G0yXn0Jnq",
IsLoginForDoctorApp: true,
PatientOutSA: false);
return BaseView<DashboardViewModel>(
//onModelReady: (model) => model.getDashboard(),
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: false,
body: ListView(children: [
Column(
children: <Widget>[
Stack(children: [
Column(
children: <Widget>[
ProfileWelcomeWidget(
InkWell(
onTap: () async {
showCupertinoPicker(
decKey: '',
context: context,
actionList: projectsProvider.doctorClinicsList);
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
AppText(
TranslationBase.of(context).welcome,
fontSize:
SizeConfig.textMultiplier * 1.7,
color: Colors.white,
)
],
),
SizedBox(
height: 4,
),
InkWell(
onTap: () async {
showCupertinoPicker(
decKey: '',
context: context,
actionList: projectsProvider
.doctorClinicsList);
},
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: AppText(
authProvider.selectedClinicName !=
null
? authProvider
.selectedClinicName
: authProvider.doctorProfile
.clinicDescription,
fontSize:
SizeConfig.textMultiplier *
1.7,
color: Colors.white,
textAlign: TextAlign.center,
),
alignment: projectsProvider.isArabic
? Alignment.topRight
: Alignment.topLeft,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
InkWell(
child: Container(
margin: EdgeInsets.only(
left: 5,
top: projectsProvider
.isArabic
? 0
: 5,
right: 10,
bottom: projectsProvider
.isArabic
? 15
: 7),
child: Icon(
DoctorApp.sync_icon,
color: Colors.white,
size: SizeConfig
.textMultiplier *
1.8,
)),
),
],
),
]),
),
],
),
]),
),
),
Container(
color: Colors.white,
height: this.isExpanded
? MediaQuery.of(context).size.height * 0.19
: MediaQuery.of(context).size.height * 0.12,
),
],
),
Positioned(
right: 9.0,
left: 9,
bottom: 15,
child: ExpandableCardContainer(
expandedChild: Container(
margin: EdgeInsets.only(left: 10, right: 10),
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.22
: MediaQuery.of(context).size.height * 0.25,
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
onTap: () {
setState(() {
this.isExpanded = false;
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Row(
children: [
Expanded(
child: Column(
children: [
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[0]
.value
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[0]
.value
.toString()
: "",
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[0]
.kPIParameter
: model
.dashboardItemsList[
1]
.summaryoptions[0]
.kPIParameter
: "",
//'My Admitted Patient',
color: Colors.white,
textAlign: TextAlign.center,
fontSize: 12,
)
],
)),
Expanded(
child: Column(
children: [
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[1]
.value
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[1]
.value
.toString()
: "",
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 28,
),
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[1]
.kPIParameter
: model
.dashboardItemsList[
1]
.summaryoptions[1]
.kPIParameter
: "",
color: Colors.white,
textAlign: TextAlign.center,
fontSize: 12,
)
],
)),
Expanded(
child: Column(
children: [
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[2]
.value
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[2]
.value
.toString()
: "",
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 28),
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[2]
.kPIParameter
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[2]
.kPIParameter
.toString()
: "",
color: Colors.white,
fontSize: 12,
textAlign: TextAlign.center)
],
))
],
),
Row(
children: [
Expanded(
child: Column(
children: [
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[3]
.value
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[3]
.value
.toString()
: "",
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 28),
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[3]
.kPIParameter
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[3]
.kPIParameter
.toString()
: "",
color: Colors.white,
fontSize: 12,
textAlign: TextAlign.center)
],
)),
Expanded(
child: Column(
children: [
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[
4]
.value
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[
4]
.value
.toString()
: "",
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 28),
AppText(
model.dashboardItemsList
.length >
0
? isInpatient == 'in'
? model
.dashboardItemsList[
0]
.summaryoptions[
4]
.kPIParameter
.toString()
: model
.dashboardItemsList[
1]
.summaryoptions[
4]
.kPIParameter
.toString()
: "",
color: Colors.white,
fontSize: 12,
textAlign: TextAlign.center)
],
),
),
Expanded(
child: Container(),
)
],
)
],
)),
imageName: '5.png',
color: HexColor('#B8382C'),
hasBorder: false,
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.22
: MediaQuery.of(context).size.height * 0.25,
),
],
),
),
collapsedChild: Container(
margin: EdgeInsets.only(left: 10, right: 10),
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.15
: MediaQuery.of(context).size.height * 0.25,
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
onTap: () {
setState(() {
this.isExpanded = true;
this.isInpatient = 'in';
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
AppText(
model.dashboardItemsList.length > 0
? getPatientCount(
model.dashboardItemsList[0])
: "",
fontSize:
SizeConfig.textMultiplier * 6,
color: Colors.white,
),
Flexible(
child: AppText(
TranslationBase.of(context).inPatient,
color: Colors.white,
textOverflow: TextOverflow.ellipsis,
)),
],
),
Padding(
padding: EdgeInsets.all(5),
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Icon(
DoctorApp.in_patient_white,
size: 35,
color: Colors.white,
)
],
))
],
),
),
imageName: '4.png',
color: HexColor('#B8382C'),
hasBorder: false,
width: MediaQuery.of(context).size.width * 0.44,
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.15
: MediaQuery.of(context).size.height * 0.25,
),
DashboardItem(
onTap: () {
setState(() {
isExpanded = true;
this.isInpatient = 'out';
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
AppText(
model.dashboardItemsList.length > 0
? getPatientCount(
model.dashboardItemsList[1])
: "",
fontSize:
SizeConfig.textMultiplier * 6,
color: Colors.white,
),
Flexible(
child: AppText(
TranslationBase.of(context)
.outPatients,
color: Colors.white,
textOverflow: TextOverflow.ellipsis,
)),
],
),
Padding(
padding: EdgeInsets.all(5),
child: Column(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
Icon(
DoctorApp.out_patient,
size: 35,
color: Colors.white,
)
],
))
],
),
),
imageName: '5.png',
color: HexColor('#B8382C'),
hasBorder: false,
width: MediaQuery.of(context).size.width * 0.44,
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.15
: MediaQuery.of(context).size.height * 0.25,
),
],
),
),
isExpanded: isExpanded,
))
]),
FractionallySizedBox(
widthFactor: 0.90,
child: Container(
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 10),
child: Icon(
DoctorApp.lab_results,
size: 40,
color: Colors.white,
),
),
Container(
// margin: EdgeInsets.only(bottom: 10),
child: Column(
children: <Widget>[
AppText(
model.dashboardItemsList.length > 0
? getPatientCount(
model.dashboardItemsList[5])
: "",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase.of(context)
.targetPatient,
textAlign: TextAlign.center,
color: Colors.white,
)
],
),
),
],
),
imageName: '1.png',
opacity: 0.82,
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 10),
child: Icon(
DoctorApp.radiology,
size: 40,
color: Colors.white,
),
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Column(
children: <Widget>[
AppText(
model.dashboardItemsList.length > 0
? getPatientCount(
model.dashboardItemsList[6])
: "",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase.of(context).clinic,
color: Colors.white,
)
],
),
),
],
),
imageName: '2.png',
opacity: 0.9,
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 10),
child: Icon(
DoctorApp.referral,
size: 40,
color: Colors.white,
),
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Column(
children: <Widget>[
AppText(
model.dashboardItemsList.length > 0
? getPatientCount(
model.dashboardItemsList[2])
: "",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase.of(context).referral,
color: Colors.white,
)
],
),
),
],
),
imageName: '3.png',
opacity: 0.9,
),
],
),
SizedBox(
height: 15,
),
Row(
children: <Widget>[
AppText(
TranslationBase.of(context).patientServices,
fontSize: SizeConfig.textMultiplier * 3,
),
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Center(
child: Icon(
DoctorApp.search_patient,
size: 50,
color: Colors.black,
),
),
Column(
children: [
AppText(
TranslationBase.of(context).searchAbout,
color: Colors.black,
textAlign: TextAlign.center,
),
AppText(
TranslationBase.of(context).patient,
color: Colors.black,
textAlign: TextAlign.center,
)
],
)
],
),
hasBorder: true,
onTap: () {
Navigator.of(context).pushNamed(PATIENT_SEARCH);
},
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.mail,
size: 50,
color: Colors.black,
),
Column(
children: [
AppText(
TranslationBase.of(context).theDoctor,
textAlign: TextAlign.center,
color: Colors.black,
),
AppText(
TranslationBase.of(context).reply,
textAlign: TextAlign.center,
color: Colors.black,
),
],
)
],
),
hasBorder: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DoctorReplyScreen(),
),
);
},
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.medicine_search,
size: 50,
color: Colors.black,
),
AppText(
TranslationBase.of(context).searchMedicine,
color: Colors.black,
textAlign: TextAlign.center,
)
],
),
hasBorder: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MedicineSearchScreen(),
),
);
},
),
],
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.qr_code,
size: 50,
color: Colors.black,
),
Column(
children: [
AppText(
projectsProvider.isArabic
? TranslationBase.of(context).reader
: TranslationBase.of(context).qr,
color: Colors.black,
textAlign: TextAlign.center,
),
AppText(
projectsProvider.isArabic
? TranslationBase.of(context).qr
: TranslationBase.of(context).reader,
color: Colors.black,
textAlign: TextAlign.center,
),
],
)
],
),
// imageName: '1.png',
hasBorder: true,
onTap: () {
Navigator.of(context).pushNamed(QR_READER);
},
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.referral,
size: 50,
color: Colors.black,
),
AppText(
TranslationBase.of(context).myReferralPatient,
textAlign: TextAlign.center,
color: Colors.black,
)
],
),
hasBorder: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
MyReferralPatientScreen(),
),
);
},
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.referred,
size: 50,
color: Colors.black,
),
AppText(
TranslationBase.of(context).myReferredPatient,
color: Colors.black,
textAlign: TextAlign.center,
)
],
),
hasBorder: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReferredPatientScreen(),
// MyReferredPatient(),
),
);
},
),
],
),
SizedBox(
height: 20,
),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.leaves,
size: 50,
),
AppText(
TranslationBase.of(context).rescheduleLeaves,
color: Colors.black,
textAlign: TextAlign.center,
)
],
),
hasBorder: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
AddRescheduleLeavScreen(),
// MyReferredPatient(),
),
);
},
),
SizedBox(
width: 8,
),
DashboardItem(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Icon(
DoctorApp.patient,
size: 50,
),
AppText(
TranslationBase.of(context).arrived,
color: Colors.black,
textAlign: TextAlign.center,
)
],
),
hasBorder: true,
onTap: () {
Navigator.of(context)
.pushNamed(PATIENTS, arguments: {
"patientSearchForm": _patientSearchFormValues,
"selectedType": "7"
});
},
)
],
),
SizedBox(
height: 20,
),
],
),
),
),
],
),
]),
),
);
}
showCupertinoPicker(
{context, List<ClinicModel> actionList, decKey, onSelectFun}) {
showModalBottomSheet(
isDismissible: false,
isScrollControlled: true,
context: context,
builder: (BuildContext builder) {
return Container(
// height: 500,
height: SizeConfig.realScreenHeight * 0.4,
color: Color(0xfff7f7f7),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
color: Color(0xfff7f7f7),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
CupertinoButton(
child: AppText(TranslationBase.of(context).cancel
// style: TextStyle(context)
),
onPressed: () {
Navigator.pop(context);
},
),
CupertinoButton(
child: AppText(TranslationBase.of(context).done
// style: textStyle(context),
),
onPressed: () {
Navigator.pop(context);
// onSelectFun(cupertinoPickerIndex);
},
)
],
),
),
Container(
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child: Column(
children: actionList
.map((e) => Flexible(
child: Container(
height: 50,
child: InkWell(
onTap: () =>
changeClinic(e.clinicID, context),
child: AppText(
e.clinicName,
fontSize:
SizeConfig.textMultiplier * 1.9,
)),
),
))
.toList(),
))
],
),
);
});
}
changeClinic(clinicId, BuildContext context) async {
Navigator.pop(context);
changeIsLoading(true);
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: doctorProfile.doctorID,
clinicID: clinicId,
license: true,
projectID: doctorProfile.projectID,
tokenID: '',
languageID: 2);
// authProvider.getDocProfiles(docInfo)
authProvider.getDocProfiles(docInfo.toJson()).then((res) async {
changeIsLoading(false);
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
}).catchError((err) {
changeIsLoading(false);
helpers.showErrorToast(err);
});
}
changeIsLoading(bool val) {
setState(() {
this.isLoading = val;
});
}
getPatientCount(DashboardModel inPatientCount) {
int value = 0;
inPatientCount.summaryoptions.forEach((result) => {value += result.value});
return value.toString();
}
}
// TODO Move to it file
class DashboardItem extends StatelessWidget {
const DashboardItem(
{this.hasBorder = false,
this.imageName,
@required this.child,
this.onTap,
Key key,
this.width,
this.height,
this.color,
this.opacity = 0.4})
: super(key: key);
final bool hasBorder;
final String imageName;
final Widget child;
final Function onTap;
final double width;
final double height;
final Color color;
final double opacity;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
width: width != null ? width : MediaQuery.of(context).size.width * 0.29,
height: height != null
? height
: MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.height * 0.19
: MediaQuery.of(context).size.height * 0.35,
decoration: BoxDecoration(
color: !hasBorder
? color != null
? color
: HexColor('#050705').withOpacity(opacity)
: Colors.white,
borderRadius: BorderRadius.circular(6.0),
border: hasBorder
? Border.all(width: 1.0, color: const Color(0xffcccccc))
: Border.all(width: 0.0, color: Colors.transparent),
image: imageName != null
? DecorationImage(
image: AssetImage('assets/images/dashboard/${imageName}'),
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(
Colors.black.withOpacity(0.2), BlendMode.dstIn),
)
: null,
),
child: Center(
child: child,
),
),
);
}
}
class ExpandableCardContainer extends StatefulWidget {
final bool isExpanded;
final Widget collapsedChild;
final Widget expandedChild;
const ExpandableCardContainer(
{Key key, this.isExpanded, this.collapsedChild, this.expandedChild})
: super(key: key);
@override
_ExpandableCardContainerState createState() =>
_ExpandableCardContainerState();
}
class _ExpandableCardContainerState extends State<ExpandableCardContainer> {
@override
Widget build(BuildContext context) {
return new AnimatedContainer(
duration: new Duration(milliseconds: 1000),
curve: Curves.easeInOut,
child: widget.isExpanded ? widget.expandedChild : widget.collapsedChild,
);
}
}