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
0d91c034
Unverified
Commit
0d91c034
authored
Jan 12, 2023
by
Taha Tesser
Committed by
GitHub
Jan 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix M3 `Drawer` default shape in RTL (#118185)
parent
51c2af56
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
194 additions
and
18 deletions
+194
-18
drawer_template.dart
dev/tools/gen_defaults/lib/drawer_template.dart
+14
-9
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+14
-9
drawer_test.dart
packages/flutter/test/material/drawer_test.dart
+166
-0
No files found.
dev/tools/gen_defaults/lib/drawer_template.dart
View file @
0d91c034
...
...
@@ -10,10 +10,11 @@ class DrawerTemplate extends TokenTemplate {
@override
String
generate
()
=>
'''
class _
${blockName}
DefaultsM3 extends DrawerThemeData {
const
_
${blockName}
DefaultsM3(this.context)
_
${blockName}
DefaultsM3(this.context)
: super(elevation:
${elevation("md.comp.navigation-drawer.modal.container")}
);
final BuildContext context;
late final TextDirection direction = Directionality.of(context);
@override
Color? get backgroundColor =>
${componentColor("md.comp.navigation-drawer.container")}
;
...
...
@@ -24,18 +25,22 @@ class _${blockName}DefaultsM3 extends DrawerThemeData {
@override
Color? get shadowColor =>
${colorOrTransparent("md.comp.navigation-drawer.container.shadow-color")}
;
// Th
is don'
t
appear
to
be
tokens
for
this
value
,
but
it
is
// s
hown in the spec
.
// Th
ere isn'
t
currently
a
token
for
this
value
,
but
it
is
shown
in
the
spec
,
// s
o hard coding here for now
.
@override
ShapeBorder
?
get
shape
=>
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
horizontal
(
right:
Radius
.
circular
(
16.0
)),
ShapeBorder
?
get
shape
=>
RoundedRectangleBorder
(
borderRadius:
const
BorderRadiusDirectional
.
horizontal
(
end:
Radius
.
circular
(
16.0
),
).
resolve
(
direction
),
);
// Th
is don't appear to be tokens for this value, but it is
// s
hown in the spec
.
// Th
ere isn't currently a token for this value, but it is shown in the spec,
// s
o hard coding here for now
.
@override
ShapeBorder
?
get
endShape
=>
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
horizontal
(
left:
Radius
.
circular
(
16.0
)),
ShapeBorder
?
get
endShape
=>
RoundedRectangleBorder
(
borderRadius:
const
BorderRadiusDirectional
.
horizontal
(
start:
Radius
.
circular
(
16.0
),
).
resolve
(
direction
),
);
}
''';
...
...
packages/flutter/lib/src/material/drawer.dart
View file @
0d91c034
...
...
@@ -830,10 +830,11 @@ class _DrawerDefaultsM2 extends DrawerThemeData {
// Token database version: v0_150
class
_DrawerDefaultsM3
extends
DrawerThemeData
{
const
_DrawerDefaultsM3
(
this
.
context
)
_DrawerDefaultsM3
(
this
.
context
)
:
super
(
elevation:
1.0
);
final
BuildContext
context
;
late
final
TextDirection
direction
=
Directionality
.
of
(
context
);
@override
Color
?
get
backgroundColor
=>
Theme
.
of
(
context
).
colorScheme
.
surface
;
...
...
@@ -844,18 +845,22 @@ class _DrawerDefaultsM3 extends DrawerThemeData {
@override
Color
?
get
shadowColor
=>
Colors
.
transparent
;
// Th
is don't appear to be tokens for this value, but it is
// s
hown in the spec
.
// Th
ere isn't currently a token for this value, but it is shown in the spec,
// s
o hard coding here for now
.
@override
ShapeBorder
?
get
shape
=>
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
horizontal
(
right:
Radius
.
circular
(
16.0
)),
ShapeBorder
?
get
shape
=>
RoundedRectangleBorder
(
borderRadius:
const
BorderRadiusDirectional
.
horizontal
(
end:
Radius
.
circular
(
16.0
),
).
resolve
(
direction
),
);
// Th
is don't appear to be tokens for this value, but it is
// s
hown in the spec
.
// Th
ere isn't currently a token for this value, but it is shown in the spec,
// s
o hard coding here for now
.
@override
ShapeBorder
?
get
endShape
=>
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
horizontal
(
left:
Radius
.
circular
(
16.0
)),
ShapeBorder
?
get
endShape
=>
RoundedRectangleBorder
(
borderRadius:
const
BorderRadiusDirectional
.
horizontal
(
start:
Radius
.
circular
(
16.0
),
).
resolve
(
direction
),
);
}
...
...
packages/flutter/test/material/drawer_test.dart
View file @
0d91c034
...
...
@@ -567,4 +567,170 @@ void main() {
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
Drawer
));
expect
(
box
.
size
.
width
,
equals
(
smallWidth
));
});
testWidgets
(
'Drawer default shape (ltr)'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Scaffold
(
drawer:
Drawer
(),
endDrawer:
Drawer
(),
),
),
),
);
final
Finder
drawerMaterial
=
find
.
descendant
(
of:
find
.
byType
(
Drawer
),
matching:
find
.
byType
(
Material
),
);
final
ScaffoldState
state
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
// Open the drawer.
state
.
openDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the drawer shape.
Material
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
16.0
),
bottomRight:
Radius
.
circular
(
16.0
),
),
),
);
// Close the opened drawer.
await
tester
.
tapAt
(
const
Offset
(
750
,
300
));
await
tester
.
pumpAndSettle
();
// Open the end drawer.
state
.
openEndDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the end drawer shape.
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
16.0
),
bottomLeft:
Radius
.
circular
(
16.0
),
),
),
);
});
testWidgets
(
'Drawer default shape (rtl)'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
const
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
Scaffold
(
drawer:
Drawer
(),
endDrawer:
Drawer
(),
),
),
),
);
final
Finder
drawerMaterial
=
find
.
descendant
(
of:
find
.
byType
(
Drawer
),
matching:
find
.
byType
(
Material
),
);
final
ScaffoldState
state
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
// Open the drawer.
state
.
openDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the drawer shape.
Material
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
16.0
),
bottomLeft:
Radius
.
circular
(
16.0
),
),
),
);
// Close the opened drawer.
await
tester
.
tapAt
(
const
Offset
(
750
,
300
));
await
tester
.
pumpAndSettle
();
// Open the end drawer.
state
.
openEndDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the end drawer shape.
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
16.0
),
bottomRight:
Radius
.
circular
(
16.0
),
),
),
);
});
group
(
'Material 2'
,
()
{
// Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
// is turned on by default, these tests can be removed.
testWidgets
(
'Drawer default shape'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
false
),
home:
const
Scaffold
(
drawer:
Drawer
(),
endDrawer:
Drawer
(),
),
),
);
final
Finder
drawerMaterial
=
find
.
descendant
(
of:
find
.
byType
(
Drawer
),
matching:
find
.
byType
(
Material
),
);
final
ScaffoldState
state
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
// Open the drawer.
state
.
openDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the drawer shape.
Material
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
null
);
// Close the opened drawer.
await
tester
.
tapAt
(
const
Offset
(
750
,
300
));
await
tester
.
pumpAndSettle
();
// Open the end drawer.
state
.
openEndDrawer
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Test the end drawer shape.
material
=
tester
.
widget
<
Material
>(
drawerMaterial
);
expect
(
material
.
shape
,
null
);
});
});
}
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