From a231c96aee3d6788acd17c8d844e6b71fb5a4a81 Mon Sep 17 00:00:00 2001 From: Jaylen Bian Date: Mon, 26 Jul 2021 23:51:15 +0800 Subject: [PATCH] [infra_ui][overlay] Impl route and pannel --- .../lib/src/overlay/overlay_manager.dart | 31 ++++++------------- .../lib/src/overlay/overlay_pannel.dart | 5 ++- .../lib/src/overlay/overlay_route.dart | 2 ++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_manager.dart b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_manager.dart index 99a0f81bac..fffa1de802 100644 --- a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_manager.dart +++ b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_manager.dart @@ -1,7 +1,15 @@ import 'package:flutter/material.dart'; +final GlobalKey _key = GlobalKey(); +TransitionBuilder overlayManagerBuilder() { + return (context, child) { + return OverlayManager(key: _key, child: child); + } +} + class OverlayManager extends StatefulWidget { - const OverlayManager({Key? key}) : super(key: key); + const OverlayManager({Key? key, required this.child}) : super(key: key); + final Widget? child; static OverlayManagerState of( BuildContext context, { @@ -49,23 +57,4 @@ class OverlayManagerState extends State { Navigator.of(context, rootNavigator: true); return Container(); } -} - - -// TODO: Impl show method - // void show(BuildContext context) { - // assert(_overlayRoute == null, 'Can\'t push single overlay twice.'); - // final NavigatorState navigator = Navigator.of(context); - // final RenderBox renderBox = context.findRenderObject()! as RenderBox; - - // _overlayRoute = OverlayPannelRoute( - // anchorDirection: widget.anchorDirection, - // barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, - // anchorPosition: widget.anchorPosition, - // maxWidth: widget.maxWidth ?? renderBox.size.width, - // maxHeight: widget.maxHeight ?? renderBox.size.height, - // ); - // _createRouteAnimation(_overlayRoute!); - - // navigator.push(_overlayRoute!); - // } \ No newline at end of file +} \ No newline at end of file diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_pannel.dart b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_pannel.dart index a3b4b83331..92f55e88bf 100644 --- a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_pannel.dart +++ b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_pannel.dart @@ -69,7 +69,10 @@ class _OverlayPannelState extends State with WidgetsBindingObserv @override Widget build(BuildContext context) { - return Container(); + return FadeTransition( + opacity: _fadeOpacity, + child: widget.route.widgetBuilder(context), + ); } @override diff --git a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_route.dart b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_route.dart index 6efe4fb74f..68cf2a853f 100644 --- a/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_route.dart +++ b/app_flowy/packages/flowy_infra_ui/lib/src/overlay/overlay_route.dart @@ -14,6 +14,7 @@ class OverlayPannelRoute extends PopupRoute<_OverlayRouteResult> { final Offset anchorPosition; final double maxWidth; final double maxHeight; + final WidgetBuilder widgetBuilder; OverlayPannelRoute({ this.padding = EdgeInsets.zero, @@ -23,6 +24,7 @@ class OverlayPannelRoute extends PopupRoute<_OverlayRouteResult> { required this.anchorPosition, required this.maxWidth, required this.maxHeight, + required this.widgetBuilder, }); @override