import 'package:flutter/material.dart'; import 'package:servermanager/pages/Constants.dart'; import 'package:servermanager/structs/discordHookHelper.dart'; import 'package:servermanager/structs/settings.dart'; class DiscordConfigPage extends StatefulWidget { @override State createState() => DiscordConfigurationState(); } class DiscordConfigurationState extends State { TextEditingController ServerNameController = TextEditingController(); TextEditingController URLController = TextEditingController(); bool enabled = false; @override void didChangeDependencies() { Settings settings = Settings(); final discord = settings.inst!.discord; ServerNameController.text = discord.serverName; URLController.text = discord.url; enabled = discord.enabled; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Conan Exiles Server Manager - Discord Hook Settings"), backgroundColor: Constants.TITLEBAR_COLOR, actions: [ IconButton( onPressed: () { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( "Discord Webhook has been successfully reset and will no longer be used"))); Settings settings = Settings(); settings.inst!.discord = DiscordHookProps(url: "", serverName: "", enabled: false); Navigator.pop(context); }, icon: Icon(Icons.clear_all)) ], ), floatingActionButton: ElevatedButton( onPressed: () { Navigator.pop( context, DiscordHookProps( url: URLController.text, serverName: ServerNameController.text, enabled: enabled)); }, child: Text("Submit"), ), body: SingleChildScrollView( child: Column( children: [ Row( children: [ SizedBox( width: 256, child: ListTile( title: Text("Server Name"), )), Expanded( child: TextField( controller: ServerNameController, )) ], ), Row( children: [ SizedBox( width: 256, child: ListTile( title: Text("URL"), )), Expanded( child: TextField( controller: URLController, )) ], ), SwitchListTile( value: enabled, onChanged: (V) { enabled = V; setState(() {}); }, title: Text("Enabled"), ) ], ), ), ); } }