Gravity
Search
⌃K

Views

Views are the main screens in your application and are comprised of various components.
Gravity comes with 10 pre-built views for you to use in your app, including:
  • Auth views (sign up, sign in, reset password)
  • Account views (profile, password, users)
  • x2 dashboard templates
Views are located in the /views directory

Creating a New View

There is a template.js file inside the views directory that you can use to speed up the process of creating new views.
Your components within a view should always be wrapped inside a <ViewContainer> which will provide common components such as header, navigation and banner notifications.

Routing the View

Once you've built your view, you need to import it into /router.js and add it to a navigation stack.

Private Views

You can restrict access to a view to a specific user permission level. For example: only account admins should be able to access the edit users view.
Inside the router – each view has a params object where you can add the user permission level, for example in the ProfileTabs stack:
users: {
screen: Users,
params: {
title: 'Profile',
permission: 'admin'
}
},
You should also consider conditionally rendering stack objects to only show links to views the user has permission for.