feat(App): update Finlytic Flutter app UI and blocs

This commit is contained in:
2026-08-09 21:01:46 +02:00
parent e7427b7464
commit a708d2977c
591 changed files with 1095105 additions and 0 deletions
@@ -0,0 +1,137 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:finlytic_app/core/network/api_client.dart';
import 'package:finlytic_app/core/theme/app_theme.dart';
import 'package:finlytic_app/features/auth/bloc/auth_bloc.dart';
class ChangeInitialPasswordScreen extends StatefulWidget {
final String userId;
const ChangeInitialPasswordScreen({super.key, required this.userId});
@override
State<ChangeInitialPasswordScreen> createState() => _ChangeInitialPasswordScreenState();
}
class _ChangeInitialPasswordScreenState extends State<ChangeInitialPasswordScreen> {
final _formKey = GlobalKey<FormState>();
final _passwordController = TextEditingController();
final _confirmPasswordController = TextEditingController();
bool _isLoading = false;
void _onChangePassword() async {
if (_formKey.currentState?.validate() ?? false) {
setState(() => _isLoading = true);
try {
final apiClient = context.read<ApiClient>();
final res = await apiClient.post('/api/v1/auth/change-initial-password', data: {
'userId': widget.userId,
'newPassword': _passwordController.text,
});
if (res.statusCode == 200) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Passwort erfolgreich geändert! Bitte melden Sie sich erneut an.'), backgroundColor: AppTheme.accentCyan),
);
context.read<AuthBloc>().add(LogoutRequested()); // Force re-login
}
} else {
throw Exception('Fehler beim Ändern des Passworts.');
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString()), backgroundColor: Colors.red),
);
}
} finally {
if (mounted) {
setState(() => _isLoading = false);
}
}
}
}
@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.accentCyan.withValues(alpha: 0.08),
blurRadius: 24,
spreadRadius: 2,
),
],
),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.lock_reset, size: 54, color: AppTheme.accentCyan),
const SizedBox(height: 12),
const Text(
'PASSWORT ÄNDERN',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, letterSpacing: 1),
),
const SizedBox(height: 8),
Text(
'Ein Administrator hat Ihr Passwort zurückgesetzt oder diesen Account neu erstellt. Bitte vergeben Sie ein neues Passwort.',
textAlign: TextAlign.center,
style: TextStyle(color: AppTheme.textSecondary, fontSize: 13),
),
const SizedBox(height: 24),
TextFormField(
controller: _passwordController,
obscureText: true,
decoration: const InputDecoration(labelText: 'Neues Passwort', prefixIcon: Icon(Icons.lock)),
validator: (v) => v == null || v.length < 6 ? 'Passwort muss mindestens 6 Zeichen lang sein' : null,
),
const SizedBox(height: 16),
TextFormField(
controller: _confirmPasswordController,
obscureText: true,
decoration: const InputDecoration(labelText: 'Passwort bestätigen', prefixIcon: Icon(Icons.lock_outline)),
validator: (v) => v != _passwordController.text ? 'Passwörter stimmen nicht überein' : null,
),
const SizedBox(height: 24),
_isLoading
? CircularProgressIndicator(color: AppTheme.accentCyan)
: SizedBox(
width: double.infinity,
height: 48,
child: ElevatedButton(
onPressed: _onChangePassword,
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.accentCyan,
foregroundColor: Colors.black,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
child: const Text('Passwort Speichern', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
const SizedBox(height: 16),
TextButton(
onPressed: () => context.read<AuthBloc>().add(LogoutRequested()),
child: Text('Abbrechen & Zurück zum Login', style: TextStyle(color: AppTheme.textSecondary)),
),
],
),
),
),
),
),
);
}
}
@@ -0,0 +1,104 @@
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(text: 'admin@finlytic.com');
final _passwordController = TextEditingController(text: 'AdminDefaultPassword2026!');
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: true,
decoration: const InputDecoration(labelText: 'Passwort', prefixIcon: Icon(Icons.lock_outline)),
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)),
),
);
},
),
],
),
),
),
),
),
);
}
}
@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../core/theme/app_theme.dart';
import '../bloc/auth_bloc.dart';
/// User registration screen widget.
class RegisterScreen extends StatefulWidget {
const RegisterScreen({super.key});
@override
State<RegisterScreen> createState() => _RegisterScreenState();
}
class _RegisterScreenState extends State<RegisterScreen> {
final _formKey = GlobalKey<FormState>();
final _nameController = TextEditingController();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
void _submit() {
if (_formKey.currentState?.validate() ?? false) {
context.read<AuthBloc>().add(RegisterRequested(
_emailController.text.trim(),
_passwordController.text.trim(),
_nameController.text.trim(),
));
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Konto Registrieren')),
body: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: Container(
constraints: const BoxConstraints(maxWidth: 420),
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: AppTheme.cardSurface,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppTheme.glassBorder),
),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.person_add_outlined, size: 48, color: AppTheme.primaryEmerald),
const SizedBox(height: 16),
const Text(
'Neues Konto erstellen',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
const SizedBox(height: 24),
TextFormField(
controller: _nameController,
decoration: const InputDecoration(labelText: 'Vollständiger Name', prefixIcon: Icon(Icons.person_outline)),
validator: (v) => v == null || v.isEmpty ? 'Name erforderlich' : null,
),
const SizedBox(height: 14),
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: 14),
TextFormField(
controller: _passwordController,
obscureText: true,
decoration: const InputDecoration(labelText: 'Passwort', prefixIcon: Icon(Icons.lock_outline)),
validator: (v) => v == null || v.length < 6 ? 'Mind. 6 Zeichen' : null,
),
const SizedBox(height: 24),
SizedBox(
width: double.infinity,
height: 48,
child: ElevatedButton(
onPressed: _submit,
style: ElevatedButton.styleFrom(
backgroundColor: AppTheme.primaryEmerald,
foregroundColor: Colors.black,
),
child: const Text('Registrieren', style: TextStyle(fontWeight: FontWeight.bold)),
),
),
],
),
),
),
),
),
);
}
}