Exemplo n.º 1
0
 public _HeroFlightManifest(
     HeroFlightDirection type,
     OverlayState overlay,
     Rect navigatorRect,
     PageRoute fromRoute,
     PageRoute toRoute,
     _HeroState fromHero,
     _HeroState toHero,
     CreateRectTween createRectTween,
     HeroFlightShuttleBuilder shuttleBuilder,
     bool isUserGestureTransition
     )
 {
     D.assert(fromHero.widget.tag == toHero.widget.tag);
     this.type                    = type;
     this.overlay                 = overlay;
     this.navigatorRect           = navigatorRect;
     this.fromRoute               = fromRoute;
     this.toRoute                 = toRoute;
     this.fromHero                = fromHero;
     this.toHero                  = toHero;
     this.createRectTween         = createRectTween;
     this.shuttleBuilder          = shuttleBuilder;
     this.isUserGestureTransition = isUserGestureTransition;
 }
Exemplo n.º 2
0
        public _DragAvatar(
            OverlayState overlayState,
            T data    = default,
            Axis?axis = null,
            Offset initialPosition = null,
            Offset dragStartPoint  = null,
            Widget feedback        = null,
            Offset feedbackOffset  = null,
            _OnDragEnd onDragEnd   = null
            )
        {
            if (feedbackOffset == null)
            {
                feedbackOffset = Offset.zero;
            }

            D.assert(overlayState != null);
            this.overlayState   = overlayState;
            this.data           = data;
            this.axis           = axis;
            this.dragStartPoint = dragStartPoint ?? Offset.zero;
            this.feedback       = feedback;
            this.feedbackOffset = feedbackOffset ?? Offset.zero;
            this.onDragEnd      = onDragEnd;

            _entry = new OverlayEntry(_build);
            this.overlayState.insert(_entry);
            _position = initialPosition ?? Offset.zero;
            updateDrag(initialPosition);
        }
Exemplo n.º 3
0
        public TextSelectionOverlay(TextEditingValue value                  = null,
                                    BuildContext context                    = null, Widget debugRequiredFor = null,
                                    LayerLink layerLink                     = null,
                                    RenderEditable renderObject             = null,
                                    TextSelectionControls selectionControls = null,
                                    TextSelectionDelegate selectionDelegate = null,
                                    DragStartBehavior dragStartBehavior     = DragStartBehavior.start)
        {
            D.assert(value != null);
            D.assert(context != null);
            this.context           = context;
            this.debugRequiredFor  = debugRequiredFor;
            this.layerLink         = layerLink;
            this.renderObject      = renderObject;
            this.selectionControls = selectionControls;
            this.selectionDelegate = selectionDelegate;
            this._value            = value;
            OverlayState overlay = Overlay.of(context);

            D.assert(overlay != null, () => $"No Overlay widget exists above {context}.\n" +
                     "Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your " +
                     "app content was created above the Navigator with the WidgetsApp builder parameter.");
            this._toolbarController = new AnimationController(duration: fadeDuration, vsync: overlay);
            this.dragStartBehavior  = dragStartBehavior;
        }
Exemplo n.º 4
0
        public static OverlayState of(
            BuildContext context,
            bool rootOverlay        = false,
            Widget debugRequiredFor = null)
        {
            OverlayState result = rootOverlay
                ? context.findRootAncestorStateOfType <OverlayState>()
                : context.findAncestorStateOfType <OverlayState>();

            D.assert(() => {
                if (debugRequiredFor != null && result == null)
                {
                    var additional = context.widget != debugRequiredFor
                        ? context.describeElement($"\nThe context from which that widget was searching for an overlay was:\n  {context}")
                        : context.describeElement("");
                    throw new UIWidgetsError(
                        new List <DiagnosticsNode>()
                    {
                        new ErrorSummary("No Overlay widget found."),
                        new ErrorDescription($"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation."),
                        new ErrorHint("The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call."),
                        new DiagnosticsProperty <Widget>("The specific widget that failed to find an overlay was", debugRequiredFor, style: DiagnosticsTreeStyle.errorProperty),
                        additional
                    });
                }

                return(true);
            });
            return(result);
        }
Exemplo n.º 5
0
 public _HeroFlightManifest(
     HeroFlightDirection type                = default,
     OverlayState overlay                    = null,
     Rect navigatorRect                      = null,
     PageRoute fromRoute                     = null,
     PageRoute toRoute                       = null,
     _HeroState fromHero                     = null,
     _HeroState toHero                       = null,
     CreateRectTween createRectTween         = null,
     HeroFlightShuttleBuilder shuttleBuilder = null,
     bool?isUserGestureTransition            = null,
     bool?isDiverted = null
     )
 {
     D.assert(fromHero.widget.tag.Equals(toHero.widget.tag));
     this.type                    = type;
     this.overlay                 = overlay;
     this.navigatorRect           = navigatorRect;
     this.fromRoute               = fromRoute;
     this.toRoute                 = toRoute;
     this.fromHero                = fromHero;
     this.toHero                  = toHero;
     this.createRectTween         = createRectTween;
     this.shuttleBuilder          = shuttleBuilder;
     this.isUserGestureTransition = isUserGestureTransition ?? false;
     this.isDiverted              = isDiverted ?? false;
 }
Exemplo n.º 6
0
        public void remove()
        {
            D.assert(this._overlay != null);
            OverlayState overlay = this._overlay;

            this._overlay = null;
            if (SchedulerBinding.instance.schedulerPhase == SchedulerPhase.persistentCallbacks)
            {
                SchedulerBinding.instance.addPostFrameCallback((duration) => { overlay._remove(this); });
            }
            else
            {
                overlay._remove(this);
            }
        }
Exemplo n.º 7
0
        public _DragAvatar(
            T data,
            OverlayState overlayState,
            Axis?axis = null,
            Offset initialPosition = null,
            Offset dragStartPoint  = null,
            Widget feedback        = null,
            Offset feedbackOffset  = null,
            _OnDragEnd onDragEnd   = null
            )
        {
            if (initialPosition == null)
            {
                initialPosition = Offset.zero;
            }

            if (dragStartPoint == null)
            {
                dragStartPoint = Offset.zero;
            }

            if (feedbackOffset == null)
            {
                feedbackOffset = Offset.zero;
            }

            D.assert(overlayState != null);
            this.overlayState   = overlayState;
            this.data           = data;
            this.axis           = axis;
            this.dragStartPoint = dragStartPoint;
            this.feedback       = feedback;
            this.feedbackOffset = feedbackOffset;
            this.onDragEnd      = onDragEnd;

            this._entry = new OverlayEntry(this._build);

            this.overlayState.insert(this._entry);
            this._position = initialPosition;
            this.updateDrag(initialPosition);
        }
Exemplo n.º 8
0
        public TextSelectionOverlay(TextEditingValue value                  = null,
                                    BuildContext context                    = null, Widget debugRequiredFor = null,
                                    LayerLink layerLink                     = null,
                                    RenderEditable renderObject             = null,
                                    TextSelectionControls selectionControls = null,
                                    TextSelectionDelegate selectionDelegate = null)
        {
            D.assert(value != null);
            D.assert(context != null);
            this.context           = context;
            this.debugRequiredFor  = debugRequiredFor;
            this.layerLink         = layerLink;
            this.renderObject      = renderObject;
            this.selectionControls = selectionControls;
            this.selectionDelegate = selectionDelegate;
            this._value            = value;
            OverlayState overlay = Overlay.of(context);

            D.assert(overlay != null);
            this._handleController  = new AnimationController(duration: _fadeDuration, vsync: overlay);
            this._toolbarController = new AnimationController(duration: _fadeDuration, vsync: overlay);
        }
Exemplo n.º 9
0
        public TextSelectionOverlay(
            TextEditingValue value                  = null,
            BuildContext context                    = null,
            Widget debugRequiredFor                 = null,
            LayerLink toolbarLayerLink              = null,
            LayerLink startHandleLayerLink          = null,
            LayerLink endHandleLayerLink            = null,
            RenderEditable renderObject             = null,
            TextSelectionControls selectionControls = null,
            bool?handlesVisible = false,
            TextSelectionDelegate selectionDelegate = null,
            DragStartBehavior dragStartBehavior     = DragStartBehavior.start,
            VoidCallback onSelectionHandleTapped    = null)
        {
            D.assert(value != null);
            D.assert(context != null);
            D.assert(handlesVisible != null);
            _handlesVisible              = handlesVisible.Value;
            this.context                 = context;
            this.debugRequiredFor        = debugRequiredFor;
            this.toolbarLayerLink        = toolbarLayerLink;
            this.startHandleLayerLink    = startHandleLayerLink;
            this.endHandleLayerLink      = endHandleLayerLink;
            this.renderObject            = renderObject;
            this.selectionControls       = selectionControls;
            this.selectionDelegate       = selectionDelegate;
            this.onSelectionHandleTapped = onSelectionHandleTapped;
            _value = value;
            OverlayState overlay = Overlay.of(context, rootOverlay: true);

            D.assert(overlay != null, () => $"No Overlay widget exists above {context}.\n" +
                     "Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your " +
                     "app content was created above the Navigator with the WidgetsApp builder parameter.");
            _toolbarController     = new AnimationController(duration: fadeDuration, vsync: overlay);
            this.dragStartBehavior = dragStartBehavior;
        }
Exemplo n.º 10
0
        public static OverlayState of(BuildContext context, Widget debugRequiredFor = null)
        {
            OverlayState result = (OverlayState)context.ancestorStateOfType(new TypeMatcher <OverlayState>());

            D.assert(() => {
                if (debugRequiredFor != null && result == null)
                {
                    var additional = context.widget != debugRequiredFor
                        ? $"\nThe context from which that widget was searching for an overlay was:\n  {context}"
                        : "";
                    throw new UIWidgetsError(
                        "No Overlay widget found.\n" +
                        $"{debugRequiredFor.GetType()} widgets require an Overlay widget ancestor for correct operation.\n" +
                        "The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n" +
                        "The specific widget that failed to find an overlay was:\n" +
                        $"  {debugRequiredFor}" +
                        $"{additional}"
                        );
                }

                return(true);
            });
            return(result);
        }