mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Highlight active option in AppBar
This commit is contained in:
parent
0b1dfa460a
commit
1750d6079e
@ -30,16 +30,22 @@ class AppBarCustomDropDownWidget extends StatefulWidget {
|
|||||||
|
|
||||||
class _AppBarCustomDropDownWidgetState
|
class _AppBarCustomDropDownWidgetState
|
||||||
extends State<AppBarCustomDropDownWidget> {
|
extends State<AppBarCustomDropDownWidget> {
|
||||||
|
bool _visible = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return IconButtonWithBadge(
|
return IconButtonWithBadge(
|
||||||
icon: widget.icon,
|
icon: widget.icon,
|
||||||
onPressed: toggleOverlay,
|
onPressed: toggleOverlay,
|
||||||
number: widget.notificationsBadge,
|
number: widget.notificationsBadge,
|
||||||
|
active: _visible,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleOverlay() async {
|
void toggleOverlay() async {
|
||||||
|
setState(() => _visible = !_visible);
|
||||||
|
|
||||||
|
if (_visible) {
|
||||||
RenderBox renderBox = context.findRenderObject();
|
RenderBox renderBox = context.findRenderObject();
|
||||||
final size = renderBox.size;
|
final size = renderBox.size;
|
||||||
final offset = renderBox.localToGlobal(Offset(size.width, size.height));
|
final offset = renderBox.localToGlobal(Offset(size.width, size.height));
|
||||||
@ -48,7 +54,10 @@ class _AppBarCustomDropDownWidgetState
|
|||||||
onBuild: widget.onBuildOverlay,
|
onBuild: widget.onBuildOverlay,
|
||||||
showContext: context,
|
showContext: context,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
|
onDispose: () => setState(() => _visible = false),
|
||||||
));
|
));
|
||||||
|
} else
|
||||||
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +65,22 @@ class _AppBarCustomPopupRoute extends PopupRoute {
|
|||||||
final BuildContext showContext;
|
final BuildContext showContext;
|
||||||
final Widget Function(BuildContext) onBuild;
|
final Widget Function(BuildContext) onBuild;
|
||||||
final Offset offset;
|
final Offset offset;
|
||||||
|
final void Function() onDispose;
|
||||||
|
|
||||||
_AppBarCustomPopupRoute({
|
_AppBarCustomPopupRoute({
|
||||||
@required this.showContext,
|
@required this.showContext,
|
||||||
@required this.onBuild,
|
@required this.onBuild,
|
||||||
@required this.offset,
|
@required this.offset,
|
||||||
|
@required this.onDispose,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
|
onDispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color get barrierColor => null;
|
Color get barrierColor => null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user