Skip to content

feat(ui): Phase 2 v3.3 — iOS toast + setText#327

Merged
proggeramlug merged 1 commit into
mainfrom
feat/ios-toast-settext
Apr 30, 2026
Merged

feat(ui): Phase 2 v3.3 — iOS toast + setText#327
proggeramlug merged 1 commit into
mainfrom
feat/ios-toast-settext

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

$(cat <<'EOF'

Summary

  • New widgets/toast.rs in perry-ui-ios, perry-ui-tvos, and perry-ui-visionos: UIView overlay added to the key UIWindow, alpha-fade 0→1 over 0.25s, 2.5s hold, fade out, removeFromSuperview. FIFO queue via thread_local VecDeque<String> + Cell<bool> for back-to-back toasts. Two NSTimer target classes (PerryIOSToast* / PerryTVOSToast* / PerryVisionOSToast*) drive the animation pipeline using the same define_class! + scheduledTimerWithTimeInterval:target:selector: pattern as PerryPumpTarget. Class names are platform-prefixed to avoid ObjC namespace collision.
  • New widgets/text_registry.rs in all three crates: Mutex<Option<HashMap<String, i64>>> mapping user-supplied Text ids to widget handles. register_text_id_handler populates; set_text_handler looks up and calls widgets::text::set_text_str (UILabel setText: — the UIKit analogue of NSTextField setStringValue:). Direct port of the macOS file.
  • Each crate's app_run calls register_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) before UIApplicationMain, so the three runtime AtomicPtr handler slots are populated before any TS code fires showToast or setText.

Stacks on #326 (macOS implementation, which is the reference template).

What changed

File Change
perry-ui-ios/src/widgets/toast.rs New — UIKit HUD toast
perry-ui-ios/src/widgets/text_registry.rs New — id→handle registry
perry-ui-ios/src/widgets/mod.rs +2 pub mod declarations
perry-ui-ios/src/app.rs register_cross_platform_text_handlers() call + extern block
perry-ui-tvos/src/widgets/toast.rs New — same, PerryTVOS class prefix
perry-ui-tvos/src/widgets/text_registry.rs New
perry-ui-tvos/src/widgets/mod.rs +2 pub mod declarations
perry-ui-tvos/src/app.rs registration call + extern block
perry-ui-visionos/src/widgets/toast.rs New — same, PerryVisionOS class prefix
perry-ui-visionos/src/widgets/text_registry.rs New
perry-ui-visionos/src/widgets/mod.rs +2 pub mod declarations
perry-ui-visionos/src/app.rs registration call + extern block
Cargo.toml Version bump 0.5.408 → 0.5.415
CLAUDE.md Current version + Recent Changes entry

No 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 at app_run is 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 perry clean on macOS host (requires Apple SDK — parent to verify).
  • cargo build --release -p perry-ui-tvos --target aarch64-apple-tvos-sim clean.
  • cargo build --release -p perry-ui-visionos --target aarch64-apple-visionos-sim clean.
  • Smoke: Text("Count: 0", "counter") + Button("tap", () => { setText("counter", "1"); showToast("done"); }) compiled for --target ios-simulator produces a binary that shows the toast overlay and updates the label on tap.

https://claude.ai/code/session_01QvJUom4CxtYCxpyqcukt7y
EOF
)


Generated by Claude Code

@proggeramlug proggeramlug changed the base branch from phase-2-v3.3 to main April 30, 2026 13:56
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
@proggeramlug proggeramlug force-pushed the feat/ios-toast-settext branch from 37edeba to e3b22ef Compare April 30, 2026 13:57
@proggeramlug proggeramlug merged commit ab4bd60 into main Apr 30, 2026
5 of 8 checks passed
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.
@proggeramlug proggeramlug deleted the feat/ios-toast-settext branch May 10, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants