示例#1
0
        public ToggleButtons(
            Key key = null,
            List <Widget> children          = null,
            List <bool> isSelected          = null,
            ToggleButtonOnPressed onPressed = null,
            TextStyle textStyle             = null,
            BoxConstraints constraints      = null,
            Color color                 = null,
            Color selectedColor         = null,
            Color disabledColor         = null,
            Color fillColor             = null,
            Color focusColor            = null,
            Color highlightColor        = null,
            Color hoverColor            = null,
            Color splashColor           = null,
            List <FocusNode> focusNodes = null,
            bool renderBorder           = false,
            Color borderColor           = null,
            Color selectedBorderColor   = null,
            Color disabledBorderColor   = null,
            BorderRadius borderRadius   = null,
            float?borderWidth           = null
            ) : base(key: key)
        {
            D.assert(children != null);
            D.assert(isSelected != null);
            D.assert(children.Count == isSelected.Count);

            this.children            = children;
            this.isSelected          = isSelected;
            this.onPressed           = onPressed;
            this.textStyle           = textStyle;
            this.constraints         = constraints;
            this.color               = color;
            this.selectedColor       = selectedColor;
            this.disabledColor       = disabledColor;
            this.fillColor           = fillColor;
            this.focusColor          = focusColor;
            this.highlightColor      = highlightColor;
            this.hoverColor          = hoverColor;
            this.splashColor         = splashColor;
            this.focusNodes          = focusNodes;
            this.renderBorder        = renderBorder;
            this.borderColor         = borderColor;
            this.selectedBorderColor = selectedBorderColor;
            this.disabledBorderColor = disabledBorderColor;
            this.borderRadius        = borderRadius;
            this.borderWidth         = borderWidth;
        }
示例#2
0
 Widget _buildIndicator(float animationValue)
 {
     return(new Container(
                constraints: BoxConstraints.tightFor(
                    float.PositiveInfinity,
                    2
                    ),
                child: new CustomPaint(
                    painter: new _CustomProgressPainter(this.widget.backgroundColor,
                                                        this.widget.valueColor?.value ?? CColors.PrimaryBlue, this.widget.value,
                                                        animationValue
                                                        )
                    )
                ));
 }
示例#3
0
 internal _DropdownMenuItemButton(
     Key key = null,
     _DropdownRoute <T> route   = null,
     EdgeInsets padding         = null,
     Rect buttonRect            = null,
     BoxConstraints constraints = null,
     int?itemIndex = null
     ) : base(key: key)
 {
     this.route       = route;
     this.padding     = padding;
     this.buttonRect  = buttonRect;
     this.constraints = constraints;
     this.itemIndex   = itemIndex;
 }
示例#4
0
 public _DropdownMenu(
     Key key                    = null,
     EdgeInsets padding         = null,
     _DropdownRoute <T> route   = null,
     Rect buttonRect            = null,
     BoxConstraints constraints = null,
     Color dropdownColor        = null
     ) : base(key: key)
 {
     this.route         = route;
     this.padding       = padding;
     this.buttonRect    = buttonRect;
     this.constraints   = constraints;
     this.dropdownColor = dropdownColor;
 }
        protected RenderToggleable(
            bool?value                           = null,
            bool tristate                        = false,
            Color activeColor                    = null,
            Color inactiveColor                  = null,
            ValueChanged <bool?> onChanged       = null,
            BoxConstraints additionalConstraints = null,
            TickerProvider vsync                 = null
            ) : base(additionalConstraints: additionalConstraints)
        {
            D.assert(tristate || value != null);
            D.assert(activeColor != null);
            D.assert(inactiveColor != null);
            D.assert(vsync != null);
            this._value         = value;
            this._tristate      = tristate;
            this._activeColor   = activeColor;
            this._inactiveColor = inactiveColor;
            this._onChanged     = onChanged;
            this._vsync         = vsync;

            this._tap = new TapGestureRecognizer {
                onTapDown   = this._handleTapDown,
                onTap       = this._handleTap,
                onTapUp     = this._handleTapUp,
                onTapCancel = this._handleTapCancel
            };

            this._positionController = new AnimationController(
                duration: ToggleableUtils._kToggleDuration,
                value: value == false ? 0.0f : 1.0f,
                vsync: vsync);

            this._position = new CurvedAnimation(
                parent: this._positionController,
                curve: Curves.linear);
            this._position.addListener(this.markNeedsPaint);
            this._position.addStatusListener(this._handlePositionStateChanged);

            this._reactionController = new AnimationController(
                duration: Constants.kRadialReactionDuration,
                vsync: vsync);

            this._reaction = new CurvedAnimation(
                parent: this._reactionController,
                curve: Curves.fastOutSlowIn);
            this._reaction.addListener(this.markNeedsPaint);
        }
示例#6
0
 public override Widget build(BuildContext context)
 {
     return(new GestureDetector(
                onTapDown: details => {
         if (this.dismissible)
         {
             Navigator.maybePop(context);
         }
     },
                behavior: HitTestBehavior.opaque,
                child: new ConstrainedBox(
                    constraints: BoxConstraints.expand(),
                    child: this.color == null ? null : new DecoratedBox(decoration: new BoxDecoration(this.color))
                    )
                ));
 }
        protected RenderBox insertAndLayoutLeadingChild(BoxConstraints childConstraints, bool parentUsesSize = false)
        {
            D.assert(this._debugAssertChildListLocked());

            int index = this.indexOf(this.firstChild) - 1;

            this._createOrObtainChild(index, after: null);
            if (this.indexOf(this.firstChild) == index)
            {
                this.firstChild.layout(childConstraints, parentUsesSize: parentUsesSize);
                return(this.firstChild);
            }

            this.childManager.setDidUnderflow(true);
            return(null);
        }
示例#8
0
        void slideEvent(RenderBox getBox, BoxConstraints box, Offset globalPosition)
        {
            float localDx  = getBox.globalToLocal(globalPosition).dx - 15f;
            float progress = localDx.clamp(0f, box.maxWidth - 30f) / (box.maxWidth - 30f);

            switch (trackType)
            {
            case TrackType.hue:
                // 360 is the same as zero
                // if set to 360, sliding to end goes to zero
                onColorChanged(hsvColor.withHue(progress * 359));

                break;

            case TrackType.saturation:
                onColorChanged(hsvColor.withSaturation(progress));
                break;

            case TrackType.saturationForHSL:
                onColorChanged(Utils.hslToHsv(Utils.hsvToHsl(hsvColor).withSaturation(progress)));
                break;

            case TrackType.value:
                onColorChanged(hsvColor.withValue(progress));
                break;

            case TrackType.lightness:
                onColorChanged(Utils.hslToHsv(Utils.hsvToHsl(hsvColor).withLightness(progress)));
                break;

            case TrackType.red:
                onColorChanged(HSVColorExtention.fromColor(hsvColor.toColor().withRed((progress * 0xff).round())));
                break;

            case TrackType.green:
                onColorChanged(HSVColorExtention.fromColor(hsvColor.toColor().withGreen((progress * 0xff).round())));
                break;

            case TrackType.blue:
                onColorChanged(HSVColorExtention.fromColor(hsvColor.toColor().withBlue((progress * 0xff).round())));
                break;

            case TrackType.alpha:
                onColorChanged(hsvColor.withAlpha(localDx.clamp(0f, box.maxWidth - 30f) / (box.maxWidth - 30f)));
                break;
            }
        }
示例#9
0
        private Widget renderUpload()
        {
            var    thumbnailPath = widget.shareState.thumbnailDir;
            Widget image         = new Icon(Icons.add_photo_alternate, color: new Color(0xFFCECECE), size: 72f);

            if (!string.IsNullOrEmpty(thumbnailPath))
            {
                image = Image.file(thumbnailPath, fit: BoxFit.cover, width: 72, height: 72);
            }

            var imgSelectButton = new FlatButton(
                child: new Text("Select image file...", style: new TextStyle(fontSize: 15f, color: new Color(0xFF2196F3), fontWeight: FontWeight.w700)),
                onPressed: () =>
            {
                string path = EditorUtility.OpenFilePanel("Select thumbnail", "", "jpg,jpeg,png");
                if (path.Length != 0)
                {
                    var fileInfo = new System.IO.FileInfo(path);

                    if (fileInfo.Length > thumbnailLimit)
                    {
                        widget.onErrorAction("Max file size 5MB");
                    }
                    else
                    {
                        widget.onThumbnailSelect(path);
                    }
                }
            }
                );
            var label = new Text(data: "Max file size 5MB (PNG or JPG)", style: new TextStyle(fontSize: 13f, color: new Color(0xFF888888)));

            return(new Container(
                       color: new Color(0xFFF6F6F6),
                       padding: EdgeInsets.only(top: 10, bottom: 10),
                       child:
                       new Column(
                           children: new List <Widget>()
            {
                image,
                imgSelectButton,
                label
            }
                           ),
                       constraints: BoxConstraints.expand().widthConstraints()
                       ));
        }
示例#10
0
        public RawMaterialButton(
            Key key = null,
            VoidCallback onPressed = null,
            ValueChanged <bool> onHighlightChanged = null,
            TextStyle textStyle        = null,
            Color fillColor            = null,
            Color highlightColor       = null,
            Color splashColor          = null,
            float elevation            = 2.0f,
            float highlightElevation   = 8.0f,
            float disabledElevation    = 0.0f,
            EdgeInsets padding         = null,
            BoxConstraints constraints = null,
            ShapeBorder shape          = null,
            TimeSpan?animationDuration = null,
            Clip clipBehavior          = Clip.none,
            MaterialTapTargetSize?materialTapTargetSize = null,
            Widget child = null) : base(key: key)
        {
            D.assert(elevation >= 0.0);
            D.assert(highlightElevation >= 0.0);
            D.assert(disabledElevation >= 0.0);

            MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded;

            shape       = shape ?? new RoundedRectangleBorder();
            padding     = padding ?? EdgeInsets.zero;
            constraints = constraints ?? new BoxConstraints(minWidth: 88.0f, minHeight: 36.0f);
            TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration;

            this.onPressed          = onPressed;
            this.onHighlightChanged = onHighlightChanged;
            this.textStyle          = textStyle;
            this.fillColor          = fillColor;
            this.highlightColor     = highlightColor;
            this.splashColor        = splashColor;
            this.elevation          = elevation;
            this.highlightElevation = highlightElevation;
            this.disabledElevation  = disabledElevation;
            this.padding            = padding;
            this.constraints        = constraints;
            this.shape                 = shape;
            this.animationDuration     = _animationDuration;
            this.clipBehavior          = clipBehavior;
            this.materialTapTargetSize = _materialTapTargetSize;
            this.child                 = child;
        }
示例#11
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            if (child != null)
            {
                BoxConstraints childConstraints = null;
                if (constrainedAxis != null)
                {
                    switch (constrainedAxis)
                    {
                    case Axis.horizontal:
                        childConstraints = new BoxConstraints(
                            maxWidth: constraints.maxWidth,
                            minWidth: constraints.minWidth);
                        break;

                    case Axis.vertical:
                        childConstraints = new BoxConstraints(
                            maxHeight: constraints.maxHeight,
                            minHeight: constraints.minHeight);
                        break;
                    }
                }
                else
                {
                    childConstraints = new BoxConstraints();
                }

                child.layout(childConstraints, parentUsesSize: true);
                size = constraints.constrain(child.size);
                alignChild();
                var childParentData = (BoxParentData)child.parentData;
                _overflowContainerRect = Offset.zero & size;
                _overflowChildRect     = childParentData.offset & child.size;
            }
            else
            {
                size = constraints.smallest;
                _overflowContainerRect = Rect.zero;
                _overflowChildRect     = Rect.zero;
            }

            _isOverflowing = RelativeRect.fromRect(
                _overflowContainerRect, _overflowChildRect).hasInsets;
        }
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            if (child == null)
            {
                size = constraints.smallest;
            }
            else
            {
                child.layout(_getInnerConstraints(constraints), parentUsesSize: true);
                size = constraints.constrain(child.size);
            }

            offset.applyViewportDimension(_viewportExtent);
            offset.applyContentDimensions(_minScrollExtent, _maxScrollExtent);
        }
示例#13
0
        public override Widget build(BuildContext context)
        {
            Widget current = child;

            if (child == null)
            {
                current = new LimitedBox(
                    maxWidth: 0.0f,
                    maxHeight: 0.0f,
                    child: new ConstrainedBox(constraints: BoxConstraints.expand())
                    );
            }

            current = new RaycastableBox(child: current);

            return(current);
        }
示例#14
0
        Size _sizeForConstraints(BoxConstraints constraints)
        {
            constraints = BoxConstraints.tightFor(
                _width,
                _height
                ).enforce(constraints);

            if (_image == null)
            {
                return(constraints.smallest);
            }

            return(constraints.constrainSizeAndAttemptToPreserveAspectRatio(new Size(
                                                                                (_image.width / _scale),
                                                                                (_image.height / _scale)
                                                                                )));
        }
示例#15
0
        Stack BuildVerticalView(BuildContext context, BoxConstraints constraints, float w)
        {
            var top    = constraints.maxHeight * w;
            var bottom = constraints.maxHeight * (1f - w);

            return(new Stack(
                       children: new List <Widget>
            {
                new Positioned(
                    top: 0,
                    left: 0,
                    right: 0,
                    bottom: bottom,
                    child: widget.view1
                    ),
                new Positioned(
                    top: top,
                    left: 0,
                    right: 0,
                    bottom: 0,
                    child: widget.view2
                    ),
                new Positioned(
                    top: top - widget.gripSize / 2f,
                    left: 0,
                    right: 0,
                    bottom: bottom - widget.gripSize / 2f,
                    child: new GestureDetector(
                        behavior: HitTestBehavior.translucent,
                        onVerticalDragUpdate: (detail) =>
                {
                    RenderBox container = context.findRenderObject() as RenderBox;
                    var pos = container.globalToLocal(detail.globalPosition);

                    if (pos.dy > widget.positionLimit && pos.dy < (container.size.height - widget.positionLimit))
                    {
                        weight.value = pos.dy / container.size.height;
                    }
                },
                        child: new Container(color: widget.gripColor)
                        )  //GestureDetector
                    ),
            }              //list
                       )); // return Stack
        }
示例#16
0
        protected override void performLayout()
        {
            _lastValue         = _controller.value;
            _hasVisualOverflow = false;
            BoxConstraints constraints = this.constraints;

            if (child == null || constraints.isTight)
            {
                _controller.stop();
                size   = _sizeTween.begin = _sizeTween.end = constraints.smallest;
                _state = RenderAnimatedSizeState.start;
                child?.layout(constraints);
                return;
            }

            child.layout(constraints, parentUsesSize: true);

            switch (_state)
            {
            case RenderAnimatedSizeState.start:
                _layoutStart();
                break;

            case RenderAnimatedSizeState.stable:
                _layoutStable();
                break;

            case RenderAnimatedSizeState.changed:
                _layoutChanged();
                break;

            case RenderAnimatedSizeState.unstable:
                _layoutUnstable();
                break;
            }

            size = constraints.constrain(_animatedSize);
            alignChild();

            if (size.width < _sizeTween.end.width ||
                size.height < _sizeTween.end.height)
            {
                _hasVisualOverflow = true;
            }
        }
示例#17
0
文件: radio.cs 项目: JC-ut0/CubeGame
 public _RenderRadio(
     bool?value,
     Color activeColor,
     Color inactiveColor,
     ValueChanged <bool?> onChanged,
     BoxConstraints additionalConstraints,
     TickerProvider vsync
     ) : base(
         value: value,
         tristate: false,
         activeColor: activeColor,
         inactiveColor: inactiveColor,
         onChanged: onChanged,
         additionalConstraints: additionalConstraints,
         vsync: vsync
         )
 {
 }
示例#18
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            if (child != null)
            {
                child.layout(constraints, parentUsesSize: true);
                float height = Mathf.Max(child.size.width, minSize.width);
                float width  = Mathf.Max(child.size.height, minSize.height);
                size = constraints.constrain(new Size(height, width));
                BoxParentData childParentData = child.parentData as BoxParentData;
                childParentData.offset = Alignment.center.alongOffset(size - child.size as Offset);
            }
            else
            {
                size = Size.zero;
            }
        }
示例#19
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            if (child != null)
            {
                child.layout(new BoxConstraints(), parentUsesSize: true);
                size = new Size(
                    Mathf.Max(constraints.minWidth, Mathf.Min(constraints.maxWidth, child.size.width)),
                    Mathf.Max(constraints.minHeight, Mathf.Min(constraints.maxHeight, child.size.height))
                    );
                alignChild();
            }
            else
            {
                size = constraints.biggest;
            }
        }
示例#20
0
        void _layoutChildren(BoxConstraints constraints)
        {
            if (childCount == 0)
            {
                return;
            }
            RenderBox child = firstChild;

            _placeholderDimensions = new List <PlaceholderDimensions>(childCount);
            int childIndex = 0;

            while (child != null)
            {
                child.layout(
                    new BoxConstraints(
                        maxWidth: constraints.maxWidth
                        ),
                    parentUsesSize: true
                    );
                float baselineOffset;
                switch (_placeholderSpans[childIndex].alignment)
                {
                case ui.PlaceholderAlignment.baseline: {
                    baselineOffset = child.getDistanceToBaseline(
                        _placeholderSpans[childIndex].baseline
                        ) ?? 0.0f;
                    break;
                }

                default: {
                    baselineOffset = 0.0f;
                    break;
                }
                }
                _placeholderDimensions[childIndex] = new PlaceholderDimensions(
                    size: child.size,
                    alignment: _placeholderSpans[childIndex].alignment,
                    baseline: _placeholderSpans[childIndex].baseline,
                    baselineOffset: baselineOffset
                    );
                child       = childAfter(child);
                childIndex += 1;
            }
        }
示例#21
0
 protected override void performLayout()
 {
     if (child != null)
     {
         BoxConstraints constraints = this.constraints;
         child.layout(constraints.loosen(), parentUsesSize: true);
         float?childBaseline   = child.getDistanceToBaseline(baselineType);
         float actualBaseline  = baseline;
         float top             = actualBaseline - (childBaseline ?? 0.0f);
         var   childParentData = (BoxParentData)child.parentData;
         childParentData.offset = new Offset(0.0f, top);
         Size childSize = child.size;
         size = constraints.constrain(new Size(childSize.width, top + childSize.height));
     }
     else
     {
         performResize();
     }
 }
示例#22
0
        Widget _buildUnderMagnifierScreen()
        {
            Color foreground = this.widget.backgroundColor?.withAlpha(
                (int)(this.widget.backgroundColor.alpha * CupertinoPickerUtils._kForegroundScreenOpacityFraction)
                );

            return(new Column(
                       children: new List <Widget> {
                new Expanded(child: new Container()),
                new Container(
                    color: foreground,
                    constraints: BoxConstraints.expand(
                        height: this.widget.itemExtent * this.widget.magnification
                        )
                    ),
                new Expanded(child: new Container())
            }
                       ));
        }
示例#23
0
 public _SwitchRenderObjectWidget(
     Key key                                      = null,
     bool?value                                   = null,
     Color activeColor                            = null,
     Color inactiveColor                          = null,
     Color hoverColor                             = null,
     Color focusColor                             = null,
     ImageProvider activeThumbImage               = null,
     ImageErrorListener onActiveThumbImageError   = null,
     ImageProvider inactiveThumbImage             = null,
     ImageErrorListener onInactiveThumbImageError = null,
     Color activeTrackColor                       = null,
     Color inactiveTrackColor                     = null,
     ImageConfiguration configuration             = null,
     ValueChanged <bool?> onChanged               = null,
     BoxConstraints additionalConstraints         = null,
     DragStartBehavior?dragStartBehavior          = null,
     bool hasFocus                                = false,
     bool hovering                                = false,
     _SwitchState state                           = null
     ) : base(key: key)
 {
     D.assert(value != null);
     this.value                     = value.Value;
     this.activeColor               = activeColor;
     this.inactiveColor             = inactiveColor;
     this.hoverColor                = hoverColor;
     this.focusColor                = focusColor;
     this.activeThumbImage          = activeThumbImage;
     this.onActiveThumbImageError   = onActiveThumbImageError;
     this.inactiveThumbImage        = inactiveThumbImage;
     this.onInactiveThumbImageError = onInactiveThumbImageError;
     this.activeTrackColor          = activeTrackColor;
     this.inactiveTrackColor        = inactiveTrackColor;
     this.configuration             = configuration;
     this.onChanged                 = onChanged;
     this.additionalConstraints     = additionalConstraints;
     this.dragStartBehavior         = dragStartBehavior;
     this.hasFocus                  = hasFocus;
     this.hovering                  = hovering;
     this.state                     = state;
 }
 FloatingActionButton(
     Key key                  = null,
     Widget child             = null,
     string tooltip           = null,
     Color foregroundColor    = null,
     Color backgroundColor    = null,
     object heroTag           = null,
     float elevation          = 6.0f,
     float highlightElevation = 12.0f,
     float?disabledElevation  = null,
     VoidCallback onPressed   = null,
     bool mini                = false,
     ShapeBorder shape        = null,
     Clip clipBehavior        = Clip.none,
     MaterialTapTargetSize?materialTapTargetSize = null,
     bool isExtended = false,
     BoxConstraints _sizeConstraints = null
     ) : base(key: key)
 {
     D.assert(elevation >= 0.0f);
     D.assert(highlightElevation >= 0.0f);
     D.assert(disabledElevation == null || disabledElevation >= 0.0f);
     heroTag                    = heroTag ?? new _DefaultHeroTag();
     shape                      = shape ?? new CircleBorder();
     this.child                 = child;
     this.tooltip               = tooltip;
     this.foregroundColor       = foregroundColor;
     this.backgroundColor       = backgroundColor;
     this.heroTag               = heroTag;
     this.elevation             = elevation;
     this.highlightElevation    = highlightElevation;
     this.onPressed             = onPressed;
     this.mini                  = mini;
     this.shape                 = shape;
     this.clipBehavior          = clipBehavior;
     this.materialTapTargetSize = materialTapTargetSize;
     this.isExtended            = isExtended;
     this.disabledElevation     = disabledElevation;
     this._sizeConstraints      = _sizeConstraints ?? (mini
                                 ? FloatActionButtonUtils._kMiniSizeConstraints
                                 : FloatActionButtonUtils._kSizeConstraints);
 }
示例#25
0
        public Size layoutChild(object childId, BoxConstraints constraints)
        {
            RenderBox child = _idToChild[childId];

            D.assert(() => {
                if (child == null)
                {
                    throw new UIWidgetsError(
                        $"The {this} custom multichild layout delegate tried to lay out a non-existent child.\n" +
                        $"There is no child with the id \"{childId}\"."
                        );
                }

                if (!_debugChildrenNeedingLayout.Remove(child))
                {
                    throw new UIWidgetsError(
                        $"The $this custom multichild layout delegate tried to lay out the child with id \"{childId}\" more than once.\n" +
                        "Each child must be laid out exactly once."
                        );
                }

                try {
                    D.assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
                }
                catch (AssertionError exception) {
                    throw new UIWidgetsError(new List <DiagnosticsNode> {
                        new ErrorSummary(
                            $"The $this custom multichild layout delegate provided invalid box constraints for the child with id {childId}."),
                        new DiagnosticsProperty <AssertionError>("Exception", exception, showName: false),
                        new ErrorDescription(
                            "The minimum width and height must be greater than or equal to zero.\n" +
                            "The maximum width must be greater than or equal to the minimum width.\n" +
                            "The maximum height must be greater than or equal to the minimum height."
                            )
                    });
                }

                return(true);
            });
            child.layout(constraints, parentUsesSize: true);
            return(child.size);
        }
示例#26
0
        Widget BuildHorizontalView(BuildContext context, BoxConstraints constraints, float w)
        {
            float left  = constraints.maxWidth * w;
            float right = constraints.maxWidth * (1f - w);

            return(new Stack(
                       children: new List <Widget> {
                new Positioned(
                    top: 0,
                    left: 0,
                    right: right,
                    bottom: 0,
                    child: widget.view1
                    ),
                new Positioned(
                    top: 0,
                    left: left,
                    right: 0,
                    bottom: 0,
                    child: widget.view2
                    ),
                new Positioned(
                    top: 0,
                    left: left - widget.gripSize / 2f,
                    right: right - widget.gripSize / 2f,
                    bottom: 0,
                    child: new GestureDetector(
                        behavior: HitTestBehavior.translucent,
                        onVerticalDragUpdate: (detail) => {
                    RenderBox container = context.findRenderObject() as RenderBox;
                    var pos = container.globalToLocal(detail.globalPosition);
                    if (pos.dx > widget.positionLimit && pos.dx < (container.size.width - widget.positionLimit))
                    {
                        weight.value = pos.dx / container.size.width;
                    }
                },
                        child: new  Container(color: widget.gripColor)
                        )  //Gesture
                    )      //position
            }  //List
                       )); //stack
        }
示例#27
0
        Widget _buildMagnifierScreen()
        {
            Color resolvedBorderColor = CupertinoDynamicColor.resolve(CupertinoPickerUtils._kHighlighterBorder, context);

            return(new IgnorePointer(
                       child: new Center(
                           child: new Container(
                               decoration: new BoxDecoration(
                                   border: new Border(
                                       top: new BorderSide(width: 0.0f, color: resolvedBorderColor),
                                       bottom: new BorderSide(width: 0.0f, color: resolvedBorderColor)
                                       )
                                   ),
                               constraints: BoxConstraints.expand(
                                   height: widget.itemExtent * widget.magnification
                                   )
                               )
                           )
                       ));
        }
示例#28
0
文件: switch.cs 项目: JC-ut0/CubeGame
        Widget buildMaterialSwitch(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData theme  = Theme.of(context);
            bool      isDark = theme.brightness == Brightness.dark;

            Color activeThumbColor = this.widget.activeColor ?? theme.toggleableActiveColor;
            Color activeTrackColor = this.widget.activeTrackColor ?? activeThumbColor.withAlpha(0x80);

            Color inactiveThumbColor;
            Color inactiveTrackColor;

            if (this.widget.onChanged != null)
            {
                Color black32 = new Color(0x52000000); // Black with 32% opacity
                inactiveThumbColor = this.widget.inactiveThumbColor ??
                                     (isDark ? Colors.grey.shade400 : Colors.grey.shade50);
                inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white30 : black32);
            }
            else
            {
                inactiveThumbColor = this.widget.inactiveThumbColor ??
                                     (isDark ? Colors.grey.shade800 : Colors.grey.shade400);
                inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12);
            }

            return(new _SwitchRenderObjectWidget(
                       dragStartBehavior: this.widget.dragStartBehavior,
                       value: this.widget.value,
                       activeColor: activeThumbColor,
                       inactiveColor: inactiveThumbColor,
                       activeThumbImage: this.widget.activeThumbImage,
                       inactiveThumbImage: this.widget.inactiveThumbImage,
                       activeTrackColor: activeTrackColor,
                       inactiveTrackColor: inactiveTrackColor,
                       configuration: ImageUtils.createLocalImageConfiguration(context),
                       onChanged: this.widget.onChanged,
                       additionalConstraints: BoxConstraints.tight(this.getSwitchSize(theme)),
                       vsync: this
                       ));
        }
示例#29
0
        protected override void performLayout()
        {
            BoxConstraints constraints      = this.constraints;
            bool           shrinkWrapWidth  = _widthFactor != null || float.IsPositiveInfinity(constraints.maxWidth);
            bool           shrinkWrapHeight = _heightFactor != null || float.IsPositiveInfinity(constraints.maxHeight);

            if (child != null)
            {
                child.layout(constraints.loosen(), parentUsesSize: true);
                size = constraints.constrain(new Size(
                                                 shrinkWrapWidth ? child.size.width * (_widthFactor ?? 1.0f) : float.PositiveInfinity,
                                                 shrinkWrapHeight ? child.size.height * (_heightFactor ?? 1.0f) : float.PositiveInfinity));
                alignChild();
            }
            else
            {
                size = constraints.constrain(new Size(
                                                 shrinkWrapWidth ? 0.0f : float.PositiveInfinity,
                                                 shrinkWrapHeight ? 0.0f : float.PositiveInfinity));
            }
        }
示例#30
0
 public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position,
                                     TextSelectionDelegate del)
 {
     D.assert(WidgetsD.debugCheckHasMediaQuery(context));
     return(new ConstrainedBox(
                constraints: BoxConstraints.tight(globalEditableRegion.size),
                child: new CustomSingleChildLayout(
                    layoutDelegate: new _TextSelectionToolbarLayout(
                        MediaQuery.of(context).size,
                        globalEditableRegion,
                        position
                        ),
                    child: new _TextSelectionToolbar(
                        handleCut: this.canCut(del) ? () => this.handleCut(del) : (VoidCallback)null,
                        handleCopy: this.canCopy(del) ? () => this.handleCopy(del) : (VoidCallback)null,
                        handlePaste: this.canPaste(del) ? () => this.handlePaste(del) : (VoidCallback)null,
                        handleSelectAll: this.canSelectAll(del) ? () => this.handleSelectAll(del) : (VoidCallback)null
                        )
                    )
                ));
 }