From 916c1266caaf9815d9328e2814a65469ca1bf59e Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 4 May 2021 11:40:14 +0300 Subject: [PATCH 01/11] refactoring home screen --- lib/core/viewModel/dashboard_view_model.dart | 28 +++- .../home/dashboard_slider-item-widget.dart | 37 +++++ lib/screens/home/home_screen.dart | 157 +++--------------- 3 files changed, 83 insertions(+), 139 deletions(-) create mode 100644 lib/screens/home/dashboard_slider-item-widget.dart diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index fede0793..7c6748a5 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -1,12 +1,18 @@ +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/dasboard_service.dart'; +import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; +import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; import '../../locator.dart'; import 'base_view_model.dart'; class DashboardViewModel extends BaseViewModel { DashboardService _dashboardService = locator(); - get dashboardItemsList => _dashboardService.dashboardItemsList; + + List get dashboardItemsList => + _dashboardService.dashboardItemsList; Future getDashboard() async { setState(ViewState.Busy); @@ -17,4 +23,24 @@ class DashboardViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + + Future changeClinic(int clinicId, AuthViewModel authProvider) async { + setState(ViewState.BusyLocal); + await getDoctorProfile(); + ProfileReqModel docInfo = new ProfileReqModel( + doctorID: doctorProfile.doctorID, + clinicID: clinicId, + license: true, + projectID: doctorProfile.projectID, + tokenID: '', + languageID: 2); + + await authProvider.getDocProfiles(docInfo.toJson()).then((res) async { + sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]); + setState(ViewState.Idle); + }).catchError((err) { + error = err; + setState(ViewState.ErrorLocal); + }); + } } diff --git a/lib/screens/home/dashboard_slider-item-widget.dart b/lib/screens/home/dashboard_slider-item-widget.dart new file mode 100644 index 00000000..9a42b4b6 --- /dev/null +++ b/lib/screens/home/dashboard_slider-item-widget.dart @@ -0,0 +1,37 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; +import 'package:doctor_app_flutter/widgets/dashboard/activity_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class DashboardSliderItemWidget extends StatelessWidget { + final DashboardModel item; + + DashboardSliderItemWidget(this.item); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AppText( + item.kPIName, + fontSize: SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.bold, + ), + ], + ), + new Container( + height: 130, + child: new ListView( + scrollDirection: Axis.horizontal, + children: + new List.generate(item.summaryoptions.length, (int index) { + return GetActivityButton(item.summaryoptions[index]); + }))) + ], + ); + } +} diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 76dba1cf..a858660b 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -3,6 +3,7 @@ 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/enum/patient_type.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart'; @@ -14,6 +15,7 @@ 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/home/dashboard_slider-item-widget.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/DischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; @@ -24,6 +26,7 @@ import 'package:doctor_app_flutter/screens/patients/patient_search/patient_searc 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/dr_app_toast_msg.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/activity_button.dart'; @@ -34,6 +37,7 @@ import 'package:doctor_app_flutter/widgets/dashboard/swiper_rounded_pagination.d import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; @@ -47,7 +51,6 @@ 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); @@ -72,7 +75,6 @@ class _HomeScreenState extends State { var clinicName = []; int sliderActiveIndex = 0; var clinicId; - var _patientSearchFormValues; void didChangeDependencies() async { super.didChangeDependencies(); @@ -105,6 +107,7 @@ class _HomeScreenState extends State { } BuildContext myContext; + @override Widget build(BuildContext context) { myContext = context; @@ -143,7 +146,6 @@ class _HomeScreenState extends State { children: [ Container( width: MediaQuery.of(context).size.width * .6, - // // height: 100, child: projectsProvider.doctorClinicsList.length > 0 ? Stack( @@ -210,10 +212,15 @@ class _HomeScreenState extends State { ); }).toList(); }, - onChanged: (newValue) { + onChanged: (newValue) async { clinicId = newValue; - changeClinic( - newValue, context, model); + GifLoaderDialogUtils.showMyDialog( + context); + await model.changeClinic(newValue, authProvider); + GifLoaderDialogUtils + .hideDialog(context); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error);} }, items: projectsProvider .doctorClinicsList @@ -309,111 +316,13 @@ class _HomeScreenState extends State { height: 10, ), 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: 130, - child: new ListView( - scrollDirection: - Axis.horizontal, - children: new List.generate( - model - .dashboardItemsList[3] - .summaryoptions - .length, (int index) { - return GetActivityButton(model - .dashboardItemsList[3] - .summaryoptions[index]); - }))) - ], - ) + ? DashboardSliderItemWidget( + model.dashboardItemsList[3]) : 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: 130, - 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: 130, - child: new ListView( - scrollDirection: Axis - .horizontal, - children: new List - .generate( - model - .dashboardItemsList[ - 4] - .summaryoptions - .length, - (int index) { - return GetActivityButton(model - .dashboardItemsList[ - 4] - .summaryoptions[index]); - }))) - ], - ), + ? DashboardSliderItemWidget( + model.dashboardItemsList[6]) + : DashboardSliderItemWidget( + model.dashboardItemsList[4]), ]))) : SizedBox(), FractionallySizedBox( @@ -810,7 +719,6 @@ class _HomeScreenState extends State { } changeClinic(clinicId, BuildContext context, model) async { - // Navigator.pop(context); changeIsLoading(true); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); @@ -960,31 +868,4 @@ class _HomeScreenState extends State { ])), ]; } - - getRequestHeader(isInpatient) { - _patientSearchFormValues = PatientModel( - FirstName: "0", - MiddleName: "0", - LastName: "0", - PatientMobileNumber: "0", - PatientIdentificationID: "0", - PatientID: 0, - From: isInpatient == true - ? '0' - : DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd') - .toString(), - To: isInpatient == true - ? '0' - : 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); - } } From 0d867592452375d67b57908d0572507e6d1b7fc4 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 4 May 2021 16:11:48 +0300 Subject: [PATCH 02/11] working on dashboard re-factoring --- lib/core/viewModel/dashboard_view_model.dart | 34 ++ lib/screens/home/dashboard_swipe_widget.dart | 234 +++++++++++ lib/screens/home/home_screen.dart | 404 +++---------------- lib/widgets/dashboard/out_patient_stack.dart | 10 +- lib/widgets/dashboard/row_count.dart | 35 +- lib/widgets/shared/app_texts_widget.dart | 14 +- 6 files changed, 369 insertions(+), 362 deletions(-) create mode 100644 lib/screens/home/dashboard_swipe_widget.dart diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index 7c6748a5..a12f3a87 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -1,19 +1,46 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/dasboard_service.dart'; import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; import '../../locator.dart'; import 'base_view_model.dart'; class DashboardViewModel extends BaseViewModel { + + final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); DashboardService _dashboardService = locator(); List get dashboardItemsList => _dashboardService.dashboardItemsList; + Future setFirebaseNotification(ProjectViewModel projectsProvider, AuthViewModel authProvider) async{ + await 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"); + }); + + _firebaseMessaging.getToken().then((String token) async { + if (token != '') { + DEVICE_TOKEN = token; + var request = await sharedPref.getObj(DOCTOR_PROFILE); + authProvider.insertDeviceImei(request).then((value) { + }); + } + }); + } + Future getDashboard() async { setState(ViewState.Busy); await _dashboardService.getDashboard(); @@ -43,4 +70,11 @@ class DashboardViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); }); } + + getPatientCount(DashboardModel inPatientCount) { + int value = 0; + inPatientCount.summaryoptions.forEach((result) => {value += result.value}); + + return value.toString(); + } } diff --git a/lib/screens/home/dashboard_swipe_widget.dart b/lib/screens/home/dashboard_swipe_widget.dart new file mode 100644 index 00000000..8f8077d8 --- /dev/null +++ b/lib/screens/home/dashboard_swipe_widget.dart @@ -0,0 +1,234 @@ +import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart'; +import 'package:doctor_app_flutter/models/dashboard/dashboard_model.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/dashboard/out_patient_stack.dart'; +import 'package:doctor_app_flutter/widgets/dashboard/row_count.dart'; +import 'package:doctor_app_flutter/widgets/dashboard/swiper_rounded_pagination.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:charts_flutter/flutter.dart' as charts; + +class DashboardSwipeWidget extends StatefulWidget { + final List dashboardItemList; + final DashboardViewModel model; + final Function(int) sliderChange; + + DashboardSwipeWidget(this.dashboardItemList, this.model, this.sliderChange); + + @override + _DashboardSwipeWidgetState createState() => _DashboardSwipeWidgetState(); +} + +class _DashboardSwipeWidgetState extends State { + int sliderActiveIndex = 0; + + @override + Widget build(BuildContext context) { + return Swiper( + onIndexChanged: (index) { + if (mounted) { + setState(() { + sliderActiveIndex = index; + widget.sliderChange(index); + }); + } + }, + itemBuilder: (BuildContext context, int index) { + return getSwipeWidget(widget.dashboardItemList, index); + }, + itemCount: 3, + itemHeight: 300, + pagination: new SwiperCustomPagination( + builder: (BuildContext context, SwiperPluginConfig config) { + return new Stack( + alignment: Alignment.bottomCenter, + children: [ + Positioned( + bottom: 0, + child: Center( + child: InkWell( + onTap: () {}, + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + config.activeIndex == 0 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + config.activeIndex == 1 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + config.activeIndex == 2 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + ], + ), + ), + ), + ), + ) + ], + ); + }), + viewportFraction: 0.9, + // scale: 0.9, + // control: new SwiperControl(), + ); + } + + Widget getSwipeWidget(List dashboardItemList, int index) { + if (index == 1) + return RoundedContainer( + height: MediaQuery.of(context).size.height * 0.35, + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + child: Padding( + padding: const EdgeInsets.all(5.0), + child: GetOutPatientStack(dashboardItemList[1]))); + if (index == 0) + return RoundedContainer( + height: MediaQuery.of(context).size.height * 0.35, + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + child: Padding( + padding: const EdgeInsets.all(5.0), + child: GetOutPatientStack(dashboardItemList[0]))); + if (index == 2) + return RoundedContainer( + height: MediaQuery.of(context).size.height * 0.35, + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + 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( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText(TranslationBase.of(context) + .patients, + fontSize: 12, + fontWeight: FontWeight.bold, + fontHeight: 0.5,), + AppText(TranslationBase.of(context) + .referral, + fontSize: 22, + fontWeight: FontWeight.bold, + ), + ], + ))), + Expanded( + flex: 2, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RowCounts( + dashboardItemList[2] + .summaryoptions[0] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[0] + .value, + Colors.black), + RowCounts( + dashboardItemList[2] + .summaryoptions[1] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[1] + .value, + Colors.grey), + RowCounts( + dashboardItemList[2] + .summaryoptions[2] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[2] + .value, + Colors.red), + ], + ), + ) + ], + )), + ), + Expanded( + flex: 3, + child: Stack(children: [ + Container( + child: GaugeChart( + _createReferralData(widget.dashboardItemList))), + Positioned( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AppText( + widget.model + .getPatientCount(dashboardItemList[2]) + .toString(), + fontSize: 30, + fontWeight: FontWeight.bold, + ) + ], + ), + top: MediaQuery.of(context).size.height * 0.12, + left: 0, + right: 0) + ]), + ), + ], + )), + ])); + return Container(); + } + + static List> _createReferralData( + List dashboardItemList) { + final data = [ + new GaugeSegment( + dashboardItemList[2].summaryoptions[0].kPIParameter, + getValue(dashboardItemList[1].summaryoptions[0].value), + charts.MaterialPalette.black), + new GaugeSegment( + dashboardItemList[2].summaryoptions[1].kPIParameter, + getValue(dashboardItemList[1].summaryoptions[1].value), + charts.MaterialPalette.gray.shadeDefault), + new GaugeSegment( + dashboardItemList[2].summaryoptions[2].kPIParameter, + getValue(dashboardItemList[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; + } +} diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index a858660b..dcf2980d 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -1,57 +1,33 @@ -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/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.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/home/dashboard_slider-item-widget.dart'; +import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/DischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; -import 'package:doctor_app_flutter/screens/patients/ReferralDischargedPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/out_patient/out_patient_screen.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_result_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/dr_app_toast_msg.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/activity_button.dart'; -import 'package:doctor_app_flutter/widgets/dashboard/guage_chart.dart'; -import 'package:doctor_app_flutter/widgets/dashboard/out_patient_stack.dart'; -import 'package:doctor_app_flutter/widgets/dashboard/row_count.dart'; -import 'package:doctor_app_flutter/widgets/dashboard/swiper_rounded_pagination.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/profile-welcome-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.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:provider/provider.dart'; import 'package:sticky_headers/sticky_headers/widget.dart'; import '../../widgets/shared/app_texts_widget.dart'; -import '../../widgets/shared/rounded_container_widget.dart'; import 'home_page_card.dart'; -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - class HomeScreen extends StatefulWidget { HomeScreen({Key key, this.title}) : super(key: key); @@ -63,65 +39,25 @@ class HomeScreen extends StatefulWidget { } 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; bool isInpatient = false; - var clinicName = []; int sliderActiveIndex = 0; var clinicId; - 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); + ProjectViewModel projectsProvider = Provider.of(context); + AuthViewModel authProvider = Provider.of(context); FocusScopeNode currentFocus = FocusScope.of(context); - if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } return BaseView( - onModelReady: (model) => model.getDashboard(), + onModelReady: (model) async { + await model.setFirebaseNotification(projectsProvider, authProvider); + await model.getDashboard(); + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: false, @@ -171,36 +107,49 @@ class _HomeScreenState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ - Container( - padding: EdgeInsets.all(2), - margin: EdgeInsets.all(2), - 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, - ), + Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Container( + padding: + EdgeInsets.all(2), + margin: + EdgeInsets.all(2), + decoration: + new BoxDecoration( + color: + Colors.red[800], + borderRadius: + BorderRadius + .circular( + 20), + ), + constraints: + BoxConstraints( + minWidth: 20, + minHeight: 20, + ), + child: Center( + child: AppText( + projectsProvider + .doctorClinicsList + .length + .toString(), + color: + Colors.white, + fontSize: + projectsProvider + .isArabic + ? 10 + : 11, + textAlign: + TextAlign + .center, + ), + )), + ], ), AppText(item.clinicName, fontSize: 12, @@ -216,11 +165,15 @@ class _HomeScreenState extends State { clinicId = newValue; GifLoaderDialogUtils.showMyDialog( context); - await model.changeClinic(newValue, authProvider); - GifLoaderDialogUtils - .hideDialog(context); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error);} + await model.changeClinic( + newValue, authProvider); + GifLoaderDialogUtils.hideDialog( + context); + if (model.state == + ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast( + model.error); + } }, items: projectsProvider .doctorClinicsList @@ -251,58 +204,14 @@ class _HomeScreenState extends State { Container( height: MediaQuery.of(context).size.height * 0.35, child: model.dashboardItemsList.length > 0 - ? new Swiper( - onIndexChanged: (index) { - if (mounted) { - setState(() { - sliderActiveIndex = index; - }); - } - }, - itemBuilder: (BuildContext context, int index) { - return getSwipeWidget(model)[index]; + ? DashboardSwipeWidget( + model.dashboardItemsList, + model, + (sliderIndex) { + setState(() { + sliderActiveIndex = sliderIndex; + }); }, - itemCount: 3, - itemHeight: 300, - pagination: new SwiperCustomPagination(builder: - (BuildContext context, - SwiperPluginConfig config) { - return new Stack( - alignment: Alignment.bottomCenter, - children: [ - Positioned( - bottom: 0, - child: Center( - child: InkWell( - onTap: () {}, - child: Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - config.activeIndex == 0 - ? SwiperRoundedPagination( - true) - : SwiperRoundedPagination( - false), - config.activeIndex == 1 - ? SwiperRoundedPagination( - true) - : SwiperRoundedPagination( - false), - config.activeIndex == 2 - ? SwiperRoundedPagination( - true) - : SwiperRoundedPagination( - false), - ], - ))))) - ]); - }), - viewportFraction: 0.9, - // scale: 0.9, - // control: new SwiperControl(), ) : SizedBox()), model.dashboardItemsList.length > 0 @@ -687,185 +596,4 @@ class _HomeScreenState extends State { ); } - 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 { - 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.toJson()).then((res) async { - changeIsLoading(false); - sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]); - }).catchError((err) { - changeIsLoading(false); - Helpers.showErrorToast(err); - }); - } - - changeIsLoading(bool val) { - setState(() { - this.isLoading = val; - }); - } - - getPatientCount(DashboardModel inPatientCount) { - int value = 0; - inPatientCount.summaryoptions.forEach((result) => {value += result.value}); - - return value.toString(); - } - - List getSwipeWidget(model) { - return [ - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), - child: Padding( - padding: const EdgeInsets.all(5.0), - child: GetOutPatientStack(model.dashboardItemsList[1]))), - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), - child: Padding( - padding: const EdgeInsets.all(5.0), - child: GetOutPatientStack(model.dashboardItemsList[0]))), - RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), - 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( - padding: EdgeInsets.all(8), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context) - .patients, - style: TextStyle( - fontSize: 12, - height: .5, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins'), - ), - Text( - TranslationBase.of(context) - .referral, - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins'), - ), - ], - ))), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - RowCounts( - model.dashboardItemsList[2] - .summaryoptions[0].kPIParameter, - model.dashboardItemsList[2] - .summaryoptions[0].value, - Colors.black), - RowCounts( - model.dashboardItemsList[2] - .summaryoptions[1].kPIParameter, - model.dashboardItemsList[2] - .summaryoptions[1].value, - Colors.grey), - RowCounts( - 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) - ]), - ), - ], - )), - ])), - ]; - } } diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index d5da97c6..c09e2757 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -31,7 +31,7 @@ class GetOutPatientStack extends StatelessWidget { Container( height: 150, margin: EdgeInsets.all(5), - width: 40, + width: 35, child: SizedBox(), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.red[50]), @@ -43,7 +43,7 @@ class GetOutPatientStack extends StatelessWidget { margin: EdgeInsets.all(5), padding: EdgeInsets.all(10), height: max != 0 ? (150 * value.value) / max : 0, - width: 40, + width: 35, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.red[300]))), @@ -55,12 +55,14 @@ class GetOutPatientStack extends StatelessWidget { quarterTurns: 1, child: Center( child: Align( - child: AppText( + child: FittedBox( + child: AppText( value.kPIParameter + ' (' + value.value.toString() + ') ', fontSize: 10, textAlign: TextAlign.center, fontWeight: FontWeight.bold, - )), + ), + )), ), )) ]); diff --git a/lib/widgets/dashboard/row_count.dart b/lib/widgets/dashboard/row_count.dart index c56613da..a42cccdf 100644 --- a/lib/widgets/dashboard/row_count.dart +++ b/lib/widgets/dashboard/row_count.dart @@ -8,31 +8,38 @@ class RowCounts extends StatelessWidget { RowCounts(this.name, this.count, this.c); @override Widget build(BuildContext context) { - return Row( - children: [ - dot(c), - Padding( - padding: EdgeInsets.only(top: 5, bottom: 5), + return Container( + padding: EdgeInsets.only(top: 5, bottom: 5), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + dot(c), + Expanded( child: Row( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - AppText( - name, - color: Colors.black, - textAlign: TextAlign.center, - fontSize: 12, - textOverflow: TextOverflow.ellipsis, + Expanded( + child: AppText( + name, + color: Colors.black, + textAlign: TextAlign.start, // from TextAlign.center + fontSize: 12, + textOverflow: TextOverflow.ellipsis, + ), ), AppText( ' (' + count.toString() + ')', color: Colors.black, textAlign: TextAlign.center, - fontSize: 14, + fontSize: 13, fontWeight: FontWeight.bold, ) ], - )), - ], + ), + ), + ], + ), ); } diff --git a/lib/widgets/shared/app_texts_widget.dart b/lib/widgets/shared/app_texts_widget.dart index 74acff8a..48661a32 100644 --- a/lib/widgets/shared/app_texts_widget.dart +++ b/lib/widgets/shared/app_texts_widget.dart @@ -9,6 +9,7 @@ class AppText extends StatefulWidget { final Color color; final FontWeight fontWeight; final double fontSize; + final double fontHeight; final String fontFamily; final int maxLength; final bool italic; @@ -35,6 +36,7 @@ class AppText extends StatefulWidget { this.fontWeight, this.variant, this.fontSize, + this.fontHeight, this.fontFamily = 'Poppins', this.italic = false, this.maxLength = 60, @@ -121,20 +123,20 @@ class _AppTextState extends State { style: widget.style != null ? _getFontStyle().copyWith( fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color , + color: widget.color, fontWeight: widget.fontWeight ?? _getFontWeight(), - ) + height: widget.fontHeight) : TextStyle( fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color != null - ? widget.color - : Colors.black, + color: + widget.color != null ? widget.color : Colors.black, fontSize: widget.fontSize ?? _getFontSize(), letterSpacing: widget.variant == "overline" ? 1.5 : null, fontWeight: widget.fontWeight ?? _getFontWeight(), fontFamily: widget.fontFamily ?? 'Poppins', - decoration: widget.textDecoration), + decoration: widget.textDecoration, + height: widget.fontHeight), ), if (widget.readMore && text.length > widget.maxLength && hidden) Positioned( From 4ce9a3c5bffb4c660ff3a0bd102392dcadbb3822 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 5 May 2021 12:32:16 +0300 Subject: [PATCH 03/11] finish home-refactoring --- .../home/dashboard_slider-item-widget.dart | 2 +- lib/screens/home/home_page_card.dart | 6 +- lib/screens/home/home_patient_card.dart | 83 +++++ lib/screens/home/home_screen.dart | 323 ++++-------------- lib/widgets/dashboard/activity_button.dart | 8 +- 5 files changed, 149 insertions(+), 273 deletions(-) create mode 100644 lib/screens/home/home_patient_card.dart diff --git a/lib/screens/home/dashboard_slider-item-widget.dart b/lib/screens/home/dashboard_slider-item-widget.dart index 9a42b4b6..4ee67daf 100644 --- a/lib/screens/home/dashboard_slider-item-widget.dart +++ b/lib/screens/home/dashboard_slider-item-widget.dart @@ -28,7 +28,7 @@ class DashboardSliderItemWidget extends StatelessWidget { child: new ListView( scrollDirection: Axis.horizontal, children: - new List.generate(item.summaryoptions.length, (int index) { + List.generate(item.summaryoptions.length, (int index) { return GetActivityButton(item.summaryoptions[index]); }))) ], diff --git a/lib/screens/home/home_page_card.dart b/lib/screens/home/home_page_card.dart index 2f85ff89..64b870b4 100644 --- a/lib/screens/home/home_page_card.dart +++ b/lib/screens/home/home_page_card.dart @@ -26,8 +26,8 @@ class HomePageCard extends StatelessWidget { child: Container( width: 100, height: MediaQuery.of(context).orientation == Orientation.portrait - ? 130 - : 250, + ? 100 + : 200, margin: this.margin, decoration: BoxDecoration( color: !hasBorder @@ -41,7 +41,7 @@ class HomePageCard extends StatelessWidget { : Border.all(width: 0.0, color: Colors.transparent), image: imageName != null ? DecorationImage( - image: AssetImage('assets/images/dashboard/${imageName}'), + image: AssetImage('assets/images/dashboard/$imageName'), fit: BoxFit.cover, colorFilter: new ColorFilter.mode( Colors.black.withOpacity(0.2), BlendMode.dstIn), diff --git a/lib/screens/home/home_patient_card.dart b/lib/screens/home/home_patient_card.dart new file mode 100644 index 00000000..c604fdd7 --- /dev/null +++ b/lib/screens/home/home_patient_card.dart @@ -0,0 +1,83 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/screens/home/home_page_card.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class HomePatientCard extends StatelessWidget { + final Color backgroundColor; + final IconData cardIcon; + final Color backgroundIconColor; + final String text; + final Color textColor; + final Function onTap; + + HomePatientCard({ + @required this.backgroundColor, + @required this.backgroundIconColor, + @required this.cardIcon, + @required this.text, + @required this.textColor, + @required this.onTap, + }); + + @override + Widget build(BuildContext context) { + return HomePageCard( + color: backgroundColor, + margin: EdgeInsets.all(4), + child: Container( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Stack( + children: [ + Positioned( + bottom: 0.1, + right: 0.5, + width: 23.0, + height: 25.0, + child: Icon( + cardIcon, + size: 60, + color: backgroundIconColor, + ), + ), + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Icon( + cardIcon, + size: 30, + color: textColor, + ), + SizedBox( + height: 4, + ), + ], + ), + ), + ], + ), + ), + Expanded( + child: Container( + child: AppText( + text, + color: textColor, + textAlign: TextAlign.start, + fontSize: SizeConfig.textMultiplier * 1.6, + ), + ), + ), + ], + ), + ), + hasBorder: false, + onTap: onTap, + ); + } +} diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index dcf2980d..49f83a66 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_slider-item-widget.dart'; import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart'; +import 'package:doctor_app_flutter/screens/home/home_patient_card.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; import 'package:doctor_app_flutter/screens/patients/out_patient/out_patient_screen.dart'; @@ -246,90 +247,44 @@ class _HomeScreenState extends State { margin: EdgeInsets.only(top: 10), child: Column( mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 10, ), - Row( - children: [ - Container( - width: 150, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).patients, - style: TextStyle( - fontSize: 12, - height: .5, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins'), - ), - Text( - TranslationBase.of(context).services, - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins'), - ), - ], - )), + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).patients, + fontSize: 12, + fontWeight: FontWeight.bold, + fontHeight: .5, + ), + AppText( + TranslationBase.of(context).services, + fontSize: 22, + fontWeight: FontWeight.bold, + ), ], - ), + )), SizedBox( height: 10, ), - new Container( - height: 130, - child: new ListView( + Container( + height: 100, + child: ListView( scrollDirection: Axis.horizontal, children: [ - HomePageCard( - color: Color(0xffD02127), - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Stack( - children: [ - Positioned( - bottom: 0.1, - right: 0.5, - width: 23.0, - height: 25.0, - child: Icon( - DoctorApp.inpatient, - size: 65, - color: Colors.white12, - ), - ), - Icon( - DoctorApp.inpatient, - size: 32, - color: Colors.white, - ), - ], - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .inPatient, - color: Colors.white, - textAlign: TextAlign.start, - fontSize: 15, - )) - ], - ), - hasBorder: false, + HomePatientCard( + backgroundColor: Color(0xffD02127), + backgroundIconColor: Colors.white12, + cardIcon: DoctorApp.inpatient, + textColor: Colors.white, + text: + TranslationBase.of(context).inPatient, onTap: () { Navigator.push( context, @@ -339,51 +294,13 @@ class _HomeScreenState extends State { ); }, ), - HomePageCard( - color: Colors.grey[300], - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Stack( - children: [ - Positioned( - bottom: 0.1, - right: 0.5, - width: 23.0, - height: 25.0, - child: Icon( - DoctorApp - .arrival_patients, - size: 65, - color: Colors.white38, - ), - ), - Icon( - DoctorApp.arrival_patients, - size: 35, - color: Colors.black, - ), - ], - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .myOutPatient, - color: Colors.black, - textAlign: TextAlign.start, - fontSize: 15, - )) - ], - ), - hasBorder: false, + HomePatientCard( + backgroundColor: Colors.grey[300], + backgroundIconColor: Colors.white38, + cardIcon: DoctorApp.arrival_patients, + textColor: Colors.black, + text: TranslationBase.of(context) + .myOutPatient, onTap: () { String date = DateUtils.convertDateToFormat( @@ -407,106 +324,30 @@ class _HomeScreenState extends State { )); }, ), - HomePageCard( - color: Color(0xff2B353E), - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Stack( - children: [ - Positioned( - bottom: 0.1, - right: 0.5, - width: 23.0, - height: 25.0, - child: Icon( - DoctorApp.referral_1, - size: 65, - color: Colors.white10 - .withOpacity(0.1), - ), - ), - 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, - fontSize: 15, - )) - ], - ), - hasBorder: false, + HomePatientCard( + backgroundColor: Color(0xff2B353E), + backgroundIconColor: Colors.white10, + cardIcon: DoctorApp.referral_1, + textColor: Colors.white, + text: TranslationBase.of(context) + .patientsreferral, onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => PatientReferralScreen(), - // MyReferredPatient(), ), ); }, ), - HomePageCard( - color: Color(0xffD02127), - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Stack( - children: [ - Positioned( - bottom: 0.1, - right: 0.5, - width: 23.0, - height: 25.0, - child: Icon( - DoctorApp.search, - size: 65, - color: Colors.white10, - ), - ), - Icon( - DoctorApp.search, - size: 35, - color: Colors.white, - ), - ], - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .searchPatient, - color: Colors.white, - textAlign: TextAlign.start, - fontSize: 13, - )) - ], - ), - hasBorder: false, + HomePatientCard( + backgroundColor: Color(0xffD02127), + backgroundIconColor: Colors.white10, + cardIcon: DoctorApp.search, + textColor: Colors.white, + text: TranslationBase.of(context) + .searchPatient, onTap: () { Navigator.push( context, @@ -516,51 +357,13 @@ class _HomeScreenState extends State { )); }, ), - HomePageCard( - color: Color(0xffC9C9C9), - margin: EdgeInsets.all(5), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 10, left: 10, right: 0), - child: Stack( - children: [ - Positioned( - bottom: 0.1, - right: 0.5, - width: 23.0, - height: 25.0, - child: Icon( - DoctorApp - .search_medicines, - color: Colors.black12, - size: 65, - ), - ), - Icon( - DoctorApp.search_medicines, - size: 40, - color: Color(0xff2B353E), - ), - ], - )), - Container( - padding: EdgeInsets.all(10), - child: AppText( - TranslationBase.of(context) - .searchMedicine, - color: Color(0xff2B353E), - textAlign: TextAlign.start, - fontSize: 13, - )) - ], - ), - hasBorder: false, + HomePatientCard( + backgroundColor: Color(0xffC9C9C9), + backgroundIconColor: Colors.black12, + cardIcon: DoctorApp.search_medicines, + textColor: Color(0xff2B353E), + text: TranslationBase.of(context) + .searchMedicine, onTap: () { Navigator.push( context, @@ -569,17 +372,8 @@ class _HomeScreenState extends State { MedicineSearchScreen(), )); }, - ) + ), ])), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 8, - ), - ], - ), SizedBox( height: 20, ), @@ -595,5 +389,4 @@ class _HomeScreenState extends State { ), ); } - } diff --git a/lib/widgets/dashboard/activity_button.dart b/lib/widgets/dashboard/activity_button.dart index 8258a1df..b925870f 100644 --- a/lib/widgets/dashboard/activity_button.dart +++ b/lib/widgets/dashboard/activity_button.dart @@ -17,17 +17,17 @@ class GetActivityButton extends StatelessWidget { ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.all(10), + padding: EdgeInsets.all(8), child: AppText(value.value.toString(), - fontSize: 32, fontWeight: FontWeight.bold)), + fontSize: 28, fontWeight: FontWeight.bold)), Expanded( child: AppText( value.kPIParameter, textOverflow: TextOverflow.clip, - fontSize: 12, + fontSize: 10, textAlign: TextAlign.center, fontWeight: FontWeight.w600, ), From 4f817810c2c28b25322e20888027922d91fb835e Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 5 May 2021 13:24:17 +0300 Subject: [PATCH 04/11] hot fix --- lib/config/localized_values.dart | 1 + lib/screens/home/home_screen.dart | 2 +- lib/util/translations_delegate_base.dart | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index d09d33f4..fb01bfb1 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -48,6 +48,7 @@ const Map> localizedValues = { 'service': {'en': 'Service', 'ar': 'خدمة'}, 'referral': {'en': 'Referral', 'ar': 'الإحالة'}, 'inPatient': {'en': 'InPatients', 'ar': 'مرضاي'}, + 'myInPatient': {'en': 'My InPatients', 'ar': 'مرضاي'}, 'inPatientLabel': {'en': 'InPatients', 'ar': 'المريض الداخلي'}, 'inPatientAll': {'en': 'All InPatients', 'ar': 'كل المرضى'}, 'operations': {'en': 'Operations', 'ar': 'عمليات'}, diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 49f83a66..3a048f52 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -284,7 +284,7 @@ class _HomeScreenState extends State { cardIcon: DoctorApp.inpatient, textColor: Colors.white, text: - TranslationBase.of(context).inPatient, + TranslationBase.of(context).myInPatient, onTap: () { Navigator.push( context, diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index ba69e104..bd9c68d9 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -100,6 +100,7 @@ class TranslationBase { String get referral => localizedValues['referral'][locale.languageCode]; String get inPatient => localizedValues['inPatient'][locale.languageCode]; + String get myInPatient => localizedValues['myInPatient'][locale.languageCode]; String get inPatientLabel => localizedValues['inPatientLabel'][locale.languageCode]; From f0039b491ee68249c133d760741e06fb1cf0e0df Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Wed, 5 May 2021 13:51:57 +0300 Subject: [PATCH 05/11] fix home page --- lib/core/viewModel/dashboard_view_model.dart | 1 + lib/screens/home/home_page_card.dart | 2 +- lib/screens/home/home_screen.dart | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index a12f3a87..faebd0c0 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -20,6 +20,7 @@ class DashboardViewModel extends BaseViewModel { _dashboardService.dashboardItemsList; Future setFirebaseNotification(ProjectViewModel projectsProvider, AuthViewModel authProvider) async{ + setState(ViewState.Busy); await projectsProvider.getDoctorClinicsList(); // _firebaseMessaging.setAutoInitEnabled(true); diff --git a/lib/screens/home/home_page_card.dart b/lib/screens/home/home_page_card.dart index 64b870b4..55919c25 100644 --- a/lib/screens/home/home_page_card.dart +++ b/lib/screens/home/home_page_card.dart @@ -24,7 +24,7 @@ class HomePageCard extends StatelessWidget { return InkWell( onTap: onTap, child: Container( - width: 100, + width: 120, height: MediaQuery.of(context).orientation == Orientation.portrait ? 100 : 200, diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 3a048f52..acfa36b1 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -274,7 +274,7 @@ class _HomeScreenState extends State { height: 10, ), Container( - height: 100, + height: 120, child: ListView( scrollDirection: Axis.horizontal, children: [ From fa194f5e0050f8ef13a3f65cda6e7dd153763833 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 5 May 2021 14:11:26 +0300 Subject: [PATCH 06/11] hot fix --- lib/config/localized_values.dart | 2 +- lib/screens/home/home_page_card.dart | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index fb01bfb1..8a1c2e01 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -48,7 +48,7 @@ const Map> localizedValues = { 'service': {'en': 'Service', 'ar': 'خدمة'}, 'referral': {'en': 'Referral', 'ar': 'الإحالة'}, 'inPatient': {'en': 'InPatients', 'ar': 'مرضاي'}, - 'myInPatient': {'en': 'My InPatients', 'ar': 'مرضاي'}, + 'myInPatient': {'en': 'My\nInPatients', 'ar': 'مرضاي'}, 'inPatientLabel': {'en': 'InPatients', 'ar': 'المريض الداخلي'}, 'inPatientAll': {'en': 'All InPatients', 'ar': 'كل المرضى'}, 'operations': {'en': 'Operations', 'ar': 'عمليات'}, diff --git a/lib/screens/home/home_page_card.dart b/lib/screens/home/home_page_card.dart index 64b870b4..a2200fad 100644 --- a/lib/screens/home/home_page_card.dart +++ b/lib/screens/home/home_page_card.dart @@ -48,9 +48,7 @@ class HomePageCard extends StatelessWidget { ) : null, ), - child: Center( - child: child, - ), + child: child, ), ); } From 2cf77bac85eec59e452c8ff79cfb509161db7955 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 5 May 2021 16:37:03 +0300 Subject: [PATCH 07/11] fit dashboard design --- lib/config/config.dart | 2 +- lib/widgets/dashboard/out_patient_stack.dart | 70 +++++++++++--------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index b21ee8ed..ec8efe26 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -337,7 +337,7 @@ const TRANSACTION_NO = 0; const LANGUAGE_ID = 2; const STAMP = '2020-04-27T12:17:17.721Z'; const IP_ADDRESS = '9.9.9.9'; -const VERSION_ID = 5.9; +const VERSION_ID = 6.0; const CHANNEL = 9; const SESSION_ID = 'BlUSkYymTt'; const IS_LOGIN_FOR_DOCTOR_APP = true; diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index c09e2757..ad79b106 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -4,7 +4,9 @@ import 'package:flutter/material.dart'; class GetOutPatientStack extends StatelessWidget { final value; + GetOutPatientStack(this.value); + @override Widget build(BuildContext context) { value.summaryoptions @@ -27,44 +29,48 @@ class GetOutPatientStack extends StatelessWidget { } getStack(Summaryoptions value, max) { - return Stack(children: [ - Container( - height: 150, - margin: EdgeInsets.all(5), - width: 35, - child: SizedBox(), + return Expanded( + child: Container( + margin: EdgeInsets.symmetric(horizontal: 2), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), color: Colors.red[50]), - ), - Positioned( - bottom: 0, - child: Container( + borderRadius: BorderRadius.circular(6), + color: Colors.red[50], + ), + child: Stack(children: [ + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( child: SizedBox(), - margin: EdgeInsets.all(5), padding: EdgeInsets.all(10), height: max != 0 ? (150 * value.value) / max : 0, - width: 35, 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: FittedBox( - child: AppText( - value.kPIParameter + ' (' + value.value.toString() + ') ', - fontSize: 10, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, + borderRadius: BorderRadius.circular(6), + color: Color(0x63D02127), ), - )), ), - )) - ]); + ), + Container( + height: 150, + margin: EdgeInsets.only(left: 5, top: 5), + padding: EdgeInsets.all(10), + child: RotatedBox( + quarterTurns: 3, + child: Center( + child: Align( + child: FittedBox( + child: AppText( + value.kPIParameter + ' (' + value.value.toString() + ') ', + fontSize: 10, + textAlign: TextAlign.center, + fontWeight: FontWeight.bold, + ), + )), + ), + )) + ]), + ), + ); } } From 95a6893b59bfe61657fa8507bb09e6976441e605 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 6 May 2021 15:19:42 +0300 Subject: [PATCH 08/11] home design --- lib/screens/home/dashboard_swipe_widget.dart | 33 +++++++------ lib/widgets/dashboard/activity_button.dart | 46 ++++++++++++------- lib/widgets/dashboard/out_patient_stack.dart | 30 ++++++++---- .../shared/rounded_container_widget.dart | 4 -- 4 files changed, 68 insertions(+), 45 deletions(-) diff --git a/lib/screens/home/dashboard_swipe_widget.dart b/lib/screens/home/dashboard_swipe_widget.dart index 8f8077d8..faca68f8 100644 --- a/lib/screens/home/dashboard_swipe_widget.dart +++ b/lib/screens/home/dashboard_swipe_widget.dart @@ -40,7 +40,7 @@ class _DashboardSwipeWidgetState extends State { return getSwipeWidget(widget.dashboardItemList, index); }, itemCount: 3, - itemHeight: 300, + // itemHeight: 300, pagination: new SwiperCustomPagination( builder: (BuildContext context, SwiperPluginConfig config) { return new Stack( @@ -82,22 +82,22 @@ class _DashboardSwipeWidgetState extends State { Widget getSwipeWidget(List dashboardItemList, int index) { if (index == 1) return RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + raduis: 16, + margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), child: GetOutPatientStack(dashboardItemList[1]))); if (index == 0) return RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + raduis: 16, + margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), child: GetOutPatientStack(dashboardItemList[0]))); if (index == 2) return RoundedContainer( - height: MediaQuery.of(context).size.height * 0.35, - margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), + raduis: 16, + margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( @@ -122,16 +122,19 @@ class _DashboardSwipeWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppText(TranslationBase.of(context) - .patients, - fontSize: 12, - fontWeight: FontWeight.bold, - fontHeight: 0.5,), - AppText(TranslationBase.of(context) - .referral, + AppText( + TranslationBase.of(context) + .patients, + fontSize: 12, + fontWeight: FontWeight.bold, + fontHeight: 0.5, + ), + AppText( + TranslationBase.of(context) + .referral, fontSize: 22, fontWeight: FontWeight.bold, - ), + ), ], ))), Expanded( diff --git a/lib/widgets/dashboard/activity_button.dart b/lib/widgets/dashboard/activity_button.dart index e9001e41..b8f390dd 100644 --- a/lib/widgets/dashboard/activity_button.dart +++ b/lib/widgets/dashboard/activity_button.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; class GetActivityButton extends StatelessWidget { final value; + GetActivityButton(this.value); + @override Widget build(BuildContext context) { return Container( @@ -15,24 +17,34 @@ class GetActivityButton extends StatelessWidget { color: Colors.white, borderRadius: BorderRadius.circular(20), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.all(8), - child: AppText(value.value.toString(), - fontSize: 30, fontWeight: FontWeight.bold)), - Expanded( - child: AppText( - value.kPIParameter, - textOverflow: TextOverflow.clip, - fontSize: 10, - textAlign: TextAlign.center, - fontWeight: FontWeight.w600, + child: Padding( + padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + AppText( + value.value.toString(), + fontSize: 30, + fontWeight: FontWeight.bold, + color: Color(0xFF2B353E), + ), + Expanded( + child: Column( + children: [ + AppText( + value.kPIParameter, + textOverflow: TextOverflow.clip, + fontSize: 10, + color: Color(0xFF2B353E), + textAlign: TextAlign.start, + fontWeight: FontWeight.w700, + ), + ], + ), ), - ), - ], + ], + ), ), ); } diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index ad79b106..b3b7ed8c 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -33,7 +33,7 @@ class GetOutPatientStack extends StatelessWidget { child: Container( margin: EdgeInsets.symmetric(horizontal: 2), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), + borderRadius: BorderRadius.circular(8), color: Colors.red[50], ), child: Stack(children: [ @@ -46,7 +46,7 @@ class GetOutPatientStack extends StatelessWidget { padding: EdgeInsets.all(10), height: max != 0 ? (150 * value.value) / max : 0, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), + borderRadius: BorderRadius.circular(8), color: Color(0x63D02127), ), ), @@ -60,13 +60,25 @@ class GetOutPatientStack extends StatelessWidget { child: Center( child: Align( child: FittedBox( - child: AppText( - value.kPIParameter + ' (' + value.value.toString() + ') ', - fontSize: 10, - textAlign: TextAlign.center, - fontWeight: FontWeight.bold, - ), - )), + child: Row( + children: [ + AppText( + value.kPIParameter, + fontSize: 10, + textAlign: TextAlign.center, + color: Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + AppText( + ' (' + value.value.toString() + ') ', + fontSize: 12, + textAlign: TextAlign.center, + color: Color(0xFF2B353E), + fontWeight: FontWeight.bold, + ), + ], + ), + )), ), )) ]), diff --git a/lib/widgets/shared/rounded_container_widget.dart b/lib/widgets/shared/rounded_container_widget.dart index e86c85aa..4cfe7b08 100644 --- a/lib/widgets/shared/rounded_container_widget.dart +++ b/lib/widgets/shared/rounded_container_widget.dart @@ -1,9 +1,5 @@ import 'package:flutter/material.dart'; -// OWNER : Ibrahim albitar -// DATE : 05-04-2020 -// DESCRIPTION : Custom widget for rounded container and custom decoration - class RoundedContainer extends StatefulWidget { final double width; final double height; From 72ee88d567b893ab60da8c3584d3fa08825f1b0b Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 9 May 2021 13:54:03 +0300 Subject: [PATCH 09/11] working on dashboard --- lib/screens/home/dashboard_swipe_widget.dart | 208 ++++++++++--------- lib/screens/home/home_screen.dart | 24 +-- lib/widgets/dashboard/out_patient_stack.dart | 10 +- lib/widgets/dashboard/row_count.dart | 4 +- 4 files changed, 128 insertions(+), 118 deletions(-) diff --git a/lib/screens/home/dashboard_swipe_widget.dart b/lib/screens/home/dashboard_swipe_widget.dart index faca68f8..de582dc2 100644 --- a/lib/screens/home/dashboard_swipe_widget.dart +++ b/lib/screens/home/dashboard_swipe_widget.dart @@ -27,55 +27,59 @@ class _DashboardSwipeWidgetState extends State { @override Widget build(BuildContext context) { - return Swiper( - onIndexChanged: (index) { - if (mounted) { - setState(() { - sliderActiveIndex = index; - widget.sliderChange(index); - }); - } - }, - itemBuilder: (BuildContext context, int index) { - return getSwipeWidget(widget.dashboardItemList, index); - }, - itemCount: 3, - // itemHeight: 300, - pagination: new SwiperCustomPagination( - builder: (BuildContext context, SwiperPluginConfig config) { - return new Stack( - alignment: Alignment.bottomCenter, - children: [ - Positioned( - bottom: 0, - child: Center( - child: InkWell( - onTap: () {}, - child: Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - config.activeIndex == 0 - ? SwiperRoundedPagination(true) - : SwiperRoundedPagination(false), - config.activeIndex == 1 - ? SwiperRoundedPagination(true) - : SwiperRoundedPagination(false), - config.activeIndex == 2 - ? SwiperRoundedPagination(true) - : SwiperRoundedPagination(false), - ], + return Container( + // height: MediaQuery.of(context).size.height * 0.35, + height: 230, + child: Swiper( + onIndexChanged: (index) { + if (mounted) { + setState(() { + sliderActiveIndex = index; + widget.sliderChange(index); + }); + } + }, + itemBuilder: (BuildContext context, int index) { + return getSwipeWidget(widget.dashboardItemList, index); + }, + itemCount: 3, + // itemHeight: 300, + pagination: new SwiperCustomPagination( + builder: (BuildContext context, SwiperPluginConfig config) { + return new Stack( + alignment: Alignment.bottomCenter, + children: [ + Positioned( + bottom: 0, + child: Center( + child: InkWell( + onTap: () {}, + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + config.activeIndex == 0 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + config.activeIndex == 1 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + config.activeIndex == 2 + ? SwiperRoundedPagination(true) + : SwiperRoundedPagination(false), + ], + ), ), ), ), - ), - ) - ], - ); - }), - viewportFraction: 0.9, - // scale: 0.9, - // control: new SwiperControl(), + ) + ], + ); + }), + viewportFraction: 0.9, + // scale: 0.9, + // control: new SwiperControl(), + ), ); } @@ -83,21 +87,21 @@ class _DashboardSwipeWidgetState extends State { if (index == 1) return RoundedContainer( raduis: 16, - margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), child: GetOutPatientStack(dashboardItemList[1]))); if (index == 0) return RoundedContainer( raduis: 16, - margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), child: GetOutPatientStack(dashboardItemList[0]))); if (index == 2) return RoundedContainer( raduis: 16, - margin: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), + margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( @@ -112,61 +116,65 @@ class _DashboardSwipeWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + Padding( + padding: EdgeInsets.all(8), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context) + .patients, + fontSize: 12, + fontWeight: FontWeight.bold, + fontHeight: 0.5, + ), + AppText( + TranslationBase.of(context) + .referral, + fontSize: 22, + fontWeight: FontWeight.bold, + ), + ], + )), Expanded( - flex: 1, - child: Padding( - padding: EdgeInsets.all(8), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context) - .patients, - fontSize: 12, - fontWeight: FontWeight.bold, - fontHeight: 0.5, - ), - AppText( - TranslationBase.of(context) - .referral, - fontSize: 22, - fontWeight: FontWeight.bold, - ), - ], - ))), - Expanded( - flex: 2, + flex: 1, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - RowCounts( - dashboardItemList[2] - .summaryoptions[0] - .kPIParameter, - dashboardItemList[2] - .summaryoptions[0] - .value, - Colors.black), - RowCounts( - dashboardItemList[2] - .summaryoptions[1] - .kPIParameter, - dashboardItemList[2] - .summaryoptions[1] - .value, - Colors.grey), - RowCounts( - dashboardItemList[2] - .summaryoptions[2] - .kPIParameter, - dashboardItemList[2] - .summaryoptions[2] - .value, - Colors.red), + Expanded( + child: RowCounts( + dashboardItemList[2] + .summaryoptions[0] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[0] + .value, + Colors.black), + ), + Expanded( + child: RowCounts( + dashboardItemList[2] + .summaryoptions[1] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[1] + .value, + Colors.grey), + ), + Expanded( + child: RowCounts( + dashboardItemList[2] + .summaryoptions[2] + .kPIParameter, + dashboardItemList[2] + .summaryoptions[2] + .value, + Colors.red), + ), ], ), ) @@ -187,7 +195,7 @@ class _DashboardSwipeWidgetState extends State { widget.model .getPatientCount(dashboardItemList[2]) .toString(), - fontSize: 30, + fontSize: 28, fontWeight: FontWeight.bold, ) ], diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index d3fe217c..4a375d6d 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -202,19 +202,17 @@ class _HomeScreenState extends State { ])), content: Column( children: [ - Container( - height: MediaQuery.of(context).size.height * 0.35, - child: model.dashboardItemsList.length > 0 - ? DashboardSwipeWidget( - model.dashboardItemsList, - model, - (sliderIndex) { - setState(() { - sliderActiveIndex = sliderIndex; - }); - }, - ) - : SizedBox()), + model.dashboardItemsList.length > 0 + ? DashboardSwipeWidget( + model.dashboardItemsList, + model, + (sliderIndex) { + setState(() { + sliderActiveIndex = sliderIndex; + }); + }, + ) + : SizedBox(), model.dashboardItemsList.length > 0 ? FractionallySizedBox( widthFactor: 0.90, diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index b3b7ed8c..2a9109c3 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -19,9 +19,13 @@ class GetOutPatientStack extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - AppText( - value.kPIName, - medium: true, + Container( + height: 30, + child: AppText( + value.kPIName, + medium: true, + fontSize: 14, + ), ), Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list) ], diff --git a/lib/widgets/dashboard/row_count.dart b/lib/widgets/dashboard/row_count.dart index a42cccdf..a22932f4 100644 --- a/lib/widgets/dashboard/row_count.dart +++ b/lib/widgets/dashboard/row_count.dart @@ -24,7 +24,7 @@ class RowCounts extends StatelessWidget { name, color: Colors.black, textAlign: TextAlign.start, // from TextAlign.center - fontSize: 12, + fontSize: 11, textOverflow: TextOverflow.ellipsis, ), ), @@ -32,7 +32,7 @@ class RowCounts extends StatelessWidget { ' (' + count.toString() + ')', color: Colors.black, textAlign: TextAlign.center, - fontSize: 13, + fontSize: 12, fontWeight: FontWeight.bold, ) ], From 27f940b4738ab233c8222d00f82992b4db65a162 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 9 May 2021 14:45:05 +0300 Subject: [PATCH 10/11] home design --- .../home/dashboard_slider-item-widget.dart | 4 +-- lib/widgets/dashboard/activity_button.dart | 29 +++++++------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/lib/screens/home/dashboard_slider-item-widget.dart b/lib/screens/home/dashboard_slider-item-widget.dart index 4ee67daf..4b7c4f46 100644 --- a/lib/screens/home/dashboard_slider-item-widget.dart +++ b/lib/screens/home/dashboard_slider-item-widget.dart @@ -24,8 +24,8 @@ class DashboardSliderItemWidget extends StatelessWidget { ], ), new Container( - height: 130, - child: new ListView( + height: 110, + child: ListView( scrollDirection: Axis.horizontal, children: List.generate(item.summaryoptions.length, (int index) { diff --git a/lib/widgets/dashboard/activity_button.dart b/lib/widgets/dashboard/activity_button.dart index b8f390dd..a46fc334 100644 --- a/lib/widgets/dashboard/activity_button.dart +++ b/lib/widgets/dashboard/activity_button.dart @@ -9,39 +9,32 @@ class GetActivityButton extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - width: 120, + width: 110, padding: EdgeInsets.all(5), margin: EdgeInsets.all(5), - height: 130, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), ), child: Padding( - padding: const EdgeInsets.fromLTRB(8, 8, 8, 0), + padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ AppText( value.value.toString(), - fontSize: 30, + fontSize: 27, fontWeight: FontWeight.bold, color: Color(0xFF2B353E), ), - Expanded( - child: Column( - children: [ - AppText( - value.kPIParameter, - textOverflow: TextOverflow.clip, - fontSize: 10, - color: Color(0xFF2B353E), - textAlign: TextAlign.start, - fontWeight: FontWeight.w700, - ), - ], - ), + AppText( + value.kPIParameter, + textOverflow: TextOverflow.clip, + fontSize: 10, + color: Color(0xFF2B353E), + textAlign: TextAlign.start, + fontWeight: FontWeight.w700, ), ], ), From 50b4b8eb500e1d81f39949f6b53e06f63e633949 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 9 May 2021 16:15:06 +0300 Subject: [PATCH 11/11] dashboard change --- lib/screens/home/dashboard_swipe_widget.dart | 15 +++++++ lib/widgets/dashboard/out_patient_stack.dart | 45 +++++++++++-------- .../shared/rounded_container_widget.dart | 12 +++-- 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/lib/screens/home/dashboard_swipe_widget.dart b/lib/screens/home/dashboard_swipe_widget.dart index de582dc2..a6dc12eb 100644 --- a/lib/screens/home/dashboard_swipe_widget.dart +++ b/lib/screens/home/dashboard_swipe_widget.dart @@ -87,6 +87,11 @@ class _DashboardSwipeWidgetState extends State { if (index == 1) return RoundedContainer( raduis: 16, + showBorder: true, + borderColor: Colors.white, + shadowWidth: 0.2, + shadowSpreadRadius: 3, + shadowDy: 1, margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), @@ -94,6 +99,11 @@ class _DashboardSwipeWidgetState extends State { if (index == 0) return RoundedContainer( raduis: 16, + showBorder: true, + borderColor: Colors.white, + shadowWidth: 0.2, + shadowSpreadRadius: 3, + shadowDy: 1, margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Padding( padding: const EdgeInsets.all(5.0), @@ -101,6 +111,11 @@ class _DashboardSwipeWidgetState extends State { if (index == 2) return RoundedContainer( raduis: 16, + showBorder: true, + borderColor: Colors.white, + shadowWidth: 0.2, + shadowSpreadRadius: 3, + shadowDy: 1, margin: EdgeInsets.only(top: 15, bottom: 15, left: 10, right: 10), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/widgets/dashboard/out_patient_stack.dart b/lib/widgets/dashboard/out_patient_stack.dart index 2a9109c3..2b982e20 100644 --- a/lib/widgets/dashboard/out_patient_stack.dart +++ b/lib/widgets/dashboard/out_patient_stack.dart @@ -37,8 +37,15 @@ class GetOutPatientStack extends StatelessWidget { child: Container( margin: EdgeInsets.symmetric(horizontal: 2), decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment( + 0.0, 1.0), // 10% of the width, so there are ten blinds. + colors: [Color(0x8FF5F6FA), Colors.red[50]], // red to yellow + tileMode: TileMode.mirror, // repeats the gradient over the canvas + ), borderRadius: BorderRadius.circular(8), - color: Colors.red[50], + // color: Colors.red[50], ), child: Stack(children: [ Positioned( @@ -64,25 +71,25 @@ class GetOutPatientStack extends StatelessWidget { child: Center( child: Align( child: FittedBox( - child: Row( - children: [ - AppText( - value.kPIParameter, - fontSize: 10, - textAlign: TextAlign.center, - color: Color(0xFF2B353E), - fontWeight: FontWeight.w700, - ), - AppText( - ' (' + value.value.toString() + ') ', - fontSize: 12, - textAlign: TextAlign.center, - color: Color(0xFF2B353E), - fontWeight: FontWeight.bold, - ), - ], + child: Row( + children: [ + AppText( + value.kPIParameter, + fontSize: 10, + textAlign: TextAlign.center, + color: Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + AppText( + ' (' + value.value.toString() + ') ', + fontSize: 12, + textAlign: TextAlign.center, + color: Color(0xFF2B353E), + fontWeight: FontWeight.bold, ), - )), + ], + ), + )), ), )) ]), diff --git a/lib/widgets/shared/rounded_container_widget.dart b/lib/widgets/shared/rounded_container_widget.dart index 4cfe7b08..8364bb79 100644 --- a/lib/widgets/shared/rounded_container_widget.dart +++ b/lib/widgets/shared/rounded_container_widget.dart @@ -9,6 +9,9 @@ class RoundedContainer extends StatefulWidget { final double elevation; final bool showBorder; final Color borderColor; + final double shadowWidth; + final double shadowSpreadRadius; + final double shadowDy; final bool customCornerRaduis; final double topLeft; final double bottomRight; @@ -27,6 +30,9 @@ class RoundedContainer extends StatefulWidget { this.elevation = 1, this.showBorder = false, this.borderColor = Colors.red, + this.shadowWidth = 0.1, + this.shadowSpreadRadius = 10, + this.shadowDy = 5, this.customCornerRaduis = false, this.topLeft = 0, this.topRight = 0, @@ -59,10 +65,10 @@ class _RoundedContainerState extends State { : BorderRadius.circular(widget.raduis), boxShadow: [ BoxShadow( - color: Colors.grey.withOpacity(0.1), - spreadRadius: 10, + color: Colors.grey.withOpacity(widget.shadowWidth), + spreadRadius: widget.shadowSpreadRadius, blurRadius: 5, - offset: Offset(0, 5), // changes position of shadow + offset: Offset(0, widget.shadowDy), // changes position of shadow ), ]) : null,