Skip to content

Migrate Preferences and Settings UI from ObjC to Swift/SwiftUI - #8

Merged
supagroova merged 5 commits into
mainfrom
feature/swiftui-migration
Mar 19, 2026
Merged

Migrate Preferences and Settings UI from ObjC to Swift/SwiftUI#8
supagroova merged 5 commits into
mainfrom
feature/swiftui-migration

Conversation

@supagroova

@supagroova supagroova commented Mar 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Phase 1: Migrate EMRPreferences from Objective-C to a Swift Preferences class
  • Phase 2a: Add SwiftUI SettingsView with full test coverage
  • Phase 2b: Replace the ObjC EMRPopoverViewController with the SwiftUI SettingsView via SettingsViewBridge
  • Phase 3: Replace EMRMoveResize.h/.m with MoveResize.swift
  • Fix popover sizing to use NSHostingController.sizingOptions for correct automatic content sizing

Test plan

  • All existing tests pass (xcodebuild test)
  • Open popover from menu bar — verify correct sizing, no gap at top, buttons visible
  • Toggle all modifier checkboxes, mouse buttons, hover mode — verify preferences persist
  • Verify conflict warning appears when move/resize shortcuts match
  • Reset to Defaults and Quit buttons work correctly

Replace EMRPreferences (ObjC) with Preferences.swift, providing full
@objc bridge methods so existing ObjC callers (EMRAppDelegate,
EMRPopoverViewController) work unchanged. Add 31 Swift preference tests
and fix test target header search path for Zooom3-Swift.h. All 112 tests
pass.
Create SettingsView.swift replicating the popover UI in SwiftUI with
modifier checkboxes, mouse button pickers, boolean toggles, conflict
warning, and reset/quit buttons. Uses SettingsCallbacks struct for
action wiring. Add 18 tests covering creation, callbacks, conflict
detection, and static data. All 130 tests pass.
Swap EMRPopoverViewController for SettingsViewBridge (NSHostingController
wrapping SwiftUI SettingsView). Add SettingsViewDelegate protocol so
EMRAppDelegate receives callbacks for modifier/button/hover changes,
reset, and quit. Remove all IBAction wiring code and the old ObjC popover
files. All 101 tests pass.
Remove the Spacer() that caused the popover to expand beyond its content,
and use NSHostingController.sizingOptions = .preferredContentSize to let
the popover automatically match the SwiftUI view's intrinsic size. Fixes
the gap at the top and clipped buttons at the bottom.
Replace EMRMoveResize.h/.m with MoveResize.swift. Extract C enum/struct
types into ResizeTypes.h for shared ObjC/Swift access. AXUIElement memory
management now uses Swift ARC instead of manual CFRetain/CFRelease.
Update EMRAppDelegate and tests to use the new MoveResize class.
@supagroova
supagroova merged commit 7c2189e into main Mar 19, 2026
1 check passed
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.

1 participant