Commit 75fec892 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Propagate theme typography to slider label (#6629)

parent 67f59100
......@@ -139,11 +139,13 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
return new _SliderRenderObjectWidget(
value: (config.value - config.min) / (config.max - config.min),
divisions: config.divisions,
label: config.label,
activeColor: config.activeColor ?? Theme.of(context).accentColor,
activeColor: config.activeColor ?? theme.accentColor,
textTheme: theme.primaryTextTheme,
onChanged: config.onChanged != null ? _handleChanged : null,
vsync: this,
);
......@@ -157,6 +159,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
this.divisions,
this.label,
this.activeColor,
this.textTheme,
this.onChanged,
this.vsync,
}) : super(key: key);
......@@ -165,6 +168,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
final int divisions;
final String label;
final Color activeColor;
final TextTheme textTheme;
final ValueChanged<double> onChanged;
final TickerProvider vsync;
......@@ -174,6 +178,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
divisions: divisions,
label: label,
activeColor: activeColor,
textTheme: textTheme,
onChanged: onChanged,
vsync: vsync,
);
......@@ -185,6 +190,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
..divisions = divisions
..label = label
..activeColor = activeColor
..textTheme = textTheme
..onChanged = onChanged;
// Ticker provider cannot change since there's a 1:1 relationship between
// the _SliderRenderObjectWidget object and the _SliderState object.
......@@ -229,11 +235,13 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
int divisions,
String label,
Color activeColor,
TextTheme textTheme,
this.onChanged,
TickerProvider vsync,
}) : _value = value,
_divisions = divisions,
_activeColor = activeColor,
_textTheme = textTheme,
super(additionalConstraints: _getAdditionalConstraints(label)) {
assert(value != null && value >= 0.0 && value <= 1.0);
this.label = label;
......@@ -290,7 +298,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
// https://github.com/flutter/flutter/issues/5938
_labelPainter
..text = new TextSpan(
style: Typography.white.body1.copyWith(fontSize: 10.0),
style: _textTheme.body1.copyWith(fontSize: 10.0),
text: newLabel
)
..layout();
......@@ -309,6 +317,15 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
markNeedsPaint();
}
TextTheme get textTheme => _textTheme;
TextTheme _textTheme;
set textTheme(TextTheme value) {
if (value == _textTheme)
return;
_textTheme = value;
markNeedsPaint();
}
ValueChanged<double> onChanged;
double get _trackLength => size.width - 2.0 * _kReactionRadius;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment