import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/countdown_timer_controller.dart'; import 'package:flutter_countdown_timer/current_remaining_time.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; import '../../my_rich_text.dart'; class DoctorCard extends StatelessWidget { final String? name; final String? subName; final double? rating; final DateTime? date; final String? profileUrl; final String? billNo; final VoidCallback? onTap; final VoidCallback? onEmailTap; final bool? isInOutPatient; final bool? isShowInOutPatient; final bool? isLiveCareAppointment; final bool? isSortByClinic; final String? appointmentTime; final bool? isParentAppointment; final int? remainingTimeInMinutes; final String vaccineName; final bool isSickLeave; final int sickLeaveStatus; final int projectID; DoctorCard( {this.name, this.subName, this.rating, this.date, this.profileUrl, this.isSortByClinic = true, this.billNo, this.onTap, this.onEmailTap, this.isInOutPatient, this.isLiveCareAppointment = false, this.appointmentTime, this.remainingTimeInMinutes, this.isShowInOutPatient = true, this.vaccineName = "", this.isParentAppointment = false, this.isSickLeave = false, this.sickLeaveStatus = 0, this.projectID = 0}); late ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return Container( height: 135, decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.0), ), border: Border.all(width: 1, color: Color(0xffEFEFEF)), boxShadow: [ BoxShadow( color: Color(0xff000000).withOpacity(.05), //spreadRadius: 5, blurRadius: 27, offset: Offset(0, -3), ), ], color: Colors.white), child: InkWell( onTap: onTap, child: Row( mainAxisSize: MainAxisSize.min, children: [ Container( // width: 16, // projectViewModel.isArabic ? 27 : 20, height: double.infinity, alignment: Alignment.center, padding: EdgeInsets.only(left: 2, right: 2), decoration: isShowInOutPatient! ? BoxDecoration( //Colors.red[900] Color(0xff404545) color: Utils.isHMCProject(projectViewModel, projectID) ? Color(0xff3FACC8) : isLiveCareAppointment != null && isLiveCareAppointment == true ? Color(0xff2E303A) : isInOutPatient != null && isInOutPatient == false ? appColor : Color(0xffa9a089), borderRadius: BorderRadius.only( topLeft: projectViewModel!.isArabic ? Radius.circular(0) : Radius.circular(10), bottomLeft: projectViewModel!.isArabic ? Radius.circular(0) : Radius.circular(10), topRight: projectViewModel!.isArabic ? Radius.circular(10) : Radius.circular(0), bottomRight: projectViewModel!.isArabic ? Radius.circular(10) : Radius.circular(0), ), ) : BoxDecoration(), child: isShowInOutPatient! ? RotatedBox( quarterTurns: 3, child: Text( isLiveCareAppointment != null && isLiveCareAppointment == true ? TranslationBase.of(context).liveCare.toLowerCase().capitalizeFirstofEach : isInOutPatient != null && isInOutPatient == false ? TranslationBase.of(context).inPatient.toLowerCase().capitalizeFirstofEach : TranslationBase.of(context).outpatient.toLowerCase().capitalizeFirstofEach, style: TextStyle(fontSize: 10, fontWeight: FontWeight.w700, color: Colors.white, letterSpacing: -0.2, height: 16 / 10), ), ) : Container(), ), Expanded( child: Padding( padding: const EdgeInsets.only(left: 20, right: 12, top: 12, bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ if (isSickLeave) Text( getStatusText(context), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: getStatusColor(), letterSpacing: -0.4, height: 16 / 10), ), Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Text( (name ?? ""), style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, ), ), ), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( DateUtil.getDayMonthYearDateFormatted(date!), style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12), ), Text( // DateUtil.formatDateToTime(date), appointmentTime ?? "", style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.48, height: 18 / 12), ), ], ), ], ), Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ LargeAvatar( name: name, url: profileUrl, width: 48, height: 48, ), SizedBox(width: 11), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ MyRichText(isSortByClinic! ? TranslationBase.of(context).branch : TranslationBase.of(context).clinic + ":", subName ?? "", projectViewModel!.isArabic), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ if (rating == null && billNo != "") MyRichText(TranslationBase.of(context).orderNo, billNo ?? "", projectViewModel!.isArabic), if (vaccineName != "") MyRichText("", vaccineName ?? "", projectViewModel!.isArabic), if (rating != null) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ // RatingBar.readOnly( // initialRating: rating, // size: 16.0, // filledColor: Color(0XFFD02127), // emptyColor: Color(0XFFD02127), // isHalfAllowed: true, // halfFilledIcon: Icons.star_half, // filledIcon: Icons.star, // emptyIcon: Icons.star_border, // ), RatingBar( itemSize: 20.0, allowHalfRating: true, initialRating: rating!, ignoreGestures: true, ratingWidget: RatingWidget( full: Icon( Icons.star, color: CustomColors.primaryColor, ), half: Icon( Icons.star_half, color: CustomColors.primaryColor, ), empty: Icon( Icons.star_border, color: CustomColors.primaryColor, ), ), unratedColor: Colors.grey[500], onRatingUpdate: (double value) {}), ], ), if (remainingTimeInMinutes != null) CountdownTimer( controller: CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (remainingTimeInMinutes! * 1000) * 60), widgetBuilder: (_, CurrentRemainingTime? time) { return time != null ? Text( "${time.days ?? 0}:${time.hours ?? 0}:${time.min}:${time.sec}", style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: CustomColors.primaryColor, letterSpacing: -0.48, height: 18 / 12), ) : Container(); }, ), ], ), ], ), ), SizedBox( height: 48, child: Align( alignment: Alignment.bottomCenter, child: (onEmailTap != null && projectViewModel!.havePrivilege(17)) ? InkWell( onTap: onEmailTap, child: Icon( Icons.email, color: sickLeaveStatus != 3 ? Theme.of(context).primaryColor : Colors.grey[400], ), ) : onTap != null ? Icon( Icons.arrow_forward, color: Theme.of(context).primaryColor, ) : SizedBox(), ), ), ], ), ], ), ), ) ], ), ), ); } String getStatusText(BuildContext context) { String statusText = ""; if (sickLeaveStatus == 1) { statusText = TranslationBase.of(context).pendingActivation; } else if (sickLeaveStatus == 2) { statusText = TranslationBase.of(context).ready; } else if (sickLeaveStatus == 3) { statusText = TranslationBase.of(context).awaitingApproval; } else { statusText = ""; } return statusText; } Color getStatusColor() { Color statusColor = Colors.white; if (sickLeaveStatus == 1) { statusColor = Color(0xffCC9B14); } else if (sickLeaveStatus == 2) { statusColor = Color(0xff359846); } else if (sickLeaveStatus == 3) { statusColor = Color(0xffD02127); } else { statusColor = Colors.white; } return statusColor; } }