3. Advanced Layout Application
How to create an application with advanced professional layout?
The Goal
Compose an Advanced Layout application switching between different Views by the Routes.

The Description
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.
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.
The Knowledge I Will Get
- Switching between Views using the Routes. 
- Referencing dynamic values from Data Explorer. 
- How to Logout the application. 
The Project Structure
- ViewA - Container[cntRoot] - Label[lblTitle] 
 
 
- ViewB - Container[cntRoot] - Label[lblTitle] 
 
 
- ViewHome - Container[cntRoot] - Label[lblTitle] 
 
 
- ViewProfil - Container[cntRoot] - Label[lblTitle] 
 
 
1. Prepare a Sub-Pages
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 - cntRootput 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"
 
2. Prepare MainView Header Content
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 - hdrMainPlace in a Text with ID ->- txtAppName:- Value -> - constants.appName(ƒx); Font Size ->- LARGE; Foreground ->- WHITE; Item Flex ->- Stretch
 
- Into - hdrMainput 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)
 
 
 

3. Place in a Sidebar Layout and Its Components
The Main content of the Sidebar layout will contain a Route component; the Sidebar itself will include a Navigation.
- Put in the - MainViewa Sidebar and name it- sdbMain:- Main Content -> Spacing -> - Medium; Sidebar -> Spacing ->- Medium; Width ->- Medium; Item Flex ->- Stretch
 
- Place into Content Container of - sdbMaina Routes Component, name it- rtsMainand 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 - trnNavigationwith Item Flex ->- Stretch; We will configure Navigation in the following steps

4. Configuring Routes
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);
 



5. Editing Routes Content
The Content of the individual Options is dependent on the matching of the URL pattern.
- 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 - cntNotFoundContainer a Label with ID ->- lblNotFound; Value -> "- The page could not be found!"; Font Size ->- LARGE; Icon Name -> "- mdi/alert-circle-outline"; Icon Size ->- Large
 
 


6. Editing Navigation Content
The Navigation Options allow clicking on specified Views, including MainView. It's self-targeting switching Routes in corresponding ViewID.
- Select the - trnNavigationComponent 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
 
 
The Conclusion
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.
Last updated
Was this helpful?


