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

Custom properties for enum value #76

Closed
JakeLin opened this issue Feb 8, 2016 · 3 comments
Closed

Custom properties for enum value #76

JakeLin opened this issue Feb 8, 2016 · 3 comments
Milestone

Comments

@JakeLin
Copy link
Member

JakeLin commented Feb 8, 2016

TBD

Some discussions
#8
#59

@tbaranes
Copy link
Member

tbaranes commented Feb 9, 2016

The current ideas suggested (which could be working) in order to make that thread going further:

  1. Wave(up,40,10): MaskType(param1,param2,param3)
  2. More AnimatableView's children to add custom designable properties following the shape
  3. Other suggestions?

I prefer the first solution, but it could be maybe too hard to use, or improving a bit the syntax to be a bit more swift: Wave(direction:up,width:40,offset:10) (still annoying since the syntax is really strict)

@tbaranes
Copy link
Member

tbaranes commented Feb 9, 2016

Another approach:

public enum Mask {
    case Circle()
    case Star(branches: Int)
    case Wave(up: Bool, width: Int, offset: Int)
}

Mask.Circle()
Mask.Star(branches: 5)
Mask.Wave(up: true, width: 40, offset: 40)

I still missing a nice way to make this working with the interface builder, but I find this approach more swifty.

@JakeLin
Copy link
Member Author

JakeLin commented Feb 10, 2016

@tbaranes @lexrus came up similar ideas before to use Swiftified enum. But since IB doesn't support enum yet, it can't fix our problem.

I prefer option one, and it can at least move us forward. If we can support option one, we can subclass AnimatableView to support option two if needed.

To get the benefit of Swiftified enum, we can have

public enum Mask {
    case Circle()
    case Star(branches: Int)
    case Wave(up: Bool, width: Int, offset: Int)
}

in code then map the String value e.g. Star(6) to Star(branches:6) for IB. And fall back to default value Star(branches:5) if the user put it wrongly like Star5, Star(12 or Star2)

@JakeLin JakeLin added this to the v1.2 milestone Feb 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants