Beispiel #1
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));

            SliderThemeData sliderTheme = SliderTheme.of(context);

            if (this.widget.activeColor != null || this.widget.inactiveColor != null)
            {
                sliderTheme = sliderTheme.copyWith(
                    activeTrackColor: this.widget.activeColor,
                    inactiveTrackColor: this.widget.inactiveColor,
                    activeTickMarkColor: this.widget.inactiveColor,
                    inactiveTickMarkColor: this.widget.activeColor,
                    thumbColor: this.widget.activeColor,
                    valueIndicatorColor: this.widget.activeColor,
                    overlayColor: this.widget.activeColor?.withAlpha(0x29)
                    );
            }

            return(new _SliderRenderObjectWidget(
                       value: this._unlerp(this.widget.value),
                       divisions: this.widget.divisions,
                       label: this.widget.label,
                       sliderTheme: sliderTheme,
                       mediaQueryData: MediaQuery.of(context),
                       onChanged: (this.widget.onChanged != null) && (this.widget.max > this.widget.min)
                    ? this._handleChanged
                    : (ValueChanged <float>)null,
                       onChangeStart: this.widget.onChangeStart != null ? this._handleDragStart : (ValueChanged <float>)null,
                       onChangeEnd: this.widget.onChangeEnd != null ? this._handleDragEnd : (ValueChanged <float>)null,
                       state: this
                       ));
        }
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));

            ThemeData       theme       = Theme.of(context);
            SliderThemeData sliderTheme = SliderTheme.of(context);

            sliderTheme = sliderTheme.copyWith(
                trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
                activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
                inactiveTrackColor: widget.inactiveColor ??
                sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
                disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ??
                theme.colorScheme.onSurface.withOpacity(0.32f),
                disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ??
                theme.colorScheme.onSurface.withOpacity(0.12f),
                activeTickMarkColor: widget.inactiveColor ??
                sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
                inactiveTickMarkColor: widget.activeColor ??
                sliderTheme.inactiveTickMarkColor ??
                theme.colorScheme.primary.withOpacity(0.54f),
                disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ??
                theme.colorScheme.onPrimary.withOpacity(0.12f),
                disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ??
                theme.colorScheme.onSurface.withOpacity(0.12f),
                thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
                overlappingShapeStrokeColor: sliderTheme.overlappingShapeStrokeColor ?? theme.colorScheme.surface,
                disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
                overlayColor: widget.activeColor?.withOpacity(0.12f) ??
                sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
                valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
                rangeTrackShape: sliderTheme.rangeTrackShape ?? _defaultTrackShape,
                rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? _defaultTickMarkShape,
                rangeThumbShape: sliderTheme.rangeThumbShape ?? _defaultThumbShape,
                overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
                rangeValueIndicatorShape: sliderTheme.rangeValueIndicatorShape ?? _defaultValueIndicatorShape,
                showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
                valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
                    color: theme.colorScheme.onPrimary
                    ),
                minThumbSeparation: sliderTheme.minThumbSeparation ?? _defaultMinThumbSeparation,
                thumbSelector: sliderTheme.thumbSelector ?? _defaultRangeThumbSelector
                );

            return(new _RangeSliderRenderObjectWidget(
                       values: _unlerpRangeValues(widget.values),
                       divisions: widget.divisions,
                       labels: widget.labels,
                       sliderTheme: sliderTheme,
                       textScaleFactor: MediaQuery.of(context).textScaleFactor,
                       onChanged: (widget.onChanged != null) && (widget.max > widget.min)
                    ? _handleChanged
                    : (ValueChanged <RangeValues>)null,
                       onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged <RangeValues>)null,
                       onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged <RangeValues>)null,
                       state: this
                       ));
        }
Beispiel #3
0
        Widget _buildMaterialSlider(BuildContext context)
        {
            ThemeData       theme       = Theme.of(context);
            SliderThemeData sliderTheme = SliderTheme.of(context);

            sliderTheme = sliderTheme.copyWith(
                trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
                activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
                inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
                disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32f),
                disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
                activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
                inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54f),
                disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12f),
                disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
                thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
                disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
                overlayColor: widget.activeColor?.withOpacity(0.12f) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
                valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
                trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
                tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
                thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
                overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
                valueIndicatorShape: sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape,
                showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
                valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
                    color: theme.colorScheme.onPrimary
                    )
                );

            return(new _SliderRenderObjectWidget(
                       value: _unlerp(widget.value),
                       divisions: widget.divisions,
                       label: widget.label,
                       sliderTheme: sliderTheme,
                       mediaQueryData: MediaQuery.of(context),
                       onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : (ValueChanged <float>)null,
                       onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged <float>)null,
                       onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged <float>)null,
                       state: this
                       ));
        }