kaldjf
This commit is contained in:
98
lib/core/widgets/flux_logo.dart
Normal file
98
lib/core/widgets/flux_logo.dart
Normal file
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,5 +51,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
);
|
||||
}
|
||||
});
|
||||
on<LogoutRequested>((event, emit) async {
|
||||
await _supabase.auth.signOut();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,5 @@ class LoginRequested extends AuthEvent {
|
||||
@override
|
||||
List<Object?> get props => [email, password];
|
||||
}
|
||||
|
||||
class LogoutRequested extends AuthEvent {} // Logout
|
||||
|
||||
@@ -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<AuthScreen> {
|
||||
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<AuthScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CreateCompanyScreen> {
|
||||
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<AuthBloc>().add(LogoutRequested());
|
||||
|
||||
// Se vuoi solo tornare brutalmente alla login per testare il logo:
|
||||
// Navigator.of(context).pushReplacementNamed('/login');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: BlocConsumer<CompanyBloc, CompanyState>(
|
||||
listener: (context, state) {
|
||||
if (state.status == CompanyStatus.success) {
|
||||
|
||||
Reference in New Issue
Block a user