Exemple #1
0
        public Widget _build(BuildContext context, BoxConstraints constraints)
        {
            if (this._ink == null)
            {
                this._ink = new InkDecoration(
                    decoration: this.widget.decoration,
                    configuration: ImageUtils.createLocalImageConfiguration(context),
                    controller: Material.of(context),
                    referenceBox: (RenderBox)context.findRenderObject(),
                    onRemoved: this._handleRemoved
                    );
            }
            else
            {
                this._ink.decoration    = this.widget.decoration;
                this._ink.configuration = ImageUtils.createLocalImageConfiguration(context);
            }

            Widget     current          = this.widget.child;
            EdgeInsets effectivePadding = this.widget._paddingIncludingDecoration;

            if (effectivePadding != null)
            {
                current = new Padding(
                    padding: effectivePadding,
                    child: current);
            }

            return(current);
        }
Exemple #2
0
 public override RenderObject createRenderObject(BuildContext context)
 {
     return(new RenderDecoratedBox(
                decoration: this.decoration,
                position: this.position,
                configuration: ImageUtils.createLocalImageConfiguration(context)
                ));
 }
Exemple #3
0
        public override void updateRenderObject(BuildContext context, RenderObject renderObjectRaw)
        {
            var renderObject = (RenderDecoratedBox)renderObjectRaw;

            renderObject.decoration    = this.decoration;
            renderObject.configuration = ImageUtils.createLocalImageConfiguration(context);
            renderObject.position      = this.position;
        }
Exemple #4
0
        void _resolveImage()
        {
            ImageStream newStream =
                this.widget.image.resolve(ImageUtils.createLocalImageConfiguration(
                                              this.context,
                                              size: this.widget.width != null && this.widget.height != null
                        ? new Size(this.widget.width.Value, this.widget.height.Value)
                        : null
                                              ));

            D.assert(newStream != null);
            this._updateSourceStream(newStream);
        }
Exemple #5
0
 public override RenderObject createRenderObject(BuildContext context)
 {
     return(new RenderTable(
                columns: children.isNotEmpty() ? children[0].children.Count : 0,
                rows: children.Count,
                columnWidths: columnWidths,
                defaultColumnWidth: defaultColumnWidth,
                border: border,
                rowDecorations: _rowDecorations,
                configuration: ImageUtils.createLocalImageConfiguration(context),
                defaultVerticalAlignment: defaultVerticalAlignment,
                textBaseline: textBaseline
                ));
 }
Exemple #6
0
        public void resolve(ImageProvider provider) {
            ImageStream oldImageStream = this._imageStream;
            Size size = null;
            if (this.widget.width != null && this.widget.height != null) {
                size = new Size((int) this.widget.width, (int) this.widget.height);
            }

            this._imageStream = provider.resolve(ImageUtils.createLocalImageConfiguration(this.state.context, size));
            D.assert(this._imageStream != null);

            if (this._imageStream.key != oldImageStream?.key) {
                oldImageStream?.removeListener(this._handleImageChanged);
                this._imageStream.addListener(this._handleImageChanged);
            }
        }
Exemple #7
0
        public override void updateRenderObject(BuildContext context, RenderObject renderObject)
        {
            RenderTable _renderObject = (RenderTable)renderObject;

            D.assert(_renderObject.columns == (children.isNotEmpty() ? children[0].children.Count : 0));
            D.assert(_renderObject.rows == children.Count);

            _renderObject.columnWidths             = columnWidths;
            _renderObject.defaultColumnWidth       = defaultColumnWidth;
            _renderObject.border                   = border;
            _renderObject.rowDecorations           = _rowDecorations;
            _renderObject.configuration            = ImageUtils.createLocalImageConfiguration(context);
            _renderObject.defaultVerticalAlignment = defaultVerticalAlignment;
            _renderObject.textBaseline             = textBaseline;
        }
Exemple #8
0
        void _resolveImage()
        {
            //TODO: why refactoring this code? we need a PR to fix it!

            /*ScrollAwareImageProvider<object> provider = new ScrollAwareImageProvider<object>(
             *  context: _scrollAwareContext,
             *  imageProvider: widget.image);*/
            var newStream =
                widget.image.resolve(ImageUtils.createLocalImageConfiguration(
                                         context: context,
                                         widget.width != null && widget.height != null
                        ? new Size(width: widget.width.Value, height: widget.height.Value)
                        : null
                                         ));

            D.assert(newStream != null);
            _updateSourceStream(newStream: newStream);
        }
Exemple #9
0
        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
                       ));
        }
Exemple #10
0
 public override void initState()
 {
     base.initState();
     this._scaleAnimationController = new AnimationController(
         duration: TimeSpan.FromMilliseconds(100),
         vsync: this);
     this._scaleAnimationController.addListener(listener: this._onScaleAndPositionChanged);
     this._scaleAnimation = new FloatTween(1.0f, 1.0f).animate(parent: this._scaleAnimationController);
     this._positionAnimationController = new AnimationController(
         duration: TimeSpan.FromMilliseconds(100),
         vsync: this);
     this._positionAnimation =
         new OffsetTween(begin: Offset.zero, end: Offset.zero).animate(parent: this._scaleAnimationController);
     this._positionAnimationController.addListener(
         listener: this._onScaleAndPositionChanged
         );
     this._inertiaAnimationController = new AnimationController(
         duration: TimeSpan.FromMilliseconds(1000),
         vsync: this);
     this._inertiaAnimationController.addListener(listener: this._onScaleAndPositionChanged);
     this._inertiaAnimationController.addStatusListener(status => {
         if (status == AnimationStatus.completed)
         {
             var clampedPosition     = this._clampPosition(position: this._position, scale: this._scale);
             this._positionAnimation =
                 new OffsetTween(begin: clampedPosition, end: clampedPosition).animate(
                     parent: this._positionAnimationController);
             this._positionAnimationController.reset();
         }
     });
     if (!this.widget.useCachedNetworkImage)
     {
         SchedulerBinding.instance.addPostFrameCallback(_ => {
             this._imageStream = new NetworkImage(url: this.widget.url,
                                                  headers: this.widget.headers).resolve(ImageUtils.createLocalImageConfiguration(
                                                                                            context: this.context
                                                                                            ));
             this._imageStream.addListener((imageInfo, __) => {
                 this.setState(() => { this._onImageResolved(imageInfo: imageInfo); });
             });
         });
     }
 }