Shimmer is a super-light modifier that adds a shimmering effect to any SwiftUI View, for example, to show that an operation is in progress. It works well on light and dark modes, and across iOS, macOS, tvOS, watchOS and visionOS.
Since GradientMask.startPoint and GradientMask.endPoint are properties, this allows the gradient to "move" in different directions. Due to this, I think that this overrides #4.
Right to Left Example
https://user-images.githubusercontent.com/20747774/201496531-581444e8-5d9e-4204-82bf-802ce0ec05ee.mov
Top to Bottom Example
https://user-images.githubusercontent.com/20747774/201496550-99f90a1a-9c99-4b07-ab97-d48116244210.mov
Inverse mask
Currently, the gradient is applied as a plain .mask(...) which doesn't suite my needs, as it changes the opacity of the underlying view to the opacity of the edge points of the LinearGradient, and I don't think that a shimmer should change the opacity of the underlying view. GradientMask.inverse determines whether the mask should be inverted or not, therefore having the shimmer effect be the gradient itself, and not a mask over the gradient. I personally think this should be the default behavior but I won't change the current implementation.
Current Implementation Example
https://user-images.githubusercontent.com/20747774/201496252-16c66f36-68ee-4034-8ad5-6b414892965d.mov
Inverted Mask Example
https://user-images.githubusercontent.com/20747774/201496481-64b57e6b-e59d-4c8b-b9b9-ba7528bebda1.mov
Other
I provide two view functions used to determine the mask
Remove the defaults to the Shimmer object. Redundant for this package's use.
Some personal linting styles applied
Previews are updated to show GradientMask customization
Update documentation. The phrases where the default was provided was redundant as they are already shown in the Xcode preview while you are reading them.
Hello there 👋
I'm going to be using a shimmer in my application and thought this package was great! However, I desired more customization over the gradient.
Overview
I change
GradientMask
to supply the definition used for the underlyingLinearGradient
. The default values match the current gradient.Example
```swift Text("Shimmering") .shimmering(gradientMask: .init( centerOpacity: 0.8, edgeOpacity: 0.3, startPoint: .topLeading, endPoint: .bottomTrailing, width: 0.1)) ```Since
GradientMask.startPoint
andGradientMask.endPoint
are properties, this allows the gradient to "move" in different directions. Due to this, I think that this overrides #4.Right to Left Example
https://user-images.githubusercontent.com/20747774/201496531-581444e8-5d9e-4204-82bf-802ce0ec05ee.movTop to Bottom Example
https://user-images.githubusercontent.com/20747774/201496550-99f90a1a-9c99-4b07-ab97-d48116244210.movInverse mask
Currently, the gradient is applied as a plain
.mask(...)
which doesn't suite my needs, as it changes the opacity of the underlying view to the opacity of the edge points of theLinearGradient
, and I don't think that a shimmer should change the opacity of the underlying view.GradientMask.inverse
determines whether the mask should be inverted or not, therefore having the shimmer effect be the gradient itself, and not a mask over the gradient. I personally think this should be the default behavior but I won't change the current implementation.Current Implementation Example
https://user-images.githubusercontent.com/20747774/201496252-16c66f36-68ee-4034-8ad5-6b414892965d.movInverted Mask Example
https://user-images.githubusercontent.com/20747774/201496481-64b57e6b-e59d-4c8b-b9b9-ba7528bebda1.movOther
Shimmer
object. Redundant for this package's use.GradientMask
customization