Adds @objc from Slot feature and updates obj sample app#71
Adds @objc from Slot feature and updates obj sample app#71Sonal-Kachare wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThe PR expands the Objective-C interop surface of the core ChangesObjC Interop + NDDisplayHelper Consolidation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ios-objc-sample/NativeDisplaySampleObjc/NDDisplayHelper.swift`:
- Line 33: The condition checking parentWidth > 0 before subtracting 32 allows
negative inner widths when parentWidth is between 0 and 32, creating invalid
sizes. In the NDDisplayHelper.swift file, locate all three instances where
parentSize is being computed (at the lines handling parentWidth > 0 checks), and
modify the logic to ensure the resulting width value is never negative by either
changing the condition to check parentWidth >= 32, or by using a max operation
to clamp the computed width to a minimum of 0, ensuring valid sizing dimensions
are always passed to CGSize initialization.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 44efad51-e829-49c5-b812-d5b01c7c5c16
📒 Files selected for processing (13)
ios-objc-sample/NativeDisplaySampleObjc/BannerShowcaseViewController.mios-objc-sample/NativeDisplaySampleObjc/BridgeIntegrationViewController.mios-objc-sample/NativeDisplaySampleObjc/CleverTapIntegrationViewController.mios-objc-sample/NativeDisplaySampleObjc/NDDisplayHelper.swiftios-objc-sample/NativeDisplaySampleObjc/SampleHelpers.swiftios-objc-sample/NativeDisplaySampleObjc/SlotDemoViewController.mios/Sources/CleverTapNativeDisplay/Bridge/NativeDisplayBridgeListener.swiftios/Sources/CleverTapNativeDisplay/Evaluator/VariableEvaluator.swiftios/Sources/CleverTapNativeDisplay/Placement/NativeDisplaySlotManager.swiftios/Sources/CleverTapNativeDisplay/Renderer/NativeDisplayRenderer.swiftios/Sources/CleverTapNativeDisplay/UiKit/NativeDisplayCollectionViewCell.swiftios/Sources/CleverTapNativeDisplay/UiKit/NativeDisplayTableViewCell.swiftios/Sources/CleverTapNativeDisplay/UiKit/NativeDisplayViewController.swift
💤 Files with no reviewable changes (3)
- ios/Sources/CleverTapNativeDisplay/Evaluator/VariableEvaluator.swift
- ios/Sources/CleverTapNativeDisplay/Renderer/NativeDisplayRenderer.swift
- ios-objc-sample/NativeDisplaySampleObjc/SampleHelpers.swift
| ) -> NativeDisplayUIView? { | ||
| do { | ||
| let config = try ResolvedConfig.from(jsonData: jsonData) | ||
| let parentSize: CGSize? = parentWidth > 0 ? CGSize(width: parentWidth - 32, height: 0) : nil |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clamp computed parent width before creating parentSize.
At Line 33, Line 102, and Line 147, parentWidth > 0 still allows negative inner widths when 0 < parentWidth < 32, which can produce invalid sizing.
💡 Proposed fix
- let parentSize: CGSize? = parentWidth > 0 ? CGSize(width: parentWidth - 32, height: 0) : nil
+ let innerWidth = max(parentWidth - 32, 0)
+ let parentSize: CGSize? = innerWidth > 0 ? CGSize(width: innerWidth, height: 0) : nil- let parentSize: CGSize? = parentWidth > 0 ? CGSize(width: parentWidth - 32, height: 0) : nil
+ let innerWidth = max(parentWidth - 32, 0)
+ let parentSize: CGSize? = innerWidth > 0 ? CGSize(width: innerWidth, height: 0) : nil- let parentSize: CGSize? = parentWidth > 0 ? CGSize(width: parentWidth - 32, height: 0) : nil
+ let innerWidth = max(parentWidth - 32, 0)
+ let parentSize: CGSize? = innerWidth > 0 ? CGSize(width: innerWidth, height: 0) : nilAlso applies to: 102-102, 147-147
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ios-objc-sample/NativeDisplaySampleObjc/NDDisplayHelper.swift` at line 33,
The condition checking parentWidth > 0 before subtracting 32 allows negative
inner widths when parentWidth is between 0 and 32, creating invalid sizes. In
the NDDisplayHelper.swift file, locate all three instances where parentSize is
being computed (at the lines handling parentWidth > 0 checks), and modify the
logic to ensure the resulting width value is never negative by either changing
the condition to check parentWidth >= 32, or by using a max operation to clamp
the computed width to a minimum of 0, ensuring valid sizing dimensions are
always passed to CGSize initialization.
Summary by CodeRabbit
Release Notes
New Features
Improvements
Chores