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

Radial Gradients #527

Merged
merged 5 commits into from
Jan 10, 2018
Merged

Radial Gradients #527

merged 5 commits into from
Jan 10, 2018

Conversation

tbaranes
Copy link
Member

@tbaranes tbaranes commented Jan 8, 2018

Close #508

Currently in this PR:

  • New enum GradientMode: currently supporting linear and radial
  • Working version of radial gradient (basic configuration only)
  • Moved "gradients" example to their own section (playground example), + add of radial gradients example
  • Documentation and CHANGELOG

Currently missing:

  • Add startPoints (and custom) support to radial gradient

Any feedbacks welcome :)

simulator screen shot - iphone 6 - 2018-01-08 at 11 13 57

@IBAnimatableBot
Copy link

IBAnimatableBot commented Jan 8, 2018

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@tbaranes
Copy link
Member Author

tbaranes commented Jan 8, 2018

There's still rooms for improvements but I think we can already merge this then add the missing features in a future PR (support for startPoint), helps welcome 😬

@tbaranes tbaranes changed the title [WIP] Radial Gradients Radial Gradients Jan 8, 2018

func configurePoints(with startPoint: GradientStartPoint) {
private func layerPoints() -> (CGPoint, CGPoint) {
Copy link
Member

@gkye gkye Jan 8, 2018

Choose a reason for hiding this comment

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

Could we keep the name configurePoints or configureGradientPoints? It's a lot more readable imo

Copy link
Member Author

Choose a reason for hiding this comment

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

I’d like to drop the comfigure because it doesn’t change the layer anymore, it will simply returns the points. Beside that, I’m completely open for another name!

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe gradientPonts?

Copy link
Member

Choose a reason for hiding this comment

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

Okay that makes sense. gradientPoints should work 😄

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.

Great job👍, this is a very useful feature, please merge in💪.

return gradientLayer
extension CALayer {

fileprivate func makeImage() -> UIImage? {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use private now

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't do that, it's still in use in the GradientDesignable extension used for the navigation bar, otherwise, I could move it, but it's quite useful to have it in the layer extension 😬

super.init(frame: frame)
layer.insertSublayer(gradientLayer, at: 0)
autoresizingMask = [.flexibleWidth, .flexibleHeight]
extension GradientDesignable {
Copy link
Member

Choose a reason for hiding this comment

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

Since all methods are private, we can just mark GradientDesignable as private and remove the others.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, that's not working in swift, you can try this in a playground as an example:

final class Test {

}

private extension Test {

    func test() {
        print("test")
    }

}

let test = Test()
test.test()

You can call the method from the private extension from outside even if the extension is private, that's why I moved the private to the methods instead of the extension.

Copy link
Member

Choose a reason for hiding this comment

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

@tbaranes interesting, I didn't know that 🤣

@JakeLin JakeLin merged commit 6dfc024 into master Jan 10, 2018
@JakeLin JakeLin deleted the feature/radial_gradient branch January 10, 2018 22:55
@JakeLin
Copy link
Member

JakeLin commented Jan 10, 2018

@tbaranes @gkye thanks, guys, I merged this useful feature in now 👏

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