Lessons · Building apps · 17 of 36
Screens
go_to, go_back, transitions, and phone / tablet / desktop.
The main container is the first screen. Every other screen is a container you open with
go_to(name); go_back() returns. Screens fill the phone and stay clear of the notch and the
keyboard by themselves.
tasks = [{ name: "Buy milk", note: "Two litres" }, { name: "Call Sam", note: "About Friday" }]
main home:
space_inside: 24
space_between: 12
children:
first:
button: tasks[0].name
on_tap: go_to(details(tasks[0]))
second:
button: tasks[1].name
on_tap: go_to(details(tasks[1]), fade)
settings_button:
button: "Settings"
on_tap: go_to(settings, slide)
details(task):
space_inside: 24
space_between: 12
children:
title:
text: task.name
text_style: 28, bold
note:
text: task.note
back:
button: "Back"
on_tap: go_back()
settings:
arrange: center
children:
label:
text: "Settings"
back:
button: "Back"
on_tap: go_back()
go_to(details(task))opens a screen that takes a value (lesson Containers that take values).- The second value picks the change:
slide,fadeornone. The default is the phone's own slide. phone,tabletanddesktoparetrueon that size of screen:arrange: row if (tablet) else column.
Every example here runs in Vi Studio: open it in your browser (phones too) and press Start learning on the welcome page. Each code block there has a Try it button that runs it in the phone preview.
More in Building apps
- Containers that take valuescard(task): one container, many values.
- Repeating thingsrepeat: task in tasks, grids, index, x, y and .at().
- Reaching other containersInside names, parent.name and top-level names.
- Changing the screenA dot for one change, a block for several; wait and animate.
- Timers and gamesevery(), stop(), on_touch, place: x, y and on_hit.
- Sound and videoplay, loop, stop_sounds, audio and video.
- Files and projectssrc/, every file sees every name, one name in one file.
- The config blockApp name, store id, version, icon and splash screen.
- Errors and good habitsThe real error messages and their fixes; how to organise a project.
About Vi. Vi is a free, open-source programming language for building real mobile apps. You describe each screen in plain words, and Vi compiles it to React Native (Expo) for Android, iOS and the web. Its editor, Vi Studio, runs on Windows, in any browser and on your phone, with the app running live as you type. Read more about Vi.