[Feature][iOS] Add fixed Lynx viewport policy - #128
Open
Huxpro wants to merge 1 commit into
Open
Conversation
Huxpro
force-pushed
the
agent/ios-fixed-lynx-viewport
branch
from
August 9, 2026 04:35
37ff550 to
9bccb6d
Compare
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
force-pushed
the
agent/ios-fixed-lynx-viewport
branch
from
August 9, 2026 04:44
9bccb6d to
9a82fc5
Compare
There was a problem hiding this comment.
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
fixedViewportSizeis captured only during initialization, but this view also accepts replacement contexts throughreload(_:)and replacement params throughconfig(withParams:). Those paths updateparamswithout updating this cached value, so adding, changing, or clearinglynxViewporton 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 |
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.
Summary
SPKContextWhy
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
LynxViewBuilderor 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' testSparkling-Swift.hexposes nullable-initWithWidth:height:and nullableSPKContext.lynxViewportgit diff --checkFormatting note
The repository's current Xcode
swift-formatreports pre-existing findings in the touched files (legacy enum/variable names, existingforEach, and existing collection commas). The added lines introduce no new formatter category beyond that baseline.Stack