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
2781a086
Commit
2781a086
authored
Apr 26, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tooltips show up in the wrong place (#3574)
We had a math-o. Fixes #3563
parent
adac9275
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+1
-1
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+54
-1
No files found.
packages/flutter/lib/src/material/tooltip.dart
View file @
2781a086
...
...
@@ -246,7 +246,7 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
}
else
if
(
normalizedTargetX
>
size
.
width
-
screenEdgeMargin
.
right
-
childSize
.
width
/
2.0
)
{
x
=
size
.
width
-
screenEdgeMargin
.
right
-
childSize
.
width
;
}
else
{
x
=
normalizedTargetX
+
childSize
.
width
/
2.0
;
x
=
normalizedTargetX
-
childSize
.
width
/
2.0
;
}
return
new
Offset
(
x
,
y
);
}
...
...
packages/flutter/test/
widget
/tooltip_test.dart
→
packages/flutter/test/
material
/tooltip_test.dart
View file @
2781a086
...
...
@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
import
'package:flutter_test/flutter_test.dart'
;
import
'package:test/test.dart'
;
import
'test_semantics.dart'
;
import
'
../widget/
test_semantics.dart'
;
// This file uses "as dynamic" in a few places to defeat the static
// analysis. In general you want to avoid using this style in your
...
...
@@ -26,6 +26,59 @@ import 'test_semantics.dart';
// production code.
void
main
(
)
{
test
(
'Does tooltip end up in the right place - center'
,
()
{
testElementTree
((
ElementTreeTester
tester
)
{
GlobalKey
key
=
new
GlobalKey
();
tester
.
pumpWidget
(
new
Overlay
(
initialEntries:
<
OverlayEntry
>[
new
OverlayEntry
(
builder:
(
BuildContext
context
)
{
return
new
Stack
(
children:
<
Widget
>[
new
Positioned
(
left:
300.0
,
top:
0.0
,
child:
new
Tooltip
(
key:
key
,
message:
'TIP'
,
height:
20.0
,
padding:
const
EdgeInsets
.
all
(
5.0
),
verticalOffset:
20.0
,
screenEdgeMargin:
const
EdgeInsets
.
all
(
10.0
),
preferBelow:
false
,
fadeDuration:
const
Duration
(
seconds:
1
),
showDuration:
const
Duration
(
seconds:
2
),
child:
new
Container
(
width:
0.0
,
height:
0.0
)
)
),
]
);
}
),
]
)
);
(
key
.
currentState
as
dynamic
).
showTooltip
();
// before using "as dynamic" in your code, see note top of file
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
/********************* 800x600 screen
* o * y=0
* | * }- 20.0 vertical offset, of which 10.0 is in the screen edge margin
* +----+ * \- (5.0 padding in height)
* | | * |- 20 height
* +----+ * /- (5.0 padding in height)
* *
*********************/
RenderBox
tip
=
tester
.
findText
(
'TIP'
).
renderObject
.
parent
.
parent
.
parent
.
parent
.
parent
;
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Point
.
origin
)),
equals
(
const
Point
(
284.0
,
20.0
)));
});
});
test
(
'Does tooltip end up in the right place - top left'
,
()
{
testElementTree
((
ElementTreeTester
tester
)
{
GlobalKey
key
=
new
GlobalKey
();
...
...
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