diff --git a/lib/src/components/top_app_bar/extended_top_app_bar.dart b/lib/src/components/top_app_bar/extended_top_app_bar.dart index b3b53735..7866d3e6 100644 --- a/lib/src/components/top_app_bar/extended_top_app_bar.dart +++ b/lib/src/components/top_app_bar/extended_top_app_bar.dart @@ -2,7 +2,14 @@ import 'package:flutter/material.dart'; import '../../../zeta_flutter.dart'; -const _searchBarOffset = 6; +const _searchBarOffsetTop = ZetaSpacing.x1 * 1.5; +const _searchBarOffsetRight = ZetaSpacing.x1 * 22; +const _maxExtent = ZetaSpacing.x1 * 26; +const _minExtent = ZetaSpacing.x16; +const _leftMin = ZetaSpacing.x4; +const _leftMax = ZetaSpacing.x14; +const _topMin = ZetaSpacing.x5; +const _topMax = ZetaSpacing.x1 * 15; /// Delegate for creating an extended app bar, that grows and shrinks when scrolling. class ZetaExtendedAppBarDelegate extends SliverPersistentHeaderDelegate { @@ -30,17 +37,10 @@ class ZetaExtendedAppBarDelegate extends SliverPersistentHeaderDelegate { /// If `ZetaTopAppBarType.extend` shrinks. Does not affect other types of app bar. final bool shrinks; - final double _maxExtent = ZetaSpacing.x1 * 26; - final double _minExtent = ZetaSpacing.x16; - final double _leftMin = ZetaSpacing.x4; - final double _leftMax = ZetaSpacing.x14; - final double _topMin = ZetaSpacing.x5; - final double _topMax = ZetaSpacing.x1 * 15; - @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { return ConstrainedBox( - constraints: BoxConstraints(minHeight: ZetaSpacing.x16, maxHeight: _maxExtent), + constraints: const BoxConstraints(minHeight: ZetaSpacing.x16, maxHeight: _maxExtent), child: ColoredBox( color: Zeta.of(context).colors.surfacePrimary, child: Stack( @@ -48,12 +48,12 @@ class ZetaExtendedAppBarDelegate extends SliverPersistentHeaderDelegate { Positioned( top: shrinks ? (_topMax + (-1 * shrinkOffset)).clamp( - _topMin - (searchController != null && searchController!.isEnabled ? _searchBarOffset : 0), + _topMin - (searchController != null && searchController!.isEnabled ? _searchBarOffsetTop : 0), _topMax, ) : _topMax, left: shrinks ? ((shrinkOffset / _maxExtent) * ZetaSpacing.x50).clamp(_leftMin, _leftMax) : _leftMin, - right: searchController != null && searchController!.isEnabled ? 88 : 0, + right: searchController != null && searchController!.isEnabled ? _searchBarOffsetRight : 0, child: title, ), if (leading != null) Positioned(top: ZetaSpacing.x3, left: ZetaSpacing.x2, child: leading!), diff --git a/lib/src/components/top_app_bar/search_top_app_bar.dart b/lib/src/components/top_app_bar/search_top_app_bar.dart index 3ceab8c9..d79a3991 100644 --- a/lib/src/components/top_app_bar/search_top_app_bar.dart +++ b/lib/src/components/top_app_bar/search_top_app_bar.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import '../../../zeta_flutter.dart'; +const _extendedOffset = ZetaSpacing.x1 * 6.5; + /// Creates a search field used on a [ZetaTopAppBar]. class ZetaTopAppBarSearchField extends StatefulWidget { /// Constructs a [ZetaTopAppBarSearchField]. @@ -148,7 +150,7 @@ class _ZetaTopAppBarSearchFieldState extends State wit ], ), ConstrainedBox( - constraints: BoxConstraints(maxHeight: widget.isExtended ? 26 : double.infinity), + constraints: BoxConstraints(maxHeight: widget.isExtended ? _extendedOffset : double.infinity), child: AnimatedBuilder( animation: _animationController, builder: (context, child) => Transform.scale( diff --git a/lib/src/components/top_app_bar/top_app_bar.dart b/lib/src/components/top_app_bar/top_app_bar.dart index 58df7f13..10df8e87 100644 --- a/lib/src/components/top_app_bar/top_app_bar.dart +++ b/lib/src/components/top_app_bar/top_app_bar.dart @@ -7,7 +7,7 @@ import 'search_top_app_bar.dart'; export 'search_top_app_bar.dart' show AppBarSearchController; -/// Top app bars provide content and actions related to the current screen +/// Top app bars provide content and actions related to the current screen. class ZetaTopAppBar extends StatefulWidget implements PreferredSizeWidget { /// Creates a ZetaTopAppBar. const ZetaTopAppBar({