import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.dart';
import 'package:diplomaticquarterapp/widgets/others/rounded_container_widget.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';

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;

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

  @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? 170 :100 : 150,
                  decoration: BoxDecoration(
                    color: !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(
                          !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(
                                      name,
                                      bold: true,
                                    ),
                                    Texts(
                                      subName,
                                      variant: 'caption3',
                                    ),
                                    if (billNo != null)
                                      Row(
                                        children: <Widget>[
                                          Texts(
                                            'Bill No: ',
                                            variant: 'caption3',
                                          ),
                                          Texts(
                                            billNo,
                                            variant: 'caption3',
                                          )
                                        ],
                                      ),
                                    if (rat != null)
                                      StarRating(
                                          totalAverage: rat, forceStars: true),
                                  ],
                                ),
                              ),
                            ),
                            if (onEmailTap != null)
                              InkWell(
                                onTap: onEmailTap,
                                child: Icon(
                                  Icons.email,
                                  color: Colors.red,
                                ),
                              )
                          ],
                        ),
                      ),
                      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',
                              ),
                            )
                          ],
                        )
                    ],
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }
}
