From f744fd10de43e0d4c1e76cd76af6ef8389a7edc5 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 7 Apr 2023 15:36:34 -0600 Subject: [PATCH] add stacked overlay center widget to ensure exact center in desktop appbar --- lib/widgets/desktop/desktop_app_bar.dart | 36 ++++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/widgets/desktop/desktop_app_bar.dart b/lib/widgets/desktop/desktop_app_bar.dart index a95a552e5..848d4c0a3 100644 --- a/lib/widgets/desktop/desktop_app_bar.dart +++ b/lib/widgets/desktop/desktop_app_bar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; const double kDesktopAppBarHeight = 96.0; const double kDesktopAppBarHeightCompact = 82.0; @@ -8,6 +9,7 @@ class DesktopAppBar extends StatelessWidget { Key? key, this.leading, this.center, + this.overlayCenter, this.trailing, this.background = Colors.transparent, required this.isCompactHeight, @@ -16,6 +18,7 @@ class DesktopAppBar extends StatelessWidget { final Widget? leading; final Widget? center; + final Widget? overlayCenter; final Widget? trailing; final Color background; final bool isCompactHeight; @@ -43,16 +46,31 @@ class DesktopAppBar extends StatelessWidget { items.add(trailing!); } - return Container( - decoration: BoxDecoration( - color: background, + return ConditionalParent( + condition: overlayCenter != null, + builder: (child) => Stack( + children: [ + child, + Positioned.fill( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [overlayCenter!], + ), + ), + ], ), - height: - isCompactHeight ? kDesktopAppBarHeightCompact : kDesktopAppBarHeight, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: items, + child: Container( + decoration: BoxDecoration( + color: background, + ), + height: isCompactHeight + ? kDesktopAppBarHeightCompact + : kDesktopAppBarHeight, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: items, + ), ), ); }