[infra_ui][overlay] Impl route and pannel

This commit is contained in:
Jaylen Bian 2021-07-26 23:51:15 +08:00
parent 06ac3bc29e
commit a231c96aee
3 changed files with 16 additions and 22 deletions

View File

@ -1,7 +1,15 @@
import 'package:flutter/material.dart';
final GlobalKey<OverlayManagerState> _key = GlobalKey<OverlayManagerState>();
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<OverlayManager> {
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!);
// }
}

View File

@ -69,7 +69,10 @@ class _OverlayPannelState extends State<OverlayPannel> with WidgetsBindingObserv
@override
Widget build(BuildContext context) {
return Container();
return FadeTransition(
opacity: _fadeOpacity,
child: widget.route.widgetBuilder(context),
);
}
@override

View File

@ -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