Skip to content

[Feature][iOS] Add fixed Lynx viewport policy - #128

Open
Huxpro wants to merge 1 commit into
agent/ios-container-orientationfrom
agent/ios-fixed-lynx-viewport
Open

[Feature][iOS] Add fixed Lynx viewport policy#128
Huxpro wants to merge 1 commit into
agent/ios-container-orientationfrom
agent/ios-fixed-lynx-viewport

Conversation

@Huxpro

@Huxpro Huxpro commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add an Objective-C-compatible optional fixed Lynx viewport to SPKContext
  • apply the typed viewport to Lynx screen metrics and exact layout without changing the outer UIKit frame
  • preserve ordinary container behavior when no viewport is configured
  • reject invalid dimensions without crashing the host
  • document and test copy, merge, mapping, validation, and relayout behavior

Why

Full-page UIKit constraints can resize the outer Sparkling view after creation. A host that must preserve a legacy fixed Lynx viewport needs a public typed policy that keeps Lynx screen metrics and exact layout stable without exposing LynxViewBuilder or relying on outer-view hacks.

Test plan

  • xcodebuild -workspace packages/playground/ios/SparklingGo.xcworkspace -scheme SparklingGoTests -destination 'platform=iOS Simulator,id=EABC0BC7-12FE-4940-969C-FF3D6B9135F5' test
    • 336 tests in 20 suites passed
  • generated Sparkling-Swift.h exposes nullable -initWithWidth:height: and nullable SPKContext.lynxViewport
  • git diff --check

Formatting note

The repository's current Xcode swift-format reports pre-existing findings in the touched files (legacy enum/variable names, existing forEach, and existing collection commas). The added lines introduce no new formatter category beyond that baseline.

Stack

@Huxpro
Huxpro force-pushed the agent/ios-fixed-lynx-viewport branch from 37ff550 to 9bccb6d Compare August 9, 2026 04:35
Summary of change:
- Add an Objective-C-compatible optional fixed Lynx viewport to SPKContext and preserve it through context copy and merge.
- Apply typed viewport dimensions to Lynx builder screen metrics and exact layout while keeping the outer UIKit frame host-owned.
- Keep ordinary containers unchanged when no viewport is configured and reject invalid dimensions without crashing the host.
- Document the API and cover mapping, copy, merge, validation, and outer-frame relayout behavior.

TEST: xcodebuild -workspace packages/playground/ios/SparklingGo.xcworkspace -scheme SparklingGoTests -destination platform=iOS\ Simulator,id=EABC0BC7-12FE-4940-969C-FF3D6B9135F5 test; 336 tests in 20 suites passed
TEST: generated Sparkling-Swift.h exposes nullable -initWithWidth:height: and nullable SPKContext.lynxViewport
TEST: git diff --check

Co-authored-by: TRAE CLI <noreply@bytedance.com>
@Huxpro
Huxpro force-pushed the agent/ios-fixed-lynx-viewport branch from 9bccb6d to 9a82fc5 Compare August 9, 2026 04:44
@Huxpro
Huxpro changed the base branch from main to agent/ios-container-orientation August 9, 2026 07:55
@Huxpro
Huxpro requested review from LittleGru and dirtmelon August 11, 2026 10:34
@dirtmelon
dirtmelon requested a balanced review from Copilot August 11, 2026 23:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Objective-C-compatible fixed Lynx viewport policy while preserving the host-controlled UIKit frame.

Changes:

  • Adds validated viewport configuration with copy/merge support.
  • Applies fixed Lynx screen metrics and layout sizing.
  • Adds documentation and tests for mapping, validation, and relayout.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
SPKWrapperLynxViewProtocol.swift Adds viewport parameters.
SPKWrapperLynxView.swift Applies fixed Lynx sizing.
SPKLynxKitUtils.swift Maps context viewport into Lynx parameters.
SPKContext.swift Defines and stores the viewport policy.
SPKHybridContextTests.swift Tests parameter mapping.
SPKViewTests.swift Tests viewport stability after frame changes.
SPKSchemeTests.swift Tests validation, copying, and merging.
docs/zh/apis/sparkling-sdk-ios.md Documents the Chinese API.
docs/en/apis/sparkling-sdk-ios.md Documents the English API.
Suppressed comments (1)

packages/sparkling-sdk/ios/Sparkling/Sources/Service/LynxService/SPKWrapperLynxView.swift:210

  • fixedViewportSize is captured only during initialization, but this view also accepts replacement contexts through reload(_:) and replacement params through config(withParams:). Those paths update params without updating this cached value, so adding, changing, or clearing lynxViewport on reload has no effect (and an old viewport remains active). Centralize viewport synchronization and call it from initialization, config, and reload; when clearing the policy, restore metrics/layout from the current outer frame.
        self.fixedViewportSize = viewportSize

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 208 to 209
self.layoutWidthMode = params?.widthMode as? LynxViewSizeMode ?? .undefined
self.layoutHeightMode = params?.heightMode as? LynxViewSizeMode ?? .undefined
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