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-01 21:44:19 +00:00
|
|
|
//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 {
|
|
|
|
final TetrioPlayer 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);
|
|
|
|
windowManager.setTitle("Tetra Stats: ${t.stateViewTitle(nickname: widget.state.username.toUpperCase(), date: dateFormat.format(widget.state.state))}");
|
|
|
|
}
|
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(
|
|
|
|
appBar: AppBar(
|
2023-07-12 15:14:25 +00:00
|
|
|
title: Text(t.stateViewTitle(nickname: widget.state.username.toUpperCase(), date: dateFormat.format(widget.state.state))),
|
2023-06-17 21:50:52 +00:00
|
|
|
),
|
|
|
|
backgroundColor: Colors.black,
|
|
|
|
body: SafeArea(
|
|
|
|
child: NestedScrollView(
|
|
|
|
controller: _scrollController,
|
|
|
|
headerSliverBuilder: (context, value) {
|
|
|
|
return [SliverToBoxAdapter(child: UserThingy(player: widget.state, showStateTimestamp: true, setState: _justUpdate))];
|
|
|
|
},
|
2024-09-01 21:44:19 +00:00
|
|
|
body: Container())));
|
2023-06-17 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|