import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart'; import 'package:doctor_app_flutter/util/helpers.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) { double barHeight = SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 20 : SizeConfig.isHeightLarge?20:17); value.summaryoptions.sort((Summaryoptions a, Summaryoptions b) => b.value - a.value); value.summaryoptions .sort((Summaryoptions a, Summaryoptions b) => b.value - a.value); var list = new List(); value.summaryoptions.forEach((result) => {list.add(getStack(result, value.summaryoptions.first.value,context,barHeight))}); return Container( margin: EdgeInsets.only(bottom: 20, top: 10, left: 5, right: 5), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20) ), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 0, blurRadius: 9, offset: Offset(0, 0), // changes position of shadow ), ], ), child: Padding( padding: const EdgeInsets.all(5.0), child:Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5), child: Label( firstLine: Helpers.getLabelFromKPI(value.kPIName), secondLine: Helpers.getNameFromKPI(value.kPIName), color: Color(0xFF2B353E), firstLineFontSize: SizeConfig.getHeightMultiplier(height: barHeight) * (SizeConfig.isHeightVeryShort ? 10 : SizeConfig.isHeightShort ? 10 : 8.5), secondLineFontSize: SizeConfig.getHeightMultiplier(height: barHeight) * (SizeConfig.isHeightVeryShort ? 15 : SizeConfig.isHeightShort ? 15 : 14.5), ), ), Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: list) ], ) ), ); } getStack(Summaryoptions value, max, context, barHeight) { 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(0x8FF5F6FA), Colors.red[50]], // red to yellow tileMode: TileMode.mirror, // repeats the gradient over the canvas ), borderRadius: BorderRadius.circular(4), // 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 ? ((barHeight) * value.value) / max : 0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), color: Color(0x63D02127), ), ), ), Container( height: barHeight, 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: SizeConfig.getTextMultiplierBasedOnWidth() * 2.5, textAlign: TextAlign.center, color: Color(0xFF2B353E), fontWeight: FontWeight.w700, letterSpacing: -0.3, ), AppText( ' (' + value.value.toString() + ') ', fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 2.5, textAlign: TextAlign.center, color: Color(0xFF2B353E), letterSpacing: -0.3, fontWeight: FontWeight.bold, ), ], ), )), ), )) ]), ), ); } } // ignore: must_be_immutable class Label extends StatelessWidget { Label({ Key key, this.firstLine, this.secondLine, this.color= const Color(0xFF2E303A), this.secondLineFontSize, this.firstLineFontSize, }) : super(key: key); final String firstLine; final String secondLine; Color color; final double secondLineFontSize; final double firstLineFontSize; @override Widget build(BuildContext context) { return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( firstLine, fontSize: firstLineFontSize??SizeConfig.getTextMultiplierBasedOnWidth() *(SizeConfig.isWidthLarge?2:3) , // fontWeight: FontWeight.bold, color: color, fontHeight: .5, letterSpacing: -0.72, fontWeight: FontWeight.w600, ), AppText( secondLine, color: color, fontSize: secondLineFontSize??SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge?4:6.40), fontWeight: FontWeight.bold, letterSpacing: -1.44, ), ], ); } }