Merge pull request #68 from dan63047/master

Update stable
This commit is contained in:
dan63047 2024-02-09 14:42:03 +03:00 committed by GitHub
commit 86d065717b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 765 additions and 531 deletions

View File

@ -4,7 +4,7 @@ Track your and other players stats in TETR.IO
You can [download an app](https://github.com/dan63047/TetraStats/releases), or [use web version](https://ts.dan63.by). You can [download an app](https://github.com/dan63047/TetraStats/releases), or [use web version](https://ts.dan63.by).
![Screenshot of the app 1](https://imgur.com/CKGYyBg.png) ![Screenshot of the app 1](https://imgur.com/e8CYvj3.png)
# Available functionality # Available functionality
- Advanced stats for players - Advanced stats for players
@ -15,6 +15,7 @@ You can [download an app](https://github.com/dan63047/TetraStats/releases), or [
- Comparison to players, rank averages, and player stats from the past - Comparison to players, rank averages, and player stats from the past
- Stats Calculator - Stats Calculator
- Player history in charts - Player history in charts
- Tetra League matches history
# Special thanks # Special thanks
- **kerrmunism** — formulas - **kerrmunism** — formulas

View File

@ -830,7 +830,14 @@ class EndContextMulti {
required this.tertiaryTracking, required this.tertiaryTracking,
required this.extra, required this.extra,
required this.extraTracking, required this.extraTracking,
required this.success}); required this.success}){
nerdStats = NerdStats(secondary, tertiary, extra);
nerdStatsTracking = [for (int i = 0; i < secondaryTracking.length; i++) NerdStats(secondaryTracking[i], tertiaryTracking[i], extraTracking[i])];
estTr = EstTr(secondary, tertiary, extra, nerdStats.app, nerdStats.dss, nerdStats.dsp, nerdStats.gbe);
estTrTracking = [for (int i = 0; i < secondaryTracking.length; i++) EstTr(secondaryTracking[i], tertiaryTracking[i], extraTracking[i], nerdStatsTracking[i].app, nerdStatsTracking[i].dss, nerdStatsTracking[i].dsp, nerdStatsTracking[i].gbe)];
playstyle = Playstyle(secondary, tertiary, nerdStats.app, nerdStats.vsapm, nerdStats.dsp, nerdStats.gbe, estTr.srarea, estTr.statrank);
playstyleTracking = [for (int i = 0; i < secondaryTracking.length; i++) Playstyle(secondaryTracking[i], tertiaryTracking[i], nerdStatsTracking[i].app, nerdStatsTracking[i].vsapm, nerdStatsTracking[i].dsp, nerdStatsTracking[i].gbe, estTrTracking[i].srarea, estTrTracking[i].statrank)];
}
EndContextMulti.fromJson(Map<String, dynamic> json) { EndContextMulti.fromJson(Map<String, dynamic> json) {
userId = json['id'] ?? json['user']['_id']; userId = json['id'] ?? json['user']['_id'];

View File

@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang` /// To regenerate, run: `dart run slang`
/// ///
/// Locales: 2 /// Locales: 2
/// Strings: 1008 (504 per locale) /// Strings: 1018 (509 per locale)
/// ///
/// Built on 2024-01-22 at 19:27 UTC /// Built on 2024-02-08 at 20:30 UTC
// coverage:ignore-file // coverage:ignore-file
// ignore_for_file: type=lint // ignore_for_file: type=lint
@ -165,8 +165,12 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
late final _StringsNewsPartsEn newsParts = _StringsNewsPartsEn._(_root); late final _StringsNewsPartsEn newsParts = _StringsNewsPartsEn._(_root);
String get openSearch => 'Search player'; String get openSearch => 'Search player';
String get closeSearch => 'Close search'; String get closeSearch => 'Close search';
String get searchHint => 'Nickname, ID or Discord userID (with "ds:" prefix)';
String get refresh => 'Refresh'; String get refresh => 'Refresh';
String get fetchAndsaveTLHistory => 'Get player history'; String get fetchAndsaveTLHistory => 'Get player history';
String get fetchAndSaveOldTLmatches => 'Get Tetra League matches history';
String fetchAndsaveTLHistoryResult({required Object number}) => '${number} states was found';
String fetchAndSaveOldTLmatchesResult({required Object number}) => '${number} matches was found';
String get showStoredData => 'Show stored data'; String get showStoredData => 'Show stored data';
String get statsCalc => 'Stats Calculator'; String get statsCalc => 'Stats Calculator';
String get settings => 'Settings'; String get settings => 'Settings';
@ -221,8 +225,8 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
String get importCancelled => 'Operation was cancelled'; String get importCancelled => 'Operation was cancelled';
String get importSuccess => 'Import successful'; String get importSuccess => 'Import successful';
String get yourID => 'Your TETR.IO account'; String get yourID => 'Your TETR.IO account';
String get yourIDAlertTitle => 'Your TETR.IO account nickname or ID'; String get yourIDAlertTitle => 'Your nickname in TETR.IO';
String get yourIDText => 'Every time when app loads, stats of that player will be fetched. Please prefer ID over nickname because nickname can be changed.'; String get yourIDText => 'When app loads, it will retrieve data for this account';
String get language => 'Language'; String get language => 'Language';
String get aboutApp => 'About app'; String get aboutApp => 'About app';
String aboutAppText({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy'; String aboutAppText({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy';
@ -262,7 +266,7 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
String get winChance => 'Win Chance'; String get winChance => 'Win Chance';
String get byGlicko => 'By Glicko'; String get byGlicko => 'By Glicko';
String get byEstTR => 'By Est. TR'; String get byEstTR => 'By Est. TR';
String compareViewNoValues({required Object avgR}) => 'Please, enter username, user ID, APM-PPS-VS values (divider doesn\'t matter, only order matter) or ${avgR} (where R is rank) to both of fields'; String compareViewNoValues({required Object avgR}) => 'Please, enter username, user ID, APM-PPS-VS values (divider doesn\'t matter, only order matter) or ${avgR} (where R is rank) to both fields';
String compareViewWrongValue({required Object value}) => 'Falied to assign ${value}'; String compareViewWrongValue({required Object value}) => 'Falied to assign ${value}';
String get mostRecentOne => 'Most recent one'; String get mostRecentOne => 'Most recent one';
String get yes => 'Yes'; String get yes => 'Yes';
@ -697,6 +701,7 @@ class _StringsErrorsEn {
String connection({required Object code, required Object message}) => 'Some issue with connection: ${code} ${message}'; String connection({required Object code, required Object message}) => 'Some issue with connection: ${code} ${message}';
String get noSuchUser => 'No such user'; String get noSuchUser => 'No such user';
String get history => 'History for that player is missing'; String get history => 'History for that player is missing';
String get p1nkl0bst3rTLmatches => 'No Tetra League matches was found';
String get clientException => 'No internet connection'; String get clientException => 'No internet connection';
String get forbidden => 'Your IP address is blocked.\nChange IP address or reach out to osk'; String get forbidden => 'Your IP address is blocked.\nChange IP address or reach out to osk';
String get tooManyRequests => 'You have been rate limited. Try again later'; String get tooManyRequests => 'You have been rate limited. Try again later';
@ -753,8 +758,12 @@ class _StringsRu implements Translations {
@override late final _StringsNewsPartsRu newsParts = _StringsNewsPartsRu._(_root); @override late final _StringsNewsPartsRu newsParts = _StringsNewsPartsRu._(_root);
@override String get openSearch => 'Искать игрока'; @override String get openSearch => 'Искать игрока';
@override String get closeSearch => 'Закрыть поиск'; @override String get closeSearch => 'Закрыть поиск';
@override String get searchHint => 'Ник, ID или ID в Discord (с префиксом "ds:")';
@override String get refresh => 'Обновить'; @override String get refresh => 'Обновить';
@override String get fetchAndsaveTLHistory => 'Получить историю игрока'; @override String get fetchAndsaveTLHistory => 'Получить историю игрока';
@override String get fetchAndSaveOldTLmatches => 'Получить старые матчи Тетра Лиги';
@override String fetchAndsaveTLHistoryResult({required Object number}) => '${number} состояний было найдено';
@override String fetchAndSaveOldTLmatchesResult({required Object number}) => '${number} старых матчей было найдено';
@override String get showStoredData => 'Показать сохранённые данные'; @override String get showStoredData => 'Показать сохранённые данные';
@override String get statsCalc => 'Калькулятор статистики'; @override String get statsCalc => 'Калькулятор статистики';
@override String get settings => 'Настройки'; @override String get settings => 'Настройки';
@ -809,8 +818,8 @@ class _StringsRu implements Translations {
@override String get importCancelled => 'Операция была отменена'; @override String get importCancelled => 'Операция была отменена';
@override String get importSuccess => 'Успешно импортировано'; @override String get importSuccess => 'Успешно импортировано';
@override String get yourID => 'Ваш аккаунт в TETR.IO'; @override String get yourID => 'Ваш аккаунт в TETR.IO';
@override String get yourIDAlertTitle => 'Никнейм или ID вашего аккаунта в TETR.IO'; @override String get yourIDAlertTitle => 'Ваш ник в TETR.IO';
@override String get yourIDText => 'Каждый раз, когда приложение запускается, приложение будет получать статистику этого игрока. Пожалуйста, отдайте предпочтение ID, так как никнейм можно изменить.'; @override String get yourIDText => 'При запуске приложения оно будет получать статистику этого игрока.';
@override String get language => 'Язык (Language)'; @override String get language => 'Язык (Language)';
@override String get aboutApp => 'О приложении'; @override String get aboutApp => 'О приложении';
@override String aboutAppText({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy'; @override String aboutAppText({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy';
@ -1285,6 +1294,7 @@ class _StringsErrorsRu implements _StringsErrorsEn {
@override String connection({required Object code, required Object message}) => 'Проблема с подключением: ${code} ${message}'; @override String connection({required Object code, required Object message}) => 'Проблема с подключением: ${code} ${message}';
@override String get noSuchUser => 'Нет такого пользователя'; @override String get noSuchUser => 'Нет такого пользователя';
@override String get history => 'История данного игрока отсутствует'; @override String get history => 'История данного игрока отсутствует';
@override String get p1nkl0bst3rTLmatches => 'Старых матчей Тетра Лиги не было найдено';
@override String get clientException => 'Нет соединения с интернетом'; @override String get clientException => 'Нет соединения с интернетом';
@override String get forbidden => 'Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом'; @override String get forbidden => 'Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом';
@override String get tooManyRequests => 'Слишком много запросов. Попробуйте позже'; @override String get tooManyRequests => 'Слишком много запросов. Попробуйте позже';
@ -1333,8 +1343,12 @@ extension on Translations {
case 'newsParts.unknownNews': return ({required Object type}) => 'Unknown news of type ${type}'; case 'newsParts.unknownNews': return ({required Object type}) => 'Unknown news of type ${type}';
case 'openSearch': return 'Search player'; case 'openSearch': return 'Search player';
case 'closeSearch': return 'Close search'; case 'closeSearch': return 'Close search';
case 'searchHint': return 'Nickname, ID or Discord userID (with "ds:" prefix)';
case 'refresh': return 'Refresh'; case 'refresh': return 'Refresh';
case 'fetchAndsaveTLHistory': return 'Get player history'; case 'fetchAndsaveTLHistory': return 'Get player history';
case 'fetchAndSaveOldTLmatches': return 'Get Tetra League matches history';
case 'fetchAndsaveTLHistoryResult': return ({required Object number}) => '${number} states was found';
case 'fetchAndSaveOldTLmatchesResult': return ({required Object number}) => '${number} matches was found';
case 'showStoredData': return 'Show stored data'; case 'showStoredData': return 'Show stored data';
case 'statsCalc': return 'Stats Calculator'; case 'statsCalc': return 'Stats Calculator';
case 'settings': return 'Settings'; case 'settings': return 'Settings';
@ -1389,8 +1403,8 @@ extension on Translations {
case 'importCancelled': return 'Operation was cancelled'; case 'importCancelled': return 'Operation was cancelled';
case 'importSuccess': return 'Import successful'; case 'importSuccess': return 'Import successful';
case 'yourID': return 'Your TETR.IO account'; case 'yourID': return 'Your TETR.IO account';
case 'yourIDAlertTitle': return 'Your TETR.IO account nickname or ID'; case 'yourIDAlertTitle': return 'Your nickname in TETR.IO';
case 'yourIDText': return 'Every time when app loads, stats of that player will be fetched. Please prefer ID over nickname because nickname can be changed.'; case 'yourIDText': return 'When app loads, it will retrieve data for this account';
case 'language': return 'Language'; case 'language': return 'Language';
case 'aboutApp': return 'About app'; case 'aboutApp': return 'About app';
case 'aboutAppText': return ({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy'; case 'aboutAppText': return ({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy';
@ -1430,7 +1444,7 @@ extension on Translations {
case 'winChance': return 'Win Chance'; case 'winChance': return 'Win Chance';
case 'byGlicko': return 'By Glicko'; case 'byGlicko': return 'By Glicko';
case 'byEstTR': return 'By Est. TR'; case 'byEstTR': return 'By Est. TR';
case 'compareViewNoValues': return ({required Object avgR}) => 'Please, enter username, user ID, APM-PPS-VS values (divider doesn\'t matter, only order matter) or ${avgR} (where R is rank) to both of fields'; case 'compareViewNoValues': return ({required Object avgR}) => 'Please, enter username, user ID, APM-PPS-VS values (divider doesn\'t matter, only order matter) or ${avgR} (where R is rank) to both fields';
case 'compareViewWrongValue': return ({required Object value}) => 'Falied to assign ${value}'; case 'compareViewWrongValue': return ({required Object value}) => 'Falied to assign ${value}';
case 'mostRecentOne': return 'Most recent one'; case 'mostRecentOne': return 'Most recent one';
case 'yes': return 'Yes'; case 'yes': return 'Yes';
@ -1540,6 +1554,7 @@ extension on Translations {
case 'errors.connection': return ({required Object code, required Object message}) => 'Some issue with connection: ${code} ${message}'; case 'errors.connection': return ({required Object code, required Object message}) => 'Some issue with connection: ${code} ${message}';
case 'errors.noSuchUser': return 'No such user'; case 'errors.noSuchUser': return 'No such user';
case 'errors.history': return 'History for that player is missing'; case 'errors.history': return 'History for that player is missing';
case 'errors.p1nkl0bst3rTLmatches': return 'No Tetra League matches was found';
case 'errors.clientException': return 'No internet connection'; case 'errors.clientException': return 'No internet connection';
case 'errors.forbidden': return 'Your IP address is blocked.\nChange IP address or reach out to osk'; case 'errors.forbidden': return 'Your IP address is blocked.\nChange IP address or reach out to osk';
case 'errors.tooManyRequests': return 'You have been rate limited. Try again later'; case 'errors.tooManyRequests': return 'You have been rate limited. Try again later';
@ -1847,8 +1862,12 @@ extension on _StringsRu {
case 'newsParts.unknownNews': return ({required Object type}) => 'Неизвестная новость типа ${type}'; case 'newsParts.unknownNews': return ({required Object type}) => 'Неизвестная новость типа ${type}';
case 'openSearch': return 'Искать игрока'; case 'openSearch': return 'Искать игрока';
case 'closeSearch': return 'Закрыть поиск'; case 'closeSearch': return 'Закрыть поиск';
case 'searchHint': return 'Ник, ID или ID в Discord (с префиксом "ds:")';
case 'refresh': return 'Обновить'; case 'refresh': return 'Обновить';
case 'fetchAndsaveTLHistory': return 'Получить историю игрока'; case 'fetchAndsaveTLHistory': return 'Получить историю игрока';
case 'fetchAndSaveOldTLmatches': return 'Получить старые матчи Тетра Лиги';
case 'fetchAndsaveTLHistoryResult': return ({required Object number}) => '${number} состояний было найдено';
case 'fetchAndSaveOldTLmatchesResult': return ({required Object number}) => '${number} старых матчей было найдено';
case 'showStoredData': return 'Показать сохранённые данные'; case 'showStoredData': return 'Показать сохранённые данные';
case 'statsCalc': return 'Калькулятор статистики'; case 'statsCalc': return 'Калькулятор статистики';
case 'settings': return 'Настройки'; case 'settings': return 'Настройки';
@ -1903,8 +1922,8 @@ extension on _StringsRu {
case 'importCancelled': return 'Операция была отменена'; case 'importCancelled': return 'Операция была отменена';
case 'importSuccess': return 'Успешно импортировано'; case 'importSuccess': return 'Успешно импортировано';
case 'yourID': return 'Ваш аккаунт в TETR.IO'; case 'yourID': return 'Ваш аккаунт в TETR.IO';
case 'yourIDAlertTitle': return 'Никнейм или ID вашего аккаунта в TETR.IO'; case 'yourIDAlertTitle': return 'Ваш ник в TETR.IO';
case 'yourIDText': return 'Каждый раз, когда приложение запускается, приложение будет получать статистику этого игрока. Пожалуйста, отдайте предпочтение ID, так как никнейм можно изменить.'; case 'yourIDText': return 'При запуске приложения оно будет получать статистику этого игрока.';
case 'language': return 'Язык (Language)'; case 'language': return 'Язык (Language)';
case 'aboutApp': return 'О приложении'; case 'aboutApp': return 'О приложении';
case 'aboutAppText': return ({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy'; case 'aboutAppText': return ({required Object appName, required Object packageName, required Object version, required Object buildNumber}) => '${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy';
@ -2054,6 +2073,7 @@ extension on _StringsRu {
case 'errors.connection': return ({required Object code, required Object message}) => 'Проблема с подключением: ${code} ${message}'; case 'errors.connection': return ({required Object code, required Object message}) => 'Проблема с подключением: ${code} ${message}';
case 'errors.noSuchUser': return 'Нет такого пользователя'; case 'errors.noSuchUser': return 'Нет такого пользователя';
case 'errors.history': return 'История данного игрока отсутствует'; case 'errors.history': return 'История данного игрока отсутствует';
case 'errors.p1nkl0bst3rTLmatches': return 'Старых матчей Тетра Лиги не было найдено';
case 'errors.clientException': return 'Нет соединения с интернетом'; case 'errors.clientException': return 'Нет соединения с интернетом';
case 'errors.forbidden': return 'Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом'; case 'errors.forbidden': return 'Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом';
case 'errors.tooManyRequests': return 'Слишком много запросов. Попробуйте позже'; case 'errors.tooManyRequests': return 'Слишком много запросов. Попробуйте позже';

View File

@ -27,7 +27,7 @@ const String endContext2 = "endContext2";
const String statesCol = "jsonStates"; const String statesCol = "jsonStates";
const String player1id = "player1id"; const String player1id = "player1id";
const String player2id = "player2id"; const String player2id = "player2id";
/// Table, that store players data, their stats and some moments of time /// Table, that store players data, their stats at some moments of time
const String createTetrioUsersTable = ''' const String createTetrioUsersTable = '''
CREATE TABLE IF NOT EXISTS "tetrioUsers" ( CREATE TABLE IF NOT EXISTS "tetrioUsers" (
"id" TEXT UNIQUE, "id" TEXT UNIQUE,
@ -66,7 +66,7 @@ const String createTetrioTLReplayStats = '''
'''; ''';
class TetrioService extends DB { class TetrioService extends DB {
Map<String, List<TetrioPlayer>> _players = {}; final Map<String, String> _players = {};
// I'm trying to send as less requests, as possible, so i'm caching the results of those requests. // I'm trying to send as less requests, as possible, so i'm caching the results of those requests.
// Usually those maps looks like this: {"cached_until_unix_milliseconds": Object} // Usually those maps looks like this: {"cached_until_unix_milliseconds": Object}
@ -82,9 +82,9 @@ class TetrioService extends DB {
/// We should have only one instanse of this service /// We should have only one instanse of this service
static final TetrioService _shared = TetrioService._sharedInstance(); static final TetrioService _shared = TetrioService._sharedInstance();
factory TetrioService() => _shared; factory TetrioService() => _shared;
late final StreamController<Map<String, List<TetrioPlayer>>> _tetrioStreamController; late final StreamController<Map<String, String>> _tetrioStreamController;
TetrioService._sharedInstance() { TetrioService._sharedInstance() {
_tetrioStreamController = StreamController<Map<String, List<TetrioPlayer>>>.broadcast(onListen: () { _tetrioStreamController = StreamController<Map<String, String>>.broadcast(onListen: () {
_tetrioStreamController.sink.add(_players); _tetrioStreamController.sink.add(_players);
}); });
} }
@ -95,17 +95,15 @@ class TetrioService extends DB {
await _loadPlayers(); await _loadPlayers();
} }
Stream<Map<String, List<TetrioPlayer>>> get allPlayers => _tetrioStreamController.stream; Stream<Map<String, String>> get allPlayers => _tetrioStreamController.stream;
/// Loading and sending to the stream everyone. /// Loading and sending to the stream everyone.
Future<void> _loadPlayers() async { Future<void> _loadPlayers() async {
final allPlayers = await getAllPlayers(); final allPlayers = await getAllPlayerToTrack();
try{ for (var element in allPlayers) {
_players = allPlayers.toList().first; // ??? _players[element] = await getNicknameByID(element);
}catch (e){
developer.log("_loadPlayers: allPlayers.toList().first did oopsie", name: "services/tetrio_crud", error: e);
_players = {};
} }
developer.log("_loadPlayers: $_players", name: "services/tetrio_crud");
_tetrioStreamController.add(_players); _tetrioStreamController.add(_players);
} }
@ -128,7 +126,10 @@ class TetrioService extends DB {
Future<String> getNicknameByID(String id) async { Future<String> getNicknameByID(String id) async {
if (id.length <= 16) return id; // nicknames can be up to 16 symbols in length, that's how i'm differentiate nickname from ids if (id.length <= 16) return id; // nicknames can be up to 16 symbols in length, that's how i'm differentiate nickname from ids
try{ try{
return await getPlayer(id).then((value) => value.last.username); await ensureDbIsOpen();
final db = getDatabaseOrThrow();
var request = await db.query(tetrioUsersTable, limit: 1, where: '$idCol = ?', whereArgs: [id.toLowerCase()]);
return request.first[nickCol] as String;
} catch (e){ } catch (e){
return await fetchPlayer(id).then((value) => value.username); return await fetchPlayer(id).then((value) => value.username);
} }
@ -350,16 +351,8 @@ class TetrioService extends DB {
// trying to dump it to local DB // trying to dump it to local DB
await ensureDbIsOpen(); await ensureDbIsOpen();
final db = getDatabaseOrThrow(); final db = getDatabaseOrThrow();
late List<TetrioPlayer> states; List<TetrioPlayer> states = await getPlayer(id);
try{ if (states.isEmpty) await createPlayer(history.first);
// checking if tetra stats aware about that player TODO: is it necessary?
states = _players[id]!;
}catch(e){
// if somehow not - create it
var player = await fetchPlayer(id);
await createPlayer(player);
states = _players[id]!;
}
states.insertAll(0, history.reversed); states.insertAll(0, history.reversed);
final Map<String, dynamic> statesJson = {}; final Map<String, dynamic> statesJson = {};
for (var e in states) { // making one big json out of this list for (var e in states) { // making one big json out of this list
@ -367,7 +360,6 @@ class TetrioService extends DB {
} }
// and putting it to local DB // and putting it to local DB
await db.update(tetrioUsersTable, {idCol: id, nickCol: nick, statesCol: jsonEncode(statesJson)}, where: '$idCol = ?', whereArgs: [id]); await db.update(tetrioUsersTable, {idCol: id, nickCol: nick, statesCol: jsonEncode(statesJson)}, where: '$idCol = ?', whereArgs: [id]);
_tetrioStreamController.add(_players);
return history; return history;
case 404: case 404:
developer.log("fetchTLHistory: Probably, history doesn't exist", name: "services/tetrio_crud", error: response.statusCode); developer.log("fetchTLHistory: Probably, history doesn't exist", name: "services/tetrio_crud", error: response.statusCode);
@ -393,6 +385,100 @@ class TetrioService extends DB {
} }
} }
/// Docs later
Future<List<TetraLeagueAlphaRecord>> fetchAndSaveOldTLmatches(String userID) async {
Uri url;
if (kIsWeb) {
url = Uri.https('ts.dan63.by', 'oskware_bridge.php', {"endpoint": "TLMatches", "user": userID});
} else {
url = Uri.https('api.p1nkl0bst3r.xyz', 'tlmatches/$userID');
}
try{
final response = await client.get(url);
switch (response.statusCode) {
case 200:
// that one api returns csv instead of json
List<List<dynamic>> csv = const CsvToListConverter().convert(response.body)..removeAt(0);
List<TetraLeagueAlphaRecord> matches = [];
// parsing data into TetraLeagueAlphaRecord objects
for (var entry in csv){
TetraLeagueAlphaRecord match = TetraLeagueAlphaRecord(
replayId: entry[0],
ownId: entry[0], // i gonna disting p1nkl0bst3r entries with it
timestamp: DateTime.parse(entry[1]),
endContext: [
EndContextMulti(
userId: entry[2],
username: entry[3].toString(),
naturalOrder: 0,
inputs: -1,
piecesPlaced: -1,
handling: Handling(arr: -1, das: -1, sdf: -1, dcd: 0, cancel: true, safeLock: true),
points: entry[4],
wins: entry[4],
secondary: entry[6],
secondaryTracking: [],
tertiary: entry[5],
tertiaryTracking: [],
extra: entry[7],
extraTracking: [],
success: true
),
EndContextMulti(
userId: entry[8],
username: entry[9].toString(),
naturalOrder: 1,
inputs: -1,
piecesPlaced: -1,
handling: Handling(arr: -1, das: -1, sdf: -1, dcd: 0, cancel: true, safeLock: true),
points: entry[10],
wins: entry[10],
secondary: entry[12],
secondaryTracking: [],
tertiary: entry[11],
tertiaryTracking: [],
extra: entry[13],
extraTracking: [],
success: false
)
],
replayAvalable: false
);
matches.add(match);
}
// trying to dump it to local DB
TetraLeagueAlphaStream fakeStream = TetraLeagueAlphaStream(userId: userID, records: matches);
saveTLMatchesFromStream(fakeStream);
return matches;
case 404:
developer.log("fetchAndSaveOldTLmatches: Probably, history doesn't exist", name: "services/tetrio_crud", error: response.statusCode);
throw TetrioHistoryNotExist();
case 403:
throw P1nkl0bst3rForbidden();
case 429:
throw P1nkl0bst3rTooManyRequests();
case 418:
throw TetrioOskwareBridgeProblem();
case 500:
case 502:
case 503:
case 504:
throw P1nkl0bst3rInternalProblem();
default:
developer.log("fetchAndSaveOldTLmatches: Failed to fetch history", name: "services/tetrio_crud", error: response.statusCode);
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
}
} on http.ClientException catch (e, s) {
developer.log("$e, $s");
throw http.ClientException(e.message, e.uri);
}
}
/// Retrieves full Tetra League leaderboard from Tetra Channel api. Returns a leaderboard object. Throws an exception if fails to retrieve. /// Retrieves full Tetra League leaderboard from Tetra Channel api. Returns a leaderboard object. Throws an exception if fails to retrieve.
Future<TetrioPlayersLeaderboard> fetchTLLeaderboard() async { Future<TetrioPlayersLeaderboard> fetchTLLeaderboard() async {
try{ try{
@ -638,7 +724,7 @@ class TetrioService extends DB {
await db.delete(tetrioTLReplayStatsTable, where: '$idCol = ?', whereArgs: [rID]); await db.delete(tetrioTLReplayStatsTable, where: '$idCol = ?', whereArgs: [rID]);
} }
/// Retrieves Blitz, 40 Lines and Zen records for a given [playerID] from Tetra Channel api. Returns Map, which contains user id (`user`), /// Retrieves Blitz, 40 Lines and Zen records for a given [userID] from Tetra Channel api. Returns Map, which contains user id (`user`),
/// Blitz (`blitz`) and 40 Lines (`sprint`) record objects and Zen object (`zen`). Throws an exception if fails to retrieve. /// Blitz (`blitz`) and 40 Lines (`sprint`) record objects and Zen object (`zen`). Throws an exception if fails to retrieve.
Future<Map<String, dynamic>> fetchRecords(String userID) async { Future<Map<String, dynamic>> fetchRecords(String userID) async {
try{ try{
@ -717,9 +803,7 @@ class TetrioService extends DB {
// converting to json and store // converting to json and store
final Map<String, dynamic> statesJson = {(tetrioPlayer.state.millisecondsSinceEpoch ~/ 1000).toString(): tetrioPlayer.toJson()}; final Map<String, dynamic> statesJson = {(tetrioPlayer.state.millisecondsSinceEpoch ~/ 1000).toString(): tetrioPlayer.toJson()};
db.insert(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)}); db.insert(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)});
_players.addEntries({ _players.addEntries({tetrioPlayer.userId: tetrioPlayer.username}.entries);
tetrioPlayer.userId: [tetrioPlayer]
}.entries);
_tetrioStreamController.add(_players); _tetrioStreamController.add(_players);
} }
@ -747,7 +831,6 @@ class TetrioService extends DB {
await ensureDbIsOpen(); await ensureDbIsOpen();
final db = getDatabaseOrThrow(); final db = getDatabaseOrThrow();
final players = await db.query(tetrioUsersToTrackTable); final players = await db.query(tetrioUsersToTrackTable);
developer.log("getAllPlayerToTrack: $players", name: "services/tetrio_crud");
return players.map((noteRow) => noteRow["id"].toString()); return players.map((noteRow) => noteRow["id"].toString());
} }
@ -759,25 +842,22 @@ class TetrioService extends DB {
if (deletedPlayer != 1) { if (deletedPlayer != 1) {
throw CouldNotDeletePlayer(); throw CouldNotDeletePlayer();
} else { } else {
// _players.removeWhere((key, value) => key == id); _players.removeWhere((key, value) => key == id);
// _tetrioStreamController.add(_players); _tetrioStreamController.add(_players);
} }
} }
/// Saves state (which is [tetrioPlayer]) to the local database. /// Saves state (which is [tetrioPlayer]) to the local database.
Future<void> storeState(TetrioPlayer tetrioPlayer) async { Future<void> storeState(TetrioPlayer tetrioPlayer) async {
await ensureDbIsOpen(); // if tetrio player doesn't have entry in database - just calling different function
final db = getDatabaseOrThrow(); List<TetrioPlayer> states = await getPlayer(tetrioPlayer.userId);
late List<TetrioPlayer> states; if (states.isEmpty) {
try { // retrieveing previous states
states = _players[tetrioPlayer.userId]!;
} catch (e) { // nothing found - player not exist - create them
await createPlayer(tetrioPlayer); await createPlayer(tetrioPlayer);
states = await getPlayer(tetrioPlayer.userId); return;
} }
// we not going to add state, that is same, as the previous // we not going to add state, that is same, as the previous
bool test = _players[tetrioPlayer.userId]!.last.isSameState(tetrioPlayer); bool test = states.last.isSameState(tetrioPlayer);
if (test == false) states.add(tetrioPlayer); if (test == false) states.add(tetrioPlayer);
// Making map of the states // Making map of the states
@ -786,21 +866,21 @@ class TetrioService extends DB {
// Saving in format: {"unix_seconds": json_of_state} // Saving in format: {"unix_seconds": json_of_state}
statesJson.addEntries({(e.state.millisecondsSinceEpoch ~/ 1000).toString(): e.toJson()}.entries); statesJson.addEntries({(e.state.millisecondsSinceEpoch ~/ 1000).toString(): e.toJson()}.entries);
} }
// Rewrite our database // Rewrite our database
await ensureDbIsOpen();
final db = getDatabaseOrThrow();
await db.update(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)}, await db.update(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)},
where: '$idCol = ?', whereArgs: [tetrioPlayer.userId]); where: '$idCol = ?', whereArgs: [tetrioPlayer.userId]);
_players[tetrioPlayer.userId]!.add(tetrioPlayer);
_tetrioStreamController.add(_players);
} }
/// Remove state (which is [tetrioPlayer]) from the local database /// Remove state (which is [tetrioPlayer]) from the local database
Future<void> deleteState(TetrioPlayer tetrioPlayer) async { Future<void> deleteState(TetrioPlayer tetrioPlayer) async {
await ensureDbIsOpen(); await ensureDbIsOpen();
final db = getDatabaseOrThrow(); final db = getDatabaseOrThrow();
late List<TetrioPlayer> states; List<TetrioPlayer> states = await getPlayer(tetrioPlayer.userId);
// removing state from map that contain every state of each user // removing state from map that contain every state of each user
_players[tetrioPlayer.userId]!.removeWhere((element) => element.state == tetrioPlayer.state); states.removeWhere((element) => element.state == tetrioPlayer.state);
states = _players[tetrioPlayer.userId]!;
// Making map of the states (without deleted one) // Making map of the states (without deleted one)
final Map<String, dynamic> statesJson = {}; final Map<String, dynamic> statesJson = {};
@ -810,7 +890,6 @@ class TetrioService extends DB {
// Rewriting database entry with new json // Rewriting database entry with new json
await db.update(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)}, await db.update(tetrioUsersTable, {idCol: tetrioPlayer.userId, nickCol: tetrioPlayer.username, statesCol: jsonEncode(statesJson)},
where: '$idCol = ?', whereArgs: [tetrioPlayer.userId]); where: '$idCol = ?', whereArgs: [tetrioPlayer.userId]);
_players[tetrioPlayer.userId]!.add(tetrioPlayer);
_tetrioStreamController.add(_players); _tetrioStreamController.add(_players);
} }
@ -830,7 +909,7 @@ class TetrioService extends DB {
rawStates.forEach((k, v) => states.add(TetrioPlayer.fromJson(v, DateTime.fromMillisecondsSinceEpoch(int.parse(k) * 1000), id, results.first[nickCol] as String))); rawStates.forEach((k, v) => states.add(TetrioPlayer.fromJson(v, DateTime.fromMillisecondsSinceEpoch(int.parse(k) * 1000), id, results.first[nickCol] as String)));
// updating the stream // updating the stream
_players.removeWhere((key, value) => key == id); _players.removeWhere((key, value) => key == id);
_players.addEntries({states.last.userId: states}.entries); _players.addEntries({states.last.userId: states.last.username}.entries);
_tetrioStreamController.add(_players); _tetrioStreamController.add(_players);
return states; return states;
} }
@ -940,20 +1019,18 @@ class TetrioService extends DB {
} }
} }
/// Basucally, retrieves whole [tetrioUsersTable] and do stupud things idk /// Retrieves whole [tetrioUsersTable] and returns Map with [TetrioPlayer] objects of everyone in database
/// Returns god knows what. TODO: Rewrite this shit Future<Map<String, List<TetrioPlayer>>> getAllPlayers() async {
Future<Iterable<Map<String, List<TetrioPlayer>>>> getAllPlayers() async {
await ensureDbIsOpen(); await ensureDbIsOpen();
final db = getDatabaseOrThrow(); final db = getDatabaseOrThrow();
final players = await db.query(tetrioUsersTable); final players = await db.query(tetrioUsersTable);
Map<String, List<TetrioPlayer>> data = {}; Map<String, List<TetrioPlayer>> data = {};
return players.map((row) { for (var entry in players){
// what the fuck am i doing here? var test = json.decode(entry['jsonStates'] as String);
var test = json.decode(row['jsonStates'] as String);
List<TetrioPlayer> states = []; List<TetrioPlayer> states = [];
test.forEach((k, v) => states.add(TetrioPlayer.fromJson(v, DateTime.fromMillisecondsSinceEpoch(int.parse(k) * 1000), row[idCol] as String, row[nickCol] as String))); test.forEach((k, v) => states.add(TetrioPlayer.fromJson(v, DateTime.fromMillisecondsSinceEpoch(int.parse(k) * 1000), entry[idCol] as String, entry[nickCol] as String)));
data.addEntries({states.last.userId: states}.entries); data.addEntries({states.last.userId: states}.entries);
}
return data; return data;
});
} }
} }

View File

@ -0,0 +1,6 @@
import 'package:flutter/material.dart';
const List<Shadow> textShadow = <Shadow>[ // man i love this shadow
Shadow(offset: Offset(0.0, 0.0), blurRadius: 3.0, color: Colors.black),
Shadow(offset: Offset(0.0, 0.0), blurRadius: 8.0, color: Colors.black),
];

View File

@ -1,5 +1,3 @@
// 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';
@ -70,8 +68,7 @@ class CompareState extends State<CompareView> {
theRedSide = [null, null, average]; theRedSide = [null, null, average];
return setState(() {}); return setState(() {});
}on Exception { }on Exception {
ScaffoldMessenger.of(context) if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.compareViewWrongValue(value: user))));
.showSnackBar(SnackBar(content: Text(t.compareViewWrongValue(value: user))));
return; return;
} }
} }
@ -126,8 +123,7 @@ class CompareState extends State<CompareView> {
} }
theRedSide = [player, dStates, player.tlSeason1]; theRedSide = [player, dStates, player.tlSeason1];
} on Exception { } on Exception {
ScaffoldMessenger.of(context) if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.compareViewWrongValue(value: user))));
.showSnackBar(SnackBar(content: Text(t.compareViewWrongValue(value: user))));
} }
_justUpdate(); _justUpdate();
} }
@ -146,8 +142,7 @@ class CompareState extends State<CompareView> {
theGreenSide = [null, null, average]; theGreenSide = [null, null, average];
return setState(() {}); return setState(() {});
}on Exception { }on Exception {
ScaffoldMessenger.of(context) if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Falied to assign $user")));
.showSnackBar(SnackBar(content: Text("Falied to assign $user")));
return; return;
} }
} }
@ -202,8 +197,7 @@ class CompareState extends State<CompareView> {
} }
theGreenSide = [player, dStates, player.tlSeason1]; theGreenSide = [player, dStates, player.tlSeason1];
} on Exception { } on Exception {
ScaffoldMessenger.of(context) if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Falied to assign $user")));
.showSnackBar(SnackBar(content: Text("Falied to assign $user")));
} }
_justUpdate(); _justUpdate();
} }
@ -213,19 +207,16 @@ class CompareState extends State<CompareView> {
theGreenSide[2] = user.tlSeason1;}); theGreenSide[2] = user.tlSeason1;});
} }
double getWinrateByTR(double yourGlicko, double yourRD, double notyourGlicko, double getWinrateByTR(double yourGlicko, double yourRD, double notyourGlicko,double notyourRD) {
double notyourRD) {
return ((1 / return ((1 /
(1 + (1 + pow(10,
pow(
10,
(notyourGlicko - yourGlicko) / (notyourGlicko - yourGlicko) /
(400 * (400 * sqrt(1 + (3 * pow(0.0057564273, 2) *
sqrt(1 + (pow(yourRD, 2) + pow(notyourRD, 2)) / pow(pi, 2)
(3 * )))
pow(0.0057564273, 2) * )
(pow(yourRD, 2) + pow(notyourRD, 2)) / )
pow(pi, 2)))))))); ));
} }
void _justUpdate() { void _justUpdate() {

View File

@ -16,9 +16,11 @@ 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/main.dart' show prefs; import 'package:tetra_stats/main.dart' show prefs;
import 'package:tetra_stats/services/crud_exceptions.dart'; import 'package:tetra_stats/services/crud_exceptions.dart';
import 'package:tetra_stats/utils/text_shadow.dart';
import 'package:tetra_stats/views/ranks_averages_view.dart' show RankAveragesView; import 'package:tetra_stats/views/ranks_averages_view.dart' show RankAveragesView;
import 'package:tetra_stats/views/tl_leaderboard_view.dart' show TLLeaderboardView; import 'package:tetra_stats/views/tl_leaderboard_view.dart' show TLLeaderboardView;
import 'package:tetra_stats/views/tl_match_view.dart' show TlMatchResultView; import 'package:tetra_stats/views/tl_match_view.dart' show TlMatchResultView;
import 'package:tetra_stats/widgets/search_box.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/user_thingy.dart'; import 'package:tetra_stats/widgets/user_thingy.dart';
@ -40,10 +42,6 @@ final NumberFormat secs = NumberFormat("00.###");
final NumberFormat _f2 = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 2); final NumberFormat _f2 = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 2);
final NumberFormat _f4 = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 4); final NumberFormat _f4 = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 4);
final DateFormat _dateFormat = DateFormat.yMMMd(LocaleSettings.currentLocale.languageCode).add_Hms(); final DateFormat _dateFormat = DateFormat.yMMMd(LocaleSettings.currentLocale.languageCode).add_Hms();
final List<Shadow> textShadow = <Shadow>[ // man i love this shadow
const Shadow(offset: Offset(0.0, 0.0), blurRadius: 3.0, color: Colors.black),
const Shadow(offset: Offset(0.0, 0.0), blurRadius: 8.0, color: Colors.black),
];
class MainView extends StatefulWidget { class MainView extends StatefulWidget {
@ -74,19 +72,6 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
late TabController _tabController; late TabController _tabController;
late bool fixedScroll; late bool fixedScroll;
Widget _searchTextField() {
return TextField(
maxLength: 25,
autocorrect: false,
enableSuggestions: false,
decoration: const InputDecoration(counter: Offstage()),
style: TextStyle(shadows: textShadow),
onSubmitted: (String value) {
changePlayer(value);
},
);
}
@override @override
void initState() { void initState() {
initDB(); initDB();
@ -116,10 +101,10 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
/// That function initiate search of data about [player]. If [fetchHistory] is true, /// That function initiate search of data about [player]. If [fetchHistory] is true,
/// also attempting to retrieve players history. Can trow an Exception if fails /// also attempting to retrieve players history. Can trow an Exception if fails
void changePlayer(String player, {bool fetchHistory = false}) { void changePlayer(String player, {bool fetchHistory = false, bool fetchTLmatches = false}) {
setState(() { setState(() {
_searchFor = player; _searchFor = player;
me = fetch(_searchFor, fetchHistory: fetchHistory); me = fetch(_searchFor, fetchHistory: fetchHistory, fetchTLmatches: fetchTLmatches);
}); });
} }
@ -128,13 +113,14 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
} }
/// Retrieves data from 3 different Tetra Channel API endpoints + 1 endpoint from p1nkl0bst3r's API /// Retrieves data from 3 different Tetra Channel API endpoints + 1 endpoint from p1nkl0bst3r's API
/// using [nickOrID] of player. If [fetchHistory] is true, also retrieves players history from p1nkl0bst3r's API. /// using [nickOrID] of player.
/// ///
/// Returns list which contains players object, his TL records, previous states, TL matches, previos TL state, if player tracked (bool), news entries and topTR. /// If [fetchHistory] is true, also retrieves players history from p1nkl0bst3r's API. If [fetchTLmatches] is true, also retrieves players old Tetra League
/// matches from p1nkl0bst3r's API. Returns list which contains [TetrioPlayer], his records, previous states, TL matches, previous TL state,
/// if player tracked (bool), news entries and topTR.
/// ///
/// If at least one request to some endpoint fails, whole function will throw an exception. /// If at least one request to Tetra Channel API fails, whole function will throw an exception.
/// TODO: Change this behavior Future<List> fetch(String nickOrID, {bool fetchHistory = false, bool fetchTLmatches = false}) async {
Future<List> fetch(String nickOrID, {bool fetchHistory = false}) async {
TetrioPlayer me; TetrioPlayer me;
// If user trying to search with discord id // If user trying to search with discord id
@ -173,13 +159,28 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
TetraLeagueAlpha? compareWith; TetraLeagueAlpha? compareWith;
Set<TetraLeagueAlpha> uniqueTL = {}; Set<TetraLeagueAlpha> uniqueTL = {};
tlMatches = tlStream.records; tlMatches = tlStream.records;
var storedRecords = await teto.getTLMatchesbyPlayerID(me.userId); // get old matches List<TetraLeagueAlphaRecord> storedRecords = await teto.getTLMatchesbyPlayerID(me.userId); // get old matches
if (isTracking){ // if tracked - save data to local DB if (isTracking){ // if tracked - save data to local DB
await teto.storeState(me); await teto.storeState(me);
await teto.saveTLMatchesFromStream(tlStream); await teto.saveTLMatchesFromStream(tlStream);
} }
// building list of TL matches // building list of TL matches
if(fetchTLmatches) {
try{
List<TetraLeagueAlphaRecord> oldMatches = await teto.fetchAndSaveOldTLmatches(_searchFor);
storedRecords.addAll(oldMatches);
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.fetchAndSaveOldTLmatchesResult(number: oldMatches.length))));
}on TetrioHistoryNotExist{
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rTLmatches)));
}on P1nkl0bst3rForbidden {
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rForbidden)));
}on P1nkl0bst3rInternalProblem {
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rinternal)));
}on P1nkl0bst3rTooManyRequests{
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rTooManyRequests)));
}
}
for (var match in storedRecords) { for (var match in storedRecords) {
// add stored match to list only if it missing from retrived ones // add stored match to list only if it missing from retrived ones
if (!tlMatches.contains(match)) tlMatches.add(match); if (!tlMatches.contains(match)) tlMatches.add(match);
@ -192,7 +193,21 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
}); });
// Handling history // Handling history
if(fetchHistory) await teto.fetchAndsaveTLHistory(_searchFor); // Retrieve if needed if(fetchHistory){
try{
var history = await teto.fetchAndsaveTLHistory(_searchFor); // Retrieve if needed
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.fetchAndsaveTLHistoryResult(number: history.length))));
}on TetrioHistoryNotExist{
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.noHistorySaved)));
}on P1nkl0bst3rForbidden {
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rForbidden)));
}on P1nkl0bst3rInternalProblem {
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rinternal)));
}on P1nkl0bst3rTooManyRequests{
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.p1nkl0bst3rTooManyRequests)));
}
}
states.addAll(await teto.getPlayer(me.userId)); states.addAll(await teto.getPlayer(me.userId));
for (var element in states) { // For graphs I need only unique entries for (var element in states) { // For graphs I need only unique entries
if (uniqueTL.isNotEmpty && uniqueTL.last != element.tlSeason1) uniqueTL.add(element.tlSeason1); if (uniqueTL.isNotEmpty && uniqueTL.last != element.tlSeason1) uniqueTL.add(element.tlSeason1);
@ -235,11 +250,12 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final t = Translations.of(context); final t = Translations.of(context);
bool bigScreen = MediaQuery.of(context).size.width > 768;
return Scaffold( return Scaffold(
drawer: widget.player == null ? NavDrawer(changePlayer) : null, // Side menu hidden if player provided drawer: widget.player == null ? NavDrawer(changePlayer) : null, // Side menu hidden if player provided
drawerEdgeDragWidth: MediaQuery.of(context).size.width * 0.2, // 20% of left side of the screen used of Drawer gesture drawerEdgeDragWidth: MediaQuery.of(context).size.width * 0.2, // 20% of left side of the screen used of Drawer gesture
appBar: AppBar( appBar: AppBar(
title: _showSearchBar ? _searchTextField() : Text(widget.title, style: TextStyle(shadows: textShadow)), title: _showSearchBar ? SearchBox(onSubmit: changePlayer, bigScreen: bigScreen) : Text(widget.title, style: const TextStyle(shadows: textShadow)),
backgroundColor: Colors.black, backgroundColor: Colors.black,
actions: widget.player == null ? [ // search bar and PopupMenuButton hidden if player provided TODO: Subject to change actions: widget.player == null ? [ // search bar and PopupMenuButton hidden if player provided TODO: Subject to change
_showSearchBar _showSearchBar
@ -271,6 +287,10 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
value: "history", value: "history",
child: Text(t.fetchAndsaveTLHistory), child: Text(t.fetchAndsaveTLHistory),
), ),
PopupMenuItem(
value: "TLmatches",
child: Text(t.fetchAndSaveOldTLmatches),
),
PopupMenuItem( PopupMenuItem(
value: "/states", value: "/states",
child: Text(t.showStoredData), child: Text(t.showStoredData),
@ -292,6 +312,9 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
case "history": case "history":
changePlayer(_searchFor, fetchHistory: true); changePlayer(_searchFor, fetchHistory: true);
break; break;
case "TLmatches":
changePlayer(_searchFor, fetchTLmatches: true);
break;
default: default:
context.go(value); context.go(value);
} }
@ -309,7 +332,6 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
case ConnectionState.active: case ConnectionState.active:
return const Center(child: CircularProgressIndicator(color: Colors.white)); return const Center(child: CircularProgressIndicator(color: Colors.white));
case ConnectionState.done: case ConnectionState.done:
//bool bigScreen = MediaQuery.of(context).size.width > 1024;
if (snapshot.hasData) { if (snapshot.hasData) {
return RefreshIndicator( return RefreshIndicator(
onRefresh: () { onRefresh: () {
@ -373,15 +395,6 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
var err = snapshot.error as ConnectionIssue; var err = snapshot.error as ConnectionIssue;
errText = t.errors.connection(code: err.code, message: err.message); errText = t.errors.connection(code: err.code, message: err.message);
break; break;
case P1nkl0bst3rForbidden:
errText = t.errors.p1nkl0bst3rForbidden;
break;
case P1nkl0bst3rTooManyRequests:
errText = t.errors.p1nkl0bst3rTooManyRequests;
break;
case P1nkl0bst3rInternalProblem:
errText = kIsWeb ? t.errors.p1nkl0bst3rinternalWebVersion : t.errors.p1nkl0bst3rinternal;
break;
case TetrioHistoryNotExist: case TetrioHistoryNotExist:
errText = t.errors.history; errText = t.errors.history;
break; break;
@ -466,8 +479,9 @@ class _NavDrawerState extends State<NavDrawer> {
case ConnectionState.waiting: case ConnectionState.waiting:
case ConnectionState.active: case ConnectionState.active:
final allPlayers = (snapshot.data != null) final allPlayers = (snapshot.data != null)
? snapshot.data as Map<String, List<TetrioPlayer>> ? snapshot.data as Map<String, String>
: <String, List<TetrioPlayer>>{}; : <String, String>{};
allPlayers.remove(prefs.getString("player") ?? "6098518e3d5155e6ec429cdc"); // player from the home button will be delisted
List<String> keys = allPlayers.keys.toList(); List<String> keys = allPlayers.keys.toList();
return NestedScrollView( return NestedScrollView(
headerSliverBuilder: (context, value) { headerSliverBuilder: (context, value) {
@ -522,7 +536,7 @@ class _NavDrawerState extends State<NavDrawer> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
var i = allPlayers.length-1-index; // Last players in this map are most recent ones, they are gonna be shown at the top. var i = allPlayers.length-1-index; // Last players in this map are most recent ones, they are gonna be shown at the top.
return ListTile( return ListTile(
title: Text(allPlayers[keys[i]]?.last.username as String), // Takes last known username from list of states title: Text(allPlayers[keys[i]]??keys[i]), // Takes last known username from list of states
onTap: () { onTap: () {
widget.changePlayer(keys[i]); // changes to chosen player widget.changePlayer(keys[i]); // changes to chosen player
Navigator.of(context).pop(); // and closes itself. Navigator.of(context).pop(); // and closes itself.
@ -548,16 +562,26 @@ class _TLRecords extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (data.isEmpty) return Center(child: Text(t.noRecords, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28)));
bool bigScreen = MediaQuery.of(context).size.width > 768; bool bigScreen = MediaQuery.of(context).size.width > 768;
return ListView( // TODO: Redo using ListView.builder() return ListView.builder(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
children: (data.isNotEmpty) itemCount: data.length,
? [for (var value in data) ListTile( itemBuilder: (BuildContext context, int index) {
leading: Text("${value.endContext.firstWhere((element) => element.userId == userID).points} : ${value.endContext.firstWhere((element) => element.userId != userID).points}", var accentColor = data[index].endContext.firstWhere((element) => element.userId == userID).success ? Colors.green : Colors.red;
style: bigScreen ? const TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 28) : return Container(
const TextStyle(fontSize: 28)), decoration: BoxDecoration(
title: Text("vs. ${value.endContext.firstWhere((element) => element.userId != userID).username}"), gradient: LinearGradient(
subtitle: Text(_dateFormat.format(value.timestamp)), stops: const [0, 0.05],
colors: [accentColor, Colors.transparent]
)
),
child: ListTile(
// tileColor: data[index].endContext.firstWhere((element) => element.userId == userID).success ? Colors.green[900] : Colors.red[900],
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)),
title: Text("vs. ${data[index].endContext.firstWhere((element) => element.userId != userID).username}"),
subtitle: Text(_dateFormat.format(data[index].timestamp)),
trailing: Table(defaultColumnWidth: const IntrinsicColumnWidth(), trailing: Table(defaultColumnWidth: const IntrinsicColumnWidth(),
defaultVerticalAlignment: TableCellVerticalAlignment.baseline, defaultVerticalAlignment: TableCellVerticalAlignment.baseline,
textBaseline: TextBaseline.alphabetic, textBaseline: TextBaseline.alphabetic,
@ -566,19 +590,14 @@ class _TLRecords extends StatelessWidget {
2: FixedColumnWidth(50), 2: FixedColumnWidth(50),
}, },
children: [ children: [
TableRow(children: [Text(_f2.format(value.endContext.firstWhere((element) => element.userId == userID).secondary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(value.endContext.firstWhere((element) => element.userId != userID).secondary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" APM", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]), TableRow(children: [Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId == userID).secondary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId != userID).secondary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" APM", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]),
TableRow(children: [Text(_f2.format(value.endContext.firstWhere((element) => element.userId == userID).tertiary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(value.endContext.firstWhere((element) => element.userId != userID).tertiary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" PPS", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]), TableRow(children: [Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId == userID).tertiary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId != userID).tertiary), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" PPS", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]),
TableRow(children: [Text(_f2.format(value.endContext.firstWhere((element) => element.userId == userID).extra), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(value.endContext.firstWhere((element) => element.userId != userID).extra), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" VS", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]), TableRow(children: [Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId == userID).extra), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" :", style: TextStyle(height: 1.1)), Text(_f2.format(data[index].endContext.firstWhere((element) => element.userId != userID).extra), textAlign: TextAlign.right, style: const TextStyle(height: 1.1)), const Text(" VS", textAlign: TextAlign.right, style: TextStyle(height: 1.1))]),
],), ],),
onTap: (){Navigator.push( onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => TlMatchResultView(record: data[index], initPlayerId: userID))),
context,
MaterialPageRoute(
builder: (context) => TlMatchResultView(record: value, initPlayerId: userID),
), ),
);},
)]
: [Center(child: Text(t.noRecords, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28)))],
); );
});
} }
} }
@ -620,7 +639,7 @@ class _HistoryChartThigy extends StatefulWidget{
final NumberFormat yFormat; final NumberFormat yFormat;
/// Implements graph for the _History widget. Requires [data] which is a list of dots for the graph. [yAxisTitle] used to keep track of changes. /// Implements graph for the _History widget. Requires [data] which is a list of dots for the graph. [yAxisTitle] used to keep track of changes.
/// [bigScreen] tells if screen wide enough, [leftSpace] sets size, reserved for titles on the left from the graph and [yFormat] sets numer format /// [bigScreen] tells if screen wide enough, [leftSpace] sets size, reserved for titles on the left from the graph and [yFormat] sets number format
/// for left titles /// for left titles
const _HistoryChartThigy({required this.data, required this.yAxisTitle, required this.bigScreen, required this.leftSpace, required this.yFormat}); const _HistoryChartThigy({required this.data, required this.yAxisTitle, required this.bigScreen, required this.leftSpace, required this.yFormat});
@ -896,6 +915,7 @@ class _RecordThingy extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (record == null) return Center(child: Text(t.noRecord, textAlign: TextAlign.center, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28)));
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
bool bigScreen = constraints.maxWidth > 768; bool bigScreen = constraints.maxWidth > 768;
return ListView.builder( return ListView.builder(
@ -903,7 +923,7 @@ class _RecordThingy extends StatelessWidget {
itemCount: 1, itemCount: 1,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Column( return Column(
children: (record != null) ? [ children: [
// show mode title // show mode title
if (record!.stream.contains("40l")) Text(t.sprint, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)) if (record!.stream.contains("40l")) Text(t.sprint, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28))
else if (record!.stream.contains("blitz")) Text(t.blitz, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)), else if (record!.stream.contains("blitz")) Text(t.blitz, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
@ -1055,9 +1075,6 @@ class _RecordThingy extends StatelessWidget {
), ),
), ),
] ]
: [ // If no record, show this
Text(t.noRecord, textAlign: TextAlign.center, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28))
],
); );
}); });
}); });

View File

@ -7,7 +7,8 @@ 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' show MainView, textShadow; import 'package:tetra_stats/views/main_view.dart' show MainView;
import 'package:tetra_stats/utils/text_shadow.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
var _chartsShortTitlesDropdowns = <DropdownMenuItem>[for (MapEntry e in chartsShortTitles.entries) DropdownMenuItem(value: e.key, child: Text(e.value),)]; var _chartsShortTitlesDropdowns = <DropdownMenuItem>[for (MapEntry e in chartsShortTitles.entries) DropdownMenuItem(value: e.key, child: Text(e.value),)];

View File

@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'package:tetra_stats/data_objects/tetrio.dart';
import 'package:tetra_stats/main.dart' show packageInfo; import 'package:tetra_stats/main.dart' show packageInfo;
import 'package:file_selector/file_selector.dart'; import 'package:file_selector/file_selector.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
@ -66,6 +67,11 @@ class SettingsState extends State<SettingsView> {
await _setDefaultNickname(player); await _setDefaultNickname(player);
} }
Future<void> _removePlayer() async {
await prefs.remove('player');
await _setDefaultNickname("dan63047");
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final t = Translations.of(context); final t = Translations.of(context);
@ -212,9 +218,21 @@ class SettingsState extends State<SettingsView> {
), ),
TextButton( TextButton(
child: Text(t.popupActions.submit), child: Text(t.popupActions.submit),
onPressed: () { onPressed: () async {
_setPlayer(_playertext.text.toLowerCase().trim()); if (_playertext.text.isEmpty) {
_removePlayer();
Navigator.of(context).pop(); Navigator.of(context).pop();
return;
}
late TetrioPlayer user;
try{
user = await teto.fetchPlayer(_playertext.text.toLowerCase().trim());
}on Exception{
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.errors.noSuchUser)));
return;
}
_setPlayer(user.userId);
if (context.mounted) Navigator.of(context).pop();
setState(() {}); setState(() {});
}, },
) )

View File

@ -195,6 +195,9 @@ class TlMatchResultState extends State<TlMatchResultView> {
), ),
), ),
), ),
if (widget.record.ownId == widget.record.replayId) SliverToBoxAdapter(
child: Center(child: Text(t.p1nkl0bst3rAlert, textAlign: TextAlign.center)),
),
SliverToBoxAdapter(child: FutureBuilder(future: replayData, builder: (context, snapshot) { SliverToBoxAdapter(child: FutureBuilder(future: replayData, builder: (context, snapshot) {
switch(snapshot.connectionState){ switch(snapshot.connectionState){
case ConnectionState.none: case ConnectionState.none:
@ -470,8 +473,8 @@ class TlMatchResultState extends State<TlMatchResultView> {
) )
], ],
), ),
const Divider(), if (widget.record.ownId != widget.record.replayId) const Divider(),
Column( if (widget.record.ownId != widget.record.replayId) Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.only(bottom: 16),

View File

@ -70,14 +70,15 @@ class TrackedPlayersState extends State<TrackedPlayersView> {
), ),
backgroundColor: Colors.black, backgroundColor: Colors.black,
body: SafeArea( body: SafeArea(
child: StreamBuilder( child: FutureBuilder(
stream: teto.allPlayers, future: teto.getAllPlayers(),
builder: (context, snapshot) { builder: (context, snapshot) {
switch (snapshot.connectionState) { switch (snapshot.connectionState) {
case ConnectionState.none: case ConnectionState.none:
return const Center(child: Text('none case of StreamBuilder'));
case ConnectionState.waiting: case ConnectionState.waiting:
case ConnectionState.active: case ConnectionState.active:
return const Center(child: CircularProgressIndicator(color: Colors.white));
case ConnectionState.done:
final allPlayers = (snapshot.data != null) ? snapshot.data as Map<String, List<TetrioPlayer>> : <String, List<TetrioPlayer>>{}; final allPlayers = (snapshot.data != null) ? snapshot.data as Map<String, List<TetrioPlayer>> : <String, List<TetrioPlayer>>{};
List<String> keys = allPlayers.keys.toList(); List<String> keys = allPlayers.keys.toList();
return NestedScrollView( return NestedScrollView(
@ -114,7 +115,7 @@ class TrackedPlayersState extends State<TrackedPlayersView> {
icon: const Icon(Icons.delete_forever), icon: const Icon(Icons.delete_forever),
onPressed: () { onPressed: () {
String nn = allPlayers[keys[index]]!.last.username; String nn = allPlayers[keys[index]]!.last.username;
teto.deletePlayer(keys[index]); setState(() {teto.deletePlayer(keys[index]);});
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.trackedPlayersStatesDeleted(nickname: nn)))); ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(t.trackedPlayersStatesDeleted(nickname: nn))));
}, },
), ),
@ -128,10 +129,6 @@ class TrackedPlayersState extends State<TrackedPlayersView> {
}, },
); );
})); }));
case ConnectionState.done:
return const Center(
child: Text('done case of StreamBuilder',
style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 42), textAlign: TextAlign.center));
} }
})), })),
); );

View File

@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/utils/text_shadow.dart';
const int length = 25;
final TextEditingController controller = TextEditingController();
class SearchBox extends StatefulWidget {
final Function onSubmit;
final bool bigScreen;
const SearchBox({required this.onSubmit, required this.bigScreen, super.key});
@override
State<StatefulWidget> createState() => _SearchBoxState();
}
class _SearchBoxState extends State<SearchBox>{
late FocusNode textbotFocus;
@override
void initState() {
textbotFocus = FocusNode();
controller.addListener(() {
setState(() {});
});
super.initState();
}
@override
void dispose(){
controller.clear();
textbotFocus.dispose();
super.dispose();
}
Color getColorOfCounter(){
// if limit was hit
if ((length - controller.text.length) <= 0) return Colors.redAccent;
// if input more than 16 symbols (username length limit)
if ((length - controller.text.length) < 9) return Colors.yellowAccent;
// if we good (we not)
return Colors.grey;
}
double getFontSizeOfCounter(){
return (length - controller.text.length) <= 0 ? 24 : 16;
}
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
return Row(
mainAxisSize: MainAxisSize.min,
//alignment: Alignment.centerRight,
children: [
Expanded(
child: TextField(
controller: controller,
maxLength: length,
focusNode: textbotFocus,
autofocus: true,
autocorrect: false,
enableSuggestions: false,
decoration: InputDecoration(
counter: const Offstage(),
hintText: widget.bigScreen ? t.searchHint : null,
),
style: const TextStyle(shadows: textShadow, fontSize: 18),
onSubmitted: (String value) {
widget.onSubmit(value);
textbotFocus.unfocus();
},
),
),
AnimatedDefaultTextStyle(
style: TextStyle(
fontFamily: "Eurostile Round",
fontSize: getFontSizeOfCounter(),
color: getColorOfCounter(),
shadows: textShadow
),
duration: Durations.short4,
curve: Curves.easeOutCirc,
child: Text("${length - controller.text.length}")
)
]
);
}
}

View File

@ -47,6 +47,7 @@ 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);
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;
return ListView.builder( return ListView.builder(
@ -54,8 +55,7 @@ class _TLThingyState extends State<TLThingy> {
itemCount: 1, itemCount: 1,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Column( return Column(
children: (currentTl.gamesPlayed > 0) children: [
? [
if (widget.showTitle) Text(t.tetraLeague, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)), if (widget.showTitle) Text(t.tetraLeague, style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)),
if (oldTl != null) Text(t.comparingWith(newDate: dateFormat.format(currentTl.timestamp), oldDate: dateFormat.format(oldTl!.timestamp)), if (oldTl != null) Text(t.comparingWith(newDate: dateFormat.format(currentTl.timestamp), oldDate: dateFormat.format(oldTl!.timestamp)),
textAlign: TextAlign.center,), textAlign: TextAlign.center,),
@ -409,9 +409,6 @@ class _TLThingyState extends State<TLThingy> {
), ),
if (currentTl.nerdStats != null) Graphs(currentTl.apm!, currentTl.pps!, currentTl.vs!, currentTl.nerdStats!, currentTl.playstyle!) if (currentTl.nerdStats != null) Graphs(currentTl.apm!, currentTl.pps!, currentTl.vs!, currentTl.nerdStats!, currentTl.playstyle!)
] ]
: [
Center(child: Text(widget.guest ? t.anonTL : widget.bot ? t.botTL : t.neverPlayedTL, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28), textAlign: TextAlign.center,)),
],
); );
}, },
); );

View File

@ -5,7 +5,7 @@ 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/compare_view.dart'; import 'package:tetra_stats/views/compare_view.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:tetra_stats/views/main_view.dart' show textShadow; import 'package:tetra_stats/utils/text_shadow.dart';
import 'dart:developer' as developer; import 'dart:developer' as developer;
import 'package:tetra_stats/widgets/stat_sell_num.dart'; import 'package:tetra_stats/widgets/stat_sell_num.dart';

View File

@ -2,7 +2,7 @@ name: tetra_stats
description: Track your and other player stats in TETR.IO description: Track your and other player stats in TETR.IO
publish_to: 'none' publish_to: 'none'
version: 1.4.0+14 version: 1.4.1+15
environment: environment:
sdk: '>=3.0.0' sdk: '>=3.0.0'

View File

@ -30,8 +30,12 @@
}, },
"openSearch": "Search player", "openSearch": "Search player",
"closeSearch": "Close search", "closeSearch": "Close search",
"searchHint": "Nickname, ID or Discord userID (with \"ds:\" prefix)",
"refresh": "Refresh", "refresh": "Refresh",
"fetchAndsaveTLHistory": "Get player history", "fetchAndsaveTLHistory": "Get player history",
"fetchAndSaveOldTLmatches": "Get Tetra League matches history",
"fetchAndsaveTLHistoryResult": "${number} states was found",
"fetchAndSaveOldTLmatchesResult": "${number} matches was found",
"showStoredData": "Show stored data", "showStoredData": "Show stored data",
"statsCalc": "Stats Calculator", "statsCalc": "Stats Calculator",
"settings": "Settings", "settings": "Settings",
@ -86,8 +90,8 @@
"importCancelled": "Operation was cancelled", "importCancelled": "Operation was cancelled",
"importSuccess": "Import successful", "importSuccess": "Import successful",
"yourID": "Your TETR.IO account", "yourID": "Your TETR.IO account",
"yourIDAlertTitle": "Your TETR.IO account nickname or ID", "yourIDAlertTitle": "Your nickname in TETR.IO",
"yourIDText": "Every time when app loads, stats of that player will be fetched. Please prefer ID over nickname because nickname can be changed.", "yourIDText": "When app loads, it will retrieve data for this account",
"language": "Language", "language": "Language",
"aboutApp": "About app", "aboutApp": "About app",
"aboutAppText": "${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy", "aboutAppText": "${appName} (${packageName}) Version ${version} Build ${buildNumber}\n\nDeveloped by dan63047\nFormulas provided by kerrmunism\nHistory provided by p1nkl0bst3r\nTETR.IO replay grabber API by szy",
@ -127,7 +131,7 @@
"winChance": "Win Chance", "winChance": "Win Chance",
"byGlicko": "By Glicko", "byGlicko": "By Glicko",
"byEstTR": "By Est. TR", "byEstTR": "By Est. TR",
"compareViewNoValues": "Please, enter username, user ID, APM-PPS-VS values (divider doesn't matter, only order matter) or $avgR (where R is rank) to both of fields", "compareViewNoValues": "Please, enter username, user ID, APM-PPS-VS values (divider doesn't matter, only order matter) or $avgR (where R is rank) to both fields",
"compareViewWrongValue": "Falied to assign ${value}", "compareViewWrongValue": "Falied to assign ${value}",
"mostRecentOne": "Most recent one", "mostRecentOne": "Most recent one",
"yes": "Yes", "yes": "Yes",
@ -246,6 +250,7 @@
"connection": "Some issue with connection: ${code} ${message}", "connection": "Some issue with connection: ${code} ${message}",
"noSuchUser": "No such user", "noSuchUser": "No such user",
"history": "History for that player is missing", "history": "History for that player is missing",
"p1nkl0bst3rTLmatches": "No Tetra League matches was found",
"clientException": "No internet connection", "clientException": "No internet connection",
"forbidden": "Your IP address is blocked.\nChange IP address or reach out to osk", "forbidden": "Your IP address is blocked.\nChange IP address or reach out to osk",
"tooManyRequests": "You have been rate limited. Try again later", "tooManyRequests": "You have been rate limited. Try again later",

View File

@ -30,8 +30,12 @@
}, },
"openSearch": "Искать игрока", "openSearch": "Искать игрока",
"closeSearch": "Закрыть поиск", "closeSearch": "Закрыть поиск",
"searchHint": "Ник, ID или ID в Discord (с префиксом \"ds:\")",
"refresh": "Обновить", "refresh": "Обновить",
"fetchAndsaveTLHistory": "Получить историю игрока", "fetchAndsaveTLHistory": "Получить историю игрока",
"fetchAndSaveOldTLmatches": "Получить старые матчи Тетра Лиги",
"fetchAndsaveTLHistoryResult": "${number} состояний было найдено",
"fetchAndSaveOldTLmatchesResult": "${number} старых матчей было найдено",
"showStoredData": "Показать сохранённые данные", "showStoredData": "Показать сохранённые данные",
"statsCalc": "Калькулятор статистики", "statsCalc": "Калькулятор статистики",
"settings": "Настройки", "settings": "Настройки",
@ -86,8 +90,8 @@
"importCancelled": "Операция была отменена", "importCancelled": "Операция была отменена",
"importSuccess": "Успешно импортировано", "importSuccess": "Успешно импортировано",
"yourID": "Ваш аккаунт в TETR.IO", "yourID": "Ваш аккаунт в TETR.IO",
"yourIDAlertTitle": "Никнейм или ID вашего аккаунта в TETR.IO", "yourIDAlertTitle": "Ваш ник в TETR.IO",
"yourIDText": "Каждый раз, когда приложение запускается, приложение будет получать статистику этого игрока. Пожалуйста, отдайте предпочтение ID, так как никнейм можно изменить.", "yourIDText": "При запуске приложения оно будет получать статистику этого игрока.",
"language": "Язык (Language)", "language": "Язык (Language)",
"aboutApp": "О приложении", "aboutApp": "О приложении",
"aboutAppText": "${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy", "aboutAppText": "${appName} (${packageName}) Версия ${version} Сборка ${buildNumber}\n\nРазработал dan63047\nФормулы предоставил kerrmunism\nИсторию предоставляет p1nkl0bst3r\nВозможность скачивать повторы из TETR.IO предоставляет szy",
@ -246,6 +250,7 @@
"connection": "Проблема с подключением: ${code} ${message}", "connection": "Проблема с подключением: ${code} ${message}",
"noSuchUser": "Нет такого пользователя", "noSuchUser": "Нет такого пользователя",
"history": "История данного игрока отсутствует", "history": "История данного игрока отсутствует",
"p1nkl0bst3rTLmatches": "Старых матчей Тетра Лиги не было найдено",
"clientException": "Нет соединения с интернетом", "clientException": "Нет соединения с интернетом",
"forbidden": "Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом", "forbidden": "Ваш IP адрес заблокирован.\nСмените IP адрес или свяжитесь с osk-ом",
"tooManyRequests": "Слишком много запросов. Попробуйте позже", "tooManyRequests": "Слишком много запросов. Попробуйте позже",

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB