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

Extending anvil #101

Open
FunnyDevs opened this issue Mar 3, 2017 · 2 comments
Open

Extending anvil #101

FunnyDevs opened this issue Mar 3, 2017 · 2 comments

Comments

@FunnyDevs
Copy link

Is possibile a tutorial to extend Anvil with custom views (like Anko)???

@zserge
Copy link
Collaborator

zserge commented Mar 3, 2017

@FunnyDevs it is possible to extend Anvil with custom views, although maybe not like with Anko.

  1. You can always build "components", self-contained ViewGroups (extended from RenderableView).
  2. You can always mounts custom views into existing renderables, like v(MyCustomView.class, () -> {...}).
  3. You can now create your own Anvil.ViewFactory implementations, register them, and then use them to build custom classes on demand (e.g. if you class constructor is now just View(Context), but something more complex, like using styles etc.

Starting with Anvil 0.5.0 (just released it today) you may set custom attributes as well, just do attr("myAttr", someValue) and that will call setMyAttr(someValue) on your view if fthe value has been changed since the last call. In the worst case that will use reflection, but you may also register your own Anvil.AttributeSetter to handle your custom attributes and speed up things.

@FunnyDevs
Copy link
Author

i would like to do like Anko that maps custom function (like toast(), dialog()), but with custom view:
customview()
Must i do a custom Anvil.ViewFactory???

Is there a changelog of new release???

Thanks

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

No branches or pull requests

2 participants