Design changes

Colors in TL matches list, new search bar
This commit is contained in:
dan63047 2024-02-09 00:39:54 +03:00
parent 638b2f6850
commit 7688b49ef9
10 changed files with 487 additions and 396 deletions

View File

@ -4,9 +4,9 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 2
/// Strings: 1016 (508 per locale)
/// Strings: 1018 (509 per locale)
///
/// Built on 2024-02-06 at 20:25 UTC
/// Built on 2024-02-08 at 20:30 UTC
// coverage:ignore-file
// ignore_for_file: type=lint
@ -165,6 +165,7 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
late final _StringsNewsPartsEn newsParts = _StringsNewsPartsEn._(_root);
String get openSearch => 'Search player';
String get closeSearch => 'Close search';
String get searchHint => 'Nickname, ID or Discord userID (with "ds:" prefix)';
String get refresh => 'Refresh';
String get fetchAndsaveTLHistory => 'Get player history';
String get fetchAndSaveOldTLmatches => 'Get Tetra League matches history';
@ -265,7 +266,7 @@ class Translations implements BaseTranslations<AppLocale, Translations> {
String get winChance => 'Win Chance';
String get byGlicko => 'By Glicko';
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 get mostRecentOne => 'Most recent one';
String get yes => 'Yes';
@ -757,6 +758,7 @@ class _StringsRu implements Translations {
@override late final _StringsNewsPartsRu newsParts = _StringsNewsPartsRu._(_root);
@override String get openSearch => 'Искать игрока';
@override String get closeSearch => 'Закрыть поиск';
@override String get searchHint => 'Ник, ID или ID в Discord (с префиксом "ds:")';
@override String get refresh => 'Обновить';
@override String get fetchAndsaveTLHistory => 'Получить историю игрока';
@override String get fetchAndSaveOldTLmatches => 'Получить старые матчи Тетра Лиги';
@ -1341,6 +1343,7 @@ extension on Translations {
case 'newsParts.unknownNews': return ({required Object type}) => 'Unknown news of type ${type}';
case 'openSearch': return 'Search player';
case 'closeSearch': return 'Close search';
case 'searchHint': return 'Nickname, ID or Discord userID (with "ds:" prefix)';
case 'refresh': return 'Refresh';
case 'fetchAndsaveTLHistory': return 'Get player history';
case 'fetchAndSaveOldTLmatches': return 'Get Tetra League matches history';
@ -1441,7 +1444,7 @@ extension on Translations {
case 'winChance': return 'Win Chance';
case 'byGlicko': return 'By Glicko';
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 'mostRecentOne': return 'Most recent one';
case 'yes': return 'Yes';
@ -1859,6 +1862,7 @@ extension on _StringsRu {
case 'newsParts.unknownNews': return ({required Object type}) => 'Неизвестная новость типа ${type}';
case 'openSearch': return 'Искать игрока';
case 'closeSearch': return 'Закрыть поиск';
case 'searchHint': return 'Ник, ID или ID в Discord (с префиксом "ds:")';
case 'refresh': return 'Обновить';
case 'fetchAndsaveTLHistory': return 'Получить историю игрока';
case 'fetchAndSaveOldTLmatches': return 'Получить старые матчи Тетра Лиги';

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

@ -16,9 +16,11 @@ import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/services/tetrio_crud.dart';
import 'package:tetra_stats/main.dart' show prefs;
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/tl_leaderboard_view.dart' show TLLeaderboardView;
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/tl_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 _f4 = NumberFormat.decimalPatternDigits(locale: LocaleSettings.currentLocale.languageCode, decimalDigits: 4);
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 {
@ -74,19 +72,6 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
late TabController _tabController;
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
void initState() {
initDB();
@ -265,11 +250,12 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
final t = Translations.of(context);
bool bigScreen = MediaQuery.of(context).size.width > 768;
return Scaffold(
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
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,
actions: widget.player == null ? [ // search bar and PopupMenuButton hidden if player provided TODO: Subject to change
_showSearchBar
@ -346,7 +332,6 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
case ConnectionState.active:
return const Center(child: CircularProgressIndicator(color: Colors.white));
case ConnectionState.done:
//bool bigScreen = MediaQuery.of(context).size.width > 1024;
if (snapshot.hasData) {
return RefreshIndicator(
onRefresh: () {
@ -577,16 +562,24 @@ class _TLRecords extends StatelessWidget {
@override
Widget build(BuildContext context) {
bool bigScreen = MediaQuery.of(context).size.width > 768;
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;
return ListView.builder(
physics: const AlwaysScrollableScrollPhysics(),
itemCount: data.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
var accentColor = data[index].endContext.firstWhere((element) => element.userId == userID).success ? Colors.green : Colors.red;
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
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) :
const TextStyle(fontSize: 28)),
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(),
@ -602,6 +595,7 @@ class _TLRecords extends StatelessWidget {
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(context, MaterialPageRoute(builder: (context) => TlMatchResultView(record: data[index], initPlayerId: userID))),
),
);
});
}
@ -645,7 +639,7 @@ class _HistoryChartThigy extends StatefulWidget{
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.
/// [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
const _HistoryChartThigy({required this.data, required this.yAxisTitle, required this.bigScreen, required this.leftSpace, required this.yFormat});
@ -921,6 +915,7 @@ class _RecordThingy extends StatelessWidget {
@override
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) {
bool bigScreen = constraints.maxWidth > 768;
return ListView.builder(
@ -928,7 +923,7 @@ class _RecordThingy extends StatelessWidget {
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Column(
children: (record != null) ? [
children: [
// show mode title
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)),
@ -1080,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:tetra_stats/data_objects/tetrio.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';
var _chartsShortTitlesDropdowns = <DropdownMenuItem>[for (MapEntry e in chartsShortTitles.entries) DropdownMenuItem(value: e.key, child: Text(e.value),)];

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
Widget build(BuildContext 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) {
bool bigScreen = constraints.maxWidth > 768;
return ListView.builder(
@ -54,8 +55,7 @@ class _TLThingyState extends State<TLThingy> {
itemCount: 1,
itemBuilder: (BuildContext context, int index) {
return Column(
children: (currentTl.gamesPlayed > 0)
? [
children: [
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)),
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!)
]
: [
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/views/compare_view.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 '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
publish_to: 'none'
version: 1.4.0+14
version: 1.4.1+15
environment:
sdk: '>=3.0.0'

View File

@ -30,6 +30,7 @@
},
"openSearch": "Search player",
"closeSearch": "Close search",
"searchHint": "Nickname, ID or Discord userID (with \"ds:\" prefix)",
"refresh": "Refresh",
"fetchAndsaveTLHistory": "Get player history",
"fetchAndSaveOldTLmatches": "Get Tetra League matches history",
@ -130,7 +131,7 @@
"winChance": "Win Chance",
"byGlicko": "By Glicko",
"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}",
"mostRecentOne": "Most recent one",
"yes": "Yes",

View File

@ -30,6 +30,7 @@
},
"openSearch": "Искать игрока",
"closeSearch": "Закрыть поиск",
"searchHint": "Ник, ID или ID в Discord (с префиксом \"ds:\")",
"refresh": "Обновить",
"fetchAndsaveTLHistory": "Получить историю игрока",
"fetchAndSaveOldTLmatches": "Получить старые матчи Тетра Лиги",