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; 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 { public class NewPoolController extends JoinstrFormController {
@FXML
private TextField denominationField;
@FXML
private TextField peersField;
@Override @Override
public void initializeView() { 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"/> <Insets top="30" right="30" bottom="30" left="30"/>
</padding> </padding>
<center> <center>
<VBox maxWidth="Infinity" fx:id="contentVBox"> <VBox maxWidth="Infinity" fx:id="contentVBox" spacing="20">
<GridPane maxWidth="Infinity" HBox.hgrow="ALWAYS" hgap="10.0" vgap="10.0"> <VBox maxWidth="Infinity" HBox.hgrow="ALWAYS">
<columnConstraints> <Label styleClass="sub-title">Create a new pool</Label>
<ColumnConstraints percentWidth="80" /> </VBox>
<ColumnConstraints percentWidth="20" />
</columnConstraints> <GridPane hgap="10" vgap="15" maxWidth="600">
<children> <padding>
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS" GridPane.rowIndex="0" GridPane.columnIndex="0"> <Insets top="20"/>
<Label styleClass="title">New Pool</Label> </padding>
<Label styleClass="sub-title">Create a new pool</Label>
</VBox> <Label text="Denomination (BTC):" GridPane.rowIndex="0" GridPane.columnIndex="0" style="-fx-text-fill: #aaaaaa;"/>
</children> <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> </GridPane>
</VBox> </VBox>
</center> </center>