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';

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;

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

  @override
  Widget build(BuildContext 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),
        ),
      ),
      child: InkWell(
        onTap: onTap,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Row(
              children: <Widget>[
                Container(
                  width: 20,
                  height: date == null ? 100 : 130,
                  decoration: BoxDecoration(
                      color: Colors.red[900],
                      borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(8),
                          bottomLeft: Radius.circular(8))),
                  child: RotatedBox(
                      quarterTurns: 3,
                      child: Center(
                        child: Text(
                          "Calendar",
                          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 (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',
                              ),
                            )
                          ],
                        )
                    ],
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }
}
