Moving between screens
Buttons, the back button, sheets and tabs.
Actions
Anything that can be pressed, such as a button, a link row or a navigation bar’s button, takes an action:
| Action | What it does |
|---|---|
{ "go": "postcode" } |
Goes to another screen, without checking anything |
"submit" |
Checks the screen’s fields and, if they’re valid, follows its next |
"back" |
Goes back a screen. From a sheet’s first screen, it closes the sheet |
"dismiss" |
Closes the sheet the screen is in, however far into it, as Done at the end of a task does |
{ "tab": "chat" } |
Shows the tab that starts on that screen, where it was left |
{ "set": { "removed-address": true } } |
Keeps values, by name, and stays on the screen |
"exit" |
Leaves the prototype |
A navigation bar with "back": true has a back button of its own, which goes back.
History
go takes a history, which says what going back does afterwards:
push, the default, lets the person go back.presentshows the screen in a sheet over the one it came from, as the app presents a task to finish or cancel. The screens it goes on to are in the sheet too, until going back from its first screen closes it.replaceswaps the current screen out, so they can’t go back to it.resetleaves nothing to go back to, in any tab, and closes any sheet, as signing out does.
{ "type": "section-heading", "attributes": { "action": "Edit" }, "text": "Your local services", "action": { "go": "local-services", "history": "present" } }
Tabs
A tab bar’s items each show a tab, named by the screen it starts on. Each tab keeps its own history: going to Chat and back to Home finds Home where it was left. Choosing the tab already on show goes back to its first screen.
{
"type": "tab-bar",
"children": [
{ "type": "tab-bar-item", "attributes": { "icon": "home", "selected": true }, "text": "Home", "action": { "tab": "home" } },
{ "type": "tab-bar-item", "attributes": { "icon": "chat_bubble" }, "text": "Chat", "action": { "tab": "chat" } }
]
}
Where submitting leads
A screen’s next says where submit leads, once its fields are valid. Each is tried in order, and the first whose when holds, or that has none, is followed. One can stay on the screen and show an error against a field instead, or set values to keep before going on:
"next": [
{ "when": { "missing": "match" }, "error": { "field": "postcode", "message": "We could not find a council for this postcode." } },
{ "when": { "present": "match.council" }, "set": { "council": "match.council" }, "go": "confirmation" },
{ "when": { "present": "match.addresses" }, "go": "choose-council" }
]