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
18ccfe63
Unverified
Commit
18ccfe63
authored
Jul 01, 2021
by
Rémi Doreau
Committed by
GitHub
Jul 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feat(cupertino): [date_picker] Date order parameter (#84599)
parent
21a95f6b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
3 deletions
+50
-3
date_picker.dart
packages/flutter/lib/src/cupertino/date_picker.dart
+21
-3
date_picker_test.dart
packages/flutter/test/cupertino/date_picker_test.dart
+29
-0
No files found.
packages/flutter/lib/src/cupertino/date_picker.dart
View file @
18ccfe63
...
...
@@ -188,7 +188,7 @@ enum _PickerColumnType {
/// There are several modes of the date picker listed in [CupertinoDatePickerMode].
///
/// The class will display its children as consecutive columns. Its children
/// order is based on internationalization.
/// order is based on internationalization
, or the [dateOrder] property if specified
.
///
/// Example of the picker in date mode:
///
...
...
@@ -245,6 +245,9 @@ class CupertinoDatePicker extends StatefulWidget {
/// positive integer factor of 60.
///
/// [use24hFormat] decides whether 24 hour format is used. Defaults to false.
///
/// [dateOrder] determines the order of the columns inside [CupertinoDatePicker] in date mode.
/// Defaults to the locale's default date format/order.
CupertinoDatePicker
({
Key
?
key
,
this
.
mode
=
CupertinoDatePickerMode
.
dateAndTime
,
...
...
@@ -256,6 +259,7 @@ class CupertinoDatePicker extends StatefulWidget {
this
.
maximumYear
,
this
.
minuteInterval
=
1
,
this
.
use24hFormat
=
false
,
this
.
dateOrder
,
this
.
backgroundColor
,
})
:
initialDateTime
=
initialDateTime
??
DateTime
.
now
(),
assert
(
mode
!=
null
),
...
...
@@ -355,6 +359,10 @@ class CupertinoDatePicker extends StatefulWidget {
/// Whether to use 24 hour format. Defaults to false.
final
bool
use24hFormat
;
/// Determines the order of the columns inside [CupertinoDatePicker] in date mode.
/// Defaults to the locale's default date format/order.
final
DatePickerDateOrder
?
dateOrder
;
/// Callback called when the selected date and/or time changes. If the new
/// selected [DateTime] is not valid, or is not in the [minimumDate] through
/// [maximumDate] range, this callback will not be called.
...
...
@@ -378,7 +386,7 @@ class CupertinoDatePicker extends StatefulWidget {
case
CupertinoDatePickerMode
.
dateAndTime
:
return
_CupertinoDatePickerDateTimeState
();
case
CupertinoDatePickerMode
.
date
:
return
_CupertinoDatePickerDateState
();
return
_CupertinoDatePickerDateState
(
dateOrder:
dateOrder
);
}
}
...
...
@@ -1049,6 +1057,13 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
}
class
_CupertinoDatePickerDateState
extends
State
<
CupertinoDatePicker
>
{
_CupertinoDatePickerDateState
({
required
this
.
dateOrder
,
});
final
DatePickerDateOrder
?
dateOrder
;
late
int
textDirectionFactor
;
late
CupertinoLocalizations
localizations
;
...
...
@@ -1331,7 +1346,10 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
List
<
_ColumnBuilder
>
pickerBuilders
=
<
_ColumnBuilder
>[];
List
<
double
>
columnWidths
=
<
double
>[];
switch
(
localizations
.
datePickerDateOrder
)
{
final
DatePickerDateOrder
datePickerDateOrder
=
dateOrder
??
localizations
.
datePickerDateOrder
;
switch
(
datePickerDateOrder
)
{
case
DatePickerDateOrder
.
mdy
:
pickerBuilders
=
<
_ColumnBuilder
>[
_buildMonthPicker
,
_buildDayPicker
,
_buildYearPicker
];
columnWidths
=
<
double
>[
...
...
packages/flutter/test/cupertino/date_picker_test.dart
View file @
18ccfe63
...
...
@@ -1221,6 +1221,35 @@ void main() {
);
});
testWidgets
(
'DatePicker displays the date in correct order'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
SizedBox
(
height:
400.0
,
width:
400.0
,
child:
CupertinoDatePicker
(
dateOrder:
DatePickerDateOrder
.
ydm
,
mode:
CupertinoDatePickerMode
.
date
,
onDateTimeChanged:
(
DateTime
newDate
)
{},
initialDateTime:
DateTime
(
2018
,
1
,
14
,
10
,
30
),
),
),
),
),
);
expect
(
tester
.
getTopLeft
(
find
.
text
(
'2018'
)).
dx
,
lessThan
(
tester
.
getTopLeft
(
find
.
text
(
'14'
)).
dx
),
);
expect
(
tester
.
getTopLeft
(
find
.
text
(
'14'
)).
dx
,
lessThan
(
tester
.
getTopLeft
(
find
.
text
(
'January'
)).
dx
),
);
});
testWidgets
(
'DatePicker displays hours and minutes correctly in RTL'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
...
...
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