I actually should to start working

This commit is contained in:
dan63047 2023-08-15 00:26:20 +03:00
parent e2c5a652d1
commit f058919fd2
3 changed files with 480 additions and 261 deletions

View File

@ -1313,6 +1313,7 @@ class TetrioPlayersLeaderboard {
avgGamesWon = (totalGamesWon / filtredLeaderboard.length).floor(); avgGamesWon = (totalGamesWon / filtredLeaderboard.length).floor();
return [TetraLeagueAlpha(timestamp: DateTime.now(), apm: avgAPM, pps: avgPPS, vs: avgVS, glicko: avgGlicko, rd: avgRD, gamesPlayed: avgGamesPlayed, gamesWon: avgGamesWon, bestRank: rank, decaying: false, rating: avgTR, rank: rank, percentileRank: rank, percentile: rankCutoffs[rank]!, standing: -1, standingLocal: -1, nextAt: -1, prevAt: -1), return [TetraLeagueAlpha(timestamp: DateTime.now(), apm: avgAPM, pps: avgPPS, vs: avgVS, glicko: avgGlicko, rd: avgRD, gamesPlayed: avgGamesPlayed, gamesWon: avgGamesWon, bestRank: rank, decaying: false, rating: avgTR, rank: rank, percentileRank: rank, percentile: rankCutoffs[rank]!, standing: -1, standingLocal: -1, nextAt: -1, prevAt: -1),
{ {
"everyone": rank == "",
"totalGamesPlayed": totalGamesPlayed, "totalGamesPlayed": totalGamesPlayed,
"totalGamesWon": totalGamesWon, "totalGamesWon": totalGamesWon,
"players": filtredLeaderboard.length, "players": filtredLeaderboard.length,

View File

@ -1,9 +1,13 @@
import 'dart:math';
import 'package:fl_chart/fl_chart.dart';
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';
import 'package:tetra_stats/gen/strings.g.dart'; import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/views/main_view.dart'; import 'package:tetra_stats/views/main_view.dart';
import 'package:tetra_stats/widgets/stat_sell_num.dart'; import 'package:tetra_stats/widgets/stat_sell_num.dart';
import 'package:tetra_stats/widgets/tl_thingy.dart';
//import 'package:tetra_stats/widgets/tl_thingy.dart'; //import 'package:tetra_stats/widgets/tl_thingy.dart';
final DateFormat dateFormat = final DateFormat dateFormat =
@ -65,14 +69,10 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
Stack( Stack(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
children: [ children: [
Container( Image.asset(
padding:
EdgeInsets.fromLTRB(0, pfpHeight, 0, 0),
child: Image.asset(
"res/tetrio_tl_alpha_ranks/${widget.rank[0].rank}.png", "res/tetrio_tl_alpha_ranks/${widget.rank[0].rank}.png",
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
height: 128), height: 128),
),
], ],
), ),
Flexible( Flexible(
@ -92,35 +92,35 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
)), )),
], ],
), ),
Wrap( // Wrap(
direction: Axis.horizontal, // direction: Axis.horizontal,
alignment: WrapAlignment.center, // alignment: WrapAlignment.center,
spacing: 25, // spacing: 25,
crossAxisAlignment: WrapCrossAlignment.start, // crossAxisAlignment: WrapCrossAlignment.start,
clipBehavior: Clip.hardEdge, // hard WHAT??? // clipBehavior: Clip.hardEdge, // hard WHAT???
children: [ // children: [
StatCellNum( // StatCellNum(
playerStat: widget.rank[1]["totalGamesPlayed"], // playerStat: widget.rank[1]["totalGamesPlayed"],
playerStatLabel: "Total games\nplayed", // playerStatLabel: "Total games\nplayed",
isScreenBig: bigScreen, // isScreenBig: bigScreen,
higherIsBetter: true, // higherIsBetter: true,
), // ),
StatCellNum( // StatCellNum(
playerStat: widget.rank[1]["totalGamesWon"], // playerStat: widget.rank[1]["totalGamesWon"],
playerStatLabel: "Total games\nwon", // playerStatLabel: "Total games\nwon",
isScreenBig: bigScreen, // isScreenBig: bigScreen,
higherIsBetter: true, // higherIsBetter: true,
), // ),
StatCellNum( // StatCellNum(
playerStat: (widget.rank[1]["totalGamesWon"] / // playerStat: (widget.rank[1]["totalGamesWon"] /
widget.rank[1]["totalGamesPlayed"]) * // widget.rank[1]["totalGamesPlayed"]) *
100, // 100,
playerStatLabel: t.statCellNum.winrate, // playerStatLabel: t.statCellNum.winrate,
fractionDigits: 3, // fractionDigits: 3,
isScreenBig: bigScreen, // isScreenBig: bigScreen,
higherIsBetter: true) // higherIsBetter: true)
], // ],
), // ),
], ],
)), )),
SliverToBoxAdapter( SliverToBoxAdapter(
@ -142,11 +142,57 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
controller: _tabController, controller: _tabController,
children: [ children: [
Column( Column(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Text("Chart", LayoutBuilder(builder: (context, constraints) {
style: TextStyle( return true ?
fontFamily: "Eurostile Round Extended", Column(
fontSize: bigScreen ? 42 : 28)), children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [Column(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("X axis:", style: const TextStyle(fontSize: 22))),
DropdownButton(
items: chartsData,
value: chartsData[chartsIndex].value,
onChanged: (value) {
chartsIndex = chartsData.indexWhere((element) => element.value == value);
_justUpdate();
}
),
],
),
],
),Column(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Y axis:", style: const TextStyle(fontSize: 22)),
),
DropdownButton(
items: chartsData,
value: chartsData[chartsIndex].value,
onChanged: (value) {
chartsIndex = chartsData.indexWhere((element) => element.value == value);
_justUpdate();
}
),
],
),
],
),],),
if(chartsData[chartsIndex].value!.length > 1) _ChartThigy(data: chartsData[chartsIndex].value!, title: "ss", yAxisTitle: chartsShortTitles[chartsIndex], bigScreen: bigScreen, leftSpace: bigScreen? 80 : 45, yFormat: bigScreen? f2 : NumberFormat.compact(),)
else Center(child: Text(t.notEnoughData, style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28)))
],
) : Center(child: Text(t.noHistorySaved, style: const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28)));
})
], ],
), ),
Column( Column(
@ -273,7 +319,8 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestAPP"], value: widget.rank[1]["lowestAPP"],
label: t.statCellNum.app.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.app
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestAPPid"], id: widget.rank[1]["lowestAPPid"],
username: widget.rank[1]["lowestAPPnick"], username: widget.rank[1]["lowestAPPnick"],
approximate: false, approximate: false,
@ -287,63 +334,72 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestDSS"], value: widget.rank[1]["lowestDSS"],
label: t.statCellNum.dss.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dss
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestDSSid"], id: widget.rank[1]["lowestDSSid"],
username: widget.rank[1]["lowestDSSnick"], username: widget.rank[1]["lowestDSSnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestDSP"], value: widget.rank[1]["lowestDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestDSPid"], id: widget.rank[1]["lowestDSPid"],
username: widget.rank[1]["lowestDSPnick"], username: widget.rank[1]["lowestDSPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestAPPDSP"], value: widget.rank[1]["lowestAPPDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestAPPDSPid"], id: widget.rank[1]["lowestAPPDSPid"],
username: widget.rank[1]["lowestAPPDSPnick"], username: widget.rank[1]["lowestAPPDSPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestCheese"], value: widget.rank[1]["lowestCheese"],
label: t.statCellNum.cheese.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.cheese
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestCheeseID"], id: widget.rank[1]["lowestCheeseID"],
username: widget.rank[1]["lowestCheeseNick"], username: widget.rank[1]["lowestCheeseNick"],
approximate: false, approximate: false,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestGBE"], value: widget.rank[1]["lowestGBE"],
label: t.statCellNum.gbe.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.gbe
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestGBEid"], id: widget.rank[1]["lowestGBEid"],
username: widget.rank[1]["lowestGBEnick"], username: widget.rank[1]["lowestGBEnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestNyaAPP"], value: widget.rank[1]["lowestNyaAPP"],
label: t.statCellNum.nyaapp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.nyaapp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestNyaAPPid"], id: widget.rank[1]["lowestNyaAPPid"],
username: widget.rank[1]["lowestNyaAPPnick"], username: widget.rank[1]["lowestNyaAPPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestArea"], value: widget.rank[1]["lowestArea"],
label: t.statCellNum.area.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.area
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestAreaID"], id: widget.rank[1]["lowestAreaID"],
username: widget.rank[1]["lowestAreaNick"], username: widget.rank[1]["lowestAreaNick"],
approximate: false, approximate: false,
fractionDigits: 1), fractionDigits: 1),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestEstTR"], value: widget.rank[1]["lowestEstTR"],
label: t.statCellNum.estOfTR.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.estOfTR
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestEstTRid"], id: widget.rank[1]["lowestEstTRid"],
username: widget.rank[1]["lowestEstTRnick"], username: widget.rank[1]["lowestEstTRnick"],
approximate: false, approximate: false,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["lowestEstAcc"], value: widget.rank[1]["lowestEstAcc"],
label: t.statCellNum.accOfEst.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.accOfEst
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["lowestEstAccID"], id: widget.rank[1]["lowestEstAccID"],
username: widget.rank[1]["lowestEstAccNick"], username: widget.rank[1]["lowestEstAccNick"],
approximate: false, approximate: false,
@ -388,8 +444,7 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fontFamily: "Eurostile Round Extended", fontFamily: "Eurostile Round Extended",
fontSize: bigScreen ? 42 : 28)), fontSize: bigScreen ? 42 : 28)),
Expanded( Expanded(
child: ListView( child: ListView(children: [
children: [
_ListEntry( _ListEntry(
value: widget.rank[0].rating, value: widget.rank[0].rating,
label: "Tetra Rating", label: "Tetra Rating",
@ -426,7 +481,7 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
approximate: true, approximate: true,
fractionDigits: 0), fractionDigits: 0),
_ListEntry( _ListEntry(
value: widget.rank[0].winrate*100, value: widget.rank[0].winrate * 100,
label: "Winrate", label: "Winrate",
id: "", id: "",
username: "", username: "",
@ -469,63 +524,72 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgDSS"], value: widget.rank[1]["avgDSS"],
label: t.statCellNum.dss.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dss
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgDSP"], value: widget.rank[1]["avgDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgAPPDSP"], value: widget.rank[1]["avgAPPDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgCheese"], value: widget.rank[1]["avgCheese"],
label: t.statCellNum.cheese.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.cheese
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgGBE"], value: widget.rank[1]["avgGBE"],
label: t.statCellNum.gbe.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.gbe
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgNyaAPP"], value: widget.rank[1]["avgNyaAPP"],
label: t.statCellNum.nyaapp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.nyaapp
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgArea"], value: widget.rank[1]["avgArea"],
label: t.statCellNum.area.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.area
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 1), fractionDigits: 1),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgEstTR"], value: widget.rank[1]["avgEstTR"],
label: t.statCellNum.estOfTR.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.estOfTR
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["avgEstAcc"], value: widget.rank[1]["avgEstAcc"],
label: t.statCellNum.accOfEst.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.accOfEst
.replaceAll(RegExp(r'\n'), " "),
id: "", id: "",
username: "", username: "",
approximate: true, approximate: true,
@ -558,9 +622,7 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
username: "", username: "",
approximate: true, approximate: true,
fractionDigits: 3), fractionDigits: 3),
] ]))
)
)
], ],
), ),
Column( Column(
@ -638,7 +700,8 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestAPP"], value: widget.rank[1]["highestAPP"],
label: t.statCellNum.app.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.app
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestAPPid"], id: widget.rank[1]["highestAPPid"],
username: widget.rank[1]["highestAPPnick"], username: widget.rank[1]["highestAPPnick"],
approximate: false, approximate: false,
@ -652,63 +715,72 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestDSS"], value: widget.rank[1]["highestDSS"],
label: t.statCellNum.dss.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dss
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestDSSid"], id: widget.rank[1]["highestDSSid"],
username: widget.rank[1]["highestDSSnick"], username: widget.rank[1]["highestDSSnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestDSP"], value: widget.rank[1]["highestDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestDSPid"], id: widget.rank[1]["highestDSPid"],
username: widget.rank[1]["highestDSPnick"], username: widget.rank[1]["highestDSPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestAPPDSP"], value: widget.rank[1]["highestAPPDSP"],
label: t.statCellNum.dsp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.dsp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestAPPDSPid"], id: widget.rank[1]["highestAPPDSPid"],
username: widget.rank[1]["highestAPPDSPnick"], username: widget.rank[1]["highestAPPDSPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestCheese"], value: widget.rank[1]["highestCheese"],
label: t.statCellNum.cheese.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.cheese
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestCheeseID"], id: widget.rank[1]["highestCheeseID"],
username: widget.rank[1]["highestCheeseNick"], username: widget.rank[1]["highestCheeseNick"],
approximate: false, approximate: false,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestGBE"], value: widget.rank[1]["highestGBE"],
label: t.statCellNum.gbe.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.gbe
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestGBEid"], id: widget.rank[1]["highestGBEid"],
username: widget.rank[1]["highestGBEnick"], username: widget.rank[1]["highestGBEnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestNyaAPP"], value: widget.rank[1]["highestNyaAPP"],
label: t.statCellNum.nyaapp.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.nyaapp
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestNyaAPPid"], id: widget.rank[1]["highestNyaAPPid"],
username: widget.rank[1]["highestNyaAPPnick"], username: widget.rank[1]["highestNyaAPPnick"],
approximate: false, approximate: false,
fractionDigits: 3), fractionDigits: 3),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestArea"], value: widget.rank[1]["highestArea"],
label: t.statCellNum.area.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.area
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestAreaID"], id: widget.rank[1]["highestAreaID"],
username: widget.rank[1]["highestAreaNick"], username: widget.rank[1]["highestAreaNick"],
approximate: false, approximate: false,
fractionDigits: 1), fractionDigits: 1),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestEstTR"], value: widget.rank[1]["highestEstTR"],
label: t.statCellNum.estOfTR.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.estOfTR
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestEstTRid"], id: widget.rank[1]["highestEstTRid"],
username: widget.rank[1]["highestEstTRnick"], username: widget.rank[1]["highestEstTRnick"],
approximate: false, approximate: false,
fractionDigits: 2), fractionDigits: 2),
_ListEntry( _ListEntry(
value: widget.rank[1]["highestEstAcc"], value: widget.rank[1]["highestEstAcc"],
label: t.statCellNum.accOfEst.replaceAll(RegExp(r'\n'), " "), label: t.statCellNum.accOfEst
.replaceAll(RegExp(r'\n'), " "),
id: widget.rank[1]["highestEstAccID"], id: widget.rank[1]["highestEstAccID"],
username: widget.rank[1]["highestEstAccNick"], username: widget.rank[1]["highestEstAccNick"],
approximate: false, approximate: false,
@ -747,7 +819,47 @@ class RankState extends State<RankView> with SingleTickerProviderStateMixin {
], ],
), ),
Column( Column(
children: [], children: [
Expanded(
child: ListView(
children: [
_ListEntry(
value: widget.rank[1]["totalGamesPlayed"],
label: "Total Games Played",
id: "",
username: "",
approximate: true,
fractionDigits: 0),
_ListEntry(
value: widget.rank[1]["totalGamesWon"],
label: "Total Games Won",
id: "",
username: "",
approximate: true,
fractionDigits: 0),
_ListEntry(
value: (widget.rank[1]["totalGamesWon"] /
widget.rank[1]["totalGamesPlayed"]) *
100,
label: "Winrate",
id: "",
username: "",
approximate: true,
fractionDigits: 3),
Center(
child: Text("Typical TL profile",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
fontSize: bigScreen ? 42 : 28)),
),
SizedBox(
height: 800,
child: TLThingy(tl: widget.rank[0], userID: ""),
)
]
)
)
],
), ),
], ],
)))); ))));
@ -799,3 +911,95 @@ class _ListEntry extends StatelessWidget {
); );
} }
} }
class _ChartThigy extends StatelessWidget {
final List<FlSpot> data;
final String title;
final String yAxisTitle;
final bool bigScreen;
final double leftSpace;
final NumberFormat yFormat;
const _ChartThigy(
{required this.data,
required this.title,
required this.yAxisTitle,
required this.bigScreen,
required this.leftSpace,
required this.yFormat});
@override
Widget build(BuildContext context) {
double xInterval = bigScreen
? max(1, (data.last.x - data.first.x) / 6)
: max(1, (data.last.x - data.first.x) / 3);
return SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 104,
child: Stack(
children: [
Padding(
padding: bigScreen
? const EdgeInsets.fromLTRB(40, 40, 40, 48)
: const EdgeInsets.fromLTRB(0, 40, 16, 48),
child: LineChart(LineChartData(
lineBarsData: [LineChartBarData(spots: data)],
borderData: FlBorderData(show: false),
gridData: FlGridData(verticalInterval: xInterval),
titlesData: FlTitlesData(
topTitles:
AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles:
AxisTitles(sideTitles: SideTitles(showTitles: false)),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
interval: xInterval,
showTitles: true,
reservedSize: 30,
getTitlesWidget: (double value, TitleMeta meta) {
return value != meta.min && value != meta.max
? SideTitleWidget(
axisSide: meta.axisSide,
child: Text(DateFormat.yMMMd(
LocaleSettings
.currentLocale.languageCode)
.format(DateTime
.fromMillisecondsSinceEpoch(
value.floor()))),
)
: Container();
})),
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: leftSpace,
getTitlesWidget: (double value, TitleMeta meta) {
return value != meta.min && value != meta.max
? SideTitleWidget(
axisSide: meta.axisSide,
child: Text(yFormat.format(value)),
)
: Container();
}))),
lineTouchData: LineTouchData(
touchTooltipData: LineTouchTooltipData(
fitInsideHorizontally: true,
fitInsideVertically: true,
getTooltipItems: (touchedSpots) {
return [
for (var v in touchedSpots)
LineTooltipItem("${f4.format(v.y)} $yAxisTitle \n",
const TextStyle(),
children: [
TextSpan(
text: dateFormat.format(
DateTime.fromMillisecondsSinceEpoch(
v.x.floor())))
])
];
},
)))),
),
],
));
}
}

View File

@ -3,6 +3,7 @@ import 'package:intl/intl.dart';
import 'package:tetra_stats/gen/strings.g.dart'; import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/services/tetrio_crud.dart'; import 'package:tetra_stats/services/tetrio_crud.dart';
import 'package:tetra_stats/views/main_view.dart'; import 'package:tetra_stats/views/main_view.dart';
import 'package:tetra_stats/views/rank_averages_view.dart';
import 'package:tetra_stats/views/ranks_averages_view.dart'; import 'package:tetra_stats/views/ranks_averages_view.dart';
final TetrioService teto = TetrioService(); final TetrioService teto = TetrioService();
@ -67,10 +68,23 @@ class TLLeaderboardState extends State<TLLeaderboardView> {
SliverToBoxAdapter( SliverToBoxAdapter(
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 16), padding: const EdgeInsets.only(left: 16),
child: Text( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
howManyPlayers(allPlayers.length), howManyPlayers(allPlayers.length),
style: const TextStyle(color: Colors.white, fontSize: 25), style: const TextStyle(color: Colors.white, fontSize: 25),
), ),
TextButton(onPressed: (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RankView(rank: snapshot.data!.getAverageOfRank("")),
),
);
}, child: Text("Values for everyone",
style: const TextStyle(fontSize: 25)))
],)
)), )),
const SliverToBoxAdapter(child: Divider()) const SliverToBoxAdapter(child: Divider())
]; ];