import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/user-guid/CusomRow.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../config/config.dart';

class DoctorCardInsurance extends StatelessWidget {
  final String? doctorName;
  final String? approvalNo;
  final DateTime? appointmentDate;
  final String? profileUrl;
  final String? invoiceNO;
  final String? orderNo;
  final Function? onTap;
  final bool isInsurance;
  final String? clinic;
  final String? approvalStatus;
  final String? patientOut;
  final String? branch2;

  DoctorCardInsurance(
      {this.doctorName,
      this.approvalNo,
      this.profileUrl,
      this.invoiceNO,
      this.onTap,
      this.appointmentDate,
      this.orderNo,
      this.isInsurance = false,
      this.clinic,
      this.approvalStatus,
      this.patientOut,
      this.branch2});

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return Container(
      width: double.maxFinite,
      //height: 160,
      margin: EdgeInsets.all(10),
      padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(15),
        color: Colors.white,
      ),
      child: Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              height: 160,
              width: 4.5,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(10),
                  bottomLeft: Radius.circular(10),
                ),
                color: approvalStatus == "Approved" ||
                        approvalStatus == "تمت الموافقة"
                    ? AppGlobal.appGreenColor
                    : Color(0xffD02127),
              ),
            ),
            Expanded(
              child: Container(
                padding: EdgeInsets.only(
                    left: projectViewModel.isArabic ? 0 : 15,
                    right: projectViewModel.isArabic ? 15 : 0),
                child: InkWell(
                  onTap: onTap!(),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          AppText(
                            "$approvalStatus",
                            color: approvalStatus == "Approved" ||
                                    approvalStatus == "تمت الموافقة"
                                ? AppGlobal.appGreenColor
                                : Color(0xffD02127),
                            letterSpacing: -0.4,
                            fontSize:
                                SizeConfig.getTextMultiplierBasedOnWidth() *
                                    2.7,
                          ),
                          Container(
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.all(
                                  Radius.circular(20.0),
                                ),
                                color: Color(0xff2E303A)),
                            child: Padding(
                              padding: const EdgeInsets.symmetric(
                                  vertical: 6.5, horizontal: 11.5),
                              child: AppText(
                                '$patientOut'.replaceAll(" ", ""),
                                color: Colors.white,
                                fontSize:
                                    SizeConfig.getTextMultiplierBasedOnWidth() *
                                        2.7,
                                letterSpacing: -0.4,
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                          )
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(
                              child: AppText(
                            doctorName!,
                            fontSize: 16.0,
                            letterSpacing: -0.64,
                            fontWeight: FontWeight.w600,
                          )),
                        ],
                      ),
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Container(
                            child: LargeAvatar(
                              name: doctorName!,
                              url: profileUrl,
                            ),
                            width: 55,
                            height: 55,
                          ),
                          Expanded(
                            flex: 4,
                            child: Container(
                              margin: EdgeInsets.all(10),
                              child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    if (orderNo != null && !isInsurance)
                                      CustomRow(
                                        label: 'Invoice:',
                                        value: invoiceNO!,
                                      ),
                                    if (invoiceNO != null && !isInsurance)
                                      CustomRow(
                                        label: 'Invoice:',
                                        value: invoiceNO!,
                                      ),
                                    if (isInsurance)
                                      CustomRow(
                                        label:
                                            TranslationBase.of(context).clinic +
                                                ": ",
                                        value: clinic!,
                                      ),
                                    if (branch2 != null)
                                      CustomRow(
                                        label:
                                            TranslationBase.of(context).branch +
                                                ": ",
                                        value: branch2!,
                                      ),
                                    if (approvalNo != null)
                                      CustomRow(
                                        label: TranslationBase.of(context)
                                                .approvalNo +
                                            ": ",
                                        value: approvalNo!,
                                      ),
                                  ]),
                            ),
                          ),
                          Column(
                            children: [
                              Padding(
                                padding: const EdgeInsets.symmetric(
                                    horizontal: 15.0),
                                child: Icon(
                                  EvaIcons.eye,
                                  color: Color(0xff2E303A),
                                ),
                              ),
                            ],
                          )
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
