import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.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/providers/auth_provider.dart'; import 'package:doctor_app_flutter/providers/doctor_reply_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/providers/referral_patient_provider.dart'; import 'package:doctor_app_flutter/providers/referred_patient_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/'; @override _DashboardScreenState createState() => _DashboardScreenState(); } class _DashboardScreenState extends State { HospitalProvider hospitalProvider; AuthProvider authProvider; bool isLoading = false; ProjectProvider projectsProvider; var _isInit = true; DoctorProfileModel profile; void didChangeDependencies() async { super.didChangeDependencies(); if (_isInit) { projectsProvider = Provider.of(context); projectsProvider.getDoctorClinicsList(); } _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(); } return SafeArea( bottom: true, child: AppScaffold( isShowAppBar: false, isLoading: isLoading, body: ListView(children: [ Column( children: [ Stack(children: [ Column( children: [ Container( height: 140, color: Hexcolor('#515B5D'), width: double.infinity, child: FractionallySizedBox( widthFactor: 0.9, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Row( children: [ AppText( TranslationBase .of(context) .welcome, fontSize: SizeConfig.textMultiplier * 1.7, color: Colors.white, ) ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ 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: [ 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: [ 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: [ 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: [ 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: [ 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: [ 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: [ 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: [ 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: [ 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: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ 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: [ 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: [ Container( child: Icon( DoctorApp.radiology, size: 40, color: Colors.white, ), ), Container( child: Column( children: [ 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: [ Container( margin: EdgeInsets.only(top: 10), child: Icon( DoctorApp.referral, size: 40, color: Colors.white, ), ), Container( margin: EdgeInsets.only(bottom: 10), child: Column( children: [ AppText( "05", 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( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ DashboardItem( child: Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ Icon( DoctorApp.in_patient_white, size: 40, color: Colors.white, ), ], ), Column( mainAxisAlignment: MainAxisAlignment.end, children: [ 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, ), DashboardItem( child: Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( children: [ Icon( DoctorApp.operations, size: 40, color: Colors.white, ), ], ), Column( mainAxisAlignment: MainAxisAlignment.end, children: [ 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: [ AppText( TranslationBase .of(context) .patientServices, fontSize: SizeConfig.textMultiplier * 3, ), ], ), SizedBox( height: 10, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Center( child: Icon( DoctorApp.search_patient, size: 50, color: Colors.black, ), ), AppText( TranslationBase .of(context) .searchPatient, color: Colors.black, textAlign: TextAlign.center, ) ], ), hasBorder: true, onTap: () { Navigator.of(context).pushNamed(PATIENT_SEARCH); }, ), DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon( DoctorApp.mail, size: 50, color: Colors.black, ), AppText( TranslationBase .of(context) .doctorReply, textAlign: TextAlign.center, color: Colors.black, ) ], ), hasBorder: true, onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => ChangeNotifierProvider( create: (_) => DoctorReplyProvider(), child: DoctorReplyScreen(), ), ), ); }, ), DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ 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: [ DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Icon( DoctorApp.qr_code, size: 50, color: Colors.black, ), AppText( TranslationBase .of(context) .qrReader, 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: [ 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) => ChangeNotifierProvider( create: (_) => MyReferralPatientProvider(), child: MyReferralPatient(), ), ), ); }, ), DashboardItem( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ 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) => ChangeNotifierProvider( create: (_) => MyReferredPatientProvider(), child: MyReferredPatient(), ), ), ); }, ), ], ), SizedBox( height: 20, ), ], ), ), ), ], ), ]), ), ); } showCupertinoPicker( {context, List 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: [ Container( color: Color(0xfff7f7f7), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ 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; }); } } // 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,), ), ); } }