3. Advanced Layout Application
How to create an application with advanced professional layout?
Last updated
How to create an application with advanced professional layout?
Last updated
Compose an Advanced Layout application switching between different Views by the Routes.
The principle of the Route component is in switching between the exact URL addresses based on the unique Views IDs. Component option settings change any matched route, including the exact home page, specific Views, or non-existing addresses.
Be noticed that the application URL address is always in the following format: ApplicationURL/view/view_id
All Defined Routes are matched from top to bottom, which means it's essential to prepare Routes heading from the home page, followed by specific View IDs, ending with the non-existing content.
home
-> exact ApplicationURL
view
-> ApplicationURL/view/view_id
home
-> non-exact ApplicationURL
Switching between Views using the Routes.
Referencing dynamic values from Data Explorer.
How to Logout the application.
First, let's prepare four sub-Views serving as basic elements of the MainView
. Its structure would be the same, just with different content.
Structure of all sub-Views:
Place in a Container named ID -> cntRoot
; Padding -> Wide
; Spacing -> Medium
; Item Flex -> Stretch
Into the cntRoot
put a Label with ID -> lblTitle
; Text Style -> Bold
; Font Size -> MEDIUM
; Icon Size -> Medium
Create the following Views and upgrade their Properties:
ID -> ViewA
; lblTitle
-> Value -> "ViewA
"; Icon Name -> "mdi/alpha-a-circle
"
ID -> ViewB
; lblTitle
-> Value -> "ViewB
"; Icon Name -> "mdi/alpha-b-circle
"
ID -> ViewHome
; lblTitle
-> Value -> "Home
"; Icon Name -> "mdi/home
"
ID -> ViewProfil
; lblTitle
-> Value -> currentUser.fullName
(ƒx) ; Icon Name -> "mdi/account-circle
"
You can overwatch the whole currentUser structure in the Data Explorer. Be sure, that you will switch (ƒx) Values dynamically.
MainView
Header ContentLet's start with a Header following a SideBar in the next step.
Create an Application Header, name it hdrMain
, and set up its properties as follows:
Height -> Medium
; Horizontal Alignment -> Left
; Padding -> 10px 20px
; Spacing -> Medium
Into hdrMain
Place in a Text with ID -> txtAppName
:
Value -> constants.appName
(ƒx); Font Size -> LARGE
; Foreground -> WHITE
; Item Flex -> Stretch
Into hdrMain
put also a Menu Button with ID -> mnbMain
; Value -> currentUser.email
(ƒx) and add Items:
Profile
-> Value -> "Profil
"; Icon Name -> "mdi/account-circle-outline
"
Link -> Link Type -> View
; View -> Select(ViewProfil)
; Link Target -> Self
Logout
-> Value -> "Logout
"; Icon Name -> "mdi/logout-variant
"
Link -> Link Type -> Named Route
; View -> Select(Logout
)
Any Link Type has to beSelf
-targeting to match the inner Routes.
The Main content of the Sidebar layout will contain a Route component; the Sidebar itself will include a Navigation.
Put in the MainView
a Sidebar and name it sdbMain
:
Main Content -> Spacing -> Medium
; Sidebar -> Spacing -> Medium
; Width -> Medium
; Item Flex -> Stretch
Place into Content Container of sdbMain
a Routes Component, name it rtsMain
and Item Flex -> Stretch
; We will configure Routes in following steps.
Into Sidebar Content place a Box with ID -> boxBackground
;
Style -> Background -> WHITE
; Border Color -> #dee6ec
; Border Width -> 0px 1px 0px 0px
; Padding -> 50px 20px 0px 0px
; Spacing -> Medium
; Item Flex -> Stretch
Sidebar Box will carry a Navigation Component named trnNavigation
with Item Flex -> Stretch
; We will configure Navigation in the following steps
Adding Routes Items by clicking on the Plus icon in the Inspector Panel will allow us to define separated Content Containers. Switching between Route Canvas is done by clicking on the cogwheel on the Route component.
Add three Routes:
Home
-> Route Name -> Select(home
); Exact -> true
View
-> Route Name -> Select(view
);
Home
-> Route Name -> Select(home
);
Exact expression telling us that home
has to be matched with a MainView URL
.
Selected view
option matching Route just with ViewID
parameters.
Non-exact expression of home
matching anything else than existing any ViewID
or MainView
URLs.
The Content of the individual Options is dependent on the matching of the URL pattern.
Any selected Content Components have the routeParams
attributes passing the last ViewID
state.
Switch between Routes Content by clicking on Toggle Options Cogwheel and add and configure the following Components:
home
(#1 Option) -> add a View name it viewHome
-> View -> Select(ViewHome
)
view
(#2 Option) -> add a View name it viewDynamic
-> View -> routeParams.viewId
(ƒx)
home
(#3 Option) -> add a Container with ID -> cntNotFound
; Horizontal Alignment -> Left
; Style -> Padding -> 100px
; Spacing -> Medium
Place into cntNotFound
Container a Label with ID -> lblNotFound
; Value -> "The page could not be found!
"; Font Size -> LARGE
; Icon Name -> "mdi/alert-circle-outline
"; Icon Size -> Large
The Navigation Options allow clicking on specified Views, including MainView
. It's self-targeting switching Routes in corresponding ViewID.
Select the trnNavigation
Component and edit Items as follows:
Add an Item and name it Home
; Label Value -> "Home
"; Icon Name -> "mdi/home-outline
"
Link -> Link Type -> Select(Named Route
); Named Route -> Select(home
); Link Target -> Self
Add an Item and name it View A
; Label Value -> "View A
"; Icon Name -> "mdi/alpha-a-circle-outline
"
Link -> Link Type -> Select(View
); View -> Select(ViewA
); Link Target -> Self
Add an Item and name it View B
; Label Value -> "View B
"; Icon Name -> "mdi/alpha-b-circle-outline
"
Link -> Link Type -> Select(View
); View -> Select(ViewB
); Link Target -> Self
In this Tutorial we learn how to switch between routes by matching Exact or Non-exact URL patterns. Its obvious that Views have to be self-targeted and can be dynamically change by a routeParams
Parameter. Try to create few new Views, give them some content, and add into the Navigation Panel.
Follow up on our Navigation & Routing tutorial https://youtu.be/odHoEMonSPg