Skip to content

Commit b38f451

Browse files
chore(javafx): Enhance Card CardPropertiesView
1 parent e92fe65 commit b38f451

14 files changed

Lines changed: 198 additions & 41 deletions

File tree

app/javafx/src/main/java/it/niedermann/nextcloud/deck/javafx/ui/controller/views/CardPreviewView.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class CardPreviewView extends BorderPane {
1616
@FXML
1717
Label description;
1818
@FXML
19+
CardPropertiesView cardProperties;
20+
@FXML
1921
ContextMenu contextMenu;
2022
@FXML
2123
MenuItem assign;
@@ -38,6 +40,14 @@ public void bind(Card card, boolean isAssignedToCurrentUser, CardPreviewActionLi
3840
description.setText(card.description());
3941
assign.setVisible(!isAssignedToCurrentUser);
4042
unassign.setVisible(isAssignedToCurrentUser);
43+
cardProperties.setArgs(new CardPropertiesView.Args(
44+
card.description(),
45+
card.labels().size(),
46+
card.commentsUnread(),
47+
card.comments().size(),
48+
card.attachments().size(),
49+
card.assignees().size()
50+
));
4151

4252
setOnMouseClicked(event -> {
4353
cardPreviewActionListener.onOpenCard(card);
@@ -52,22 +62,22 @@ public void bind(Card card, boolean isAssignedToCurrentUser, CardPreviewActionLi
5262
});
5363

5464
assign.setOnAction(event -> {
55-
cardPreviewActionListener.onDeleteCard(card);
65+
cardPreviewActionListener.onAssignCard(card);
5666
event.consume();
5767
});
5868

5969
unassign.setOnAction(event -> {
60-
cardPreviewActionListener.onDeleteCard(card);
70+
cardPreviewActionListener.onUnassignCard(card);
6171
event.consume();
6272
});
6373

6474
move.setOnAction(event -> {
65-
cardPreviewActionListener.onDeleteCard(card);
75+
cardPreviewActionListener.onMoveCard(card);
6676
event.consume();
6777
});
6878

6979
copy.setOnAction(event -> {
70-
cardPreviewActionListener.onDeleteCard(card);
80+
cardPreviewActionListener.onCopyCard(card);
7181
event.consume();
7282
});
7383

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package it.niedermann.nextcloud.deck.javafx.ui.controller.views;
2+
3+
import it.niedermann.nextcloud.deck.javafx.ui.fxml.Inflater;
4+
import it.niedermann.nextcloud.deck.javafx.util.FxUtils;
5+
import javafx.beans.property.ObjectProperty;
6+
import javafx.beans.property.SimpleObjectProperty;
7+
import javafx.fxml.FXML;
8+
import javafx.scene.layout.HBox;
9+
10+
public class CardPropertiesView extends HBox {
11+
12+
@FXML
13+
private IconCounterView descriptionIconCounter;
14+
@FXML
15+
private IconCounterView labelsIconCounter;
16+
@FXML
17+
private IconCounterView commentsIconCounter;
18+
@FXML
19+
private IconCounterView attachmentsIconCounter;
20+
@FXML
21+
private IconCounterView assigneesIconCounter;
22+
23+
private final ObjectProperty<Args> args = new SimpleObjectProperty<>(this, "args");
24+
25+
public CardPropertiesView() {
26+
Inflater.getInstance().inflateAndBind(this);
27+
28+
final var views = new IconCounterView[]{
29+
descriptionIconCounter,
30+
labelsIconCounter,
31+
commentsIconCounter,
32+
attachmentsIconCounter,
33+
assigneesIconCounter,
34+
};
35+
36+
managedProperty().bind(visibleProperty());
37+
FxUtils.anyVisible(views).subscribe(this::setVisible);
38+
39+
for (final var view : views) {
40+
view.managedProperty().bind(view.visibleProperty());
41+
}
42+
43+
args.subscribe(args -> {
44+
if (args == null) {
45+
for (final var view : views) {
46+
view.setVisible(false);
47+
return;
48+
}
49+
}
50+
51+
descriptionIconCounter.setVisible(args.description() != null && !args.description().isEmpty());
52+
labelsIconCounter.setVisible(args.labels() > 0);
53+
commentsIconCounter.setVisible(args.commentsTotalCount() > 0);
54+
attachmentsIconCounter.setVisible(args.attachments() > 0);
55+
assigneesIconCounter.setVisible(args.assignees() > 0);
56+
57+
// TODO Set checkbox item count
58+
descriptionIconCounter.setCounter(0);
59+
labelsIconCounter.setCounter(args.labels());
60+
commentsIconCounter.setCounter(args.commentsTotalCount());
61+
attachmentsIconCounter.setCounter(args.attachments());
62+
assigneesIconCounter.setCounter(args.assignees());
63+
});
64+
}
65+
66+
public final ObjectProperty<Args> argsProperty() {
67+
return args;
68+
}
69+
70+
public final Args getArgs() {
71+
return args.get();
72+
}
73+
74+
public final void setArgs(Args value) {
75+
args.set(value);
76+
}
77+
78+
public record Args(String description,
79+
int labels,
80+
int commentsUnreadCount,
81+
int commentsTotalCount,
82+
int attachments,
83+
int assignees) {
84+
}
85+
}
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
package it.niedermann.nextcloud.deck.javafx.ui.controller.views;
22

3+
import org.kordamp.ikonli.Ikon;
4+
import org.kordamp.ikonli.javafx.FontIcon;
5+
36
import it.niedermann.nextcloud.deck.javafx.ui.fxml.Inflater;
47
import javafx.beans.binding.Bindings;
58
import javafx.beans.property.IntegerProperty;
9+
import javafx.beans.property.ObjectProperty;
610
import javafx.beans.property.SimpleIntegerProperty;
711
import javafx.fxml.FXML;
812
import javafx.scene.control.Label;
9-
import javafx.scene.image.Image;
10-
import javafx.scene.image.ImageView;
1113
import javafx.scene.layout.HBox;
1214

1315
public class IconCounterView extends HBox {
1416

1517
@FXML
16-
ImageView imageView;
18+
FontIcon fontIcon;
1719
@FXML
1820
Label counter;
1921

2022
IntegerProperty counterProperty = new SimpleIntegerProperty();
2123

2224
public IconCounterView() {
2325
Inflater.getInstance().inflateAndBind(this);
26+
}
2427

28+
public void initialize() {
2529
Bindings.bindBidirectional(
2630
counter.textProperty(),
2731
counterProperty,
2832
new javafx.util.converter.NumberStringConverter()
2933
);
3034

31-
counter.visibleProperty().bind(counter.textProperty().isNotNull());
35+
counter.visibleProperty().bind(counter.textProperty().map(text -> text != null && text.length() > 1));
3236
counter.managedProperty().bind(counter.visibleProperty());
3337
}
3438

@@ -40,15 +44,23 @@ public void setCounter(int value) {
4044
counterProperty.set(value);
4145
}
4246

43-
public IntegerProperty counterProperty() {
44-
return counterProperty;
47+
public ObjectProperty<Ikon> iconCodeProperty() {
48+
return fontIcon.iconCodeProperty();
49+
}
50+
51+
public Ikon getIconCode() {
52+
return fontIcon.getIconCode();
53+
}
54+
55+
public void setIconCode(Ikon iconCode) {
56+
fontIcon.setIconCode(iconCode);
4557
}
4658

47-
public String getImage() {
48-
return imageView.getImage().getUrl();
59+
public String getIconLiteral() {
60+
return fontIcon.getIconLiteral();
4961
}
5062

51-
public void setImage(String value) {
52-
imageView.setImage(new Image(value));
63+
public void setIconLiteral(String iconCode) {
64+
fontIcon.setIconLiteral(iconCode);
5365
}
5466
}

app/javafx/src/main/java/it/niedermann/nextcloud/deck/javafx/util/FxUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
import org.intellij.lang.annotations.Language;
44

55
import java.awt.Color;
6+
import java.util.Arrays;
67
import java.util.Optional;
78

9+
import javafx.beans.Observable;
10+
import javafx.beans.binding.Bindings;
11+
import javafx.beans.binding.BooleanBinding;
812
import javafx.scene.Node;
913
import javafx.scene.control.ListCell;
1014
import javafx.scene.control.ListView;
@@ -60,4 +64,8 @@ private static int identifyClosestListViewIndex(ListCell<?> listCell, double sce
6064
: intersectedIndex + 1;
6165
}
6266

67+
public static BooleanBinding anyVisible(Node... nodes) {
68+
return Bindings.createBooleanBinding(() -> Arrays.stream(nodes).anyMatch(Node::isVisible),
69+
Arrays.stream(nodes).map(Node::visibleProperty).toArray(Observable[]::new));
70+
}
6371
}

app/javafx/src/main/resources/css/views/CardPreviewView.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@
44
-fx-border-radius: 10;
55
-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.15), 10, 0, 0, 2);
66
-fx-padding: 10;
7+
}
8+
9+
.top {
10+
-fx-padding: 0 0 10 0;
11+
}
12+
13+
.bottom {
14+
-fx-padding: 10 0 0 0;
715
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#root {
2+
-fx-alignment: center-left;
3+
-fx-spacing: 10;
4+
-fx-padding: 0 0 0 0;
5+
}

app/javafx/src/main/resources/fxml/features/EditCardFeature.fxml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<TabPane VBox.vgrow="ALWAYS">
1414
<tabs>
1515
<Tab closable="false" text="Details">
16+
<graphic>
17+
<FontIcon iconLiteral="fltral-home-16"/>
18+
</graphic>
1619
<content>
1720
<VBox>
1821

@@ -44,13 +47,19 @@
4447
</content>
4548
</Tab>
4649
<Tab closable="false" text="Attachments">
50+
<graphic>
51+
<FontIcon iconLiteral="fltfal-attach-16"/>
52+
</graphic>
4753
<content>
4854
<VBox>
4955
<ListView VBox.vgrow="ALWAYS" fx:id="attachments" />
5056
</VBox>
5157
</content>
5258
</Tab>
5359
<Tab closable="false" text="Comments">
60+
<graphic>
61+
<FontIcon iconLiteral="fltral-comment-16"/>
62+
</graphic>
5463
<content>
5564
<VBox>
5665
<ListView VBox.vgrow="ALWAYS" fx:id="comments" />
@@ -60,6 +69,9 @@
6069
</content>
6170
</Tab>
6271
<Tab closable="false" text="Activity">
72+
<graphic>
73+
<FontIcon iconLiteral="fltral-flash-on-20"/>
74+
</graphic>
6375
<content>
6476
<VBox>
6577
<ListView VBox.vgrow="ALWAYS" fx:id="activities" />

app/javafx/src/main/resources/fxml/views/CardPreviewView.fxml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<?import javafx.scene.control.ContextMenu?><?import javafx.scene.control.MenuItem?><?import javafx.scene.control.ButtonBar?><?import javafx.geometry.Insets?><?import javafx.scene.control.MenuButton?><?import javafx.scene.control.Label?><?import javafx.scene.control.MenuItem?><?import javafx.scene.layout.BorderPane?><?import javafx.scene.layout.HBox?><?import javafx.scene.text.Text?><?import it.niedermann.nextcloud.deck.javafx.ui.controller.views.IconCounterView?><?import javafx.scene.layout.Region?>
3+
<?import javafx.scene.control.ContextMenu?><?import it.niedermann.nextcloud.deck.javafx.ui.controller.views.CardPropertiesView?><?import javafx.scene.control.MenuItem?><?import javafx.scene.control.ButtonBar?><?import javafx.geometry.Insets?><?import javafx.scene.control.MenuButton?><?import javafx.scene.control.Label?><?import javafx.scene.control.MenuItem?><?import javafx.scene.layout.BorderPane?><?import javafx.scene.layout.HBox?><?import javafx.scene.text.Text?><?import it.niedermann.nextcloud.deck.javafx.ui.controller.views.IconCounterView?><?import javafx.scene.layout.Region?>
44

55

66
<fx:root xmlns:fx="http://javafx.com/fxml/1" styleClass="card"
77
stylesheets="css/views/CardPreviewView.css" type="BorderPane"
88
xmlns="http://javafx.com/javafx/25.0.1">
99

1010
<top>
11-
<HBox BorderPane.alignment="CENTER">
11+
<HBox BorderPane.alignment="CENTER" styleClass="top">
1212
<Label fx:id="title" />
1313
</HBox>
1414
</top>
1515

16-
<bottom>
17-
<HBox alignment="CENTER_LEFT">
18-
19-
<IconCounterView fx:id="descriptionIconCounter" />
20-
<IconCounterView fx:id="labelsIconCounter" />
21-
<IconCounterView fx:id="commentsIconCounter" />
22-
<IconCounterView fx:id="attachmentsIconCounter" />
23-
<IconCounterView fx:id="assigneesIconCounter" />
16+
<center>
17+
<Label BorderPane.alignment="TOP_LEFT" wrapText="true" fx:id="description" />
18+
</center>
2419

20+
<bottom>
21+
<HBox BorderPane.alignment="CENTER_LEFT" styleClass="bottom">
22+
<CardPropertiesView fx:id="cardProperties" />
2523
<Region HBox.hgrow="SOMETIMES" />
26-
2724
</HBox>
2825
</bottom>
2926

30-
<center>
31-
<Label alignment="TOP_LEFT" wrapText="true" fx:id="description" />
32-
</center>
33-
3427
<fx:define>
3528
<ContextMenu fx:id="contextMenu">
3629
<items>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import it.niedermann.nextcloud.deck.javafx.ui.controller.views.IconCounterView?><?import org.kordamp.ikonli.javafx.FontIcon?><?import javafx.scene.image.ImageView?><?import javafx.scene.control.Label?><?import javafx.scene.layout.HBox?>
4+
5+
<fx:root xmlns:fx="http://javafx.com/fxml/1" stylesheets="css/views/CardPropertiesView.css"
6+
type="HBox" fx:id="root">
7+
<IconCounterView iconLiteral="fltrmz-text-description-20" fx:id="descriptionIconCounter" />
8+
<IconCounterView iconLiteral="fltrmz-tag-16" fx:id="labelsIconCounter" />
9+
<IconCounterView iconLiteral="fltral-comment-16" fx:id="commentsIconCounter" />
10+
<IconCounterView iconLiteral="fltfal-attach-16" fx:id="attachmentsIconCounter" />
11+
<IconCounterView iconLiteral="fltrmz-person-16" fx:id="assigneesIconCounter" />
12+
</fx:root>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<?import org.kordamp.ikonli.javafx.FontIcon?>
34
<?import javafx.scene.image.ImageView?>
45
<?import javafx.scene.control.Label?>
56
<?import javafx.scene.layout.HBox?>
67

7-
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" alignment="CENTER_LEFT">
8-
<ImageView fx:id="imageView" />
8+
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" spacing="3" alignment="CENTER_LEFT">
9+
<FontIcon fx:id="fontIcon" iconSize="16" />
910
<Label fx:id="counter" />
1011
</fx:root>

0 commit comments

Comments
 (0)