From 83ab0cff649eea7146386caf3572fffca731a4a1 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 18 Apr 2021 12:54:50 +0300 Subject: [PATCH] fix home --- lib/landing_page.dart | 4 +- lib/routes.dart | 2 +- lib/screens/dashboard_screen.dart | 1431 -------------------------- lib/screens/home/home_page_card.dart | 62 ++ lib/screens/home/home_screen.dart | 920 +++++++++++++++++ 5 files changed, 985 insertions(+), 1434 deletions(-) delete mode 100644 lib/screens/dashboard_screen.dart create mode 100644 lib/screens/home/home_page_card.dart create mode 100644 lib/screens/home/home_screen.dart diff --git a/lib/landing_page.dart b/lib/landing_page.dart index 303b4413..a48b550f 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -1,5 +1,5 @@ import 'package:doctor_app_flutter/screens/QR_reader_screen.dart'; -import 'package:doctor_app_flutter/screens/dashboard_screen.dart'; +import 'package:doctor_app_flutter/screens/home/home_screen.dart'; import 'package:doctor_app_flutter/screens/doctor/doctor_reply_screen.dart'; import 'package:doctor_app_flutter/screens/doctor/message_screen.dart'; import 'package:doctor_app_flutter/screens/doctor/my_schedule_screen.dart'; @@ -66,7 +66,7 @@ class _LandingPageState extends State { controller: pageController, children: [ ShowCaseWidget( - builder: Builder(builder: (context) => DashboardScreen()), + builder: Builder(builder: (context) => HomeScreen()), ), MyScheduleScreen(), QrReaderScreen(), diff --git a/lib/routes.dart b/lib/routes.dart index dc905ba8..dbe4f0cb 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -28,7 +28,7 @@ import './screens/auth/login_screen.dart'; import './screens/auth/verification_methods_screen.dart'; import './screens/auth/verify_account_screen.dart'; import './screens/blood_bank_screen.dart'; -import './screens/dashboard_screen.dart'; +import 'screens/home/home_screen.dart'; import './screens/doctor/message_screen.dart'; import './screens/doctor/my_schedule_screen.dart'; import './screens/doctor/services_screen.dart'; diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart deleted file mode 100644 index c249c0bc..00000000 --- a/lib/screens/dashboard_screen.dart +++ /dev/null @@ -1,1431 +0,0 @@ -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:charts_flutter/flutter.dart' as charts; -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/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/medicine/search_medicine_patient_screen.dart'; -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/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/dashboard/guage_chart.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/Text.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:flutter_swiper/flutter_swiper.dart'; -import 'package:hexcolor/hexcolor.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 '../widgets/shared/rounded_container_widget.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 { - final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); - HospitalViewModel hospitalProvider; - AuthViewModel authProvider; - bool isLoading = false; - ProjectViewModel projectsProvider; - var _isInit = true; - DoctorProfileModel profile; - bool isExpanded = false; - String isInpatient = ""; - var clinicName = []; - int sliderActiveIndex = 0; - var clinicId; - 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); - void didChangeDependencies() async { - super.didChangeDependencies(); - if (_isInit) { - projectsProvider = Provider.of(context); - projectsProvider.getDoctorClinicsList(); - - // _firebaseMessaging.setAutoInitEnabled(true); - _firebaseMessaging.requestNotificationPermissions( - const IosNotificationSettings( - sound: true, badge: true, alert: true, provisional: true)); - _firebaseMessaging.onIosSettingsRegistered - .listen((IosNotificationSettings settings) { - print("Settings registered: $settings"); - }); - clinicName = await sharedPref.getObj(CLINIC_NAME); - print(clinicName); - _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(); - } - - return BaseView( - onModelReady: (model) => model.getDashboard(), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: ListView(children: [ - Column( - children: [ - Stack(children: [ - Column( - children: [ - ProfileWelcomeWidget( - Row( - children: [ - Container( - padding: EdgeInsets.all(4), - margin: EdgeInsets.all(4), - decoration: new BoxDecoration( - color: Colors.red[800], - borderRadius: BorderRadius.circular(20), - ), - constraints: BoxConstraints( - minWidth: 20, - minHeight: 20, - ), - child: new Text( - projectsProvider.doctorClinicsList.length - .toString(), - style: new TextStyle( - color: Colors.white, - fontSize: projectsProvider.isArabic ? 10 : 11, - ), - textAlign: TextAlign.center, - ), - ), - Container( - width: MediaQuery.of(context).size.width * .6, - // // height: 100, - child: projectsProvider.doctorClinicsList.length > 0 - ? Stack( - children: [ - DropdownButtonHideUnderline( - child: DropdownButton( - dropdownColor: Colors.white, - iconEnabledColor: Colors.black, - isExpanded: true, - value: clinicId == null - ? projectsProvider - .doctorClinicsList[0].clinicID - : clinicId, - iconSize: 25, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return projectsProvider - .doctorClinicsList - .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText(item.clinicName, - fontSize: SizeConfig - .textMultiplier * - 1.6, - color: Colors.black, - fontWeight: FontWeight.bold, - textAlign: - TextAlign.center), - ], - ); - }).toList(); - }, - onChanged: (newValue) { - clinicId = newValue; - changeClinic( - newValue, context, model); - }, - items: projectsProvider - .doctorClinicsList - .map((item) { - return DropdownMenuItem( - child: Text( - item.clinicName, - textAlign: TextAlign.end, - ), - value: item.clinicID, - ); - }).toList(), - )), - ], - ) - : AppText(TranslationBase.of(context).noClinic), - ), - ], - ), - isClilic: true, - ), - Container( - height: MediaQuery.of(context).size.height * 0.20, - ), - ], - ), - Positioned( - right: 9.0, - left: 9, - top: MediaQuery.of(context).size.height * .05, - child: Container( - height: MediaQuery.of(context).size.height * 0.30, - child: model.dashboardItemsList.length > 0 - ? new Swiper( - onIndexChanged: (index) { - if (mounted) { - setState(() { - sliderActiveIndex = index; - }); - } - }, - itemBuilder: (BuildContext context, int index) { - return getSwiperWidget(model)[index]; - }, - itemCount: 3, - - pagination: new SwiperCustomPagination(builder: - (BuildContext context, - SwiperPluginConfig config) { - return new Stack( - alignment: Alignment.bottomCenter, - children: [ - Positioned( - bottom: -5, - child: Center( - child: InkWell( - onTap: () {}, - child: Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Container( - height: 10, - width: 50, - margin: - EdgeInsets.all(2), - color: - config.activeIndex == - 0 - ? Colors.black - : Colors - .grey), - Container( - height: 10, - width: 50, - margin: - EdgeInsets.all(2), - color: - config.activeIndex == - 1 - ? Colors.black - : Colors - .grey), - Container( - height: 10, - width: 50, - margin: - EdgeInsets.all(2), - color: - config.activeIndex == - 2 - ? Colors.black - : Colors - .grey), - ], - ))))) - ]); - }), - viewportFraction: 0.9, - // scale: 0.9, - // control: new SwiperControl(), - ) - : SizedBox()), - - //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: [ - // 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: [ - // DashboardItem( - // onTap: () { - // setState(() { - // this.isExpanded = true; - // this.isInpatient = 'in'; - // }); - // }, - // child: Padding( - // padding: const EdgeInsets.all(8.0), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.spaceBetween, - // children: [ - // Column( - // mainAxisAlignment: - // MainAxisAlignment.start, - // children: [ - // 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: [ - // Column( - // mainAxisAlignment: - // MainAxisAlignment.start, - // children: [ - // 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, - // )) - ) - ]), - model.dashboardItemsList.length > 0 - ? FractionallySizedBox( - widthFactor: 0.90, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - height: 15, - ), - sliderActiveIndex == 1 - ? Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - model.dashboardItemsList[3].kPIName, - fontSize: - SizeConfig.textMultiplier * 2.2, - fontWeight: FontWeight.bold, - ), - ], - ), - new Container( - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .height * - 0.15 - : MediaQuery.of(context) - .size - .height * - 0.20, - child: new ListView( - scrollDirection: Axis.horizontal, - children: new List.generate( - model - .dashboardItemsList[3] - .summaryoptions - .length, (int index) { - return getActivityButton(model - .dashboardItemsList[3] - .summaryoptions[index]); - }))) - ], - ) - : sliderActiveIndex == 0 - ? Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - model.dashboardItemsList[6] - .kPIName, - fontSize: - SizeConfig.textMultiplier * - 2.2, - fontWeight: FontWeight.bold, - ), - ], - ), - new Container( - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .height * - 0.15 - : MediaQuery.of(context) - .size - .height * - 0.20, - child: new ListView( - scrollDirection: - Axis.horizontal, - children: new List.generate( - model - .dashboardItemsList[6] - .summaryoptions - .length, (int index) { - return getActivityButton(model - .dashboardItemsList[6] - .summaryoptions[index]); - }))) - ], - ) - : Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - model.dashboardItemsList[4] - .kPIName, - fontSize: - SizeConfig.textMultiplier * - 2.2, - fontWeight: FontWeight.bold, - ), - ], - ), - new Container( - height: MediaQuery.of(context) - .orientation == - Orientation.portrait - ? MediaQuery.of(context) - .size - .height * - 0.15 - : MediaQuery.of(context) - .size - .height * - 0.20, - child: new ListView( - scrollDirection: - Axis.horizontal, - children: new List.generate( - model - .dashboardItemsList[4] - .summaryoptions - .length, (int index) { - return getActivityButton(model - .dashboardItemsList[4] - .summaryoptions[index]); - }))) - ], - ), - ]))) - : SizedBox(), - FractionallySizedBox( - // widthFactor: 0.90, - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topRight: Radius.circular(50), - )), - padding: EdgeInsets.all(15), - margin: EdgeInsets.only(top: 15), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - height: 15, - ), - Row( - children: [ - Container( - width: 150, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).patient, - fontSize: SizeConfig.textMultiplier * 1.5, - fontWeight: FontWeight.bold, - ), - AppText( - TranslationBase.of(context).services, - fontSize: SizeConfig.textMultiplier * 3, - fontWeight: FontWeight.bold, - ) - ], - )), - ], - ), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DashboardItem( - color: Colors.red[800], - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Icon( - DoctorApp.referral_1, - size: 35, - color: Colors.white, - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .patientsreferral, - color: Colors.white, - textAlign: TextAlign.start, - )) - ], - ), - hasBorder: false, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => PatientReferralScreen(), - // MyReferredPatient(), - ), - ); - }, - ), - DashboardItem( - color: Colors.grey[300], - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Icon( - DoctorApp.arrival_patients, - size: 35, - color: Colors.black, - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .arrivalpatient, - color: Colors.black, - textAlign: TextAlign.start, - )) - ], - ), - hasBorder: false, - onTap: () { - Navigator.of(context) - .pushNamed(PATIENTS, arguments: { - "patientSearchForm": _patientSearchFormValues, - "selectedType": "7", - "arrivalType": "1" - }); - }, - ), - DashboardItem( - color: Colors.black, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Icon( - DoctorApp.search, - size: 32, - color: Colors.white, - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .searchmedicinepatient, - color: Colors.white, - textAlign: TextAlign.start, - fontSize: 14, - )) - ], - ), - hasBorder: false, - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - SearchMedicinePatientScreen(), - )); - }, - ) - ], - ), - SizedBox( - height: 10, - ), - SizedBox( - height: 20, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 8, - ), - ], - ), - SizedBox( - height: 20, - ), - ], - ), - ), - ), - ], - ), - ]), - ), - ); - } - - static List> _createReferralData(model) { - final data = [ - new GaugeSegment( - model.dashboardItemsList[2].summaryoptions[0].kPIParameter, - getValue(model.dashboardItemsList[1].summaryoptions[0].value), - charts.MaterialPalette.black), - new GaugeSegment( - model.dashboardItemsList[2].summaryoptions[1].kPIParameter, - getValue(model.dashboardItemsList[1].summaryoptions[1].value), - charts.MaterialPalette.gray.shadeDefault), - new GaugeSegment( - model.dashboardItemsList[2].summaryoptions[2].kPIParameter, - getValue(model.dashboardItemsList[1].summaryoptions[2].value), - charts.MaterialPalette.red.shadeDefault), - ]; - - return [ - new charts.Series( - id: 'Segments', - domainFn: (GaugeSegment segment, _) => segment.segment, - measureFn: (GaugeSegment segment, _) => segment.size, - data: data, - colorFn: (GaugeSegment segment, _) => segment.color, - ) - ]; - } - - static int getValue(value) { - return value == 0 ? 1 : value; - } - - changeClinic(clinicId, BuildContext context, model) 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]); - // model.getDashboard(); - }).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(); - } - - Widget getActivityButton(value) { - return Container( - width: MediaQuery.of(context).size.width * 0.24, - padding: EdgeInsets.all(5), - margin: EdgeInsets.all(5), - height: MediaQuery.of(context).orientation == Orientation.portrait - ? MediaQuery.of(context).size.height * 0.15 - : MediaQuery.of(context).size.height * 0.20, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(10), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.all(10), - child: AppText(value.value.toString(), - fontSize: 28, fontWeight: FontWeight.bold)), - Expanded( - child: AppText( - value.kPIParameter, - textOverflow: TextOverflow.clip, - fontSize: 12, - textAlign: TextAlign.center, - ), - ), - ], - ), - ); - } - - Widget dot(Color c) { - return Container( - padding: EdgeInsets.all(5.0), - margin: EdgeInsets.all(5.0), - decoration: BoxDecoration(color: c, shape: BoxShape.circle)); - } - - Widget rowCount(name, int count, Color c) { - return Row( - children: [ - dot(c), - Padding( - padding: EdgeInsets.only(top: 5, bottom: 5), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - name, - color: Colors.black, - textAlign: TextAlign.center, - fontSize: 12, - textOverflow: TextOverflow.ellipsis, - ), - AppText( - ' (' + count.toString() + ')', - color: Colors.black, - textAlign: TextAlign.center, - fontSize: 14, - fontWeight: FontWeight.bold, - ) - ], - )), - ], - ); - } - - Widget getOutPatientStack(value) { - value.summaryoptions - .sort((Summaryoptions a, Summaryoptions b) => b.value - a.value); - - var list = new List(); - value.summaryoptions.forEach((result) => - {list.add(getStack(result, value.summaryoptions.first.value))}); - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Texts( - value.kPIName, - medium: true, - ), - Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list) - ], - ); - } - - getStack(Summaryoptions value, max) { - return Stack(children: [ - Container( - height: 150, - margin: EdgeInsets.all(5), - width: 40, - child: SizedBox(), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), color: Colors.red[50]), - ), - Positioned( - bottom: 0, - child: Container( - child: SizedBox(), - margin: EdgeInsets.all(5), - padding: EdgeInsets.all(10), - height: max != 0 ? (150 * value.value) / max : 0, - width: 40, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Colors.red[300]))), - Container( - height: 150, - margin: EdgeInsets.only(left: 5, top: 5), - padding: EdgeInsets.all(10), - child: RotatedBox( - quarterTurns: 1, - child: Center( - child: Align( - child: AppText( - value.kPIParameter + ' (' + value.value.toString() + ') ', - fontSize: 10, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, - )), - ), - )) - ]); - } - - List getSwiperWidget(model) { - return [ - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.32, - margin: 5, - child: Padding( - padding: const EdgeInsets.all(5.0), - child: getOutPatientStack(model.dashboardItemsList[1]))), - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.32, - margin: 5, - child: Padding( - padding: const EdgeInsets.all(5.0), - child: getOutPatientStack(model.dashboardItemsList[0]))), - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.24, - margin: 5, - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - flex: 1, - child: Row( - children: [ - Expanded( - flex: 4, - child: Padding( - padding: const EdgeInsets.all(5.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Padding( - child: AppText( - TranslationBase.of(context).referral, - fontSize: 20, - fontWeight: FontWeight.bold, - ), - padding: EdgeInsets.all(10))), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - rowCount( - model.dashboardItemsList[2] - .summaryoptions[0].kPIParameter, - model.dashboardItemsList[2] - .summaryoptions[0].value, - Colors.black), - rowCount( - model.dashboardItemsList[2] - .summaryoptions[1].kPIParameter, - model.dashboardItemsList[2] - .summaryoptions[1].value, - Colors.grey), - rowCount( - model.dashboardItemsList[2] - .summaryoptions[2].kPIParameter, - model.dashboardItemsList[2] - .summaryoptions[2].value, - Colors.red), - ], - ), - ) - ], - ))), - Expanded( - flex: 3, - child: Stack(children: [ - Container( - child: GaugeChart(_createReferralData(model))), - Positioned( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - AppText( - getPatientCount(model.dashboardItemsList[2]) - .toString(), - fontSize: 30, - fontWeight: FontWeight.bold, - ) - ], - ), - top: MediaQuery.of(context).size.height * 0.12, - left: 0, - right: 0) - ]), - ), - ], - )), - ])), - ]; - } -} - -// 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.18 - : MediaQuery.of(context).size.height * 0.36, - decoration: BoxDecoration( - color: !hasBorder - ? color != null - ? color - : HexColor('#050705').withOpacity(opacity) - : Colors.white, - borderRadius: BorderRadius.circular(15.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, - ), - ), - ); - } - - getDashboardWidget() {} -} - -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 { - @override - Widget build(BuildContext context) { - return new AnimatedContainer( - duration: new Duration(milliseconds: 1000), - curve: Curves.easeInOut, - child: widget.isExpanded ? widget.expandedChild : widget.collapsedChild, - ); - } -} diff --git a/lib/screens/home/home_page_card.dart b/lib/screens/home/home_page_card.dart new file mode 100644 index 00000000..bdf52129 --- /dev/null +++ b/lib/screens/home/home_page_card.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class HomePageCard extends StatelessWidget { + const HomePageCard({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.18 + : MediaQuery.of(context).size.height * 0.36, + decoration: BoxDecoration( + color: !hasBorder + ? color != null + ? color + : HexColor('#050705').withOpacity(opacity) + : Colors.white, + borderRadius: BorderRadius.circular(15.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, + ), + ), + ); + } + + getDashboardWidget() {} +} \ No newline at end of file diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart new file mode 100644 index 00000000..9a8f4fb3 --- /dev/null +++ b/lib/screens/home/home_screen.dart @@ -0,0 +1,920 @@ +import 'package:charts_flutter/flutter.dart' as charts; +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/auth_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/dashboard_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/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/models/dashboard/dashboard_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/models/patient/patient_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/medicine/search_medicine_patient_screen.dart'; +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/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/dashboard/guage_chart.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.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:flutter_swiper/flutter_swiper.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:provider/provider.dart'; + +import '../../routes.dart'; +import '../../widgets/shared/app_texts_widget.dart'; +import '../../widgets/shared/rounded_container_widget.dart'; +import 'home_page_card.dart'; + +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +Helpers helpers = Helpers(); + +class HomeScreen extends StatefulWidget { + HomeScreen({Key key, this.title}) : super(key: key); + + final String title; + final String iconURL = 'assets/images/dashboard_icon/'; + + @override + _HomeScreenState createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); + HospitalViewModel hospitalProvider; + AuthViewModel authProvider; + bool isLoading = false; + ProjectViewModel projectsProvider; + var _isInit = true; + DoctorProfileModel profile; + bool isExpanded = false; + String isInpatient = ""; + var clinicName = []; + int sliderActiveIndex = 0; + var clinicId; + 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); + + void didChangeDependencies() async { + super.didChangeDependencies(); + if (_isInit) { + projectsProvider = Provider.of(context); + projectsProvider.getDoctorClinicsList(); + + // _firebaseMessaging.setAutoInitEnabled(true); + _firebaseMessaging.requestNotificationPermissions( + const IosNotificationSettings( + sound: true, badge: true, alert: true, provisional: true)); + _firebaseMessaging.onIosSettingsRegistered + .listen((IosNotificationSettings settings) { + print("Settings registered: $settings"); + }); + clinicName = await sharedPref.getObj(CLINIC_NAME); + print(clinicName); + _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; + @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 BaseView( + onModelReady: (model) => model.getDashboard(), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: ListView(children: [ + Column( + children: [ + Stack(children: [ + Column( + children: [ + ProfileWelcomeWidget( + Row( + children: [ + Container( + padding: EdgeInsets.all(4), + margin: EdgeInsets.all(4), + decoration: new BoxDecoration( + color: Colors.red[800], + borderRadius: BorderRadius.circular(20), + ), + constraints: BoxConstraints( + minWidth: 20, + minHeight: 20, + ), + child: new Text( + projectsProvider.doctorClinicsList.length + .toString(), + style: new TextStyle( + color: Colors.white, + fontSize: projectsProvider.isArabic ? 10 : 11, + ), + textAlign: TextAlign.center, + ), + ), + Container( + width: MediaQuery.of(context).size.width * .6, + // // height: 100, + child: projectsProvider.doctorClinicsList.length > 0 + ? Stack( + children: [ + DropdownButtonHideUnderline( + child: DropdownButton( + dropdownColor: Colors.white, + iconEnabledColor: Colors.black, + isExpanded: true, + value: clinicId == null + ? projectsProvider + .doctorClinicsList[0].clinicID + : clinicId, + iconSize: 25, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return projectsProvider + .doctorClinicsList + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText(item.clinicName, + fontSize: SizeConfig + .textMultiplier * + 1.6, + color: Colors.black, + fontWeight: FontWeight.bold, + textAlign: + TextAlign.center), + ], + ); + }).toList(); + }, + onChanged: (newValue) { + clinicId = newValue; + changeClinic( + newValue, context, model); + }, + items: projectsProvider + .doctorClinicsList + .map((item) { + return DropdownMenuItem( + child: Text( + item.clinicName, + textAlign: TextAlign.end, + ), + value: item.clinicID, + ); + }).toList(), + )), + ], + ) + : AppText(TranslationBase.of(context).noClinic), + ), + ], + ), + isClilic: true, + ), + Container( + height: MediaQuery.of(context).size.height * 0.20, + ), + ], + ), + Positioned( + right: 9.0, + left: 9, + top: MediaQuery.of(context).size.height * .05, + child: Container( + height: MediaQuery.of(context).size.height * 0.30, + child: model.dashboardItemsList.length > 0 + ? new Swiper( + onIndexChanged: (index) { + if (mounted) { + setState(() { + sliderActiveIndex = index; + }); + } + }, + itemBuilder: (BuildContext context, int index) { + return getSwipeWidget(model)[index]; + }, + itemCount: 3, + + pagination: new SwiperCustomPagination(builder: + (BuildContext context, + SwiperPluginConfig config) { + return new Stack( + alignment: Alignment.bottomCenter, + children: [ + Positioned( + bottom: -5, + child: Center( + child: InkWell( + onTap: () {}, + child: Container( + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Container( + height: 10, + width: 50, + margin: + EdgeInsets.all(2), + color: + config.activeIndex == + 0 + ? Colors.black + : Colors + .grey), + Container( + height: 10, + width: 50, + margin: + EdgeInsets.all(2), + color: + config.activeIndex == + 1 + ? Colors.black + : Colors + .grey), + Container( + height: 10, + width: 50, + margin: + EdgeInsets.all(2), + color: + config.activeIndex == + 2 + ? Colors.black + : Colors + .grey), + ], + ))))) + ]); + }), + viewportFraction: 0.9, + // scale: 0.9, + // control: new SwiperControl(), + ) + : SizedBox()), + ) + ]), + model.dashboardItemsList.length > 0 + ? FractionallySizedBox( + widthFactor: 0.90, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 15, + ), + sliderActiveIndex == 1 + ? Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + model.dashboardItemsList[3].kPIName, + fontSize: + SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.bold, + ), + ], + ), + new Container( + height: MediaQuery.of(context) + .orientation == + Orientation.portrait + ? MediaQuery.of(context) + .size + .height * + 0.15 + : MediaQuery.of(context) + .size + .height * + 0.20, + child: new ListView( + scrollDirection: Axis.horizontal, + children: new List.generate( + model + .dashboardItemsList[3] + .summaryoptions + .length, (int index) { + return getActivityButton(model + .dashboardItemsList[3] + .summaryoptions[index]); + }))) + ], + ) + : sliderActiveIndex == 0 + ? Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + model.dashboardItemsList[6] + .kPIName, + fontSize: + SizeConfig.textMultiplier * + 2.2, + fontWeight: FontWeight.bold, + ), + ], + ), + new Container( + height: MediaQuery.of(context) + .orientation == + Orientation.portrait + ? MediaQuery.of(context) + .size + .height * + 0.15 + : MediaQuery.of(context) + .size + .height * + 0.20, + child: new ListView( + scrollDirection: + Axis.horizontal, + children: new List.generate( + model + .dashboardItemsList[6] + .summaryoptions + .length, (int index) { + return getActivityButton(model + .dashboardItemsList[6] + .summaryoptions[index]); + }))) + ], + ) + : Column( + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + model.dashboardItemsList[4] + .kPIName, + fontSize: + SizeConfig.textMultiplier * + 2.2, + fontWeight: FontWeight.bold, + ), + ], + ), + new Container( + height: MediaQuery.of(context) + .orientation == + Orientation.portrait + ? MediaQuery.of(context) + .size + .height * + 0.15 + : MediaQuery.of(context) + .size + .height * + 0.20, + child: new ListView( + scrollDirection: + Axis.horizontal, + children: new List.generate( + model + .dashboardItemsList[4] + .summaryoptions + .length, (int index) { + return getActivityButton(model + .dashboardItemsList[4] + .summaryoptions[index]); + }))) + ], + ), + ]))) + : SizedBox(), + FractionallySizedBox( + // widthFactor: 0.90, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topRight: Radius.circular(50), + )), + padding: EdgeInsets.all(15), + margin: EdgeInsets.only(top: 15), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 15, + ), + Row( + children: [ + Container( + width: 150, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).patient, + fontSize: SizeConfig.textMultiplier * 1.5, + fontWeight: FontWeight.bold, + ), + AppText( + TranslationBase.of(context).services, + fontSize: SizeConfig.textMultiplier * 3, + fontWeight: FontWeight.bold, + ) + ], + )), + ], + ), + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + HomePageCard( + color: Colors.red[800], + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, left: 10, right: 0), + child: Icon( + DoctorApp.referral_1, + size: 35, + color: Colors.white, + )), + Container( + padding: EdgeInsets.all(10), + child: AppText( + TranslationBase.of(context) + .patientsreferral, + color: Colors.white, + textAlign: TextAlign.start, + )) + ], + ), + hasBorder: false, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PatientReferralScreen(), + // MyReferredPatient(), + ), + ); + }, + ), + HomePageCard( + color: Colors.grey[300], + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, left: 10, right: 0), + child: Icon( + DoctorApp.arrival_patients, + size: 35, + color: Colors.black, + )), + Container( + padding: EdgeInsets.all(10), + child: AppText( + TranslationBase.of(context) + .arrivalpatient, + color: Colors.black, + textAlign: TextAlign.start, + )) + ], + ), + hasBorder: false, + onTap: () { + Navigator.of(context) + .pushNamed(PATIENTS, arguments: { + "patientSearchForm": _patientSearchFormValues, + "selectedType": "7", + "arrivalType": "1" + }); + }, + ), + HomePageCard( + color: Colors.black, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only( + top: 10, left: 10, right: 0), + child: Icon( + DoctorApp.search, + size: 32, + color: Colors.white, + )), + Container( + padding: EdgeInsets.all(10), + child: AppText( + TranslationBase.of(context) + .searchmedicinepatient, + color: Colors.white, + textAlign: TextAlign.start, + fontSize: 14, + )) + ], + ), + hasBorder: false, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + SearchMedicinePatientScreen(), + )); + }, + ) + ], + ), + SizedBox( + height: 10, + ), + SizedBox( + height: 20, + ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 8, + ), + ], + ), + SizedBox( + height: 20, + ), + ], + ), + ), + ), + ], + ), + ]), + ), + ); + } + + static List> _createReferralData(model) { + final data = [ + new GaugeSegment( + model.dashboardItemsList[2].summaryoptions[0].kPIParameter, + getValue(model.dashboardItemsList[1].summaryoptions[0].value), + charts.MaterialPalette.black), + new GaugeSegment( + model.dashboardItemsList[2].summaryoptions[1].kPIParameter, + getValue(model.dashboardItemsList[1].summaryoptions[1].value), + charts.MaterialPalette.gray.shadeDefault), + new GaugeSegment( + model.dashboardItemsList[2].summaryoptions[2].kPIParameter, + getValue(model.dashboardItemsList[1].summaryoptions[2].value), + charts.MaterialPalette.red.shadeDefault), + ]; + + return [ + new charts.Series( + id: 'Segments', + domainFn: (GaugeSegment segment, _) => segment.segment, + measureFn: (GaugeSegment segment, _) => segment.size, + data: data, + colorFn: (GaugeSegment segment, _) => segment.color, + ) + ]; + } + + static int getValue(value) { + return value == 0 ? 1 : value; + } + + changeClinic(clinicId, BuildContext context, model) 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]); + // model.getDashboard(); + }).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(); + } + + Widget getActivityButton(value) { + return Container( + width: MediaQuery.of(context).size.width * 0.24, + padding: EdgeInsets.all(5), + margin: EdgeInsets.all(5), + height: MediaQuery.of(context).orientation == Orientation.portrait + ? MediaQuery.of(context).size.height * 0.15 + : MediaQuery.of(context).size.height * 0.20, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.all(10), + child: AppText(value.value.toString(), + fontSize: 28, fontWeight: FontWeight.bold)), + Expanded( + child: AppText( + value.kPIParameter, + textOverflow: TextOverflow.clip, + fontSize: 12, + textAlign: TextAlign.center, + ), + ), + ], + ), + ); + } + + Widget dot(Color c) { + return Container( + padding: EdgeInsets.all(5.0), + margin: EdgeInsets.all(5.0), + decoration: BoxDecoration(color: c, shape: BoxShape.circle)); + } + + Widget rowCount(name, int count, Color c) { + return Row( + children: [ + dot(c), + Padding( + padding: EdgeInsets.only(top: 5, bottom: 5), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + name, + color: Colors.black, + textAlign: TextAlign.center, + fontSize: 12, + textOverflow: TextOverflow.ellipsis, + ), + AppText( + ' (' + count.toString() + ')', + color: Colors.black, + textAlign: TextAlign.center, + fontSize: 14, + fontWeight: FontWeight.bold, + ) + ], + )), + ], + ); + } + + Widget getOutPatientStack(value) { + value.summaryoptions + .sort((Summaryoptions a, Summaryoptions b) => b.value - a.value); + + var list = new List(); + value.summaryoptions.forEach((result) => + {list.add(getStack(result, value.summaryoptions.first.value))}); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Texts( + value.kPIName, + medium: true, + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list) + ], + ); + } + + getStack(Summaryoptions value, max) { + return Stack(children: [ + Container( + height: 150, + margin: EdgeInsets.all(5), + width: 40, + child: SizedBox(), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), color: Colors.red[50]), + ), + Positioned( + bottom: 0, + child: Container( + child: SizedBox(), + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(10), + height: max != 0 ? (150 * value.value) / max : 0, + width: 40, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.red[300]))), + Container( + height: 150, + margin: EdgeInsets.only(left: 5, top: 5), + padding: EdgeInsets.all(10), + child: RotatedBox( + quarterTurns: 1, + child: Center( + child: Align( + child: AppText( + value.kPIParameter + ' (' + value.value.toString() + ') ', + fontSize: 10, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + )), + ), + )) + ]); + } + + List getSwipeWidget(model) { + return [ + RoundedContainer( + height: MediaQuery.of(context).size.height * 0.32, + margin: 5, + child: Padding( + padding: const EdgeInsets.all(5.0), + child: getOutPatientStack(model.dashboardItemsList[1]))), + RoundedContainer( + height: MediaQuery.of(context).size.height * 0.32, + margin: 5, + child: Padding( + padding: const EdgeInsets.all(5.0), + child: getOutPatientStack(model.dashboardItemsList[0]))), + RoundedContainer( + height: MediaQuery.of(context).size.height * 0.24, + margin: 5, + child: + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Expanded( + flex: 1, + child: Row( + children: [ + Expanded( + flex: 4, + child: Padding( + padding: const EdgeInsets.all(5.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Padding( + child: AppText( + TranslationBase.of(context).referral, + fontSize: 20, + fontWeight: FontWeight.bold, + ), + padding: EdgeInsets.all(10))), + Expanded( + flex: 2, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + rowCount( + model.dashboardItemsList[2] + .summaryoptions[0].kPIParameter, + model.dashboardItemsList[2] + .summaryoptions[0].value, + Colors.black), + rowCount( + model.dashboardItemsList[2] + .summaryoptions[1].kPIParameter, + model.dashboardItemsList[2] + .summaryoptions[1].value, + Colors.grey), + rowCount( + model.dashboardItemsList[2] + .summaryoptions[2].kPIParameter, + model.dashboardItemsList[2] + .summaryoptions[2].value, + Colors.red), + ], + ), + ) + ], + ))), + Expanded( + flex: 3, + child: Stack(children: [ + Container( + child: GaugeChart(_createReferralData(model))), + Positioned( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AppText( + getPatientCount(model.dashboardItemsList[2]) + .toString(), + fontSize: 30, + fontWeight: FontWeight.bold, + ) + ], + ), + top: MediaQuery.of(context).size.height * 0.12, + left: 0, + right: 0) + ]), + ), + ], + )), + ])), + ]; + } +}