feat: animated transition of root PageWindowTitleBar

This commit is contained in:
Kingkor Roy Tirtho 2022-10-10 23:25:58 +06:00
parent 4df917e65e
commit ff35e06a66
2 changed files with 26 additions and 14 deletions

View File

@ -62,12 +62,24 @@ class Shell extends HookConsumerWidget {
return null; return null;
}, [backgroundColor]); }, [backgroundColor]);
const pageWindowTitleBar = PageWindowTitleBar(); final allowedPath = _path.values.contains(GoRouter.of(context).location);
final preferredSize =
allowedPath ? PageWindowTitleBar.staticPreferredSize : Size.zero;
return Scaffold( return Scaffold(
primary: true, primary: true,
appBar: _path.values.contains(GoRouter.of(context).location) appBar: PreferredSize(
? pageWindowTitleBar preferredSize: preferredSize,
: null, 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, extendBodyBehindAppBar: true,
body: Row( body: Row(
children: [ children: [
@ -78,13 +90,7 @@ class Shell extends HookConsumerWidget {
GoRouter.of(context).go(_path[selectedIndex]!); GoRouter.of(context).go(_path[selectedIndex]!);
}, },
), ),
Expanded( Expanded(child: child),
child: Column(
children: [
Expanded(child: child),
],
),
),
], ],
), ),
extendBody: true, extendBody: true,

View File

@ -77,18 +77,24 @@ class PageWindowTitleBar extends StatelessWidget
final Widget? center; final Widget? center;
final Color? backgroundColor; final Color? backgroundColor;
final Color? foregroundColor; final Color? foregroundColor;
final Size? _preferredSize;
const PageWindowTitleBar({ const PageWindowTitleBar({
Key? key, Key? key,
Size? preferredSize,
this.leading, this.leading,
this.center, this.center,
this.backgroundColor, this.backgroundColor,
this.foregroundColor, this.foregroundColor,
}) : super(key: key); }) : _preferredSize = preferredSize,
@override super(key: key);
Size get preferredSize => Size.fromHeight(
static Size get staticPreferredSize => Size.fromHeight(
(kIsDesktop ? appWindow.titleBarHeight : 35), (kIsDesktop ? appWindow.titleBarHeight : 35),
); );
@override
Size get preferredSize => _preferredSize ?? staticPreferredSize;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (kIsMobile) { if (kIsMobile) {