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,context))});
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        Container(
          height: 30,
          child: AppText(
            value.kPIName,
            medium: true,
            fontSize: 14,
          ),
        ),
        Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list)
      ],
    );
  }

  getStack(Summaryoptions value, max,context) {
    return Expanded(
      child: Container(
        margin: EdgeInsets.symmetric(horizontal: 2),
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topLeft,
            end: Alignment(
                0.0, 1.0), // 10% of the width, so there are ten blinds.
            colors: <Color>[Color(0x8FF5F6FA), Colors.red[50]], // red to yellow
            tileMode: TileMode.mirror, // repeats the gradient over the canvas
          ),
          borderRadius: BorderRadius.circular(8),
          // color: Colors.red[50],
        ),
        child: Stack(children: [
          Positioned(
            bottom: 0,
            left: 0,
            right: 0,
            child: Container(
              child: SizedBox(),
              padding: EdgeInsets.all(10),
              height: max != 0 ? ((MediaQuery.of(context).size.height * 0.24 )* value.value) / max : 0,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(8),
                color: Color(0x63D02127),
              ),
            ),
          ),
          Container(
              height: (MediaQuery.of(context).size.height * 0.24 ),
              margin: EdgeInsets.only(left: 5, top: 5),
              padding: EdgeInsets.all(10),
              child: RotatedBox(
                quarterTurns: 3,
                child: Center(
                  child: Align(
                      child: FittedBox(
                    child: Row(
                      children: [
                        AppText(
                          value.kPIParameter,
                          fontSize: 10,
                          textAlign: TextAlign.center,
                          color: Color(0xFF2B353E),
                          fontWeight: FontWeight.w700,
                        ),
                        AppText(
                          ' (' + value.value.toString() + ') ',
                          fontSize: 12,
                          textAlign: TextAlign.center,
                          color: Color(0xFF2B353E),
                          fontWeight: FontWeight.bold,
                        ),
                      ],
                    ),
                  )),
                ),
              ))
        ]),
      ),
    );
  }
}
