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
ac905b29
Unverified
Commit
ac905b29
authored
Aug 24, 2022
by
Pierre-Louis
Committed by
GitHub
Aug 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to specify class name (#109865)
parent
360ac5bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
update_icons.dart
dev/tools/update_icons.dart
+20
-7
No files found.
dev/tools/update_icons.dart
View file @
ac905b29
...
...
@@ -18,6 +18,7 @@ const String _iconsTemplatePathOption = 'icons-template';
const
String
_newCodepointsPathOption
=
'new-codepoints'
;
const
String
_oldCodepointsPathOption
=
'old-codepoints'
;
const
String
_fontFamilyOption
=
'font-family'
;
const
String
_classNameOption
=
'class-name'
;
const
String
_enforceSafetyChecks
=
'enforce-safety-checks'
;
const
String
_dryRunOption
=
'dry-run'
;
...
...
@@ -25,6 +26,7 @@ const String _defaultIconsPath = 'packages/flutter/lib/src/material/icons.dart';
const
String
_defaultNewCodepointsPath
=
'codepoints'
;
const
String
_defaultOldCodepointsPath
=
'bin/cache/artifacts/material_fonts/codepoints'
;
const
String
_defaultFontFamily
=
'MaterialIcons'
;
const
String
_defaultClassName
=
'Icons'
;
const
String
_defaultDemoFilePath
=
'/tmp/new_icons_demo.dart'
;
const
String
_beginGeneratedMark
=
'// BEGIN GENERATED ICONS'
;
...
...
@@ -211,6 +213,7 @@ void main(List<String> args) {
iconsTemplateContents
,
newTokenPairMap
,
argResults
[
_fontFamilyOption
]
as
String
,
argResults
[
_classNameOption
]
as
String
,
argResults
[
_enforceSafetyChecks
]
as
bool
,
);
...
...
@@ -245,6 +248,9 @@ ArgResults _handleArguments(List<String> args) {
..
addOption
(
_fontFamilyOption
,
defaultsTo:
_defaultFontFamily
,
help:
'The font family to use for the IconData constants'
)
..
addOption
(
_classNameOption
,
defaultsTo:
_defaultClassName
,
help:
'The containing class for all icons'
)
..
addFlag
(
_enforceSafetyChecks
,
defaultsTo:
true
,
help:
'Whether to exit if safety checks fail (e.g. codepoints are missing or unstable'
)
...
...
@@ -280,10 +286,12 @@ String _regenerateIconsFile(
String
templateFileContents
,
Map
<
String
,
String
>
tokenPairMap
,
String
fontFamily
,
String
className
,
bool
enforceSafetyChecks
,
)
{
final
List
<
Icon
>
newIcons
=
tokenPairMap
.
entries
.
map
((
MapEntry
<
String
,
String
>
entry
)
=>
Icon
(
entry
,
fontFamily:
fontFamily
))
.
map
((
MapEntry
<
String
,
String
>
entry
)
=>
Icon
(
entry
,
fontFamily:
fontFamily
,
className:
className
))
.
toList
();
newIcons
.
sort
((
Icon
a
,
Icon
b
)
=>
a
.
_compareTo
(
b
));
...
...
@@ -309,7 +317,8 @@ String _regenerateIconsFile(
final
Icon
iOSIcon
=
newIcons
.
firstWhere
(
(
Icon
icon
)
=>
icon
.
id
==
'
${ids[1]}$style
'
,
orElse:
()
=>
throw
ids
[
1
]);
platformAdaptiveDeclarations
.
add
(
Icon
.
platformAdaptiveDeclaration
(
'
$flutterId$style
'
,
agnosticIcon
,
iOSIcon
),
platformAdaptiveDeclarations
.
add
(
agnosticIcon
.
platformAdaptiveDeclaration
(
'
$flutterId$style
'
,
iOSIcon
),
);
}
catch
(
e
)
{
if
(
style
==
''
)
{
...
...
@@ -433,7 +442,10 @@ void _generateIconDemo(File demoFilePath, Map<String, String> tokenPairMap) {
class
Icon
{
// Parse tokenPair (e.g. {"6_ft_apart_outlined": "e004"}).
Icon
(
MapEntry
<
String
,
String
>
tokenPair
,
{
this
.
fontFamily
=
_defaultFontFamily
})
{
Icon
(
MapEntry
<
String
,
String
>
tokenPair
,
{
this
.
fontFamily
=
_defaultFontFamily
,
this
.
className
=
_defaultClassName
,
})
{
id
=
tokenPair
.
key
;
hexCodepoint
=
tokenPair
.
value
;
...
...
@@ -485,6 +497,7 @@ class Icon {
late
String
hexCodepoint
;
// e.g. e547
late
String
htmlSuffix
=
''
;
// The suffix for the 'material-icons' HTML class.
String
fontFamily
;
// The IconData font family.
String
className
;
// The containing class.
String
get
name
=>
shortId
.
replaceAll
(
'_'
,
' '
).
trim
();
...
...
@@ -493,7 +506,7 @@ class Icon {
String
get
dartDoc
=>
'<i class="material-icons
$htmlSuffix
md-36">
$shortId
</i> —
$family
icon named "
$name
"
$style
'
;
String
get
usage
=>
'Icon(
Icons
.
$flutterId
),'
;
String
get
usage
=>
'Icon(
$className
.
$flutterId
),'
;
String
get
mirroredInRTL
=>
_iconsMirroredWhenRTL
.
contains
(
shortId
)
?
', matchTextDirection: true'
...
...
@@ -508,10 +521,10 @@ class Icon {
$declaration
'''
;
static
String
platformAdaptiveDeclaration
(
String
fullFlutterId
,
Icon
agnosticIcon
,
Icon
iOSIcon
)
=>
'''
String
platformAdaptiveDeclaration
(
String
fullFlutterId
,
Icon
iOSIcon
)
=>
'''
/// Platform-adaptive icon for
$
{agnosticIcon.dartDoc}
and
${iOSIcon.dartDoc}
.;
IconData get
$fullFlutterId
=> !_isCupertino() ?
Icons.
${agnosticIcon.flutterId}
: Icons
.
${iOSIcon.flutterId}
;
/// Platform-adaptive icon for
$
dartDoc
and
${iOSIcon.dartDoc}
.;
IconData get
$fullFlutterId
=> !_isCupertino() ?
$className
.
$flutterId
:
$className
.
${iOSIcon.flutterId}
;
'''
;
@override
...
...
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