Commit dc1eefa9 authored by Alexander Ryzhov's avatar Alexander Ryzhov Committed by xster

Fixed #27621: CupertinoTimerPicker breaks if minuteInterval > 1 (#27647)

parent e5e89529
...@@ -1150,7 +1150,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> { ...@@ -1150,7 +1150,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
backgroundColor: _kBackgroundColor, backgroundColor: _kBackgroundColor,
onSelectedItemChanged: (int index) { onSelectedItemChanged: (int index) {
setState(() { setState(() {
selectedMinute = index; selectedMinute = index * widget.minuteInterval;
widget.onTimerDurationChanged( widget.onTimerDurationChanged(
Duration( Duration(
hours: selectedHour ?? 0, hours: selectedHour ?? 0,
...@@ -1262,7 +1262,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> { ...@@ -1262,7 +1262,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
backgroundColor: _kBackgroundColor, backgroundColor: _kBackgroundColor,
onSelectedItemChanged: (int index) { onSelectedItemChanged: (int index) {
setState(() { setState(() {
selectedSecond = index; selectedSecond = index * widget.secondInterval;
widget.onTimerDurationChanged( widget.onTimerDurationChanged(
Duration( Duration(
hours: selectedHour ?? 0, hours: selectedHour ?? 0,
......
...@@ -198,6 +198,39 @@ void main() { ...@@ -198,6 +198,39 @@ void main() {
); );
}); });
}); });
testWidgets('picker honors minuteInterval and secondInterval', (WidgetTester tester) async {
Duration duration;
await tester.pumpWidget(
CupertinoApp(
home: SizedBox(
height: 400.0,
width: 400.0,
child: CupertinoTimerPicker(
minuteInterval: 10,
secondInterval: 15,
initialTimerDuration: const Duration(hours: 10, minutes: 40, seconds: 45),
mode: CupertinoTimerPickerMode.hms,
onTimerDurationChanged: (Duration d) {
duration = d;
},
),
),
),
);
await tester.drag(find.text('40'), _kRowOffset);
await tester.pump();
await tester.drag(find.text('45'), -_kRowOffset);
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
duration,
const Duration(hours: 10, minutes: 50, seconds: 30),
);
});
group('Date picker', () { group('Date picker', () {
testWidgets('mode is not null', (WidgetTester tester) async { testWidgets('mode is not null', (WidgetTester tester) async {
expect( expect(
......
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