2023-10-19 21:45:07 +00:00
|
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2024-06-15 22:49:57 +00:00
|
|
|
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
2024-06-10 11:55:32 +00:00
|
|
|
import 'package:tetra_stats/views/settings_view.dart' show subtitleStyle;
|
2024-06-15 22:49:57 +00:00
|
|
|
import 'package:tetra_stats/main.dart' show MyApp, MyAppState, prefs, setAccentColor;
|
2023-10-19 21:45:07 +00:00
|
|
|
import 'package:tetra_stats/gen/strings.g.dart';
|
|
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
|
|
|
|
late String oldWindowTitle;
|
2023-10-25 23:00:47 +00:00
|
|
|
Color pickerColor = Colors.cyanAccent;
|
|
|
|
Color currentColor = Colors.cyanAccent;
|
2023-10-19 21:45:07 +00:00
|
|
|
|
|
|
|
class CustomizationView extends StatefulWidget {
|
2024-01-13 18:49:36 +00:00
|
|
|
const CustomizationView({super.key});
|
2023-10-19 21:45:07 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => CustomizationState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class CustomizationState extends State<CustomizationView> {
|
2024-03-20 22:56:13 +00:00
|
|
|
late bool oskKagariGimmick;
|
2024-06-10 11:55:32 +00:00
|
|
|
late bool sheetbotRadarGraphs;
|
2024-06-10 22:35:07 +00:00
|
|
|
late int ratingMode;
|
2024-06-11 16:30:13 +00:00
|
|
|
late int timestampMode;
|
2023-10-19 21:45:07 +00:00
|
|
|
|
2023-10-25 23:00:47 +00:00
|
|
|
void changeColor(Color color) {
|
|
|
|
setState(() => pickerColor = color);
|
|
|
|
}
|
|
|
|
|
2023-10-19 21:45:07 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
2023-10-25 23:00:47 +00:00
|
|
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) {
|
2023-10-19 21:45:07 +00:00
|
|
|
windowManager.getTitle().then((value) => oldWindowTitle = value);
|
|
|
|
windowManager.setTitle("Tetra Stats: ${t.settings}");
|
|
|
|
}
|
2024-06-11 20:51:57 +00:00
|
|
|
_getPreferences();
|
2023-10-19 21:45:07 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2023-10-25 23:00:47 +00:00
|
|
|
void dispose() {
|
2023-10-19 21:45:07 +00:00
|
|
|
if (!kIsWeb && !Platform.isAndroid && !Platform.isIOS) windowManager.setTitle(oldWindowTitle);
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2024-06-11 20:51:57 +00:00
|
|
|
void _getPreferences() {
|
2024-03-20 22:56:13 +00:00
|
|
|
if (prefs.getBool("oskKagariGimmick") != null) {
|
|
|
|
oskKagariGimmick = prefs.getBool("oskKagariGimmick")!;
|
|
|
|
} else {
|
|
|
|
oskKagariGimmick = true;
|
|
|
|
}
|
2024-06-10 11:55:32 +00:00
|
|
|
if (prefs.getBool("sheetbotRadarGraphs") != null) {
|
|
|
|
sheetbotRadarGraphs = prefs.getBool("sheetbotRadarGraphs")!;
|
|
|
|
} else {
|
|
|
|
sheetbotRadarGraphs = false;
|
|
|
|
}
|
2024-06-10 22:35:07 +00:00
|
|
|
if (prefs.getInt("ratingMode") != null) {
|
|
|
|
ratingMode = prefs.getInt("ratingMode")!;
|
|
|
|
} else {
|
|
|
|
ratingMode = 0;
|
|
|
|
}
|
2024-06-11 16:30:13 +00:00
|
|
|
if (prefs.getInt("timestampMode") != null) {
|
2024-06-11 20:51:57 +00:00
|
|
|
timestampMode = prefs.getInt("timestampMode")!;
|
2024-06-11 16:30:13 +00:00
|
|
|
} else {
|
|
|
|
timestampMode = 0;
|
|
|
|
}
|
2023-10-19 21:45:07 +00:00
|
|
|
}
|
|
|
|
|
2023-10-25 23:00:47 +00:00
|
|
|
ThemeData getTheme(BuildContext context, Color color){
|
2023-10-28 22:05:56 +00:00
|
|
|
return Theme.of(context).copyWith(colorScheme: ColorScheme.dark(primary: color, secondary: Colors.white));
|
2023-10-25 23:00:47 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 21:45:07 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final t = Translations.of(context);
|
2023-10-25 23:00:47 +00:00
|
|
|
List<DropdownMenuItem<AppLocale>>? locales =
|
|
|
|
<DropdownMenuItem<AppLocale>>[];
|
|
|
|
for (var v in AppLocale.values) {
|
2023-10-19 21:45:07 +00:00
|
|
|
locales.add(DropdownMenuItem<AppLocale>(
|
2023-10-25 23:00:47 +00:00
|
|
|
value: v, child: Text(t.locales[v.languageTag]!)));
|
2023-10-19 21:45:07 +00:00
|
|
|
}
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2024-06-10 11:55:32 +00:00
|
|
|
title: Text(t.customization),
|
2023-10-19 21:45:07 +00:00
|
|
|
),
|
|
|
|
backgroundColor: Colors.black,
|
2023-10-28 22:05:56 +00:00
|
|
|
body: SafeArea(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
2024-06-15 22:49:57 +00:00
|
|
|
ListTile(
|
|
|
|
title: const Text("Accent color"),
|
|
|
|
trailing: ColorIndicator(HSVColor.fromColor(Theme.of(context).colorScheme.primary), width: 25, height: 25),
|
|
|
|
onTap: () {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) => AlertDialog(
|
|
|
|
title: const Text('Pick an accent color'),
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
child: ColorPicker(
|
|
|
|
pickerColor: pickerColor,
|
|
|
|
onColorChanged: changeColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
actions: <Widget>[
|
|
|
|
ElevatedButton(
|
|
|
|
child: const Text('Set'),
|
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
context.findAncestorStateOfType<MyAppState>()?.setAccentColor(pickerColor);
|
|
|
|
});
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
),
|
2024-03-20 22:56:13 +00:00
|
|
|
// const ListTile(
|
|
|
|
// title: Text("Stats Table in TL mathes list"),
|
|
|
|
// subtitle: Text("Not implemented"),
|
|
|
|
// ),
|
|
|
|
ListTile(title: Text(t.oskKagari),
|
2024-06-10 11:55:32 +00:00
|
|
|
subtitle: Text(t.oskKagariDescription, style: subtitleStyle),
|
2024-03-20 22:56:13 +00:00
|
|
|
trailing: Switch(value: oskKagariGimmick, onChanged: (bool value){
|
|
|
|
prefs.setBool("oskKagariGimmick", value);
|
|
|
|
setState(() {
|
|
|
|
oskKagariGimmick = value;
|
|
|
|
});
|
2024-06-10 11:55:32 +00:00
|
|
|
}),),
|
2024-06-11 16:30:13 +00:00
|
|
|
ListTile(title: Text("Timestamps"),
|
|
|
|
subtitle: Text(t.oskKagariDescription, style: subtitleStyle),
|
|
|
|
trailing: DropdownButton(
|
|
|
|
value: timestampMode,
|
|
|
|
items: <DropdownMenuItem>[
|
|
|
|
DropdownMenuItem(value: 0, child: Text("Absolute (GMT)")),
|
|
|
|
DropdownMenuItem(value: 1, child: Text("Absolute (Local Time)")),
|
|
|
|
DropdownMenuItem(value: 2, child: Text("Relative"))
|
|
|
|
],
|
|
|
|
onChanged: (dynamic value){
|
|
|
|
prefs.setInt("timestampMode", value);
|
|
|
|
setState(() {
|
|
|
|
timestampMode = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-06-10 22:35:07 +00:00
|
|
|
ListTile(title: Text("Main representation of rating"),
|
|
|
|
subtitle: Text(t.oskKagariDescription, style: subtitleStyle),
|
|
|
|
trailing: DropdownButton(
|
|
|
|
value: ratingMode,
|
|
|
|
items: <DropdownMenuItem>[
|
|
|
|
DropdownMenuItem(value: 0, child: Text("TR")),
|
|
|
|
DropdownMenuItem(value: 1, child: Text("Glicko")),
|
|
|
|
DropdownMenuItem(value: 2, child: Text("LB position"))
|
|
|
|
],
|
|
|
|
onChanged: (dynamic value){
|
|
|
|
prefs.setInt("ratingMode", value);
|
|
|
|
setState(() {
|
|
|
|
ratingMode = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-06-10 11:55:32 +00:00
|
|
|
ListTile(title: Text("Sheetbot-like behavior for radar graphs"),
|
|
|
|
subtitle: Text(t.oskKagariDescription, style: subtitleStyle),
|
|
|
|
trailing: Switch(value: sheetbotRadarGraphs, onChanged: (bool value){
|
|
|
|
prefs.setBool("sheetbotRadarGraphs", value);
|
|
|
|
setState(() {
|
|
|
|
sheetbotRadarGraphs = value;
|
|
|
|
});
|
2024-03-20 22:56:13 +00:00
|
|
|
}),)
|
2023-10-28 22:05:56 +00:00
|
|
|
],
|
|
|
|
)),
|
2023-10-19 21:45:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|