
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: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 name;
  final String subName;
  final double rat;
  final String date;
  final String profileUrl;
  final String billNo;
  final Function onTap;
  final Function onEmailTap;
  final bool isInOutPatient;
  final bool isLiveCareAppointment;

  DoctorCard(
      {this.name,
      this.subName,
      this.rat,
      this.date,
      this.profileUrl,
      this.billNo,
      this.onTap,
      this.onEmailTap,
      this.isInOutPatient,
      this.isLiveCareAppointment = false});

  @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: Theme.of(context).primaryColor,
          ),
          borderRadius: BorderRadius.all(
            Radius.circular(8.0),
          ),
          color: Colors.white),
      child: InkWell(
        onTap: onTap,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Row(
              children: <Widget>[
                Container(
                  width: projectViewModel.isArabic ? 27 : 20,
                  height: date == null
                      ? projectViewModel.isArabic
                          ? 185
                          : 100
                      : 180,
                  decoration: BoxDecoration(
                    //Colors.red[900]  Color(0xff404545)
                    color: isLiveCareAppointment
                        ? Color(0xff404545)
                        : !isInOutPatient
                            ? Colors.red[900]
                            : Theme.of(context).primaryColor,
                    borderRadius: BorderRadius.only(
                      topLeft: projectViewModel.isArabic
                          ? Radius.circular(0)
                          : Radius.circular(8),
                      bottomLeft: projectViewModel.isArabic
                          ? Radius.circular(0)
                          : Radius.circular(8),
                      topRight: projectViewModel.isArabic
                          ? Radius.circular(8)
                          : Radius.circular(0),
                      bottomRight: projectViewModel.isArabic
                          ? Radius.circular(8)
                          : Radius.circular(0),
                    ),
                  ),
                  child: RotatedBox(
                      quarterTurns: 3,
                      child: Center(
                        child: Text(
                          isLiveCareAppointment
                              ? TranslationBase.of(context)
                                  .liveCare
                                  .toUpperCase()
                              : !isInOutPatient
                                  ? TranslationBase.of(context)
                                      .inPatient
                                      .toUpperCase()
                                  : TranslationBase.of(context)
                                      .outpatient
                                      .toUpperCase(),
                          style: TextStyle(color: Colors.white),
                        ),
                      )),
                ),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Padding(
                        padding: const EdgeInsets.all(10.0),
                        child: Row(
                          children: <Widget>[
                            Expanded(
                              flex: 1,
                              child: LargeAvatar(
                                name: name,
                                url: profileUrl,
                              ),
                            ),
                            Expanded(
                              flex: 4,
                              child: Container(
                                margin: EdgeInsets.all(10),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    Texts(
                                      TranslationBase.of(context).dr +
                                          " " +
                                          name,
                                      bold: true,
                                    ),
                                    Texts(
                                      subName,
                                    ),
                                    if (billNo != null)
                                      Row(
                                        children: <Widget>[
                                          Texts(
                                            '${TranslationBase.of(context).billNo}: ',
                                          ),
                                          Texts(
                                            billNo,
                                          )
                                        ],
                                      ),
                                    if (rat != null)
                                      StarRating(
                                          totalAverage: rat, forceStars: true),
                                  ],
                                ),
                              ),
                            ),
                            if (onEmailTap != null)
                              InkWell(
                                onTap: onEmailTap,
                                child: Icon(
                                  Icons.email,
                                  color: Theme.of(context).primaryColor,
                                ),
                              ),
                          ],
                        ),
                      ),
                      if (date != null)
                        Divider(
                          height: 8,
                          color: Colors.grey[400],
                        ),
                      if (date != null)
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: <Widget>[
                            Image.asset(
                              'assets/images/Icon-awesome-calendar.png',
                              width: 30,
                              height: 30,
                            ),
                            Expanded(
                              child: Texts(
                                date,
                                variant: 'bodyText',
                              ),
                            )
                          ],
                        )
                    ],
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }
}
