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
913e21e4
Unverified
Commit
913e21e4
authored
Jun 12, 2020
by
Darren Austin
Committed by
GitHub
Jun 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First pass at keyboard navigation for the Material Date Picker (#59279)
parent
0093c6a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
61 deletions
+112
-61
date_picker_header.dart
.../flutter/lib/src/material/pickers/date_picker_header.dart
+53
-56
date_picker_test.dart
packages/flutter/test/material/date_picker_test.dart
+59
-5
No files found.
packages/flutter/lib/src/material/pickers/date_picker_header.dart
View file @
913e21e4
...
...
@@ -8,6 +8,7 @@ import 'package:flutter/widgets.dart';
import
'../color_scheme.dart'
;
import
'../icon_button.dart'
;
import
'../material.dart'
;
import
'../text_theme.dart'
;
import
'../theme.dart'
;
...
...
@@ -127,69 +128,65 @@ class DatePickerHeader extends StatelessWidget {
switch
(
orientation
)
{
case
Orientation
.
portrait
:
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Container
(
height:
_datePickerHeaderPortraitHeight
,
color:
primarySurfaceColor
,
padding:
const
EdgeInsetsDirectional
.
only
(
start:
24
,
end:
12
,
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
const
SizedBox
(
height:
16
),
Flexible
(
child:
help
),
const
SizedBox
(
height:
38
),
Row
(
children:
<
Widget
>[
Expanded
(
child:
title
),
icon
,
],
),
],
),
),
],
);
return
SizedBox
(
height:
_datePickerHeaderPortraitHeight
,
child:
Material
(
color:
primarySurfaceColor
,
child:
Padding
(
padding:
const
EdgeInsetsDirectional
.
only
(
start:
24
,
end:
12
,
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
const
SizedBox
(
height:
16
),
Flexible
(
child:
help
),
const
SizedBox
(
height:
38
),
Row
(
children:
<
Widget
>[
Expanded
(
child:
title
),
icon
,
],
),
],
),
),
),
);
case
Orientation
.
landscape
:
return
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Container
(
width:
_datePickerHeaderLandscapeWidth
,
color:
primarySurfaceColor
,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
const
SizedBox
(
height:
16
),
Padding
(
return
SizedBox
(
width:
_datePickerHeaderLandscapeWidth
,
child:
Material
(
color:
primarySurfaceColor
,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
const
SizedBox
(
height:
16
),
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
_headerPaddingLandscape
,
),
child:
help
,
),
SizedBox
(
height:
isShort
?
16
:
56
),
Expanded
(
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
_headerPaddingLandscape
,
),
child:
help
,
child:
title
,
),
SizedBox
(
height:
isShort
?
16
:
56
),
Expanded
(
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
_headerPaddingLandscape
,
),
child:
title
,
),
),
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
4
,
),
child:
icon
,
),
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
4
,
),
],
),
child:
icon
,
),
],
),
]
,
)
,
);
}
return
null
;
...
...
packages/flutter/test/material/date_picker_test.dart
View file @
913e21e4
...
...
@@ -803,8 +803,7 @@ void main() {
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
>
date
)
async
{
// Header
expect
(
tester
.
getSemantics
(
find
.
text
(
'SELECT DATE'
)),
matchesSemantics
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'SELECT DATE'
)),
matchesSemantics
(
label:
'SELECT DATE
\n
Fri, Jan 15'
,
));
...
...
@@ -819,8 +818,7 @@ void main() {
));
// Year mode drop down button
expect
(
tester
.
getSemantics
(
find
.
text
(
'January 2016'
)),
matchesSemantics
(
expect
(
tester
.
getSemantics
(
find
.
text
(
'January 2016'
)),
matchesSemantics
(
label:
'Select year'
,
isButton:
true
,
));
...
...
@@ -983,7 +981,6 @@ void main() {
hasEnabledState:
true
,
isFocusable:
true
,
));
});
semantics
.
dispose
();
...
...
@@ -1107,6 +1104,63 @@ void main() {
});
});
group
(
'Keyboard navigation'
,
()
{
testWidgets
(
'Can toggle to calendar entry mode'
,
(
WidgetTester
tester
)
async
{
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
>
date
)
async
{
expect
(
find
.
byType
(
TextField
),
findsNothing
);
// Navigate to the entry toggle button and activate it
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
// Should be in the input mode
expect
(
find
.
byType
(
TextField
),
findsOneWidget
);
});
});
testWidgets
(
'Can toggle to year mode'
,
(
WidgetTester
tester
)
async
{
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
>
date
)
async
{
expect
(
find
.
text
(
'2016'
),
findsNothing
);
// Navigate to the year selector and activate it
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
// The years should be visible
expect
(
find
.
text
(
'2016'
),
findsOneWidget
);
});
});
testWidgets
(
'Can navigate next/previous months'
,
(
WidgetTester
tester
)
async
{
await
prepareDatePicker
(
tester
,
(
Future
<
DateTime
>
date
)
async
{
expect
(
find
.
text
(
'January 2016'
),
findsOneWidget
);
// Navigate to the previous month button and activate it twice
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
// Should be showing Nov 2015
expect
(
find
.
text
(
'November 2015'
),
findsOneWidget
);
// Navigate to the next month button and activate it four times
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
tab
);
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
space
);
await
tester
.
pumpAndSettle
();
// Should be on Mar 2016
expect
(
find
.
text
(
'March 2016'
),
findsOneWidget
);
});
});
});
group
(
'Screen configurations'
,
()
{
// Test various combinations of screen sizes, orientations and text scales
// to ensure the layout doesn't overflow and cause an exception to be thrown.
...
...
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