import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

class VitalSignItem extends StatelessWidget {
  const VitalSignItem(
      {Key key,
      @required this.des,
      this.lastVal = 'N/A',
      this.unit = '',
      this.height,
      this.width,
      @required this.icon})
      : super(key: key);

  final String des;
  final String lastVal;
  final String unit;
  final IconData icon;
  final double height;
  final double width;

  @override
  Widget build(BuildContext context) {
    return RoundedContainer(
      margin: 0.025 * SizeConfig.realScreenWidth,
      height: 0.15 * SizeConfig.realScreenHeight,
      width: 0.45 * SizeConfig.realScreenWidth,
      child: Container(
        padding: EdgeInsets.all(5),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              height: 0.10 * SizeConfig.realScreenHeight,
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 2,
                    child: Align(
                      alignment: Alignment.topLeft,
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: Text(
                          des,
                          style: TextStyle(
                              fontSize: 1.7 * SizeConfig.textMultiplier,
                              color: Hexcolor('#B8382C'),
                              fontWeight: FontWeight.bold,),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    flex: 1,
                    child: Container(child: Icon(icon,size: 40,),),
                  )
                ],
              ),
            ),
            Expanded(
              child: Container(
                width: double.infinity,
                child: Align(
                  alignment: Alignment.topRight,
                  child: Container(
                    margin: EdgeInsets.only(left: 5,right: 5),
                    child: RichText(
                      text: TextSpan(
                          style: TextStyle(color: Colors.black),
                          children: [
                            TextSpan(text: lastVal),
                            TextSpan(
                              text: unit,
                              style: TextStyle(
                                color: Hexcolor('#B8382C'),
                              ),
                            ),
                          ]),
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
