Skip to content

Commit

Permalink
Update refresh page navigation logic and UI adjustments
Browse files Browse the repository at this point in the history
Refactor `MobileRefreshPage` to use a boolean flag for home page navigation and ensure consistent repository update checks. Adjust padding and image size in `mobile.css` for better visual alignment. Simplify the constructor call in `JFXCentral2MobileApp`.
  • Loading branch information
dlemmermann committed Sep 5, 2024
1 parent 938bda6 commit 37daa80
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private MobileRouter createMobileRouter() {
return MobileResponse.redirect(r, PagePath.REFRESH);
}
}))
.and(MobileRoute.get(PagePath.REFRESH, r -> MobileResponse.view(r, new MobileRefreshPage(size))))
.and(MobileRoute.get(PagePath.REFRESH, r -> MobileResponse.view(r, new MobileRefreshPage())))
.and(MobileRoute.redirect("/index", PagePath.HOME))
.and(MobileRoute.redirect("/home", PagePath.HOME))
.and(MobileRoute.get(PagePath.LINKS, r -> MobileResponse.view(r, new MobileLinksOfTheWeekPage(size))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,20 @@ public class MobileRefreshPage extends StackPane {
*/
private final InvalidationListener invalidationListener = it -> {
if (RepositoryManager.isRepositoryUpdated()) {
Platform.runLater(() -> MobileLinkUtil.getToPage(PagePath.HOME));
Platform.runLater(() -> {
if (isGoToHomePage()) {
MobileLinkUtil.getToPage(PagePath.HOME);
}
});
}
};

private boolean goToHomePage = false;
private final WeakInvalidationListener weakInvalidationListener = new WeakInvalidationListener(invalidationListener);
private final RepositoryUpdater repositoryUpdater = new RepositoryUpdater();
private final CustomImageView logo;

public MobileRefreshPage(ObjectProperty<Size> size) {
public MobileRefreshPage() {
getStyleClass().add(DEFAULT_STYLE_CLASS);

Platform.runLater(() -> {
Expand All @@ -63,10 +68,15 @@ public MobileRefreshPage(ObjectProperty<Size> size) {
if (firstTimeSetup) {
setupFirstTimeUI();
} else {
goToHomePage = true;
setupUpdateUI();
}
}

private boolean isGoToHomePage() {
return goToHomePage;
}

private void setupFirstTimeUI() {
// center part (intro pane)
IntroPane introPane = new IntroPane();
Expand Down Expand Up @@ -98,7 +108,6 @@ private void setupFirstTimeUI() {

FadeIn fadeIn = new FadeIn(loadLabel);
fadeIn.setSpeed(2);
fadeIn.setOnFinished(e -> repositoryUpdater.performUpdate(false));

fadeOut.setOnFinished(e -> {
startButton.setVisible(false);
Expand All @@ -107,6 +116,14 @@ private void setupFirstTimeUI() {
});

fadeOut.play();

goToHomePage = true;

if (RepositoryManager.isRepositoryUpdated()) {
Platform.runLater(() -> {
MobileLinkUtil.getToPage(PagePath.HOME);
});
}
});

StackPane bottomBox = new StackPane(startButton, loadLabel);
Expand All @@ -115,6 +132,8 @@ private void setupFirstTimeUI() {
VBox content = new VBox(logo, introPane, bottomBox);
content.getStyleClass().add("content-box");
getChildren().add(content);

repositoryUpdater.performUpdate(false);
}

private void setupUpdateUI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,12 +1034,12 @@

.mobile-refresh-page > .content-box {
-fx-alignment: top-center;
-fx-padding: 80px 0 40px 0;
-fx-padding: 90px 0 40px 0;
-fx-spacing: 20px;
}

.mobile-refresh-page > .content-box > .custom-image-view {
-fx-fit-height: 40px;
-fx-fit-height: 50px;
}

.mobile-refresh-page .bottom-box {
Expand Down

0 comments on commit 37daa80

Please sign in to comment.