Refactor project, get server-client coms working

This commit is contained in:
zontreck 2024-05-23 00:11:14 -07:00
parent 6fadb92a26
commit 7cddfd2de6
22 changed files with 730 additions and 677 deletions

135
lib/pages/autorestart.dart Normal file
View file

@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import 'package:servermanager/structs/autorestarts.dart';
import 'package:servermanager/structs/settings.dart';
class AutoRestartPage extends StatefulWidget {
AutoRestartPage({super.key});
@override
AutoRestartState createState() => AutoRestartState();
}
class AutoRestartState extends State<AutoRestartPage> {
Settings settings = Settings();
bool firstDisplay = true;
bool enabled = false;
int seconds = 0;
int minutes = 0;
int hours = 0;
@override
Widget build(BuildContext context) {
if (firstDisplay) {
var args =
ModalRoute.of(context)!.settings.arguments as AutomaticRestartInfo;
enabled = args.enabled;
seconds = args.seconds;
minutes = args.minutes;
hours = args.hours;
firstDisplay = false;
}
return Scaffold(
appBar: AppBar(
title: Text("Automatic Restart"),
backgroundColor: Color.fromARGB(255, 100, 0, 0),
),
body: PopScope(
onPopInvoked: (v) async {
Navigator.pop(
context,
AutomaticRestartInfo(
enabled: enabled,
hours: hours,
minutes: minutes,
seconds: seconds));
},
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(children: [
SwitchListTile(
value: enabled,
onChanged: (val) {
setState(() {
enabled = !enabled;
});
},
title: Text("Enabled"),
),
Row(
children: [
SizedBox(
width: 256,
child: ListTile(
title: Text("Hours"),
subtitle: Text("${hours}"),
),
),
Expanded(
child: Slider(
max: 24,
min: 0,
value: hours.toDouble(),
onChanged: (value) {
setState(() {
hours = value.toInt();
});
},
),
)
],
),
Row(
children: [
SizedBox(
width: 256,
child: ListTile(
title: Text("Minutes"),
subtitle: Text("${minutes}"),
),
),
Expanded(
child: Slider(
max: 60,
min: 0,
value: minutes.toDouble(),
onChanged: (value) {
setState(() {
minutes = value.toInt();
});
},
),
)
],
),
Row(
children: [
SizedBox(
width: 256,
child: ListTile(
title: Text("Seconds"),
subtitle: Text("${seconds}"),
),
),
Expanded(
child: Slider(
max: 60,
min: 0,
value: seconds.toDouble(),
onChanged: (value) {
setState(() {
seconds = value.toInt();
});
},
),
)
],
)
]),
)),
),
);
}
}