ConanServerManager/lib/pages/GameServerPage.dart

124 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import '../structs/autorestarts.dart';
import '../structs/discordHookHelper.dart';
import '../structs/serversettings.dart';
import '../structs/settings.dart';
class GameServerPage extends StatefulWidget {
Settings settings;
GameServerPage({super.key, required this.settings});
@override
GameServerPageState createState() => GameServerPageState(settings: settings);
}
class GameServerPageState extends State<GameServerPage> {
Settings settings;
GameServerPageState({required this.settings});
var downloading = false;
late Stream<List<int>> download_stream;
TextEditingController ValueControl = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Conan Exiles Server Manager - Game Server"),
backgroundColor: Color.fromARGB(255, 100, 0, 0),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
children: [
ListTile(
title: Text("Mods"),
leading: Icon(Icons.build),
subtitle: Text("Server Mod Management"),
onTap: () {
if (downloading) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Wait until the download completes")));
return;
}
Navigator.pushNamed(context, "/server/mods");
},
),
ListTile(
title: Text("Server Snapshots"),
leading: Icon(Icons.photo),
subtitle: Text("Manage server database snapshots"),
onTap: () {
Navigator.pushNamed(context, "/server/snapshots");
},
),
ListTile(
title: Text("Configure AutoRestart"),
leading: Icon(Icons.timer),
onTap: () async {
if (downloading) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Wait until the download completes")));
return;
}
var reply = await Navigator.pushNamed(
context, "/server/autorestart",
arguments: settings.inst!.timer);
if (reply == null) return; // No change was made
setState(() {
settings.inst!.timer = reply as AutomaticRestartInfo;
});
},
),
ListTile(
title: Text("Configure Server Ports"),
leading: Icon(Icons.numbers),
onTap: () async {
var reply = await Navigator.pushNamed(
context, "/server/ports",
arguments: settings.inst!.serverSettings);
if (reply == null) return; // If null, no change.
setState(() {
settings.inst!.serverSettings = reply as ServerSettings;
});
},
),
ListTile(
title: Text("Discord WebHook"),
onTap: () async {
var response =
await Navigator.pushNamed(context, "/server/discord");
if (response == null) {
return;
} else {
DiscordHookProps editResult = response as DiscordHookProps;
Settings settings = Settings();
settings.inst!.discord = editResult;
setState(() {});
}
},
),
SwitchListTile(
value: settings.inst!.pterodactylMode,
onChanged: (B) {
setState(() {
settings.inst!.pterodactylMode = B;
});
},
title: Text("Pterodactyl Mode"),
subtitle: Text(
"This mode changes restart behavior. Instead of restarting the process and keeping the wrapper running, the wrapper will stop once the server stops, allowing for Pterodactyl to reset the container process and update the uptime."),
)
],
)),
);
}
}