2023-06-21 19:17:39 +00:00
import ' package:fl_chart/fl_chart.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:intl/intl.dart ' ;
import ' package:tetra_stats/data_objects/tetrio.dart ' ;
2023-07-14 20:21:49 +00:00
import ' package:tetra_stats/gen/strings.g.dart ' ;
2023-06-21 19:17:39 +00:00
2023-07-14 20:21:49 +00:00
final DateFormat dateFormat = DateFormat . yMMMd ( LocaleSettings . currentLocale . languageCode ) . add_Hms ( ) ;
2023-09-05 20:32:34 +00:00
int roundSelector = - 1 ; // -1 = match averages, otherwise round number-1
List < DropdownMenuItem > rounds = [ ] ; // index zero will be match stats
2023-06-21 19:17:39 +00:00
class TlMatchResultView extends StatefulWidget {
final TetraLeagueAlphaRecord record ;
final String initPlayerId ;
const TlMatchResultView ( { Key ? key , required this . record , required this . initPlayerId } )
: super ( key: key ) ;
@ override
State < StatefulWidget > createState ( ) = > TlMatchResultState ( ) ;
}
class TlMatchResultState extends State < TlMatchResultView > {
late ScrollController _scrollController ;
@ override
void initState ( ) {
_scrollController = ScrollController ( ) ;
2023-09-05 20:32:34 +00:00
rounds = [ const DropdownMenuItem ( value: - 1 , child: Text ( " Match " ) ) ] ;
rounds . addAll ( [ for ( int i = 0 ; i < widget . record . endContext . first . secondaryTracking . length ; i + + ) DropdownMenuItem ( value: i , child: Text ( " Round ${ i + 1 } " ) ) ] ) ;
2023-06-21 19:17:39 +00:00
super . initState ( ) ;
}
2023-09-05 20:32:34 +00:00
@ override
void dispose ( ) {
roundSelector = - 1 ;
super . dispose ( ) ;
}
2023-06-21 19:17:39 +00:00
@ override
Widget build ( BuildContext context ) {
2023-07-14 20:21:49 +00:00
final t = Translations . of ( context ) ;
2023-06-21 19:17:39 +00:00
bool bigScreen = MediaQuery . of ( context ) . size . width > 768 ;
return Scaffold (
appBar: AppBar (
2023-09-05 20:32:34 +00:00
title: Text ( " ${ widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . username . toUpperCase ( ) } ${ t . vs } ${ widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . username . toUpperCase ( ) } in TL match ${ dateFormat . format ( widget . record . timestamp ) } " ) ,
2023-06-21 19:17:39 +00:00
) ,
backgroundColor: Colors . black ,
body: SafeArea (
child: NestedScrollView (
controller: _scrollController ,
headerSliverBuilder: ( context , value ) {
return [
SliverToBoxAdapter (
child: Padding (
padding: const EdgeInsets . fromLTRB ( 16 , 16 , 16 , 32 ) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Expanded (
child: Container (
2023-06-23 18:38:15 +00:00
decoration: BoxDecoration (
2023-06-21 19:17:39 +00:00
gradient: LinearGradient (
2023-06-23 18:38:15 +00:00
colors: const [ Colors . green , Colors . transparent ] ,
2023-06-21 19:17:39 +00:00
begin: Alignment . bottomCenter ,
end: Alignment . topCenter ,
2023-06-23 18:38:15 +00:00
stops: [ 0.0 , widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . success ? 0.4 : 0.0 ] ,
2023-06-21 19:17:39 +00:00
) ) ,
child: Padding (
padding: const EdgeInsets . fromLTRB ( 8 , 0 , 8 , 0 ) ,
child: Column ( children: [
2023-06-23 18:38:15 +00:00
Text ( widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . username , style: bigScreen ? const TextStyle (
2023-06-21 19:17:39 +00:00
fontFamily: " Eurostile Round Extended " ,
2023-06-23 18:38:15 +00:00
fontSize: 28 ) : const TextStyle ( ) ) ,
2023-06-21 19:17:39 +00:00
Text ( widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . points . toString ( ) , style: const TextStyle (
fontFamily: " Eurostile Round Extended " ,
fontSize: 42 ) )
] ) ,
) ,
) ,
) ,
const Padding (
padding: EdgeInsets . only ( top: 16 ) ,
child: Text ( " VS " ) ,
) ,
Expanded (
child: Container (
2023-06-23 18:38:15 +00:00
decoration: BoxDecoration (
2023-06-21 19:17:39 +00:00
gradient: LinearGradient (
2023-06-23 18:38:15 +00:00
colors: const [ Colors . red , Colors . transparent ] ,
2023-06-21 19:17:39 +00:00
begin: Alignment . bottomCenter ,
end: Alignment . topCenter ,
2023-06-23 18:38:15 +00:00
stops: [ 0.0 , widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . success ? 0.4 : 0.0 ] ,
2023-06-21 19:17:39 +00:00
) ) ,
child: Padding (
padding: const EdgeInsets . fromLTRB ( 8 , 0 , 8 , 0 ) ,
child: Column ( children: [
2023-06-23 18:38:15 +00:00
Text ( widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . username , style: bigScreen ? const TextStyle (
2023-06-21 19:17:39 +00:00
fontFamily: " Eurostile Round Extended " ,
2023-06-23 18:38:15 +00:00
fontSize: 28 ) : const TextStyle ( ) ) ,
2023-06-21 19:17:39 +00:00
Text ( widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . points . toString ( ) , style: const TextStyle (
fontFamily: " Eurostile Round Extended " ,
fontSize: 42 ) )
] ) ,
) ,
) ,
) ,
] ,
) ,
) ,
) ,
2023-09-05 20:32:34 +00:00
SliverToBoxAdapter (
child: Center (
child: Row (
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . baseline ,
textBaseline: TextBaseline . alphabetic ,
children: [
Text ( " Stats for: " ,
style: const TextStyle ( color: Colors . white , fontSize: 25 ) ) ,
DropdownButton ( items: rounds , value: roundSelector , onChanged: ( ( value ) {
roundSelector = value ;
setState ( ( ) { } ) ;
} ) , ) ,
] ,
) ,
) ,
) ,
2023-06-21 19:17:39 +00:00
const SliverToBoxAdapter (
child: Divider ( ) ,
)
] ;
} ,
body: ListView (
children: [
Column (
children: [
CompareThingy (
label: " APM " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . secondary : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . secondaryTracking [ roundSelector ] ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . secondary : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . secondaryTracking [ roundSelector ] ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " PPS " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . tertiary : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . tertiaryTracking [ roundSelector ] ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . tertiary : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . tertiaryTracking [ roundSelector ] ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " VS " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . extra : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . extraTracking [ roundSelector ] ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . extra : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . extraTracking [ roundSelector ] ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
] ,
) ,
const Divider ( ) ,
Column (
children: [
Padding (
padding: const EdgeInsets . only ( bottom: 16 ) ,
2023-07-14 20:21:49 +00:00
child: Text ( t . nerdStats ,
2023-06-21 19:17:39 +00:00
style: TextStyle (
fontFamily: " Eurostile Round Extended " ,
fontSize: bigScreen ? 42 : 28 ) ) ,
) ,
CompareThingy (
label: " APP " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . app : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . app ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . app : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . app ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " VS/APM " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . vsapm : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . vsapm ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . vsapm : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . vsapm ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " DS/S " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . dss : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dss ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . dss : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dss ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " DS/P " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . dsp : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dsp ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . dsp : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dsp ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " APP + DS/P " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . appdsp : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . appdsp ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . appdsp : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . appdsp ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
2023-07-14 20:21:49 +00:00
label: t . statCellNum . cheese . replaceAll ( RegExp ( r'\n' ) , " " ) ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . cheese : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . cheese ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . cheese : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . cheese ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
CompareThingy (
2023-07-14 20:21:49 +00:00
label: " Gb Eff. " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . gbe : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . gbe ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . gbe : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . gbe ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
2023-07-14 20:21:49 +00:00
label: " wAPP " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . nyaapp : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . nyaapp ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . nyaapp : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . nyaapp ,
2023-06-21 19:17:39 +00:00
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " Area " ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . area : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . area ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . area : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . area ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
CompareThingy (
2023-07-15 16:22:25 +00:00
label: t . statCellNum . estOfTRShort ,
2023-09-05 20:32:34 +00:00
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . estTr . esttr : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . estTrTracking [ roundSelector ] . esttr ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . estTr . esttr : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . estTrTracking [ roundSelector ] . esttr ,
2023-06-21 19:17:39 +00:00
fractionDigits: 2 ,
higherIsBetter: true ,
) ,
2023-09-05 20:32:34 +00:00
CompareThingy (
label: " Opener " ,
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . opener : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . opener ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . opener : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . opener ,
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " Plonk " ,
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . plonk : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . plonk ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . plonk : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . plonk ,
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " Stride " ,
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . stride : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . stride ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . stride : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . stride ,
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
CompareThingy (
label: " Inf. DS " ,
greenSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . infds : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . infds ,
redSide: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . infds : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . infds ,
fractionDigits: 3 ,
higherIsBetter: true ,
) ,
2023-06-21 19:17:39 +00:00
Wrap (
direction: Axis . horizontal ,
alignment: WrapAlignment . spaceAround ,
spacing: 25 ,
crossAxisAlignment: WrapCrossAlignment . start ,
clipBehavior: Clip . hardEdge ,
2023-09-05 20:32:34 +00:00
children: [ Padding (
padding: const EdgeInsets . fromLTRB ( 20 , 20 , 20 , 20 ) ,
2023-06-21 19:17:39 +00:00
child: SizedBox (
2023-09-05 20:32:34 +00:00
height: 310 ,
width: 310 ,
child: RadarChart (
RadarChartData (
radarShape: RadarShape . polygon ,
tickCount: 4 ,
ticksTextStyle: const TextStyle ( color: Colors . transparent , fontSize: 10 ) ,
radarBorderData: const BorderSide ( color: Colors . transparent , width: 1 ) ,
gridBorderData: const BorderSide ( color: Colors . white24 , width: 1 ) ,
tickBorderData: const BorderSide ( color: Colors . transparent , width: 1 ) ,
2023-06-21 19:17:39 +00:00
getTitle: ( index , angle ) {
switch ( index ) {
case 0 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' APM ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 1 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' PPS ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 2 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' VS ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 3 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' APP ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 4 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' DS/S ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 5 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' DS/P ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 6 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' APP+DS/P ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 7 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' VS/APM ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 8 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Cheese ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 9 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Gb Eff. ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
default :
2023-09-05 20:32:34 +00:00
return const RadarChartTitle ( text: ' ' ) ;
2023-06-21 19:17:39 +00:00
}
} ,
dataSets: [
RadarDataSet (
fillColor: const Color . fromARGB (
115 , 76 , 175 , 79 ) ,
borderColor: Colors . green ,
dataEntries: [
2023-09-05 20:32:34 +00:00
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . secondary * apmWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . secondaryTracking [ roundSelector ] * apmWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . tertiary * ppsWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . tertiaryTracking [ roundSelector ] * ppsWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . extra * vsWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . extraTracking [ roundSelector ] * vsWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . app * appWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . app * appWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . dss * dssWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dss * dssWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . dsp * dspWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dsp * dspWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . appdsp * appdspWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . appdsp * appdspWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . vsapm * vsapmWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . vsapm * vsapmWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . cheese * cheeseWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . cheese * cheeseWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStats . gbe * gbeWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . gbe ) ,
2023-06-21 19:17:39 +00:00
] ,
) ,
RadarDataSet (
fillColor: const Color . fromARGB (
115 , 244 , 67 , 54 ) ,
borderColor: Colors . red ,
dataEntries: [
2023-09-05 20:32:34 +00:00
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . secondary * apmWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . secondaryTracking [ roundSelector ] * apmWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . tertiary * ppsWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . tertiaryTracking [ roundSelector ] * ppsWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . extra * vsWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . extraTracking [ roundSelector ] * vsWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . app * appWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . app * appWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . dss * dssWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dss * dssWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . dsp * dspWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . dsp * dspWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . appdsp * appdspWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . appdsp * appdspWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . vsapm * vsapmWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . vsapm * vsapmWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . cheese * cheeseWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . cheese * cheeseWeight ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStats . gbe * gbeWeight : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . nerdStatsTracking [ roundSelector ] . gbe * gbeWeight ) ,
2023-06-21 19:17:39 +00:00
] ,
) ,
RadarDataSet (
fillColor: Colors . transparent ,
borderColor: Colors . transparent ,
dataEntries: [
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
] ,
)
] ,
) ,
swapAnimationDuration: const Duration (
milliseconds: 150 ) , // Optional
swapAnimationCurve:
Curves . linear , // Optional
) ,
) ,
) ,
Padding (
2023-09-05 20:32:34 +00:00
padding: const EdgeInsets . fromLTRB ( 20 , 20 , 20 , 20 ) ,
2023-06-21 19:17:39 +00:00
child: SizedBox (
2023-09-05 20:32:34 +00:00
height: 310 ,
width: 310 ,
child: RadarChart ( RadarChartData (
radarShape: RadarShape . polygon ,
tickCount: 4 ,
ticksTextStyle: const TextStyle ( color: Colors . white24 , fontSize: 10 ) ,
radarBorderData: const BorderSide ( color: Colors . transparent , width: 1 ) ,
gridBorderData: const BorderSide ( color: Colors . white24 , width: 1 ) ,
tickBorderData: const BorderSide ( color: Colors . transparent , width: 1 ) ,
titleTextStyle: const TextStyle ( height: 1.1 ) ,
2023-06-21 19:17:39 +00:00
getTitle: ( index , angle ) {
switch ( index ) {
case 0 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Opener ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 1 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Stride ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 2 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Inf Ds ' , angle: angle + 180 , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
case 3 :
2023-09-05 20:32:34 +00:00
return RadarChartTitle ( text: ' Plonk ' , angle: angle , positionPercentageOffset: 0.05 ) ;
2023-06-21 19:17:39 +00:00
default :
2023-09-05 20:32:34 +00:00
return const RadarChartTitle ( text: ' ' ) ;
2023-06-21 19:17:39 +00:00
}
} ,
dataSets: [
RadarDataSet (
fillColor: const Color . fromARGB (
115 , 76 , 175 , 79 ) ,
borderColor: Colors . green ,
dataEntries: [
2023-09-05 20:32:34 +00:00
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . opener : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . opener ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . stride : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . stride ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . infds : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . infds ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyle . plonk : widget . record . endContext . firstWhere ( ( element ) = > element . userId = = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . plonk ) ,
2023-06-21 19:17:39 +00:00
] ,
) ,
RadarDataSet (
fillColor: const Color . fromARGB (
115 , 244 , 67 , 54 ) ,
borderColor: Colors . red ,
dataEntries: [
2023-09-05 20:32:34 +00:00
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . opener : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . opener ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . stride : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . stride ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . infds : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . infds ) ,
RadarEntry ( value: roundSelector . isNegative ? widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyle . plonk : widget . record . endContext . firstWhere ( ( element ) = > element . userId ! = widget . initPlayerId ) . playstyleTracking [ roundSelector ] . plonk ) ,
2023-06-21 19:17:39 +00:00
] ,
) ,
RadarDataSet (
fillColor: Colors . transparent ,
borderColor: Colors . transparent ,
dataEntries: [
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
const RadarEntry ( value: 0 ) ,
] ,
) ,
RadarDataSet (
fillColor: Colors . transparent ,
borderColor: Colors . transparent ,
dataEntries: [
const RadarEntry ( value: 1 ) ,
const RadarEntry ( value: 1 ) ,
const RadarEntry ( value: 1 ) ,
const RadarEntry ( value: 1 ) ,
] ,
)
] ,
) ,
swapAnimationDuration: const Duration (
milliseconds: 150 ) , // Optional
swapAnimationCurve:
Curves . linear , // Optional
) ,
) ,
)
] ,
)
] ,
)
] ,
)
) ,
) ,
) ;
}
}
class CompareThingy extends StatelessWidget {
final num greenSide ;
final num redSide ;
final String label ;
final bool higherIsBetter ;
final int ? fractionDigits ;
const CompareThingy (
{ super . key ,
required this . greenSide ,
required this . redSide ,
required this . label ,
required this . higherIsBetter ,
this . fractionDigits } ) ;
String verdict ( num greenSide , num redSide , int fraction ) {
var f = NumberFormat ( " +#,###.##;-#,###.## " ) ;
f . maximumFractionDigits = fraction ;
return f . format ( ( greenSide - redSide ) ) ;
}
@ override
Widget build ( BuildContext context ) {
2023-07-15 16:22:25 +00:00
NumberFormat f = NumberFormat . decimalPatternDigits ( locale: LocaleSettings . currentLocale . languageCode , decimalDigits: fractionDigits ? ? 0 ) ;
2023-06-21 19:17:39 +00:00
return Padding (
padding: const EdgeInsets . fromLTRB ( 16 , 2 , 16 , 2 ) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Expanded (
child: Container (
padding: const EdgeInsets . all ( 4 ) ,
decoration: BoxDecoration (
gradient: LinearGradient (
colors: const [ Colors . green , Colors . transparent ] ,
begin: Alignment . centerLeft ,
end: Alignment . centerRight ,
stops: [
0.0 ,
higherIsBetter
? greenSide > redSide
? 0.6
: 0
: greenSide < redSide
? 0.6
: 0
] ,
) ) ,
child: Text (
f . format ( greenSide ) ,
style: const TextStyle (
fontSize: 22 ,
shadows: < Shadow > [
Shadow (
offset: Offset ( 0.0 , 0.0 ) ,
blurRadius: 3.0 ,
color: Colors . black ,
) ,
Shadow (
offset: Offset ( 0.0 , 0.0 ) ,
blurRadius: 8.0 ,
color: Colors . black ,
) ,
] ,
) ,
textAlign: TextAlign . start ,
) ,
) ) ,
Column (
children: [
Text (
label ,
style: const TextStyle ( fontSize: 22 ) ,
textAlign: TextAlign . center ,
) ,
Text (
verdict ( greenSide , redSide ,
fractionDigits ! = null ? fractionDigits ! + 2 : 0 ) ,
style: const TextStyle ( fontSize: 16 ) ,
textAlign: TextAlign . center ,
)
] ,
) ,
Expanded (
child: Container (
padding: const EdgeInsets . all ( 4 ) ,
decoration: BoxDecoration (
gradient: LinearGradient (
colors: const [ Colors . red , Colors . transparent ] ,
begin: Alignment . centerRight ,
end: Alignment . centerLeft ,
stops: [
0.0 ,
higherIsBetter
? redSide > greenSide
? 0.6
: 0
: redSide < greenSide
? 0.6
: 0
] ,
) ) ,
child: Text (
f . format ( redSide ) ,
style: const TextStyle (
fontSize: 22 ,
shadows: < Shadow > [
Shadow (
offset: Offset ( 0.0 , 0.0 ) ,
blurRadius: 3.0 ,
color: Colors . black ,
) ,
Shadow (
offset: Offset ( 0.0 , 0.0 ) ,
blurRadius: 8.0 ,
color: Colors . black ,
) ,
] ,
) ,
textAlign: TextAlign . end ,
) ,
) ) ,
] ,
) ,
) ;
}
}