Skip to content

Commit

Permalink
feat: animated transition of root PageWindowTitleBar
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Oct 10, 2022
1 parent 4df917e commit ff35e06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
28 changes: 17 additions & 11 deletions lib/components/Home/Shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,24 @@ class Shell extends HookConsumerWidget {
return null;
}, [backgroundColor]);

const pageWindowTitleBar = PageWindowTitleBar();
final allowedPath = _path.values.contains(GoRouter.of(context).location);
final preferredSize =
allowedPath ? PageWindowTitleBar.staticPreferredSize : Size.zero;
return Scaffold(
primary: true,
appBar: _path.values.contains(GoRouter.of(context).location)
? pageWindowTitleBar
: null,
appBar: PreferredSize(
preferredSize: preferredSize,
child: AnimatedContainer(
duration: const Duration(milliseconds: 250),
height:
allowedPath ? PageWindowTitleBar.staticPreferredSize.height : 0,
child: AnimatedOpacity(
duration: const Duration(milliseconds: 250),
opacity: allowedPath ? 1 : 0,
child: PageWindowTitleBar(preferredSize: preferredSize),
),
),
),
extendBodyBehindAppBar: true,
body: Row(
children: [
Expand All @@ -78,13 +90,7 @@ class Shell extends HookConsumerWidget {
GoRouter.of(context).go(_path[selectedIndex]!);
},
),
Expanded(
child: Column(
children: [
Expanded(child: child),
],
),
),
Expanded(child: child),
],
),
extendBody: true,
Expand Down
12 changes: 9 additions & 3 deletions lib/components/Shared/PageWindowTitleBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,24 @@ class PageWindowTitleBar extends StatelessWidget
final Widget? center;
final Color? backgroundColor;
final Color? foregroundColor;
final Size? _preferredSize;
const PageWindowTitleBar({
Key? key,
Size? preferredSize,
this.leading,
this.center,
this.backgroundColor,
this.foregroundColor,
}) : super(key: key);
@override
Size get preferredSize => Size.fromHeight(
}) : _preferredSize = preferredSize,
super(key: key);

static Size get staticPreferredSize => Size.fromHeight(
(kIsDesktop ? appWindow.titleBarHeight : 35),
);

@override
Size get preferredSize => _preferredSize ?? staticPreferredSize;

@override
Widget build(BuildContext context) {
if (kIsMobile) {
Expand Down

0 comments on commit ff35e06

Please sign in to comment.