From d8fa90fc6a39f14d2977eeb387a24ab0f05b6cf0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 7 May 2020 13:03:08 +0200 Subject: [PATCH] Add active mode --- lib/ui/widgets/icon_button_badge.dart | 52 +++++++++++++++------------ 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/ui/widgets/icon_button_badge.dart b/lib/ui/widgets/icon_button_badge.dart index ada949b..1f8ff85 100644 --- a/lib/ui/widgets/icon_button_badge.dart +++ b/lib/ui/widgets/icon_button_badge.dart @@ -10,41 +10,47 @@ class IconButtonWithBadge extends StatelessWidget { final Widget icon; final void Function() onPressed; final int number; + final bool active; const IconButtonWithBadge({ Key key, @required this.icon, @required this.onPressed, this.number = 0, + this.active = false, }) : assert(icon != null), assert(number != null), + assert(active != null), super(key: key); @override Widget build(BuildContext context) { - return Stack( - alignment: AlignmentDirectional.center, - children: [ - IconButton(icon: icon, onPressed: onPressed), - number != 0 - ? Positioned( - right: 6, - top: 6, - child: Container( - padding: EdgeInsets.all(2), - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(6), - ), - constraints: BoxConstraints(minWidth: 14, minHeight: 14), - child: Text( - "$number", - style: TextStyle(color: Colors.white, fontSize: 12), - textAlign: TextAlign.center, - ), - )) - : Container() - ], + return Container( + color: active ? Color(0x55000000) : null, + child: Stack( + alignment: AlignmentDirectional.center, + children: [ + IconButton(icon: icon, onPressed: onPressed), + number != 0 + ? Positioned( + right: 6, + top: 6, + child: Container( + padding: EdgeInsets.all(2), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(6), + ), + constraints: BoxConstraints(minWidth: 14, minHeight: 14), + child: Text( + "$number", + style: TextStyle(color: Colors.white, fontSize: 12), + textAlign: TextAlign.center, + ), + )) + : Container() + ], + ), ); } }