コード例 #1
0
        public CupertinoFullscreenDialogTransition(
            Key key = null,
            Animation <float> primaryRouteAnimation   = null,
            Animation <float> secondaryRouteAnimation = null,
            Widget child          = null,
            bool linearTransition = false

            ) : base(key: key)
        {
            _positionAnimation = new CurvedAnimation(
                parent: primaryRouteAnimation,
                curve: Curves.linearToEaseOut,
                reverseCurve: Curves.linearToEaseOut.flipped
                ).drive(CupertinoRouteUtils._kBottomUpTween);
            this.child = child;
            _secondaryPositionAnimation =
                (linearTransition
                    ? secondaryRouteAnimation
                    : new CurvedAnimation(
                     parent: secondaryRouteAnimation,
                     curve: Curves.linearToEaseOut,
                     reverseCurve: Curves.easeInToLinear
                     )
                ).drive(CupertinoRouteUtils._kMiddleLeftTween);
        }
コード例 #2
0
        protected override Widget build(BuildContext context)
        {
            Animation <float> progress = this.listenable as Animation <float>;

            float opacity1 = new CurvedAnimation(
                parent: new ReverseAnimation(progress),
                curve: new Interval(0.5f, 1.0f)
                ).value;

            float opacity2 = new CurvedAnimation(
                parent: progress,
                curve: new Interval(0.5f, 1.0f)
                ).value;

            return(new Stack(
                       alignment: this.alignment,
                       children: new List <Widget> {
                new Opacity(
                    opacity: opacity1,
                    child: this.child1
                    ),
                new Opacity(
                    opacity: opacity2,
                    child: this.child0
                    )
            }
                       ));
        }
コード例 #3
0
        public override void initState()
        {
            base.initState();

            _tap                    = new TapGestureRecognizer();
            _tap.onTapDown          = _handleTapDown;
            _tap.onTapUp            = _handleTapUp;
            _tap.onTap              = _handleTap;
            _tap.onTapCancel        = _handleTapCancel;
            _drag                   = new HorizontalDragGestureRecognizer();
            _drag.onStart           = _handleDragStart;
            _drag.onUpdate          = _handleDragUpdate;
            _drag.onEnd             = _handleDragEnd;
            _drag.dragStartBehavior = widget.dragStartBehavior;

            _positionController = new AnimationController(
                duration: CupertinoSwitchUtils._kToggleDuration,
                value: widget.value ? 1.0f : 0.0f,
                vsync: this
                );
            position = new CurvedAnimation(
                parent: _positionController,
                curve: Curves.linear
                );
            _reactionController = new AnimationController(
                duration: CupertinoSwitchUtils._kReactionDuration,
                vsync: this
                );
            _reaction = new CurvedAnimation(
                parent: _reactionController,
                curve: Curves.ease
                );
        }
コード例 #4
0
        void _initGap(MaterialGap gap)
        {
            AnimationController controller = new AnimationController(
                duration: ThemeUtils.kThemeAnimationDuration,
                vsync: this);

            CurvedAnimation startAnimation = new CurvedAnimation(
                parent: controller,
                curve: Curves.fastOutSlowIn);

            CurvedAnimation endAnimation = new CurvedAnimation(
                parent: controller,
                curve: Curves.fastOutSlowIn);

            CurvedAnimation gapAnimation = new CurvedAnimation(
                parent: controller,
                curve: Curves.fastOutSlowIn);

            controller.addListener(this._handleTick);

            this._animationTuples[gap.key] = new _AnimationTuple(
                controller: controller,
                startAnimation: startAnimation,
                endAnimation: endAnimation,
                gapAnimation: gapAnimation);
        }
コード例 #5
0
        public _RenderSlider(
            float?value   = null,
            int?divisions = null,
            string label  = null,
            SliderThemeData sliderTheme        = null,
            MediaQueryData mediaQueryData      = null,
            RuntimePlatform?platform           = null,
            ValueChanged <float> onChanged     = null,
            ValueChanged <float> onChangeStart = null,
            ValueChanged <float> onChangeEnd   = null,
            _SliderState state          = null,
            TextDirection?textDirection = null
            )
        {
            D.assert(value != null && value >= 0.0 && value <= 1.0);
            D.assert(state != null);
            D.assert(textDirection != null);

            this.onChangeStart = onChangeStart;
            this.onChangeEnd   = onChangeEnd;
            _platform          = platform;
            _label             = label;
            _value             = value.Value;
            _divisions         = divisions;
            _sliderTheme       = sliderTheme;
            _mediaQueryData    = mediaQueryData;
            _onChanged         = onChanged;
            _state             = state;
            _textDirection     = textDirection.Value;

            _updateLabelPainter();
            GestureArenaTeam team = new GestureArenaTeam();

            _drag = new HorizontalDragGestureRecognizer {
                team     = team,
                onStart  = _handleDragStart,
                onUpdate = _handleDragUpdate,
                onEnd    = _handleDragEnd,
                onCancel = _endInteraction
            };

            _tap = new TapGestureRecognizer {
                team        = team,
                onTapDown   = _handleTapDown,
                onTapUp     = _handleTapUp,
                onTapCancel = _endInteraction
            };

            _overlayAnimation = new CurvedAnimation(
                parent: _state.overlayController,
                curve: Curves.fastOutSlowIn);

            _valueIndicatorAnimation = new CurvedAnimation(
                parent: _state.valueIndicatorController,
                curve: Curves.fastOutSlowIn);

            _enableAnimation = new CurvedAnimation(
                parent: _state.enableController,
                curve: Curves.easeInOut);
        }
コード例 #6
0
        public override Widget build(BuildContext context)
        {
            CurvedAnimation opacity;

            float unit = 0.5f / (widget.route.items.Count + 1.5f);

            if (widget.itemIndex == widget.route.selectedIndex)
            {
                opacity = new CurvedAnimation(parent: widget.route.animation, curve: new Threshold(0.0f));
            }
            else
            {
                float start = ((0.5f + (widget.itemIndex + 1) * unit) ?? 0).clamp(0.0f, 1.0f);
                float end   = (start + 1.5f * unit).clamp(0.0f, 1.0f);
                opacity = new CurvedAnimation(parent: widget.route.animation, curve: new Interval(start, end));
            }

            Widget child = new FadeTransition(
                opacity: opacity,
                child: new InkWell(
                    autofocus: widget.itemIndex == widget.route.selectedIndex,
                    child: new Container(
                        padding: widget.padding,
                        child: widget.route.items[widget.itemIndex ?? 0]
                        ),
                    onTap: _handleOnTap,
                    onFocusChange: _handleFocusChange
                    )
                );

            return(child);
        }
コード例 #7
0
 public RenderAnimatedSize(
     TickerProvider vsync     = null,
     TimeSpan?duration        = null,
     TimeSpan?reverseDuration = null,
     Curve curve = null,
     AlignmentGeometry alignment = null,
     TextDirection?textDirection = null,
     RenderBox child             = null
     ) : base(child: child, alignment: alignment ?? Alignment.center, textDirection: textDirection)
 {
     curve = curve ?? Curves.linear;
     D.assert(vsync != null);
     D.assert(duration != null);
     _vsync      = vsync;
     _controller = new AnimationController(
         vsync: this.vsync,
         duration: duration,
         reverseDuration: reverseDuration);
     _controller.addListener(() => {
         if (_controller.value != _lastValue)
         {
             markNeedsLayout();
         }
     });
     _animation = new CurvedAnimation(
         parent: _controller,
         curve: curve);
 }
コード例 #8
0
        public static Widget _buildCupertinoDialogTransitions(
            BuildContext context,
            Animation <float> animation,
            Animation <float> secondaryAnimation,
            Widget child)
        {
            CurvedAnimation fadeAnimation = new CurvedAnimation(
                parent: animation,
                curve: Curves.easeInOut
                );

            if (animation.status == AnimationStatus.reverse)
            {
                return(new FadeTransition(
                           opacity: fadeAnimation,
                           child: child
                           ));
            }

            return(new FadeTransition(
                       opacity: fadeAnimation,
                       child: new ScaleTransition(
                           child: child,
                           scale: animation.drive(_dialogScaleTween)
                           )
                       ));
        }
コード例 #9
0
    void Awake()
    {
        Curve         curve = new ExponentialCurve(power);
        Tween <float> tween = new RotationTween(start, end);

        animator = new CurvedAnimation <float>(
            curve: curve, tween: tween, duration: duration
            );
    }
コード例 #10
0
        internal _RailDestination(
            float?minWidth         = null,
            float?minExtendedWidth = null,
            Widget icon            = null,
            Widget label           = null,
            Animation <float> destinationAnimation        = null,
            Animation <float> extendedTransitionAnimation = null,
            NavigationRailLabelType?labelType             = null,
            bool?selected            = null,
            IconThemeData iconTheme  = null,
            TextStyle labelTextStyle = null,
            VoidCallback onTap       = null,
            string indexLabel        = null
            )
        {
            D.assert(minWidth != null);
            D.assert(minExtendedWidth != null);
            D.assert(icon != null);
            D.assert(label != null);
            D.assert(destinationAnimation != null);
            D.assert(extendedTransitionAnimation != null);
            D.assert(labelType != null);
            D.assert(selected != null);
            D.assert(iconTheme != null);
            D.assert(labelTextStyle != null);
            D.assert(onTap != null);
            D.assert(indexLabel != null);
            this.minWidth = minWidth;

            this.minExtendedWidth = minExtendedWidth;

            this.icon = icon;

            this.label = label;

            this.destinationAnimation = destinationAnimation;

            this.extendedTransitionAnimation = extendedTransitionAnimation;

            this.labelType = labelType;

            this.selected = selected;

            this.iconTheme = iconTheme;

            this.labelTextStyle = labelTextStyle;

            this.onTap = onTap;

            this.indexLabel = indexLabel;

            _positionAnimation = new CurvedAnimation(
                parent: new ReverseAnimation(destinationAnimation),
                curve: Curves.easeInOut,
                reverseCurve: Curves.easeInOut.flipped
                );
        }
コード例 #11
0
ファイル: TipMenu.cs プロジェクト: zuoyanshun/ConnectAppCN
        public override void initState()
        {
            base.initState();
            this._animationController = new AnimationController(
                duration: TimeSpan.FromMilliseconds(150),
                vsync: this
                );
            CurvedAnimation curve = new CurvedAnimation(parent: this._animationController, curve: Curves.linear);

            this._animationOpacity = new FloatTween(0, 1).animate(parent: curve);
            this._animationController.forward();
        }
コード例 #12
0
 public _AnimationTuple(
     AnimationController controller = null,
     CurvedAnimation startAnimation = null,
     CurvedAnimation endAnimation   = null,
     CurvedAnimation gapAnimation   = null,
     float gapStart = 0.0f)
 {
     this.controller     = controller;
     this.startAnimation = startAnimation;
     this.endAnimation   = endAnimation;
     this.gapAnimation   = gapAnimation;
     this.gapStart       = gapStart;
 }
コード例 #13
0
 public override void initState()
 {
     base.initState();
     _fadeOpacity = new CurvedAnimation(
         parent: widget.route.animation,
         curve: new Interval(0.0f, 0.25f),
         reverseCurve: new Interval(0.75f, 1.0f)
         );
     _resize = new CurvedAnimation(
         parent: widget.route.animation,
         curve: new Interval(0.25f, 0.5f),
         reverseCurve: new Threshold(0.0f)
         );
 }
コード例 #14
0
        public override Widget build(BuildContext context)
        {
            Color         fixColor           = this.color ?? Colors.transparent;
            Color         fixSelectedColor   = this.selectedColor ?? Theme.of(context).accentColor;
            ColorTween    selectedColorTween = new ColorTween(begin: fixColor, end: fixSelectedColor);
            ColorTween    previousColorTween = new ColorTween(begin: fixSelectedColor, end: fixColor);
            TabController tabController      = this.controller ?? DefaultTabController.of(context);

            D.assert(() => {
                if (tabController == null)
                {
                    throw new UIWidgetsError(
                        "No TabController for " + this.GetType() + ".\n" +
                        "When creating a " + this.GetType() + ", you must either provide an explicit TabController " +
                        "using the \"controller\" property, or you must ensure that there is a " +
                        "DefaultTabController above the " + this.GetType() + ".\n" +
                        "In this case, there was neither an explicit controller nor a default controller."
                        );
                }

                return(true);
            });

            Animation <float> animation = new CurvedAnimation(
                parent: tabController.animation,
                curve: Curves.fastOutSlowIn
                );

            return(new AnimatedBuilder(
                       animation: animation,
                       builder: (BuildContext subContext, Widget child) => {
                List <Widget> children = new List <Widget>();

                for (int tabIndex = 0; tabIndex < tabController.length; tabIndex++)
                {
                    children.Add(this._buildTabIndicator(
                                     tabIndex,
                                     tabController,
                                     selectedColorTween,
                                     previousColorTween)
                                 );
                }

                return new Row(
                    mainAxisSize: MainAxisSize.min,
                    children: children
                    );
            }
                       ));
        }
コード例 #15
0
        Widget _buildThumbnail(BuildContext context, int index, Animation <float> animation)
        {
            Animation <float> thumbnailSize = new FloatTween(begin: 0.8f, end: 1.0f).animate(
                new CurvedAnimation(
                    curve: new Interval(0.33f, 1.0f, curve: Curves.easeIn),
                    parent: animation
                    )
                );

            Animation <float> opacity = new CurvedAnimation(
                curve: new Interval(0.33f, 1.0f, curve: Curves.linear),
                parent: animation
                );

            return(new ProductThumbnail(thumbnailSize, opacity, _productWithId(_list.ElementAt(index))));
        }
コード例 #16
0
        void _addEntryForNewChild(bool animate)
        {
            D.assert(animate || _currentEntry == null);
            if (_currentEntry != null)
            {
                D.assert(animate);
                D.assert(!_outgoingEntries.Contains(_currentEntry));
                _outgoingEntries.Add(_currentEntry);
                _currentEntry.controller.reverse();
                _markChildWidgetCacheAsDirty();
                _currentEntry = null;
            }

            if (widget.child == null)
            {
                return;
            }

            AnimationController controller = new AnimationController(
                duration: widget.duration,
                reverseDuration: widget.reverseDuration,
                vsync: this
                );
            Animation <float> animation = new CurvedAnimation(
                parent: controller,
                curve: widget.switchInCurve,
                reverseCurve: widget.switchOutCurve
                );

            _currentEntry = _newEntry(
                child: widget.child,
                controller: controller,
                animation: animation,
                builder: widget.transitionBuilder
                );
            if (animate)
            {
                controller.forward();
            }
            else
            {
                D.assert(_outgoingEntries.isEmpty);
                controller.setValue(1.0f);
            }
        }
コード例 #17
0
        public _GlowController(
            TickerProvider vsync,
            Color color,
            Axis axis
            )
        {
            D.assert(vsync != null);
            D.assert(color != null);
            _color          = color;
            _axis           = axis;
            _glowController = new AnimationController(vsync: vsync);
            _glowController.addStatusListener(_changePhase);
            Animation <float> decelerator = new CurvedAnimation(
                parent: _glowController,
                curve: Curves.decelerate
                );

            decelerator.addListener(notifyListeners);
            _glowOpacity        = decelerator.drive(_glowOpacityTween);
            _glowSize           = decelerator.drive(_glowSizeTween);
            _displacementTicker = vsync.createTicker(_tickDisplacement);
        }
コード例 #18
0
 public _Circle(
     _BottomNavigationBarState state = null,
     int?index            = null,
     Color color          = null,
     TickerProvider vsync = null
     )
 {
     D.assert(state != null);
     D.assert(index != null);
     D.assert(color != null);
     this.state = state;
     this.index = index;
     this.color = color;
     controller = new AnimationController(
         duration: ThemeUtils.kThemeAnimationDuration,
         vsync: vsync
         );
     animation = new CurvedAnimation(
         parent: controller,
         curve: Curves.fastOutSlowIn
         );
     controller.forward();
 }
コード例 #19
0
        protected RenderToggleable(
            bool?value                           = null,
            bool tristate                        = false,
            Color activeColor                    = null,
            Color inactiveColor                  = null,
            Color hoverColor                     = null,
            Color focusColor                     = null,
            ValueChanged <bool?> onChanged       = null,
            BoxConstraints additionalConstraints = null,
            TickerProvider vsync                 = null,
            bool hasFocus                        = false,
            bool hovering                        = false
            ) : base(additionalConstraints: additionalConstraints)
        {
            D.assert(tristate || value != null);
            D.assert(activeColor != null);
            D.assert(inactiveColor != null);
            D.assert(vsync != null);
            _value         = value;
            _tristate      = tristate;
            _activeColor   = activeColor;
            _inactiveColor = inactiveColor;
            _hoverColor    = hoverColor ?? activeColor.withAlpha(material_.kRadialReactionAlpha);
            _focusColor    = focusColor ?? activeColor.withAlpha(material_.kRadialReactionAlpha);
            _onChanged     = onChanged;
            _hasFocus      = hasFocus;
            _hovering      = hovering;
            _vsync         = vsync;

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

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

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

            _reactionController = new AnimationController(
                duration: material_.kRadialReactionDuration,
                vsync: vsync);
            _reaction = new CurvedAnimation(
                parent: _reactionController,
                curve: Curves.fastOutSlowIn);
            _reaction.addListener(markNeedsPaint);

            _reactionHoverFadeController = new AnimationController(
                duration: ToggleableUtils._kReactionFadeDuration,
                value: hovering || hasFocus ? 1.0f : 0.0f,
                vsync: vsync
                );
            _reactionHoverFade = new CurvedAnimation(
                parent: _reactionHoverFadeController,
                curve: Curves.fastOutSlowIn
                );
            _reactionHoverFade.addListener(markNeedsPaint);

            _reactionFocusFadeController = new AnimationController(
                duration: ToggleableUtils._kReactionFadeDuration,
                value: hovering || hasFocus ? 1.0f : 0.0f,
                vsync: vsync
                );
            _reactionFocusFade = new CurvedAnimation(
                parent: _reactionFocusFadeController,
                curve: Curves.fastOutSlowIn
                );
            _reactionFocusFade.addListener(markNeedsPaint);
        }
コード例 #20
0
        public override Widget build(BuildContext context)
        {
            float              unit           = 1.0f / (route.items.Count + 1.5f);
            List <Widget>      children       = new List <Widget>();
            PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);

            for (int i = 0; i < route.items.Count; i += 1)
            {
                int             index = i;
                float           start = (index + 1) * unit;
                float           end   = (start + 1.5f * unit).clamp(0.0f, 1.0f);
                CurvedAnimation opacityCurvedAnimation = new CurvedAnimation(
                    parent: route.animation,
                    curve: new Interval(start, end)
                    );
                Widget item = route.items[index];
                if (route.initialValue != null && route.items[index].represents((T)route.initialValue))
                {
                    item = new Container(
                        color: Theme.of(context).highlightColor,
                        child: item
                        );
                }

                children.Add(
                    new _MenuItem(
                        onLayout: (Size size) => { route.itemSizes[index] = size; },
                        child: new FadeTransition(
                            opacity: opacityCurvedAnimation,
                            child: item
                            )
                        )
                    );
            }

            CurveTween opacity = new CurveTween(curve: new Interval(0.0f, 1.0f / 3.0f));
            CurveTween width   = new CurveTween(curve: new Interval(0.0f, unit));
            CurveTween height  = new CurveTween(curve: new Interval(0.0f, unit * route.items.Count));

            Widget child = new ConstrainedBox(
                constraints: new BoxConstraints(
                    minWidth: material_._kMenuMinWidth,
                    maxWidth: material_._kMenuMaxWidth
                    ),
                child: new IntrinsicWidth(
                    stepWidth: material_._kMenuWidthStep,
                    child: new SingleChildScrollView(
                        padding: EdgeInsets.symmetric(
                            vertical: material_._kMenuVerticalPadding
                            ),
                        child: new ListBody(children: children)
                        )
                    )
                );

            return(new AnimatedBuilder(
                       animation: route.animation,
                       builder: (_, builderChild) => {
                return new Opacity(
                    opacity: opacity.evaluate(route.animation),
                    child: new Material(
                        shape: route.shape ?? popupMenuTheme.shape,
                        color: route.color ?? popupMenuTheme.color,
                        type: MaterialType.card,
                        elevation: route.elevation ?? popupMenuTheme.elevation ?? 8.0f,
                        child: new Align(
                            alignment: Alignment.topRight,
                            widthFactor: width.evaluate(route.animation),
                            heightFactor: height.evaluate(route.animation),
                            child: builderChild
                            )
                        )
                    );
            },
                       child: child
                       ));
        }
コード例 #21
0
        public override Widget build(BuildContext context)
        {
            return(new LayoutBuilder(
                       builder: (BuildContext _context, BoxConstraints constraints) => {
                Size size = constraints.biggest;

                CurvedAnimation primaryAnimation = new CurvedAnimation(
                    parent: animation,
                    curve: _transitionCurve,
                    reverseCurve: _transitionCurve.flipped
                    );

                Animation <float> clipAnimation = new FloatTween(
                    begin: 0.0f,
                    end: size.height
                    ).animate(primaryAnimation);

                Animation <float> opacityAnimation = _scrimOpacityTween.animate(primaryAnimation);
                Animation <Offset> primaryTranslationAnimation = _primaryTranslationTween.animate(primaryAnimation);

                Animation <Offset> secondaryTranslationAnimation = _secondaryTranslationTween.animate(
                    new CurvedAnimation(
                        parent: secondaryAnimation,
                        curve: _transitionCurve,
                        reverseCurve: _transitionCurve.flipped
                        )
                    );

                return new AnimatedBuilder(
                    animation: animation,
                    builder: (BuildContext _, Widget child) => {
                    return new Container(
                        color: Colors.black.withOpacity(opacityAnimation.value),
                        alignment: Alignment.bottomLeft,
                        child: new ClipRect(
                            child: new SizedBox(
                                height: clipAnimation.value,
                                child: new OverflowBox(
                                    alignment: Alignment.bottomLeft,
                                    maxHeight: size.height,
                                    child: child
                                    )
                                )
                            )
                        );
                },
                    child: new AnimatedBuilder(
                        animation: secondaryAnimation,
                        child: new FractionalTranslation(
                            translation: primaryTranslationAnimation.value,
                            child: this.child
                            ),
                        builder: (BuildContext _, Widget child) => {
                    return new FractionalTranslation(
                        translation: secondaryTranslationAnimation.value,
                        child: child
                        );
                }
                        )
                    );
            }
                       ));
        }
コード例 #22
0
ファイル: snack_bar.cs プロジェクト: JC-ut0/CubeGame
        public override Widget build(BuildContext context)
        {
            MediaQueryData mediaQueryData = MediaQuery.of(context);

            D.assert(this.animation != null);

            ThemeData theme     = Theme.of(context);
            ThemeData darkTheme = new ThemeData(
                brightness: Brightness.dark,
                accentColor: theme.accentColor,
                accentColorBrightness: theme.accentColorBrightness
                );

            List <Widget> children = new List <Widget> {
                new SizedBox(width: SnackBarUtils._kSnackBarPadding),
                new Expanded(
                    child: new Container(
                        padding: EdgeInsets.symmetric(vertical: SnackBarUtils._kSingleLineVerticalPadding),
                        child: new DefaultTextStyle(
                            style: darkTheme.textTheme.subhead,
                            child: this.content)
                        )
                    )
            };

            if (this.action != null)
            {
                children.Add(ButtonTheme.bar(
                                 padding: EdgeInsets.symmetric(horizontal: SnackBarUtils._kSnackBarPadding),
                                 textTheme: ButtonTextTheme.accent,
                                 child: this.action
                                 ));
            }
            else
            {
                children.Add(new SizedBox(width: SnackBarUtils._kSnackBarPadding));
            }

            CurvedAnimation heightAnimation =
                new CurvedAnimation(parent: this.animation, curve: SnackBarUtils._snackBarHeightCurve);
            CurvedAnimation fadeAnimation = new CurvedAnimation(parent: this.animation,
                                                                curve: SnackBarUtils._snackBarFadeCurve, reverseCurve: new Threshold(0.0f));
            Widget snackbar = new SafeArea(
                top: false,
                child: new Row(
                    children: children,
                    crossAxisAlignment: CrossAxisAlignment.center
                    )
                );

            snackbar = new Dismissible(
                key: Key.key("dismissible"),
                direction: DismissDirection.down,
                resizeDuration: null,
                onDismissed: (DismissDirection? direction) => {
                Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
            },
                child: new Material(
                    elevation: 6.0f,
                    color: this.backgroundColor ?? SnackBarUtils._kSnackBackground,
                    child: new Theme(
                        data: darkTheme,
                        child: mediaQueryData.accessibleNavigation
                            ? snackbar
                            : new FadeTransition(
                            opacity: fadeAnimation,
                            child: snackbar
                            )
                        )
                    )
                );

            return(new ClipRect(
                       child: mediaQueryData.accessibleNavigation
                    ? snackbar
                    : new AnimatedBuilder(
                           animation: heightAnimation,
                           builder: (BuildContext subContext, Widget child) => {
                return new Align(
                    alignment: Alignment.topLeft,
                    heightFactor: heightAnimation.value,
                    child: child
                    );
            },
                           child: snackbar
                           )
                       ));
        }
コード例 #23
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            _DropdownRoute <T>    route         = this.widget.route;
            float         unit     = 0.5f / (route.items.Count + 1.5f);
            List <Widget> children = new List <Widget>();

            for (int itemIndex = 0; itemIndex < route.items.Count; ++itemIndex)
            {
                CurvedAnimation opacity;
                if (itemIndex == route.selectedIndex)
                {
                    opacity = new CurvedAnimation(parent: route.animation, curve: new Threshold(0.0f));
                }
                else
                {
                    float start = (0.5f + (itemIndex + 1) * unit).clamp(0.0f, 1.0f);
                    float end   = (start + 1.5f * unit).clamp(0.0f, 1.0f);
                    opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end));
                }

                var index = itemIndex;
                children.Add(new FadeTransition(
                                 opacity: opacity,
                                 child: new InkWell(
                                     child: new Container(
                                         padding: this.widget.padding,
                                         child: route.items[itemIndex]
                                         ),
                                     onTap: () => Navigator.pop(
                                         context,
                                         new _DropdownRouteResult <T>(route.items[index].value)
                                         )
                                     )
                                 ));
            }

            return(new FadeTransition(
                       opacity: this._fadeOpacity,
                       child: new CustomPaint(
                           painter: new _DropdownMenuPainter(
                               color: Theme.of(context).canvasColor,
                               elevation: route.elevation,
                               selectedIndex: route.selectedIndex,
                               resize: this._resize
                               ),
                           child: new Material(
                               type: MaterialType.transparency,
                               textStyle: route.style,
                               child: new ScrollConfiguration(
                                   behavior: new _DropdownScrollBehavior(),
                                   child: new Scrollbar(
                                       child: new ListView(
                                           controller: this.widget.route.scrollController,
                                           padding: Constants.kMaterialListPadding,
                                           itemExtent: DropdownConstants._kMenuItemHeight,
                                           shrinkWrap: true,
                                           children: children
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
コード例 #24
0
        protected override Widget build(BuildContext context)
        {
            Animation <float> animation = new CurvedAnimation(
                parent: listenable as Animation <float>,
                curve: new Interval(0.0f, 0.78f)
                );

            return(new DefaultTextStyle(
                       style: Theme.of(context).primaryTextTheme.headline6,
                       softWrap: false,
                       overflow: TextOverflow.ellipsis,
                       child: new Row(children: new List <Widget> {
                new SizedBox(
                    width: 72.0f,
                    child: new IconButton(
                        padding: EdgeInsets.only(right: 8.0f),
                        onPressed: () => { onPress?.Invoke(); },
                        icon: new Stack(children: new List <Widget> {
                    new Opacity(
                        opacity: animation.value,
                        child: new Container(
                            width: 20.0f,
                            height: 20.0f,
                            decoration: new BoxDecoration(
                                image: new DecorationImage(
                                    image: new FileImage(
                                        file: "shrine_images/slanted_menu.png"
                                        )
                                    ),
                                shape: BoxShape.circle
                                )
                            )
                        ),
                    new FractionalTranslation(
                        translation: new OffsetTween(
                            begin: Offset.zero,
                            end: new Offset(1.0f, 0.0f)).evaluate(animation),
                        child: new Container(
                            width: 20.0f,
                            height: 20.0f,
                            decoration: new BoxDecoration(
                                image: new DecorationImage(
                                    image: new FileImage(
                                        file: "shrine_images/diamond.png"
                                        )
                                    ),
                                shape: BoxShape.circle
                                )
                            )
                        )
                })
                        )
                    ),
                new Stack(
                    children: new List <Widget> {
                    new Opacity(
                        opacity: new CurvedAnimation(
                            parent: new ReverseAnimation(animation),
                            curve: new Interval(0.5f, 1.0f)
                            ).value,
                        child: new FractionalTranslation(
                            translation: new OffsetTween(
                                begin: Offset.zero,
                                end: new Offset(0.5f, 0.0f)).evaluate(animation),
                            child: backTitle
                            )
                        ),
                    new Opacity(
                        opacity: new CurvedAnimation(
                            parent: animation,
                            curve: new Interval(0.5f, 1.0f)).value,
                        child: new FractionalTranslation(
                            translation: new OffsetTween(
                                begin: new Offset(-0.25f, 0.0f),
                                end: Offset.zero).evaluate(animation),
                            child: frontTitle
                            )
                        ),
                }
                    ),
            })
                       ));
        }
コード例 #25
0
        public _RenderRangeSlider(
            RangeValues values,
            int?divisions,
            RangeLabels labels,
            SliderThemeData sliderTheme,
            ThemeData theme,
            float textScaleFactor,
            RuntimePlatform platform,
            ValueChanged <RangeValues> onChanged,
            ValueChanged <RangeValues> onChangeStart,
            ValueChanged <RangeValues> onChangeEnd,
            _RangeSliderState state,
            TextDirection?textDirection)
        {
            D.assert(values != null);
            D.assert(values.start >= 0.0 && values.start <= 1.0);
            D.assert(values.end >= 0.0 && values.end <= 1.0);
            D.assert(state != null);
            D.assert(textDirection != null);

            this.onChangeStart = onChangeStart;
            this.onChangeEnd   = onChangeEnd;

            _platform        = platform;
            _labels          = labels;
            _values          = values;
            _divisions       = divisions;
            _sliderTheme     = sliderTheme;
            _theme           = theme;
            _textScaleFactor = textScaleFactor;
            _onChanged       = onChanged;
            _state           = state;
            _textDirection   = textDirection;

            _updateLabelPainters();

            GestureArenaTeam team = new GestureArenaTeam();

            _drag          = new HorizontalDragGestureRecognizer();
            _drag.team     = team;
            _drag.onStart  = _handleDragStart;
            _drag.onUpdate = _handleDragUpdate;
            _drag.onEnd    = _handleDragEnd;
            _drag.onCancel = _handleDragCancel;

            _tap             = new TapGestureRecognizer();
            _tap.team        = team;
            _tap.onTapDown   = _handleTapDown;
            _tap.onTapUp     = _handleTapUp;
            _tap.onTapCancel = _handleTapCancel;

            _overlayAnimation = new CurvedAnimation(
                parent: _state.overlayController,
                curve: Curves.fastOutSlowIn
                );
            _valueIndicatorAnimation = new CurvedAnimation(
                parent: _state.valueIndicatorController,
                curve: Curves.fastOutSlowIn
                );
            _enableAnimation = new CurvedAnimation(
                parent: _state.enableController,
                curve: Curves.easeInOut
                );
        }
コード例 #26
0
        public override Widget build(BuildContext context)
        {
            MediaQueryData mediaQueryData = MediaQuery.of(context);

            D.assert(widget.animation != null);
            ThemeData         theme         = Theme.of(context);
            ColorScheme       colorScheme   = theme.colorScheme;
            SnackBarThemeData snackBarTheme = theme.snackBarTheme;
            bool isThemeDark = theme.brightness == Brightness.dark;

            Brightness brightness           = isThemeDark ? Brightness.light : Brightness.dark;
            Color      themeBackgroundColor = isThemeDark
                ? colorScheme.onSurface
                : Color.alphaBlend(colorScheme.onSurface.withOpacity(0.80f), colorScheme.surface);
            ThemeData inverseTheme = new ThemeData(
                brightness: brightness,
                backgroundColor: themeBackgroundColor,
                colorScheme: new ColorScheme(
                    primary: colorScheme.onPrimary,
                    primaryVariant: colorScheme.onPrimary,
                    secondary: isThemeDark ? colorScheme.primaryVariant : colorScheme.secondary,
                    secondaryVariant: colorScheme.onSecondary,
                    surface: colorScheme.onSurface,
                    background: themeBackgroundColor,
                    error: colorScheme.onError,
                    onPrimary: colorScheme.primary,
                    onSecondary: colorScheme.secondary,
                    onSurface: colorScheme.surface,
                    onBackground: colorScheme.background,
                    onError: colorScheme.error,
                    brightness: brightness
                    ),
                snackBarTheme: snackBarTheme
                );

            TextStyle        contentTextStyle   = snackBarTheme.contentTextStyle ?? inverseTheme.textTheme.subtitle1;
            SnackBarBehavior snackBarBehavior   = widget.behavior ?? snackBarTheme.behavior ?? SnackBarBehavior.fix;
            bool             isFloatingSnackBar = snackBarBehavior == SnackBarBehavior.floating;
            float            snackBarPadding    = isFloatingSnackBar ? 16.0f : 24.0f;

            CurvedAnimation heightAnimation =
                new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarHeightCurve);
            CurvedAnimation fadeInAnimation =
                new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarFadeInCurve);
            CurvedAnimation fadeOutAnimation = new CurvedAnimation(
                parent: widget.animation,
                curve: SnackBarUtils._snackBarFadeOutCurve,
                reverseCurve: new Threshold(0.0f)
                );

            var childrenList = new List <Widget>()
            {
                new SizedBox(width: snackBarPadding),
                new Expanded(
                    child: new Container(
                        padding: EdgeInsets.symmetric(vertical: SnackBarUtils._singleLineVerticalPadding),
                        child: new DefaultTextStyle(
                            style: contentTextStyle,
                            child: widget.content
                            )
                        )
                    )
            };

            if (widget.action != null)
            {
                childrenList.Add(new ButtonTheme(
                                     textTheme: ButtonTextTheme.accent,
                                     minWidth: 64.0f,
                                     padding: EdgeInsets.symmetric(horizontal: snackBarPadding),
                                     child: widget.action
                                     ));
            }
            else
            {
                childrenList.Add(new SizedBox(width: snackBarPadding));
            }

            Widget snackBar = new SafeArea(
                top: false,
                bottom: !isFloatingSnackBar,
                child: new Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: childrenList
                    )
                );

            float elevation       = widget.elevation ?? snackBarTheme.elevation ?? 6.0f;
            Color backgroundColor =
                widget.backgroundColor ?? snackBarTheme.backgroundColor ?? inverseTheme.backgroundColor;
            ShapeBorder shape = widget.shape
                                ?? snackBarTheme.shape
                                ?? (isFloatingSnackBar
                                    ? new RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0f))
                                    : null);

            snackBar = new Material(
                shape: shape,
                elevation: elevation,
                color: backgroundColor,
                child: new Theme(
                    data: inverseTheme,
                    child: mediaQueryData.accessibleNavigation
                        ? snackBar
                        : new FadeTransition(
                        opacity: fadeOutAnimation,
                        child: snackBar
                        )
                    )
                );

            if (isFloatingSnackBar)
            {
                snackBar = new Padding(
                    padding: EdgeInsets.fromLTRB(15.0f, 5.0f, 15.0f, 10.0f),
                    child: snackBar
                    );
            }

            snackBar = new Dismissible(
                key: Key.key("dismissible"),
                direction: DismissDirection.down,
                resizeDuration: null,
                onDismissed: (DismissDirection? direction) => {
                Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
            },
                child: snackBar
                );

            Widget snackBarTransition = null;

            if (mediaQueryData.accessibleNavigation)
            {
                snackBarTransition = snackBar;
            }
            else if (isFloatingSnackBar)
            {
                snackBarTransition = new FadeTransition(
                    opacity: fadeInAnimation,
                    child: snackBar
                    );
            }
            else
            {
                snackBarTransition = new AnimatedBuilder(
                    animation: heightAnimation,
                    builder: (BuildContext subContext, Widget subChild) => {
                    return(new Align(
                               alignment: AlignmentDirectional.topStart,
                               heightFactor: heightAnimation.value,
                               child: subChild
                               ));
                },
                    child: snackBar
                    );
            }

            return(new ClipRect(child: snackBarTransition));
        }
コード例 #27
0
        Animation <RelativeRect> _getLayerAnimation(Size layerSize, float layerTop)
        {
            Curve             firstCurve;
            Curve             secondCurve;
            float             firstWeight;
            float             secondWeight;
            Animation <float> animation;

            if (_frontLayerVisible)
            {
                firstCurve   = backdropUtils._kAccelerateCurve;
                secondCurve  = backdropUtils._kDecelerateCurve;
                firstWeight  = backdropUtils._kPeakVelocityTime;
                secondWeight = 1.0f - backdropUtils._kPeakVelocityTime;
                animation    = new CurvedAnimation(
                    parent: _controller.view,
                    curve: new Interval(0.0f, 0.78f)
                    );
            }
            else
            {
                firstCurve   = backdropUtils._kDecelerateCurve.flipped;
                secondCurve  = backdropUtils._kAccelerateCurve.flipped;
                firstWeight  = 1.0f - backdropUtils._kPeakVelocityTime;
                secondWeight = backdropUtils._kPeakVelocityTime;
                animation    = _controller.view;
            }

            return(new TweenSequence <RelativeRect>(
                       new List <TweenSequenceItem <RelativeRect> > {
                new TweenSequenceItem <RelativeRect>(
                    tween: new RelativeRectTween(
                        begin: RelativeRect.fromLTRB(
                            0.0f,
                            layerTop,
                            0.0f,
                            layerTop - layerSize.height
                            ),
                        end: RelativeRect.fromLTRB(
                            0.0f,
                            layerTop * backdropUtils._kPeakVelocityProgress,
                            0.0f,
                            (layerTop - layerSize.height) * backdropUtils._kPeakVelocityProgress
                            )
                        ).chain(new CurveTween(curve: firstCurve)),
                    weight: firstWeight
                    ),
                new TweenSequenceItem <RelativeRect>(
                    tween: new RelativeRectTween(
                        begin: RelativeRect.fromLTRB(
                            0.0f,
                            layerTop * backdropUtils._kPeakVelocityProgress,
                            0.0f,
                            (layerTop - layerSize.height) * backdropUtils._kPeakVelocityProgress
                            ),
                        end: RelativeRect.fill
                        ).chain(new CurveTween(curve: secondCurve)),
                    weight: secondWeight
                    ),
            }
                       ).animate(animation));
        }