Skip to content

Commit

Permalink
Add video category and adjust display settings
Browse files Browse the repository at this point in the history
Added a new category for videos in the mobile home page.
  • Loading branch information
leewyatt committed Jul 19, 2024
1 parent 08459ce commit 2426aa2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.Video;
import com.dlsc.jfxcentral2.components.AvatarView;
import com.dlsc.jfxcentral2.components.SizeSupport;
import com.dlsc.jfxcentral2.mobile.home.CategoryPreviewView;
Expand Down Expand Up @@ -121,14 +122,6 @@ private void updatePersonLinkedObjectBox(Person person) {
personLinkedObjectBox.getChildren().add(libraryPreviewView);
}

List<Tip> 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<Book> linkedBooks = getLinkedObjects(person, Book.class);
if (!linkedBooks.isEmpty()) {
CategoryPreviewView booksPreviewView = CategoryPreviewView.createBooksPreviewView(linkedBooks);
Expand All @@ -137,6 +130,22 @@ private void updatePersonLinkedObjectBox(Person person) {
personLinkedObjectBox.getChildren().add(booksPreviewView);
}

List<Video> linkedVideos = getLinkedObjects(person, Video.class);
if (!linkedVideos.isEmpty()) {
CategoryPreviewView videoPreviewView = CategoryPreviewView.createVideosPreviewView(linkedVideos);
videoPreviewView.sizeProperty().bind(sizeProperty());
videoPreviewView.setTitle("Related Videos");
personLinkedObjectBox.getChildren().add(videoPreviewView);
}

List<Tip> 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<Blog> linkedBlogs = getLinkedObjects(person, Blog.class);
if (!linkedBlogs.isEmpty()) {
CategoryPreviewView blogPreviewView = CategoryPreviewView.createBlogPreviewView(linkedBlogs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.Video;
import com.dlsc.jfxcentral2.components.AvatarView;
import com.dlsc.jfxcentral2.components.SizeSupport;
import com.dlsc.jfxcentral2.model.Size;
Expand Down Expand Up @@ -488,4 +489,30 @@ public static CategoryPreviewView createPeoplePreviewView(List<Person> people) {
return createPeoplePreviewView(people, null);
}

public static CategoryPreviewView createVideosPreviewView(List<Video> videos, String showAllUrl) {
CategoryPreviewView view = new CategoryPreviewView();
view.setTitle("Videos");
if (showAllUrl != null) {
view.setShowAllUrl(showAllUrl);
}

List<CategoryPreviewView.CategoryItem> items = new ArrayList<>();
for (Video video : videos) {
CategoryPreviewView.CategoryItem item = new CategoryPreviewView.CategoryItem(
video.getName(),
video.getDescription(),
ImageManager.getInstance().youTubeImageProperty(video),
ModelObjectTool.getModelLink(video)
);
items.add(item);
}

view.getItems().setAll(items);
return view;
}

public static CategoryPreviewView createVideosPreviewView(List<Video> videos) {
return createVideosPreviewView(videos, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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.Video;
import com.dlsc.jfxcentral2.components.PrettyScrollPane;
import com.dlsc.jfxcentral2.components.SizeSupport;
import com.dlsc.jfxcentral2.mobile.components.MobileSearchView;
Expand Down Expand Up @@ -117,7 +118,7 @@ private Node createNormalView() {
CategoryPreviewView showCasePreviewView = CategoryPreviewView.createShowCasePreviewView(randomApps, PagePath.SHOWCASES);
showCasePreviewView.sizeProperty().bind(sizeProperty());

List<Tip> randomTips = getRandomSample(DataRepository2.getInstance().getTips(), 3);
List<Tip> randomTips = getRandomSample(DataRepository2.getInstance().getTips(), 2);
CategoryPreviewView tipsPreviewView = CategoryPreviewView.createTipsPreviewView(randomTips, PagePath.TIPS);
tipsPreviewView.sizeProperty().bind(sizeProperty());

Expand All @@ -133,11 +134,15 @@ private Node createNormalView() {
CategoryPreviewView libraryPreviewView = CategoryPreviewView.createLibraryPreviewView(randomLibraries, PagePath.LIBRARIES);
libraryPreviewView.sizeProperty().bind(sizeProperty());

List<Blog> randomBlogs = getRandomSample(DataRepository2.getInstance().getBlogs(), 3);
List<Video> randomVideos = getRandomSample(DataRepository2.getInstance().getVideos(), 3);
CategoryPreviewView videoPreviewView = CategoryPreviewView.createVideosPreviewView(randomVideos, PagePath.VIDEOS);
videoPreviewView.sizeProperty().bind(sizeProperty());

List<Blog> randomBlogs = getRandomSample(DataRepository2.getInstance().getBlogs(), 2);
CategoryPreviewView blogPreviewView = CategoryPreviewView.createBlogPreviewView(randomBlogs, PagePath.BLOGS);
blogPreviewView.sizeProperty().bind(sizeProperty());

VBox normalView = new VBox(categoryAdvancedView, weekLinksView, showCasePreviewView, peoplePreviewView, libraryPreviewView, booksPreviewView, blogPreviewView, tipsPreviewView);
VBox normalView = new VBox(categoryAdvancedView, weekLinksView, showCasePreviewView, peoplePreviewView, libraryPreviewView, booksPreviewView, videoPreviewView, blogPreviewView, tipsPreviewView);
normalView.getStyleClass().add("content-box");

PrettyScrollPane prettyScrollPane = new PrettyScrollPane(normalView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@
}

.category-preview-view > .content > .category-cell .cell-content {
-fx-spacing: 5px;
-fx-spacing: 3px;
}

.category-preview-view > .content > .category-cell .cell-content > .title {
-fx-font-family: "Roboto Condensed";
-fx-font-weight: bold;
-fx-font-size: 18px;
-fx-font-size: 15px;
-fx-text-fill: -grey-100;
-fx-padding: 2px 0 2px 0;
}
Expand All @@ -347,7 +347,7 @@
-fx-font-family: "Roboto Condensed";
-fx-text-fill: -grey-60;
-fx-alignment: top-left;
-fx-font-size: 15px;
-fx-font-size: 13px;
}

.category-preview-view:md > .content > .category-cell .cell-content > .description {
Expand Down

0 comments on commit 2426aa2

Please sign in to comment.