Skip to content

Commit

Permalink
Replaced search text field with new implementation. Some polishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Jul 30, 2024
1 parent c10ff0a commit 9f6b17e
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.dlsc.jfxcentral2.components;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.materialdesign.MaterialDesign;

public class MobileSearchTextField extends BorderPane {

public MobileSearchTextField() {
getStyleClass().add("text-input");

getStyleClass().add("mobile-search-text-field");

TextField textField = new TextField();
textField.textProperty().bindBidirectional(textProperty());
textField.promptTextProperty().bind(promptText);

HBox.setHgrow(textField, Priority.ALWAYS);

FontIcon icon = new FontIcon(MaterialDesign.MDI_MAGNIFY);
BorderPane.setAlignment(icon, Pos.CENTER);
BorderPane.setMargin(textField, new Insets(0, 10, 0, 10));

setLeft(icon);
setCenter(textField);
}

private final StringProperty text = new SimpleStringProperty();

public String getText() {
return text.get();
}

public StringProperty textProperty() {
return text;
}

public void setText(String text) {
this.text.set(text);
}

public final void clear() {
text.set("");
}

private final StringProperty promptText = new SimpleStringProperty();

public String getPromptText() {
return promptText.get();
}

public StringProperty promptTextProperty() {
return promptText;
}

public void setPromptText(String promptText) {
this.promptText.set(promptText);
}
}
1 change: 1 addition & 0 deletions components/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
requires org.kordamp.ikonli.win10;
requires org.kordamp.ikonli.zondicons;
requires com.rometools.rome;
requires java.prefs;
// ikonli icon packs END

exports com.dlsc.jfxcentral2.components;
Expand Down
12 changes: 11 additions & 1 deletion components/src/main/resources/com/dlsc/jfxcentral2/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -8139,7 +8139,7 @@
}

/** ------------------------------------
* search-field-list-view (SearchField popup)
* search-field-list-view (MobileSearchTextField popup)
*/
.search-field-list-view {
-fx-pref-height: 350px !important;
Expand Down Expand Up @@ -9312,6 +9312,16 @@
-fx-padding: 10px 30px;
}

/* ----------------------------------------------------------------------------
* ScrollPane
*/

.scroll-pane {
-fx-padding: 0;
-fx-background-insets: 0; /* no focus border */
-fx-border-width: 0;
}

/* ----------------------------------------------------------------------------
* Pretty ScrollPane
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import com.dlsc.jfxcentral.data.model.LearnRaspberryPi;
import com.dlsc.jfxcentral2.components.AvatarView;
import com.dlsc.jfxcentral2.components.CustomMarkdownView;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.utils.MobileLinkUtil;
import com.dlsc.jfxcentral2.utils.ModelObjectTool;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
Expand All @@ -28,7 +29,7 @@ public class LearnPagination<T extends Learn> extends MobilePagination<T> {
private static final String DEFAULT_STYLE_CLASS = "learn-pagination";
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);

private final PrettyScrollPane scrollPane = new PrettyScrollPane();
private final ScrollPane scrollPane = new ScrollPane();

public LearnPagination() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import com.dlsc.jfxcentral.data.DataRepository2;
import com.dlsc.jfxcentral.data.model.LinksOfTheWeek;
import com.dlsc.jfxcentral2.components.CustomMarkdownView;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import javafx.beans.binding.Bindings;
import javafx.scene.control.ScrollPane;

public class LotwPagination extends MobilePagination<LinksOfTheWeek> {

private static final String DEFAULT_STYLE_CLASS = "lotw-pagination";
private final PrettyScrollPane scrollPane = new PrettyScrollPane();
private final ScrollPane scrollPane = new ScrollPane();

public LotwPagination() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.dlsc.jfxcentral2.mobile.components;

import com.dlsc.gemsfx.SearchTextField;
import com.dlsc.jfxcentral.data.model.Documentation;
import com.dlsc.jfxcentral.data.model.ModelObject;
import com.dlsc.jfxcentral2.components.MobileSearchTextField;
import com.dlsc.jfxcentral2.mobile.utils.ListViewUtil;
import com.dlsc.jfxcentral2.utils.MobileLinkUtil;
import com.dlsc.jfxcentral2.utils.ModelObjectTool;
Expand Down Expand Up @@ -36,8 +36,7 @@ public class ModelListView<T extends ModelObject> extends VBox {
public ModelListView() {
getStyleClass().add(DEFAULT_STYLE_CLASS);

SearchTextField searchTextField = new SearchTextField();
searchTextField.setRound(true);
MobileSearchTextField searchTextField = new MobileSearchTextField();
searchTextField.promptTextProperty().bind(promptTextProperty());
StackPane searchWrapper = new StackPane(searchTextField);
searchWrapper.getStyleClass().add("search-wrapper");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.dlsc.jfxcentral2.mobile.components;

import com.dlsc.gemsfx.SearchTextField;
import com.dlsc.jfxcentral2.components.MobileSearchTextField;
import com.dlsc.jfxcentral2.components.SizeSupport;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.BooleanProperty;
Expand All @@ -20,8 +20,7 @@ public class SearchTextView extends StackPane {
public SearchTextView() {
getStyleClass().add(DEFAULT_STYLE_CLASS);

SearchTextField searchTextField = new SearchTextField();
searchTextField.setRound(true);
MobileSearchTextField searchTextField = new MobileSearchTextField();
searchTextField.promptTextProperty().bind(promptTextProperty());
searchText.bind(searchTextField.textProperty());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dlsc.jfxcentral2.mobile.pages;

import com.dlsc.gemsfx.SearchTextField;
import com.dlsc.jfxcentral.data.DataRepository2;
import com.dlsc.jfxcentral.data.model.Blog;
import com.dlsc.jfxcentral.data.model.Book;
Expand All @@ -11,8 +10,9 @@
import com.dlsc.jfxcentral.data.model.RealWorldApp;
import com.dlsc.jfxcentral.data.model.Tip;
import com.dlsc.jfxcentral.data.model.Video;
import com.dlsc.jfxcentral2.components.MobileSearchTextField;
import com.dlsc.jfxcentral2.components.MobilePageBase;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.mobile.components.LearnCategoryBox;
import com.dlsc.jfxcentral2.mobile.components.MobileSearchView;
import com.dlsc.jfxcentral2.mobile.home.CategoryAdvancedView;
Expand All @@ -25,6 +25,7 @@
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
Expand All @@ -37,7 +38,7 @@ public class MobileHomePage extends MobilePageBase {

private static MobileHomePage instance;

private final SearchTextField searchTextField;
private final MobileSearchTextField searchTextField;

public enum ContentType {
NORMAL, SEARCH
Expand Down Expand Up @@ -69,8 +70,7 @@ private MobileHomePage() {
header.sizeProperty().bind(sizeProperty());

// search field
searchTextField = new SearchTextField();
searchTextField.setRound(true);
searchTextField = new MobileSearchTextField();
searchTextField.setRight(createSearchCancelButton());
searchTextField.setPromptText("Search for anything...");
searchView.searchTextProperty().bindBidirectional(searchTextField.textProperty());
Expand Down Expand Up @@ -149,10 +149,10 @@ private Node createNormalView() {
VBox normalView = new VBox(categoryAdvancedView, weekLinksView, showCasePreviewView, peoplePreviewView, libraryPreviewView, booksPreviewView, videoPreviewView, blogPreviewView, tipsPreviewView, learnCategoryBox);
normalView.getStyleClass().add("content-box");

PrettyScrollPane prettyScrollPane = new PrettyScrollPane(normalView);
prettyScrollPane.getStyleClass().add("mobile");
VBox.setVgrow(prettyScrollPane, Priority.ALWAYS);
return prettyScrollPane;
ScrollPane ScrollPane = new ScrollPane(normalView);
ScrollPane.getStyleClass().add("mobile");
VBox.setVgrow(ScrollPane, Priority.ALWAYS);
return ScrollPane;
}

private <T extends ModelObject> List<T> getRandomSample(List<T> list, int sampleSize) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.dlsc.jfxcentral2.mobile.pages.details;

import com.dlsc.jfxcentral.data.model.Book;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.components.overviewbox.BookOverviewBox;
import com.dlsc.jfxcentral2.mobile.components.LinkedObjectsBox;
import com.dlsc.jfxcentral2.mobile.components.MobilePageHeader;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;

Expand Down Expand Up @@ -42,7 +43,7 @@ public List<Node> content() {
VBox detailsPageContentWrapper = new VBox(bookOverviewBox, linkedObjectsBox);
detailsPageContentWrapper.getStyleClass().add("details-page-content-wrapper");

PrettyScrollPane detailsContentPane = new PrettyScrollPane(detailsPageContentWrapper);
ScrollPane detailsContentPane = new ScrollPane(detailsPageContentWrapper);
detailsContentPane.getStyleClass().add("mobile");
detailsContentPane.setMaxHeight(Double.MAX_VALUE);
VBox.setVgrow(detailsContentPane, Priority.ALWAYS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.dlsc.jfxcentral.data.ImageManager;
import com.dlsc.jfxcentral.data.model.Company;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.components.overviewbox.CompanyOverviewBox;
import com.dlsc.jfxcentral2.mobile.components.LinkedObjectsBox;
import com.dlsc.jfxcentral2.mobile.components.MobilePageHeader;
import com.dlsc.jfxcentral2.model.Size;
import com.dlsc.jfxcentral2.utils.IkonUtil;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;

Expand Down Expand Up @@ -45,7 +46,7 @@ public List<Node> content() {
VBox detailsPageContentWrapper = new VBox(companyOverviewBox, linkedObjectsBox);
detailsPageContentWrapper.getStyleClass().add("details-page-content-wrapper");

PrettyScrollPane detailsContentPane = new PrettyScrollPane(detailsPageContentWrapper);
ScrollPane detailsContentPane = new ScrollPane(detailsPageContentWrapper);
detailsContentPane.getStyleClass().add("mobile");
detailsContentPane.setMaxHeight(Double.MAX_VALUE);
VBox.setVgrow(detailsContentPane, Priority.ALWAYS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.dlsc.jfxcentral2.mobile.pages.details;

import com.dlsc.jfxcentral.data.model.Library;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.components.overviewbox.LibraryOverviewBox;
import com.dlsc.jfxcentral2.mobile.components.LinkedObjectsBox;
import com.dlsc.jfxcentral2.mobile.components.MobilePageHeader;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;

Expand Down Expand Up @@ -41,7 +42,7 @@ public List<Node> content() {
VBox detailsPageContentWrapper = new VBox(libraryOverviewBox, linkedObjectsBox);
detailsPageContentWrapper.getStyleClass().add("details-page-content-wrapper");

PrettyScrollPane detailsContentPane = new PrettyScrollPane(detailsPageContentWrapper);
ScrollPane detailsContentPane = new ScrollPane(detailsPageContentWrapper);
detailsContentPane.getStyleClass().add("mobile");
detailsContentPane.setMaxHeight(Double.MAX_VALUE);
VBox.setVgrow(detailsContentPane, Priority.ALWAYS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.dlsc.jfxcentral2.mobile.pages.details;

import com.dlsc.jfxcentral.data.model.Person;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.mobile.components.MobilePersonDetailView;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
Expand All @@ -25,7 +26,7 @@ public List<Node> content() {
MobilePersonDetailView personDetailView = new MobilePersonDetailView();
personDetailView.setPerson(person);
personDetailView.sizeProperty().bind(sizeProperty());
PrettyScrollPane scrollPane = new PrettyScrollPane(new StackPane(personDetailView));
ScrollPane scrollPane = new ScrollPane(new StackPane(personDetailView));
scrollPane.getStyleClass().add("mobile");
scrollPane.setMaxHeight(Double.MAX_VALUE);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.dlsc.jfxcentral2.mobile.pages.details;

import com.dlsc.jfxcentral.data.model.RealWorldApp;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.components.overviewbox.ShowcaseOverviewBox;
import com.dlsc.jfxcentral2.mobile.components.LinkedObjectsBox;
import com.dlsc.jfxcentral2.mobile.components.MobilePageHeader;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;

import java.util.List;
Expand Down Expand Up @@ -40,7 +41,7 @@ public List<Node> content() {
VBox detailsPageContentWrapper = new VBox(appOverviewBox, linkedObjectsBox);
detailsPageContentWrapper.getStyleClass().add("details-page-content-wrapper");

PrettyScrollPane scrollPane = new PrettyScrollPane(detailsPageContentWrapper);
ScrollPane scrollPane = new ScrollPane(detailsPageContentWrapper);
scrollPane.getStyleClass().add("mobile");

return List.of(header, scrollPane);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.dlsc.jfxcentral2.mobile.pages.details;

import com.dlsc.jfxcentral.data.model.Tip;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;

import com.dlsc.jfxcentral2.components.overviewbox.TipOverviewBox;
import com.dlsc.jfxcentral2.mobile.components.LinkedObjectsBox;
import com.dlsc.jfxcentral2.mobile.components.MobilePageHeader;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;

Expand Down Expand Up @@ -41,12 +42,11 @@ public List<Node> content() {
VBox detailsPageContentWrapper = new VBox(tipOverviewBox, linkedObjectsBox);
detailsPageContentWrapper.getStyleClass().add("details-page-content-wrapper");

PrettyScrollPane detailsContentPane = new PrettyScrollPane(detailsPageContentWrapper);
ScrollPane detailsContentPane = new ScrollPane(detailsPageContentWrapper);
detailsContentPane.getStyleClass().add("mobile");
detailsContentPane.setMaxHeight(Double.MAX_VALUE);
VBox.setVgrow(detailsContentPane, Priority.ALWAYS);


return List.of(header, detailsContentPane);
}
}
Loading

0 comments on commit 9f6b17e

Please sign in to comment.