Accent color + Links for singleplayer records

This commit is contained in:
dan63047 2024-06-16 01:49:57 +03:00
parent 0f90358160
commit 10da3b5b6a
7 changed files with 90 additions and 49 deletions

View File

@ -27,7 +27,7 @@ import 'package:go_router/go_router.dart';
late final PackageInfo packageInfo; late final PackageInfo packageInfo;
late SharedPreferences prefs; late SharedPreferences prefs;
late TetrioService teto; late TetrioService teto;
ColorScheme sheme = const ColorScheme.dark(primary: Colors.cyanAccent, secondary: Colors.white); ThemeData theme = ThemeData(fontFamily: 'Eurostile Round', colorScheme: const ColorScheme.dark(primary: Colors.cyanAccent, secondary: Colors.white), scaffoldBackgroundColor: Colors.black);
Future<dynamic> computeIsolate(Future Function() function) async { Future<dynamic> computeIsolate(Future Function() function) async {
final receivePort = ReceivePort(); final receivePort = ReceivePort();
@ -61,10 +61,6 @@ class _IsolateData {
}); });
} }
void setAccentColor(Color color){ // does this thing work??? yes??? no???
sheme = ColorScheme.dark(primary: color, secondary: Colors.white);
}
final router = GoRouter( final router = GoRouter(
initialLocation: "/", initialLocation: "/",
routes: [ routes: [
@ -160,9 +156,21 @@ void main() async {
)); ));
} }
class MyApp extends StatelessWidget { class MyApp extends StatefulWidget {
const MyApp({super.key}); const MyApp({super.key});
@override
State<MyApp> createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
void setAccentColor(Color color){ // does this thing work??? yes??? no???
setState(() {
theme = theme.copyWith(colorScheme: theme.colorScheme.copyWith(primary: color));
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp.router( return MaterialApp.router(
@ -174,11 +182,7 @@ class MyApp extends StatelessWidget {
locale: TranslationProvider.of(context).flutterLocale, locale: TranslationProvider.of(context).flutterLocale,
supportedLocales: AppLocaleUtils.supportedLocales, supportedLocales: AppLocaleUtils.supportedLocales,
localizationsDelegates: GlobalMaterialLocalizations.delegates, localizationsDelegates: GlobalMaterialLocalizations.delegates,
theme: ThemeData( theme: theme
fontFamily: 'Eurostile Round',
colorScheme: sheme,
scaffoldBackgroundColor: Colors.black
)
); );
} }
} }

View File

@ -1,8 +1,9 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:tetra_stats/views/settings_view.dart' show subtitleStyle; import 'package:tetra_stats/views/settings_view.dart' show subtitleStyle;
import 'package:tetra_stats/main.dart' show prefs; import 'package:tetra_stats/main.dart' show MyApp, MyAppState, prefs, setAccentColor;
import 'package:tetra_stats/gen/strings.g.dart'; import 'package:tetra_stats/gen/strings.g.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
@ -87,36 +88,33 @@ class CustomizationState extends State<CustomizationView> {
body: SafeArea( body: SafeArea(
child: ListView( child: ListView(
children: [ children: [
// ListTile( ListTile(
// title: const Text("Accent color"), title: const Text("Accent color"),
// trailing: ColorIndicator(HSVColor.fromColor(Theme.of(context).colorScheme.primary)), trailing: ColorIndicator(HSVColor.fromColor(Theme.of(context).colorScheme.primary), width: 25, height: 25),
// onTap: () { onTap: () {
// showDialog( showDialog(
// context: context, context: context,
// builder: (BuildContext context) => AlertDialog( builder: (BuildContext context) => AlertDialog(
// title: const Text('Pick an accent color'), title: const Text('Pick an accent color'),
// content: SingleChildScrollView( content: SingleChildScrollView(
// child: ColorPicker( child: ColorPicker(
// pickerColor: pickerColor, pickerColor: pickerColor,
// onColorChanged: changeColor, onColorChanged: changeColor,
// ), ),
// ), ),
// actions: <Widget>[ actions: <Widget>[
// ElevatedButton( ElevatedButton(
// child: const Text('Set'), child: const Text('Set'),
// onPressed: () { onPressed: () {
// setState(() { setState(() {
// setAccentColor(pickerColor); context.findAncestorStateOfType<MyAppState>()?.setAccentColor(pickerColor);
// }); });
// Navigator.of(context).pop(); Navigator.of(context).pop();
// }, },
// ), ),
// ])); ]));
// }), }
// const ListTile( ),
// title: Text("Font"),
// subtitle: Text("Not implemented"),
// ),
// const ListTile( // const ListTile(
// title: Text("Stats Table in TL mathes list"), // title: Text("Stats Table in TL mathes list"),
// subtitle: Text("Not implemented"), // subtitle: Text("Not implemented"),

View File

@ -17,6 +17,7 @@ import 'package:tetra_stats/gen/strings.g.dart';
import 'package:tetra_stats/main.dart' show prefs, teto; import 'package:tetra_stats/main.dart' show prefs, teto;
import 'package:tetra_stats/services/crud_exceptions.dart'; import 'package:tetra_stats/services/crud_exceptions.dart';
import 'package:tetra_stats/utils/numers_formats.dart'; import 'package:tetra_stats/utils/numers_formats.dart';
import 'package:tetra_stats/utils/open_in_browser.dart';
import 'package:tetra_stats/utils/relative_timestamps.dart'; import 'package:tetra_stats/utils/relative_timestamps.dart';
import 'package:tetra_stats/utils/text_shadow.dart'; import 'package:tetra_stats/utils/text_shadow.dart';
import 'package:tetra_stats/views/singleplayer_record_view.dart'; import 'package:tetra_stats/views/singleplayer_record_view.dart';
@ -948,6 +949,7 @@ class _HistoryChartThigyState extends State<_HistoryChartThigy> {
primaryYAxis: const NumericAxis( primaryYAxis: const NumericAxis(
rangePadding: ChartRangePadding.additional, rangePadding: ChartRangePadding.additional,
), ),
margin: const EdgeInsets.all(0),
series: <CartesianSeries>[ series: <CartesianSeries>[
if (_gamesPlayedInsteadOfDateAndTime) StepLineSeries<_HistoryChartSpot, int>( if (_gamesPlayedInsteadOfDateAndTime) StepLineSeries<_HistoryChartSpot, int>(
enableTooltip: true, enableTooltip: true,
@ -958,12 +960,13 @@ class _HistoryChartThigyState extends State<_HistoryChartThigy> {
opacity: _smooth ? 0 : 1, opacity: _smooth ? 0 : 1,
xValueMapper: (_HistoryChartSpot data, _) => data.gamesPlayed, xValueMapper: (_HistoryChartSpot data, _) => data.gamesPlayed,
yValueMapper: (_HistoryChartSpot data, _) => data.stat, yValueMapper: (_HistoryChartSpot data, _) => data.stat,
color: Theme.of(context).colorScheme.primary,
trendlines:<Trendline>[ trendlines:<Trendline>[
Trendline( Trendline(
isVisible: _smooth, isVisible: _smooth,
period: (widget.data.length/175).floor(), period: (widget.data.length/175).floor(),
type: TrendlineType.movingAverage, type: TrendlineType.movingAverage,
color: Colors.blue) color: Theme.of(context).colorScheme.primary)
], ],
) )
else StepLineSeries<_HistoryChartSpot, DateTime>( else StepLineSeries<_HistoryChartSpot, DateTime>(
@ -975,12 +978,13 @@ class _HistoryChartThigyState extends State<_HistoryChartThigy> {
opacity: _smooth ? 0 : 1, opacity: _smooth ? 0 : 1,
xValueMapper: (_HistoryChartSpot data, _) => data.timestamp, xValueMapper: (_HistoryChartSpot data, _) => data.timestamp,
yValueMapper: (_HistoryChartSpot data, _) => data.stat, yValueMapper: (_HistoryChartSpot data, _) => data.stat,
color: Theme.of(context).colorScheme.primary,
trendlines:<Trendline>[ trendlines:<Trendline>[
Trendline( Trendline(
isVisible: _smooth, isVisible: _smooth,
period: (widget.data.length/175).floor(), period: (widget.data.length/175).floor(),
type: TrendlineType.movingAverage, type: TrendlineType.movingAverage,
color: Colors.blue) color: Theme.of(context).colorScheme.primary)
], ],
), ),
], ],
@ -1029,9 +1033,9 @@ class _TwoRecordsThingy extends StatelessWidget {
} }
return SingleChildScrollView(child: Padding( return SingleChildScrollView(child: Padding(
padding: const EdgeInsets.only(top: 20.0), padding: const EdgeInsets.only(top: 20.0),
child: Row( child: Wrap(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, alignment: WrapAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: WrapCrossAlignment.start,
children: [ children: [
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -1084,6 +1088,15 @@ class _TwoRecordsThingy extends StatelessWidget {
if (sprint != null) FinesseThingy(sprint?.endContext.finesse, sprint?.endContext.finessePercentage), if (sprint != null) FinesseThingy(sprint?.endContext.finesse, sprint?.endContext.finessePercentage),
if (sprint != null) LineclearsThingy(sprint!.endContext.clears, sprint!.endContext.lines, sprint!.endContext.holds, sprint!.endContext.tSpins), if (sprint != null) LineclearsThingy(sprint!.endContext.clears, sprint!.endContext.lines, sprint!.endContext.holds, sprint!.endContext.tSpins),
if (sprint != null) Text("${sprint!.endContext.inputs} KP • ${f2.format(sprint!.endContext.kps)} KPS"), if (sprint != null) Text("${sprint!.endContext.inputs} KP • ${f2.format(sprint!.endContext.kps)} KPS"),
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.start,
spacing: 20,
children: [
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${sprint!.replayId}"));}, child: Text("Open replay in TETR.IO")),
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${sprint!.replayId}"));}, child: Text("Download replay")),
],
),
if (sprintStream.records.length > 1) SizedBox( if (sprintStream.records.length > 1) SizedBox(
width: 400, width: 400,
child: Column( child: Column(
@ -1161,6 +1174,15 @@ class _TwoRecordsThingy extends StatelessWidget {
if (blitz != null) FinesseThingy(blitz?.endContext.finesse, blitz?.endContext.finessePercentage), if (blitz != null) FinesseThingy(blitz?.endContext.finesse, blitz?.endContext.finessePercentage),
if (blitz != null) LineclearsThingy(blitz!.endContext.clears, blitz!.endContext.lines, blitz!.endContext.holds, blitz!.endContext.tSpins), if (blitz != null) LineclearsThingy(blitz!.endContext.clears, blitz!.endContext.lines, blitz!.endContext.holds, blitz!.endContext.tSpins),
if (blitz != null) Text("${blitz!.endContext.piecesPlaced} P • ${blitz!.endContext.inputs} KP • ${f2.format(blitz!.endContext.kpp)} KPP • ${f2.format(blitz!.endContext.kps)} KPS"), if (blitz != null) Text("${blitz!.endContext.piecesPlaced} P • ${blitz!.endContext.inputs} KP • ${f2.format(blitz!.endContext.kpp)} KPP • ${f2.format(blitz!.endContext.kps)} KPS"),
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.start,
spacing: 20,
children: [
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${blitz!.replayId}"));}, child: Text("Open replay in TETR.IO")),
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${blitz!.replayId}"));}, child: Text("Download replay")),
],
),
if (blitzStream.records.length > 1) SizedBox( if (blitzStream.records.length > 1) SizedBox(
width: 400, width: 400,
child: Column( child: Column(

View File

@ -33,6 +33,7 @@ class SingleplayerRecordView extends StatelessWidget {
Column( Column(
children: [ children: [
SingleplayerRecord(record: record, hideTitle: true), SingleplayerRecord(record: record, hideTitle: true),
// TODO: Insert replay link here
] ]
) )
], ],

View File

@ -332,6 +332,8 @@ class Graphs extends StatelessWidget{
}, },
dataSets: [ dataSets: [
RadarDataSet( RadarDataSet(
fillColor: Theme.of(context).colorScheme.primary.withAlpha(100),
borderColor: Theme.of(context).colorScheme.primary,
dataEntries: [ dataEntries: [
RadarEntry(value: apm * apmWeight), RadarEntry(value: apm * apmWeight),
RadarEntry(value: pps * ppsWeight), RadarEntry(value: pps * ppsWeight),
@ -399,6 +401,8 @@ class Graphs extends StatelessWidget{
}, },
dataSets: [ dataSets: [
RadarDataSet( RadarDataSet(
fillColor: Theme.of(context).colorScheme.primary.withAlpha(100),
borderColor: Theme.of(context).colorScheme.primary,
dataEntries: [ dataEntries: [
RadarEntry(value: playstyle.opener), RadarEntry(value: playstyle.opener),
RadarEntry(value: playstyle.stride), RadarEntry(value: playstyle.stride),
@ -454,6 +458,8 @@ class Graphs extends StatelessWidget{
}, },
dataSets: [ dataSets: [
RadarDataSet( RadarDataSet(
fillColor: Theme.of(context).colorScheme.primary.withAlpha(100),
borderColor: Theme.of(context).colorScheme.primary,
dataEntries: [ dataEntries: [
RadarEntry(value: attack), RadarEntry(value: attack),
RadarEntry(value: speed), RadarEntry(value: speed),

View File

@ -3,6 +3,7 @@ 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/utils/numers_formats.dart'; import 'package:tetra_stats/utils/numers_formats.dart';
import 'package:tetra_stats/utils/open_in_browser.dart';
import 'package:tetra_stats/utils/relative_timestamps.dart'; import 'package:tetra_stats/utils/relative_timestamps.dart';
import 'package:tetra_stats/utils/text_shadow.dart'; import 'package:tetra_stats/utils/text_shadow.dart';
import 'package:tetra_stats/views/singleplayer_record_view.dart'; import 'package:tetra_stats/views/singleplayer_record_view.dart';
@ -125,6 +126,15 @@ class SingleplayerRecord extends StatelessWidget {
LineclearsThingy(record!.endContext.clears, record!.endContext.lines, record!.endContext.holds, record!.endContext.tSpins), LineclearsThingy(record!.endContext.clears, record!.endContext.lines, record!.endContext.holds, record!.endContext.tSpins),
if (record!.endContext.gameType == "40l") Text("${record!.endContext.inputs} KP • ${f2.format(record!.endContext.kps)} KPS"), if (record!.endContext.gameType == "40l") Text("${record!.endContext.inputs} KP • ${f2.format(record!.endContext.kps)} KPS"),
if (record!.endContext.gameType == "blitz") Text("${record!.endContext.piecesPlaced} P • ${record!.endContext.inputs} KP • ${f2.format(record!.endContext.kpp)} KPP • ${f2.format(record!.endContext.kps)} KPS"), if (record!.endContext.gameType == "blitz") Text("${record!.endContext.piecesPlaced} P • ${record!.endContext.inputs} KP • ${f2.format(record!.endContext.kpp)} KPP • ${f2.format(record!.endContext.kps)} KPS"),
Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.start,
spacing: 20,
children: [
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://tetr.io/#r:${record!.replayId}"));}, child: Text("Open replay in TETR.IO")),
TextButton(onPressed: (){launchInBrowser(Uri.parse("https://inoue.szy.lol/api/replay/${record!.replayId}"));}, child: Text("Download replay")),
],
),
if (stream != null && stream!.records.length > 1) for(int i = 1; i < stream!.records.length; i++) ListTile( if (stream != null && stream!.records.length > 1) for(int i = 1; i < stream!.records.length; i++) ListTile(
onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: stream!.records[i]))), onTap: () => Navigator.push(context, MaterialPageRoute(builder: (context) => SingleplayerRecordView(record: stream!.records[i]))),
leading: Text("#${i+1}", leading: Text("#${i+1}",

View File

@ -82,8 +82,8 @@ class TLProgress extends StatelessWidget{
maximum: 1, maximum: 1,
interval: 1, interval: 1,
ranges: [ ranges: [
if (previousRankTRcutoff != null && nextRankTRcutoff != null) LinearGaugeRange(endValue: getBarTR(tlData.rating)!, color: Colors.cyanAccent, position: LinearElementPosition.cross) if (previousRankTRcutoff != null && nextRankTRcutoff != null) LinearGaugeRange(endValue: getBarTR(tlData.rating)!, color: Theme.of(context).colorScheme.primary, position: LinearElementPosition.cross)
else if (tlData.standing != -1) LinearGaugeRange(endValue: getBarPosition(), color: Colors.cyanAccent, position: LinearElementPosition.cross), else if (tlData.standing != -1) LinearGaugeRange(endValue: getBarPosition(), color: Theme.of(context).colorScheme.primary, position: LinearElementPosition.cross),
if (previousRankTRcutoff != null && previousRankTRcutoffTarget != null) LinearGaugeRange(endValue: getBarTR(previousRankTRcutoffTarget!)!, color: Colors.greenAccent, position: LinearElementPosition.inside), if (previousRankTRcutoff != null && previousRankTRcutoffTarget != null) LinearGaugeRange(endValue: getBarTR(previousRankTRcutoffTarget!)!, color: Colors.greenAccent, position: LinearElementPosition.inside),
if (nextRankTRcutoff != null && nextRankTRcutoffTarget != null && previousRankTRcutoff != null) LinearGaugeRange(startValue: getBarTR(nextRankTRcutoffTarget!)!, endValue: 1, color: Colors.yellowAccent, position: LinearElementPosition.inside) if (nextRankTRcutoff != null && nextRankTRcutoffTarget != null && previousRankTRcutoff != null) LinearGaugeRange(startValue: getBarTR(nextRankTRcutoffTarget!)!, endValue: 1, color: Colors.yellowAccent, position: LinearElementPosition.inside)
], ],