Practical Learning Exercises
Solidify your understanding of ZKite by completing these six progressive exercises.
Exercise 1: Understand the Starter App
Section titled “Exercise 1: Understand the Starter App”- Goal: Build and run an app without an active preview session.
- Steps:
- Create a project:
zkite new exercise_one. - Inspect
main.pyand modify the displayed greeting text. - Run
zkite runto install a standalone build on your phone. - Disconnect the USB cable or close the computer terminal.
- Create a project:
- Success Criteria: The application launches cleanly from your phone’s Android app launcher drawer.
Exercise 2: Multi-Field Reactive State
Section titled “Exercise 2: Multi-Field Reactive State”- Goal: Manage multiple state fields within a single
Store. - Steps:
- Add a second state variable (e.g.
is_liked: bool = False) to yourStore. - Create a heart toggle button that updates
is_likedwhile retaining the existing tap counter. - Verify that updating one field does not unintentionally overwrite or reset the other.
- Add a second state variable (e.g.
Exercise 3: Build a Validated Form
Section titled “Exercise 3: Build a Validated Form”- Goal: Implement controlled text input with live validation.
- Steps:
- Add a
TextFieldfor an email address and aButtonfor submission. - Validate whether the email contains an
@symbol as the user types. - Show a red validation warning text when invalid, and enable the submit button only when valid.
- Test typing, deleting all text, and dismissing the software keyboard on your device.
- Add a
Exercise 4: Adaptive Themed Screen
Section titled “Exercise 4: Adaptive Themed Screen”- Goal: Coordinate in-app colors with Android status and navigation bars.
- Steps:
- Wrap your root view in
SystemBars. - Add a
Switchthat toggles between Dark Mode (#0b0f19) and Light Mode (#ffffff). - Bind
status_color,navigation_color, and icon contrast (light/dark) to the active theme state.
- Wrap your root view in
Exercise 5: Navigation & Modal Dialogs
Section titled “Exercise 5: Navigation & Modal Dialogs”- Goal: Implement multi-screen navigation and dialog confirmation.
- Steps:
- Set up
Navwith aHomeScreenand aDetailsScreen. - Pass an item ID from the home screen into the details screen via
nav.push("details", item_id="101"). - Add a delete button on the details screen that triggers an
Overlayconfirmation modal. - Verify that Android Back dismisses the overlay first without popping the screen.
- Set up
Exercise 6: Package a Production App
Section titled “Exercise 6: Package a Production App”- Goal: Build and sign a distributable APK with custom branding.
- Steps:
- Generate a permanent release key with
zkite keygen --out release_key. - Set your custom
packageidentifier,label, andicon = "icon.png"inpyproject.toml. - Build the APK:
zkite build apk --abi arm64-v8a --keystore release_key.pem. - Install and verify the custom launcher icon and app label on your phone.
- Generate a permanent release key with
