stat_sell_num fix + tl_rating_thingy update

This commit is contained in:
dan63047 2024-06-16 16:25:16 +03:00
parent 10da3b5b6a
commit 0262c8dcf9
4 changed files with 46 additions and 27 deletions

View File

@ -953,8 +953,6 @@ class _HistoryChartThigyState extends State<_HistoryChartThigy> {
series: <CartesianSeries>[ series: <CartesianSeries>[
if (_gamesPlayedInsteadOfDateAndTime) StepLineSeries<_HistoryChartSpot, int>( if (_gamesPlayedInsteadOfDateAndTime) StepLineSeries<_HistoryChartSpot, int>(
enableTooltip: true, enableTooltip: true,
// splineType: SplineType.cardinal,
// cardinalSplineTension: 0.2,
dataSource: widget.data, dataSource: widget.data,
animationDuration: 0, animationDuration: 0,
opacity: _smooth ? 0 : 1, opacity: _smooth ? 0 : 1,
@ -971,8 +969,6 @@ class _HistoryChartThigyState extends State<_HistoryChartThigy> {
) )
else StepLineSeries<_HistoryChartSpot, DateTime>( else StepLineSeries<_HistoryChartSpot, DateTime>(
enableTooltip: true, enableTooltip: true,
// splineType: SplineType.cardinal,
// cardinalSplineTension: 0.2,
dataSource: widget.data, dataSource: widget.data,
animationDuration: 0, animationDuration: 0,
opacity: _smooth ? 0 : 1, opacity: _smooth ? 0 : 1,

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:tetra_stats/data_objects/tetrio.dart'; import 'package:tetra_stats/data_objects/tetrio.dart';
@ -43,16 +45,16 @@ class StatCellNum extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
NumberFormat f = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: fractionDigits ?? 0);
NumberFormat comparef = NumberFormat("+#,###.###;-#,###.###")..maximumFractionDigits = fractionDigits ?? 0; NumberFormat comparef = NumberFormat("+#,###.###;-#,###.###")..maximumFractionDigits = fractionDigits ?? 0;
NumberFormat fractionf = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: fractionDigits ?? 0)..maximumIntegerDigits = 0; String formated = f.format(playerStat);
num fraction = playerStat.isNegative ? 1 - (playerStat - playerStat.floor()) : playerStat - playerStat.floor(); List<String> splited = formated.split(f.symbols.DECIMAL_SEP);
int integer = playerStat.isNegative ? (playerStat + fraction).toInt() : (playerStat - fraction).toInt();
return Column( return Column(
children: [ children: [
RichText( RichText(
text: TextSpan(text: intf.format(integer), text: TextSpan(text: splited[0],
children: [ children: [
TextSpan(text: fractionf.format(fraction).substring(1), style: smallDecimal ? const TextStyle(fontSize: 16) : null) if ((fractionDigits??0) > 0) TextSpan(text: f.symbols.DECIMAL_SEP+splited[1], style: smallDecimal ? const TextStyle(fontFamily: "Eurostile Round", fontSize: 16) : null)
], ],
style: TextStyle( style: TextStyle(
fontFamily: "Eurostile Round Extended", fontFamily: "Eurostile Round Extended",

View File

@ -5,7 +5,7 @@ import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/main.dart' show prefs; import 'package:tetra_stats/main.dart' show prefs;
import 'package:tetra_stats/utils/numers_formats.dart'; import 'package:tetra_stats/utils/numers_formats.dart';
var fDiff = NumberFormat("+#,###.###;-#,###.###"); var fDiff = NumberFormat("+#,###.####;-#,###.####");
class TLRatingThingy extends StatelessWidget{ class TLRatingThingy extends StatelessWidget{
final String userID; final String userID;
@ -19,7 +19,10 @@ class TLRatingThingy extends StatelessWidget{
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool oskKagariGimmick = prefs.getBool("oskKagariGimmick")??true; bool oskKagariGimmick = prefs.getBool("oskKagariGimmick")??true;
bool bigScreen = MediaQuery.of(context).size.width >= 768; bool bigScreen = MediaQuery.of(context).size.width >= 768;
int test = 0; String decimalSeparator = f4.symbols.DECIMAL_SEP;
List<String> formatedTR = f4.format(tlData.rating).split(decimalSeparator);
List<String> formatedGlicko = f4.format(tlData.glicko).split(decimalSeparator);
List<String> formatedPercentile = f4.format(tlData.percentile * 100).split(decimalSeparator);
return Wrap( return Wrap(
direction: Axis.horizontal, direction: Axis.horizontal,
alignment: WrapAlignment.spaceAround, alignment: WrapAlignment.spaceAround,
@ -31,17 +34,34 @@ class TLRatingThingy extends StatelessWidget{
: Image.asset("res/tetrio_tl_alpha_ranks/${tlData.rank}.png", height: 128), : Image.asset("res/tetrio_tl_alpha_ranks/${tlData.rank}.png", height: 128),
Column( Column(
children: [ children: [
Text( RichText(
switch(prefs.getInt("ratingMode")){ text: TextSpan(
1 => "${f2.format(tlData.glicko)} Glicko", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 20, color: Colors.white),
2 => "Top ${tlData.percentile < 0.1 ? f3.format(tlData.percentile * 100) : f2.format(tlData.percentile * 100)}%", children: switch(prefs.getInt("ratingMode")){
_ => "${(tlData.rating >= 24999 || tlData.rating < 100) ? f4.format(tlData.rating) : f2.format(tlData.rating)} TR", 1 => [
}, TextSpan(text: formatedGlicko[0], style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
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 => [
TextSpan(text: "Top ${formatedPercentile[0]}", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
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))
],
}
)
), ),
// Text("${f4.format(25000.0 - tlData.rating)} TR", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
if (oldTl != null) Text( if (oldTl != null) Text(
"${fDiff.format(tlData.rating - oldTl!.rating)} TR", switch(prefs.getInt("ratingMode")){
1 => "${fDiff.format(tlData.glicko! - oldTl!.glicko!)} Glicko",
2 => "${fDiff.format(tlData.percentile * 100 - oldTl!.percentile * 100)} %",
_ => "${fDiff.format(tlData.rating - oldTl!.rating)} TR"
},
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: tlData.rating - oldTl!.rating < 0 ? color: tlData.rating - oldTl!.rating < 0 ?

View File

@ -13,7 +13,7 @@ import 'package:tetra_stats/widgets/tl_progress_bar.dart';
import 'package:tetra_stats/widgets/tl_rating_thingy.dart'; import 'package:tetra_stats/widgets/tl_rating_thingy.dart';
var intFDiff = NumberFormat("+#,###;-#,###"); var intFDiff = NumberFormat("+#,###.000;-#,###.000");
class TLThingy extends StatefulWidget { class TLThingy extends StatefulWidget {
final TetraLeagueAlpha tl; final TetraLeagueAlpha tl;
@ -56,8 +56,9 @@ class _TLThingyState extends State<TLThingy> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final t = Translations.of(context); final t = Translations.of(context);
NumberFormat fractionfEstTR = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 2)..maximumIntegerDigits = 0; String decimalSeparator = f2.symbols.DECIMAL_SEP;
NumberFormat fractionfEstTRAcc = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 3)..maximumIntegerDigits = 0; List<String> estTRformated = f2.format(currentTl.estTr!.esttr).split(decimalSeparator);
List<String> estTRaccFormated = intFDiff.format(currentTl.esttracc!).split(decimalSeparator);
if (currentTl.gamesPlayed == 0) return Center(child: Text(widget.guest ? t.anonTL : widget.bot ? t.botTL : t.neverPlayedTL, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28), textAlign: TextAlign.center,)); if (currentTl.gamesPlayed == 0) return Center(child: Text(widget.guest ? t.anonTL : widget.bot ? t.botTL : t.neverPlayedTL, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28), textAlign: TextAlign.center,));
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
bool bigScreen = constraints.maxWidth >= 768; bool bigScreen = constraints.maxWidth >= 768;
@ -260,9 +261,9 @@ class _TLThingyState extends State<TLThingy> {
Text(t.statCellNum.estOfTR, style: const TextStyle(height: 0.1),), Text(t.statCellNum.estOfTR, style: const TextStyle(height: 0.1),),
RichText( RichText(
text: TextSpan( text: TextSpan(
text: intf.format(currentTl.estTr!.esttr.truncate()), text: estTRformated[0],
style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 36 : 30, fontWeight: FontWeight.w500, color: Colors.white), style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 36 : 30, fontWeight: FontWeight.w500, color: Colors.white),
children: [TextSpan(text: fractionfEstTR.format(currentTl.estTr!.esttr - currentTl.estTr!.esttr.truncate()).substring(1), style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))] children: [TextSpan(text: decimalSeparator+estTRformated[1], style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))]
), ),
), ),
RichText(text: TextSpan( RichText(text: TextSpan(
@ -289,10 +290,10 @@ class _TLThingyState extends State<TLThingy> {
Text(t.statCellNum.accOfEst, style: const TextStyle(height: 0.1),), Text(t.statCellNum.accOfEst, style: const TextStyle(height: 0.1),),
RichText( RichText(
text: TextSpan( text: TextSpan(
text: (currentTl.esttracc != null && currentTl.bestRank != "z") ? intFDiff.format(currentTl.esttracc!.truncate()) : "---", text: (currentTl.esttracc != null && currentTl.bestRank != "z") ? estTRaccFormated[0] : "---",
style: TextStyle(fontFamily: "Eurostile Round", fontSize: bigScreen ? 36 : 30, fontWeight: FontWeight.w500, color: Colors.white), style: TextStyle(fontFamily: "Eurostile Round", fontSize: bigScreen ? 36 : 30, fontWeight: FontWeight.w500, color: Colors.white),
children: [ children: [
TextSpan(text: (currentTl.esttracc != null && currentTl.bestRank != "z") ? fractionfEstTRAcc.format(currentTl.esttracc!.isNegative ? 1 - (currentTl.esttracc! - currentTl.esttracc!.truncate()) : (currentTl.esttracc! - currentTl.esttracc!.truncate())).substring(1) : ".---", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100)) TextSpan(text: (currentTl.esttracc != null && currentTl.bestRank != "z") ? decimalSeparator+estTRaccFormated[1] : ".---", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100))
] ]
), ),
), ),