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
01b53bd0
Unverified
Commit
01b53bd0
authored
Feb 22, 2018
by
amirh
Committed by
GitHub
Feb 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix overlap check in bottom app bar's custom clipper (#14813)
parent
0b6c1938
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
1 deletion
+102
-1
bottom_app_bar.dart
packages/flutter/lib/src/material/bottom_app_bar.dart
+1
-1
bottom_app_bar_test.dart
packages/flutter/test/material/bottom_app_bar_test.dart
+101
-0
No files found.
packages/flutter/lib/src/material/bottom_app_bar.dart
View file @
01b53bd0
...
...
@@ -117,7 +117,7 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
final
Rect
button
=
geometry
.
value
.
floatingActionButtonArea
.
translate
(
0.0
,
geometry
.
value
.
bottomNavigationBarTop
*
-
1.0
);
if
(
appBar
.
overlaps
(
button
))
{
if
(
!
appBar
.
overlaps
(
button
))
{
return
new
Path
()..
addRect
(
appBar
);
}
...
...
packages/flutter/test/material/bottom_app_bar_test.dart
0 → 100644
View file @
01b53bd0
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
void
main
(
)
{
testWidgets
(
'no overlap with floating action button'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
const
Scaffold
(
floatingActionButton:
const
FloatingActionButton
(
onPressed:
null
,
),
bottomNavigationBar:
const
ShapeListener
(
const
BottomAppBar
()),
),
),
);
final
ShapeListenerState
shapeListenerState
=
tester
.
state
(
find
.
byType
(
ShapeListener
));
final
RenderBox
renderBox
=
tester
.
renderObject
(
find
.
byType
(
BottomAppBar
));
final
Path
expectedPath
=
new
Path
()
..
addRect
(
Offset
.
zero
&
renderBox
.
size
);
final
Path
actualPath
=
shapeListenerState
.
cache
.
value
;
expect
(
actualPath
,
coversSameAreaAs
(
expectedPath
,
areaToCompare:
(
Offset
.
zero
&
renderBox
.
size
).
inflate
(
5.0
),
)
);
});
}
// The bottom app bar clip path computation is only available at paint time.
// In order to examine the notch path we implement this caching painter which
// at paint time looks for for a descendant PhysicalShape and caches the
// clip path it is using.
class
ClipCachePainter
extends
CustomPainter
{
ClipCachePainter
(
this
.
context
);
Path
value
;
BuildContext
context
;
@override
void
paint
(
Canvas
canvas
,
Size
size
)
{
final
RenderPhysicalShape
physicalShape
=
findPhysicalShapeChild
(
context
);
value
=
physicalShape
.
clipper
.
getClip
(
size
);
}
RenderPhysicalShape
findPhysicalShapeChild
(
BuildContext
context
)
{
RenderPhysicalShape
result
;
context
.
visitChildElements
((
Element
e
)
{
final
RenderObject
renderObject
=
e
.
findRenderObject
();
if
(
renderObject
.
runtimeType
==
RenderPhysicalShape
)
{
assert
(
result
==
null
);
result
=
renderObject
;
}
else
{
result
=
findPhysicalShapeChild
(
e
);
}
});
return
result
;
}
@override
bool
shouldRepaint
(
ClipCachePainter
oldDelegate
)
{
return
true
;
}
}
class
ShapeListener
extends
StatefulWidget
{
const
ShapeListener
(
this
.
child
);
final
Widget
child
;
@override
State
createState
()
=>
new
ShapeListenerState
();
}
class
ShapeListenerState
extends
State
<
ShapeListener
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
new
CustomPaint
(
child:
widget
.
child
,
painter:
cache
);
}
ClipCachePainter
cache
;
@override
void
didChangeDependencies
()
{
super
.
didChangeDependencies
();
cache
=
new
ClipCachePainter
(
context
);
}
}
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