import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.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:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

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

  DoctorCardInsurance(
      {this.doctorName,
      this.branch,
      this.profileUrl,
      this.invoiceNO,
      this.onTap,
      this.appointmentDate,
      this.orderNo,
      this.isPrescriptions = 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: 5,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(10),
                  bottomLeft: Radius.circular(10),
                ),
                color: approvalStatus == "Approved"
                    ? Color(0xff359846)
                    : 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"
                                ? Color(0xff359846)
                                : Color(0xffD02127),
                          ),
                          Container(
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.all(
                                  Radius.circular(25.0),
                                ),
                                color: Color(0xff2E303A)),
                            child: Padding(
                              padding: const EdgeInsets.all(5.0),
                              child: AppText(
                                '$patientOut'.replaceAll(" ", ""),
                                color: Colors.white,
                                fontSize: 13.0,
                              ),
                            ),
                          )
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(
                              child: AppText(
                            doctorName,
                            bold: true,
                          )),
                        ],
                      ),
                      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 && !isPrescriptions)
                                      Row(
                                        children: <Widget>[
                                          AppText(
                                            'order No:',
                                            color: Colors.grey[500],
                                          ),
                                          AppText(
                                            orderNo ?? '',
                                          )
                                        ],
                                      ),
                                    if (invoiceNO != null && !isPrescriptions)
                                      Row(
                                        children: <Widget>[
                                          AppText(
                                            'Invoice:',
                                            color: Colors.grey[500],
                                          ),
                                          AppText(
                                            invoiceNO,
                                          )
                                        ],
                                      ),
                                    if (isPrescriptions)
                                      Row(
                                        children: <Widget>[
                                          AppText(
                                            TranslationBase.of(context).clinic +
                                                ": ",
                                            color: Colors.grey[500],
                                            fontSize: 14,
                                            //fontWeight: FontWeight.w600,
                                            //color: Colors.grey[500],
                                          ),
                                          Expanded(
                                            child: AppText(
                                              clinic,
                                              //fontWeight: FontWeight.w700,
                                              fontSize: 14.0,
                                            ),
                                          )
                                        ],
                                      ),
                                    if (branch2 != null)
                                      Row(
                                        children: <Widget>[
                                          AppText(
                                            TranslationBase.of(context).branch +
                                                ": ",
                                            fontSize: 14,
                                            color: Colors.grey[500],
                                          ),
                                          AppText(
                                            branch2,
                                            fontSize: 14.0,
                                          )
                                        ],
                                      ),
                                    Row(
                                      children: <Widget>[
                                        AppText(
                                          TranslationBase.of(context)
                                                  .approvalNo +
                                              ": ",
                                          fontSize: 14,
                                          color: Colors.grey[500],
                                          //color: Colors.grey[500],
                                        ),
                                        AppText(
                                          branch,
                                          fontSize: 14.0,
                                        )
                                      ],
                                    ),
                                  ]),
                            ),
                          ),
                          Padding(
                            padding:
                                const EdgeInsets.symmetric(horizontal: 15.0),
                            child: Icon(
                              EvaIcons.eye,
                            ),
                          )
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
