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
3cd6f40a
Unverified
Commit
3cd6f40a
authored
Sep 04, 2018
by
Jonah Williams
Committed by
GitHub
Sep 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wire bold text flag to text widget (#21325)
parent
d04a057e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
2 deletions
+64
-2
media_query.dart
packages/flutter/lib/src/widgets/media_query.dart
+26
-1
text.dart
packages/flutter/lib/src/widgets/text.dart
+3
-1
media_query_test.dart
packages/flutter/test/widgets/media_query_test.dart
+35
-0
No files found.
packages/flutter/lib/src/widgets/media_query.dart
View file @
3cd6f40a
...
...
@@ -46,6 +46,7 @@ class MediaQueryData {
this
.
accessibleNavigation
=
false
,
this
.
invertColors
=
false
,
this
.
disableAnimations
=
false
,
this
.
boldText
=
false
,
});
/// Creates data for a media query based on the given window.
...
...
@@ -63,6 +64,7 @@ class MediaQueryData {
accessibleNavigation
=
window
.
accessibilityFeatures
.
accessibleNavigation
,
invertColors
=
window
.
accessibilityFeatures
.
accessibleNavigation
,
disableAnimations
=
window
.
accessibilityFeatures
.
disableAnimations
,
boldText
=
window
.
accessibilityFeatures
.
boldText
,
alwaysUse24HourFormat
=
window
.
alwaysUse24HourFormat
;
/// The size of the media in logical pixel (e.g, the size of the screen).
...
...
@@ -149,10 +151,20 @@ class MediaQueryData {
/// Whether the platform is requesting that animations be disabled or reduced
/// as much as possible.
///
/// See also:
///
/// * [Window.AccessibilityFeatures], where the setting originates.
///
final
bool
disableAnimations
;
/// Whether the platform is requesting that text be drawn with a bold font
/// weight.
///
/// See also:
///
/// * [Window.AccessibilityFeatures], where the setting originates.
final
bool
boldText
;
/// The orientation of the media (e.g., whether the device is in landscape or portrait mode).
Orientation
get
orientation
{
return
size
.
width
>
size
.
height
?
Orientation
.
landscape
:
Orientation
.
portrait
;
...
...
@@ -170,6 +182,7 @@ class MediaQueryData {
bool
disableAnimations
,
bool
invertColors
,
bool
accessibleNavigation
,
bool
boldText
,
})
{
return
new
MediaQueryData
(
size:
size
??
this
.
size
,
...
...
@@ -181,6 +194,7 @@ class MediaQueryData {
invertColors:
invertColors
??
this
.
invertColors
,
disableAnimations:
disableAnimations
??
this
.
disableAnimations
,
accessibleNavigation:
accessibleNavigation
??
this
.
accessibleNavigation
,
boldText:
boldText
??
this
.
boldText
,
);
}
...
...
@@ -221,6 +235,7 @@ class MediaQueryData {
disableAnimations:
disableAnimations
,
invertColors:
invertColors
,
accessibleNavigation:
accessibleNavigation
,
boldText:
boldText
,
);
}
...
...
@@ -259,6 +274,7 @@ class MediaQueryData {
disableAnimations:
disableAnimations
,
invertColors:
invertColors
,
accessibleNavigation:
accessibleNavigation
,
boldText:
boldText
,
);
}
...
...
@@ -275,7 +291,8 @@ class MediaQueryData {
&&
typedOther
.
alwaysUse24HourFormat
==
alwaysUse24HourFormat
&&
typedOther
.
disableAnimations
==
disableAnimations
&&
typedOther
.
invertColors
==
invertColors
&&
typedOther
.
accessibleNavigation
==
accessibleNavigation
;
&&
typedOther
.
accessibleNavigation
==
accessibleNavigation
&&
typedOther
.
boldText
==
boldText
;
}
@override
...
...
@@ -290,6 +307,7 @@ class MediaQueryData {
disableAnimations
,
invertColors
,
accessibleNavigation
,
boldText
,
);
}
...
...
@@ -305,6 +323,7 @@ class MediaQueryData {
'accessibleNavigation:
$accessibleNavigation
'
'disableAnimations:
$disableAnimations
'
'invertColors:
$invertColors
'
'boldText:
$boldText
'
')'
;
}
}
...
...
@@ -476,6 +495,12 @@ class MediaQuery extends InheritedWidget {
return
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
textScaleFactor
??
1.0
;
}
/// Returns the boldText accessibility setting for the nearest MediaQuery
/// ancestor, or false if no such ancestor exists.
static
bool
boldTextOverride
(
BuildContext
context
)
{
return
MediaQuery
.
of
(
context
,
nullOk:
true
)?.
boldText
??
false
;
}
@override
bool
updateShouldNotify
(
MediaQuery
oldWidget
)
=>
data
!=
oldWidget
.
data
;
...
...
packages/flutter/lib/src/widgets/text.dart
View file @
3cd6f40a
...
...
@@ -327,7 +327,7 @@ class Text extends StatelessWidget {
/// If present, the semantics of this widget will contain this value instead
/// of the actual text.
///
/// This is useful for replacing abbreviations or shorthands wi
ll
the full
/// This is useful for replacing abbreviations or shorthands wi
th
the full
/// text value:
///
/// ```dart
...
...
@@ -342,6 +342,8 @@ class Text extends StatelessWidget {
TextStyle
effectiveTextStyle
=
style
;
if
(
style
==
null
||
style
.
inherit
)
effectiveTextStyle
=
defaultTextStyle
.
style
.
merge
(
style
);
if
(
MediaQuery
.
boldTextOverride
(
context
))
effectiveTextStyle
=
effectiveTextStyle
.
merge
(
const
TextStyle
(
fontWeight:
FontWeight
.
bold
));
Widget
result
=
new
RichText
(
textAlign:
textAlign
??
defaultTextStyle
.
textAlign
??
TextAlign
.
start
,
textDirection:
textDirection
,
// RichText uses Directionality.of to obtain a default if this is null.
...
...
packages/flutter/test/widgets/media_query_test.dart
View file @
3cd6f40a
...
...
@@ -46,6 +46,7 @@ void main() {
expect
(
data
.
accessibleNavigation
,
false
);
expect
(
data
.
invertColors
,
false
);
expect
(
data
.
disableAnimations
,
false
);
expect
(
data
.
boldText
,
false
);
});
testWidgets
(
'MediaQueryData.copyWith defaults to source'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -60,6 +61,7 @@ void main() {
expect
(
copied
.
accessibleNavigation
,
data
.
accessibleNavigation
);
expect
(
copied
.
invertColors
,
data
.
invertColors
);
expect
(
copied
.
disableAnimations
,
data
.
disableAnimations
);
expect
(
copied
.
boldText
,
data
.
boldText
);
});
testWidgets
(
'MediaQuery.copyWith copies specified values'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -74,6 +76,7 @@ void main() {
accessibleNavigation:
true
,
invertColors:
true
,
disableAnimations:
true
,
boldText:
true
,
);
expect
(
copied
.
size
,
const
Size
(
3.14
,
2.72
));
expect
(
copied
.
devicePixelRatio
,
1.41
);
...
...
@@ -84,6 +87,7 @@ void main() {
expect
(
copied
.
accessibleNavigation
,
true
);
expect
(
copied
.
invertColors
,
true
);
expect
(
copied
.
disableAnimations
,
true
);
expect
(
copied
.
boldText
,
true
);
});
testWidgets
(
'MediaQuery.removePadding removes specified padding'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -106,6 +110,7 @@ void main() {
accessibleNavigation:
true
,
invertColors:
true
,
disableAnimations:
true
,
boldText:
true
,
),
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
...
...
@@ -136,6 +141,7 @@ void main() {
expect
(
unpadded
.
accessibleNavigation
,
true
);
expect
(
unpadded
.
invertColors
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
});
testWidgets
(
'MediaQuery.removeViewInsets removes specified viewInsets'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -158,6 +164,7 @@ void main() {
accessibleNavigation:
true
,
invertColors:
true
,
disableAnimations:
true
,
boldText:
true
,
),
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
...
...
@@ -188,6 +195,7 @@ void main() {
expect
(
unpadded
.
accessibleNavigation
,
true
);
expect
(
unpadded
.
invertColors
,
true
);
expect
(
unpadded
.
disableAnimations
,
true
);
expect
(
unpadded
.
boldText
,
true
);
});
testWidgets
(
'MediaQuery.textScaleFactorOf'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -216,4 +224,31 @@ void main() {
expect
(
outsideTextScaleFactor
,
1.0
);
expect
(
insideTextScaleFactor
,
4.0
);
});
testWidgets
(
'MediaQuery.boldTextOverride'
,
(
WidgetTester
tester
)
async
{
bool
outsideBoldTextOverride
;
bool
insideBoldTextOverride
;
await
tester
.
pumpWidget
(
new
Builder
(
builder:
(
BuildContext
context
)
{
outsideBoldTextOverride
=
MediaQuery
.
boldTextOverride
(
context
);
return
new
MediaQuery
(
data:
const
MediaQueryData
(
boldText:
true
,
),
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
insideBoldTextOverride
=
MediaQuery
.
boldTextOverride
(
context
);
return
new
Container
();
},
),
);
},
),
);
expect
(
outsideBoldTextOverride
,
false
);
expect
(
insideBoldTextOverride
,
true
);
});
}
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