示例#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);
        }
示例#2
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
                       ));
        }
示例#3
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); });
             });
         });
     }
 }