ConanServerManager/lib/pages/credentials_prompt.dart

100 lines
3.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:servermanager/structs/credentials.dart';
class CredentialsPage extends StatefulWidget {
@override
CredentialsPrompt createState() => CredentialsPrompt();
}
// Returns a Credentials Object
class CredentialsPrompt extends State<CredentialsPage> {
TextEditingController username = TextEditingController();
TextEditingController password = TextEditingController();
bool initialInitDone = false;
@override
void initState() {}
@override
void didChangeDependencies() {
final args = ModalRoute.of(context)!.settings.arguments as Credentials?;
if (args != null) {
if (!initialInitDone) {
username.text = args.username;
password.text = args.password;
initialInitDone = true;
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Conan Exiles Server Manager - Credentials (Super User)"),
backgroundColor: Color.fromARGB(255, 100, 0, 0),
),
floatingActionButton: ElevatedButton(
child: Text("Save"),
onPressed: () {
Navigator.pop(
context,
Credentials(
username: username.text,
password: password.text,
));
},
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16),
child: Column(
children: [
Row(
children: [
SizedBox(
width: 150,
child: Row(
children: [
Icon(Icons.person),
Text("Username:"),
],
)),
Expanded(
child: TextField(
controller: username,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4))),
),
)
],
),
SizedBox(
height: 16,
),
Row(
children: [
SizedBox(
width: 150,
child: Row(
children: [
Icon(Icons.key),
Text("Password:"),
],
)),
Expanded(
child: TextField(
controller: password,
keyboardType: TextInputType.visiblePassword,
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(4))),
),
)
],
),
],
)));
}
}