Skip to content

[Material] Simple API for skipping over certain Slider shapes - #27613

Merged
clocksmith merged 11 commits into
flutter:masterfrom
clocksmith:slider-shape-empty
Feb 11, 2019
Merged

clocksmith merged 11 commits into
flutter:masterfrom
clocksmith:slider-shape-empty

Conversation

@clocksmith

@clocksmith clocksmith commented Feb 6, 2019 •

Copy link
Copy Markdown
Contributor

Make it possible to selectively disable the visuals for the slider's track, thumb, overlay (expands around the thumb when it's pressed), tick marks, and value indicator.

  • To disable the track visual set SliderThemeData.trackHeight to 0.
  • To disable the thumb visual set SliderThemeData.thumbShape to SliderComponentShape.noThumb.
  • To disable the overlay visual set SliderThemeData.overlayShape to SliderComponentShape.noOverlay.
  • To disable the tick marks set SliderThemeData.tickMarkShape to SliderTickMarkShape.noTickMark.
  • To disable the value indicator set SliderThemeData.showValueIndicator to ShowValueIndicator.never.

@clocksmith clocksmith self-assigned this Feb 6, 2019
@clocksmith
clocksmith requested a review from HansMuller February 6, 2019 20:50
@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Feb 7, 2019

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. The gist of the feedback is to make the empty shape classes private and make the connection between the noFoo shapes and the SliderThemeData properties clear.

/// [RoundSliderOverlayShape] for examples.
///
/// The track painting can be skipped by specifying [trackHeight] as 0.
/// The thumb painting can be skipped by specifying

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to identify which properties are to be set in each case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

TextDirection textDirection,
});

/// Special instance of [SliderTickMarkShape] to skip the thumb painting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where a "See also" section that points to the SliderThemeData tick mark property would be helpful

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here and in the other 2 special instance docs (thumb, overlay)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for all 3 shapes

Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
@clocksmith

Copy link
Copy Markdown
Contributor Author

Updated. Need a second look at new dartdoc added

@johnsonmh johnsonmh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments.

Comment thread packages/flutter/lib/src/material/slider_theme.dart
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart
Comment thread packages/flutter/lib/src/material/slider_theme.dart
await tester.pumpAndSettle();

// Now that there is a tap, and the value indicator is specified to be
// , shown an path is expected to be painted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not totally sure what this supposed to say, but I think there is a typo on the second line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was a typo, updated

@rami-a rami-a left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor comments

Comment thread packages/flutter/lib/src/material/slider_theme.dart
//
// The value indicator can be skipped by passing the appropriate
// [ShowValueIndicator].
testWidgets('The slider shape paintings can be variously skipped or removed', (WidgetTester tester) async {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit/Optional: I would suggest breaking this into multiple smaller tests to make it easier to follow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

await tester.pumpAndSettle();

// 1 value indicator.
expect(sliderBox, paintsExactlyCountTimes(#drawPath, 1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can strengthen the tests a bit by also checking that 0 circles/rects were painted. Like-wise for the other tests too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rami-a rami-a left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few minor changes.

Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/lib/src/material/slider_theme.dart Outdated
Comment thread packages/flutter/test/material/slider_theme_test.dart Outdated
@clocksmith
clocksmith merged commit 39bb671 into flutter:master Feb 11, 2019
kangwang1988 pushed a commit to XianyuTech/flutter that referenced this pull request Feb 12, 2019
…r#27613)

* Provide a simmplified API for skipping over slider thumb, overlay, and tick mark painting

* doc fixes

* comments

* comments

* comments

* comments

* comments

* analyzer

* comments
@clocksmith
clocksmith deleted the slider-shape-empty branch September 12, 2019 16:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants