Got more things functional

This commit is contained in:
zontreck 2024-05-23 22:18:59 -07:00
parent a1141cd2b8
commit fc0c1c7e7a
23 changed files with 1080 additions and 876 deletions

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:libac_flutter/utils/TimeUtils.dart';
import 'package:servermanager/structs/autorestarts.dart';
import 'package:servermanager/structs/settings.dart';
@ -14,9 +15,7 @@ class AutoRestartState extends State<AutoRestartPage> {
bool firstDisplay = true;
bool enabled = false;
int seconds = 0;
int minutes = 0;
int hours = 0;
Time time = Time(hours: 0, minutes: 0, seconds: 0);
@override
Widget build(BuildContext context) {
@ -24,9 +23,7 @@ class AutoRestartState extends State<AutoRestartPage> {
var args =
ModalRoute.of(context)!.settings.arguments as AutomaticRestartInfo;
enabled = args.enabled;
seconds = args.seconds;
minutes = args.minutes;
hours = args.hours;
time = args.time.copy();
firstDisplay = false;
}
@ -35,101 +32,100 @@ class AutoRestartState extends State<AutoRestartPage> {
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}"),
),
body: 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("${time.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: 24,
min: 0,
value: time.hours.toDouble(),
onChanged: (value) {
setState(() {
time.hours = value.toInt();
});
},
),
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}"),
),
)
],
),
Row(
children: [
SizedBox(
width: 256,
child: ListTile(
title: Text("Minutes"),
subtitle: Text("${time.minutes}"),
),
Expanded(
child: Slider(
max: 60,
min: 0,
value: seconds.toDouble(),
onChanged: (value) {
setState(() {
seconds = value.toInt();
});
},
),
)
],
)
]),
)),
),
),
Expanded(
child: Slider(
max: 60,
min: 0,
value: time.minutes.toDouble(),
onChanged: (value) {
setState(() {
time.minutes = value.toInt();
});
},
),
)
],
),
Row(
children: [
SizedBox(
width: 256,
child: ListTile(
title: Text("Seconds"),
subtitle: Text("${time.seconds}"),
),
),
Expanded(
child: Slider(
max: 60,
min: 0,
value: time.seconds.toDouble(),
onChanged: (value) {
setState(() {
time.seconds = value.toInt();
});
},
),
)
],
),
Row(
children: [
ElevatedButton(
onPressed: () {
Navigator.pop(context,
AutomaticRestartInfo(enabled: enabled, time: time));
},
child: Text("Submit"))
],
)
]),
)),
);
}
}