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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom gradient start point #380

Merged
merged 6 commits into from
Dec 31, 2016
Merged

Conversation

tbaranes
Copy link
Member

@tbaranes tbaranes commented Dec 22, 2016

Close #378

Using StartPoint.custom(0,0.5,0,0), it will render:

screen shot 2016-12-22 at 10 44 43

That may be useful! After a quick first look to update the example app, I have to say that I'm a bit lost with the ParamType 😨 @lastMove How am I supposed to create ParamType using custom parameters?

Missing:

  • Example app
  • Changelog

@IBAnimatableBot
Copy link

IBAnimatableBot commented Dec 22, 2016

1 Warning
⚠️ Consider adding supporting documentation to this change. Documentation can be found in the docs directory.

Generated by 🚫 danger

@lastMove
Copy link
Member

lastMove commented Dec 22, 2016

Hello,
Nice feature !
How do you want to render it ?
Presently in the Playground part of the app in "predefined gradients" section;
there is a Picker with 2 components (one for the gradient, the other one for the startPoint).
So it will be difficult to had 4 more components to customise that.
Maybe we should create another section.
ParamType allows To generate and manage arrays of possible values for a pickerComponent.
And you can generate this array from enum; Sample :

let gradientValues = ParamType(fromEnum: GradientStartPoint.self)
print(gradientValues.value(at: 0))
// "top"
print(gradientValues.value(at: 4))
// "bottomRight"

It's like an array generated from enum values.

It works also to generate array of possible values from number interval :

private let numberParam = ParamType.number(min: -50, max: 50, interval: 5, ascending: true, unit: "")
// this will generate this array : [-50, -45, -40, -35, ... , 35, 40, 45, 50]

So numberParam.value(at: 0) will gives -50.

@tbaranes
Copy link
Member Author

I was thinking to add directly a predefined startPoint, but you are right, it will be for the best to add a section to render it.
Thanks for the explanation! I will give it a try.

@tbaranes
Copy link
Member Author

tbaranes commented Dec 22, 2016

Working perfectly @lastMove! Thanks for the tips.

simulator screen shot 22 dec 2016 14 22 29

One more question, any suggestion how we should update the current example (it won't compile since .custom isn't compatible with the other startPoint). I see that for the animation you used PickerEntry, should I do the same or is there a better existing solution?

Copy link
Member

@JakeLin JakeLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ready to go👍

self = .custom(start: CGPoint(x: params[safe: 0]?.toDouble() ?? 0,
y: params[safe: 1]?.toDouble() ?? 0),
end: CGPoint(x: params[safe: 2]?.toDouble() ?? 0,
y: params[safe: 3]?.toDouble() ?? 0))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great method from @lastMove for safe extracting data from params

@tbaranes
Copy link
Member Author

Not really, the gradient example is still broken 😬 Open to any suggestion

@tbaranes tbaranes force-pushed the feature/custom_gradient_start branch from bac8cf0 to 7d6a27f Compare December 27, 2016 17:25
@lastMove lastMove self-assigned this Dec 30, 2016
switch name {
case "top":
self = .top
case "topRight":
case "topright":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I always forgot that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) It's error-prone. I saw it when testing with the exemple app.

@lastMove
Copy link
Member

Should be good know.
@tbaranes the problem was that since GradientStartPoint does not anymore have a String RawValue ParamType.enumeration(values: ["top", "topLeft", "topRight", "left", "right", "bottom", "bottomRight", "bottomLeft"])

@tbaranes
Copy link
Member Author

@lastMove thanks for that!

@tbaranes tbaranes merged commit 9e962d8 into master Dec 31, 2016
@tbaranes tbaranes deleted the feature/custom_gradient_start branch January 15, 2017 10:35
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

4 participants