-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rfw] Material slider widget #6610
base: main
Are you sure you want to change the base?
Changes from 6 commits
e7fe375
70c0c4d
a0d3e44
e36ff8f
4174533
77f6303
d502d46
771f595
6f89100
5b48d90
905f8a9
77028ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 1.0.27 | ||
* Adds `Slider` material widget | ||
|
||
## 1.0.26 | ||
* Supports overriding the error widget builder. | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -37,6 +37,7 @@ import 'runtime.dart'; | |||||||||||||||||||
/// * [Material] | ||||||||||||||||||||
/// * [OutlinedButton] | ||||||||||||||||||||
/// * [Scaffold] | ||||||||||||||||||||
/// * [Slider] | ||||||||||||||||||||
/// * [TextButton] | ||||||||||||||||||||
/// * [VerticalDivider] | ||||||||||||||||||||
/// * [OverflowBar] | ||||||||||||||||||||
|
@@ -499,6 +500,39 @@ Map<String, LocalWidgetBuilder> get _materialWidgetsDefinitions => <String, Loca | |||||||||||||||||||
); | ||||||||||||||||||||
}, | ||||||||||||||||||||
|
||||||||||||||||||||
'Slider': (BuildContext context, DataSource source) { | ||||||||||||||||||||
// not implemented: overlayColor, mouseCursor, semanticFormatterCallback, focusNode, autofocus | ||||||||||||||||||||
final min = source.v<double>(['min']) ?? 0.0; | ||||||||||||||||||||
final value = source.v<double>(['value']) ?? min; | ||||||||||||||||||||
final labelText = source.v<String>(['label']); | ||||||||||||||||||||
final label = labelText != null ? '$labelText:${value.toStringAsFixed(2)}' : value.toStringAsFixed(2); | ||||||||||||||||||||
return Slider( | ||||||||||||||||||||
value: value, | ||||||||||||||||||||
secondaryTrackValue: source.v<double>(['secondaryTrackValue']), | ||||||||||||||||||||
onChanged: source.handler(['onChanged'], | ||||||||||||||||||||
(HandlerTrigger trigger) => (double value) { | ||||||||||||||||||||
trigger({'value': value}); | ||||||||||||||||||||
}), | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the style guide, indentation should never have a line that is less indented than a line that is of higher lexical scope (well the style guide doesn't say it quite that way but that's the intent).
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same below) |
||||||||||||||||||||
onChangeStart: source.handler(['onChangeStart'], | ||||||||||||||||||||
(HandlerTrigger trigger) => (double value) { | ||||||||||||||||||||
trigger({'value': value}); | ||||||||||||||||||||
}), | ||||||||||||||||||||
onChangeEnd: source.handler(['onChangeEnd'], | ||||||||||||||||||||
(HandlerTrigger trigger) => (double value) { | ||||||||||||||||||||
trigger({'value': value}); | ||||||||||||||||||||
}), | ||||||||||||||||||||
min: min, | ||||||||||||||||||||
max: source.v<double>(['max']) ?? 1.0, | ||||||||||||||||||||
divisions: source.v<int>(['divisions']), | ||||||||||||||||||||
label: label, | ||||||||||||||||||||
activeColor: ArgumentDecoders.color(source, ['activeColor']), | ||||||||||||||||||||
inactiveColor: ArgumentDecoders.color(source, ['inactiveColor']), | ||||||||||||||||||||
secondaryActiveColor: ArgumentDecoders.color(source, ['secondaryActiveColor']), | ||||||||||||||||||||
thumbColor: ArgumentDecoders.color(source, ['thumbColor']), | ||||||||||||||||||||
allowedInteraction: ArgumentDecoders.enumValue<SliderInteraction>(SliderInteraction.values, source, ['allowedInteraction']), | ||||||||||||||||||||
); | ||||||||||||||||||||
}, | ||||||||||||||||||||
|
||||||||||||||||||||
'TextButton': (BuildContext context, DataSource source) { | ||||||||||||||||||||
// not implemented: buttonStyle, focusNode | ||||||||||||||||||||
return TextButton( | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import 'dart:io' show Platform; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
// Detects if we're running the tests on the main channel. | ||
// | ||
|
@@ -21,3 +22,15 @@ bool get isMainChannel { | |
|
||
// See Contributing section of README.md file. | ||
final bool runGoldens = !kIsWeb && Platform.isLinux && isMainChannel; | ||
|
||
// slide to value for material slider in tests | ||
extension SlideTo on WidgetTester { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make this a function instead of an extension? that would make it easier to find when reading the code (otherwise it looks like you have to look on WidgetTester). See also https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-using-extension |
||
Future<void> slideToValue(Finder slider, double value, | ||
{double paddingOffset = 24.0}) async { | ||
final Offset zeroPoint = | ||
getTopLeft(slider) + Offset(paddingOffset, getSize(slider).height / 2); | ||
final double totalWidth = getSize(slider).width - (2 * paddingOffset); | ||
final double calculateOffset = value * (totalWidth / 100); | ||
await dragFrom(zeroPoint, Offset(calculateOffset, 0)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be a space after the
:
?