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
a88888e4
Unverified
Commit
a88888e4
authored
Jan 25, 2022
by
dani
Committed by
GitHub
Jan 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add direction to CupertinoPickerDefaultSelectionOverlay (#92959)
parent
0ef7e637
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
29 deletions
+53
-29
date_picker.dart
packages/flutter/lib/src/cupertino/date_picker.dart
+13
-13
picker.dart
packages/flutter/lib/src/cupertino/picker.dart
+16
-16
picker_test.dart
packages/flutter/test/cupertino/picker_test.dart
+24
-0
No files found.
packages/flutter/lib/src/cupertino/date_picker.dart
View file @
a88888e4
...
...
@@ -64,9 +64,9 @@ void _animateColumnControllerToItem(FixedExtentScrollController controller, int
);
}
const
Widget
_
leftSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
capRight
Edge:
false
);
const
Widget
_centerSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
cap
LeftEdge:
false
,
capRight
Edge:
false
);
const
Widget
_
rightSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
capLef
tEdge:
false
);
const
Widget
_
startSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
capEnd
Edge:
false
);
const
Widget
_centerSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
cap
StartEdge:
false
,
capEnd
Edge:
false
);
const
Widget
_
endSelectionOverlay
=
CupertinoPickerDefaultSelectionOverlay
(
capStar
tEdge:
false
);
// Lays out the date picker based on how much space each single column needs.
//
...
...
@@ -1013,14 +1013,14 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
Widget
selectionOverlay
=
_centerSelectionOverlay
;
if
(
i
==
0
)
{
offAxisFraction
=
-
_kMaximumOffAxisFraction
*
textDirectionFactor
;
selectionOverlay
=
_
lef
tSelectionOverlay
;
selectionOverlay
=
_
star
tSelectionOverlay
;
}
else
if
(
i
>=
2
||
columnWidths
.
length
==
2
)
offAxisFraction
=
_kMaximumOffAxisFraction
*
textDirectionFactor
;
EdgeInsets
padding
=
const
EdgeInsets
.
only
(
right:
_kDatePickerPadSize
);
if
(
i
==
columnWidths
.
length
-
1
)
{
padding
=
padding
.
flipped
;
selectionOverlay
=
_
right
SelectionOverlay
;
selectionOverlay
=
_
end
SelectionOverlay
;
}
if
(
textDirectionFactor
==
-
1
)
padding
=
padding
.
flipped
;
...
...
@@ -1404,9 +1404,9 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
Widget
selectionOverlay
=
_centerSelectionOverlay
;
if
(
i
==
0
)
selectionOverlay
=
_
lef
tSelectionOverlay
;
selectionOverlay
=
_
star
tSelectionOverlay
;
else
if
(
i
==
columnWidths
.
length
-
1
)
selectionOverlay
=
_
right
SelectionOverlay
;
selectionOverlay
=
_
end
SelectionOverlay
;
pickers
.
add
(
LayoutId
(
id:
i
,
...
...
@@ -2035,14 +2035,14 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
start:
hourColumnStartPadding
,
end:
pickerColumnWidth
-
hourColumnStartPadding
-
hourLabelContentWidth
,
),
_
lef
tSelectionOverlay
,
_
star
tSelectionOverlay
,
),
_buildMinuteColumn
(
EdgeInsetsDirectional
.
only
(
start:
pickerColumnWidth
-
minuteColumnEndPadding
-
minuteLabelContentWidth
,
end:
minuteColumnEndPadding
,
),
_
right
SelectionOverlay
,
_
end
SelectionOverlay
,
),
];
break
;
...
...
@@ -2064,14 +2064,14 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
start:
minuteColumnStartPadding
,
end:
pickerColumnWidth
-
minuteColumnStartPadding
-
minuteLabelContentWidth
,
),
_
lef
tSelectionOverlay
,
_
star
tSelectionOverlay
,
),
_buildSecondColumn
(
EdgeInsetsDirectional
.
only
(
start:
pickerColumnWidth
-
secondColumnEndPadding
-
minuteLabelContentWidth
,
end:
secondColumnEndPadding
,
),
_
right
SelectionOverlay
,
_
end
SelectionOverlay
,
),
];
break
;
...
...
@@ -2089,7 +2089,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
start:
_kTimerPickerMinHorizontalPadding
,
end:
math
.
max
(
hourColumnEndPadding
,
0
),
),
_
lef
tSelectionOverlay
,
_
star
tSelectionOverlay
,
),
_buildMinuteColumn
(
EdgeInsetsDirectional
.
only
(
...
...
@@ -2103,7 +2103,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
start:
math
.
max
(
secondColumnStartPadding
,
0
),
end:
_kTimerPickerMinHorizontalPadding
,
),
_
right
SelectionOverlay
,
_
end
SelectionOverlay
,
),
];
break
;
...
...
packages/flutter/lib/src/cupertino/picker.dart
View file @
a88888e4
...
...
@@ -324,7 +324,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
/// rectangle that spans the entire multi-column picker.
/// To achieve the same effect using [CupertinoPickerDefaultSelectionOverlay],
/// the additional margin and corner radii on the left or the right side can be
/// disabled by turning off [cap
LeftEdge] and [capRight
Edge], so this selection
/// disabled by turning off [cap
StartEdge] and [capEnd
Edge], so this selection
/// overlay visually connects with selection overlays of adjoining
/// [CupertinoPicker]s (i.e., other "column"s).
///
...
...
@@ -340,25 +340,25 @@ class CupertinoPickerDefaultSelectionOverlay extends StatelessWidget {
/// The [background] argument default value is [CupertinoColors.tertiarySystemFill].
/// It must be non-null.
///
/// The [cap
LeftEdge] and [capRight
Edge] arguments decide whether to add a
/// The [cap
StartEdge] and [capEnd
Edge] arguments decide whether to add a
/// default margin and use rounded corners on the left and right side of the
/// rectangular overlay.
/// Default to true and must not be null.
const
CupertinoPickerDefaultSelectionOverlay
({
Key
?
key
,
this
.
background
=
CupertinoColors
.
tertiarySystemFill
,
this
.
cap
Lef
tEdge
=
true
,
this
.
cap
Right
Edge
=
true
,
this
.
cap
Star
tEdge
=
true
,
this
.
cap
End
Edge
=
true
,
})
:
assert
(
background
!=
null
),
assert
(
cap
Lef
tEdge
!=
null
),
assert
(
cap
Right
Edge
!=
null
),
assert
(
cap
Star
tEdge
!=
null
),
assert
(
cap
End
Edge
!=
null
),
super
(
key:
key
);
/// Whether to use the default use rounded corners and margin on the
lef
t side.
final
bool
cap
Lef
tEdge
;
/// Whether to use the default use rounded corners and margin on the
star
t side.
final
bool
cap
Star
tEdge
;
/// Whether to use the default use rounded corners and margin on the
right
side.
final
bool
cap
Right
Edge
;
/// Whether to use the default use rounded corners and margin on the
end
side.
final
bool
cap
End
Edge
;
/// The color to fill in the background of the [CupertinoPickerDefaultSelectionOverlay].
/// It Support for use [CupertinoDynamicColor].
...
...
@@ -379,14 +379,14 @@ class CupertinoPickerDefaultSelectionOverlay extends StatelessWidget {
const
Radius
radius
=
Radius
.
circular
(
_defaultSelectionOverlayRadius
);
return
Container
(
margin:
EdgeInsets
.
only
(
left:
capLef
tEdge
?
_defaultSelectionOverlayHorizontalMargin
:
0
,
right:
capRight
Edge
?
_defaultSelectionOverlayHorizontalMargin
:
0
,
margin:
EdgeInsets
Directional
.
only
(
start:
capStar
tEdge
?
_defaultSelectionOverlayHorizontalMargin
:
0
,
end:
capEnd
Edge
?
_defaultSelectionOverlayHorizontalMargin
:
0
,
),
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
horizontal
(
left:
capLef
tEdge
?
radius
:
Radius
.
zero
,
right:
capRight
Edge
?
radius
:
Radius
.
zero
,
borderRadius:
BorderRadius
Directional
.
horizontal
(
start:
capStar
tEdge
?
radius
:
Radius
.
zero
,
end:
capEnd
Edge
?
radius
:
Radius
.
zero
,
),
color:
CupertinoDynamicColor
.
resolve
(
background
,
context
),
),
...
...
packages/flutter/test/cupertino/picker_test.dart
View file @
a88888e4
...
...
@@ -422,4 +422,28 @@ void main() {
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
});
group
(
'CupertinoPickerDefaultSelectionOverlay'
,
()
{
testWidgets
(
'should be using directional decoration'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
theme:
const
CupertinoThemeData
(
brightness:
Brightness
.
light
),
home:
CupertinoPicker
(
itemExtent:
15.0
,
onSelectedItemChanged:
(
int
i
)
{},
selectionOverlay:
const
CupertinoPickerDefaultSelectionOverlay
(
background:
Color
(
0x12345678
)),
children:
const
<
Widget
>[
Text
(
'1'
),
Text
(
'1'
)],
),
),
);
final
Finder
selectionContainer
=
find
.
byType
(
Container
);
final
Container
container
=
tester
.
firstWidget
<
Container
>(
selectionContainer
);
final
EdgeInsetsGeometry
?
margin
=
container
.
margin
;
final
BorderRadiusGeometry
?
borderRadius
=
(
container
.
decoration
as
BoxDecoration
?)?.
borderRadius
;
expect
(
margin
,
isA
<
EdgeInsetsDirectional
>());
expect
(
borderRadius
,
isA
<
BorderRadiusDirectional
>());
});
});
}
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