Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Gradient Support #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Custom Gradient Support #7

wants to merge 3 commits into from

Conversation

LePips
Copy link

@LePips LePips commented Nov 12, 2022

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 underlying LinearGradient. The default values match the current gradient.

Example
Text("Shimmering")
	.shimmering(gradientMask: .init(
		centerOpacity: 0.8,
		edgeOpacity: 0.3,
		startPoint: .topLeading,
		endPoint: .bottomTrailing,
		width: 0.1))

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
Screen.Recording.2022-11-12.at.2.55.22.PM.mov
Top to Bottom Example
Screen.Recording.2022-11-12.at.2.56.06.PM.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
Screen.Recording.2022-11-12.at.2.57.18.PM.mov
Inverted Mask Example
Screen.Recording.2022-11-12.at.2.54.33.PM.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.

@mickey-at-easelapps-ai
Copy link

Is this going to be merged? This seems like a reasonable pull request...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants