TetraStats/lib/views/state_view.dart

67 lines
2.3 KiB
Dart
Raw Normal View History

import 'dart:io';
2023-10-10 20:20:27 +00:00
import 'package:flutter/foundation.dart';
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';
import 'package:tetra_stats/widgets/text_timestamp.dart';
import 'package:tetra_stats/widgets/tl_thingy.dart';
import 'package:window_manager/window_manager.dart';
2023-07-12 15:14:25 +00:00
final DateFormat dateFormat = DateFormat.yMMMd(LocaleSettings.currentLocale.languageCode).add_Hms();
class StateView extends StatefulWidget {
final TetraLeague state;
const StateView({super.key, required this.state});
@override
State<StatefulWidget> createState() => StateState();
}
late String oldWindowTitle;
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){
windowManager.getTitle().then((value) => oldWindowTitle = value);
windowManager.setTitle("State from ${timestamp(widget.state.timestamp)}");
}
super.initState();
}
@override
void dispose() {
_scrollController.dispose();
2023-10-10 20:20:27 +00:00
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) windowManager.setTitle(oldWindowTitle);
super.dispose();
}
@override
Widget build(BuildContext context) {
2024-09-05 21:42:21 +00:00
//final t = Translations.of(context);
return Scaffold(
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)),
),
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!)
],
),
)
)
);
}
}