← App Builder apps

A chores checklist

Build a checklist of jobs as tick boxes, then a 🌙 Dark / ☀️ Light button that switches the screen and back. Two separate events with the same trigger both run on one click and undo each other, so the switch is one event with a sub-event and an Else: one trigger, two branches, and only one branch runs.

A dark mode button looks like the simplest thing in an app. Making one that switches back shows how apps choose between two things to do.

Today's prototype is a list of jobs to tick off, and a button that switches the screen between light and dark.

The ticking is built in: a Toggle can look like a tick box. The light and dark button you build yourself, and it needs the lesson's one big idea.

The chores checklist twice: light, with a "🌙 Dark" button, and dark, with a "☀️ Light" button. Two jobs are ticked.

How this lesson works: See it, Build, Check, Make it yours
See itTry the finished thing first, so you know what you are building.

Try the finished app

This is the checklist you'll build, open on the Run tab. Tick and untick the jobs. Click 🌙 Dark a few times: dark, then light, then dark. The event list beside the app lights up each time an event runs.

Try it yourselfYour edits are saved in this browser.

BuildWatch the short clip, then do the steps. Your app carries on from the step before.

Build 1: jobs as tick boxes

The screen is made for you: a title, three jobs on a light card, and a button called ModeButton. Each job is a Toggle, an on/off switch. (You can change the jobs to your own at the end.)

  1. Click Make my bed to select it. In Properties, set Look to Tick box.
  2. Do the same for the other two jobs.
  3. Run it and tick a job, then untick it. You didn't write an event: a Toggle switches itself.
Look: Tick box · Sound on for the voiceover
Try it yourselfYour edits are saved in this browser.

All three jobs are Toggles with the Tick box look.

    Run your program. This ticks when your code does all of the above.

    BuildWatch the short clip, then do the steps. Your app carries on from the step before.

    Build 2: a button that goes dark

    The app has a variable, Dark, made for you on the left. It starts at false: the screen isn't dark yet. A variable that is only ever true or false is a true/false variable.

    1. On the Events tab, choose + Add event, + Condition, ModeButton, ModeButton is clicked.
    2. Add four actions:
      • Variables, Set variable Dark to true
      • Screen, Set screen background to "#1c2333" (a dark blue)
      • Title, Set Title colour to "white"
      • ModeButton, Set ModeButton text to "☀️ Light" (copy it from here)
    3. Click the button in the preview. It goes dark. Click again: it stays dark.
    Click to go dark · Sound on for the voiceover
    Try it yourselfYour edits are saved in this browser.

    ModeButton is clicked sets Dark to true, the screen background to "#1c2333", Title's colour to "white" and its own text to "☀️ Light".

      Run your program. This ticks when your code does all of the above.

      BuildWatch the short clip, then do the steps. Your app carries on from the step before.

      Build 3: two events (and why they cancel)

      1. Click the event to select it, choose + Condition, Variables, Variable … …, and type false. Now it only goes dark when Dark is false.
      2. Add a second event: ModeButton is clicked, and Variable Dark = true. Give it the opposite actions: Dark to false, background "white", Title colour "black", text "🌙 Dark".
      3. Click the button in the preview. Nothing seems to happen. Watch the events beside the preview: both light up on the one click. The first goes dark and sets Dark to true, then the second sees Dark is true and goes straight back.
      Both events run · Sound on for the voiceover
      Try it yourselfYour edits are saved in this browser.

      Two separate events for ModeButton: one checks Dark = false and goes dark, one checks Dark = true and goes light.

        Run your program. This ticks when your code does all of the above.

        BuildWatch the short clip, then do the steps. Your app carries on from the step before.

        Build 4: a sub-event

        1. Delete both events: click each, then ⋯, Delete this event.
        2. Add one event: ModeButton is clicked, with no other condition and no action.
        3. With it selected, choose ⋯, Add a sub-event.
        4. Give the sub-event the condition Variable Dark = false and the four dark actions from Build 2.
        Go dark only if it's light · Sound on for the voiceover
        Try it yourselfYour edits are saved in this browser.

        One ModeButton click event with a sub-event: if Dark = false, go dark (all four actions). The two flat events are gone.

          Run your program. This ticks when your code does all of the above.

          BuildWatch the short clip, then do the steps. Your app carries on from the step before.

          Build 5: an Else

          1. With the sub-event selected, choose ⋯, Add an Else below.
          2. Give the Else the four light actions: Dark to false, background "white", Title colour "black", text "🌙 Dark".
          3. Click to go dark, click again to go light.

          Your event should look like this:

          When (condition) Do (actions)
          ⚡ ModeButton is clicked
          ↳ Variable Dark = false Set Dark to true, background "#1c2333", Title colour "white", ModeButton text "☀️ Light"
          ↳ Else Set Dark to false, background "white", Title colour "black", ModeButton text "🌙 Dark"

          You've built a switch by hand: it remembers whether it's on (Dark), and one click runs one of two branches. A Toggle with the Tick box look is App Builder's built-in version of the same thing: BedJob.on is true or false, like Dark.

          Otherwise, go light · Sound on for the voiceover
          Try it yourselfYour edits are saved in this browser.

          The click event has a sub-event (Dark = false: go dark) and an Else (go light, all four actions), and the two flat events are gone.

            Run your program. This ticks when your code does all of the above.

            CheckA quick check that the idea has stuck.

            Check: which branch runs?

            With the sub-event and Else, the screen is dark, so Dark is true. You click ModeButton once. What happens?

            Nib's dark mode button doesn't seem to do anything. Click the line where Nib first goes wrong.

            Make it yoursChange your app on purpose, then try it on someone.

            Make it yours: count what's done

            Add a variable Done (starting at 0) and a Text called DoneText on the card, under the jobs. A tick box has its own trigger, BedJob is switched, and its own condition, BedJob is on. Use the same shape you just built: one event BedJob is switched, a sub-event BedJob is on that adds 1 to Done, and an Else that subtracts 1. In both branches, set DoneText to "Done: " & Done & " of 3". Then do the same for the other jobs.

            Make a checklist for someone you know: a packing list, a morning routine, or jobs for a club. Use their words for each job. Add a Reset button that unticks every job (Turn BedJob off) and sets Done to 0. Then watch them use it without helping. What did they expect to happen that didn't?

            Try it yourselfYour edits are saved in this browser.

            Done goes up when a job is ticked and down when it's unticked, and DoneText shows it.

              Run your program. This ticks when your code does all of the above.

              Now you can
              Next lesson3. A water trackerBuild a water tracker with a goal: add a glass, reset the day, and see a message and a progress bar. An Every tick event keeps the display in step without setting the text in every button's event. A condition that isn't a trigger, such as comparing a variable, is checked every tick, and an action only waits for a sub-event's condition if it sits inside that sub-event.
              For teachers

              Students make a checklist of jobs as tick boxes (Toggles with the Tick box look, which switch themselves), then build a 🌙 Dark / ☀️ Light button by hand with a true/false variable Dark. They first build a button that goes dark and stays dark, then try two separate click events (which cancel each other on one click), then fix it with one click event, a sub-event and an Else. About 60 minutes.

              Open the teacher guide: answers, solutions, slides and a worksheet.

              Students will be able to

              Before class

              Needs App Builder 1.11 or later (the tick box look is 1.10, colours while the app runs are 1.11). The lesson's playground already has it.

              The jobs are Toggles. Look: Tick box changes only how they look: BedJob.on is true or false either way, and "is switched" and "is on" work the same. A Toggle can't be given a colour, so the jobs sit on a light card (a Box) that stays light in dark mode.

              Sub-events and Else are added from an event's ⋯ menu (Add a sub-event, Add an Else below). Select the event first by clicking it.

              Dark is a true/false variable: it starts at false. Conditions compare it with = (Variable Dark = false). In a formula, App Builder's if() needs a comparison too: if(Dark = true, "On", "Off"), not if(Dark, …).

              The emoji ☀️ and 🌙 paste fine on most laptops; if one shows an empty square, use "Light" and "Dark" instead, in the actions and in the button's text.

              The one idea: on one click, every event whose conditions are true runs, top to bottom. One trigger with two branches (a sub-event and an Else) means exactly one runs.

              Running the lesson

              1. Before Build 3 (whole class, on the deck): two events, one click: what does the screen show? Most say dark. Leave it open; Build 3 is the reveal.
              2. Build 3: ask a pair to explain what happened in order: first event, then second event, and what Dark was each time.
              3. Check: draw the event on the board with the two branches as arrows. Only one arrow is taken per click.
              4. After Build 5: point back to the tick boxes. Each one is the same switch, built in: it remembers on or off, and one click flips it.
              5. Make it yours: this is the review step. Ask which branch means 'just finished a job'.

              The hard part (on purpose)

              Building the version that doesn't work on purpose (Build 3) feels like wasted effort, and Build 4 asks students to delete it and type the actions again. That's the point: they need to see two flat events cancel before the sub-event makes sense. Pairs can share the typing.

              When students get stuck

              Stretch and support

              Stretch: Show "All done!" when Done is 3: set DoneText to if(Done = 3, "All done!", "Done: " & Done & " of 3"). Or swap ModeButton for a Toggle with the Switch look, and use ModeButton is switched with ModeButton is on.

              Support: Give pairs the finished event (the table at the end of Build 5) to copy, then ask them to explain each row.

              Where it leads

              Next: Water tracker, which keeps a display up to date every tick and checks a goal.

              What each step is for