diff --git a/assets/svg/flux_logo_dark.svg b/assets/svg/flux_logo_dark.svg new file mode 100644 index 0000000..78d9eaa --- /dev/null +++ b/assets/svg/flux_logo_dark.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/assets/svg/flux_logo_light.svg b/assets/svg/flux_logo_light.svg new file mode 100644 index 0000000..11efda0 --- /dev/null +++ b/assets/svg/flux_logo_light.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/lib/core/widgets/flux_logo.dart b/lib/core/widgets/flux_logo.dart new file mode 100644 index 0000000..15f2176 --- /dev/null +++ b/lib/core/widgets/flux_logo.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +// Classe privata per gestire i percorsi in modo ordinato +class _FluxSvgPaths { + // Nota: Usa l'estensione .svg + static const String logoLight = 'assets/svg/flux_logo_light.svg'; + static const String logoDark = 'assets/svg/flux_logo_dark.svg'; +} + +/// Widget base generico per il logo FLUX in formato SVG. +/// Gestisce il dimensionamento vettoriale e la nitidezza. +class _FluxLogoBase extends StatelessWidget { + final String assetPath; + final double? width; + final double? height; + + const _FluxLogoBase({required this.assetPath, this.width, this.height}); + + @override + Widget build(BuildContext context) { + // Usiamo SvgPicture.asset per gli SVG + return SvgPicture.asset( + assetPath, + width: width, + height: height, + // BoxFit.contain assicura che il logo si adatti perfettamente + // alle dimensioni fornite senza mai distorcersi. + fit: BoxFit.contain, + // Opzionale: previene sfarfallii al caricamento + placeholderBuilder: (BuildContext context) => Container( + padding: const EdgeInsets.all(10.0), + child: const CircularProgressIndicator(), + ), + ); + } +} + +// --- I TUOI DUE WIDGET RICHIESTI --- + +/// Logo FLUX per sfondi CHIARI (testo nero). +class FluxLogoLight extends StatelessWidget { + final double? width; + final double? height; + + const FluxLogoLight({super.key, this.width, this.height}); + + @override + Widget build(BuildContext context) { + return _FluxLogoBase( + assetPath: _FluxSvgPaths.logoLight, + width: width, + height: height, + ); + } +} + +/// Logo FLUX per sfondi SCURI (testo bianco). +class FluxLogoDark extends StatelessWidget { + final double? width; + final double? height; + + const FluxLogoDark({super.key, this.width, this.height}); + + @override + Widget build(BuildContext context) { + return _FluxLogoBase( + assetPath: _FluxSvgPaths.logoDark, + width: width, + height: height, + ); + } +} + +// --- BONUS: IL WIDGET INTELLIGENTE PER LA TUA APP --- + +/// Un singolo widget che sceglie automaticamente il logo giusto +/// in base al tema attuale (Light o Dark Mode) dell'app. +/// Ideale per la dashboard o la splash screen. +class FluxLogoAuto extends StatelessWidget { + final double? width; + final double? height; + + const FluxLogoAuto({super.key, this.width, this.height}); + + @override + Widget build(BuildContext context) { + // Controlla se il tema attuale รจ scuro + final isDarkMode = Theme.of(context).brightness == Brightness.dark; + + return _FluxLogoBase( + // Sceglie l'asset giusto + assetPath: isDarkMode ? _FluxSvgPaths.logoLight : _FluxSvgPaths.logoDark, + width: width, + height: height, + ); + } +} diff --git a/lib/features/auth/bloc/auth_bloc.dart b/lib/features/auth/bloc/auth_bloc.dart index b02c718..202136b 100644 --- a/lib/features/auth/bloc/auth_bloc.dart +++ b/lib/features/auth/bloc/auth_bloc.dart @@ -51,5 +51,8 @@ class AuthBloc extends Bloc { ); } }); + on((event, emit) async { + await _supabase.auth.signOut(); + }); } } diff --git a/lib/features/auth/bloc/auth_events.dart b/lib/features/auth/bloc/auth_events.dart index 15ddeba..da08631 100644 --- a/lib/features/auth/bloc/auth_events.dart +++ b/lib/features/auth/bloc/auth_events.dart @@ -17,3 +17,5 @@ class LoginRequested extends AuthEvent { @override List get props => [email, password]; } + +class LogoutRequested extends AuthEvent {} // Logout diff --git a/lib/features/auth/ui/auth_screen.dart b/lib/features/auth/ui/auth_screen.dart index b5a97bf..d17e3fe 100644 --- a/lib/features/auth/ui/auth_screen.dart +++ b/lib/features/auth/ui/auth_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flux/core/theme/theme.dart'; +import 'package:flux/core/widgets/flux_logo.dart'; import 'package:flux/core/widgets/flux_text_field.dart'; import 'package:flux/features/auth/bloc/auth_bloc.dart'; @@ -48,7 +49,7 @@ class _AuthScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ // --- LOGO FLUX --- - _buildLogo(context), + FluxLogoAuto(height: 80), const SizedBox(height: 60), // --- TITOLO DINAMICO --- @@ -151,16 +152,4 @@ class _AuthScreenState extends State { ), ); } - - Widget _buildLogo(BuildContext context) { - // Controlliamo se siamo in dark mode o light mode - bool isDark = Theme.of(context).brightness == Brightness.dark; - - return SvgPicture.asset( - isDark - ? 'assets/images/flux_logo_light.svg' - : 'assets/images/flux_logo_dark.svg', - height: 80, - ); - } } diff --git a/lib/features/company/ui/create_company_screen.dart b/lib/features/company/ui/create_company_screen.dart index 1d9901e..a343a73 100644 --- a/lib/features/company/ui/create_company_screen.dart +++ b/lib/features/company/ui/create_company_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flux/features/auth/bloc/auth_bloc.dart'; import 'package:flux/features/company/bloc/company_bloc.dart'; import 'package:flux/core/blocs/session/session_bloc.dart'; import 'package:flux/core/theme/theme.dart'; @@ -32,6 +33,22 @@ class _CreateCompanyScreenState extends State { return BlocProvider( create: (context) => CompanyBloc(), child: Scaffold( + appBar: AppBar( + title: const Text('Configurazione Azienda'), + actions: [ + IconButton( + icon: const Icon(Icons.logout_rounded), + onPressed: () { + // Qui chiami il tuo Bloc dell'autenticazione per fare logout + // Esempio se hai un AuthBloc o SessionBloc: + context.read().add(LogoutRequested()); + + // Se vuoi solo tornare brutalmente alla login per testare il logo: + // Navigator.of(context).pushReplacementNamed('/login'); + }, + ), + ], + ), body: BlocConsumer( listener: (context, state) { if (state.status == CompanyStatus.success) { diff --git a/pubspec.yaml b/pubspec.yaml index 1162733..9a95c75 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,5 +28,7 @@ flutter: assets: - assets/images/ + - assets/svg/ +