hide paging if there is only one event

This commit is contained in:
Armin Schrenk
2025-12-12 11:21:39 +01:00
parent 5a0145800d
commit bebe3064ee
2 changed files with 27 additions and 13 deletions

View File

@@ -13,7 +13,6 @@ import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
@@ -31,6 +30,7 @@ public class NotificationController implements FxController {
private final IntegerProperty selectionIndex;
private final ObservableStringValue paging;
private final ObjectProperty<VaultEvent> selectedEvent;
private final ObservableValue<Boolean> singleEvent;
private final StringProperty vaultName;
private final StringProperty message;
private final StringProperty description;
@@ -43,6 +43,7 @@ public class NotificationController implements FxController {
this.events = new SimpleListProperty<>(notificationManager.getEventsRequiringNotification());
this.selectionIndex = new SimpleIntegerProperty(-1);
this.selectedEvent = new SimpleObjectProperty<>();
this.singleEvent = events.sizeProperty().map(size -> size.intValue() == 1);
this.paging = Bindings.createStringBinding(() -> selectionIndex.get() + 1 + "/" + events.size(), selectionIndex, events);
this.vaultName = new SimpleStringProperty();
this.message = new SimpleStringProperty();
@@ -104,7 +105,7 @@ public class NotificationController implements FxController {
if (events.isEmpty()) {
close(); //no more events
} else if (events.size() == i) {
selectionIndex.set(i-1); //triggers event update
selectionIndex.set(i - 1); //triggers event update
} else {
selectedEvent.set(events.get(i));
}
@@ -141,6 +142,7 @@ public class NotificationController implements FxController {
public String getVaultName() {
return vaultName.get();
}
public ObservableValue<String> messageProperty() {
return message;
}
@@ -173,4 +175,12 @@ public class NotificationController implements FxController {
return paging.get();
}
public ObservableValue<Boolean> singleEventProperty() {
return singleEvent;
}
public boolean isSingleEvent() {
return singleEvent.getValue();
}
}

View File

@@ -27,17 +27,19 @@
</ImageView>
<Label text="Cryptomator" styleClass="label-window-title"/>
<Region HBox.hgrow="ALWAYS"/>
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#previousNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_LEFT" glyphSize="12"/>
</graphic>
</Button>
<Label text="${controller.paging}" styleClass="label"/>
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#nextNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_RIGHT" glyphSize="12"/>
</graphic>
</Button>
<HBox styleClass="dialog-header" alignment="CENTER_LEFT" visible="${!controller.singleEvent}">
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#previousNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_LEFT" glyphSize="12"/>
</graphic>
</Button>
<Label text="${controller.paging}" styleClass="label-window-title"/>
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#nextNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_RIGHT" glyphSize="12"/>
</graphic>
</Button>
</HBox>
<Button contentDisplay="GRAPHIC_ONLY" onAction="#close" styleClass="close-button">
<graphic>
<FontAwesome5IconView glyph="TIMES" glyphSize="12"/>
@@ -55,7 +57,9 @@
</padding>
<Label text="${controller.message}" styleClass="label-large" wrapText="true"/>
<Label text="${controller.vaultName}" styleClass="label-small" wrapText="true"/>
<Region minHeight="6"/>
<Label text="${controller.description}" styleClass="label" wrapText="true"/>
<Region VBox.vgrow="ALWAYS"/>
<Button text="${controller.actionText}" onAction="#processSelectedEvent"
visible="${!controller.actionText.empty}" managed="${!controller.actionText.empty}"/>
</VBox>