Files
breeze/tests/practice_settings_apps_behavior.zi
waozi 017d3565d3 Build on Ziran 0.5.0 and Kryon's namespaced widgets, with the Tao picture page
Pin only pushed commits, with no local overrides: Ziran v0.5.0
(f9f92b46), Kryon b45cc524 (one lock entry, ref master, shared with the
Css and Plot master edges), Apps 352901e, Entity b30dd4a and practices
893e5b6f, whose sharpened banners and regenerated Lumi guide clips the
narration check now matches.

The Library opens each Tao Te Ching chapter on its own picture page: the
chapter art and its title, centered together; the text pages follow.
The reader keeps the picture page across reflow, and a chapter start or
a Contents pick opens it. The 81 approved chapter pictures are included.

Breeze now uses Kryon's namespaced widgets (Text.Draw/Text.Props,
Button, Image, Modal.ActionModal, Layout, TabBar, LoadingScreen,
LoadingIndicator, Shape.Circle) instead of the removed Kryon/Widgets
facades. Hosted apps import std/text explicitly, since a short "text"
import now names Kryon's widget. AGENTS.md and the Text/Button API checks
describe the namespaced forms; two unused test doubles are removed.

Build fixes for the new toolchain: the bundle runtime carries Ziran's
instruction engine (no BOOTSTRAP=1) and takes the pinned host zi2c for
cross builds; the Apps controller's lock context has the manifest's
module roots; the app codec generator lists Kryon's raw modules only;
the package scripts read ZX revision 28 bundle assets. The Apps
controller digest matches the Apps 352901e build.

Also included: the stopped lanes' work in this tree (Radio download,
Photos install, Lists, Lumi, Habits shop rewards, astral exercise
selection, appearance and download recovery) and the raylib-free desktop
lane's host modules (app_trace, host_input, host_window, host_clock),
inactive unless DESKTOP_HOST is defined.

Not included: the crash-recovery lane's picture-window and storage
crash-safety changes, which that lane commits itself.

Local tests: zi-check (510 modules), native and Android source checks,
hosted app checks, build-laws, clean-text-api-check, button-api-check,
library-reader-test, library-ui-test, storage-crash-zi-test and
native-image-decode-test pass. The bundled Arcade is still ZX revision 26
and waits for an Arcade build on these pins.
2026-11-16 14:20:12 -03:00

227 lines
8.2 KiB
Ziran

// Practices draws its Customize pages: the bundled package lays out
// Meditation's settings, a breathing pattern's, Wim Hof's with its preview
// and start speed editor, the music and the narration from the frame the host
// gives it, reads each track and language through the host, and gives back
// the one change asked for.
#import "session"
#import "geometry"
#import "kryon/tree"
#import "tree_draw"
#import "paint_queue"
#import "bundle_host"
#import "byte_text_linux"
#import "hosted_values"
#import "widget_host"
#import "drawing_props"
#import, file "../src/apps/module_host.zi";
#import, file "../src/apps/practice_types.zi";
#import, file "../src/apps/practice_ui_types.zi";
#import, file "../src/apps/app_codec.zi";
#import, file "../src/app/exercise_types.zi";
using ExerciseType;
using HostValueKind;
settings_test_frame: PracticeSettingsFrame;
settings_test_codec: WidgetPracticeSettingsFrameCodec;
settings_test_track_codec: WidgetPracticeMusicTrackCodec;
settings_test_language_codec: WidgetPracticeNarrationChoiceCodec;
settings_test_character_codec: WidgetPracticeCharacterChoiceCodec;
settings_test_writes: s32;
settings_test_figures: s32;
settings_test_characters: s32;
settings_test_tracks: s32;
settings_test_languages: s32;
SettingsTestAssets :: (path: string) -> bool {
return path.count == 0
}
SettingsTestCall :: (context: *void, module: *u8, function: *u8,
arguments: *HostValue, count: s32, result: *HostValue) -> s32 {
if TextFromCString(module) == "figure_view" && TextFromCString(function) == "DrawPracticeFigureHost" &&
count == 1 && WidgetValidPracticeFigureRequest(arguments[0]) {
settings_test_figures += 1
return 1
}
if TextFromCString(module) != "settings_view" {
return WidgetHostCall(context, module, function, arguments, count, result)
}
name := TextFromCString(function)
if name == "ReadPracticeSettingsHost" && count == 0 {
result.* = WidgetEncodePracticeSettingsFrame(settings_test_frame, *settings_test_codec)
return 1
}
if name == "WritePracticeSettingsHost" && count == 1 && WidgetValidPracticeSettingsFrame(arguments[0]) {
settings_test_writes += 1
settings_test_frame = WidgetDecodePracticeSettingsFrame(arguments[0], *settings_test_codec)
return 1
}
if name == "ReadPracticeMusicTrackHost" && count == 1 {
index := cast(s32)arguments[0].integer
if index < 0 || index >= settings_test_frame.music_count {
return 0
}
settings_test_tracks += 1
result.* = WidgetEncodePracticeMusicTrack(PracticeMusicTrack.{.label = "Deep Meditation"},
*settings_test_track_codec)
return 1
}
if name == "ReadPracticeNarrationHost" && count == 1 {
index := cast(s32)arguments[0].integer
if index < 0 || index >= settings_test_frame.narration_count {
return 0
}
settings_test_languages += 1
result.* = WidgetEncodePracticeNarrationChoice(PracticeNarrationChoice.{.label = "English",
.state = 2, .rank = index}, *settings_test_language_codec)
return 1
}
if name == "ReadPracticeCharacterHost" && count == 1 {
settings_test_characters += 1
result.* = WidgetEncodePracticeCharacterChoice(PracticeCharacterChoice.{.label = "Jade woman"},
*settings_test_character_codec)
return 1
}
if name == "SettingsLocaleHost" && count == 1 {
text := "Customize"
result.* = HostValue.{.kind = cast(s32)HostString, .type_name = HostTextData("string"),
.data = HostTextData(text), .length = cast(usize)text.count}
return 1
}
return 0
}
SettingsTestDraw :: (frame: PracticeSettingsFrame, frame_id: u64) -> s32 {
session := SessionOpen()
BeginFrame(session, frame_id, Rectangle.{0.0, 0.0, 411.0, 900.0})
frame.session = session
settings_test_frame = frame
settings_test_writes = 0
settings_test_figures = 0
settings_test_characters = 0
settings_test_tracks = 0
settings_test_languages = 0
WidgetHostBegin(session, SettingsTestAssets)
AppsUiBegin(SettingsTestCall, null)
drawn := PracticeRun(PracticeMessage.{.action = PRACTICE_SETTINGS_VIEW})
AppsUiEnd()
WidgetHostEnd()
painted := PendingPaintCount(session)
unused EndFrame(session)
unused SessionClose(session)
if !drawn.succeeded {
return 1
}
if settings_test_writes != 1 {
return 2
}
if painted == 0 {
return 3
}
return 0
}
// Draws Meditation's page with a track downloading, then Astral
// Projection's with narration in two voices; returns 0 when the package
// drew both through the host and asked for nothing.
CheckPracticeSettings :: () -> s32 {
frame := PracticeSettingsFrame.{.scale = 1.0, .view_width = 411, .view_height = 900,
.font = 16, .small_font = 14, .title_height = 48, .scroll_y = 66, .scroll_height = 834,
.canvas_color = Color.{.r = 245, .g = 248, .b = 246, .a = 255},
.accent_color = Color.{.r = 120, .g = 200, .b = 160, .a = 255},
.practice = EXERCISE_MEDITATION, .duration_mode = 1, .custom_minutes = 20,
.bell_minutes = 5, .music = true, .music_selection = 1, .music_count = 3,
.music_built_in = true, .music_show_status = true, .music_downloading = true,
.music_bytes = 40, .music_total = 100, .music_status = "Downloading 40%"}
meditation := SettingsTestDraw(frame, cast(u64)1)
if meditation != 0 {
return meditation
}
if settings_test_tracks != 3 || settings_test_frame.action != PRACTICE_SETTINGS_NONE {
return 4
}
frame.practice = EXERCISE_ASTRAL_PROJECTION
frame.music_selection = 0
frame.narration = true
frame.narration_enabled = true
frame.narration_voices = true
frame.narration_count = 2
frame.narration_selected = 0
frame.narration_status = "Downloading English…"
astral := SettingsTestDraw(frame, cast(u64)2)
if astral != 0 {
return 4 + astral
}
if settings_test_languages != 2 || settings_test_frame.action != PRACTICE_SETTINGS_NONE {
return 8
}
frame.narration = false
frame.practice = EXERCISE_PATTERNS
frame.pattern = 4
frame.pattern_inhale = 4
frame.pattern_hold_in = 2
frame.pattern_exhale = 6
frame.pattern_minutes = 5
patterns := SettingsTestDraw(frame, cast(u64)3)
if patterns != 0 {
return 8 + patterns
}
if settings_test_frame.action != PRACTICE_SETTINGS_NONE {
return 12
}
frame.practice = EXERCISE_WIM_HOF
frame.whm_speed = 6
frame.whm_speed_min = 1
frame.whm_speed_max = 8
frame.whm_rounds = 3
frame.whm_rounds_max = 12
frame.whm_breaths = 30
frame.whm_breaths_min = 15
frame.whm_breaths_max = 80
frame.whm_pause_max = 30
frame.whm_progressive = true
frame.whm_start_speed = 3
frame.whm_reminder = 30
frame.whm_preview = 0.5
frame.whm_editor = true
frame.whm_editor_preview = 0.25
frame.surface_color = Color.{.r = 255, .g = 255, .b = 255, .a = 255}
frame.border_color = Color.{.r = 220, .g = 224, .b = 222, .a = 255}
frame.link_color = Color.{.r = 40, .g = 120, .b = 90, .a = 255}
frame.text_color = Color.{.r = 20, .g = 24, .b = 22, .a = 255}
whm := SettingsTestDraw(frame, cast(u64)4)
if whm != 0 {
return 12 + whm
}
if settings_test_frame.action != PRACTICE_SETTINGS_NONE {
return 16
}
frame.practice = EXERCISE_SUN_SALUTATION
frame.sun_repetitions = 4
frame.sun_start_seconds = 6
frame.sun_end_seconds = 3
frame.sun_seconds_min = 1
frame.sun_seconds_max = 20
frame.sun_duration = 240
frame.whm_editor = false
frame.narration = true
sun := SettingsTestDraw(frame, cast(u64)5)
if sun != 0 {
return 16 + sun
}
if settings_test_frame.action != PRACTICE_SETTINGS_NONE {
return 20
}
frame.practice = EXERCISE_TAI_CHI
frame.tai_character_count = 4
frame.tai_preview_item = 0
tai := SettingsTestDraw(frame, cast(u64)6)
if tai != 0 {
return 20 + tai
}
if settings_test_figures != 4 || settings_test_characters != 4 ||
settings_test_frame.action != PRACTICE_SETTINGS_NONE { return 24 }
return 0
}