Skip to content

Commit

Permalink
Merge pull request #1 from gldiazcardenas/main
Browse files Browse the repository at this point in the history
Updating to latest version
  • Loading branch information
dlemmermann authored Nov 12, 2023
2 parents 04914b1 + 4377c39 commit bade0bd
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 107 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.dlsc.phonenumberfx.demo;

import com.dlsc.phonenumberfx.PhoneNumberField;
import com.google.i18n.phonenumbers.Phonenumber;
import javafx.application.Application;
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings;
Expand Down Expand Up @@ -29,19 +28,11 @@ public class PhoneNumberFieldApp extends Application {
return null;
}
PhoneNumberField.CountryCallingCode code = (PhoneNumberField.CountryCallingCode) c;
return "(+" + code.phonePrefix() + ") " + code;
};

private static final Function<Object, String> PHONE_NUMBER_CONVERTER = c -> {
if (c == null) {
return null;
}
Phonenumber.PhoneNumber number = (Phonenumber.PhoneNumber) c;
return number.getRawInput();
return "(" + code.phonePrefix() + ") " + code;
};

@Override
public void start(Stage stage) throws Exception {
public void start(Stage stage) {
PhoneNumberField field = new PhoneNumberField();

VBox controls = new VBox(10);
Expand All @@ -52,7 +43,9 @@ public void start(Stage stage) throws Exception {

VBox fields = new VBox(10);
addField(fields, "Country Code", field.countryCallingCodeProperty(), COUNTRY_CODE_CONVERTER);
addField(fields, "Phone Number", field.phoneNumberProperty(), PHONE_NUMBER_CONVERTER);
addField(fields, "Raw PhoneNumber", field.rawPhoneNumberProperty());
addField(fields, "E164 PhoneNumber", field.e164PhoneNumberProperty());
addField(fields, "National PhoneNumber", field.nationalPhoneNumberProperty());

VBox vBox = new VBox(20);
vBox.setPadding(new Insets(20));
Expand Down Expand Up @@ -109,7 +102,7 @@ private Node disableCountryCheck(PhoneNumberField field) {

private Node clearButton(PhoneNumberField field) {
Button clear = new Button("Clear all");
clear.setOnAction(evt -> field.setPhoneNumber(null));
clear.setOnAction(evt -> field.setRawPhoneNumber(null));
return clear;
}

Expand Down
Loading

0 comments on commit bade0bd

Please sign in to comment.