diff --git a/lib/data_objects/tetrio_player.dart b/lib/data_objects/tetrio_player.dart index 02f3ed2..1746942 100644 --- a/lib/data_objects/tetrio_player.dart +++ b/lib/data_objects/tetrio_player.dart @@ -95,7 +95,7 @@ class TetrioPlayer { // data['_id'] = userId; // data['username'] = username; data['role'] = role; - if (registrationTime != null) data['ts'] = registrationTime?.toString(); + data['ts'] = registrationTime.toString(); if (badges.isNotEmpty) data['badges'] = badges.map((v) => v.toJson()).toList(); if (xp >= 0) data['xp'] = xp; if (gamesPlayed >= 0) data['gamesplayed'] = gamesPlayed; diff --git a/lib/main.dart b/lib/main.dart index 8e3a945..c0b11f3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,7 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart'; import 'package:tetra_stats/gen/strings.g.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:tetra_stats/views/main_view.dart'; +import 'package:tetra_stats/views/main_view_tiles.dart'; import 'package:tetra_stats/views/settings_view.dart'; import 'package:tetra_stats/views/tracked_players_view.dart'; import 'package:tetra_stats/views/calc_view.dart'; diff --git a/lib/views/compare_view_tiles.dart b/lib/views/compare_view_tiles.dart index ad13355..b772888 100644 --- a/lib/views/compare_view_tiles.dart +++ b/lib/views/compare_view_tiles.dart @@ -150,6 +150,8 @@ class CompareState extends State { "Pieces Per Second", "Key Presses Per Second", "" + // TODO: line clears + // TODO: spins ], "Blitz": [ "Score", @@ -407,7 +409,7 @@ class CompareState extends State { Text(s.sprint != null ? f4.format(s.sprint!.stats.kps) : "---") ]); formattedValues[5].add([ - Text(s.blitz != null ? getMoreNormalTime(s.blitz!.stats.finalTime) : "---"), + Text(s.blitz != null ? intf.format(s.sprint!.stats.score) : "---"), Text(s.blitz != null ? intf.format(s.blitz!.stats.piecesPlaced) : "---"), Text(s.blitz != null ? intf.format(s.blitz!.stats.inputs) : "---"), Text(s.blitz != null ? f4.format(s.blitz!.stats.kpp) : "---"), @@ -640,7 +642,7 @@ class CompareState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - for (int l = 0; l < formattedValues[i][k].length; l++) Container(decoration: BoxDecoration(color: (rawValues[0].length > 1 && rawValues[i][k][l] != null && best[i][l] == rawValues[i][k][l]) ? Colors.cyanAccent.withAlpha(96) : null), child: formattedValues[i][k][l]), + for (int l = 0; l < formattedValues[i][k].length; l++) Container(decoration: (rawValues[0].length > 1 && rawValues[i][k][l] != null && best[i][l] == rawValues[i][k][l]) ? BoxDecoration(boxShadow: [BoxShadow(color: Colors.cyanAccent.withAlpha(96), spreadRadius: 0, blurRadius: 4)]) : null, child: formattedValues[i][k][l]), ], ), ), diff --git a/lib/views/main_view_tiles.dart b/lib/views/main_view_tiles.dart index 1cfd74e..c77697a 100644 --- a/lib/views/main_view_tiles.dart +++ b/lib/views/main_view_tiles.dart @@ -26,6 +26,7 @@ import 'package:tetra_stats/data_objects/record_single.dart'; import 'package:tetra_stats/data_objects/singleplayer_stream.dart'; import 'package:tetra_stats/data_objects/summaries.dart'; import 'package:tetra_stats/data_objects/tetra_league.dart'; +import 'package:tetra_stats/data_objects/tetra_league_alpha_record.dart'; import 'package:tetra_stats/data_objects/tetra_league_beta_stream.dart'; import 'package:tetra_stats/data_objects/tetrio_constants.dart'; import 'package:tetra_stats/data_objects/tetrio_player.dart'; @@ -208,6 +209,7 @@ class _MainState extends State with TickerProviderStateMixin { 2 => DestinationLeaderboards(constraints: constraints), 3 => DestinationCutoffs(constraints: constraints), 4 => DestinationCalculator(constraints: constraints), + 6 => DestinationSavedData(constraints: constraints), _ => Text("Unknown destination $destination") }, ) @@ -217,6 +219,139 @@ class _MainState extends State with TickerProviderStateMixin { } } +class DestinationSavedData extends StatefulWidget{ + final BoxConstraints constraints; + + const DestinationSavedData({super.key, required this.constraints}); + + @override + State createState() => _DestinationSavedData(); +} + +class _DestinationSavedData extends State { + String? selectedID; + + Future<(List, List, List)> getDataAbout(String id) async { + return (await teto.getStates(id), await teto.getStates(id, season: 1), await teto.getTLMatchesbyPlayerID(id)); + } + + Widget getTetraLeagueListTile(TetraLeague data){ + return ListTile( + title: Text(timestamp(data.timestamp)), + subtitle: Text("${intf.format(data.gamesPlayed)} games"), + ); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder>( + future: teto.getAllPlayers(), + 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.hasError){ return FutureError(snapshot); } + if (snapshot.hasData){ + return Row( + children: [ + SizedBox( + width: 450, + child: Column( + children: [ + const Card( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Spacer(), + Text("Saved Data", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36)), + Spacer() + ], + ), + ), + for (String id in snapshot.data!.keys) Card( + child: ListTile( + title: Text(snapshot.data![id]!), + subtitle: Text("NaN states, NaN TL records", style: TextStyle(color: Colors.grey)), + onTap: () => setState(() { + selectedID = id; + }), + ), + ) + ], + ), + ), + SizedBox( + width: widget.constraints.maxWidth - 450 - 80, + child: selectedID != null ? FutureBuilder<(List, List, List)>( + future: getDataAbout(selectedID!), + 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.hasError){ return FutureError(snapshot); } + if (snapshot.hasData){ + return DefaultTabController( + length: 3, + child: Card( + child: Column( + children: [ + Card( + child: TabBar(tabs: [ + Tab(text: "S${currentSeason} TL States"), + Tab(text: "S1 TL States"), + Tab(text: "TL Records") + ]), + ), + SizedBox( + height: widget.constraints.maxHeight - 164, + child: TabBarView(children: [ + ListView.builder( + itemCount: snapshot.data!.$1.length, + itemBuilder: (context, index) { + return getTetraLeagueListTile(snapshot.data!.$1[index]); + },), + ListView.builder( + itemCount: snapshot.data!.$2.length, + itemBuilder: (context, index) { + return getTetraLeagueListTile(snapshot.data!.$2[index]); + },), + ListView.builder( + itemCount: snapshot.data!.$3.length, + itemBuilder: (context, index) { + return ListTile( + title: Text(snapshot.data!.$3[index].toString()), + ); + },), + ] + ), + ) + ], + ), + ), + ); + } + return Text("what?"); + } + } + ) : + Text("Select nickname on the left to see data assosiated with it") + ) + ], + ); + } + } + return const Text("End of FutureBuilder"); + }, + ); + } +} + class DestinationCalculator extends StatefulWidget{ final BoxConstraints constraints; @@ -682,7 +817,13 @@ class _DestinationCalculatorState extends State { SizedBox( width: widget.constraints.maxWidth - 350 - 80, height: widget.constraints.maxHeight - 148, - child: clears.isEmpty ? Center(child: Text("Click on the actions on the left to add them here", textAlign: ui.TextAlign.center)) : + child: clears.isEmpty ? Center(child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.info_outline, size: 128.0, color: Colors.grey.shade800), + Text("Click on the actions on the left to add them here", textAlign: ui.TextAlign.center), + ], + )) : Card( child: Column( children: [ diff --git a/web/index.html b/web/index.html index 66c6956..a1c9ed2 100644 --- a/web/index.html +++ b/web/index.html @@ -131,7 +131,7 @@ } - +