2024-04-04 14:35:33 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class SignInForm extends StatefulWidget {
|
|
|
|
const SignInForm({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _SignInFormState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SignInFormState extends State<SignInForm> {
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
static const dialogName = "Sign In";
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) => AlertDialog(
|
|
|
|
title: const Text(dialogName),
|
2024-04-04 21:40:00 +00:00
|
|
|
content: SizedBox(
|
|
|
|
width: 420,
|
|
|
|
height: 140,
|
|
|
|
child: Form(
|
2024-04-04 14:35:33 +00:00
|
|
|
key: _formKey,
|
|
|
|
child: Center(
|
|
|
|
child: Column(children: [
|
|
|
|
TextFormField(
|
|
|
|
autofocus: true,
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
hintText: "Enter your username or email",
|
|
|
|
icon: Icon(Icons.account_circle),
|
2024-04-04 21:40:00 +00:00
|
|
|
label: Text("Username"),
|
2024-04-04 14:35:33 +00:00
|
|
|
),
|
2024-04-04 21:40:00 +00:00
|
|
|
cursorWidth: 1,
|
|
|
|
cursorHeight: 18,
|
|
|
|
cursorRadius: const Radius.circular(10),
|
2024-04-04 14:35:33 +00:00
|
|
|
),
|
|
|
|
TextFormField(
|
|
|
|
obscureText: true,
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
hintText: "Enter your password",
|
|
|
|
icon: Icon(Icons.password),
|
2024-04-04 21:40:00 +00:00
|
|
|
label: Text("Password")
|
2024-04-04 14:35:33 +00:00
|
|
|
),
|
2024-04-04 21:40:00 +00:00
|
|
|
cursorWidth: 1,
|
|
|
|
cursorHeight: 18,
|
|
|
|
cursorRadius: const Radius.circular(10),
|
2024-04-04 14:35:33 +00:00
|
|
|
),
|
2024-04-04 21:40:00 +00:00
|
|
|
])))),
|
2024-04-04 14:35:33 +00:00
|
|
|
actions: <Widget>[
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.pop(context, 'Cancel'),
|
|
|
|
child: const Text('Cancel'),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
// Validate returns true if the form is valid, or false otherwise.
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
// If the form is valid, display a snackbar. In the real world,
|
|
|
|
// you'd often call a server or save the information in a database.
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
SnackBar(content: Text(_formKey.toString())),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: const Text('OK'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|