Exemplo n.º 1
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);
        }
        public override void initState()
        {
            base.initState();

            GestureArenaTeam team = new GestureArenaTeam();

            longPress.team = team;
            drag.team      = team;
            team.captain   = drag;

            _highlighted = widget.groupValue;

            thumbController = new AnimationController(
                duration: CupertinoSlidingSegmentedControlsUtils._kSpringAnimationDuration,
                value: 0,
                vsync: this
                );

            thumbScaleController = new AnimationController(
                duration:    CupertinoSlidingSegmentedControlsUtils._kSpringAnimationDuration,
                value: 1,
                vsync: this
                );

            separatorOpacityController = new AnimationController(
                duration:    CupertinoSlidingSegmentedControlsUtils._kSpringAnimationDuration,
                value: 0,
                vsync: this
                );

            foreach (T currentKey in widget.children.Keys)
            {
                _highlightControllers[currentKey] = _createHighlightAnimationController(
                    isCompleted: currentKey.Equals(widget.groupValue) // Highlight the current selection.
                    );
                _pressControllers[currentKey] = _createFadeoutAnimationController();
            }
        }
Exemplo n.º 3
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
                );
        }