diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/HistoryController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/HistoryController.java index e7c2037d..f1febec7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/HistoryController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/HistoryController.java @@ -1,8 +1,23 @@ package com.sparrowwallet.sparrow.joinstr; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.TextField; + public class HistoryController extends JoinstrFormController { + + @FXML + private TextField searchTextField; + @Override public void initializeView() { } + + public void handleSearchButton(ActionEvent e) { + if(e.getSource()==searchTextField) { + System.out.println(searchTextField.getText()); + }; + } + } diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrAction.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrAction.java new file mode 100644 index 00000000..f81629fb --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrAction.java @@ -0,0 +1,7 @@ +package com.sparrowwallet.sparrow.joinstr; + +public enum JoinstrAction { + JOIN, + CREATE, + REMOVE +} diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java index b3e8190c..9e631e55 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrFormController.java @@ -12,7 +12,6 @@ public abstract class JoinstrFormController extends BaseController { public void setJoinstrForm(JoinstrForm joinstrForm) { this.joinstrForm = joinstrForm; - initializeView(); } public abstract void initializeView(); diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java new file mode 100644 index 00000000..ca1515d3 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/JoinstrPool.java @@ -0,0 +1,35 @@ +package com.sparrowwallet.sparrow.joinstr; + +public class JoinstrPool { + + private final String relay; + private final Integer port; + private final String pubkey; + private final Double denomination; + + public JoinstrPool(String relay_, Integer port_, String pubkey_, Double denomination_) { + + relay = relay_; + port = port_; + pubkey = pubkey_; + denomination = denomination_; + + } + + public String getRelay() { + return relay; + } + + public Integer getPort() { + return port; + } + + public String getPubkey() { + return pubkey; + } + + public Double getDenomination() { + return denomination; + } + +} diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/MyPoolsController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/MyPoolsController.java index 2837d9a5..1cb2509f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/MyPoolsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/MyPoolsController.java @@ -1,8 +1,23 @@ package com.sparrowwallet.sparrow.joinstr; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.TextField; + public class MyPoolsController extends JoinstrFormController { + + @FXML + private TextField searchTextField; + @Override public void initializeView() { } + + public void handleSearchButton(ActionEvent e) { + if(e.getSource()==searchTextField) { + System.out.println(searchTextField.getText()); + }; + } + } diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/OtherPoolsController.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/OtherPoolsController.java index cbfa7c56..6a010d46 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/OtherPoolsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/OtherPoolsController.java @@ -1,16 +1,41 @@ package com.sparrowwallet.sparrow.joinstr; +import com.sparrowwallet.sparrow.joinstr.control.JoinstrInfoPane; import com.sparrowwallet.sparrow.joinstr.control.JoinstrPoolList; +import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; public class OtherPoolsController extends JoinstrFormController { @FXML - private JoinstrPoolList joinstrPoolList; + private VBox contentVBox; + + @FXML + private TextField searchTextField; @Override public void initializeView() { - joinstrPoolList.fillList(); + try { + + JoinstrPoolList joinstrPoolList = new JoinstrPoolList(JoinstrAction.JOIN); + + JoinstrInfoPane joinstrInfoPane = new JoinstrInfoPane(); + joinstrInfoPane.initInfoPane(); + + contentVBox.getChildren().addAll(joinstrPoolList, joinstrInfoPane); + + } catch (Exception e) { + if(e != null) {} + } } + + public void handleSearchButton(ActionEvent e) { + if(e.getSource()==searchTextField) { + System.out.println(searchTextField.getText()); + }; + } + } diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrInfoPane.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrInfoPane.java new file mode 100644 index 00000000..d1575f99 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrInfoPane.java @@ -0,0 +1,49 @@ +package com.sparrowwallet.sparrow.joinstr.control; + +import javafx.scene.control.Label; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.GridPane; + +public class JoinstrInfoPane extends AnchorPane { + + public JoinstrInfoPane() { super(); } + + public void initInfoPane() { + + GridPane mainGridPane = new GridPane(); + + Label relayTitleLabel = new Label(); + relayTitleLabel.setText("Relay:"); + GridPane.setRowIndex(relayTitleLabel, 0); + GridPane.setColumnIndex(relayTitleLabel, 0); + + Label pubkeyTitleLabel = new Label(); + pubkeyTitleLabel.setText("Pubkey:"); + GridPane.setRowIndex(pubkeyTitleLabel, 1); + GridPane.setColumnIndex(pubkeyTitleLabel, 0); + + Label denominationTitleLabel = new Label(); + denominationTitleLabel.setText("Denomination:"); + GridPane.setRowIndex(denominationTitleLabel, 2); + GridPane.setColumnIndex(denominationTitleLabel, 0); + + + Label relayDescLabel = new Label(); + relayDescLabel.setText("Relay desc"); + GridPane.setRowIndex(relayDescLabel, 0); + GridPane.setColumnIndex(relayDescLabel, 1); + + Label pubkeyDescLabel = new Label(); + pubkeyDescLabel.setText("Pubkey desc"); + GridPane.setRowIndex(pubkeyDescLabel, 1); + GridPane.setColumnIndex(pubkeyDescLabel, 1); + + Label denominationDescLabel = new Label(); + denominationDescLabel.setText("Denomination desc"); + GridPane.setRowIndex(denominationDescLabel, 2); + GridPane.setColumnIndex(denominationDescLabel, 1); + + getChildren().add(mainGridPane); + } + +} diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolList.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolList.java index e38d33c0..f898557b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolList.java +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolList.java @@ -1,48 +1,39 @@ package com.sparrowwallet.sparrow.joinstr.control; -import com.sparrowwallet.sparrow.AppController; +import com.sparrowwallet.sparrow.joinstr.JoinstrAction; +import com.sparrowwallet.sparrow.joinstr.JoinstrPool; -import java.io.IOException; +import javafx.scene.layout.*; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.layout.VBox; -import javafx.scene.layout.Pane; +public class JoinstrPoolList extends VBox { -public class JoinstrPoolList extends Pane { + public JoinstrPoolList(JoinstrAction action) { + super(); - @FXML - private VBox listVBox; + setPrefHeight(500); + setPrefWidth(500); + setSpacing(10); - public JoinstrPoolList() { + setMaxWidth(Double.MAX_VALUE); + setMaxHeight(Double.MAX_VALUE); - FXMLLoader loader = new FXMLLoader(AppController.class.getResource("joinstr/control/joinstrpoollist.fxml")); - loader.setRoot(this); - loader.setController(this); + JoinstrPoolListRow header = new JoinstrPoolListRow(); + getChildren().add(header); - try { - loader.load(); + JoinstrPool[] poolsDummy = getDummyData(); - } catch (IOException e) { - throw new RuntimeException(e); + for (JoinstrPool joinstrPool : poolsDummy) { + JoinstrPoolListRow joinstrRow = new JoinstrPoolListRow(joinstrPool, action); + getChildren().add(joinstrRow); } } - public void fillList() { - - JoinstrPoolListItem listItem1 = new JoinstrPoolListItem(); - listItem1.setLabel("Pool #1"); - listVBox.getChildren().add(listItem1); - - JoinstrPoolListItem listItem2 = new JoinstrPoolListItem(); - listItem2.setLabel("Pool #2"); - listVBox.getChildren().add(listItem2); - - JoinstrPoolListItem listItem3 = new JoinstrPoolListItem(); - listItem3.setLabel("Pool #3"); - listVBox.getChildren().add(listItem3); + private JoinstrPool[] getDummyData() { + return new JoinstrPool[]{ new JoinstrPool("Relay1", 1234, "pubkey1", 0.001), + new JoinstrPool("Relay2", 1234, "pubkey2", 0.002), + new JoinstrPool("Relay3", 1234, "pubkey3", 0.005)}; } } diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListItem.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListItem.java deleted file mode 100644 index e817d56e..00000000 --- a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListItem.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sparrowwallet.sparrow.joinstr.control; - -import com.sparrowwallet.sparrow.AppController; - -import java.io.IOException; - -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.control.Label; -import javafx.scene.layout.Pane; - -public class JoinstrPoolListItem extends Pane { - - @FXML - private Label lblTest; - - public JoinstrPoolListItem() { - - FXMLLoader loader = new FXMLLoader(AppController.class.getResource("joinstr/control/joinstrpoollistitem.fxml")); - loader.setRoot(this); - loader.setController(this); - - try { - loader.load(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - - public void setLabel(String txt) { - lblTest.setText(txt); - } - -} diff --git a/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListRow.java b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListRow.java new file mode 100644 index 00000000..26269293 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/joinstr/control/JoinstrPoolListRow.java @@ -0,0 +1,170 @@ +package com.sparrowwallet.sparrow.joinstr.control; + +import com.sparrowwallet.sparrow.joinstr.JoinstrAction; +import com.sparrowwallet.sparrow.joinstr.JoinstrPool; + +import javafx.event.ActionEvent; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +public class JoinstrPoolListRow extends GridPane { + + private JoinstrPool poolData; + + /// Constructor for header + public JoinstrPoolListRow() { + + setMaxWidth(Double.MAX_VALUE); + setMaxHeight(Double.MAX_VALUE); + GridPane.setHgrow(this, Priority.ALWAYS); + setColumnConstraints(); + + Label relayLabel = new Label("Relay"); + GridPane.setRowIndex(relayLabel, 0); + GridPane.setColumnIndex(relayLabel, 0); + + Label pubkeyLabel = new Label("Pubkey (Shortened)"); + GridPane.setRowIndex(pubkeyLabel, 0); + GridPane.setColumnIndex(pubkeyLabel, 1); + + Label denominationLabel = new Label("Denomination"); + GridPane.setRowIndex(denominationLabel, 0); + GridPane.setColumnIndex(denominationLabel, 2); + + Label peersLabel = new Label("Peers"); + GridPane.setRowIndex(peersLabel, 0); + GridPane.setColumnIndex(peersLabel, 3); + + Label timeoutLabel = new Label("Timeout"); + GridPane.setRowIndex(timeoutLabel, 0); + GridPane.setColumnIndex(timeoutLabel, 4); + + Label actionLabel = new Label("Action"); + GridPane.setRowIndex(actionLabel, 0); + GridPane.setColumnIndex(actionLabel, 5); + + getChildren().addAll(relayLabel, pubkeyLabel, denominationLabel, peersLabel, timeoutLabel, actionLabel); + + getStyleClass().add("joinstr-list-header"); + + } + + /// Constructor for data rows + public JoinstrPoolListRow(JoinstrPool poolData_, JoinstrAction action) { + poolData = poolData_; + + setMaxWidth(Double.MAX_VALUE); + setMaxHeight(Double.MAX_VALUE); + GridPane.setHgrow(this, Priority.ALWAYS); + setColumnConstraints(); + + VBox relayVBox = new VBox(); + Label relayLabel = new Label(poolData.getRelay()); + relayLabel.getStyleClass().add("joinstr-list-item"); + + Label portLabel = new Label("Port: " + poolData.getPort().toString()); + portLabel.getStyleClass().add("joinstr-list-item-subtitle"); + + relayVBox.getChildren().addAll(relayLabel, portLabel); + GridPane.setRowIndex(relayVBox, 0); + GridPane.setColumnIndex(relayVBox, 0); + + VBox pubkeyVBox = new VBox(); + Label pubkeyLabel = new Label(poolData.getPubkey()); + pubkeyLabel.getStyleClass().add("joinstr-list-item"); + + Label pubkeyTypeLabel = new Label("type"); + pubkeyTypeLabel.getStyleClass().add("joinstr-list-item-subtitle"); + + pubkeyVBox.getChildren().addAll(pubkeyLabel, pubkeyTypeLabel); + GridPane.setRowIndex(pubkeyVBox, 0); + GridPane.setColumnIndex(pubkeyVBox, 1); + + VBox denominationVBox = new VBox(); + Label denominationLabel = new Label(poolData.getDenomination().toString()); + denominationLabel.getStyleClass().add("joinstr-list-item"); + + Label denominationMinLabel = new Label("Min: _____ BTC"); + denominationMinLabel.getStyleClass().add("joinstr-list-item-subtitle"); + + denominationVBox.getChildren().addAll(denominationLabel, denominationMinLabel); + GridPane.setRowIndex(denominationVBox, 0); + GridPane.setColumnIndex(denominationVBox, 2); + + VBox peersVBox = new VBox(); + Label peersLabel = new Label("__/__"); + peersLabel.getStyleClass().add("joinstr-list-item"); + + Label peersMinLabel = new Label("Min: -"); + peersMinLabel.getStyleClass().add("joinstr-list-item-subtitle"); + + peersVBox.getChildren().addAll(peersLabel, peersMinLabel); + GridPane.setRowIndex(peersVBox, 0); + GridPane.setColumnIndex(peersVBox, 3); + + VBox timeoutVBox = new VBox(); + Label timeoutLabel = new Label("0"); + timeoutLabel.getStyleClass().add("joinstr-list-item"); + + Label timeoutTypeLabel = new Label("mins"); + timeoutTypeLabel.getStyleClass().add("joinstr-list-item-subtitle"); + + timeoutVBox.getChildren().addAll(timeoutLabel, timeoutTypeLabel); + GridPane.setRowIndex(timeoutVBox, 0); + GridPane.setColumnIndex(timeoutVBox, 4); + + Button actionButton = new Button(); + actionButton.getStyleClass().add("joinstr-list-action-button"); + switch(action) { + case JOIN -> { + actionButton.setText("Join"); + actionButton.setOnAction(event -> { + System.out.println("Join " + poolData.getRelay() + "!"); + }); + } + case REMOVE -> { + // For MY_POOLS & HISTORY + actionButton.setText("Remove"); + actionButton.setOnAction(event -> { + System.out.println("Remove " + poolData.getRelay() + "!"); + }); + } + } + GridPane.setRowIndex(actionButton, 0); + GridPane.setColumnIndex(actionButton, 5); + + getChildren().addAll( relayVBox, pubkeyVBox, denominationVBox, peersVBox, timeoutVBox, actionButton); + getStyleClass().add("joinstr-list-row"); + + } + + private void setColumnConstraints() { + + ColumnConstraints column1 = new ColumnConstraints(); + column1.setPercentWidth(25); + ColumnConstraints column2 = new ColumnConstraints(); + column2.setPercentWidth(25); + ColumnConstraints column3 = new ColumnConstraints(); + column3.setPercentWidth(16); + ColumnConstraints column4 = new ColumnConstraints(); + column4.setPercentWidth(10); + ColumnConstraints column5 = new ColumnConstraints(); + column5.setPercentWidth(10); + ColumnConstraints column6 = new ColumnConstraints(); + column6.setPercentWidth(14); + + getColumnConstraints().addAll(column1, column2, column3, column4, column5, column6); + + } + + public void handleActionButton(ActionEvent e) { + if(e.getSource()!=null) { + System.out.println("Action!"); + }; + } + +} diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/control.css b/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/control.css deleted file mode 100644 index 695fa94b..00000000 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/control.css +++ /dev/null @@ -1,18 +0,0 @@ - -pool-list { -} - -pool-header { - -fx-background-color: #000000; -} - -pool-list-item { - -fx-insets:10, 10, 10, 10; - -fx-border-radius:10, 10, 10, 10; - -fx-background-color: #1D2124; -} - -pool-list-item:hover { - -fx-background-color: #164768; - -fx-border-color: #4E99D3; -} \ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollist.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollist.fxml deleted file mode 100644 index 5660b290..00000000 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollist.fxml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollistitem.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollistitem.fxml deleted file mode 100644 index b9b95a48..00000000 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/control/joinstrpoollistitem.fxml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/history.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/history.fxml index 0dba04de..dab41352 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/history.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/history.fxml @@ -2,9 +2,26 @@ + + + +
- + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/joinstr.css b/src/main/resources/com/sparrowwallet/sparrow/joinstr/joinstr.css index fc645387..1a42ad8d 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/joinstr.css +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/joinstr.css @@ -7,6 +7,49 @@ -fx-padding:25, 0, 0, 0; } +.joinstr-list-action-button { + -fx-background-color: #3DA0E3; + -fx-padding:10, 30, 10, 30; + -fx-text-fill: white; + -fx-font-weight: bold; +} + +.joinstr-list-header { + -fx-padding:10, 0, 10, 0; + -fx-font-weight: bold; + -fx-font-size: 1.3em; + -fx-background-color: lightgray; + -fx-background-radius: 5px; +} + +.joinstr-list-item-subtitle { + -fx-font-size: 1em; +} + +.joinstr-list-item { + -fx-font-size: 1.2em; +} + +.joinstr-list-row { + -fx-padding:10, 0, 10, 0; + -fx-background-color: #DDDDDD; + -fx-background-radius: 5px; + -fx-border-style:solid; + -fx-border-width: 3px; + -fx-border-radius: 5px; + -fx-border-color: #DDDDDD; +} + +.joinstr-list-row:hover { + -fx-padding:10, 0, 10, 0; + -fx-background-color: lightgray; + -fx-background-radius: 5px; + -fx-border-style:solid; + -fx-border-width: 3px; + -fx-border-radius: 5px; + -fx-border-color: #1A6BA2; +} + .joinstr-balance-label { -fx-text-fill: white; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/my_pools.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/my_pools.fxml index f010a77f..d7c766df 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/my_pools.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/my_pools.fxml @@ -2,9 +2,27 @@ + + + +
- + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml index b8f19592..abd08ad8 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/new_pool.fxml @@ -2,9 +2,26 @@ + + + +
- + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/main/resources/com/sparrowwallet/sparrow/joinstr/other_pools.fxml b/src/main/resources/com/sparrowwallet/sparrow/joinstr/other_pools.fxml index c646e8a6..46f692b0 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/joinstr/other_pools.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/joinstr/other_pools.fxml @@ -2,22 +2,17 @@ - - +
- - - - - + @@ -28,11 +23,9 @@ - + - -
\ No newline at end of file