import 'package:auto_size_text/auto_size_text.dart';
import 'package:hmg_patient_app/models/vital_sign.dart';
import 'package:hmg_patient_app/theme/colors.dart';
import 'package:hmg_patient_app/uitl/utils_new.dart';
import 'package:hmg_patient_app/widgets/card/rounded_container.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class VitalSignItem extends StatelessWidget {
  const VitalSignItem({
    Key? key,
    required this.vitalSign,
    this.height,
    this.width,
  }) : super(key: key);

  final double? height;
  final double? width;
  final VitalSign vitalSign;

  @override
  Widget build(BuildContext context) {
    return RoundedContainer(
      margin: 0,
      height: double.infinity,
      width: double.infinity,
      child: Container(
        padding: EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      AutoSizeText(
                        vitalSign.lastVal ?? 'N/A',
                        minFontSize: 10,
                        maxLines: 1,
                        style: TextStyle(
                          fontSize: 15,
                          color: Color(0xff2B353E),
                          letterSpacing: -0.45,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      Text(
                        vitalSign.unit ?? "",
                        style: TextStyle(
                          fontSize: 9,
                          letterSpacing: -0.27,
                          color: CustomColors.accentColor,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ],
                  ),
                ),
                mWidth(4),
                Container(
                  width: MediaQuery.of(context).size.width / 16,
                  height: MediaQuery.of(context).size.width / 16,
                  child: SvgPicture.asset(
                    vitalSign.icon,
                    color: Color(0xff2E303A),
                  ),
                ),
              ],
            ),
            mFlex(1),
            AutoSizeText(
              vitalSign.des,
              minFontSize: 8,
              maxLines: 2,
              style: TextStyle(
                fontSize: 12,
                letterSpacing: -0.33,
                height: 1,
                fontWeight: FontWeight.w600,
              ),
            )
          ],
        ),
      ),
    );
  }
}
