126 lines
4.8 KiB
Dart
126 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../bloc/auth_bloc.dart';
|
|
|
|
|
|
/// User Login Screen widget.
|
|
class LoginScreen extends StatefulWidget {
|
|
const LoginScreen({super.key});
|
|
|
|
@override
|
|
State<LoginScreen> createState() => _LoginScreenState();
|
|
}
|
|
|
|
class _LoginScreenState extends State<LoginScreen> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
final _emailController = TextEditingController();
|
|
final _passwordController = TextEditingController();
|
|
bool _obscurePassword = true;
|
|
|
|
@override
|
|
void dispose() {
|
|
_emailController.dispose();
|
|
_passwordController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _onLogin() {
|
|
if (_formKey.currentState?.validate() ?? false) {
|
|
context.read<AuthBloc>().add(LoginRequested(
|
|
_emailController.text.trim(),
|
|
_passwordController.text.trim(),
|
|
));
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Container(
|
|
constraints: const BoxConstraints(maxWidth: 400),
|
|
padding: const EdgeInsets.all(28),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.cardSurface,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppTheme.glassBorder),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: AppTheme.primaryEmerald.withValues(alpha: 0.08),
|
|
blurRadius: 24,
|
|
spreadRadius: 2,
|
|
),
|
|
],
|
|
),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.auto_graph_rounded, size: 54, color: AppTheme.primaryEmerald),
|
|
const SizedBox(height: 12),
|
|
const Text(
|
|
'FINLYTIC',
|
|
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2),
|
|
),
|
|
Text('Enterprise Financial Intelligence', style: TextStyle(color: AppTheme.textMuted, fontSize: 12)),
|
|
const SizedBox(height: 28),
|
|
TextFormField(
|
|
controller: _emailController,
|
|
decoration: const InputDecoration(labelText: 'E-Mail', prefixIcon: Icon(Icons.email_outlined)),
|
|
validator: (v) => v == null || !v.contains('@') ? 'Gültige E-Mail erforderlich' : null,
|
|
),
|
|
const SizedBox(height: 16),
|
|
TextFormField(
|
|
controller: _passwordController,
|
|
obscureText: _obscurePassword,
|
|
decoration: InputDecoration(
|
|
labelText: 'Passwort',
|
|
prefixIcon: const Icon(Icons.lock_outline),
|
|
suffixIcon: IconButton(
|
|
icon: Icon(_obscurePassword ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
|
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
|
),
|
|
),
|
|
validator: (v) => v == null || v.isEmpty ? 'Passwort erforderlich' : null,
|
|
),
|
|
const SizedBox(height: 32),
|
|
BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) {
|
|
if (state is AuthLoading) {
|
|
return CircularProgressIndicator(color: AppTheme.primaryEmerald);
|
|
}
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: 48,
|
|
child: ElevatedButton(
|
|
onPressed: _onLogin,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppTheme.primaryEmerald,
|
|
foregroundColor: Colors.black,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
),
|
|
child: const Text('Anmelden', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15)),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
"Konten werden ausschließlich vom Administrator angelegt.",
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(color: AppTheme.textMuted, fontSize: 11),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|