implement more ui logic

and reduce css

Signed-off-by: Armin Schrenk <armin.schrenk@skymatic.de>
This commit is contained in:
Armin Schrenk
2025-12-04 17:03:36 +01:00
parent 285ddac219
commit 185c5a4f5d
3 changed files with 53 additions and 81 deletions

View File

@@ -1,11 +1,12 @@
package org.cryptomator.ui.notification;
import org.cryptomator.cryptofs.event.BrokenDirFileEvent;
import org.cryptomator.cryptofs.event.FilesystemEvent;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.fxapp.FxNotificationRadar;
import javax.inject.Inject;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.Bindings;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
@@ -15,6 +16,7 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableBooleanValue;
import javafx.beans.value.ObservableIntegerValue;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.stage.Stage;
@@ -30,6 +32,7 @@ public class NotificationController implements FxController {
private final Stage window;
private final SimpleListProperty<FilesystemEvent> notificationsProp;
private final IntegerProperty selectionIndex;
private final ObservableStringValue paging;
private final ObjectProperty<FilesystemEvent> selectedEvent;
private final StringProperty message;
private final StringProperty description;
@@ -42,8 +45,9 @@ public class NotificationController implements FxController {
this.notificationsProp = new SimpleListProperty<>(notificationRadar.getEventsRequiringNotification());
this.selectionIndex = new SimpleIntegerProperty(0);
this.selectedEvent = new SimpleObjectProperty<>();
selectionIndex.addListener((obs, o, n) -> selectedEvent.setValue(notificationsProp.get(n.intValue())));
selectionIndex.addListener((_, _, n) -> selectedEvent.setValue(notificationsProp.get(n.intValue())));
selectedEvent.addListener(this::adjustTexts);
this.paging = Bindings.createStringBinding(() -> selectionIndex.get() + 1 + "/" + notificationsProp.size(), selectionIndex, notificationsProp);
this.message = new SimpleStringProperty();
this.description = new SimpleStringProperty();
this.actionText = new SimpleStringProperty();
@@ -87,6 +91,20 @@ public class NotificationController implements FxController {
}
}
@FXML void previousNotification() {
int i = selectionIndex.get();
if( i != 0) {
selectionIndex.set(i-1);
}
}
@FXML void nextNotification() {
int i = selectionIndex.get();
if(i != notificationsProp.size() - 1){
selectionIndex.set(i+1);
}
}
@FXML
public void close() {
notificationsProp.clear();
@@ -127,20 +145,12 @@ public class NotificationController implements FxController {
return actionText.get() != null;
}
public ObservableIntegerValue selectionIndexProperty() {
return selectionIndex;
public ObservableStringValue pagingProperty() {
return paging;
}
public int getSelectionIndex() {
return selectionIndex.get();
}
public ObservableIntegerValue numberOfNotificationsProperty() {
return notificationsProp.sizeProperty();
}
public int getNumberOfNotifications() {
return notificationsProp.size();
public String getPaging() {
return paging.get();
}
}

View File

@@ -1187,16 +1187,17 @@
-fx-font-size: 1.166667em; /* 14pt - 2 more than the default font */
}
/**
Notification Window
**/
/*******************************************************************************
* *
* Notification Window
* *
******************************************************************************/
.notification-window {
-fx-background-color: MAIN_BG;
-fx-background-radius: 22;
-fx-border-radius: 22;
-fx-background-radius: 8px;
-fx-border-radius: 8px;
-fx-background-insets: 0;
-fx-background-color: rgba(255, 255, 255, 0.92);
-fx-border-color: rgba(0, 0, 0, 0.1);
-fx-border-color: MUTED_BG;
-fx-border-width: 1px;
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.2), 28, 0.35, 0, 6);
}
@@ -1205,11 +1206,6 @@
-fx-alignment: center-left;
}
.notification-window .brand-title {
-fx-font-family: 'Open Sans SemiBold';
-fx-font-size: 18px;
}
.notification-window .close-button {
-fx-background-color: transparent;
-fx-border-color: transparent;
@@ -1225,30 +1221,6 @@
-fx-background-color: CONTROL_BG_ARMED;
}
.notification-window .notification-title {
-fx-font-family: 'Open Sans Bold';
-fx-font-size: 28px;
-fx-text-fill: TEXT_FILL;
}
.notification-window .notification-description {
-fx-font-size: 20px;
-fx-text-fill: TEXT_FILL;
-fx-line-spacing: 6px;
}
.notification-window .action-button {
-fx-background-color: CONTROL_BG_NORMAL;
-fx-border-color: CONTROL_BORDER_NORMAL;
-fx-border-width: 2px;
-fx-background-radius: 12;
-fx-border-radius: 12;
-fx-font-family: 'Open Sans SemiBold';
-fx-font-size: 22px;
-fx-text-fill: TEXT_FILL;
-fx-padding: 10 28 12 28;
}
.notification-window .action-button:hover {
-fx-background-color: CONTROL_BG_HOVER;
-fx-border-color: CONTROL_BORDER_FOCUSED;
@@ -1271,9 +1243,4 @@
.notification-window .nav-button:pressed {
-fx-background-color: CONTROL_BG_ARMED;
}
.notification-window .page-indicator {
-fx-font-size: 14px;
-fx-text-fill: TEXT_FILL;
}
}

View File

@@ -6,29 +6,28 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import org.cryptomator.ui.controls.FormattedLabel?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.notification.NotificationController"
prefHeight="360.0" prefWidth="1100.0" maxHeight="600.0" maxWidth="1200.0"
prefHeight="200.0" prefWidth="300.0" maxHeight="300.0" maxWidth="400.0"
styleClass="notification-window">
<padding>
<Insets top="18" right="24" bottom="22" left="24"/>
</padding>
<top>
<HBox spacing="12" styleClass="dialog-header" alignment="CENTER_LEFT">
<ImageView fitHeight="28" preserveRatio="true" cache="true">
<ImageView fitHeight="16" preserveRatio="true" cache="true">
<Image url="@../img/logo64.png"/>
</ImageView>
<Label text="cryptomator" styleClass="brand-title"/>
<Label text="${controller.message}" styleClass="label-large"/>
<Region HBox.hgrow="ALWAYS"/>
<Button contentDisplay="GRAPHIC_ONLY" onAction="#close" styleClass="close-button">
<graphic>
<FontAwesome5IconView glyph="TIMES" glyphSize="18"/>
<FontAwesome5IconView glyph="TIMES" glyphSize="12"/>
</graphic>
</Button>
</HBox>
@@ -36,31 +35,27 @@
<center>
<VBox spacing="10">
<Label text="${controller.message}" styleClass="notification-title" wrapText="true"/>
<Label text="${controller.description}" styleClass="notification-description" wrapText="true"/>
<!--Label text="${controller.message}" styleClass="label-large" wrapText="true"/-->
<Label text="${controller.description}" styleClass="label" wrapText="true"/>
</VBox>
</center>
<bottom>
<HBox spacing="12" alignment="CENTER_LEFT">
<HBox spacing="6" alignment="CENTER_LEFT">
<Button text="${controller.actionText}" onAction="#handleButtonAction"
visible="${controller.buttonVisible}" managed="${controller.buttonVisible}"
styleClass="action-button"/>
visible="${controller.buttonVisible}" managed="${controller.buttonVisible}"/>
<Region HBox.hgrow="ALWAYS"/>
<HBox spacing="6" alignment="CENTER">
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#previousNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_LEFT" glyphSize="10"/>
</graphic>
</Button>
<FormattedLabel format="a%d / %d" arg1="${controller.selectionIndex}" arg2="${controller.numberOfNotifications}"
styleClass="page-indicator"/>
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#nextNotification">
<graphic>
<FontAwesome5IconView glyph="CHEVRON_RIGHT" glyphSize="10"/>
</graphic>
</Button>
</HBox>
<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>
</bottom>
</BorderPane>