feat(ui): Phase 2 v3.3 — iOS toast + setText#327
Merged
Conversation
aa4b629 to
03f4aa7
Compare
Wire `showToast` and `setText` on the three UIKit platforms (iOS, tvOS, visionOS) using the macOS NSPanel implementation in PR #326 as the template. Each platform gets the same two new files: - `widgets/toast.rs`: UIView overlay added to the key UIWindow, alpha- fade 0→1 in 0.25 s (UIView.animateWithDuration:), hold 2 s, fade out, removeFromSuperview. FIFO queue via thread_local VecDeque + Cell<bool> so back-to-back showToast calls render sequentially. Two NSTimer target classes drive the hold → fade-out → cleanup pipeline, using the same define_class! + scheduledTimerWithTimeInterval:target:selector: pattern as PerryPumpTarget / PerryTimerTarget. ObjC class names are platform- prefixed (PerryIOSToast*, PerryTVOSToast*, PerryVisionOSToast*) to avoid runtime namespace collision if both crates ever link together. - `widgets/text_registry.rs`: Mutex<Option<HashMap<String, i64>>> mapping user-supplied Text ids to widget handles. register_text_id_handler populates; set_text_handler looks up + calls widgets::text::set_text_str which issues UILabel setText: — UIKit analogue of NSTextField setStringValue:. Direct port of the macOS file; no platform-specific code needed. Each crate's mod.rs exposes the two new modules. Each crate's app_run calls register_cross_platform_text_handlers (with the same extern block + function body as macOS) before UIApplicationMain / register_view_controller, so the three runtime AtomicPtr handler slots are populated before any TS code fires showToast or setText. No codegen changes: PR #326's cross-platform design routes all UIKit targets through the existing perry_arkts_show_toast / perry_arkts_set_text / perry_arkts_register_text_id symbols in perry-runtime; the handler registration in app_run is the only per-platform hook required. Verified: cargo test --release -p perry-codegen-arkts 23/23 pass. https://claude.ai/code/session_01QvJUom4CxtYCxpyqcukt7y
37edeba to
e3b22ef
Compare
proggeramlug
added a commit
that referenced
this pull request
Apr 30, 2026
…s! toast targets (v0.5.451) The Phase 2 v3.3 toast port (#327, v0.5.420) for iOS / tvOS / visionOS missed `use objc2::AnyThread;` in their respective `widgets/toast.rs`. macOS sibling already had the trait import so it linked cleanly all along; only the iOS simulator runner exercises iOS UI crate end-to-end (tvOS / visionOS targets aren't in CI rustup either, so all three needed the same one-line fix). Per CLAUDE.md "objc2 v0.6 API" guidance the `Self::alloc()` call inside `define_class!`-generated impls requires `objc2::AnyThread` in scope. Verified locally: `cargo check --release -p perry-ui-ios --target aarch64-apple-ios-sim` clean (only pre-existing warnings). v0.5.450 tag was pushed but the release-packages publish blocked on the failed Simulator Tests gate; v0.5.451 patches forward and re-releases. The v0.5.450 GH release is benign — no assets, no published binaries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
$(cat <<'EOF'
Summary
widgets/toast.rsinperry-ui-ios,perry-ui-tvos, andperry-ui-visionos: UIView overlay added to the key UIWindow, alpha-fade 0→1 over 0.25s, 2.5s hold, fade out,removeFromSuperview. FIFO queue viathread_local VecDeque<String>+Cell<bool>for back-to-back toasts. TwoNSTimertarget classes (PerryIOSToast*/PerryTVOSToast*/PerryVisionOSToast*) drive the animation pipeline using the samedefine_class!+scheduledTimerWithTimeInterval:target:selector:pattern asPerryPumpTarget. Class names are platform-prefixed to avoid ObjC namespace collision.widgets/text_registry.rsin all three crates:Mutex<Option<HashMap<String, i64>>>mapping user-supplied Text ids to widget handles.register_text_id_handlerpopulates;set_text_handlerlooks up and callswidgets::text::set_text_str(UILabel setText:— the UIKit analogue ofNSTextField setStringValue:). Direct port of the macOS file.app_runcallsregister_cross_platform_text_handlers(same extern block + function body as macOS PR feat(ui): Phase 2 v3.3 — cross-platform showToast + setText (macOS, v0.5.408) #326) beforeUIApplicationMain, so the three runtimeAtomicPtrhandler slots are populated before any TS code firesshowToastorsetText.Stacks on #326 (macOS implementation, which is the reference template).
What changed
perry-ui-ios/src/widgets/toast.rsperry-ui-ios/src/widgets/text_registry.rsperry-ui-ios/src/widgets/mod.rspub moddeclarationsperry-ui-ios/src/app.rsregister_cross_platform_text_handlers()call + extern blockperry-ui-tvos/src/widgets/toast.rsPerryTVOSclass prefixperry-ui-tvos/src/widgets/text_registry.rsperry-ui-tvos/src/widgets/mod.rspub moddeclarationsperry-ui-tvos/src/app.rsperry-ui-visionos/src/widgets/toast.rsPerryVisionOSclass prefixperry-ui-visionos/src/widgets/text_registry.rsperry-ui-visionos/src/widgets/mod.rspub moddeclarationsperry-ui-visionos/src/app.rsCargo.tomlCLAUDE.mdNo codegen changes: PR #326's cross-platform runtime-dispatch design already routes all UIKit targets through
perry_arkts_show_toast/perry_arkts_set_text/perry_arkts_register_text_id; the handler registration atapp_runis the only per-platform hook required.Test plan
cargo test --release -p perry-codegen-arkts— 23/23 pass (no codegen-arkts code touched).cargo build --release -p perry-runtime -p perry-stdlib -p perry-ui-ios --target aarch64-apple-ios-sim -p perryclean on macOS host (requires Apple SDK — parent to verify).cargo build --release -p perry-ui-tvos --target aarch64-apple-tvos-simclean.cargo build --release -p perry-ui-visionos --target aarch64-apple-visionos-simclean.Text("Count: 0", "counter")+Button("tap", () => { setText("counter", "1"); showToast("done"); })compiled for--target ios-simulatorproduces a binary that shows the toast overlay and updates the label on tap.https://claude.ai/code/session_01QvJUom4CxtYCxpyqcukt7y
EOF
)
Generated by Claude Code