-
Notifications
You must be signed in to change notification settings - Fork 58
Update BlendMode #682
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
Update BlendMode #682
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,8 @@ package struct _ShapeStyle_Pack: Equatable { | |
| package struct Style: Equatable, Sendable { | ||
| package var fill: _ShapeStyle_Pack.Fill | ||
| package var opacity: Float | ||
| package var _blend: GraphicsBlendMode? | ||
| private var _blend: GraphicsBlendMode? | ||
|
|
||
| package var blend: GraphicsBlendMode { | ||
| _blend ?? .normal | ||
| } | ||
|
|
@@ -122,7 +122,11 @@ package struct _ShapeStyle_Pack: Equatable { | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private func indices(of name: ShapeStyle.Name) -> Range<Int> { | ||
| _openSwiftUIUnimplementedFailure() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| package subscript(name: _ShapeStyle_Name) -> _ShapeStyle_Pack.Slice { | ||
| Slice(pack: self, name: name) | ||
| } | ||
|
|
@@ -148,8 +152,20 @@ package struct _ShapeStyle_Pack: Equatable { | |
| } | ||
| } | ||
|
|
||
| package mutating func modify(name: _ShapeStyle_Name, levels: Range<Int>, _ modifier: (inout _ShapeStyle_Pack.Style) -> Void) { | ||
| _openSwiftUIUnimplementedFailure() | ||
| package mutating func modify( | ||
| name: ShapeStyle.Name, | ||
| levels: Range<Int>, | ||
| _ modifier: (inout ShapeStyle.Pack.Style) -> Void | ||
| ) { | ||
| let indices = indices(of: name) | ||
| guard !indices.isEmpty else { return } | ||
| var modifiedStyles = styles | ||
| for index in indices { | ||
| if levels.contains(modifiedStyles[index].key.level) { | ||
| modifier(&modifiedStyles[index].style) | ||
| } | ||
| } | ||
| styles = modifiedStyles | ||
| } | ||
|
|
||
| package mutating func adjustLevelIndices(of name: _ShapeStyle_Name, by offset: Int) { | ||
|
|
@@ -200,9 +216,17 @@ extension _ShapeStyle_Pack.Style { | |
| } | ||
|
|
||
| package mutating func applyBlend(_ blend: GraphicsBlendMode) { | ||
| _openSwiftUIUnimplementedFailure() | ||
| let shouldApply = !_SemanticFeature_v6.isEnabled | ||
| if shouldApply || _blend == nil { | ||
| _blend = blend | ||
| } | ||
| for index in effects.indices { | ||
| if shouldApply || effects[index]._blend == nil { | ||
| effects[index]._blend = blend | ||
| } | ||
| } | ||
| } | ||
|
|
||
| package var color: Color.Resolved? { | ||
| _openSwiftUIUnimplementedFailure() | ||
| } | ||
|
|
@@ -213,17 +237,24 @@ extension _ShapeStyle_Pack.Style { | |
| // MARK: - _ShapeStyle_Shape + _ShapeStyle_Pack | ||
|
|
||
| extension _ShapeStyle_Shape { | ||
| package var stylePack: _ShapeStyle_Pack { | ||
| package var stylePack: ShapeStyle.Pack { | ||
| get { | ||
| switch result { | ||
| case let .pack(pack): pack | ||
| default: .defaultValue | ||
| } | ||
| } | ||
| _modify { | ||
| var pack = stylePack | ||
| yield &pack | ||
| result = .pack(pack) | ||
| var styles: ShapeStyle.Pack | ||
| switch result { | ||
| case let .pack(pack): | ||
| styles = pack | ||
| result = .none | ||
| default: | ||
| styles = .defaultValue | ||
| } | ||
| yield &styles | ||
| result = .pack(styles) | ||
| } | ||
| } | ||
| } | ||
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.
In the
.primaryStyleoperation,_BlendModeShapeStylecurrently does nothing, which can causeShapeStyle.primaryStyle(in:)to returnnileven if the wrappedstyleprovides a primary style (other wrappers likeOffsetShapeStyleforward something here).🤖 Was this useful? React with 👍 or 👎