Skip to content

Commit

Permalink
feat: add pinned header, fade child animation
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-orion committed Mar 14, 2024
1 parent 07e6b5a commit 476006b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lib/app/router/components/floating_app_bar/floating_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,35 @@ class FloatingAppBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
final double safeAreaOffset = MediaQuery.paddingOf(context).top;
final double totalHeight =
height + topOffset + bottomOffset + safeAreaOffset;
final double fadeOffset = topOffset + safeAreaOffset / 2;

return SliverAppBar(
elevation: 50,
floating: true,
pinned: true,
expandedHeight: height + topOffset + bottomOffset,
shadowColor:
context.theme.appColors.onTertararyBackground.withOpacity(0.05),
toolbarHeight: height + topOffset + bottomOffset,
toolbarHeight: 0,
backgroundColor: context.theme.appColors.onPrimaryAccent,
surfaceTintColor: context.theme.appColors.onPrimaryAccent,
flexibleSpace: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return ScreenTopOffset(margin: topOffset, child: child);
final double opacity = 1 -
((totalHeight - constraints.maxHeight) / fadeOffset).clamp(0, 1);
return Align(
alignment: Alignment.bottomCenter,
child: Opacity(
opacity: opacity,
child: Padding(
padding: EdgeInsets.only(bottom: bottomOffset),
child: child,
),
),
);
},
),
);
Expand Down

0 comments on commit 476006b

Please sign in to comment.