Unverified Commit 0cdd131c authored by Darren Austin's avatar Darren Austin Committed by GitHub

Removed the date from the Next/Previous month buttons on the Date Picker. (#96876)

parent 5d0403db
...@@ -490,8 +490,6 @@ class _MonthPicker extends StatefulWidget { ...@@ -490,8 +490,6 @@ class _MonthPicker extends StatefulWidget {
class _MonthPickerState extends State<_MonthPicker> { class _MonthPickerState extends State<_MonthPicker> {
final GlobalKey _pageViewKey = GlobalKey(); final GlobalKey _pageViewKey = GlobalKey();
late DateTime _currentMonth; late DateTime _currentMonth;
late DateTime _nextMonthDate;
late DateTime _previousMonthDate;
late PageController _pageController; late PageController _pageController;
late MaterialLocalizations _localizations; late MaterialLocalizations _localizations;
late TextDirection _textDirection; late TextDirection _textDirection;
...@@ -504,8 +502,6 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -504,8 +502,6 @@ class _MonthPickerState extends State<_MonthPicker> {
void initState() { void initState() {
super.initState(); super.initState();
_currentMonth = widget.initialMonth; _currentMonth = widget.initialMonth;
_previousMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, -1);
_nextMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, 1);
_pageController = PageController(initialPage: DateUtils.monthDelta(widget.firstDate, _currentMonth)); _pageController = PageController(initialPage: DateUtils.monthDelta(widget.firstDate, _currentMonth));
_shortcutMap = const <ShortcutActivator, Intent>{ _shortcutMap = const <ShortcutActivator, Intent>{
SingleActivator(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left), SingleActivator(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left),
...@@ -556,8 +552,6 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -556,8 +552,6 @@ class _MonthPickerState extends State<_MonthPicker> {
final DateTime monthDate = DateUtils.addMonthsToMonthDate(widget.firstDate, monthPage); final DateTime monthDate = DateUtils.addMonthsToMonthDate(widget.firstDate, monthPage);
if (!DateUtils.isSameMonth(_currentMonth, monthDate)) { if (!DateUtils.isSameMonth(_currentMonth, monthDate)) {
_currentMonth = DateTime(monthDate.year, monthDate.month); _currentMonth = DateTime(monthDate.year, monthDate.month);
_previousMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, -1);
_nextMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, 1);
widget.onDisplayedMonthChanged(_currentMonth); widget.onDisplayedMonthChanged(_currentMonth);
if (_focusedDay != null && !DateUtils.isSameMonth(_focusedDay, _currentMonth)) { if (_focusedDay != null && !DateUtils.isSameMonth(_focusedDay, _currentMonth)) {
// We have navigated to a new month with the grid focused, but the // We have navigated to a new month with the grid focused, but the
...@@ -565,6 +559,10 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -565,6 +559,10 @@ class _MonthPickerState extends State<_MonthPicker> {
// the same day of the month. // the same day of the month.
_focusedDay = _focusableDayForMonth(_currentMonth, _focusedDay!.day); _focusedDay = _focusableDayForMonth(_currentMonth, _focusedDay!.day);
} }
SemanticsService.announce(
_localizations.formatMonthYear(_currentMonth),
_textDirection,
);
} }
}); });
} }
...@@ -596,10 +594,6 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -596,10 +594,6 @@ class _MonthPickerState extends State<_MonthPicker> {
/// Navigate to the next month. /// Navigate to the next month.
void _handleNextMonth() { void _handleNextMonth() {
if (!_isDisplayingLastMonth) { if (!_isDisplayingLastMonth) {
SemanticsService.announce(
_localizations.formatMonthYear(_nextMonthDate),
_textDirection,
);
_pageController.nextPage( _pageController.nextPage(
duration: _monthScrollDuration, duration: _monthScrollDuration,
curve: Curves.ease, curve: Curves.ease,
...@@ -610,10 +604,6 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -610,10 +604,6 @@ class _MonthPickerState extends State<_MonthPicker> {
/// Navigate to the previous month. /// Navigate to the previous month.
void _handlePreviousMonth() { void _handlePreviousMonth() {
if (!_isDisplayingFirstMonth) { if (!_isDisplayingFirstMonth) {
SemanticsService.announce(
_localizations.formatMonthYear(_previousMonthDate),
_textDirection,
);
_pageController.previousPage( _pageController.previousPage(
duration: _monthScrollDuration, duration: _monthScrollDuration,
curve: Curves.ease, curve: Curves.ease,
...@@ -748,8 +738,6 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -748,8 +738,6 @@ class _MonthPickerState extends State<_MonthPicker> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String previousTooltipText = '${_localizations.previousMonthTooltip} ${_localizations.formatMonthYear(_previousMonthDate)}';
final String nextTooltipText = '${_localizations.nextMonthTooltip} ${_localizations.formatMonthYear(_nextMonthDate)}';
final Color controlColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.60); final Color controlColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.60);
return Semantics( return Semantics(
...@@ -764,13 +752,13 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -764,13 +752,13 @@ class _MonthPickerState extends State<_MonthPicker> {
IconButton( IconButton(
icon: const Icon(Icons.chevron_left), icon: const Icon(Icons.chevron_left),
color: controlColor, color: controlColor,
tooltip: _isDisplayingFirstMonth ? null : previousTooltipText, tooltip: _isDisplayingFirstMonth ? null : _localizations.previousMonthTooltip,
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth, onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
), ),
IconButton( IconButton(
icon: const Icon(Icons.chevron_right), icon: const Icon(Icons.chevron_right),
color: controlColor, color: controlColor,
tooltip: _isDisplayingLastMonth ? null : nextTooltipText, tooltip: _isDisplayingLastMonth ? null : _localizations.nextMonthTooltip,
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
), ),
], ],
......
...@@ -649,7 +649,7 @@ void main() { ...@@ -649,7 +649,7 @@ void main() {
// Prev/Next month buttons. // Prev/Next month buttons.
expect(tester.getSemantics(previousMonthIcon), matchesSemantics( expect(tester.getSemantics(previousMonthIcon), matchesSemantics(
label: 'Previous month December 2015', label: 'Previous month',
isButton: true, isButton: true,
hasTapAction: true, hasTapAction: true,
isEnabled: true, isEnabled: true,
...@@ -657,7 +657,7 @@ void main() { ...@@ -657,7 +657,7 @@ void main() {
isFocusable: true, isFocusable: true,
)); ));
expect(tester.getSemantics(nextMonthIcon), matchesSemantics( expect(tester.getSemantics(nextMonthIcon), matchesSemantics(
label: 'Next month February 2016', label: 'Next month',
isButton: true, isButton: true,
hasTapAction: true, hasTapAction: true,
isEnabled: true, isEnabled: true,
......
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