Repository navigation
fix(render): keep text and clips aligned during matched geometry animations #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9f06a01
fix(render): allow pure translations when merging display list items
Kyle-Ye a4967a7
fix(text): derive TextLayoutManager major axis from writing mode
Kyle-Ye 64cead0
fix(text): apply content interpolation to styled text
Kyle-Ye d53192a
test(render): require exact matched geometry snapshots
Kyle-Ye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
69 changes: 69 additions & 0 deletions
69
Tests/OpenSwiftUICoreTests/View/Text/ResolvedStyledTextTests.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| // | ||
| // ResolvedStyledTextTests.swift | ||
| // OpenSwiftUICoreTests | ||
|
|
||
| #if canImport(Darwin) | ||
| import Foundation | ||
| @_spi(Private) @testable import OpenSwiftUICore | ||
| import Testing | ||
|
|
||
| struct ResolvedStyledTextTests { | ||
| @Test | ||
| func unanimatedRunCanChangeLengthBetweenOrdinaryRuns() throws { | ||
| let source = try timerText("9") | ||
| let next = try timerText("10") | ||
| let differentUnit = try timerText("10", unit: "minutes") | ||
|
|
||
| #expect(!source.requiresTransition(to: next)) | ||
| #expect(source.requiresTransition(to: differentUnit)) | ||
| } | ||
|
|
||
| @Test | ||
| func animatedRunRequiresTransitionWhenItsTextChanges() throws { | ||
| let source = try timerText("9", strategy: .animated) | ||
| let next = try timerText("10", strategy: .animated) | ||
|
|
||
| #expect(source.requiresTransition(to: next)) | ||
| } | ||
|
|
||
| @Test | ||
| func changingInterpolationStrategyRequiresTransitionForTheSameText() throws { | ||
| let source = try timerText("9", strategy: .unanimated) | ||
| let next = try timerText("9", strategy: .animated) | ||
|
|
||
| #expect(source.requiresTransition(to: next)) | ||
| } | ||
|
|
||
| @Test(arguments: [ | ||
| (Text.WritingMode.horizontalTopToBottom, Axis.horizontal), | ||
| (.verticalRightToLeft, .vertical), | ||
| ]) | ||
| func numericTransitionSuppliesAxisForWritingMode(_ mode: Text.WritingMode, _ expectedAxis: Axis) throws { | ||
| let text = try timerText("9", writingMode: mode) | ||
| var state = ContentTransition.State(transition: .numericText(.fixed())) | ||
|
|
||
| text.modifyTransition(state: &state, to: text) | ||
|
|
||
| #expect(state.transition == .numericText(.fixed().axis(expectedAxis))) | ||
| } | ||
|
|
||
| private func timerText( | ||
| _ digits: String, | ||
| unit: String = "seconds", | ||
| strategy: AttributeScopes.OpenSwiftUIAttributes.InterpolationStrategy = .unanimated, | ||
| writingMode: Text.WritingMode = .horizontalTopToBottom | ||
| ) throws -> ResolvedStyledText { | ||
| var time = AttributedString(digits) | ||
| time.interpolationStrategy = strategy | ||
| let text = AttributedString("Time: ") + time + AttributedString(" " + unit) | ||
| let storage = try NSAttributedString(text, including: \.openSwiftUI) | ||
| var layout = TextLayoutProperties() | ||
| layout.writingMode = writingMode | ||
| return ResolvedStyledText.styledText( | ||
| storage: storage, | ||
| layoutProperties: layout, | ||
| features: [.checkInterpolationStrategy] | ||
| ) | ||
| } | ||
| } | ||
| #endif |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
.checkInterpolationStrategyis enabled and the destination removes a trailing ordinary run, this guard stops enumeration withoffset == otherStorage.length, so the final comparison incorrectly returnsfalse. For example, changing"Time: " + unanimated("9") + " seconds"to"Time: " + unanimated("9")suppresses the required transition for deleting" seconds", even though that run is not marked unanimated. Track whether source runs remain when the destination is exhausted rather than treating destination exhaustion alone as a successful match.Useful? React with 👍 / 👎.