Skip to content

Commit

Permalink
Expand phoneNumberField functionality and improve usability
Browse files Browse the repository at this point in the history
Enhanced the phoneNumberField application by adding multiple features and improving the user interface. The phoneNumberField now feature buttons and checkboxes that allow customization by the user such as showing example numbers for the selected country or visible country code within the number. The UI has also been shifted from centered to centered-left alignment for improved layout. Updated the PhoneNumberFieldSamples class to be more versatile by changing the access modifier of 'buildSample()' method to public.
  • Loading branch information
dlemmermann committed Nov 24, 2023
1 parent ddcca09 commit 1587ae9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static Node buildCountryCodeVisibleSample() {
return buildSample(title, description, field);
}

private static Node buildSample(String title, String description, PhoneNumberField field) {
public static Node buildSample(String title, String description, PhoneNumberField field) {
Label titleLabel = new Label(title);
titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 1.4em;");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.dlsc.phonenumberfx.demo;

import com.dlsc.phonenumberfx.PhoneNumberField;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Separator;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

Expand All @@ -14,11 +18,30 @@ public class SinglePhoneNumberFieldApp extends Application {
public void start(Stage stage) {
VBox vBox = new VBox(20);
vBox.setPadding(new Insets(20));
vBox.setAlignment(Pos.CENTER);
vBox.setAlignment(Pos.CENTER_LEFT);

PhoneNumberField field = new PhoneNumberField();
vBox.getChildren().addAll(
PhoneNumberFieldSamples.buildCountryCodeVisibleSample()
PhoneNumberFieldSamples.buildSample("Phone Number Field", "A configurable field for entering international phone numbers.", field)
);

Button clearButton = new Button("Clear");
clearButton.setOnAction(evt -> field.clear());

CheckBox showExampleBox = new CheckBox("Show example number for selected country");
showExampleBox.selectedProperty().bindBidirectional(field.showExampleNumbersProperty());

CheckBox countryCodeVisibleBox = new CheckBox("Show country code as part of number");
countryCodeVisibleBox.selectedProperty().bindBidirectional(field.countryCodeVisibleProperty());

CheckBox disableCountryCodeBox = new CheckBox("Disable country dropdown");
disableCountryCodeBox.selectedProperty().bindBidirectional(field.disableCountryDropdownProperty());

CheckBox editableBox = new CheckBox("Editable");
editableBox.selectedProperty().bindBidirectional(field.editableProperty());

vBox.getChildren().addAll(new Separator(), clearButton, showExampleBox, countryCodeVisibleBox, disableCountryCodeBox, editableBox);

ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(vBox);

Expand Down

0 comments on commit 1587ae9

Please sign in to comment.