2024-07-10 15:31:00 +00:00
|
|
|
|
2024-06-10 22:35:07 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-09-05 21:42:21 +00:00
|
|
|
import 'package:tetra_stats/data_objects/tetra_league.dart';
|
2024-06-10 22:35:07 +00:00
|
|
|
import 'package:tetra_stats/gen/strings.g.dart';
|
|
|
|
import 'package:tetra_stats/main.dart' show prefs;
|
2024-11-05 23:07:43 +00:00
|
|
|
import 'package:tetra_stats/utils/colors_functions.dart';
|
2024-06-10 22:35:07 +00:00
|
|
|
import 'package:tetra_stats/utils/numers_formats.dart';
|
|
|
|
|
2024-11-05 23:07:43 +00:00
|
|
|
import 'text_timestamp.dart';
|
2024-06-10 22:35:07 +00:00
|
|
|
|
|
|
|
class TLRatingThingy extends StatelessWidget{
|
|
|
|
final String userID;
|
2024-08-16 22:40:09 +00:00
|
|
|
final TetraLeague tlData;
|
|
|
|
final TetraLeague? oldTl;
|
2024-06-10 22:35:07 +00:00
|
|
|
final double? topTR;
|
2024-11-05 23:07:43 +00:00
|
|
|
final bool? showPositions;
|
2024-07-10 15:31:00 +00:00
|
|
|
final DateTime? lastMatchPlayed;
|
2024-06-10 22:35:07 +00:00
|
|
|
|
2024-11-05 23:07:43 +00:00
|
|
|
const TLRatingThingy({super.key, required this.userID, required this.tlData, this.oldTl, this.topTR, this.lastMatchPlayed, this.showPositions});
|
2024-06-10 22:35:07 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
bool oskKagariGimmick = prefs.getBool("oskKagariGimmick")??true;
|
|
|
|
bool bigScreen = MediaQuery.of(context).size.width >= 768;
|
2024-06-16 13:25:16 +00:00
|
|
|
String decimalSeparator = f4.symbols.DECIMAL_SEP;
|
2024-08-16 22:40:09 +00:00
|
|
|
List<String> formatedTR = f4.format(tlData.tr).split(decimalSeparator);
|
2024-08-15 21:55:45 +00:00
|
|
|
List<String> formatedGlicko = tlData.glicko != null ? f4.format(tlData.glicko).split(decimalSeparator) : ["---","--"];
|
2024-06-16 13:25:16 +00:00
|
|
|
List<String> formatedPercentile = f4.format(tlData.percentile * 100).split(decimalSeparator);
|
2024-08-03 17:52:20 +00:00
|
|
|
//DateTime now = DateTime.now();
|
2024-07-27 19:10:45 +00:00
|
|
|
//bool beforeS1end = now.isBefore(seasonEnd);
|
|
|
|
//int daysLeft = seasonEnd.difference(now).inDays;
|
|
|
|
//int safeRD = min(100, (100 + ((tlData.rd! >= 100 && tlData.decaying) ? 7 : max(0, 7 - (lastMatchPlayed != null ? now.difference(lastMatchPlayed!).inDays : 7))) - daysLeft).toInt());
|
2024-06-10 22:35:07 +00:00
|
|
|
return Wrap(
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
alignment: WrapAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
children: [
|
|
|
|
(userID == "5e32fc85ab319c2ab1beb07c" && oskKagariGimmick) // he love her so much, you can't even imagine
|
|
|
|
? Image.asset("res/icons/kagari.png", height: 128) // Btw why she wearing Kazamatsuri high school uniform?
|
|
|
|
: Image.asset("res/tetrio_tl_alpha_ranks/${tlData.rank}.png", height: 128),
|
|
|
|
Column(
|
2024-11-19 23:21:03 +00:00
|
|
|
crossAxisAlignment: bigScreen ? CrossAxisAlignment.start : CrossAxisAlignment.center,
|
2024-06-10 22:35:07 +00:00
|
|
|
children: [
|
2024-06-16 13:25:16 +00:00
|
|
|
RichText(
|
2024-11-19 23:21:03 +00:00
|
|
|
textAlign: bigScreen ? TextAlign.start : TextAlign.center,
|
2024-06-16 13:25:16 +00:00
|
|
|
text: TextSpan(
|
2024-11-05 23:07:43 +00:00
|
|
|
style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 20, color: Colors.white, height: 0.9),
|
2024-08-15 21:55:45 +00:00
|
|
|
children: (tlData.gamesPlayed > 9) ? switch(prefs.getInt("ratingMode")){
|
2024-06-16 13:25:16 +00:00
|
|
|
1 => [
|
|
|
|
TextSpan(text: formatedGlicko[0], style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
|
|
|
|
if (formatedGlicko.elementAtOrNull(1) != null) TextSpan(text: decimalSeparator + formatedGlicko[1]),
|
|
|
|
TextSpan(text: " Glicko", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28))
|
|
|
|
],
|
|
|
|
2 => [
|
2024-06-16 17:13:26 +00:00
|
|
|
TextSpan(text: "${t.top} ${formatedPercentile[0]}", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
|
2024-06-16 13:25:16 +00:00
|
|
|
if (formatedPercentile.elementAtOrNull(1) != null) TextSpan(text: decimalSeparator + formatedPercentile[1]),
|
|
|
|
TextSpan(text: " %", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28))
|
|
|
|
],
|
|
|
|
_ => [
|
|
|
|
TextSpan(text: formatedTR[0], style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
|
|
|
|
if (formatedTR.elementAtOrNull(1) != null) TextSpan(text: decimalSeparator + formatedTR[1]),
|
|
|
|
TextSpan(text: " TR", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28))
|
|
|
|
],
|
2024-09-01 21:44:19 +00:00
|
|
|
} : [TextSpan(text: "---\n", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28, color: Colors.grey)), TextSpan(text: t.gamesUntilRanked(left: 10-tlData.gamesPlayed), style: const TextStyle(color: Colors.grey, fontSize: 14)),]
|
2024-06-16 13:25:16 +00:00
|
|
|
)
|
2024-06-10 22:35:07 +00:00
|
|
|
),
|
2024-11-05 23:07:43 +00:00
|
|
|
if (oldTl != null) RichText(
|
2024-06-10 22:35:07 +00:00
|
|
|
textAlign: TextAlign.center,
|
2024-11-05 23:07:43 +00:00
|
|
|
softWrap: true,
|
|
|
|
text: TextSpan(
|
|
|
|
style: DefaultTextStyle.of(context).style,
|
|
|
|
children: [
|
|
|
|
TextSpan(text: switch(prefs.getInt("ratingMode")){
|
|
|
|
1 => "${fDiff.format(tlData.glicko! - oldTl!.glicko!)} Glicko",
|
|
|
|
2 => "${fDiff.format(tlData.percentile * 100 - oldTl!.percentile * 100)} %",
|
|
|
|
_ => "${fDiff.format(tlData.tr - oldTl!.tr)} TR"
|
|
|
|
},
|
|
|
|
style: TextStyle(
|
|
|
|
color: getDifferenceColor(switch(prefs.getInt("ratingMode")){
|
|
|
|
1 => tlData.glicko! - oldTl!.glicko!,
|
|
|
|
2 => tlData.percentile - oldTl!.percentile,
|
|
|
|
_ => tlData.tr - oldTl!.tr
|
|
|
|
})
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const TextSpan(text: " • ", style: TextStyle(color: Colors.grey)),
|
|
|
|
TextSpan(text: switch(prefs.getInt("ratingMode")){
|
|
|
|
1 => "${fDiff.format(tlData.tr - oldTl!.tr)} TR",
|
|
|
|
_ => "${fDiff.format(tlData.glicko! - oldTl!.glicko!)} Glicko"
|
|
|
|
},
|
|
|
|
style: TextStyle(
|
|
|
|
color: getDifferenceColor(switch(prefs.getInt("ratingMode")){
|
|
|
|
1 => tlData.tr - oldTl!.tr,
|
|
|
|
_ => tlData.glicko! - oldTl!.glicko!
|
|
|
|
})
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const TextSpan(text: " • ", style: TextStyle(color: Colors.grey)),
|
|
|
|
TextSpan(
|
|
|
|
text: "${fDiff.format(tlData.rd! - oldTl!.rd!)} RD",
|
|
|
|
style: TextStyle(color: getDifferenceColor(oldTl!.rd! - tlData.rd!))
|
|
|
|
)
|
|
|
|
],
|
2024-06-10 22:35:07 +00:00
|
|
|
),
|
|
|
|
),
|
2024-08-15 21:55:45 +00:00
|
|
|
if (tlData.gamesPlayed > 9) Column(
|
2024-06-10 22:35:07 +00:00
|
|
|
children: [
|
|
|
|
RichText(
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
softWrap: true,
|
|
|
|
text: TextSpan(
|
|
|
|
style: DefaultTextStyle.of(context).style,
|
|
|
|
children: [
|
2024-08-16 22:40:09 +00:00
|
|
|
TextSpan(text: prefs.getInt("ratingMode") == 2 ? "${f2.format(tlData.tr)} TR • % ${t.rank}: ${tlData.percentileRank.toUpperCase()}" : "${t.top} ${f2.format(tlData.percentile * 100)}% (${tlData.percentileRank.toUpperCase()})"),
|
2024-06-10 22:35:07 +00:00
|
|
|
if (tlData.bestRank != "z") const TextSpan(text: " • "),
|
|
|
|
if (tlData.bestRank != "z") TextSpan(text: "${t.topRank}: ${tlData.bestRank.toUpperCase()}"),
|
|
|
|
if (topTR != null) TextSpan(text: " (${f2.format(topTR)} TR)"),
|
2024-08-16 22:40:09 +00:00
|
|
|
TextSpan(text: " • ${prefs.getInt("ratingMode") == 1 ? "${f2.format(tlData.tr)} TR • RD: " : "Glicko: ${tlData.glicko != null ? f2.format(tlData.glicko) : "---"}±"}"),
|
2024-06-10 22:35:07 +00:00
|
|
|
TextSpan(text: f2.format(tlData.rd!), style: tlData.decaying ? TextStyle(color: tlData.rd! > 98 ? Colors.red : Colors.yellow) : null),
|
2024-07-10 15:31:00 +00:00
|
|
|
if (tlData.decaying) WidgetSpan(child: Icon(Icons.trending_up, color: tlData.rd! > 98 ? Colors.red : Colors.yellow,), alignment: PlaceholderAlignment.middle, baseline: TextBaseline.alphabetic),
|
2024-07-27 19:10:45 +00:00
|
|
|
//if (beforeS1end) tlData.rd! <= safeRD ? TextSpan(text: " (Safe)", style: TextStyle(color: Colors.greenAccent)) : TextSpan(text: " (> ${safeRD} RD !!!)", style: TextStyle(color: Colors.redAccent))
|
2024-06-10 22:35:07 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-11-05 23:07:43 +00:00
|
|
|
if (showPositions == true) RichText(
|
2024-11-19 23:21:03 +00:00
|
|
|
textAlign: bigScreen ? TextAlign.start : TextAlign.center,
|
2024-11-05 23:07:43 +00:00
|
|
|
text: TextSpan(
|
|
|
|
text: "",
|
|
|
|
style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey),
|
|
|
|
children: [
|
|
|
|
if (tlData.standing != -1) TextSpan(text: "№ ${intf.format(tlData.standing)}", style: TextStyle(color: getColorOfRank(tlData.standing))),
|
|
|
|
if (tlData.standing != -1 || tlData.standingLocal != -1) const TextSpan(text: " • "),
|
|
|
|
if (tlData.standingLocal != -1) TextSpan(text: "№ ${intf.format(tlData.standingLocal)} local", style: TextStyle(color: getColorOfRank(tlData.standingLocal))),
|
|
|
|
if (tlData.standing != -1 && tlData.standingLocal != -1) const TextSpan(text: " • "),
|
|
|
|
TextSpan(text: timestamp(tlData.timestamp)),
|
|
|
|
]
|
|
|
|
),
|
|
|
|
),
|
2024-06-10 22:35:07 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|