import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';

class GetOutPatientStack extends StatelessWidget {
  final value;
  GetOutPatientStack(this.value);
  @override
  Widget build(BuildContext context) {
    value.summaryoptions
        .sort((Summaryoptions a, Summaryoptions b) => b.value - a.value);

    var list = new List<Widget>();
    value.summaryoptions.forEach((result) =>
        {list.add(getStack(result, value.summaryoptions.first.value))});
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        AppText(
          value.kPIName,
          medium: true,
        ),
        Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list)
      ],
    );
  }

  getStack(Summaryoptions value, max) {
    return Stack(children: [
      Container(
        height: 150,
        margin: EdgeInsets.all(5),
        width: 40,
        child: SizedBox(),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10), color: Colors.red[50]),
      ),
      Positioned(
          bottom: 0,
          child: Container(
              child: SizedBox(),
              margin: EdgeInsets.all(5),
              padding: EdgeInsets.all(10),
              height: max != 0 ? (150 * value.value) / max : 0,
              width: 40,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(10),
                  color: Colors.red[300]))),
      Container(
          height: 150,
          margin: EdgeInsets.only(left: 5, top: 5),
          padding: EdgeInsets.all(10),
          child: RotatedBox(
            quarterTurns: 1,
            child: Center(
              child: Align(
                  child: AppText(
                value.kPIParameter + ' (' + value.value.toString() + ') ',
                fontSize: 10,
                textAlign: TextAlign.center,
                fontWeight: FontWeight.bold,
              )),
            ),
          ))
    ]);
  }
}
