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

1039 lines
45 KiB
Dart

import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
5 years ago
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
4 years ago
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/providers/auth_provider.dart';
import 'package:doctor_app_flutter/providers/hospital_provider.dart';
import 'package:doctor_app_flutter/providers/medicine_provider.dart';
import 'package:doctor_app_flutter/providers/project_provider.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/shared/app_scaffold_widget.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 '../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';
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/';
4 years ago
@override
_DashboardScreenState createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
HospitalProvider hospitalProvider;
AuthProvider authProvider;
bool isLoading = false;
ProjectProvider projectsProvider;
4 years ago
var _isInit = true;
DoctorProfileModel profile;
4 years ago
void didChangeDependencies() async {
4 years ago
super.didChangeDependencies();
if (_isInit) {
projectsProvider = Provider.of<ProjectProvider>(context);
projectsProvider.getDoctorClinicsList();
4 years ago
}
_isInit = false;
}
BuildContext myContext;
GlobalKey _one = GlobalKey();
4 years ago
@override
Widget build(BuildContext context) {
myContext = context;
hospitalProvider = Provider.of(context);
authProvider = Provider.of(context);
projectsProvider = Provider.of(context);
4 years ago
FocusScopeNode currentFocus = FocusScope.of(context);
4 years ago
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
return SafeArea(
bottom: true,
child: AppScaffold(
isShowAppBar: false,
isLoading: isLoading,
body: ListView(children: [
Column(
children: <Widget>[
Stack(children: [
Column(
children: <Widget>[
Container(
height: 140,
color: Hexcolor('#515B5D'),
width: double.infinity,
child: FractionallySizedBox(
widthFactor: 0.9,
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,
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
AppText(
'Dr. ${authProvider.doctorProfile.doctorName}',
fontWeight: FontWeight.bold,
fontSize: SizeConfig.textMultiplier * 2.5,
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,
)),
),
],
),
]),
),
],
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Theme
.of(context)
.backgroundColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
height: 50,
width: 60,
child: Image.network(
authProvider.doctorProfile
.doctorImageURL,
// fit: BoxFit.fill,
),
),
],
),
),
],
),
),
),
Container(
color: Colors.white,
height: 90,
),
],
),
Positioned(
right: 9.0,
left: 9,
bottom: 19,
child: Container(
decoration: BoxDecoration(
color: Hexcolor("#DED8CF"),
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
margin: EdgeInsets.only(left: 10, right: 10),
height: 140,
width: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Divider(),
Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 8, right: 40, left: 8),
child: CircularPercentIndicator(
radius: 100,
animation: true,
animationDuration: 1200,
lineWidth: 7.0,
percent: .75,
center: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AppText("38",
fontSize:
SizeConfig.textMultiplier * 3.7,
color: Hexcolor('#5D4C35'),
fontWeight: FontWeight.bold,),
AppText(TranslationBase
.of(context)
.outPatients,
fontWeight: FontWeight.normal,
fontSize: SizeConfig.textMultiplier * 1.4,
color: Hexcolor('#5D4C35'),
),
],
),
circularStrokeCap: CircularStrokeCap.butt,
backgroundColor: Colors.blueGrey[100],
progressColor: Hexcolor('#B8382C'),
),
),
Container(
child: Table(
defaultColumnWidth: FixedColumnWidth(
MediaQuery.of(context).size.width / 5),
// border: TableBorder.all(
// color: Colors.black26,
// width: 1,
// style: BorderStyle.solid),
border: TableBorder.symmetric(
inside: BorderSide(
width: 0.5,
color: Hexcolor('#5D4C35'),
),
),
children: [
TableRow(
children: [
TableCell(
child: Center(
child: Column(
children: <Widget>[
AppText(
TranslationBase.of(context).arrived,
fontSize:
SizeConfig.textMultiplier * 1.5,
color: Hexcolor('#5D4C35'),
),
AppText(
"23",
fontSize:
SizeConfig.textMultiplier * 2.7,
color: Hexcolor('#5D4C35'),
fontWeight: FontWeight.bold,
),
SizedBox(
height: 6,
),
],
),
)),
TableCell(
child: Column(
children: <Widget>[
AppText(
TranslationBase.of(context).er,
fontSize:
SizeConfig.textMultiplier * 1.5,
color: Hexcolor('#5D4C35'),
),
AppText(
"03",
fontSize:
SizeConfig.textMultiplier * 2.7,
color: Hexcolor('#5D4C35'),
fontWeight: FontWeight.bold,
),
SizedBox(
height: 6,
),
],
),
),
],
//
),
TableRow(children: [
TableCell(
child: Column(
children: <Widget>[
SizedBox(
height: 6,
),
AppText(
TranslationBase.of(context).notArrived,
fontSize:
SizeConfig.textMultiplier * 1.5,
color: Hexcolor('#5D4C35'),
),
AppText(
"15",
fontSize:
SizeConfig.textMultiplier * 2.7,
color: Hexcolor('#5D4C35'),
fontWeight: FontWeight.bold,
),
],
),
),
TableCell(
child: Column(
children: <Widget>[
SizedBox(
height: 6,
),
AppText(
TranslationBase.of(context).walkIn,
fontSize:
SizeConfig.textMultiplier * 1.5,
color: Hexcolor('#5D4C35'),
),
AppText(
"04",
fontSize:
SizeConfig.textMultiplier * 2.7,
color: Hexcolor('#5D4C35'),
fontWeight: FontWeight.bold,
),
],
),
),
]),
],
),
),
Divider(),
],
),
),
)
]),
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(
"08",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase
.of(context)
.labResult,
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(
"10",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase
.of(context)
.radiology,
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(
"05",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase
.of(context)
.referral,
color: Colors.white,
)
],
),
),
],
),
imageName: '3.png',
opacity: 0.9,
),
],
5 years ago
),
SizedBox(
height: 15,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DashboardItem(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: <Widget>[
Icon(
DoctorApp.in_patient_white,
size: 40,
color: Colors.white,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppText(
"14",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase
.of(context)
.inPatient,
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.13:
MediaQuery
.of(context)
.size
.height * 0.25,
5 years ago
),
DashboardItem(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: <Widget>[
Icon(
DoctorApp.operations,
size: 40,
color: Colors.white,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppText(
"07",
fontSize: SizeConfig.textMultiplier * 6,
color: Colors.white,
),
AppText(
TranslationBase
.of(context)
.operations,
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.13:
MediaQuery
.of(context)
.size
.height * 0.25,
),
],
),
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) =>
ChangeNotifierProvider(
create: (_) => MedicineProvider(),
child: 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) =>
MyReferralPatient(),
),
);
},
),
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) =>
MyReferredPatient(),
),
);
},
),
],
),
SizedBox(
height: 20,
),
],
),
),
),
],
),
]),
),
);
}
4 years ago
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)
),
4 years ago
onPressed: () {
Navigator.pop(context);
},
),
CupertinoButton(
child: AppText(TranslationBase
.of(context)
.done
// style: textStyle(context),
),
4 years ago
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,
)),
),
4 years ago
))
.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;
});
}
}
// 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,),
),
);
}
}