Repository navigation
fix(ios): apply box shadow alpha only once - #12
Merged
Merged
Conversation
CALayer multiplies shadowOpacity with the alpha of shadowColor. The box shadow code set shadowOpacity to color.a / 255 while also passing a CGColor already carrying that alpha, so an alpha color rendered with a^2 (e.g. NativeScript#33 showed as 0.04 instead of 0.2). Keep the alpha in the CGColor and set shadowOpacity to 1, matching Android. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
farfromrefug
marked this pull request as ready for review
October 30, 2026 13:44
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.
Problem
On iOS, box shadows with an alpha color render much fainter than on Android. In
background.ios.tsthe outer shadow layer sets bothshadowOpacity = color.a / 255andshadowColor = color.ios.CGColor. The CGColor already carries the alpha andCALayermultiplies the two, so the effective alpha is a² (#00000033= 0.2 renders as 0.04).Fix
Keep the alpha in the
CGColorand setshadowOpacity = 1. Android applies the alpha once.The previous
color.a ? a/255 : 1special case fora === 0is dropped: with alpha 0 the CGColor is fully transparent either way, so the shadow stays invisible (no behaviour change). Colors without alpha info still render at full opacity.Testing
No unit test: the code path needs native
CALayerAPIs and the repo's jest specs only cover pure TS. Visual check on iOS still required:boxShadow: 0 4 12 #00000033before/after.Follow-up (not in this PR)
packages/core/ui/text-base/index.ios.ts_setShadow(text-shadow) has the same pattern (shadowOpacity = a/255+shadowColor = CGColor).Refs: ossappscollective/OSS-DocumentScanner#797
🤖 Generated with Claude Code