vi studio

Lessons · Building apps · 21 of 36

Changing the screen

A dot for one change, a block for several; wait and animate.

There are two ways to change a container from code:

main home:
  arrange: center
  space_between: 16
  children:
    light
    switch

light:
  size: 40
  shape: circle
  color: gray[300]
  animate: 0.4 seconds

switch:
  button: "Turn on for 2 seconds"
  on_tap: blink()

blink():
  light:
    color: amber[400]
    shadow: true
  switch.text = "On…"
  wait(2 seconds)
  light:
    color: gray[300]
    shadow: false
  switch.text = "Turn on for 2 seconds"

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

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.