From 4ce9a3c5bffb4c660ff3a0bd102392dcadbb3822 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 5 May 2021 12:32:16 +0300 Subject: [PATCH] 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, ),