centered login view and updated layout constraints

This commit is contained in:
2026-05-07 09:11:09 +02:00
parent e8f0c4383c
commit 517e515ac1
+75 -31
View File
@@ -46,7 +46,8 @@ class _LoginState extends State<Login> {
super.dispose(); super.dispose();
} }
String? _required(String? value) => (value ?? '').trim().isEmpty ? 'Eingabe erforderlich' : null; String? _required(String? value) =>
(value ?? '').trim().isEmpty ? 'Eingabe erforderlich' : null;
Future<void> _submit() async { Future<void> _submit() async {
if (_loading) return; if (_loading) return;
@@ -97,10 +98,7 @@ class _LoginState extends State<Login> {
icon: Icon(Icons.error_outline, color: theme.colorScheme.error), icon: Icon(Icons.error_outline, color: theme.colorScheme.error),
title: const Text('Fehlerdetails'), title: const Text('Fehlerdetails'),
content: SingleChildScrollView( content: SingleChildScrollView(
child: SelectableText( child: SelectableText(details, style: theme.textTheme.bodySmall),
details,
style: theme.textTheme.bodySmall,
),
), ),
actions: [ actions: [
TextButton.icon( TextButton.icon(
@@ -136,8 +134,12 @@ class _LoginState extends State<Login> {
child: LayoutBuilder( child: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView( builder: (context, constraints) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24), padding: const EdgeInsets.symmetric(horizontal: 24),
child: Center(
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight), constraints: BoxConstraints(
minHeight: constraints.maxHeight,
maxWidth: 420,
),
child: IntrinsicHeight( child: IntrinsicHeight(
child: Column( child: Column(
children: [ children: [
@@ -170,9 +172,7 @@ class _LoginState extends State<Login> {
), ),
), ),
const SizedBox(height: 28), const SizedBox(height: 28),
ConstrainedBox( Card(
constraints: const BoxConstraints(maxWidth: 420),
child: Card(
elevation: 8, elevation: 8,
shadowColor: Colors.black.withValues(alpha: 0.35), shadowColor: Colors.black.withValues(alpha: 0.35),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@@ -206,12 +206,18 @@ class _LoginState extends State<Login> {
validator: _required, validator: _required,
autocorrect: false, autocorrect: false,
textInputAction: TextInputAction.next, textInputAction: TextInputAction.next,
onFieldSubmitted: (_) => _passwordFocus.requestFocus(), onFieldSubmitted: (_) =>
_passwordFocus.requestFocus(),
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Nutzername', labelText: 'Nutzername',
prefixIcon: const Icon(Icons.person_outline), prefixIcon: const Icon(
Icons.person_outline,
),
filled: true, filled: true,
fillColor: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.4), fillColor: theme
.colorScheme
.surfaceContainerHighest
.withValues(alpha: 0.4),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none, borderSide: BorderSide.none,
@@ -222,7 +228,10 @@ class _LoginState extends State<Login> {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: theme.colorScheme.primary, width: 1.5), borderSide: BorderSide(
color: theme.colorScheme.primary,
width: 1.5,
),
), ),
), ),
), ),
@@ -243,7 +252,10 @@ class _LoginState extends State<Login> {
labelText: 'Passwort', labelText: 'Passwort',
prefixIcon: const Icon(Icons.lock_outline), prefixIcon: const Icon(Icons.lock_outline),
filled: true, filled: true,
fillColor: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.4), fillColor: theme
.colorScheme
.surfaceContainerHighest
.withValues(alpha: 0.4),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none, borderSide: BorderSide.none,
@@ -254,7 +266,10 @@ class _LoginState extends State<Login> {
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: theme.colorScheme.primary, width: 1.5), borderSide: BorderSide(
color: theme.colorScheme.primary,
width: 1.5,
),
), ),
), ),
), ),
@@ -262,40 +277,69 @@ class _LoginState extends State<Login> {
duration: const Duration(milliseconds: 180), duration: const Duration(milliseconds: 180),
curve: Curves.easeOut, curve: Curves.easeOut,
child: _errorMessage == null child: _errorMessage == null
? const SizedBox(height: 0, width: double.infinity) ? const SizedBox(
height: 0,
width: double.infinity,
)
: Padding( : Padding(
padding: const EdgeInsets.only(top: 14), padding: const EdgeInsets.only(
top: 14,
),
child: Material( child: Material(
color: theme.colorScheme.errorContainer.withValues(alpha: 0.6), color: theme
borderRadius: BorderRadius.circular(12), .colorScheme
.errorContainer
.withValues(alpha: 0.6),
borderRadius: BorderRadius.circular(
12,
),
child: InkWell( child: InkWell(
onTap: _errorDetails != null ? _showErrorDetails : null, onTap: _errorDetails != null
borderRadius: BorderRadius.circular(12), ? _showErrorDetails
: null,
borderRadius:
BorderRadius.circular(12),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding:
horizontal: 12, vertical: 10), const EdgeInsets.symmetric(
horizontal: 12,
vertical: 10,
),
child: Row( child: Row(
children: [ children: [
Icon(Icons.error_outline, Icon(
Icons.error_outline,
size: 20, size: 20,
color: theme.colorScheme.onErrorContainer), color: theme
.colorScheme
.onErrorContainer,
),
const SizedBox(width: 10), const SizedBox(width: 10),
Expanded( Expanded(
child: Text( child: Text(
_errorMessage!, _errorMessage!,
style: TextStyle( style: TextStyle(
color: theme.colorScheme.onErrorContainer, color: theme
.colorScheme
.onErrorContainer,
fontSize: 13, fontSize: 13,
height: 1.3, height: 1.3,
), ),
), ),
), ),
if (_errorDetails != null) ...[ if (_errorDetails !=
null) ...[
const SizedBox(width: 8), const SizedBox(width: 8),
Icon(Icons.chevron_right, Icon(
Icons.chevron_right,
size: 20, size: 20,
color: theme.colorScheme.onErrorContainer color: theme
.withValues(alpha: 0.7)), .colorScheme
.onErrorContainer
.withValues(
alpha: 0.7,
),
),
], ],
], ],
), ),
@@ -335,7 +379,6 @@ class _LoginState extends State<Login> {
), ),
), ),
), ),
),
const SizedBox(height: 18), const SizedBox(height: 18),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
@@ -369,6 +412,7 @@ class _LoginState extends State<Login> {
), ),
), ),
), ),
),
); );
} }
} }