1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-29 08:16:28 +00:00

Add active mode

This commit is contained in:
Pierre HUBERT 2020-05-07 13:03:08 +02:00
parent fe163b3c69
commit d8fa90fc6a

View File

@ -10,41 +10,47 @@ class IconButtonWithBadge extends StatelessWidget {
final Widget icon; final Widget icon;
final void Function() onPressed; final void Function() onPressed;
final int number; final int number;
final bool active;
const IconButtonWithBadge({ const IconButtonWithBadge({
Key key, Key key,
@required this.icon, @required this.icon,
@required this.onPressed, @required this.onPressed,
this.number = 0, this.number = 0,
this.active = false,
}) : assert(icon != null), }) : assert(icon != null),
assert(number != null), assert(number != null),
assert(active != null),
super(key: key); super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return Container(
alignment: AlignmentDirectional.center, color: active ? Color(0x55000000) : null,
children: <Widget>[ child: Stack(
IconButton(icon: icon, onPressed: onPressed), alignment: AlignmentDirectional.center,
number != 0 children: <Widget>[
? Positioned( IconButton(icon: icon, onPressed: onPressed),
right: 6, number != 0
top: 6, ? Positioned(
child: Container( right: 6,
padding: EdgeInsets.all(2), top: 6,
decoration: BoxDecoration( child: Container(
color: Colors.red, padding: EdgeInsets.all(2),
borderRadius: BorderRadius.circular(6), decoration: BoxDecoration(
), color: Colors.red,
constraints: BoxConstraints(minWidth: 14, minHeight: 14), borderRadius: BorderRadius.circular(6),
child: Text( ),
"$number", constraints: BoxConstraints(minWidth: 14, minHeight: 14),
style: TextStyle(color: Colors.white, fontSize: 12), child: Text(
textAlign: TextAlign.center, "$number",
), style: TextStyle(color: Colors.white, fontSize: 12),
)) textAlign: TextAlign.center,
: Container() ),
], ))
: Container()
],
),
); );
} }
} }