143 lines
4 KiB
Dart
143 lines
4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../structs/serversettings.dart';
|
|
|
|
class ServerSettingsPage extends StatefulWidget {
|
|
ServerSettingsPage({super.key});
|
|
|
|
@override
|
|
ServerSettingsState createState() => ServerSettingsState();
|
|
}
|
|
|
|
class ServerSettingsState extends State<ServerSettingsPage> {
|
|
bool firstRun = true;
|
|
String pass = "";
|
|
TextEditingController passwordController = TextEditingController();
|
|
int rconPort = 0;
|
|
int gPort = 0;
|
|
int qPort = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (firstRun) {
|
|
var args = ModalRoute.of(context)!.settings.arguments as ServerSettings;
|
|
|
|
passwordController.text = args.RconPassword;
|
|
rconPort = args.RconPort;
|
|
gPort = args.GamePort;
|
|
qPort = args.QueryPort;
|
|
|
|
firstRun = false;
|
|
}
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Server Settings"),
|
|
backgroundColor: Color.fromARGB(255, 100, 0, 0),
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 256,
|
|
child: ListTile(title: Text("Rcon Password")),
|
|
),
|
|
Expanded(
|
|
child: TextField(
|
|
controller: passwordController,
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(8))),
|
|
))
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 256,
|
|
child: ListTile(
|
|
title: Text("Rcon Port"),
|
|
subtitle: Text("$rconPort"),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Slider(
|
|
value: rconPort.toDouble(),
|
|
onChanged: (value) {
|
|
setState(() {
|
|
rconPort = value.toInt();
|
|
});
|
|
},
|
|
min: 5000,
|
|
max: 8000,
|
|
))
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 256,
|
|
child: ListTile(
|
|
title: Text("Game Port"),
|
|
subtitle: Text("$gPort"),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Slider(
|
|
value: gPort.toDouble(),
|
|
onChanged: (value) {
|
|
setState(() {
|
|
gPort = value.toInt();
|
|
});
|
|
},
|
|
min: 5000,
|
|
max: 8000,
|
|
))
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 256,
|
|
child: ListTile(
|
|
title: Text("Query Port"),
|
|
subtitle: Text("$qPort"),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Slider(
|
|
value: qPort.toDouble(),
|
|
onChanged: (value) {
|
|
setState(() {
|
|
qPort = value.toInt();
|
|
});
|
|
},
|
|
min: 5000,
|
|
max: 8000,
|
|
))
|
|
],
|
|
),
|
|
Row(
|
|
children: [
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.pop(
|
|
context,
|
|
ServerSettings(
|
|
RconPassword: passwordController.text,
|
|
RconPort: rconPort,
|
|
GamePort: gPort,
|
|
QueryPort: qPort));
|
|
},
|
|
child: Text("Submit"))
|
|
],
|
|
)
|
|
],
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
}
|