diff --git a/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart b/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart index 3804dbd5..20e8ae0e 100644 --- a/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart +++ b/Frontend/lib/mih_components/mih_package_components/Example/package_tools/package_tool_one.dart @@ -130,6 +130,7 @@ class _PackageToolOneState extends State { }, buttonColor: MzanziInnovationHub.of(context)!.theme.secondaryColor(), + elevation: 10, width: 300, child: Text( "Click Me", @@ -141,7 +142,7 @@ class _PackageToolOneState extends State { ), ), ), - const SizedBox(height: 10), + const SizedBox(height: 40), MihButton( onPressed: () { print("Button Pressed"); @@ -150,6 +151,7 @@ class _PackageToolOneState extends State { MzanziInnovationHub.of(context)!.theme.successColor(), width: 300, child: Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.delete, diff --git a/Frontend/lib/mih_components/mih_package_components/mih_button.dart b/Frontend/lib/mih_components/mih_package_components/mih_button.dart index 3c68b494..fc96eb7c 100644 --- a/Frontend/lib/mih_components/mih_package_components/mih_button.dart +++ b/Frontend/lib/mih_components/mih_package_components/mih_button.dart @@ -1,42 +1,64 @@ -import 'package:animated_button/animated_button.dart'; import 'package:flutter/material.dart'; -class MihButton extends StatefulWidget { - final void Function() onPressed; +class MihButton extends StatelessWidget { + final void Function()? onPressed; final Color buttonColor; - final double width; + final double? width; final double? height; final double? borderRadius; + final double? elevation; // 0 = flat, higher = more shadow final Widget child; const MihButton({ super.key, required this.onPressed, required this.buttonColor, - required this.width, + this.width, this.height, this.borderRadius, + this.elevation, required this.child, }); + Color _darkerColor(Color color, [double amount = .1]) { + final hsl = HSLColor.fromColor(color); + final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0)); + return hslDark.toColor(); + } - @override - State createState() => _MihButtonState(); -} - -class _MihButtonState extends State { @override Widget build(BuildContext context) { - return FittedBox( - fit: BoxFit.contain, - child: AnimatedButton( - width: widget.width, - height: widget.height ?? 50.0, - borderRadius: widget.borderRadius ?? 25.0, - color: widget.buttonColor, - shadowDegree: ShadowDegree.light, - duration: 30, - onPressed: widget.onPressed, - child: FittedBox(child: widget.child), + final Color effectiveButtonColor = onPressed == null + ? buttonColor.withValues(alpha: 0.6) // Example disabled color + : buttonColor; + final Color rippleColor = _darkerColor(effectiveButtonColor, 0.1); + final double radius = borderRadius ?? 25.0; + final double effectiveElevation = + onPressed == null ? 0.0 : (elevation ?? 4.0); + return MouseRegion( + cursor: onPressed == null + ? SystemMouseCursors.basic + : SystemMouseCursors.click, + child: Material( + color: effectiveButtonColor, + borderRadius: BorderRadius.circular(radius), + elevation: effectiveElevation, + shadowColor: Colors.black, + child: InkWell( + borderRadius: BorderRadius.circular(radius), + splashColor: rippleColor, + highlightColor: rippleColor.withValues(alpha: 0.2), + hoverColor: rippleColor.withValues(alpha: 0.15), + onTap: onPressed, + child: Container( + width: width, + height: height, + padding: (width == null || height == null) + ? const EdgeInsets.symmetric(horizontal: 24, vertical: 12) + : null, + alignment: Alignment.center, + child: child, + ), + ), ), ); }