Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.SVGContainer;
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.util.*;
Expand Down Expand Up @@ -437,19 +438,34 @@ private static final class AddonItem extends StackPane {
content.setTitle(dataItem.name());
content.setSubtitle(I18n.formatDateTime(dataItem.datePublished()));

switch (dataItem.versionType()) {
case Alpha:
content.addTag(i18n("addon.channel.alpha"));
graphicPane.getChildren().setAll(SVG.ALPHA_CIRCLE.createIcon(24));
break;
case Beta:
content.addTag(i18n("addon.channel.beta"));
graphicPane.getChildren().setAll(SVG.BETA_CIRCLE.createIcon(24));
break;
case Release:
content.addTag(i18n("addon.channel.release"));
graphicPane.getChildren().setAll(SVG.RELEASE_CIRCLE.createIcon(24));
break;
SVG svg = null;
String styleClass = null;
Comment on lines +441 to +442

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Annotate the nullable icon-selection locals

These newly introduced locals are initialized to null and can remain null when versionType() is null, but neither declaration uses @Nullable. This makes nullability implicit in modified Java code; annotate both svg and styleClass with @Nullable.

AGENTS.md reference: AGENTS.md:L8-L9

Useful? React with 👍 / 👎.

if (dataItem.versionType() != null) {
switch (dataItem.versionType()) {
case Alpha:
content.addTag(i18n("addon.channel.alpha"));
svg = SVG.ALPHA_CIRCLE;
styleClass = "alpha";
break;
case Beta:
content.addTag(i18n("addon.channel.beta"));
svg = SVG.BETA_CIRCLE;
styleClass = "beta";
break;
case Release:
content.addTag(i18n("addon.channel.release"));
svg = SVG.RELEASE_CIRCLE;
styleClass = "release";
break;
default:
styleClass = "";
break;
}
}
Comment thread
KSSJW marked this conversation as resolved.
if (svg != null) {
SVGContainer icon = svg.createIcon(24);
icon.getStyleClass().addAll("addon-channel-icon", styleClass);
graphicPane.getChildren().setAll(icon);
}

for (ModLoaderType modLoaderType : dataItem.loaders()) {
Expand Down
12 changes: 12 additions & 0 deletions HMCL/src/main/resources/assets/css/brightness-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@
-fixed-log-fatal-background: #842029;
-fixed-log-selected: #3e3e3e;
}

.addon-channel-icon.alpha .svg {
-fx-fill: #ff496e;
}

.addon-channel-icon.beta .svg {
-fx-fill: #ffa347;
}

.addon-channel-icon.release .svg {
-fx-fill: #1bd96a;
}
12 changes: 12 additions & 0 deletions HMCL/src/main/resources/assets/css/brightness-light.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@
-fixed-log-fatal-background: #F7A699;
-fixed-log-selected: #f2f2f2;
}

.addon-channel-icon.alpha .svg {
-fx-fill: #cb2245;
}

.addon-channel-icon.beta .svg {
-fx-fill: #e08325;
}

.addon-channel-icon.release .svg {
-fx-fill: #00af5c;
}
Loading