Skip to content

Commit

Permalink
Merge pull request #648 from dlsc-software-consulting-gmbh/develop
Browse files Browse the repository at this point in the history
New mobile version.
  • Loading branch information
dlemmermann authored Jul 26, 2024
2 parents 575095a + 53b6679 commit 860e6b5
Show file tree
Hide file tree
Showing 67 changed files with 3,637 additions and 902 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.dlsc.jfxcentral.data.model.Tutorial;
import com.dlsc.jfxcentral.data.model.Video;
import com.dlsc.jfxcentral2.app.pages.MobileRefreshPage;
import com.dlsc.jfxcentral2.events.OpenWebLinkEvent;
import com.dlsc.jfxcentral2.events.RepositoryUpdatedEvent;
import com.dlsc.jfxcentral2.mobile.components.BottomMenuBar;
import com.dlsc.jfxcentral2.mobile.components.MobileDevelopToolBar;
Expand All @@ -25,6 +26,7 @@
import com.dlsc.jfxcentral2.mobile.pages.category.MobileBlogsCategoryPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileBooksCategoryPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileCompaniesCategoryPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileDocPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileLearnJavaFXCategoryPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileLearnMobileCategoryPage;
import com.dlsc.jfxcentral2.mobile.pages.category.MobileLearnRaspberryPiCategoryPage;
Expand All @@ -49,11 +51,14 @@
import com.dlsc.jfxcentral2.model.Size;
import com.dlsc.jfxcentral2.utils.EventBusUtil;
import com.dlsc.jfxcentral2.utils.MobileLinkUtil;
import com.dlsc.jfxcentral2.utils.MobileResponse;
import com.dlsc.jfxcentral2.utils.MobileRoute;
import com.dlsc.jfxcentral2.utils.MobileRouter;
import com.dlsc.jfxcentral2.utils.NodeUtil;
import com.dlsc.jfxcentral2.utils.OSUtil;
import com.dlsc.jfxcentral2.utils.PagePath;
import com.dlsc.jfxcentral2.utils.Subscribe;
import com.gluonhq.attach.browser.BrowserService;
import com.gluonhq.attach.display.DisplayService;
import fr.brouillard.oss.cssfx.CSSFX;
import javafx.application.Application;
Expand All @@ -70,6 +75,8 @@
import javafx.util.Callback;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Locale;
import java.util.Objects;
import java.util.function.Supplier;
Expand Down Expand Up @@ -148,6 +155,22 @@ public void onRepositoryUpdated(RepositoryUpdatedEvent event) {
notchPane.setManaged(event.isUpdated());
}

@Subscribe
public void onOpenWebLink(OpenWebLinkEvent event) {
String link = event.link();
if (OSUtil.isNative()) {
BrowserService.create().ifPresent(service -> {
try {
service.launchExternalBrowser(link);
} catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
});
} else {
getHostServices().showDocument(link);
}
}

private void updateSizeProperty(Scene scene) {
double sceneWidth = scene.getWidth();
if (sceneWidth < 760) {
Expand All @@ -165,15 +188,18 @@ private MobileRouter createMobileRouter() {
boolean repositoryUpdated = RepositoryManager.isRepositoryUpdated();
EventBusUtil.post(new RepositoryUpdatedEvent(repositoryUpdated));
if (repositoryUpdated) {
return new MobileHomePage(size);
MobileHomePage mobileHomePage = MobileHomePage.getInstance();
mobileHomePage.sizeProperty().bind(size);
return MobileResponse.view(r, mobileHomePage);
} else {
return new MobileRefreshPage(size);
return MobileResponse.redirect(r, PagePath.REFRESH);
}
}))
.and(MobileRoute.get(PagePath.REFRESH, r -> new MobileRefreshPage(size)))
.and(MobileRoute.get(PagePath.REFRESH, r -> MobileResponse.view(r, new MobileRefreshPage(size))))
.and(MobileRoute.redirect("/index", PagePath.HOME))
.and(MobileRoute.redirect("/home", PagePath.HOME))
.and(MobileRoute.get(PagePath.LINKS, r -> new MobileLinksOfTheWeekPage(size)))
.and(MobileRoute.get(PagePath.LINKS, r -> MobileResponse.view(r, new MobileLinksOfTheWeekPage(size))))
.and(MobileRoute.get(PagePath.DOCUMENTATION, r -> MobileResponse.view(r, new MobileDocPage(size))))
.and(createCategoryOrDetailRoute(PagePath.SHOWCASES, RealWorldApp.class, () -> new MobileShowcasesCategoryPage(size), id -> new MobileShowcaseMobileDetailsPage(size, id)))
.and(createCategoryOrDetailRoute(PagePath.REAL_WORLD, RealWorldApp.class, () -> new MobileShowcasesCategoryPage(size), id -> new MobileShowcaseMobileDetailsPage(size, id)))
.and(createCategoryOrDetailRoute(PagePath.LIBRARIES, Library.class, () -> new MobileLibrariesCategoryPage(size), id -> new MobileLibraryDetailsPage(size, id)))
Expand All @@ -196,13 +222,12 @@ private MobileRoute createCategoryOrDetailRoute(String path, Class<? extends Mod
if (index > 0 && clazz != null) {
String id = url.substring(index + 1).trim();
if (!DataRepository2.getInstance().isValidId(clazz, id)) {
return new Label("Error: 404");
return MobileResponse.view(url, new Label("Error: 404"));
}
return detailedResponse.call(id);
return MobileResponse.view(url, detailedResponse.call(id));
}
return categoryResponse.get();
return MobileResponse.view(url, categoryResponse.get());
});

}

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.dlsc.jfxcentral2.app.RepositoryManager;
import com.dlsc.jfxcentral2.app.utils.RepositoryUpdater;
import com.dlsc.jfxcentral2.components.CustomImageView;
import com.dlsc.jfxcentral2.mobile.components.WelcomePageView;
import com.dlsc.jfxcentral2.mobile.components.IntroPane;
import com.dlsc.jfxcentral2.model.Size;
import com.dlsc.jfxcentral2.utils.MobileLinkUtil;
import com.dlsc.jfxcentral2.utils.PagePath;
Expand Down Expand Up @@ -44,12 +44,15 @@ public MobileRefreshPage(ObjectProperty<Size> size) {
invalidationListener.invalidated(null);
});

// top part
WelcomePageView welcomePageView = new WelcomePageView();
StackPane topBox = new StackPane(welcomePageView);
topBox.getStyleClass().add("top-box");
// top part (logo)
CustomImageView logo = new CustomImageView();
logo.getStyleClass().addAll("jfx-central-logo", "color");

Label loadLabel = new Label("Progress download github repository. 38%");
// center part (intro pane)
IntroPane introPane = new IntroPane();
VBox.setVgrow(introPane, Priority.ALWAYS);

Label loadLabel = new Label();
loadLabel.getStyleClass().add("load-label");
loadLabel.setManaged(false);
loadLabel.setVisible(false);
Expand Down Expand Up @@ -79,24 +82,10 @@ public MobileRefreshPage(ObjectProperty<Size> size) {
repositoryUpdater.performUpdate(false);
});

Label welcomeLabel = new Label("Welcome to JFXCentral");
welcomeLabel.getStyleClass().add("welcome-label");
welcomeLabel.managedProperty().bind(welcomeLabel.visibleProperty());
welcomeLabel.visibleProperty().bind(startButton.visibleProperty().not());

Label descLabel = new Label("Home to anything related to JavaFX.");
descLabel.getStyleClass().add("desc-label");
descLabel.managedProperty().bind(descLabel.visibleProperty());
descLabel.visibleProperty().bind(startButton.visibleProperty().not());

VBox bottomBox = new VBox(welcomeLabel, descLabel, startButton, loadLabel);
VBox bottomBox = new VBox(startButton, loadLabel);
bottomBox.getStyleClass().add("bottom-box");
VBox.setVgrow(bottomBox, Priority.ALWAYS);

CustomImageView logo = new CustomImageView();
logo.getStyleClass().addAll("jfx-central-logo", "color");

VBox content = new VBox(topBox, bottomBox, logo);
VBox content = new VBox(logo, introPane, bottomBox);
content.getStyleClass().add("content-box");
getChildren().add(content);

Expand Down
Loading

0 comments on commit 860e6b5

Please sign in to comment.