import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';

import 'StarRating.dart';
import 'Text.dart';

class DoctorCard 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;

  DoctorCard(
      {this.doctorName,
      this.branch,
      this.profileUrl,
      this.invoiceNO,
      this.onTap,
      this.appointmentDate,
      this.orderNo, this.isPrescriptions=false, this.clinic});

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return Container(
      margin: EdgeInsets.all(10),
      decoration: BoxDecoration(
          border: Border.all(
            width: 0.5,
            color: Colors.white,
          ),
          borderRadius: BorderRadius.all(
            Radius.circular(15.0),
          ),
          color: Colors.white),
      child: Padding(
        padding: const EdgeInsets.all(15.0),
        child: InkWell(
          onTap: onTap,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Row(
                children: [
                  Expanded(
                      child: Texts(
                    doctorName,
                    bold: true,
                  )),
                  Expanded(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Texts(
                          '${DateUtils.getDayMonthYearDateFormatted(appointmentDate, isArabic: projectViewModel.isArabic)}',
                          color: Colors.black,
                          fontWeight: FontWeight.w600,
                          fontSize: 14,
                        ),
                        if(!isPrescriptions)
                        Texts(
                          '${DateUtils.getHour(appointmentDate)}',
                          fontWeight: FontWeight.w600,
                          color: Colors.grey[700],
                          fontSize: 14,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                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>[
                                  Texts(
                                    'order No:',
                                    color: Colors.grey[500],
                                    fontSize: 14,
                                  ),
                                  Texts(
                                    orderNo ?? '',
                                    fontSize: 14,
                                  )
                                ],
                              ),
                            if (invoiceNO != null && !isPrescriptions)
                              Row(
                                children: <Widget>[
                                  Texts(
                                    'Invoice:',
                                    fontSize: 14,
                                    color: Colors.grey[500],
                                  ),
                                  Texts(
                                    invoiceNO,
                                    fontSize: 14,
                                  )
                                ],
                              ),
                            if(isPrescriptions)
                            Row(
                              children: <Widget>[
                                Texts(
                                  'Clinic: ',
                                  color: Colors.grey[500],
                                  fontSize: 14,
                                ),
                                Texts(
                                  clinic,
                                  fontSize: 14,
                                )
                              ],
                            ),
                            if(branch!=null)
                            Row(
                              children: <Widget>[
                                Texts(
                                  'Branch: ',
                                  fontSize: 14,
                                  color: Colors.grey[500],
                                ),
                                Texts(
                                  branch,
                                  fontSize: 14,
                                )
                              ],
                            )
                          ]),
                    ),
                  ),
                  Icon(
                   EvaIcons.eye,
                  )
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
