import 'package:flutter/material.dart'; import 'package:robo_advisory/models/healthSteam.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_custom_dialog/flutter_custom_dialog.dart'; class FinancialHealthStream extends StatelessWidget { FinancialHealthStream({required this.healthSteams}); final List healthSteams; double calculatePercentage(double fullWidth, int percentValue) { return (percentValue / 100) * fullWidth; } @override Widget build(BuildContext context) { YYDialog.init(context); return Container( width: double.infinity, padding: EdgeInsets.only(left: 20.0, right: 20.0, top: 7.0, bottom: 10.0), color: Color(0xFFE5E5E5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Financial Health Stream', style: GoogleFonts.inter( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 18, color: Colors.black, ), ), ), SizedBox( height: 3.0, ), Text( 'Day 01', style: GoogleFonts.inter( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 12, color: Colors.black, ), ), ), SizedBox( height: 10.0, ), new LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { return Row( children: healthSteams .asMap() .map((index, healthStream) => MapEntry( index, healthStreamBar(context, healthStream, index, constraints.maxWidth))) .values .toList() // ); }), ], ), ); } GestureDetector healthStreamBar(BuildContext context, HealthSteam healthSteam, int index, double widthOFRow) { final List healthSteamColors = [ Color(0xFF892626), Color(0xFF896126), Color(0xFF348926) ]; return GestureDetector( onTap: () { YYDialog().build(context) ..backgroundColor = healthSteamColors[index] ..width = 140 ..borderRadius = 4.0 ..text( padding: EdgeInsets.only(top: 10.0), alignment: Alignment.center, text: healthSteam.goldInGram, color: Colors.white, fontSize: 14.0, fontWeight: FontWeight.w500, ) ..text( alignment: Alignment.center, text: healthSteam.goldPriceInTurkishLira, color: Colors.white, fontSize: 14.0, fontWeight: FontWeight.w500, ) ..text( padding: EdgeInsets.only(bottom: 10.0), alignment: Alignment.center, text: "1.00g = " + healthSteam.oneGramGoldPriceInLira, color: Colors.white, fontSize: 14.0, fontWeight: FontWeight.w500, ) ..show(); }, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( width: calculatePercentage(widthOFRow, healthSteam.valueInPercentage), height: 5.0, child: DecoratedBox( decoration: BoxDecoration( color: healthSteamColors[index], ), ), ), SizedBox( height: 3.0, ), Text( healthSteam.type, style: GoogleFonts.inter( textStyle: TextStyle( fontWeight: FontWeight.normal, fontSize: 12, color: Colors.black, ), ), ) ], ), ); } }