This commit is contained in:
dan63047 2024-08-13 02:07:59 +03:00
parent cda6dc790c
commit b3fd96e58c
2 changed files with 327 additions and 172 deletions

View File

@ -573,6 +573,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
break; break;
default: default:
errText = snapshot.error.toString(); errText = snapshot.error.toString();
subText = snapshot.stackTrace.toString();
} }
return Center(child: return Center(child:
Column( Column(

View File

@ -656,6 +656,59 @@ class _DestinationHomeState extends State<DestinationHome> {
); );
} }
Widget getRecentTLrecords(String searchFor, BoxConstraints constraints){
return Column(
children: [
Card(
child: Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(t.recent, style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 42)),
],
),
),
),
),
Card(
child: FutureBuilder<TetraLeagueBetaStream>(
future: teto.fetchTLStream(searchFor),
builder: (context, snapshot) {
switch (snapshot.connectionState){
case ConnectionState.none:
case ConnectionState.waiting:
case ConnectionState.active:
return const Center(child: CircularProgressIndicator());
case ConnectionState.done:
if (snapshot.hasData){
return SizedBox(height: constraints.maxHeight, child: _TLRecords(userID: searchFor, changePlayer: (){}, data: snapshot.data!.records, wasActiveInTL: snapshot.data!.records.isNotEmpty, oldMathcesHere: false));
}
if (snapshot.hasError){
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(t.errors.noSuchUser, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 42, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(t.errors.noSuchUserSub, textAlign: TextAlign.center),
),
],
)
);
}
}
return Text("what?");
},
),
),
],
);
}
Widget getZenithCard(RecordSingle? record){ Widget getZenithCard(RecordSingle? record){
return Column( return Column(
children: [ children: [
@ -691,51 +744,119 @@ class _DestinationHomeState extends State<DestinationHome> {
); );
} }
Widget getRecordCard(RecordSingle? record){ Widget getRecordCard(RecordSingle? record, bool? betterThanRankAverage, MapEntry? closestAverage, bool? betterThanClosestAverage, String? rank){
return Column( return Column(
children: [ children: [
Row( Card(
mainAxisSize: MainAxisSize.min, child: Padding(
children: [ padding: const EdgeInsets.only(bottom: 4.0),
// if (record!.gamemode == "40l") Padding(padding: const EdgeInsets.only(right: 8.0), child: Center(
// child: Image.asset("res/tetrio_tl_alpha_ranks/${closestAverageSprint.key}.png", height: 96) child: Column(
// ), mainAxisSize: MainAxisSize.min,
// if (record!.gamemode == "blitz") Padding(padding: const EdgeInsets.only(right: 8.0), crossAxisAlignment: CrossAxisAlignment.center,
// child: Image.asset("res/tetrio_tl_alpha_ranks/${closestAverageBlitz.key}.png", height: 96) children: [
// ), Text(switch(record!.gamemode){
Column( "40l" => t.sprint,
crossAxisAlignment: CrossAxisAlignment.start, "blitz" => t.blitz,
"5mblast" => "5,000,000 Blast",
_ => record.gamemode
}, style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 42))
],
),
),
),
),
Card(
child: Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 0.0),
child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
RichText(text: TextSpan( if (closestAverage != null) Padding(padding: const EdgeInsets.only(right: 8.0),
text: record!.gamemode == "40l" ? get40lTime(record.stats.finalTime.inMicroseconds) : NumberFormat.decimalPattern().format(record.stats.score), child: Image.asset("res/tetrio_tl_alpha_ranks/${closestAverage.key}.png", height: 96)
style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36, fontWeight: FontWeight.w500, color: Colors.white), ),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
RichText(text: TextSpan(
text: switch(record.gamemode){
"40l" => get40lTime(record.stats.finalTime.inMicroseconds),
"blitz" => NumberFormat.decimalPattern().format(record.stats.score),
"5mblast" => get40lTime(record.stats.finalTime.inMicroseconds),
_ => record.stats.score.toString()
},
style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36, fontWeight: FontWeight.w500, color: Colors.white),
),
),
RichText(text: TextSpan(
text: "",
style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey),
children: [
if (rank != null && rank != "z") TextSpan(text: "${t.verdictGeneral(n: switch(record.gamemode){
"40l" => readableTimeDifference(record.stats.finalTime, sprintAverages[rank]!),
"blitz" => readableIntDifference(record.stats.score, blitzAverages[rank]!),
_ => record.stats.score.toString()
}, verdict: betterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank.toUpperCase())}\n", style: TextStyle(
color: betterThanClosestAverage??false ? Colors.greenAccent : Colors.redAccent
))
else if ((rank == null || rank == "z") && closestAverage != null) TextSpan(text: "${t.verdictGeneral(n: switch(record.gamemode){
"40l" => readableTimeDifference(record.stats.finalTime, closestAverage.value),
"blitz" => readableIntDifference(record.stats.score, closestAverage.value),
_ => record.stats.score.toString()
}, verdict: sprintBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageSprint.key.toUpperCase())}\n", style: TextStyle(
color: betterThanClosestAverage??false ? Colors.greenAccent : Colors.redAccent
)),
if (record.rank != -1) TextSpan(text: "${intf.format(record.rank)}", style: TextStyle(color: getColorOfRank(record.rank))),
if (record.rank != -1) const TextSpan(text: ""),
if (record.countryRank != -1) TextSpan(text: "${intf.format(record.countryRank)} local", style: TextStyle(color: getColorOfRank(record.countryRank))),
if (record.countryRank != -1) const TextSpan(text: ""),
TextSpan(text: timestamp(record.timestamp)),
]
),
), ),
), ],),
RichText(text: TextSpan( Spacer(),
text: "", Table(
style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), defaultColumnWidth:const IntrinsicColumnWidth(),
children: [ children: [
// if (record!.gamemode == "40l" && (rank != null && rank != "z")) TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(record!.stats.finalTime, sprintAverages[rank]!), verdict: sprintBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( TableRow(children: [
// color: sprintBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent Text(switch(record.gamemode){
// )) "40l" => record.stats.piecesPlaced.toString(),
// else if (record!.gamemode == "40l" && (rank == null || rank == "z")) TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(record!.stats.finalTime, closestAverageSprint.value), verdict: sprintBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageSprint.key.toUpperCase())}\n", style: TextStyle( "blitz" => record.stats.level.toString(),
// color: sprintBetterThanClosestAverage ? Colors.greenAccent : Colors.redAccent "5mblast" => NumberFormat.decimalPattern().format(record.stats.spp),
// )) _ => "What if "
// else if (record!.gamemode == "blitz" && (rank != null && rank != "z")) TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(record!.stats.score, blitzAverages[rank]!), verdict: blitzBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( }, textAlign: TextAlign.right, style: TextStyle(fontSize: 21)),
// color: blitzBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent Text(switch(record.gamemode){
// )) "40l" => " Pieces",
// else if (record!.gamemode == "blitz" && (rank == null || rank == "z")) TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(record!.stats.score, closestAverageBlitz.value), verdict: blitzBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageBlitz.key.toUpperCase())}\n", style: TextStyle( "blitz" => " Level",
// color: blitzBetterThanClosestAverage ? Colors.greenAccent : Colors.redAccent "5mblast" => " SPP",
// )), _ => " i wanted to"
if (record.rank != -1) TextSpan(text: "${record.rank}", style: TextStyle(color: getColorOfRank(record.rank))), }, textAlign: TextAlign.left, style: const TextStyle(fontSize: 21)),
if (record.rank != -1) const TextSpan(text: ""), ]),
TextSpan(text: timestamp(record.timestamp)), TableRow(children: [
] Text(f2.format(record.stats.pps), textAlign: TextAlign.right, style: TextStyle(fontSize: 21)),
), Text(" PPS", textAlign: TextAlign.left, style: const TextStyle(fontSize: 21)),
) ]),
],), TableRow(children: [
], Text(switch(record.gamemode){
"40l" => f2.format(record.stats.kpp),
"blitz" => f2.format(record.stats.spp),
"5mblast" => record.stats.piecesPlaced.toString(),
_ => "but god said"
}, textAlign: TextAlign.right, style: TextStyle(fontSize: 21)),
Text(switch(record.gamemode){
"40l" => " KPP",
"blitz" => " SPP",
"5mblast" => " Pieces",
_ => " no"
}, textAlign: TextAlign.left, style: const TextStyle(fontSize: 21)),
])
],
),
],
),
),
), ),
] ]
); );
@ -946,12 +1067,26 @@ class _DestinationHomeState extends State<DestinationHome> {
return const Center(child: CircularProgressIndicator()); return const Center(child: CircularProgressIndicator());
case ConnectionState.done: case ConnectionState.done:
if (snapshot.hasData){ if (snapshot.hasData){
blitzBetterThanRankAverage = (snapshot.data!.league.rank != "z" && snapshot.data!.blitz != null) ? snapshot.data!.blitz!.stats.score > blitzAverages[snapshot.data!.league.rank]! : null;
sprintBetterThanRankAverage = (snapshot.data!.league.rank != "z" && snapshot.data!.sprint != null) ? snapshot.data!.sprint!.stats.finalTime < sprintAverages[snapshot.data!.league.rank]! : null;
if (snapshot.data!.sprint != null) {
closestAverageSprint = sprintAverages.entries.singleWhere((element) => element.value == sprintAverages.values.reduce((a, b) => (a-snapshot.data!.sprint!.stats.finalTime).abs() < (b -snapshot.data!.sprint!.stats.finalTime).abs() ? a : b));
sprintBetterThanClosestAverage = snapshot.data!.sprint!.stats.finalTime < closestAverageSprint.value;
}
if (snapshot.data!.blitz != null){
closestAverageBlitz = blitzAverages.entries.singleWhere((element) => element.value == blitzAverages.values.reduce((a, b) => (a-snapshot.data!.blitz!.stats.score).abs() < (b -snapshot.data!.blitz!.stats.score).abs() ? a : b));
blitzBetterThanClosestAverage = snapshot.data!.blitz!.stats.score > closestAverageBlitz.value;
}
return switch (rightCard){ return switch (rightCard){
Cards.overview => getOverviewCard(snapshot.data!), Cards.overview => getOverviewCard(snapshot.data!),
Cards.tetraLeague => getTetraLeagueCard(snapshot.data!.league), Cards.tetraLeague => switch (cardMod){
CardMod.info => getTetraLeagueCard(snapshot.data!.league),
CardMod.recent => getRecentTLrecords(widget.searchFor, widget.constraints),
_ => Center(child: Text("huh?"))
},
Cards.quickPlay => getZenithCard(cardMod == CardMod.ex ? snapshot.data?.zenithEx : snapshot.data?.zenith), Cards.quickPlay => getZenithCard(cardMod == CardMod.ex ? snapshot.data?.zenithEx : snapshot.data?.zenith),
Cards.sprint => getRecordCard(snapshot.data?.sprint), Cards.sprint => getRecordCard(snapshot.data?.sprint, sprintBetterThanRankAverage, closestAverageSprint, sprintBetterThanClosestAverage, snapshot.data!.league.rank),
Cards.blitz => getRecordCard(snapshot.data?.blitz), Cards.blitz => getRecordCard(snapshot.data?.blitz, blitzBetterThanRankAverage, closestAverageBlitz, blitzBetterThanClosestAverage, snapshot.data!.league.rank),
}; };
} }
if (snapshot.hasError){ if (snapshot.hasError){
@ -1339,19 +1474,30 @@ class FakeDistinguishmentThingy extends StatelessWidget{
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
surfaceTintColor: getCardTint(), surfaceTintColor: getCardTint(),
child: Column( child: Container(
children: [ decoration: banned ? BoxDecoration(
Center( gradient: LinearGradient(
child: RichText( colors: [Colors.transparent, const Color.fromARGB(171, 244, 67, 54), Color.fromARGB(171, 244, 67, 54)],
textAlign: TextAlign.center, stops: [0.1, 0.9, 0.01],
text: TextSpan( tileMode: TileMode.mirror,
style: DefaultTextStyle.of(context).style, begin: Alignment.topLeft,
children: [getDistinguishmentTitle()], end: AlignmentDirectional(-0.95, -0.95)
)
) : null,
child: Column(
children: [
Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: DefaultTextStyle.of(context).style,
children: [getDistinguishmentTitle()],
),
), ),
), ),
), Text(getDistinguishmentSubtitle(), style: const TextStyle(fontSize: 18), textAlign: TextAlign.center),
Text(getDistinguishmentSubtitle(), style: const TextStyle(fontSize: 18), textAlign: TextAlign.center), ],
], ),
), ),
); );
} }
@ -1798,33 +1944,34 @@ class TetraLeagueThingy extends StatelessWidget{
SizedBox( SizedBox(
height: 128.0, height: 128.0,
width: 128.0, width: 128.0,
child: SfRadialGauge( child: ClipRRect(
axes: [ borderRadius: BorderRadius.circular(1000),
RadialAxis( child: SfRadialGauge(
// startAngle: 180, backgroundColor: Colors.black,
// endAngle: 0, axes: [
minimum: 0.4, RadialAxis(
maximum: 0.6, minimum: 0.4,
//radiusFactor: 1.5, maximum: 0.6,
showTicks: true, radiusFactor: 1.01,
showLabels: false, showTicks: true,
interval: 0.1, showLabels: false,
//labelsPosition: ElementsPosition.outside, interval: 0.1,
ranges:[ ranges:[
GaugeRange(startValue: 0, endValue: league.winrate, color: theme.colorScheme.primary) GaugeRange(startValue: 0, endValue: league.winrate, color: theme.colorScheme.primary)
], ],
annotations: [ annotations: [
GaugeAnnotation(widget: Container(child: GaugeAnnotation(widget: Container(child:
Text(percentage.format(league.winrate), textAlign: TextAlign.center, style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold))), Text(percentage.format(league.winrate), textAlign: TextAlign.center, style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold))),
angle: 90,positionFactor: 0.1 angle: 90,positionFactor: 0.1
), ),
GaugeAnnotation(widget: Container(child: GaugeAnnotation(widget: Container(child:
Text(t.statCellNum.winrate, textAlign: TextAlign.center)), Text(t.statCellNum.winrate, textAlign: TextAlign.center)),
angle: 270,positionFactor: 0.4 angle: 270,positionFactor: 0.4
) )
], ],
) )
] ]
),
), ),
), ),
Expanded( Expanded(
@ -1875,71 +2022,76 @@ class NerdStatsThingy extends StatelessWidget{
SizedBox( SizedBox(
height: 256.0, height: 256.0,
width: 256.0, width: 256.0,
child: SfRadialGauge( child: ClipRRect(
axes: [ borderRadius: BorderRadius.circular(1000),
RadialAxis( child: SfRadialGauge(
startAngle: 120, backgroundColor: Colors.black,
endAngle: 240, axes: [
minimum: 0.0, RadialAxis(
maximum: 1.0, startAngle: 200,
//radiusFactor: 1.5, endAngle: 340,
showTicks: true, minimum: 0.0,
showLabels: false, maximum: 1.0,
interval: 0.1, radiusFactor: 1.01,
//labelsPosition: ElementsPosition.outside, showTicks: true,
ranges:[ showLabels: false,
GaugeRange(startValue: 0, endValue: nerdStats.app, color: theme.colorScheme.primary) interval: 0.1,
], //labelsPosition: ElementsPosition.outside,
annotations: [ ranges:[
GaugeAnnotation(widget: Container(child: GaugeRange(startValue: 0, endValue: nerdStats.app, color: theme.colorScheme.primary)
RichText( ],
textAlign: TextAlign.center, annotations: [
text: TextSpan( GaugeAnnotation(widget: Container(child:
style: const TextStyle(fontFamily: "Eurostile Round"), RichText(
children: [ textAlign: TextAlign.center,
const TextSpan(text: "APP\n"), text: TextSpan(
TextSpan(text: f3.format(nerdStats.app), style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold)), style: const TextStyle(fontFamily: "Eurostile Round"),
//TextSpan(text: "\nAPP"), children: [
] const TextSpan(text: "APP\n"),
))), TextSpan(text: f3.format(nerdStats.app), style: const TextStyle(fontSize: 25, fontFamily: "Eurostile Round Extended", fontWeight: FontWeight.w100)),
angle: 180,positionFactor: 0.5 //TextSpan(text: "\nAPP"),
), ]
], ))),
), angle: 270,positionFactor: 0.5
RadialAxis( ),
startAngle: 300, ],
endAngle: 60, ),
isInversed: true, RadialAxis(
minimum: 1.8, startAngle: 20,
maximum: 2.4, endAngle: 160,
//radiusFactor: 1.5, isInversed: true,
showTicks: true, minimum: 1.8,
showLabels: false, maximum: 2.4,
interval: 0.1, radiusFactor: 1.01,
//labelsPosition: ElementsPosition.outside, showTicks: true,
ranges:[ showLabels: false,
GaugeRange(startValue: 0, endValue: nerdStats.vsapm, color: theme.colorScheme.primary) interval: 0.1,
], //labelsPosition: ElementsPosition.outside,
annotations: [ ranges:[
GaugeAnnotation(widget: Container(child: GaugeRange(startValue: 0, endValue: nerdStats.vsapm, color: theme.colorScheme.primary)
RichText( ],
textAlign: TextAlign.center, annotations: [
text: TextSpan( GaugeAnnotation(widget: Container(child:
style: const TextStyle(fontFamily: "Eurostile Round"), RichText(
children: [ textAlign: TextAlign.center,
const TextSpan(text: "VS/APM\n"), text: TextSpan(
TextSpan(text: f3.format(nerdStats.vsapm), style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold)), style: const TextStyle(fontFamily: "Eurostile Round"),
] children: [
))), const TextSpan(text: "VS/APM\n"),
angle: 0,positionFactor: 0.5 TextSpan(text: f3.format(nerdStats.vsapm), style: const TextStyle(fontSize: 25, fontFamily: "Eurostile Round Extended", fontWeight: FontWeight.w100)),
) ]
], ))),
) angle: 90,positionFactor: 0.5
] )
],
)
]
),
), ),
), ),
Expanded( Expanded(
child: Wrap( child: Wrap(
spacing: 10,
children: [ children: [
GaugetThingy(value: nerdStats.dss, min: 0, max: 1.0, tickInterval: .2, label: "DS/S", sideSize: 128.0, fractionDigits: 3), GaugetThingy(value: nerdStats.dss, min: 0, max: 1.0, tickInterval: .2, label: "DS/S", sideSize: 128.0, fractionDigits: 3),
GaugetThingy(value: nerdStats.dsp, min: 0, max: 1.0, tickInterval: .2, label: "DS/P", sideSize: 128.0, fractionDigits: 3), GaugetThingy(value: nerdStats.dsp, min: 0, max: 1.0, tickInterval: .2, label: "DS/P", sideSize: 128.0, fractionDigits: 3),
@ -2007,36 +2159,38 @@ class GaugetThingy extends StatelessWidget{
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
NumberFormat f = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: fractionDigits); NumberFormat f = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: fractionDigits);
return SizedBox( return ClipRRect(
height: sideSize, borderRadius: BorderRadius.circular(1000),
width: sideSize, child: SizedBox(
child: SfRadialGauge( height: sideSize,
axes: [ width: sideSize,
RadialAxis( child: SfRadialGauge(
// startAngle: 180, backgroundColor: Colors.black,
// endAngle: 0, axes: [
minimum: min, RadialAxis(
maximum: max, radiusFactor: 1.01,
//radiusFactor: 1.5, minimum: min,
showTicks: true, maximum: max,
showLabels: false, showTicks: true,
interval: tickInterval, showLabels: false,
//labelsPosition: ElementsPosition.outside, interval: tickInterval,
ranges:[ //labelsPosition: ElementsPosition.outside,
GaugeRange(startValue: 0, endValue: value, color: theme.colorScheme.primary) ranges:[
], GaugeRange(startValue: 0, endValue: value, color: theme.colorScheme.primary)
annotations: [ ],
GaugeAnnotation(widget: Container(child: annotations: [
Text(f.format(value), textAlign: TextAlign.center, style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold))), GaugeAnnotation(widget: Container(child:
angle: 90,positionFactor: 0.25 Text(f.format(value), textAlign: TextAlign.center, style: const TextStyle(fontSize: 25,fontWeight: FontWeight.bold))),
), angle: 90,positionFactor: 0.10
GaugeAnnotation(widget: Container(child: ),
Text(label, textAlign: TextAlign.center, style: const TextStyle(height: .9))), GaugeAnnotation(widget: Container(child:
angle: 270,positionFactor: 0.4 Text(label, textAlign: TextAlign.center, style: const TextStyle(height: .9))),
) angle: 270,positionFactor: 0.4
], )
) ],
] )
]
),
), ),
); );
} }