Skip to content

fix(example): align generated icons source root - #42

Merged
kingsword09 merged 2 commits into
mainfrom
fix-1
Jun 4, 2026
Merged

kingsword09 merged 2 commits into
mainfrom
fix-1

Conversation

@kingsword09

Copy link
Copy Markdown
Owner
  • move generated icons out of src/commonMain/kotlin to avoid IDE package-path warnings
  • register src/commonMain/generated/symbols as a commonMain Kotlin source root
  • switch official Material Symbols example source to esm.sh
  • update generated icon references from Fill1 to Fill
  • streamline preview annotation normalization

  - move generated icons out of src/commonMain/kotlin to avoid IDE package-path warnings
  - register src/commonMain/generated/symbols as a commonMain Kotlin source root
  - switch official Material Symbols example source to esm.sh
  - update generated icon references from Fill1 to Fill
  - streamline preview annotation normalization
@dosubot

dosubot Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Documentation Updates

1 document(s) were updated by changes in this PR:

Multi-Library Icon Support
View Changes
@@ -23,9 +23,9 @@
 
     // 官方库多变体图标
     externalIcon("home", libraryName = "official") {
-        urlTemplate = "https://example.com/{name}_{fill}_24px.svg"
+        urlTemplate = "https://esm.sh/@material-symbols/svg-400@latest/rounded/{name}{fill}.svg"
         styleParam("fill") {
-            values("", "fill1") // 未填充、填充变体
+            values("", "-fill") // 未填充、填充变体
         }
     }
 }
@@ -45,9 +45,9 @@
 
     // 官方库批量多变体
     externalIcons("home", "search", "person", "settings", "arrow_back", libraryName = "official") {
-        urlTemplate = "https://rawcdn.githack.com/google/material-design-icons/master/symbols/web/{name}/materialsymbolsrounded/{name}{fill}_24px.svg?min=1"
+        urlTemplate = "https://esm.sh/@material-symbols/svg-400@latest/rounded/{name}{fill}.svg"
         styleParam("fill") {
-            values("", "fill1")
+            values("", "-fill")
         }
     }
 }
@@ -92,8 +92,8 @@
 
     // Google Material Symbols 多变体
     externalIcons("home", "search", "person", "settings", "arrow_back", libraryName = "official") {
-        urlTemplate = "https://rawcdn.githack.com/google/material-design-icons/master/symbols/web/{name}/materialsymbolsrounded/{name}{fill}_24px.svg?min=1"
-        styleParam("fill") { values("", "fill1") }
+        urlTemplate = "https://esm.sh/@material-symbols/svg-400@latest/rounded/{name}{fill}.svg"
+        styleParam("fill") { values("", "-fill") }
     }
 }
 ```

How did I do? Any feedback?  Join Discord

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the SymbolCraft output directory configuration, moving generated symbols from the Kotlin source directory to a dedicated generated source root, and updates the documentation and example app accordingly. It also updates the Material Symbols URL template and regenerates the official icons with correct dimensions. In Svg2ComposeConverter.kt, the preview annotation replacement logic was refactored; however, a review comment suggests optimizing this by performing a substring check before executing the regular expression replacement on every line.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

/** Adds an import after the existing import block, or immediately after the package line. */
private fun addImportIfMissing(content: String, qualifiedName: String): String {
if (content.lines().any { it == "import $qualifiedName" }) return content
normalizedLines.add(line.replace(PREVIEW_ANNOTATION_REGEX, "@$annotationName"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Running a regular expression replacement on every single line of the generated file can be highly inefficient, especially for large SVG/XML path files with hundreds of lines. Since most lines do not contain the @Preview annotation, we can significantly optimize this by performing a simple substring check (line.contains("@Preview")) before executing the regex replacement.

                val processedLine = if (line.contains("@Preview")) {
                    line.replace(PREVIEW_ANNOTATION_REGEX, "@$annotationName")
                } else {
                    line
                }
                normalizedLines.add(processedLine)

@kingsword09
kingsword09 merged commit a7e6b73 into main Jun 4, 2026
2 checks passed
@kingsword09
kingsword09 deleted the fix-1 branch June 4, 2026 03:20
@alexhelder

Copy link
Copy Markdown

"update generated icon references from Fill1 to Fill"

My icons are still named "Fill1" with 0.4.0.

@kingsword09

Copy link
Copy Markdown
Owner Author

"update generated icon references from Fill1 to Fill"

My icons are still named "Fill1" with 0.4.0.

Thanks for catching this,it will be fixed as a breaking change in 0.5.0 by generating ...Fill instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants