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
e3169568
Commit
e3169568
authored
Oct 12, 2017
by
gspencergoog
Committed by
GitHub
Oct 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tooltips scale with textScaleFactor (#12498)
Fixes #12480
parent
ba0618d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
16 deletions
+62
-16
tooltip.dart
packages/flutter/lib/src/material/tooltip.dart
+14
-11
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+48
-5
No files found.
packages/flutter/lib/src/material/tooltip.dart
View file @
e3169568
...
...
@@ -255,7 +255,7 @@ class _TooltipOverlay extends StatelessWidget {
this
.
animation
,
this
.
target
,
this
.
verticalOffset
,
this
.
preferBelow
this
.
preferBelow
,
})
:
super
(
key:
key
);
final
String
message
;
...
...
@@ -286,16 +286,19 @@ class _TooltipOverlay extends StatelessWidget {
opacity:
animation
,
child:
new
Opacity
(
opacity:
0.9
,
child:
new
Container
(
decoration:
new
BoxDecoration
(
color:
darkTheme
.
backgroundColor
,
borderRadius:
new
BorderRadius
.
circular
(
2.0
),
),
height:
height
,
padding:
padding
,
child:
new
Center
(
widthFactor:
1.0
,
child:
new
Text
(
message
,
style:
darkTheme
.
textTheme
.
body1
),
child:
new
ConstrainedBox
(
constraints:
new
BoxConstraints
(
minHeight:
height
),
child:
new
Container
(
decoration:
new
BoxDecoration
(
color:
darkTheme
.
backgroundColor
,
borderRadius:
new
BorderRadius
.
circular
(
2.0
),
),
padding:
padding
,
child:
new
Center
(
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
new
Text
(
message
,
style:
darkTheme
.
textTheme
.
body1
),
),
),
),
),
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
e3169568
...
...
@@ -133,7 +133,7 @@ void main() {
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
.
parent
.
parent
.
parent
.
parent
;
expect
(
tip
.
size
.
height
,
equals
(
2
0.0
));
// 10
.0 height + 5.0 padding * 2 (top, bottom)
expect
(
tip
.
size
.
height
,
equals
(
2
4.0
));
// 14
.0 height + 5.0 padding * 2 (top, bottom)
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)),
equals
(
const
Offset
(
10.0
,
20.0
)));
});
...
...
@@ -358,10 +358,10 @@ void main() {
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
;
expect
(
tip
.
size
.
height
,
equals
(
1
0
.0
));
expect
(
tip
.
size
.
height
,
equals
(
1
4
.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
310.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dx
,
equals
(
790.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
32
0
.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
32
4
.0
));
});
testWidgets
(
'Does tooltip end up in the right place - near the edge'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -413,10 +413,10 @@ void main() {
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
;
expect
(
tip
.
size
.
height
,
equals
(
1
0
.0
));
expect
(
tip
.
size
.
height
,
equals
(
1
4
.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
310.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dx
,
equals
(
790.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
32
0
.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
32
4
.0
));
});
testWidgets
(
'Tooltip stays around'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -526,6 +526,49 @@ void main() {
expect
(
find
.
text
(
tooltipText
),
findsNothing
);
});
testWidgets
(
'Tooltip text scales with textScaleFactor'
,
(
WidgetTester
tester
)
async
{
Widget
buildApp
(
String
text
,
{
double
textScaleFactor
})
{
return
new
MediaQuery
(
data:
new
MediaQueryData
(
textScaleFactor:
textScaleFactor
),
child:
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Navigator
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
new
MaterialPageRoute
<
dynamic
>(
builder:
(
BuildContext
context
)
{
return
new
Center
(
child:
new
Tooltip
(
message:
text
,
child:
new
Container
(
width:
100.0
,
height:
100.0
,
color:
Colors
.
green
[
500
],
),
),
);
}
);
},
),
),
);
}
await
tester
.
pumpWidget
(
buildApp
(
tooltipText
,
textScaleFactor:
1.0
));
await
tester
.
longPress
(
find
.
byType
(
Tooltip
));
expect
(
find
.
text
(
tooltipText
),
findsOneWidget
);
expect
(
tester
.
getSize
(
find
.
text
(
tooltipText
)),
equals
(
const
Size
(
42.0
,
14.0
)));
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
;
expect
(
tip
.
size
.
height
,
equals
(
32.0
));
await
tester
.
pumpWidget
(
buildApp
(
tooltipText
,
textScaleFactor:
4.0
));
await
tester
.
longPress
(
find
.
byType
(
Tooltip
));
expect
(
find
.
text
(
tooltipText
),
findsOneWidget
);
expect
(
tester
.
getSize
(
find
.
text
(
tooltipText
)),
equals
(
const
Size
(
168.0
,
56.0
)));
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
;
expect
(
tip
.
size
.
height
,
equals
(
56.0
));
});
testWidgets
(
'Haptic feedback'
,
(
WidgetTester
tester
)
async
{
final
FeedbackTester
feedback
=
new
FeedbackTester
();
await
tester
.
pumpWidget
(
...
...
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