Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
cc36608f
Unverified
Commit
cc36608f
authored
4 years ago
by
Darren Austin
Committed by
GitHub
4 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keyboard navigation for the Material Date Picker grid (#59586)
parent
dd6dd7ae
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
492 additions
and
114 deletions
+492
-114
calendar_date_picker.dart
...lutter/lib/src/material/pickers/calendar_date_picker.dart
+289
-90
date_picker_dialog.dart
.../flutter/lib/src/material/pickers/date_picker_dialog.dart
+27
-19
date_utils.dart
packages/flutter/lib/src/material/pickers/date_utils.dart
+12
-4
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+164
-1
No files found.
packages/flutter/lib/src/material/pickers/calendar_date_picker.dart
View file @
cc36608f
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/pickers/date_picker_dialog.dart
View file @
cc36608f
...
...
@@ -6,7 +6,7 @@
import
'dart:math'
as
math
;
import
'package:flutter/
foundation
.dart'
;
import
'package:flutter/
services
.dart'
;
import
'package:flutter/widgets.dart'
;
import
'../button_bar.dart'
;
...
...
@@ -357,6 +357,11 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
return
null
;
}
static
final
Map
<
LogicalKeySet
,
Intent
>
_formShortcutMap
=
<
LogicalKeySet
,
Intent
>{
// Pressing enter on the field will move focus to the next field or control.
LogicalKeySet
(
LogicalKeyboardKey
.
enter
):
const
NextFocusIntent
(),
};
@override
Widget
build
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
...
...
@@ -419,24 +424,27 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24
),
height:
orientation
==
Orientation
.
portrait
?
_inputFormPortraitHeight
:
_inputFormLandscapeHeight
,
child:
Column
(
children:
<
Widget
>[
const
Spacer
(),
InputDatePickerFormField
(
initialDate:
_selectedDate
,
firstDate:
widget
.
firstDate
,
lastDate:
widget
.
lastDate
,
onDateSubmitted:
_handleDateChanged
,
onDateSaved:
_handleDateChanged
,
selectableDayPredicate:
widget
.
selectableDayPredicate
,
errorFormatText:
widget
.
errorFormatText
,
errorInvalidText:
widget
.
errorInvalidText
,
fieldHintText:
widget
.
fieldHintText
,
fieldLabelText:
widget
.
fieldLabelText
,
autofocus:
true
,
),
const
Spacer
(),
],
child:
Shortcuts
(
shortcuts:
_formShortcutMap
,
child:
Column
(
children:
<
Widget
>[
const
Spacer
(),
InputDatePickerFormField
(
initialDate:
_selectedDate
,
firstDate:
widget
.
firstDate
,
lastDate:
widget
.
lastDate
,
onDateSubmitted:
_handleDateChanged
,
onDateSaved:
_handleDateChanged
,
selectableDayPredicate:
widget
.
selectableDayPredicate
,
errorFormatText:
widget
.
errorFormatText
,
errorInvalidText:
widget
.
errorInvalidText
,
fieldHintText:
widget
.
fieldHintText
,
fieldLabelText:
widget
.
fieldLabelText
,
autofocus:
true
,
),
const
Spacer
(),
],
),
),
),
);
...
...
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/material/pickers/date_utils.dart
View file @
cc36608f
...
...
@@ -26,12 +26,20 @@ DateTimeRange datesOnly(DateTimeRange range) {
}
/// Returns true if the two [DateTime] objects have the same day, month, and
/// year.
/// year
, or are both null
.
bool
isSameDay
(
DateTime
dateA
,
DateTime
dateB
)
{
return
dateA
.
year
==
dateB
.
year
&&
dateA
.
month
==
dateB
.
month
&&
dateA
.
day
==
dateB
.
day
;
dateA
?.
year
==
dateB
?.
year
&&
dateA
?.
month
==
dateB
?.
month
&&
dateA
?.
day
==
dateB
?.
day
;
}
/// Returns true if the two [DateTime] objects have the same month, and
/// year, or are both null.
bool
isSameMonth
(
DateTime
dateA
,
DateTime
dateB
)
{
return
dateA
?.
year
==
dateB
?.
year
&&
dateA
?.
month
==
dateB
?.
month
;
}
/// Determines the number of months between two [DateTime] objects.
...
...
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/date_picker_test.dart
View file @
cc36608f
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment