add ui to create new pool

This commit is contained in:
/dev/fd0 2025-05-24 19:20:07 +05:30
parent 2f6984c4cc
commit 79a597cfa0
2 changed files with 92 additions and 12 deletions

View file

@ -1,8 +1,77 @@
package com.sparrowwallet.sparrow.joinstr;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
public class NewPoolController extends JoinstrFormController {
@FXML
private TextField denominationField;
@FXML
private TextField peersField;
@Override
public void initializeView() {
}
@FXML
private void handleCreateButton() {
try {
String denomination = denominationField.getText().trim();
String peers = peersField.getText().trim();
if (denomination.isEmpty() || peers.isEmpty()) {
showError("Please enter denomination and peers to create a pool.");
return;
}
try {
double denominationValue = Double.parseDouble(denomination);
if (denominationValue <= 0) {
showError("Denomination must be greater than 0");
return;
}
} catch (NumberFormatException e) {
showError("Invalid denomination format");
return;
}
try {
int peersValue = Integer.parseInt(peers);
if (peersValue <= 0) {
showError("Number of peers must be greater than 0");
return;
}
} catch (NumberFormatException e) {
showError("Invalid number of peers format");
return;
}
// TODO: Implement pool creation logic here
/*
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Success");
alert.setHeaderText(null);
alert.setContentText("Pool created successfully!");
alert.showAndWait();
*/
denominationField.clear();
peersField.clear();
} catch (Exception e) {
showError("An error occurred: " + e.getMessage());
}
}
private void showError(String message) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}
}

View file

@ -9,18 +9,29 @@
<Insets top="30" right="30" bottom="30" left="30"/>
</padding>
<center>
<VBox maxWidth="Infinity" fx:id="contentVBox">
<GridPane maxWidth="Infinity" HBox.hgrow="ALWAYS" hgap="10.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints percentWidth="80" />
<ColumnConstraints percentWidth="20" />
</columnConstraints>
<children>
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS" GridPane.rowIndex="0" GridPane.columnIndex="0">
<Label styleClass="title">New Pool</Label>
<Label styleClass="sub-title">Create a new pool</Label>
</VBox>
</children>
<VBox maxWidth="Infinity" fx:id="contentVBox" spacing="20">
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS">
<Label styleClass="sub-title">Create a new pool</Label>
</VBox>
<GridPane hgap="10" vgap="15" maxWidth="600">
<padding>
<Insets top="20"/>
</padding>
<Label text="Denomination (BTC):" GridPane.rowIndex="0" GridPane.columnIndex="0" style="-fx-text-fill: #aaaaaa;"/>
<TextField fx:id="denominationField" GridPane.rowIndex="0" GridPane.columnIndex="1"
style="-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;"
promptText="Enter denomination"/>
<Label text="Number of Peers:" GridPane.rowIndex="1" GridPane.columnIndex="0" style="-fx-text-fill: #aaaaaa;"/>
<TextField fx:id="peersField" GridPane.rowIndex="1" GridPane.columnIndex="1"
style="-fx-background-color: #444444; -fx-text-fill: white; -fx-prompt-text-fill: #888888;"
promptText="Enter number of peers"/>
<Button fx:id="createButton" text="Create" GridPane.rowIndex="2" GridPane.columnIndex="1"
onAction="#handleCreateButton"
style="-fx-background-color: #2196F3; -fx-text-fill: white; -fx-cursor: hand;"/>
</GridPane>
</VBox>
</center>