Unverified Commit 948ff0f2 authored by Pierre-Louis's avatar Pierre-Louis Committed by GitHub

[Fonts] Sort material icons (#76691)

* Update update_icons.dart

* Merge and simplify identifier rewrites

* Update update_icons.dart

* Update update_icons.dart

* Update update_icons.dart

* Add newline

* remove whitespace

* Copy instead of moving

* Fix typo

* Clean up code

Introduce fullFlutterId and fix a small dartdoc bug

* Update update_icons.dart

* Implement sorting

* Remove trailing spaces

* Revert "Remove trailing spaces"

This reverts commit c198a160678f636add30966a016383657ea76972.

* Revert "Implement sorting"

This reverts commit 0fac8c1f1c8ba1ce867f5d5205e3d6f751c08a89.

* Revert "Revert "Implement sorting""

This reverts commit 0f8ec2381ac87b44f43554d267783a5cc2375172.

* Revert "Revert "Remove trailing spaces""

This reverts commit c3ef8658799e4f7aab851ff830d62ca2bb9aba94.

* xx

* add braces
parent 698d4389
...@@ -244,7 +244,9 @@ Map<String, String> stringToTokenPairMap(String codepointData) { ...@@ -244,7 +244,9 @@ Map<String, String> stringToTokenPairMap(String codepointData) {
} }
String regenerateIconsFile(String iconData, Map<String, String> tokenPairMap) { String regenerateIconsFile(String iconData, Map<String, String> tokenPairMap) {
final Iterable<_Icon> newIcons = tokenPairMap.entries.map((MapEntry<String, String> entry) => _Icon(entry)); final List<_Icon> newIcons = tokenPairMap.entries.map((MapEntry<String, String> entry) => _Icon(entry)).toList();
newIcons.sort((_Icon a, _Icon b) => a._compareTo(b));
final StringBuffer buf = StringBuffer(); final StringBuffer buf = StringBuffer();
bool generating = false; bool generating = false;
...@@ -388,6 +390,16 @@ class _Icon { ...@@ -388,6 +390,16 @@ class _Icon {
@override @override
String toString() => id; String toString() => id;
/// Analogous to [String.compareTo]
int _compareTo(_Icon b) {
// Sort a regular icon before its variants.
if (shortId == b.shortId) {
return id.length - b.id.length;
} else {
return flutterId.compareTo(b.flutterId);
}
}
String _replaceLast(String string, String toReplace) { String _replaceLast(String string, String toReplace) {
return string.replaceAll(RegExp('$toReplace\$'), ''); return string.replaceAll(RegExp('$toReplace\$'), '');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment