Skip to content

Commit

Permalink
Fix FontIcon size problems
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Oct 4, 2024
1 parent 45894c5 commit 4faca60
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import net.rgielen.fxweaver.core.FxmlView;
import org.kordamp.ikonli.javafx.FontIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -88,6 +90,18 @@ public class ContactViewController implements Controller
@FXML
private Label updatedLabel;

@FXML
private FontIcon contactIcon;

@FXML
private Label acceptedLabel;

@FXML
private Label trustLabel;

@FXML
private GridPane profilePane;

private final ContactClient contactClient;
private final GeneralClient generalClient;
private final ProfileClient profileClient;
Expand Down Expand Up @@ -142,6 +156,10 @@ public void initialize() throws IOException

contactTableView.getSelectionModel().selectedItemProperty()
.addListener((observable, oldValue, newValue) -> changeSelectedContact(newValue));

// Workaround for https://github.com/mkpaz/atlantafx/issues/31
contactIcon.iconSizeProperty()
.addListener((observable, oldValue, newValue) -> contactIcon.setIconSize(128));
}

private void changeSelectedContact(Contact contact)
Expand All @@ -154,6 +172,7 @@ private void changeSelectedContact(Contact contact)
updatedLabel.setText(null);
contactImageView.setImage(null);
contactImagePane.getChildren().getFirst().setVisible(true);
profilePane.setVisible(false);
return;
}

Expand All @@ -165,6 +184,9 @@ private void changeSelectedContact(Contact contact)
.doOnSuccess(profile -> Platform.runLater(() -> {
idLabel.setText(Id.toString(profile.getPgpIdentifier()));
updatedLabel.setText(null); // XXX: for now...
acceptedLabel.setText(profile.isAccepted() ? "yes" : "no");
trustLabel.setText(profile.getTrust().toString());
profilePane.setVisible(true);
}))
.subscribe();

Expand All @@ -174,6 +196,7 @@ private void changeSelectedContact(Contact contact)
}
else if (contact.identityId() != 0L)
{
profilePane.setVisible(false);
identityClient.findById(contact.identityId())
.doOnSuccess(identity -> Platform.runLater(() -> {
idLabel.setText(Id.toString(identity.getGxsId()));
Expand Down
60 changes: 38 additions & 22 deletions ui/src/main/resources/view/contact/contactview.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,49 @@
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
</padding>
<HBox>
<StackPane fx:id="contactImagePane">
<FontIcon iconLiteral="fas-user" visible="false"/>
<StackPane fx:id="contactImagePane" alignment="TOP_LEFT">
<FontIcon fx:id="contactIcon" iconLiteral="fas-user:128" visible="false"/>
<AsyncImageView fx:id="contactImageView" fitWidth="128" fitHeight="128"/>
</StackPane>
<GridPane>
<VBox>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
</padding>
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="240.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="Name"/>
<Label fx:id="nameLabel" GridPane.columnIndex="1"/>
<Label text="ID" GridPane.rowIndex="1"/>
<Label fx:id="idLabel" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
<Label text="Type" GridPane.rowIndex="2"/>
<Label fx:id="typeLabel" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
<Label text="Created" GridPane.rowIndex="3"/>
<Label fx:id="updatedLabel" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
</GridPane>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="250.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="Name"/>
<Label fx:id="nameLabel" GridPane.columnIndex="1"/>
<Label text="ID" GridPane.rowIndex="1"/>
<Label fx:id="idLabel" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
<Label text="Type" GridPane.rowIndex="2"/>
<Label fx:id="typeLabel" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
<Label text="Created" GridPane.rowIndex="3"/>
<Label fx:id="updatedLabel" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
</GridPane>
<GridPane fx:id="profilePane" visible="false">
<columnConstraints>
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="240.0"/>
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
</rowConstraints>
<Label text="Accepted"/>
<Label fx:id="acceptedLabel" GridPane.columnIndex="1"/>
<Label text="Trust" GridPane.rowIndex="1"/>
<Label fx:id="trustLabel" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
</GridPane>
</VBox>
</HBox>
</VBox>
</SplitPane>
Expand Down
12 changes: 6 additions & 6 deletions ui/src/main/resources/view/debug/uicheck.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
-->

<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="io.xeres.ui.controller.debug.UiCheckWindowController"
prefHeight="400.0" prefWidth="600.0">
<?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="io.xeres.ui.controller.debug.UiCheckWindowController"
prefHeight="400.0" prefWidth="600.0">
<Label text="Here lies some useless debug view..."/>
</AnchorPane>
</VBox>

0 comments on commit 4faca60

Please sign in to comment.