mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Fix current day not being decorated when it was disabled for picking. (#115240)
Fixes flutter/flutter#113277
This commit is contained in:
parent
96d7f9cb13
commit
2703a2bcde
@ -979,16 +979,20 @@ class _DayPickerState extends State<_DayPicker> {
|
|||||||
color: selectedDayBackground,
|
color: selectedDayBackground,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
);
|
);
|
||||||
} else if (isDisabled) {
|
|
||||||
dayColor = disabledDayColor;
|
|
||||||
} else if (isToday) {
|
} else if (isToday) {
|
||||||
// The current day gets a different text color and a circle stroke
|
// The current day gets a different text color (if enabled) and a circle stroke
|
||||||
// border.
|
// border.
|
||||||
|
if (isDisabled) {
|
||||||
|
dayColor = disabledDayColor;
|
||||||
|
} else {
|
||||||
dayColor = todayColor;
|
dayColor = todayColor;
|
||||||
|
}
|
||||||
decoration = BoxDecoration(
|
decoration = BoxDecoration(
|
||||||
border: Border.all(color: todayColor),
|
border: Border.all(color: dayColor),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
);
|
);
|
||||||
|
} else if (isDisabled) {
|
||||||
|
dayColor = disabledDayColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget dayWidget = Container(
|
Widget dayWidget = Container(
|
||||||
|
@ -337,6 +337,26 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('currentDate is highlighted even if it is disabled', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(calendarDatePicker(
|
||||||
|
firstDate: DateTime(2016, 1, 3),
|
||||||
|
lastDate: DateTime(2016, 1, 31),
|
||||||
|
currentDate: DateTime(2016, 1, 2), // not between first and last
|
||||||
|
initialDate: DateTime(2016, 1, 5),
|
||||||
|
));
|
||||||
|
const Color disabledColor = Color(0x61000000); // default disabled color
|
||||||
|
expect(
|
||||||
|
Material.of(tester.element(find.text('2'))),
|
||||||
|
// The current day should be painted with a circle outline.
|
||||||
|
paints
|
||||||
|
..circle(
|
||||||
|
color: disabledColor,
|
||||||
|
style: PaintingStyle.stroke,
|
||||||
|
strokeWidth: 1.0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async {
|
testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(calendarDatePicker(
|
await tester.pumpWidget(calendarDatePicker(
|
||||||
initialDate: DateTime(2020, DateTime.may, 10),
|
initialDate: DateTime(2020, DateTime.may, 10),
|
||||||
|
Loading…
Reference in New Issue
Block a user