From d2f669b29b77d6313ded5d75a74986378f6e872d Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 17 Aug 2023 19:07:07 +0000 Subject: [PATCH] support `centeredContent` routes declaration --- packages/app/constants/routes.js | 24 ++++++++++++++++++------ packages/app/src/router.jsx | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/app/constants/routes.js b/packages/app/constants/routes.js index 5e13179b..00998513 100755 --- a/packages/app/constants/routes.js +++ b/packages/app/constants/routes.js @@ -16,7 +16,8 @@ export default [ }, { path: "/play/*", - centeredContent: true + centeredContent: true, + public: true, }, { path: "/post/*", @@ -36,26 +37,37 @@ export default [ { path: "/settings/*", useLayout: "default", - centeredContent: true + centeredContent: { + mobile: true, + desktop: false, + }, }, { path: "/security/*", useLayout: "default", - centeredContent: true + centeredContent: true, }, { path: "/music/*", useLayout: "default", - centeredContent: true + centeredContent: true, }, { path: "/landing/*", useLayout: "minimal", - public: true + public: true, }, { path: "/nfc/*", useLayout: "minimal", - public: true + public: true, + }, + { + path: "/", + useLayout: "default", + centeredContent: { + mobile: false, + desktop: true, + }, } ] \ No newline at end of file diff --git a/packages/app/src/router.jsx b/packages/app/src/router.jsx index ba8a0b9a..086582bf 100755 --- a/packages/app/src/router.jsx +++ b/packages/app/src/router.jsx @@ -97,6 +97,22 @@ function generatePageElementWrapper(route, element, bindProps) { app.layout.set(routeDeclaration.useLayout) } + if (typeof routeDeclaration.centeredContent !== "undefined") { + let finalBool = null + + if (typeof routeDeclaration.centeredContent === "boolean") { + finalBool = routeDeclaration.centeredContent + } else { + if (app.isMobile) { + finalBool = routeDeclaration.centeredContent?.mobile ?? null + } else { + finalBool = routeDeclaration.centeredContent?.desktop ?? null + } + } + + app.layout.toggleCenteredContent(finalBool) + } + if (typeof routeDeclaration.useTitle !== "undefined") { if (typeof routeDeclaration.useTitle === "function") { routeDeclaration.useTitle = routeDeclaration.useTitle(route, params)