diff --git a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobilePersonDetailView.java b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobilePersonDetailView.java index 061e9a8b..a8919fd5 100644 --- a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobilePersonDetailView.java +++ b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobilePersonDetailView.java @@ -2,18 +2,17 @@ import com.dlsc.jfxcentral.data.DataRepository2; import com.dlsc.jfxcentral.data.ImageManager; +import com.dlsc.jfxcentral.data.model.Blog; import com.dlsc.jfxcentral.data.model.Book; -import com.dlsc.jfxcentral.data.model.Learn; -import com.dlsc.jfxcentral.data.model.LearnJavaFX; -import com.dlsc.jfxcentral.data.model.LearnMobile; -import com.dlsc.jfxcentral.data.model.LearnRaspberryPi; import com.dlsc.jfxcentral.data.model.Library; +import com.dlsc.jfxcentral.data.model.ModelObject; import com.dlsc.jfxcentral.data.model.Person; import com.dlsc.jfxcentral.data.model.RealWorldApp; import com.dlsc.jfxcentral.data.model.Tip; -import com.dlsc.jfxcentral.data.model.Tool; -import com.dlsc.jfxcentral.data.model.Video; import com.dlsc.jfxcentral2.components.AvatarView; +import com.dlsc.jfxcentral2.components.SizeSupport; +import com.dlsc.jfxcentral2.mobile.home.CategoryPreviewView; +import com.dlsc.jfxcentral2.model.Size; import com.dlsc.jfxcentral2.utils.IkonUtil; import com.dlsc.jfxcentral2.utils.MobileLinkUtil; import javafx.beans.property.ObjectProperty; @@ -24,7 +23,6 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; -import javafx.scene.layout.TilePane; import javafx.scene.layout.VBox; import org.kordamp.ikonli.Ikon; import org.kordamp.ikonli.fontawesome.FontAwesome; @@ -35,11 +33,12 @@ public class MobilePersonDetailView extends VBox { private static final String DEFAULT_STYLE_CLASS = "mobile-person-detail-view"; - private final TilePane linkedObjectsPane; + private final SizeSupport sizeSupport = new SizeSupport(this); private final AvatarView avatarView; private final Label nameLabel; private final HBox badgeBox; private final Label descriptionLabel; + private final VBox personLinkedObjectBox; public record LinkedObjectBadge(String name, Ikon ikon, int count) { } @@ -67,10 +66,10 @@ public MobilePersonDetailView() { descriptionLabel.getStyleClass().add("description"); descriptionLabel.setWrapText(true); - linkedObjectsPane = new TilePane(); - linkedObjectsPane.getStyleClass().add("linked-objects-pane"); + personLinkedObjectBox = new VBox(); + personLinkedObjectBox.getStyleClass().add("person-linked-box"); - VBox personContentBox = new VBox(nameLabel, badgeBox, descriptionLabel, linkedObjectsPane); + VBox personContentBox = new VBox(nameLabel, badgeBox, descriptionLabel, personLinkedObjectBox); personContentBox.getStyleClass().add("person-content-box"); getChildren().addAll(topPane, personContentBox); @@ -82,27 +81,79 @@ public MobilePersonDetailView() { private void updateView() { Person person = getPerson(); - // reset the view + // reset the avatar image if (avatarView.imageProperty().isBound()) { avatarView.imageProperty().unbind(); } - nameLabel.setText(""); - descriptionLabel.setText(""); - badgeBox.getChildren().clear(); - linkedObjectsPane.getChildren().clear(); - - // update the view if (person != null) { avatarView.imageProperty().bind(ImageManager.getInstance().personImageProperty(person)); - nameLabel.setText(person.getName()); - descriptionLabel.setText(DataRepository2.getInstance().getPersonReadMe(person)); - updateLinkedObjectBadges(); - updateBadge(); } + + // reset the text + nameLabel.setText(person == null ? "" : person.getName()); + descriptionLabel.setText(person == null ? "" : DataRepository2.getInstance().getPersonReadMe(person)); + + // reset the boxes + updateBadge(); + updatePersonLinkedObjectBox(); + } + + private void updatePersonLinkedObjectBox() { + personLinkedObjectBox.getChildren().clear(); + Person person = getPerson(); + if (person == null) { + return; + } + + List linkedApps = getLinkedObjects(person, RealWorldApp.class); + if (!linkedApps.isEmpty()) { + CategoryPreviewView showCasePreviewView = CategoryPreviewView.createShowCasePreviewView(linkedApps); + showCasePreviewView.sizeProperty().bind(sizeProperty()); + showCasePreviewView.setTitle("Related Apps"); + personLinkedObjectBox.getChildren().add(showCasePreviewView); + } + + List linkedLibraries = getLinkedObjects(person, Library.class); + if (!linkedLibraries.isEmpty()) { + CategoryPreviewView libraryPreviewView = CategoryPreviewView.createLibraryPreviewView(linkedLibraries); + libraryPreviewView.sizeProperty().bind(sizeProperty()); + libraryPreviewView.setTitle("Related Libraries"); + personLinkedObjectBox.getChildren().add(libraryPreviewView); + } + + List linkedTips = getLinkedObjects(person, Tip.class); + if (!linkedTips.isEmpty()) { + CategoryPreviewView tipsPreviewView = CategoryPreviewView.createTipsPreviewView(linkedTips); + tipsPreviewView.sizeProperty().bind(sizeProperty()); + tipsPreviewView.setTitle("Related Tips"); + personLinkedObjectBox.getChildren().add(tipsPreviewView); + } + + List linkedBooks = getLinkedObjects(person, Book.class); + if (!linkedBooks.isEmpty()) { + CategoryPreviewView booksPreviewView = CategoryPreviewView.createBooksPreviewView(linkedBooks); + booksPreviewView.sizeProperty().bind(sizeProperty()); + booksPreviewView.setTitle("Related Books"); + personLinkedObjectBox.getChildren().add(booksPreviewView); + } + + List linkedBlogs = getLinkedObjects(person, Blog.class); + if (!linkedBlogs.isEmpty()) { + CategoryPreviewView blogPreviewView = CategoryPreviewView.createBlogPreviewView(linkedBlogs); + blogPreviewView.sizeProperty().bind(sizeProperty()); + blogPreviewView.setTitle("Related Blogs"); + personLinkedObjectBox.getChildren().add(blogPreviewView); + } + + // learn part } private void updateBadge() { + badgeBox.getChildren().clear(); Person person = getPerson(); + if (person == null) { + return; + } if (person.isChampion()) { Label championBadge = new Label("Rockstar", new FontIcon(IkonUtil.champion)); championBadge.getStyleClass().addAll("badge-item", "rockstar"); @@ -118,39 +169,26 @@ private void updateBadge() { } } - protected void updateLinkedObjectBadges() { - Person person = getPerson(); - DataRepository2 dataRepository = DataRepository2.getInstance(); - List linkedObjectBadge = List.of( - new LinkedObjectBadge("Apps", IkonUtil.getModelIkon(RealWorldApp.class), dataRepository.getLinkedObjects(person, RealWorldApp.class).size()), - new LinkedObjectBadge("Books", IkonUtil.getModelIkon(Book.class), dataRepository.getLinkedObjects(person, Book.class).size()), - new LinkedObjectBadge("Libraries", IkonUtil.getModelIkon(Library.class), dataRepository.getLinkedObjects(person, Library.class).size()), - new LinkedObjectBadge("Tools", IkonUtil.getModelIkon(Tool.class), dataRepository.getLinkedObjects(person, Tool.class).size()), - new LinkedObjectBadge("Videos", IkonUtil.getModelIkon(Video.class), dataRepository.getLinkedObjects(person, Video.class).size()), - new LinkedObjectBadge("Tips", IkonUtil.getModelIkon(Tip.class), dataRepository.getLinkedObjects(person, Tip.class).size()), - new LinkedObjectBadge("Learn", IkonUtil.getModelIkon(Learn.class), - dataRepository.getLinkedObjects(person, LearnJavaFX.class).size() - + dataRepository.getLinkedObjects(person, LearnMobile.class).size() - + dataRepository.getLinkedObjects(person, LearnRaspberryPi.class).size() - )); - - linkedObjectBadge.stream().filter(item -> item.count() > 0).forEach(item -> { - Label label = new Label(item.name()); - label.getStyleClass().add("linked-badge"); - linkedObjectsPane.getChildren().add(label); - - Label numberLabel = new Label(String.valueOf(item.count())); - numberLabel.getStyleClass().add("number-label"); - StackPane.setAlignment(numberLabel, Pos.TOP_RIGHT); - FontIcon icon = new FontIcon(item.ikon()); - - StackPane graphic = new StackPane(icon, numberLabel); - graphic.getStyleClass().add("badge-icon-wrapper"); - - label.setGraphic(graphic); - }); + private List getLinkedObjects(Person person, Class type) { + return DataRepository2.getInstance().getLinkedObjects(person, type); } + // Size + + public final ObjectProperty sizeProperty() { + return sizeSupport.sizeProperty(); + } + + public final void setSize(Size size) { + sizeSupport.setSize(size); + } + + public final Size getSize() { + return sizeSupport.getSize(); + } + + // person + private final ObjectProperty person = new SimpleObjectProperty<>(this, "person"); public final ObjectProperty personProperty() { diff --git a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/home/CategoryPreviewView.java b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/home/CategoryPreviewView.java index ce12d6a8..eb177f61 100644 --- a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/home/CategoryPreviewView.java +++ b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/home/CategoryPreviewView.java @@ -1,9 +1,18 @@ package com.dlsc.jfxcentral2.mobile.home; import com.dlsc.gemsfx.Spacer; +import com.dlsc.jfxcentral.data.DataRepository2; +import com.dlsc.jfxcentral.data.ImageManager; +import com.dlsc.jfxcentral.data.model.Blog; +import com.dlsc.jfxcentral.data.model.Book; +import com.dlsc.jfxcentral.data.model.Library; +import com.dlsc.jfxcentral.data.model.Person; +import com.dlsc.jfxcentral.data.model.RealWorldApp; +import com.dlsc.jfxcentral.data.model.Tip; import com.dlsc.jfxcentral2.components.AvatarView; import com.dlsc.jfxcentral2.components.SizeSupport; import com.dlsc.jfxcentral2.model.Size; +import com.dlsc.jfxcentral2.utils.ModelObjectTool; import com.dlsc.jfxcentral2.utils.PlatformLinkUtil; import com.dlsc.jfxcentral2.utils.SocialUtil; import javafx.beans.binding.Bindings; @@ -26,6 +35,9 @@ import javafx.scene.layout.VBox; import org.kordamp.ikonli.javafx.FontIcon; +import java.util.ArrayList; +import java.util.List; + public class CategoryPreviewView extends VBox { private static final String DEFAULT_STYLE_CLASS = "category-preview-view"; @@ -42,6 +54,8 @@ public CategoryPreviewView() { moreButton = new Button("More", new FontIcon("mdi-chevron-right")); moreButton.getStyleClass().add("more-button"); + moreButton.managedProperty().bind(moreButton.visibleProperty()); + moreButton.visibleProperty().bind(showAllUrlProperty().isNotEmpty()); HBox header = new HBox(titleLabel, new Spacer(), moreButton); header.getStyleClass().add("header"); @@ -204,7 +218,7 @@ public CategoryCell() { footer.managedProperty().bind(footer.visibleProperty()); footer.setVisible(SocialUtil.isSocialFeaturesEnabled()); pseudoClassStateChanged(SOCIAL_FEATURES_ENABLED, footer.isVisible()); - footer.visibleProperty().addListener(it-> pseudoClassStateChanged(SOCIAL_FEATURES_ENABLED, footer.isVisible())); + footer.visibleProperty().addListener(it -> pseudoClassStateChanged(SOCIAL_FEATURES_ENABLED, footer.isVisible())); VBox cellContent = new VBox(titleLabel, descriptionLabel, footer); cellContent.getStyleClass().add("cell-content"); @@ -319,4 +333,159 @@ public final void setViewsNumber(int viewsNumber) { viewsNumberProperty().set(viewsNumber); } } + + public static CategoryPreviewView createBlogPreviewView(List blogs, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("Blog"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + + List items = new ArrayList<>(); + for (Blog blog : blogs) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + blog.getName(), + blog.getSummary(), + ImageManager.getInstance().blogIconImageProperty(blog), + ModelObjectTool.getModelLink(blog) + ); + items.add(item); + } + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createBlogPreviewView(List blogs) { + return createBlogPreviewView(blogs, null); + } + + public static CategoryPreviewView createShowCasePreviewView(List apps, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("Real World Apps"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + + List items = new ArrayList<>(); + for (RealWorldApp app : apps) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + app.getName(), + app.getSummary(), + ImageManager.getInstance().realWorldAppBannerImageProperty(app), + ModelObjectTool.getModelLink(app) + ); + items.add(item); + } + + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createShowCasePreviewView(List apps) { + return createShowCasePreviewView(apps, null); + } + + public static CategoryPreviewView createTipsPreviewView(List tips, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("Tips"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + + List items = new ArrayList<>(); + for (Tip tip : tips) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + tip.getName(), + tip.getSummary(), + ImageManager.getInstance().tipBannerImageProperty(tip), + ModelObjectTool.getModelLink(tip) + ); + items.add(item); + } + + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createTipsPreviewView(List tips) { + return createTipsPreviewView(tips, null); + } + + public static CategoryPreviewView createBooksPreviewView(List books, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("Books"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + List items = new ArrayList<>(); + + for (Book book : books) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + book.getName(), + book.getSummary(), + ImageManager.getInstance().bookCoverImageProperty(book), + ModelObjectTool.getModelLink(book) + ); + items.add(item); + } + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createBooksPreviewView(List books) { + return createBooksPreviewView(books, null); + } + + public static CategoryPreviewView createLibraryPreviewView(List libraries, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("Libraries"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + + List items = new ArrayList<>(); + for (Library library : libraries) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + library.getName(), + library.getSummary(), + ImageManager.getInstance().libraryFeaturedImageProperty(library), + ModelObjectTool.getModelLink(library) + ); + items.add(item); + } + + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createLibraryPreviewView(List libraries) { + return createLibraryPreviewView(libraries, null); + } + + public static CategoryPreviewView createPeoplePreviewView(List people, String showAllUrl) { + CategoryPreviewView view = new CategoryPreviewView(); + view.setTitle("People"); + if (showAllUrl != null) { + view.setShowAllUrl(showAllUrl); + } + + List items = new ArrayList<>(); + for (Person person : people) { + CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( + person.getName(), + DataRepository2.getInstance().getPersonReadMe(person), + ImageManager.getInstance().personImageProperty(person), + ModelObjectTool.getModelLink(person) + ); + items.add(item); + } + + view.getItems().setAll(items); + return view; + } + + public static CategoryPreviewView createPeoplePreviewView(List people) { + return createPeoplePreviewView(people, null); + } + } diff --git a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/MobileHomePage.java b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/MobileHomePage.java index d1178304..7a2de634 100644 --- a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/MobileHomePage.java +++ b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/MobileHomePage.java @@ -2,7 +2,6 @@ import com.dlsc.gemsfx.SearchTextField; import com.dlsc.jfxcentral.data.DataRepository2; -import com.dlsc.jfxcentral.data.ImageManager; import com.dlsc.jfxcentral.data.model.Blog; import com.dlsc.jfxcentral.data.model.Book; import com.dlsc.jfxcentral.data.model.Library; @@ -19,7 +18,6 @@ import com.dlsc.jfxcentral2.mobile.home.HomePageHeader; import com.dlsc.jfxcentral2.mobile.home.WeekLinksView; import com.dlsc.jfxcentral2.model.Size; -import com.dlsc.jfxcentral2.utils.ModelObjectTool; import com.dlsc.jfxcentral2.utils.PagePath; import javafx.beans.binding.Bindings; import javafx.beans.property.ObjectProperty; @@ -39,9 +37,7 @@ public class MobileHomePage extends VBox { private static MobileHomePage instance; private final SizeSupport sizeSupport = new SizeSupport(this); - private final Node normalView; - private final MobileSearchView searchView; - private SearchTextField searchTextField; + private final SearchTextField searchTextField; public enum ContentType { NORMAL, SEARCH @@ -58,11 +54,11 @@ private MobileHomePage() { getStyleClass().add("mobile-home-page"); // content - normalView = createNormalView(); + Node normalView = createNormalView(); normalView.managedProperty().bind(normalView.visibleProperty()); VBox.setVgrow(normalView, Priority.ALWAYS); - searchView = new MobileSearchView(sizeProperty()); + MobileSearchView searchView = new MobileSearchView(sizeProperty()); searchView.managedProperty().bind(searchView.visibleProperty()); searchView.visibleProperty().bind(Bindings.createBooleanBinding(() -> getContentType() == ContentType.SEARCH, contentTypeProperty())); normalView.visibleProperty().bind(searchView.visibleProperty().not()); @@ -117,22 +113,28 @@ private Node createNormalView() { weekLinksView.sizeProperty().bind(sizeProperty()); weekLinksView.setLinksOfTheWeek(linksOfTheWeek.get(linksOfTheWeek.size() - 1)); - CategoryPreviewView showCasePreviewView = createShowCasePreviewView(); + List randomApps = getRandomSample(DataRepository2.getInstance().getRealWorldApps(), 3); + CategoryPreviewView showCasePreviewView = CategoryPreviewView.createShowCasePreviewView(randomApps, PagePath.SHOWCASES); showCasePreviewView.sizeProperty().bind(sizeProperty()); - CategoryPreviewView tipsPreviewView = createTipsPreviewView(); + List randomTips = getRandomSample(DataRepository2.getInstance().getTips(), 3); + CategoryPreviewView tipsPreviewView = CategoryPreviewView.createTipsPreviewView(randomTips, PagePath.TIPS); tipsPreviewView.sizeProperty().bind(sizeProperty()); - CategoryPreviewView peoplePreviewView = createPeoplePreviewView(); + List randomPeople = getRandomSample(DataRepository2.getInstance().getPeople(), 3); + CategoryPreviewView peoplePreviewView = CategoryPreviewView.createPeoplePreviewView(randomPeople, PagePath.PEOPLE); peoplePreviewView.sizeProperty().bind(sizeProperty()); - CategoryPreviewView booksPreviewView = createBooksPreviewView(); + List randomBooks = getRandomSample(DataRepository2.getInstance().getBooks(), 3); + CategoryPreviewView booksPreviewView = CategoryPreviewView.createBooksPreviewView(randomBooks, PagePath.BOOKS); booksPreviewView.sizeProperty().bind(sizeProperty()); - CategoryPreviewView libraryPreviewView = createLibraryPreviewView(); + List randomLibraries = getRandomSample(DataRepository2.getInstance().getLibraries(), 3); + CategoryPreviewView libraryPreviewView = CategoryPreviewView.createLibraryPreviewView(randomLibraries, PagePath.LIBRARIES); libraryPreviewView.sizeProperty().bind(sizeProperty()); - CategoryPreviewView blogPreviewView = createBlogPreviewView(); + List randomBlogs = getRandomSample(DataRepository2.getInstance().getBlogs(), 3); + CategoryPreviewView blogPreviewView = CategoryPreviewView.createBlogPreviewView(randomBlogs, PagePath.BLOGS); blogPreviewView.sizeProperty().bind(sizeProperty()); VBox normalView = new VBox(categoryAdvancedView, weekLinksView, showCasePreviewView, peoplePreviewView, libraryPreviewView, booksPreviewView, blogPreviewView, tipsPreviewView); @@ -144,82 +146,7 @@ private Node createNormalView() { return prettyScrollPane; } - private CategoryPreviewView createBlogPreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("Blog"); - view.setShowAllUrl(PagePath.BLOGS); - List items = new ArrayList<>(); - List blogs = DataRepository2.getInstance().getBlogs(); - - List randomBlogs = getRandomSample(blogs, 2); - for (Blog blog : randomBlogs) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - blog.getName(), - blog.getSummary(), - ImageManager.getInstance().blogIconImageProperty(blog), - ModelObjectTool.getModelLink(blog), - 123, - 57, - 2048 - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - - private CategoryPreviewView createLibraryPreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("Libraries"); - view.setShowAllUrl(PagePath.LIBRARIES); - List items = new ArrayList<>(); - List books = DataRepository2.getInstance().getLibraries(); - - List randomBooks = getRandomSample(books, 3); - for (Library library : randomBooks) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - library.getName(), - library.getSummary(), - ImageManager.getInstance().libraryFeaturedImageProperty(library), - ModelObjectTool.getModelLink(library), - 123, - 57, - 2048 - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - - private CategoryPreviewView createBooksPreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("Books"); - view.setShowAllUrl(PagePath.BOOKS); - List items = new ArrayList<>(); - List books = DataRepository2.getInstance().getBooks(); - - List randomBooks = getRandomSample(books, 2); - for (Book book : randomBooks) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - book.getName(), - book.getSummary(), - ImageManager.getInstance().bookCoverImageProperty(book), - ModelObjectTool.getModelLink(book), - 123, - 57, - 2048 - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - - // Size support + // Size public final ObjectProperty sizeProperty() { return sizeSupport.sizeProperty(); @@ -233,83 +160,6 @@ public final Size getSize() { return sizeSupport.getSize(); } - private CategoryPreviewView createShowCasePreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("Real World Apps"); - view.setShowAllUrl(PagePath.SHOWCASES); - List items = new ArrayList<>(); - List apps = DataRepository2.getInstance().getRealWorldApps(); - - List randomApps = getRandomSample(apps, 3); - for (RealWorldApp app : randomApps) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - app.getName(), - app.getSummary(), - ImageManager.getInstance().realWorldAppBannerImageProperty(app), - ModelObjectTool.getModelLink(app), - 123, - 57, - 2048 - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - - private CategoryPreviewView createPeoplePreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("People"); - view.setShowAllUrl(PagePath.PEOPLE); - List items = new ArrayList<>(); - List people = DataRepository2.getInstance().getPeople(); - - List randomPeople = getRandomSample(people, 3); - for (Person person : randomPeople) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - person.getName(), - DataRepository2.getInstance().getPersonReadMe(person), - ImageManager.getInstance().personImageProperty(person), - ModelObjectTool.getModelLink(person), - 399, - 258, - 3096 - - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - - private CategoryPreviewView createTipsPreviewView() { - CategoryPreviewView view = new CategoryPreviewView(); - view.setTitle("Tips"); - view.setShowAllUrl(PagePath.TIPS); - List items = new ArrayList<>(); - List tips = DataRepository2.getInstance().getTips(); - - List randomTips = getRandomSample(tips, 2); - for (Tip tip : randomTips) { - CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem( - tip.getName(), - tip.getSummary(), - ImageManager.getInstance().tipBannerImageProperty(tip), - ModelObjectTool.getModelLink(tip), - 123, - 57, - 2048 - - ); - items.add(item); - } - - view.getItems().setAll(items); - return view; - } - private List getRandomSample(List list, int sampleSize) { if (sampleSize > list.size()) { throw new IllegalArgumentException("Sample size must be less than or equal to the size of the list"); diff --git a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/details/MobilePersonDetailsPage.java b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/details/MobilePersonDetailsPage.java index 80e3b165..f4052934 100644 --- a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/details/MobilePersonDetailsPage.java +++ b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/pages/details/MobilePersonDetailsPage.java @@ -24,6 +24,7 @@ public List content() { MobilePersonDetailView personDetailView = new MobilePersonDetailView(); personDetailView.setPerson(person); + personDetailView.sizeProperty().bind(sizeProperty()); PrettyScrollPane scrollPane = new PrettyScrollPane(new StackPane(personDetailView)); scrollPane.getStyleClass().add("mobile"); scrollPane.setMaxHeight(Double.MAX_VALUE); diff --git a/mobile/src/main/resources/com/dlsc/jfxcentral2/mobile/mobile.css b/mobile/src/main/resources/com/dlsc/jfxcentral2/mobile/mobile.css index a40edebe..06e135ec 100644 --- a/mobile/src/main/resources/com/dlsc/jfxcentral2/mobile/mobile.css +++ b/mobile/src/main/resources/com/dlsc/jfxcentral2/mobile/mobile.css @@ -1099,7 +1099,7 @@ } .mobile-person-detail-view > .top-pane { - -fx-padding: 5px 0 0 0; + -fx-padding: 7px 0 0 0; -fx-background-color: linear-gradient(from 0% 0% to 0% 100%, rgba(247, 249, 255, 1) 0%, rgba(247, 249, 255, 0) 100%); } @@ -1107,6 +1107,7 @@ -fx-border-color: -white; -fx-border-radius: 50%; -fx-border-width: 2px; + -fx-avatar-size: 60px; -fx-effect: dropshadow(three-pass-box, rgb(125, 125, 125, 0.6), 5, 0, 0, 0); } @@ -1139,45 +1140,11 @@ -fx-padding: 5px 20px; -fx-text-alignment: center; -fx-font-family: "Spline Sans"; - -fx-text-fill: #444; - -fx-font-size: 15px; -} - -.mobile-person-detail-view > .person-content-box > .linked-objects-pane { - -fx-alignment: center; - -fx-hgap: 3px; - -fx-vgap: 8px; - -fx-padding: 5px; -} - -.mobile-person-detail-view > .person-content-box > .linked-objects-pane .linked-badge { - -fx-font-family: "Spline Sans Medium"; - -fx-font-size: 15px; - -fx-content-display: top; - -fx-graphic-text-gap: 5px; - -fx-alignment: center; - -fx-text-fill: #666; -} - -.mobile-person-detail-view > .person-content-box > .linked-objects-pane .linked-badge .ikonli-font-icon { - -fx-icon-size: 28px; -} - -.mobile-person-detail-view > .person-content-box .linked-objects-pane .number-label { - -fx-background-color: rgba(149, 182, 245, 0.88); - -fx-pref-width: 20px; - -fx-pref-height: 20px; - -fx-background-radius: 20px; - -fx-alignment: center; - -fx-text-fill: -white; - visibility: hidden; - -fx-translate-x: 10px; - -fx-translate-y: -2px; + -fx-text-fill: #555; + -fx-font-size: 14px; } -.mobile-person-detail-view .badge-icon-wrapper { - -fx-background-color: #f5f5f5; - -fx-pref-width: 50px; - -fx-pref-height: 50px; - -fx-background-radius: 35px; +.mobile-person-detail-view > .person-content-box .person-linked-box { + -fx-padding: 5px 15px; + -fx-spacing: 15px; } \ No newline at end of file