mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
stateless DynamicSliverAppBar
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -202,7 +202,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
class DynamicSliverAppBar extends StatefulWidget {
|
||||
class DynamicSliverAppBar extends StatelessWidget {
|
||||
const DynamicSliverAppBar.medium({
|
||||
super.key,
|
||||
this.leading,
|
||||
@@ -297,62 +297,57 @@ class DynamicSliverAppBar extends StatefulWidget {
|
||||
|
||||
final EdgeInsetsGeometry? actionsPadding;
|
||||
|
||||
@override
|
||||
State<DynamicSliverAppBar> createState() => _DynamicSliverAppBarState();
|
||||
}
|
||||
|
||||
class _DynamicSliverAppBarState extends State<DynamicSliverAppBar> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double bottomHeight = widget.bottom?.preferredSize.height ?? 0.0;
|
||||
final double topPadding = widget.primary
|
||||
final double bottomHeight = bottom?.preferredSize.height ?? 0.0;
|
||||
final double topPadding = primary
|
||||
? MediaQuery.viewPaddingOf(context).top
|
||||
: 0.0;
|
||||
final double effectiveCollapsedHeight =
|
||||
topPadding + kToolbarHeight + bottomHeight + 1;
|
||||
|
||||
return SliverPinnedHeader(
|
||||
onPerformLayout: widget.onPerformLayout,
|
||||
onPerformLayout: onPerformLayout,
|
||||
delegate: _SliverAppBarDelegate(
|
||||
leading: widget.leading,
|
||||
automaticallyImplyLeading: widget.automaticallyImplyLeading,
|
||||
title: widget.title,
|
||||
actions: widget.actions,
|
||||
automaticallyImplyActions: widget.automaticallyImplyActions,
|
||||
flexibleSpace: widget.flexibleSpace,
|
||||
bottom: widget.bottom,
|
||||
elevation: widget.elevation,
|
||||
scrolledUnderElevation: widget.scrolledUnderElevation,
|
||||
shadowColor: widget.shadowColor,
|
||||
surfaceTintColor: widget.surfaceTintColor,
|
||||
forceElevated: widget.forceElevated,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
foregroundColor: widget.foregroundColor,
|
||||
iconTheme: widget.iconTheme,
|
||||
actionsIconTheme: widget.actionsIconTheme,
|
||||
primary: widget.primary,
|
||||
centerTitle: widget.centerTitle,
|
||||
excludeHeaderSemantics: widget.excludeHeaderSemantics,
|
||||
titleSpacing: widget.titleSpacing,
|
||||
leading: leading,
|
||||
automaticallyImplyLeading: automaticallyImplyLeading,
|
||||
title: title,
|
||||
actions: actions,
|
||||
automaticallyImplyActions: automaticallyImplyActions,
|
||||
flexibleSpace: flexibleSpace,
|
||||
bottom: bottom,
|
||||
elevation: elevation,
|
||||
scrolledUnderElevation: scrolledUnderElevation,
|
||||
shadowColor: shadowColor,
|
||||
surfaceTintColor: surfaceTintColor,
|
||||
forceElevated: forceElevated,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
iconTheme: iconTheme,
|
||||
actionsIconTheme: actionsIconTheme,
|
||||
primary: primary,
|
||||
centerTitle: centerTitle,
|
||||
excludeHeaderSemantics: excludeHeaderSemantics,
|
||||
titleSpacing: titleSpacing,
|
||||
collapsedHeight: effectiveCollapsedHeight,
|
||||
topPadding: topPadding,
|
||||
shape: widget.shape,
|
||||
shape: shape,
|
||||
toolbarHeight: kToolbarHeight,
|
||||
leadingWidth: widget.leadingWidth,
|
||||
toolbarTextStyle: widget.toolbarTextStyle,
|
||||
titleTextStyle: widget.titleTextStyle,
|
||||
systemOverlayStyle: widget.systemOverlayStyle,
|
||||
forceMaterialTransparency: widget.forceMaterialTransparency,
|
||||
useDefaultSemanticsOrder: widget.useDefaultSemanticsOrder,
|
||||
clipBehavior: widget.clipBehavior,
|
||||
actionsPadding: widget.actionsPadding,
|
||||
leadingWidth: leadingWidth,
|
||||
toolbarTextStyle: toolbarTextStyle,
|
||||
titleTextStyle: titleTextStyle,
|
||||
systemOverlayStyle: systemOverlayStyle,
|
||||
forceMaterialTransparency: forceMaterialTransparency,
|
||||
useDefaultSemanticsOrder: useDefaultSemanticsOrder,
|
||||
clipBehavior: clipBehavior,
|
||||
actionsPadding: actionsPadding,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// ref [FlexibleSpaceBar]
|
||||
class DynamicFlexibleSpaceBar extends StatefulWidget {
|
||||
class DynamicFlexibleSpaceBar extends StatelessWidget {
|
||||
const DynamicFlexibleSpaceBar({
|
||||
super.key,
|
||||
required this.background,
|
||||
@@ -363,14 +358,8 @@ class DynamicFlexibleSpaceBar extends StatefulWidget {
|
||||
|
||||
final CollapseMode collapseMode;
|
||||
|
||||
@override
|
||||
State<DynamicFlexibleSpaceBar> createState() =>
|
||||
_DynamicFlexibleSpaceBarState();
|
||||
}
|
||||
|
||||
class _DynamicFlexibleSpaceBarState extends State<DynamicFlexibleSpaceBar> {
|
||||
double _getCollapsePadding(double t, FlexibleSpaceBarSettings settings) {
|
||||
switch (widget.collapseMode) {
|
||||
switch (collapseMode) {
|
||||
case CollapseMode.pin:
|
||||
return -(settings.maxExtent - settings.currentExtent);
|
||||
case CollapseMode.none:
|
||||
@@ -427,7 +416,7 @@ class _DynamicFlexibleSpaceBarState extends State<DynamicFlexibleSpaceBar> {
|
||||
// through the app bar when it is collapsed.
|
||||
alwaysIncludeSemantics: true,
|
||||
opacity: opacity,
|
||||
child: widget.background,
|
||||
child: background,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user