I lied i forgor to fix things

This commit is contained in:
dan63047 2024-06-17 00:04:07 +03:00
parent 249c2c4a68
commit 712a52ad7b
18 changed files with 40 additions and 32 deletions

View File

@ -1222,7 +1222,7 @@ class News{
News(this.id, this.news); News(this.id, this.news);
News.fromJson(Map<String, dynamic> json, String? userID){ News.fromJson(Map<String, dynamic> json, String? userID){
id = userID != null ? "user_${userID}" : json['news'].first['stream']; id = userID != null ? "user_$userID" : json['news'].first['stream'];
news = [for (var entry in json['news']) NewsEntry.fromJson(entry)]; news = [for (var entry in json['news']) NewsEntry.fromJson(entry)];
} }
} }

View File

@ -6,7 +6,7 @@
/// Locales: 2 /// Locales: 2
/// Strings: 1182 (591 per locale) /// Strings: 1182 (591 per locale)
/// ///
/// Built on 2024-06-16 at 15:08 UTC /// Built on 2024-06-16 at 21:03 UTC
// coverage:ignore-file // coverage:ignore-file
// ignore_for_file: type=lint // ignore_for_file: type=lint

View File

@ -1,10 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:isolate';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:developer' as developer; import 'dart:developer' as developer;
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -145,9 +143,9 @@ void main() async {
} }
// I dont want to store old cache // I dont want to store old cache
Timer.periodic(Duration(minutes: 5), (Timer timer) { Timer.periodic(const Duration(minutes: 5), (Timer timer) {
teto.cacheRoutine(); teto.cacheRoutine();
developer.log("Cache routine complete, next one in ${DateTime.now().add(Duration(minutes: 5))}", name: "main"); developer.log("Cache routine complete, next one in ${DateTime.now().add(const Duration(minutes: 5))}", name: "main");
// if (prefs.getBool("updateInBG") == true) teto.fetchTracked(); // TODO: Somehow avoid doing that in main isolate // if (prefs.getBool("updateInBG") == true) teto.fetchTracked(); // TODO: Somehow avoid doing that in main isolate
}); });
@ -165,6 +163,12 @@ class MyApp extends StatefulWidget {
class MyAppState extends State<MyApp> { class MyAppState extends State<MyApp> {
@override
void initState() {
setAccentColor(prefs.getInt("accentColor") != null ? Color(prefs.getInt("accentColor")!) : Colors.cyanAccent);
super.initState();
}
void setAccentColor(Color color){ // does this thing work??? yes??? no??? void setAccentColor(Color color){ // does this thing work??? yes??? no???
setState(() { setState(() {
theme = theme.copyWith(colorScheme: theme.colorScheme.copyWith(primary: color)); theme = theme.copyWith(colorScheme: theme.colorScheme.copyWith(primary: color));

View File

@ -1,3 +1,5 @@
// ignore_for_file: type_literal_in_constant_pattern
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:developer' as developer; import 'dart:developer' as developer;
@ -87,7 +89,7 @@ class CacheController {
case Cutoffs: case Cutoffs:
return object.runtimeType.toString(); return object.runtimeType.toString();
case TetrioPlayerFromLeaderboard: // i may be a little stupid case TetrioPlayerFromLeaderboard: // i may be a little stupid
return object.runtimeType.toString()+"topone"; return "${object.runtimeType}topone";
case TetraLeagueAlphaStream: case TetraLeagueAlphaStream:
return object.runtimeType.toString()+object.userId; return object.runtimeType.toString()+object.userId;
case SingleplayerStream: case SingleplayerStream:

View File

@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';

View File

@ -109,6 +109,7 @@ class CustomizationState extends State<CustomizationView> {
onPressed: () { onPressed: () {
setState(() { setState(() {
context.findAncestorStateOfType<MyAppState>()?.setAccentColor(pickerColor); context.findAncestorStateOfType<MyAppState>()?.setAccentColor(pickerColor);
prefs.setInt("accentColor", pickerColor.value);
}); });
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
@ -142,8 +143,8 @@ class CustomizationState extends State<CustomizationView> {
trailing: DropdownButton( trailing: DropdownButton(
value: ratingMode, value: ratingMode,
items: <DropdownMenuItem>[ items: <DropdownMenuItem>[
DropdownMenuItem(value: 0, child: Text("TR")), const DropdownMenuItem(value: 0, child: Text("TR")),
DropdownMenuItem(value: 1, child: Text("Glicko")), const DropdownMenuItem(value: 1, child: Text("Glicko")),
DropdownMenuItem(value: 2, child: Text(t.ratingLBposition)) DropdownMenuItem(value: 2, child: Text(t.ratingLBposition))
], ],
onChanged: (dynamic value){ onChanged: (dynamic value){

View File

@ -1,4 +1,4 @@
// ignore_for_file: type_literal_in_constant_pattern // ignore_for_file: type_literal_in_constant_pattern, use_build_context_synchronously
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
@ -75,7 +75,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
//var tableData = <TableRow>[]; //var tableData = <TableRow>[];
final bodyGlobalKey = GlobalKey(); final bodyGlobalKey = GlobalKey();
bool _showSearchBar = false; bool _showSearchBar = false;
Timer backgroundUpdate = Timer(Duration(days: 365), (){}); Timer backgroundUpdate = Timer(const Duration(days: 365), (){});
bool _TLHistoryWasFetched = false; bool _TLHistoryWasFetched = false;
late TabController _tabController; late TabController _tabController;
late TabController _wideScreenTabController; late TabController _wideScreenTabController;
@ -743,7 +743,7 @@ class _TLRecords extends StatelessWidget {
leading: Text("${data[index].endContext.firstWhere((element) => element.userId == userID).points} : ${data[index].endContext.firstWhere((element) => element.userId != userID).points}", leading: Text("${data[index].endContext.firstWhere((element) => element.userId == userID).points} : ${data[index].endContext.firstWhere((element) => element.userId != userID).points}",
style: bigScreen ? const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28, shadows: textShadow) : const TextStyle(fontSize: 28, shadows: textShadow)), style: bigScreen ? const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28, shadows: textShadow) : const TextStyle(fontSize: 28, shadows: textShadow)),
title: Text("vs. ${data[index].endContext.firstWhere((element) => element.userId != userID).username}"), title: Text("vs. ${data[index].endContext.firstWhere((element) => element.userId != userID).username}"),
subtitle: Text(timestamp(data[index].timestamp), style: TextStyle(color: Colors.grey)), subtitle: Text(timestamp(data[index].timestamp), style: const TextStyle(color: Colors.grey)),
trailing: TrailingStats( trailing: TrailingStats(
data[index].endContext.firstWhere((element) => element.userId == userID).secondary, data[index].endContext.firstWhere((element) => element.userId == userID).secondary,
data[index].endContext.firstWhere((element) => element.userId == userID).tertiary, data[index].endContext.firstWhere((element) => element.userId == userID).tertiary,
@ -1089,8 +1089,8 @@ class _TwoRecordsThingy extends StatelessWidget {
crossAxisAlignment: WrapCrossAlignment.start, crossAxisAlignment: WrapCrossAlignment.start,
spacing: 20, spacing: 20,
children: [ children: [
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${sprint!.replayId}"));}, child: Text("Open replay in TETR.IO")), TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${sprint!.replayId}"));}, child: Text(t.openSPreplay)),
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${sprint!.replayId}"));}, child: Text("Download replay")), TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${sprint!.replayId}"));}, child: Text(t.downloadSPreplay)),
], ],
), ),
if (sprintStream.records.length > 1) SizedBox( if (sprintStream.records.length > 1) SizedBox(
@ -1102,8 +1102,8 @@ class _TwoRecordsThingy extends StatelessWidget {
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: sprintStream.records[i]))), onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: sprintStream.records[i]))),
leading: Text("#${i+1}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, shadows: textShadow, height: 0.9) ), leading: Text("#${i+1}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, shadows: textShadow, height: 0.9) ),
title: Text(get40lTime(sprintStream.records[i].endContext.finalTime.inMicroseconds), title: Text(get40lTime(sprintStream.records[i].endContext.finalTime.inMicroseconds),
style: TextStyle(fontSize: 18)), style: const TextStyle(fontSize: 18)),
subtitle: Text(timestamp(sprintStream.records[i].timestamp), style: TextStyle(color: Colors.grey, height: 0.85)), subtitle: Text(timestamp(sprintStream.records[i].timestamp), style: const TextStyle(color: Colors.grey, height: 0.85)),
trailing: SpTrailingStats(sprintStream.records[i].endContext) trailing: SpTrailingStats(sprintStream.records[i].endContext)
) )
], ],
@ -1175,8 +1175,8 @@ class _TwoRecordsThingy extends StatelessWidget {
crossAxisAlignment: WrapCrossAlignment.start, crossAxisAlignment: WrapCrossAlignment.start,
spacing: 20, spacing: 20,
children: [ children: [
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${blitz!.replayId}"));}, child: Text("Open replay in TETR.IO")), TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${blitz!.replayId}"));}, child: Text(t.openSPreplay)),
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${blitz!.replayId}"));}, child: Text("Download replay")), TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${blitz!.replayId}"));}, child: Text(t.downloadSPreplay)),
], ],
), ),
if (blitzStream.records.length > 1) SizedBox( if (blitzStream.records.length > 1) SizedBox(
@ -1188,8 +1188,8 @@ class _TwoRecordsThingy extends StatelessWidget {
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: blitzStream.records[i]))), onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: blitzStream.records[i]))),
leading: Text("#${i+1}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, shadows: textShadow, height: 0.9) ), leading: Text("#${i+1}", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, shadows: textShadow, height: 0.9) ),
title: Text("${NumberFormat.decimalPattern().format(blitzStream.records[i].endContext.score)} points", title: Text("${NumberFormat.decimalPattern().format(blitzStream.records[i].endContext.score)} points",
style: TextStyle(fontSize: 18)), style: const TextStyle(fontSize: 18)),
subtitle: Text(timestamp(blitzStream.records[i].timestamp), style: TextStyle(color: Colors.grey, height: 0.85)), subtitle: Text(timestamp(blitzStream.records[i].timestamp), style: const TextStyle(color: Colors.grey, height: 0.85)),
trailing: SpTrailingStats(blitzStream.records[i].endContext) trailing: SpTrailingStats(blitzStream.records[i].endContext)
) )
], ],

View File

@ -60,7 +60,7 @@ class SprintAndBlitzState extends State<SprintAndBlitzView> {
Table( Table(
defaultVerticalAlignment: TableCellVerticalAlignment.middle, defaultVerticalAlignment: TableCellVerticalAlignment.middle,
border: TableBorder.all(color: Colors.grey.shade900), border: TableBorder.all(color: Colors.grey.shade900),
columnWidths: {0: const FixedColumnWidth(48)}, columnWidths: const {0: FixedColumnWidth(48)},
children: [ children: [
TableRow( TableRow(
children: [ children: [

View File

@ -1,4 +1,4 @@
// ignore_for_file: use_build_context_synchronously // ignore_for_file: use_build_context_synchronously, type_literal_in_constant_pattern
import 'dart:io'; import 'dart:io';
import 'package:tetra_stats/data_objects/tetrio_multiplayer_replay.dart'; import 'package:tetra_stats/data_objects/tetrio_multiplayer_replay.dart';

View File

@ -1,3 +1,5 @@
// ignore_for_file: curly_braces_in_flow_control_structures
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:tetra_stats/data_objects/tetrio.dart'; import 'package:tetra_stats/data_objects/tetrio.dart';
import 'package:tetra_stats/utils/numers_formats.dart'; import 'package:tetra_stats/utils/numers_formats.dart';

View File

@ -1,3 +1,5 @@
// ignore_for_file: curly_braces_in_flow_control_structures
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_gauges/gauges.dart'; import 'package:syncfusion_flutter_gauges/gauges.dart';
import 'package:tetra_stats/data_objects/tetrio.dart'; import 'package:tetra_stats/data_objects/tetrio.dart';

View File

@ -5,7 +5,6 @@ import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/utils/relative_timestamps.dart'; import 'package:tetra_stats/utils/relative_timestamps.dart';
import 'package:tetra_stats/utils/text_shadow.dart'; import 'package:tetra_stats/utils/text_shadow.dart';
import 'package:tetra_stats/views/singleplayer_record_view.dart'; import 'package:tetra_stats/views/singleplayer_record_view.dart';
import 'package:tetra_stats/widgets/singleplayer_record.dart';
import 'package:tetra_stats/widgets/sp_trailing_stats.dart'; import 'package:tetra_stats/widgets/sp_trailing_stats.dart';
import 'package:tetra_stats/widgets/text_timestamp.dart'; import 'package:tetra_stats/widgets/text_timestamp.dart';
@ -42,7 +41,7 @@ class RecentSingleplayerGames extends StatelessWidget{
String() => "huh", String() => "huh",
}, },
style: const TextStyle(fontSize: 18)), style: const TextStyle(fontSize: 18)),
subtitle: Text(timestamp(record.timestamp), style: TextStyle(color: Colors.grey, height: 0.85)), subtitle: Text(timestamp(record.timestamp), style: const TextStyle(color: Colors.grey, height: 0.85)),
trailing: SpTrailingStats(record.endContext) trailing: SpTrailingStats(record.endContext)
) )
], ],

View File

@ -147,8 +147,8 @@ class SingleplayerRecord extends StatelessWidget {
"5mblast" => get40lTime(stream!.records[i].endContext.finalTime.inMicroseconds), "5mblast" => get40lTime(stream!.records[i].endContext.finalTime.inMicroseconds),
String() => "huh", String() => "huh",
}, },
style: TextStyle(fontSize: 18)), style: const TextStyle(fontSize: 18)),
subtitle: Text(timestamp(stream!.records[i].timestamp), style: TextStyle(color: Colors.grey, height: 0.85)), subtitle: Text(timestamp(stream!.records[i].timestamp), style: const TextStyle(color: Colors.grey, height: 0.85)),
trailing: SpTrailingStats(stream!.records[i].endContext) trailing: SpTrailingStats(stream!.records[i].endContext)
) )
] ]

View File

@ -5,7 +5,7 @@ import 'package:tetra_stats/utils/numers_formats.dart';
class SpTrailingStats extends StatelessWidget{ class SpTrailingStats extends StatelessWidget{
final EndContextSingle endContext; final EndContextSingle endContext;
const SpTrailingStats(this.endContext); const SpTrailingStats(this.endContext, {super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -1,5 +1,3 @@
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';

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; 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/main.dart'; import 'package:tetra_stats/main.dart';

View File

@ -13,7 +13,7 @@ class TLRatingThingy extends StatelessWidget{
final TetraLeagueAlpha? oldTl; final TetraLeagueAlpha? oldTl;
final double? topTR; final double? topTR;
const TLRatingThingy({required this.userID, required this.tlData, this.oldTl, this.topTR}); const TLRatingThingy({super.key, required this.userID, required this.tlData, this.oldTl, this.topTR});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.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:syncfusion_flutter_gauges/gauges.dart'; import 'package:syncfusion_flutter_gauges/gauges.dart';