Exemplo n.º 1
0
        public static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation)
        {
            switch (contextMenuLocation)
            {
            case _ContextMenuLocation.center:
                return(AlignmentDirectional.topCenter);

            case _ContextMenuLocation.right:
                return(AlignmentDirectional.topEnd);

            default:
                return(AlignmentDirectional.topStart);
            }
        }
Exemplo n.º 2
0
 public _ContextMenuSheet(
     Key key = null,
     List <Widget> actions = null,
     _ContextMenuLocation contextMenuLocation = default,
     Orientation orientation = default
     ) : base(key: key)
 {
     D.assert(actions != null && actions.isNotEmpty());
     D.assert(contextMenuLocation != null);
     D.assert(orientation != null);
     _contextMenuLocation = contextMenuLocation;
     _orientation         = orientation;
     this.actions         = actions;
 }
Exemplo n.º 3
0
 public _ContextMenuRoute(
     List <Widget> actions = null,
     _ContextMenuLocation contextMenuLocation = default,
     string barrierLabel = null,
     _ContextMenuPreviewBuilderChildless builder = null,
     ImageFilter filter     = null,
     Rect previousChildRect = null,
     RouteSettings settings = null
     ) : base(filter: filter, settings: settings)
 {
     D.assert(actions != null && actions.isNotEmpty());
     D.assert(contextMenuLocation != null);
     this.barrierLabel    = barrierLabel;
     _actions             = actions;
     _builder             = builder;
     _contextMenuLocation = contextMenuLocation;
     _previousChildRect   = previousChildRect;
 }
Exemplo n.º 4
0
        Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation)
        {
            switch (contextMenuLocation)
            {
            case _ContextMenuLocation.center:
                return(orientation == Orientation.portrait
                    ? Alignment.bottomCenter
                    : Alignment.topRight);

            case _ContextMenuLocation.right:
                return(orientation == Orientation.portrait
                    ? Alignment.bottomCenter
                    : Alignment.topLeft);

            default:
                return(orientation == Orientation.portrait
                    ? Alignment.bottomCenter
                    : Alignment.topRight);
            }
        }
Exemplo n.º 5
0
 public _ContextMenuRouteStatic(
     Key key = null,
     List <Widget> actions    = null,
     Widget child             = null,
     GlobalKey childGlobalKey = null,
     _ContextMenuLocation contextMenuLocation = default,
     _DismissCallback onDismiss = default,
     Orientation orientation    = default,
     GlobalKey sheetGlobalKey   = null
     ) : base(key: key)
 {
     D.assert(contextMenuLocation != default);
     D.assert(orientation != default);
     this.actions             = actions;
     this.child               = child;
     this.childGlobalKey      = childGlobalKey;
     this.contextMenuLocation = contextMenuLocation;
     this.onDismiss           = onDismiss;
     this.orientation         = orientation;
     this.sheetGlobalKey      = sheetGlobalKey;
 }
Exemplo n.º 6
0
        public static Rect _getSheetRectBegin(Orientation orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect)
        {
            switch (contextMenuLocation)
            {
            case _ContextMenuLocation.center:
                Offset target1 = (orientation == Orientation.portrait)
                        ? childRect.bottomCenter
                        : childRect.topCenter;
                Offset centered = target1 - new Offset(sheetRect.width / 2, 0.0f);
                return(centered & sheetRect.size);

            case _ContextMenuLocation.right:
                Offset target2 = ((orientation == Orientation.portrait)
                        ? childRect.bottomRight
                        : childRect.topRight);
                return((target2 - new Offset(sheetRect.width, 0.0f)) & sheetRect.size);

            default:
                Offset target3 = orientation == Orientation.portrait
                        ? childRect.bottomLeft
                        : childRect.topLeft;
                return(target3 & sheetRect.size);
            }
        }
Exemplo n.º 7
0
        List <Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation)
        {
            Expanded child = new Expanded(
                child: new Align(
                    alignment: _getChildAlignment(
                        widget.orientation,
                        widget.contextMenuLocation
                        ),
                    child: new AnimatedBuilder(
                        animation: _moveController,
                        builder: _buildChildAnimation,
                        child: widget.child
                        )
                    )
                );
            Container spacer = new Container(
                width: _kPadding,
                height: _kPadding
                );
            Expanded sheet = new Expanded(
                child: new AnimatedBuilder(
                    animation: _sheetController,
                    builder: _buildSheetAnimation,
                    child: new _ContextMenuSheet(
                        key: widget.sheetGlobalKey,
                        actions: widget.actions,
                        contextMenuLocation: widget.contextMenuLocation,
                        orientation: widget.orientation
                        )
                    )
                );
            List <Widget> centerWidgets = new List <Widget>();

            centerWidgets.Add(child);
            centerWidgets.Add(spacer);
            centerWidgets.Add(sheet);
            List <Widget> rightWidgets = new List <Widget>();

            rightWidgets.Add(sheet);
            rightWidgets.Add(spacer);
            rightWidgets.Add(child);
            switch (contextMenuLocation)
            {
            case _ContextMenuLocation.center:
                return(new List <Widget> {
                    child, spacer, sheet
                });

            case _ContextMenuLocation.right:
                return(orientation == Orientation.portrait
            ? new List <Widget> {
                    child, spacer, sheet
                }
            : new List <Widget> {
                    sheet, spacer, child
                });

            default:
                return(new List <Widget> {
                    child, spacer, sheet
                });
            }
        }