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';
|
2023-06-17 21:50:52 +00:00
|
|
|
import 'package:tetra_stats/data_objects/tetrio.dart';
|
2023-07-12 15:14:25 +00:00
|
|
|
import 'package:tetra_stats/gen/strings.g.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-06-17 21:50:52 +00:00
|
|
|
import 'package:tetra_stats/widgets/user_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
|
|
|
void _justUpdate() {
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-07-12 15:14:25 +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(
|
|
|
|
title: Text("State from ${timestamp(widget.state.timestamp)}"),
|
|
|
|
),
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
body: SafeArea(
|
|
|
|
child: TLThingy(tl: widget.state, userID: widget.state.id, states: [])
|
|
|
|
)
|
|
|
|
);
|
2023-06-17 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|