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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user