Hi,
It provides three main advantages:
- A clear way to declare how your data should be displayed
- Boilerplate-free ListAdapters and PagerAdapters
- Macroid’s trademark emphasis on composability
A quick example of displaying Alice and Bob in a list (with font size proportional to their age):
import macroid._
import macroid.FullDsl._
import macroid.viewable._
// our data type
case class User(name: String, age: Int)
// defines how to view a User in a list
implicit def userListable(implicit ctx: ActivityContext, appCtx: AppContext) =
Listable[User].tw {
// the layout is a TextView
w[TextView]
} { user ⇒
// to display a user, we tweak the layout
text(user.name) + TextTweaks.size(user.age + 10)
}
// now we simply tweak the ListView
myListView <~ List(User("Alice", 12), User("Bob", 23)).listAdapterTweak
Please follow the link above for more documentation and cool features.
Also note that I’ve just submitted the library to the jCenter repo, but until it arrives there, you might need to use the following resolver:
Looking forward to hearing your feedback,
Nick