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