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 { 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(); }); }, ), ) ], ) ]), )), ), ); } }