You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/widgets/new_design/doctor_header.dart

496 lines
25 KiB
Dart

7 months ago
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/models/Appointments/DoctorRateDetails.dart';
import 'package:hmg_patient_app/models/header_model.dart';
import 'package:hmg_patient_app/services/appointment_services/GetDoctorsList.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/app_toast.dart';
import 'package:hmg_patient_app/uitl/date_uitl.dart';
import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/avatar/large_avatar.dart';
import 'package:hmg_patient_app/widgets/buttons/defaultButton.dart';
import 'package:hmg_patient_app/widgets/dialogs/confirm_send_email_dialog.dart';
import 'package:hmg_patient_app/widgets/my_rich_text.dart';
import 'package:flutter/material.dart';
2 years ago
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
class DoctorHeader extends StatelessWidget {
final HeaderModel headerModel;
2 years ago
final VoidCallback? onTap;
final VoidCallback? onRatingAndReviewTap;
final bool showConfirmMessageDialog;
2 years ago
final String? buttonTitle;
2 years ago
final String? buttonIcon;
final bool isNeedToShowButton;
3 years ago
final bool isShowName;
final bool isDownload;
DoctorHeader(
2 years ago
{Key? key,
2 years ago
required this.headerModel,
this.buttonTitle,
this.onTap,
this.isNeedToShowButton = true,
3 years ago
this.isShowName = false,
this.buttonIcon,
this.showConfirmMessageDialog = true,
this.isDownload = false,
2 years ago
this.onRatingAndReviewTap})
: super(key: key);
2 years ago
late ProjectViewModel projectViewModel;
@override
Widget build(BuildContext context) {
2 years ago
String _speciality = (headerModel.speciality ?? []).length > 0 ? headerModel.speciality.first : "";
projectViewModel = Provider.of(context);
return Container(
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
3 years ago
crossAxisAlignment: CrossAxisAlignment.start,
children: [
3 years ago
if (isShowName)
Padding(
padding: EdgeInsets.only(left: 21, right: 21, bottom: 12),
child: Text(
2 years ago
headerModel.doctorName,
3 years ago
maxLines: 1,
style: TextStyle(
fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24),
),
),
Padding(
4 years ago
padding: EdgeInsets.only(left: 21, right: 21, bottom: 12),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LargeAvatar(
2 years ago
name: headerModel.doctorName,
url: headerModel.doctorImageURL,
width: 51,
height: 51,
2 years ago
disableProfileView: headerModel.doctorImageURL.isEmpty && headerModel.doctorImageURL == null ? true : false,
),
SizedBox(width: 10),
Expanded(
2 years ago
flex: 4,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (_speciality != null && _speciality.isNotEmpty)
4 years ago
Text(
_speciality != "null" ? _speciality : "",
4 years ago
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12),
),
headerModel.invoiceNo.isNotEmpty ? MyRichText(TranslationBase.of(context).invoiceNo + ":", headerModel.invoiceNo, projectViewModel.isArabic) : Container(),
MyRichText(TranslationBase.of(context).branch, headerModel.projectName, projectViewModel.isArabic),
],
),
),
Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
4 years ago
if (headerModel.date != null)
Text(
DateUtil.getDayMonthYearDateFormatted(headerModel.date!),
4 years ago
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
if (headerModel.time != null)
Text(
headerModel.time ?? DateUtil.formatDateToTime(headerModel.date!),
4 years ago
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12),
),
2 years ago
if (headerModel.nationalityFlagURL != null)
4 years ago
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: headerModel.nationalityFlagURL.isNotEmpty && headerModel.nationalityFlagURL != null && headerModel.nationalityFlagURL != 'null'
? Image.network(headerModel.nationalityFlagURL, height: 20)
: SizedBox(),
4 years ago
),
],
)
],
),
),
4 years ago
if (headerModel.actualDoctorRate != null)
SizedBox(
height: 43,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
if ((headerModel?.totalReviews ?? 0) > 0) {
getDoctorRatingsDetails(context);
}
},
4 years ago
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 21),
2 years ago
RatingBar(
2 years ago
itemSize: 20.0,
allowHalfRating: true,
2 years ago
ignoreGestures: true,
2 years ago
initialRating: headerModel.actualDoctorRate! + 0.0,
ratingWidget: RatingWidget(
full: Icon(
Icons.star,
color: CustomColors.accentColor,
),
half: Icon(
Icons.star_half,
color: CustomColors.accentColor,
),
empty: Icon(
Icons.star_border,
color: CustomColors.accentColor,
),
),
unratedColor: Colors.grey[500],
2 years ago
onRatingUpdate: (double value) {}),
4 years ago
SizedBox(width: 6),
Text(
4 years ago
"${headerModel.totalReviews == null ? 0 : headerModel.totalReviews} ${TranslationBase.of(context).reviews}",
4 years ago
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: (headerModel?.totalReviews ?? 0) > 0 ? Colors.blue[600] : Color(0xff2B353E),
4 years ago
letterSpacing: -0.48,
height: 18 / 12,
decoration: (headerModel?.totalReviews ?? 0) > 0 ? TextDecoration.underline : null,
),
),
4 years ago
],
),
),
isNeedToShowButton
? InkWell(
onTap: () {
if (showConfirmMessageDialog)
2 years ago
showConfirmMessage(context, onTap!, headerModel.email);
4 years ago
else
7 months ago
onTap!();
4 years ago
},
child: Container(
2 years ago
padding: EdgeInsets.only(top: 10, bottom: 10, right: 15, left: 15),
decoration: BoxDecoration(
color: isDownload ? CustomColors.green : CustomColors.accentColor,
borderRadius: projectViewModel.isArabic ? BorderRadius.only(topRight: Radius.circular(10)) : BorderRadius.only(topLeft: Radius.circular(10))),
4 years ago
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
SvgPicture.asset(buttonIcon ?? 'assets/images/new/email.svg', width: 19.0),
2 years ago
SizedBox(width: 4),
4 years ago
Text(
7 months ago
buttonTitle == null ? TranslationBase.of(context).sendEmail : buttonTitle!,
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.64, height: 1),
4 years ago
),
],
),
),
)
: Container(),
],
),
)
],
),
);
}
void showConfirmMessage(BuildContext context, GestureTapCallback onTap, String email) {
showDialog(
context: context,
builder: (cxt) => ConfirmSendEmailDialog(
email: email,
onTapSendEmail: () {
onTap();
},
),
);
}
void getDoctorRatingsDetails(context) {
GifLoaderDialogUtils.showMyDialog(context);
2 years ago
List<DoctorRateDetails> doctorDetailsList = [];
DoctorsListService service = new DoctorsListService();
2 years ago
service.getDoctorsRatingDetails(headerModel.doctorId, projectViewModel.isArabic ? 1 : 2, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
doctorDetailsList.clear();
res['DoctorRatingDetailsList'].forEach((v) {
doctorDetailsList.add(new DoctorRateDetails.fromJson(v));
});
this.headerModel.decimalDoctorRate = res['DecimalDoctorRate'].toString();
showRatingDialog(doctorDetailsList, context);
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
print(err);
});
}
void showRatingDialog(List<DoctorRateDetails> doctorDetailsList, context) {
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.5),
transitionBuilder: (context, a1, a2, widget) {
final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0;
return Transform(
transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
child: Opacity(
opacity: a1.value,
child: Dialog(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
4 years ago
width: 350.0,
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.all(20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(TranslationBase.of(context).doctorRating, style: TextStyle(fontSize: 22.0, color: Colors.black, fontWeight: FontWeight.w600, letterSpacing: -0.64)),
IconButton(
icon: Icon(
Icons.close,
color: Colors.black,
),
onPressed: () {
Navigator.pop(context);
},
),
],
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
4 years ago
Container(
margin: EdgeInsets.symmetric(horizontal: 20.0),
2 years ago
child: Text(this.headerModel.decimalDoctorRate != null ? this.headerModel.decimalDoctorRate : this.headerModel.actualDoctorRate!.ceilToDouble().toString(),
4 years ago
style: TextStyle(fontSize: 32.0, color: Colors.black, letterSpacing: -0.64, fontWeight: FontWeight.bold))),
Container(
margin: EdgeInsets.symmetric(horizontal: 20.0),
2 years ago
child:
2 years ago
// RatingBar.readOnly(
// initialRating: this.headerModel.decimalDoctorRate != null ? double.tryParse(this.headerModel.decimalDoctorRate) : this.headerModel.actualDoctorRate.toDouble(),
// size: 35.0,
// filledColor: Colors.yellow[700],
// emptyColor: Colors.grey[500],
// isHalfAllowed: true,
// halfFilledIcon: Icons.star_half,
// filledIcon: Icons.star,
// emptyIcon: Icons.star,
// ),
2 years ago
RatingBar(
itemSize: 20.0,
allowHalfRating: true,
initialRating:
this.headerModel.decimalDoctorRate != null ? double.tryParse(this.headerModel.decimalDoctorRate)! : this.headerModel.actualDoctorRate!.toDouble(),
2 years ago
ratingWidget: RatingWidget(
full: Icon(
Icons.star,
color: CustomColors.accentColor,
2 years ago
),
half: Icon(
Icons.star_half,
color: CustomColors.accentColor,
2 years ago
),
empty: Icon(
Icons.star_border,
color: CustomColors.accentColor,
2 years ago
),
),
unratedColor: Colors.grey[500],
2 years ago
onRatingUpdate: (double value) {}),
2 years ago
// RatingBar(
// initialRating: this.headerModel!.decimalDoctorRate! != null ? double.tryParse(this.headerModel!.decimalDoctorRate!)! : this.headerModel!.actualDoctorRate!.toDouble(),
// //size: 15.0,
// // filledColor: ,
// // emptyColor: ,
// // isHalfAllowed: true,
// // halfFilledIcon: Icons.star_half,
// // filledIcon: ,
// ratingWidget: RatingWidget(
// full: Icon(
// Icons.star,
// color: Colors.yellow[700],
// size: 15,
// ),
// half: Icon(Icons.star_half, color: Colors.grey[500], size: 15),
// empty: Icon(Icons.star_half, color: Colors.grey[500], size: 15)),
// onRatingUpdate: (double value) {},
// ),
),
],
),
Container(
margin: EdgeInsets.symmetric(horizontal: 20.0),
4 years ago
transform: Matrix4.translationValues(0.0, -10.0, 0.0),
child: Text(this.headerModel.totalReviews.toString() + " " + TranslationBase.of(context).reviews,
style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600))),
Container(
margin: EdgeInsets.only(top: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
4 years ago
child: Text(TranslationBase.of(context).excellent, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
2 years ago
getRatingLine(doctorDetailsList[0].ratio, Colors.green[700]!),
],
),
Container(
3 years ago
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
2 years ago
child: Text(getRatingWidth(doctorDetailsList[0].ratio).round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
4 years ago
child: Text(TranslationBase.of(context).v_good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
3 years ago
getRatingLine(doctorDetailsList[1].ratio, Color(0xffB7B723)),
],
),
Container(
3 years ago
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
2 years ago
child: Text(doctorDetailsList[1].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
4 years ago
child: Text(TranslationBase.of(context).good, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
3 years ago
getRatingLine(doctorDetailsList[2].ratio, Color(0xffEBA727)),
],
),
Container(
3 years ago
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
2 years ago
child: Text(doctorDetailsList[2].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
4 years ago
child: Text(TranslationBase.of(context).average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
3 years ago
getRatingLine(doctorDetailsList[3].ratio, Color(0xffEB7227)),
],
),
Container(
3 years ago
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
2 years ago
child: Text(doctorDetailsList[3].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
),
],
),
),
Container(
margin: EdgeInsets.only(bottom: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 100.0,
margin: EdgeInsets.only(top: 10.0, left: 15.0, right: 15.0),
4 years ago
child: Text(TranslationBase.of(context).below_average, style: TextStyle(fontSize: 13.0, color: Colors.black, fontWeight: FontWeight.w600))),
3 years ago
getRatingLine(doctorDetailsList[4].ratio, Color(0xffE20C0C)),
],
),
Container(
3 years ago
margin: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
2 years ago
child: Text(doctorDetailsList[4].ratio.round().toString() + "%", style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.w600)),
),
],
),
),
],
),
),
],
),
),
),
);
},
transitionDuration: Duration(milliseconds: 500),
barrierDismissible: true,
barrierLabel: '',
context: context,
2 years ago
pageBuilder: (context, animation1, animation2) => SizedBox());
}
3 years ago
double getRatingWidth(double patientNumber) {
var width = patientNumber;
return width.roundToDouble();
}
4 years ago
3 years ago
Widget getRatingLine(double patientNumber, Color color) {
4 years ago
return Container(
margin: EdgeInsets.only(top: 10.0),
child: Stack(children: [
SizedBox(
2 years ago
width: 120.0,
4 years ago
height: 4.0,
child: Container(
color: Colors.grey[300],
),
),
SizedBox(
3 years ago
width: patientNumber * 1.35,
4 years ago
height: 4.0,
child: Container(
color: color,
),
),
]),
);
}
}