import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../text.dart';

class LaboratoryResultWidget extends StatefulWidget {
  final GestureTapCallback onTap;
  final String billNo;
  final String details;

  const LaboratoryResultWidget({Key key, this.onTap, this.billNo, this.details})
      : super(key: key);

  @override
  _LaboratoryResultWidgetState createState() => _LaboratoryResultWidgetState();
}

class _LaboratoryResultWidgetState extends State<LaboratoryResultWidget> {
  bool _isShowMore = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(15),
      child: Column(
        children: <Widget>[
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Container(
                margin: EdgeInsets.all(15),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        decoration: BoxDecoration(
                            shape: BoxShape.rectangle,
                            color: Colors.white,
                            borderRadius: BorderRadius.all(
                              Radius.circular(5.0),
                            )),
                        padding: EdgeInsets.all(10.0),
                        margin: EdgeInsets.only(left: 5, right: 5),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Texts('Bill No'),
                            Texts(widget.billNo),
                          ],
                        ),
                      ),
                    ),
                    InkWell(
                      onTap: widget.onTap,
                      child: Container(
                        margin: EdgeInsets.only(left: 5, right: 5),
                        decoration: BoxDecoration(
                            shape: BoxShape.rectangle,
                            color: Colors.red[800],
                            borderRadius: BorderRadius.all(
                              Radius.circular(5.0),
                            )),
                        child: Container(
                          padding: EdgeInsets.all(10.0),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Icon(
                                Icons.email,
                                color: Colors.white,
                              ),
                              Texts(
                                'Send a copy',
                                color: Colors.white,
                              )
                            ],
                          ),
                        ),
                      ),
                    )
                  ],
                ),
              ),
              SizedBox(
                height: 10,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    _isShowMore = !_isShowMore;
                  });
                },
                child: Container(
                  padding: EdgeInsets.all(10.0),
                  margin: EdgeInsets.only(left: 5, right: 5),
                  decoration: BoxDecoration(
                      shape: BoxShape.rectangle,
                      color: Colors.white,
                      borderRadius: BorderRadius.all(
                        Radius.circular(5.0),
                      )),
                  child: Row(
                    children: <Widget>[
                      Expanded(child: Texts('Result')),
                      Container(
                        width: 25,
                        height: 25,
                        decoration: BoxDecoration(
                            shape: BoxShape.circle, color: Colors.red[900]),
                        child: Icon(
                          _isShowMore
                              ? Icons.keyboard_arrow_up
                              : Icons.keyboard_arrow_down,
                          color: Colors.white,
                          size: 22,
                        ),
                      )
                    ],
                  ),
                ),
              ),
              if (_isShowMore)
                AnimatedContainer(
                  padding: EdgeInsets.all(10.0),
                  margin: EdgeInsets.only(left: 5, right: 5),
                  decoration: BoxDecoration(
                      shape: BoxShape.rectangle,
                      color: Colors.white,
                      borderRadius: BorderRadius.only(
                        bottomLeft: Radius.circular(5.0),
                        bottomRight: Radius.circular(5.0),
                      )),
                  duration: Duration(milliseconds: 7000),
                  child: Text(widget.details?? 'No Data'),
                )
            ],
          ),
        ],
      ),
    );
  }
}
