2023-10-09 18:48:50 +00:00
|
|
|
import 'dart:io';
|
2023-10-10 20:20:27 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-07-12 15:14:25 +00:00
|
|
|
import 'package:intl/intl.dart';
|
2024-09-05 21:42:21 +00:00
|
|
|
import 'package:tetra_stats/data_objects/tetra_league.dart';
|
2023-07-12 15:14:25 +00:00
|
|
|
import 'package:tetra_stats/gen/strings.g.dart';
|
2024-11-19 23:21:03 +00:00
|
|
|
import 'package:tetra_stats/widgets/graphs.dart';
|
|
|
|
import 'package:tetra_stats/widgets/nerd_stats_thingy.dart';
|
2024-09-04 21:12:26 +00:00
|
|
|
import 'package:tetra_stats/widgets/text_timestamp.dart';
|
|
|
|
import 'package:tetra_stats/widgets/tl_thingy.dart';
|
2023-10-09 18:48:50 +00:00
|
|
|
import 'package:window_manager/window_manager.dart';
|
2023-06-17 21:50:52 +00:00
|
|
|
|
2023-07-12 15:14:25 +00:00
|
|
|
final DateFormat dateFormat = DateFormat.yMMMd(LocaleSettings.currentLocale.languageCode).add_Hms();
|
|
|
|
|
2023-06-17 21:50:52 +00:00
|
|
|
class StateView extends StatefulWidget {
|
2024-09-04 21:12:26 +00:00
|
|
|
final TetraLeague state;
|
2024-01-13 18:49:36 +00:00
|
|
|
const StateView({super.key, required this.state});
|
2023-06-17 21:50:52 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => StateState();
|
|
|
|
}
|
|
|
|
|
2023-10-09 18:48:50 +00:00
|
|
|
late String oldWindowTitle;
|
|
|
|
|
2023-06-17 21:50:52 +00:00
|
|
|
class StateState extends State<StateView> {
|
|
|
|
late ScrollController _scrollController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_scrollController = ScrollController();
|
2023-10-10 20:20:27 +00:00
|
|
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS){
|
2023-10-09 18:48:50 +00:00
|
|
|
windowManager.getTitle().then((value) => oldWindowTitle = value);
|
2024-09-04 21:12:26 +00:00
|
|
|
windowManager.setTitle("State from ${timestamp(widget.state.timestamp)}");
|
2023-10-09 18:48:50 +00:00
|
|
|
}
|
2023-06-17 21:50:52 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2023-10-09 18:48:50 +00:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_scrollController.dispose();
|
2023-10-10 20:20:27 +00:00
|
|
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) windowManager.setTitle(oldWindowTitle);
|
2023-10-09 18:48:50 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2023-06-17 21:50:52 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-09-05 21:42:21 +00:00
|
|
|
//final t = Translations.of(context);
|
2023-06-17 21:50:52 +00:00
|
|
|
return Scaffold(
|
2024-09-04 21:12:26 +00:00
|
|
|
appBar: AppBar(
|
2024-11-19 23:21:03 +00:00
|
|
|
title: Text("State from ${timestamp(widget.state.timestamp)}", style: Theme.of(context).textTheme.titleMedium!.copyWith(fontSize: 28)),
|
2024-09-04 21:12:26 +00:00
|
|
|
),
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
body: SafeArea(
|
2024-11-19 23:21:03 +00:00
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
TetraLeagueThingy(league: widget.state),
|
|
|
|
if (widget.state.nerdStats != null) NerdStatsThingy(nerdStats: widget.state.nerdStats!),
|
|
|
|
if (widget.state.playstyle != null) Graphs(widget.state.apm!, widget.state.pps!, widget.state.vs!, widget.state.nerdStats!, widget.state.playstyle!)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2024-09-04 21:12:26 +00:00
|
|
|
)
|
|
|
|
);
|
2023-06-17 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|