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.
308 lines
13 KiB
Dart
308 lines
13 KiB
Dart
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/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/cupertino.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:provider/provider.dart';
|
|
import 'package:rating_bar/rating_bar.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 Function onTap;
|
|
final Function 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;
|
|
final bool isLabOrderResult;
|
|
final int resultStatus;
|
|
final String resultStatusDesc;
|
|
|
|
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,
|
|
this.isLabOrderResult = false,
|
|
this.resultStatus,
|
|
this.resultStatusDesc});
|
|
|
|
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: <Widget>[
|
|
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
|
|
? Color(0xff2E303A)
|
|
: !isInOutPatient
|
|
? Color(0xffD02127)
|
|
: 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
|
|
? TranslationBase.of(context).liveCare.toLowerCase().capitalizeFirstofEach
|
|
: !isInOutPatient
|
|
? 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: <Widget>[
|
|
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: <Widget>[
|
|
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: <Widget>[
|
|
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).invoiceNo, billNo ?? "", projectViewModel.isArabic),
|
|
if (vaccineName != "") MyRichText("", vaccineName ?? "", projectViewModel.isArabic),
|
|
if (rating != null)
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: <Widget>[
|
|
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,
|
|
),
|
|
],
|
|
),
|
|
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: Color(0xffD02127), letterSpacing: -0.48, height: 18 / 12),
|
|
)
|
|
: Container();
|
|
},
|
|
),
|
|
],
|
|
),
|
|
if (isLabOrderResult)
|
|
MyRichText(TranslationBase.of(context).resultStatus, resultStatusDesc ?? "", projectViewModel.isArabic, valueColor: getResultStatusColor(resultStatus)),
|
|
],
|
|
),
|
|
),
|
|
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(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Color getResultStatusColor(int resultStatus) {
|
|
Color statusColor = Color(0xff2B353E);
|
|
|
|
if (resultStatus == 17 || resultStatus == 16) {
|
|
statusColor = CustomColors.green;
|
|
}
|
|
if (resultStatus == 45) {
|
|
statusColor = CustomColors.orange;
|
|
}
|
|
if (resultStatus == 44) {
|
|
statusColor = CustomColors.accentColor;
|
|
}
|
|
|
|
return statusColor;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|