import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';

class PatientReferralItemWidget extends StatelessWidget {
  final String patientName;
  final String patientID;
  final String referralStatus;
  final isReferredTo;
  final isSameBranch;
  final String referralDoctorName;
  final String clinicDescription;
  final String remark;
  final String referredOn;
  final String answerFromTarget;
  final Widget infoIcon;

  PatientReferralItemWidget(
    this.patientID, {
    this.patientName,
    this.referralStatus,
    this.isReferredTo = false,
    this.isSameBranch,
    this.referralDoctorName,
    this.clinicDescription,
    this.remark,
    this.referredOn,
    this.answerFromTarget,
    this.infoIcon,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(16.0),
      child: Column(
        children: [
          Row(
            children: [
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    if (referralStatus != null)
                      Row(
                        children: [
                          AppText(
                            TranslationBase.of(context).referralStatus,
                            color: Colors.grey,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                          Container(
                            color: Color(0xFF4BA821),
                            padding: EdgeInsets.all(4),
                            child: AppText(
                              referralStatus
                              /*referralStatus == "46"
                                  ? TranslationBase.of(context).approved
                                  : TranslationBase.of(context).rejected*/
                              ,
                              color: Colors.white,
                              fontWeight: FontWeight.bold,
                              fontSize: 12,
                            ),
                          ),
                        ],
                      ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      children: [
                        AppText(
                          isReferredTo
                              ? "${TranslationBase.of(context).referTo}: "
                              : "${TranslationBase.of(context).referredFrom}: ",
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        AppText(
                          isSameBranch
                              ? TranslationBase.of(context).sameBranch
                              : TranslationBase.of(context).otherBranch,
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        AppText(
                          "${TranslationBase.of(context).referralDoctor} : ",
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        Expanded(
                          child: AppText(
                            referralDoctorName != null
                                ? "${TranslationBase.of(context).dr} $referralDoctorName"
                                : "-",
                            color: Colors.black,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    if (clinicDescription != null)
                      Row(
                        children: [
                          AppText(
                            "${TranslationBase.of(context).clinic}: ",
                            color: Colors.grey,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                          AppText(
                            clinicDescription,
                            color: Colors.black,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                        ],
                      ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      children: [
                        AppText(
                          "${TranslationBase.of(context).patientID}: ",
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        AppText(
                          patientID ?? '-',
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      children: [
                        AppText(
                          "${TranslationBase.of(context).patientName}: ",
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        AppText(
                          patientName ?? '-',
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        AppText(
                          TranslationBase.of(context).referralRemark,
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        Expanded(
                          child: AppText(
                            remark,
                            color: Colors.black,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Row(
                      children: [
                        AppText(
                          TranslationBase.of(context).referredOn,
                          color: Colors.grey,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                        AppText(
                          referredOn ?? '-',
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 12,
                        ),
                      ],
                    ),
                    if (answerFromTarget != null)
                      SizedBox(
                        height: 8,
                      ),
                    if (answerFromTarget != null)
                      Row(
                        children: [
                          AppText(
                            TranslationBase.of(context).referralResponse,
                            color: Colors.grey,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                          AppText(
                            answerFromTarget != "" ? answerFromTarget : '-',
                            color: Colors.black,
                            fontWeight: FontWeight.bold,
                            fontSize: 12,
                          ),
                        ],
                      ),
                    SizedBox(
                      height: 16,
                    ),
                  ],
                ),
              ),
              if (infoIcon != null) infoIcon,
            ],
          ),
          const Divider(
            color: Color(0xffCCCCCC),
            height: 1,
            thickness: 1,
            indent: 0,
            endIndent: 0,
          ),
          SizedBox(
            height: 8,
          ),
        ],
      ),
    );
  }
}
