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

This commit is contained in:
Alexander Ryzhov 2019-02-07 13:20:10 -08:00 committed by xster
parent e5e8952948
commit dc1eefa997
2 changed files with 35 additions and 2 deletions

View File

@ -1150,7 +1150,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
backgroundColor: _kBackgroundColor,
onSelectedItemChanged: (int index) {
setState(() {
selectedMinute = index;
selectedMinute = index * widget.minuteInterval;
widget.onTimerDurationChanged(
Duration(
hours: selectedHour ?? 0,
@ -1262,7 +1262,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
backgroundColor: _kBackgroundColor,
onSelectedItemChanged: (int index) {
setState(() {
selectedSecond = index;
selectedSecond = index * widget.secondInterval;
widget.onTimerDurationChanged(
Duration(
hours: selectedHour ?? 0,

View File

@ -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', () {
testWidgets('mode is not null', (WidgetTester tester) async {
expect(