Style fixes

This commit is contained in:
crschnick 2024-04-23 09:27:30 +00:00
parent a02d40cab6
commit 125d1ddbaf
3 changed files with 12 additions and 18 deletions

View file

@ -2,7 +2,6 @@ package io.xpipe.app.fxcomps.impl;
import atlantafx.base.layout.InputGroup; import atlantafx.base.layout.InputGroup;
import io.xpipe.app.comp.base.ButtonComp; import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppFont;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure; import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.fxcomps.util.PlatformThread;
@ -18,6 +17,8 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import org.kordamp.ikonli.javafx.FontIcon; import org.kordamp.ikonli.javafx.FontIcon;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
public class SecretFieldComp extends Comp<SecretFieldComp.Structure> { public class SecretFieldComp extends Comp<SecretFieldComp.Structure> {
@ -37,12 +38,17 @@ public class SecretFieldComp extends Comp<SecretFieldComp.Structure> {
private final Property<InPlaceSecretValue> value; private final Property<InPlaceSecretValue> value;
private final boolean allowCopy; private final boolean allowCopy;
private final List<Comp<?>> additionalButtons = new ArrayList<>();
public SecretFieldComp(Property<InPlaceSecretValue> value, boolean allowCopy) { public SecretFieldComp(Property<InPlaceSecretValue> value, boolean allowCopy) {
this.value = value; this.value = value;
this.allowCopy = allowCopy; this.allowCopy = allowCopy;
} }
public void addButton(Comp<?> button) {
this.additionalButtons.add(button);
}
public static SecretFieldComp ofString(Property<String> s) { public static SecretFieldComp ofString(Property<String> s) {
var prop = new SimpleObjectProperty<>(s.getValue() != null ? InPlaceSecretValue.of(s.getValue()) : null); var prop = new SimpleObjectProperty<>(s.getValue() != null ? InPlaceSecretValue.of(s.getValue()) : null);
prop.addListener((observable, oldValue, newValue) -> { prop.addListener((observable, oldValue, newValue) -> {
@ -61,7 +67,6 @@ public class SecretFieldComp extends Comp<SecretFieldComp.Structure> {
@Override @Override
public Structure createBase() { public Structure createBase() {
var text = new PasswordField(); var text = new PasswordField();
text.getStyleClass().add("secret-field-comp");
text.setText(value.getValue() != null ? value.getValue().getSecretValue() : null); text.setText(value.getValue() != null ? value.getValue().getSecretValue() : null);
text.textProperty().addListener((c, o, n) -> { text.textProperty().addListener((c, o, n) -> {
value.setValue(n != null && n.length() > 0 ? encrypt(n.toCharArray()) : null); value.setValue(n != null && n.length() > 0 ? encrypt(n.toCharArray()) : null);
@ -84,10 +89,11 @@ public class SecretFieldComp extends Comp<SecretFieldComp.Structure> {
}).grow(false, true).tooltipKey("copyPassword").createRegion(); }).grow(false, true).tooltipKey("copyPassword").createRegion();
var ig = new InputGroup(text); var ig = new InputGroup(text);
AppFont.small(ig); ig.getStyleClass().add("secret-field-comp");
if (allowCopy) { if (allowCopy) {
ig.getChildren().add(copyButton); ig.getChildren().add(copyButton);
} }
additionalButtons.forEach(comp -> ig.getChildren().add(comp.createRegion()));
ig.focusedProperty().addListener((c, o, n) -> { ig.focusedProperty().addListener((c, o, n) -> {
if (n) { if (n) {

View file

@ -18,23 +18,12 @@
-fx-border-color: derive(-color-border-default, -10%); -fx-border-color: derive(-color-border-default, -10%);
} }
.root:dark .color-box.gray {
.root:pretty:dark .color-box.gray {
-fx-background-color: linear-gradient(from 100% 0% to 0% 100%, derive(-color-bg-default, 13%) 40%, derive(-color-bg-default, 11%) 50%, derive(-color-bg-default, 14%) 100%);
-fx-border-color: -color-border-default;
}
.root:performance:dark .color-box.gray {
-fx-background-color: derive(-color-bg-default, 13%); -fx-background-color: derive(-color-bg-default, 13%);
-fx-border-color: -color-border-default; -fx-border-color: -color-border-default;
} }
.root:pretty:light .color-box.gray { .root:light .color-box.gray {
-fx-background-color: linear-gradient(from 100% 0% to 0% 100%, derive(-color-bg-default, -2%) 40%, derive(-color-bg-default, 0%) 50%, derive(-color-bg-default, -3%) 100%);
-fx-border-color: derive(-color-border-default, -10%);
}
.root:performance:light .color-box.gray {
-fx-background-color: derive(-color-bg-default, -2%); -fx-background-color: derive(-color-bg-default, -2%);
-fx-border-color: derive(-color-border-default, -10%); -fx-border-color: derive(-color-border-default, -10%);
} }

View file

@ -3,7 +3,7 @@
} }
.root:dark.background { .root:dark.background {
-fx-background-color: derive(-color-bg-default, 5%); -fx-background-color: derive(-color-bg-default, 1%);
} }
.root:light.background { .root:light.background {
@ -59,4 +59,3 @@
.root:dark .loading-comp { .root:dark .loading-comp {
-fx-background-color: rgba(0, 0, 0, 0.5); -fx-background-color: rgba(0, 0, 0, 0.5);
} }