diff --git a/lib/Views/produitsCard.dart b/lib/Views/produitsCard.dart index 255ebfd..c4011f8 100644 --- a/lib/Views/produitsCard.dart +++ b/lib/Views/produitsCard.dart @@ -4,7 +4,7 @@ import 'package:youmazgestion/Models/produit.dart'; class ProductCard extends StatefulWidget { final Product product; - final void Function(Product, int) onAddToCart; + final void Function(Product, int) onAddToCart; const ProductCard({ Key? key, @@ -16,7 +16,8 @@ class ProductCard extends StatefulWidget { State createState() => _ProductCardState(); } -class _ProductCardState extends State with TickerProviderStateMixin { +class _ProductCardState extends State + with TickerProviderStateMixin { int selectedQuantity = 1; late AnimationController _scaleController; late AnimationController _fadeController; @@ -26,7 +27,7 @@ class _ProductCardState extends State with TickerProviderStateMixin @override void initState() { super.initState(); - + // Animations pour les interactions _scaleController = AnimationController( duration: const Duration(milliseconds: 200), @@ -36,7 +37,7 @@ class _ProductCardState extends State with TickerProviderStateMixin duration: const Duration(milliseconds: 300), vsync: this, )..forward(); - + _scaleAnimation = Tween( begin: 1.0, end: 0.95, @@ -44,7 +45,7 @@ class _ProductCardState extends State with TickerProviderStateMixin parent: _scaleController, curve: Curves.easeInOut, )); - + _fadeAnimation = Tween( begin: 0.0, end: 1.0, @@ -122,7 +123,6 @@ class _ProductCardState extends State with TickerProviderStateMixin : _buildPlaceholderImage(), ), ), - Positioned.fill( child: Container( decoration: BoxDecoration( @@ -141,7 +141,6 @@ class _ProductCardState extends State with TickerProviderStateMixin ), ), ), - if (widget.product.isStockDefined()) Positioned( top: 12, @@ -183,7 +182,6 @@ class _ProductCardState extends State with TickerProviderStateMixin ), ), ), - Positioned( left: 0, right: 0, @@ -201,7 +199,8 @@ class _ProductCardState extends State with TickerProviderStateMixin vertical: 8, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( widget.product.name, @@ -222,7 +221,7 @@ class _ProductCardState extends State with TickerProviderStateMixin ), const SizedBox(height: 4), Text( - '${widget.product.price.toStringAsFixed(2)} FCFA', + '${widget.product.price.toStringAsFixed(2)} MGA', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 13, @@ -239,9 +238,7 @@ class _ProductCardState extends State with TickerProviderStateMixin ], ), ), - const SizedBox(height: 12), - Row( children: [ Container( @@ -250,7 +247,8 @@ class _ProductCardState extends State with TickerProviderStateMixin borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.1), + color: + Colors.black.withOpacity(0.1), blurRadius: 4, offset: const Offset(0, 2), ), @@ -295,9 +293,7 @@ class _ProductCardState extends State with TickerProviderStateMixin ], ), ), - const SizedBox(width: 8), - Expanded( child: MouseRegion( cursor: SystemMouseCursors.click, @@ -306,9 +302,11 @@ class _ProductCardState extends State with TickerProviderStateMixin onTapUp: _onTapUp, onTapCancel: _onTapCancel, onTap: () { - widget.onAddToCart(widget.product, selectedQuantity); - - ScaffoldMessenger.of(context).showSnackBar( + widget.onAddToCart(widget.product, + selectedQuantity); + + ScaffoldMessenger.of(context) + .showSnackBar( SnackBar( content: Row( children: [ @@ -320,16 +318,20 @@ class _ProductCardState extends State with TickerProviderStateMixin Expanded( child: Text( '${widget.product.name} (x$selectedQuantity) ajouté au panier', - overflow: TextOverflow.ellipsis, + overflow: TextOverflow + .ellipsis, ), ), ], ), backgroundColor: Colors.green, - duration: const Duration(seconds: 1), - behavior: SnackBarBehavior.floating, + duration: + const Duration(seconds: 1), + behavior: + SnackBarBehavior.floating, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), + borderRadius: + BorderRadius.circular(10), ), ), ); @@ -342,21 +344,27 @@ class _ProductCardState extends State with TickerProviderStateMixin decoration: BoxDecoration( gradient: const LinearGradient( colors: [ - Color.fromARGB(255, 4, 54, 95), - Color.fromARGB(255, 6, 80, 140), + Color.fromARGB( + 255, 4, 54, 95), + Color.fromARGB( + 255, 6, 80, 140), ], ), - borderRadius: BorderRadius.circular(20), + borderRadius: + BorderRadius.circular(20), boxShadow: [ BoxShadow( - color: const Color.fromARGB(255, 4, 54, 95).withOpacity(0.3), + color: const Color.fromARGB( + 255, 4, 54, 95) + .withOpacity(0.3), blurRadius: 6, offset: const Offset(0, 3), ), ], ), child: const Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ const Icon( Icons.add_shopping_cart, @@ -369,10 +377,12 @@ class _ProductCardState extends State with TickerProviderStateMixin 'Ajouter', style: TextStyle( color: Colors.white, - fontWeight: FontWeight.bold, + fontWeight: + FontWeight.bold, fontSize: 12, ), - overflow: TextOverflow.ellipsis, + overflow: + TextOverflow.ellipsis, ), ), ], @@ -442,10 +452,12 @@ class _ProductCardState extends State with TickerProviderStateMixin child: Icon( icon, size: 16, - color: onPressed != null ? const Color.fromARGB(255, 4, 54, 95) : Colors.grey, + color: onPressed != null + ? const Color.fromARGB(255, 4, 54, 95) + : Colors.grey, ), ), ), ); } -} \ No newline at end of file +}