コード例 #1
0
ファイル: navigation_toolbar.cs プロジェクト: JC-ut0/CubeGame
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            List <Widget> children = new List <Widget>();

            if (this.leading != null)
            {
                children.Add(new LayoutId(id: _ToolbarSlot.leading, child: this.leading));
            }

            if (this.middle != null)
            {
                children.Add(new LayoutId(id: _ToolbarSlot.middle, child: this.middle));
            }

            if (this.trailing != null)
            {
                children.Add(new LayoutId(id: _ToolbarSlot.trailing, child: this.trailing));
            }

            TextDirection textDirection = Directionality.of(context);

            return(new CustomMultiChildLayout(
                       layoutDelegate: new _ToolbarLayout(
                           centerMiddle: this.centerMiddle,
                           middleSpacing: this.middleSpacing,
                           textDirection: textDirection
                           ),
                       children: children
                       ));
        }
コード例 #2
0
 public override Widget build(BuildContext context)
 {
     D.assert(WidgetsD.debugCheckHasDirectionality(context));
     return(new CustomPaint(
                foregroundPainter: new BannerPainter(
                    message: this.message,
                    location: this.location,
                    color: this.color,
                    textStyle: this.textStyle
                    ),
                child: this.child
                ));
 }
コード例 #3
0
 public override Widget build(BuildContext context)
 {
     D.assert(WidgetsD.debugCheckHasDirectionality(context));
     return(Positioned.directional(
                textDirection: Directionality.of(context: context),
                child: widget.child,
                start: _start?.evaluate(animation: animation),
                top: _top?.evaluate(animation: animation),
                end: _end?.evaluate(animation: animation),
                bottom: _bottom?.evaluate(animation: animation),
                width: _width?.evaluate(animation: animation),
                height: _height?.evaluate(animation: animation)
                ));
 }
コード例 #4
0
 public override Widget build(BuildContext context)
 {
     D.assert((textDirection != null && layoutDirection != null) || WidgetsD.debugCheckHasDirectionality(context));
     return(new CustomPaint(
                foregroundPainter: new BannerPainter(
                    message: message,
                    textDirection: textDirection ?? Directionality.of(context),
                    location: location,
                    layoutDirection: layoutDirection ?? Directionality.of(context),
                    color: color,
                    textStyle: textStyle
                    ),
                child: child
                ));
 }
コード例 #5
0
        AxisDirection?_getDirection(BuildContext context)
        {
            switch (widget.scrollDirection)
            {
            case Axis.horizontal:
                D.assert(WidgetsD.debugCheckHasDirectionality(context));
                TextDirection textDirection = Directionality.of(context);
                AxisDirection?axisDirection = AxisUtils.textDirectionToAxisDirection(textDirection);
                return(widget.reverse ? AxisUtils.flipAxisDirection(axisDirection) : axisDirection);

            case Axis.vertical:
                return(widget.reverse ? AxisDirection.up : AxisDirection.down);
            }

            throw new UIWidgetsError("fail to get axis direction");
        }
コード例 #6
0
ファイル: dismissible.cs プロジェクト: liangxiegame/Habbit
        public override Widget build(BuildContext context)
        {
            base.build(context); // See AutomaticKeepAliveClientMixin.

            D.assert(!this._directionIsXAxis || WidgetsD.debugCheckHasDirectionality(context));

            Widget background = this.widget.background;

            if (this.widget.secondaryBackground != null)
            {
                DismissDirection?direction = this._dismissDirection;
                if (direction == DismissDirection.endToStart || direction == DismissDirection.up)
                {
                    background = this.widget.secondaryBackground;
                }
            }

            if (this._resizeAnimation != null)
            {
                // we've been dragged aside, and are now resizing.
                D.assert(() => {
                    if (this._resizeAnimation.status != AnimationStatus.forward)
                    {
                        D.assert(this._resizeAnimation.status == AnimationStatus.completed);
                        throw new UIWidgetsError(
                            "A dismissed Dismissible widget is still part of the tree.\n" +
                            "Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n" +
                            "widget from the application once that handler has fired."
                            );
                    }

                    return(true);
                });

                return(new SizeTransition(
                           sizeFactor: this._resizeAnimation,
                           axis: this._directionIsXAxis ? Axis.vertical : Axis.horizontal,
                           child: new SizedBox(
                               width: this._sizePriorToCollapse.width,
                               height: this._sizePriorToCollapse.height,
                               child: background
                               )
                           ));
            }

            Widget content = new SlideTransition(
                position: this._moveAnimation,
                child: this.widget.child
                );

            if (background != null)
            {
                List <Widget> children = new List <Widget> {
                };

                if (!this._moveAnimation.isDismissed)
                {
                    children.Add(Positioned.fill(
                                     child: new ClipRect(
                                         clipper: new _DismissibleClipper(
                                             axis: this._directionIsXAxis ? Axis.horizontal : Axis.vertical,
                                             moveAnimation: this._moveAnimation
                                             ),
                                         child: background
                                         )
                                     ));
                }

                children.Add(content);
                content = new Stack(children: children);
            }

            return(new GestureDetector(
                       onHorizontalDragStart: this._directionIsXAxis ? (GestureDragStartCallback)this._handleDragStart : null,
                       onHorizontalDragUpdate: this._directionIsXAxis
                    ? (GestureDragUpdateCallback)this._handleDragUpdate
                    : null,
                       onHorizontalDragEnd: this._directionIsXAxis ? (GestureDragEndCallback)this._handleDragEnd : null,
                       onVerticalDragStart: this._directionIsXAxis ? null : (GestureDragStartCallback)this._handleDragStart,
                       onVerticalDragUpdate: this._directionIsXAxis
                    ? null
                    : (GestureDragUpdateCallback)this._handleDragUpdate,
                       onVerticalDragEnd: this._directionIsXAxis ? null : (GestureDragEndCallback)this._handleDragEnd,
                       behavior: HitTestBehavior.opaque,
                       child: content,
                       dragStartBehavior: this.widget.dragStartBehavior
                       ));
        }
コード例 #7
0
        public override Widget build(BuildContext context)
        {
            D.assert(this.textDirection != null || WidgetsD.debugCheckHasDirectionality(context));
            TextDirection textDirection = this.textDirection ?? Directionality.of(context);
            IconThemeData iconTheme     = IconTheme.of(context);
            float         iconSize      = size ?? iconTheme.size.Value;

            if (icon == null)
            {
                return(new SizedBox(width: iconSize, height: iconSize));
            }

            float iconOpacity = iconTheme.opacity.Value;
            Color iconColor   = color ?? iconTheme.color;

            if (iconOpacity != 1.0)
            {
                iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity);
            }
            Widget iconWidget = new RichText(
                overflow: TextOverflow.visible, // Never clip.
                textDirection: textDirection,   // Since we already fetched it for the assert...
                text: new TextSpan(
                    text: new string(new[] { (char)icon.codePoint }),
                    style: new TextStyle(
                        inherit: false,
                        color: iconColor,
                        fontSize: iconSize,
                        fontFamily: icon.fontFamily
                        )
                    )
                );

            var matrix = Matrix4.identity();

            matrix.scale(-1.0f, 1.0f, 1.0f);
            if (icon.matchTextDirection)
            {
                switch (textDirection)
                {
                case TextDirection.rtl:
                    iconWidget = new Transform(
                        transform: matrix,
                        alignment: Alignment.center,
                        transformHitTests: false,
                        child: iconWidget
                        );
                    break;

                case TextDirection.ltr:
                    break;
                }
            }
            return(new SizedBox(
                       width: iconSize,
                       height: iconSize,
                       child: new Center(
                           child: iconWidget
                           )
                       ));
        }