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
b5e1ebd7
Unverified
Commit
b5e1ebd7
authored
Dec 01, 2021
by
Taha Tesser
Committed by
GitHub
Dec 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add `splashRadius` property to `IconTheme` (#93478)" (#94482)
parent
bb3b45a7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
64 deletions
+15
-64
icon_theme_data.dart
packages/flutter/lib/src/cupertino/icon_theme_data.dart
+1
-1
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+6
-8
icon_theme_data.dart
packages/flutter/lib/src/widgets/icon_theme_data.dart
+5
-14
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+0
-34
icon_theme_data_test.dart
packages/flutter/test/widgets/icon_theme_data_test.dart
+3
-7
No files found.
packages/flutter/lib/src/cupertino/icon_theme_data.dart
View file @
b5e1ebd7
...
...
@@ -29,7 +29,7 @@ class CupertinoIconThemeData extends IconThemeData with Diagnosticable {
/// Creates a copy of this icon theme but with the given fields replaced with
/// the new values.
@override
CupertinoIconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
,
double
?
splashRadius
})
{
CupertinoIconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
})
{
return
CupertinoIconThemeData
(
color:
color
??
this
.
color
,
opacity:
opacity
??
this
.
opacity
,
...
...
packages/flutter/lib/src/material/icon_button.dart
View file @
b5e1ebd7
...
...
@@ -306,7 +306,6 @@ class IconButton extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
IconThemeData
iconTheme
=
IconTheme
.
of
(
context
);
Color
?
currentColor
;
if
(
onPressed
!=
null
)
currentColor
=
color
;
...
...
@@ -320,7 +319,7 @@ class IconButton extends StatelessWidget {
minHeight:
_kMinButtonSize
,
);
final
BoxConstraints
adjustedConstraints
=
effectiveVisualDensity
.
effectiveConstraints
(
unadjustedConstraints
);
final
double
effectiveIconSize
=
iconSize
??
iconTheme
.
size
??
24.0
;
final
double
effectiveIconSize
=
iconSize
??
IconTheme
.
of
(
context
)
.
size
??
24.0
;
Widget
result
=
ConstrainedBox
(
constraints:
adjustedConstraints
,
...
...
@@ -364,12 +363,11 @@ class IconButton extends StatelessWidget {
hoverColor:
hoverColor
??
theme
.
hoverColor
,
highlightColor:
highlightColor
??
theme
.
highlightColor
,
splashColor:
splashColor
??
theme
.
splashColor
,
radius:
splashRadius
??
iconTheme
.
splashRadius
??
math
.
max
(
Material
.
defaultSplashRadius
,
(
effectiveIconSize
+
math
.
min
(
padding
.
horizontal
,
padding
.
vertical
))
*
0.7
,
// x 0.5 for diameter -> radius and + 40% overflow derived from other Material apps.
),
radius:
splashRadius
??
math
.
max
(
Material
.
defaultSplashRadius
,
(
effectiveIconSize
+
math
.
min
(
padding
.
horizontal
,
padding
.
vertical
))
*
0.7
,
// x 0.5 for diameter -> radius and + 40% overflow derived from other Material apps.
),
child:
result
,
),
);
...
...
packages/flutter/lib/src/widgets/icon_theme_data.dart
View file @
b5e1ebd7
...
...
@@ -23,7 +23,7 @@ class IconThemeData with Diagnosticable {
///
/// The opacity applies to both explicit and default icon colors. The value
/// is clamped between 0.0 and 1.0.
const
IconThemeData
({
this
.
color
,
double
?
opacity
,
this
.
size
,
this
.
splashRadius
})
:
_opacity
=
opacity
;
const
IconThemeData
({
this
.
color
,
double
?
opacity
,
this
.
size
})
:
_opacity
=
opacity
;
/// Creates an icon theme with some reasonable default values.
///
...
...
@@ -31,17 +31,15 @@ class IconThemeData with Diagnosticable {
const
IconThemeData
.
fallback
()
:
color
=
const
Color
(
0xFF000000
),
_opacity
=
1.0
,
size
=
24.0
,
splashRadius
=
null
;
size
=
24.0
;
/// Creates a copy of this icon theme but with the given fields replaced with
/// the new values.
IconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
,
double
?
splashRadius
})
{
IconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
})
{
return
IconThemeData
(
color:
color
??
this
.
color
,
opacity:
opacity
??
this
.
opacity
,
size:
size
??
this
.
size
,
splashRadius:
splashRadius
??
this
.
splashRadius
,
);
}
...
...
@@ -55,7 +53,6 @@ class IconThemeData with Diagnosticable {
color:
other
.
color
,
opacity:
other
.
opacity
,
size:
other
.
size
,
splashRadius:
other
.
splashRadius
,
);
}
...
...
@@ -90,9 +87,6 @@ class IconThemeData with Diagnosticable {
/// The default size for icons.
final
double
?
size
;
/// The default splash radius for [IconButton]s.
final
double
?
splashRadius
;
/// Linearly interpolate between two icon theme data objects.
///
/// {@macro dart.ui.shadow.lerp}
...
...
@@ -102,7 +96,6 @@ class IconThemeData with Diagnosticable {
color:
Color
.
lerp
(
a
?.
color
,
b
?.
color
,
t
),
opacity:
ui
.
lerpDouble
(
a
?.
opacity
,
b
?.
opacity
,
t
),
size:
ui
.
lerpDouble
(
a
?.
size
,
b
?.
size
,
t
),
splashRadius:
ui
.
lerpDouble
(
a
?.
splashRadius
,
b
?.
splashRadius
,
t
),
);
}
...
...
@@ -113,12 +106,11 @@ class IconThemeData with Diagnosticable {
return
other
is
IconThemeData
&&
other
.
color
==
color
&&
other
.
opacity
==
opacity
&&
other
.
size
==
size
&&
other
.
splashRadius
==
splashRadius
;
&&
other
.
size
==
size
;
}
@override
int
get
hashCode
=>
hashValues
(
color
,
opacity
,
size
,
splashRadius
);
int
get
hashCode
=>
hashValues
(
color
,
opacity
,
size
);
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
@@ -126,6 +118,5 @@ class IconThemeData with Diagnosticable {
properties
.
add
(
ColorProperty
(
'color'
,
color
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'opacity'
,
opacity
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'size'
,
size
,
defaultValue:
null
));
properties
.
add
(
DoubleProperty
(
'splashRadius'
,
splashRadius
,
defaultValue:
null
));
}
}
packages/flutter/test/material/icon_button_test.dart
View file @
b5e1ebd7
...
...
@@ -480,40 +480,6 @@ void main() {
await
gesture
.
up
();
});
testWidgets
(
'IconButton can inherit splashRadius from IconTheme'
,
(
WidgetTester
tester
)
async
{
const
double
splashRadius
=
30.0
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
IconTheme
(
data:
const
IconThemeData
(
splashRadius:
splashRadius
,
),
child:
IconButton
(
icon:
const
Icon
(
Icons
.
android
),
onPressed:
()
{
/* enable the button */
},
),
),
),
),
),
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
IconButton
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
center
);
await
tester
.
pump
();
// Start gesture.
await
tester
.
pump
(
const
Duration
(
milliseconds:
1000
));
// Wait for splash to be well under way.
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
IconButton
))),
paints
..
circle
(
radius:
splashRadius
),
);
await
gesture
.
up
();
});
testWidgets
(
'IconButton Semantics (enabled)'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
...
...
packages/flutter/test/widgets/icon_theme_data_test.dart
View file @
b5e1ebd7
...
...
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
test
(
'IconThemeData control test'
,
()
{
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xAAAAAAAA
),
opacity:
0.5
,
size:
16.0
,
splashRadius:
30.0
);
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xAAAAAAAA
),
opacity:
0.5
,
size:
16.0
);
expect
(
data
,
hasOneLineDescription
);
expect
(
data
,
equals
(
data
.
copyWith
()));
...
...
@@ -17,27 +17,24 @@ void main() {
expect
(
lerped
.
color
,
const
Color
(
0xBF7F7F7F
));
expect
(
lerped
.
opacity
,
0.625
);
expect
(
lerped
.
size
,
18.0
);
expect
(
lerped
.
splashRadius
,
22.5
);
});
test
(
'IconThemeData lerp with first null'
,
()
{
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xFFFFFFFF
),
opacity:
1.0
,
size:
16.0
,
splashRadius:
30.0
);
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xFFFFFFFF
),
opacity:
1.0
,
size:
16.0
);
final
IconThemeData
lerped
=
IconThemeData
.
lerp
(
null
,
data
,
0.25
);
expect
(
lerped
.
color
,
const
Color
(
0x40FFFFFF
));
expect
(
lerped
.
opacity
,
0.25
);
expect
(
lerped
.
size
,
4.0
);
expect
(
lerped
.
splashRadius
,
7.5
);
});
test
(
'IconThemeData lerp with second null'
,
()
{
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xFFFFFFFF
),
opacity:
1.0
,
size:
16.0
,
splashRadius:
30.0
);
const
IconThemeData
data
=
IconThemeData
(
color:
Color
(
0xFFFFFFFF
),
opacity:
1.0
,
size:
16.0
);
final
IconThemeData
lerped
=
IconThemeData
.
lerp
(
data
,
null
,
0.25
);
expect
(
lerped
.
color
,
const
Color
(
0xBFFFFFFF
));
expect
(
lerped
.
opacity
,
0.75
);
expect
(
lerped
.
size
,
12.0
);
expect
(
lerped
.
splashRadius
,
22.5
);
});
test
(
'IconThemeData lerp with both null'
,
()
{
...
...
@@ -45,6 +42,5 @@ void main() {
expect
(
lerped
.
color
,
null
);
expect
(
lerped
.
opacity
,
null
);
expect
(
lerped
.
size
,
null
);
expect
(
lerped
.
splashRadius
,
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