-
Notifications
You must be signed in to change notification settings - Fork 163
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
Support TextView#setTextAppearance
in layout DSL
#66
Comments
Does the word 'support' you used means that providing DSL-style setter with implicit Context? i.e. |
Unless the implicit parameter doesn't break a following method chain. I |
Method chaining works fine with an implicit parameter:
Based on this issue, I imagined something like this:
Could you try this? |
The last line does not be compiled.
yields the error |
Anyway, method chaining |
I'll look into it after first draft of new layout converter is done. class ValueWithContext[A] private (val value: A, val context: Context)
object ValueWithContext {
implicit def apply[A](value: A)(implicit context: Context) =
new ValueWithContext(value, context)
}
// ...
class Bar {
// ..
def something_=(vwc: ValueWithContext[Int]) = something(vwc.value)(vwc.context)
//.. |
A brief confirmation in REPL: scala> :paste
// Entering paste mode (ctrl-D to finish)
class C
class V[A](val v: A, val c: C)
object V {
implicit def apply[A](v: A)(implicit c: C) = new V(v, c)
}
// Exiting paste mode, now interpreting.
warning: there were 1 feature warning(s); re-run with -feature for details
defined class C
defined class V
defined module V
scala> class B {
| var _a: Int = _
| def a = _a
| def a(v: Int)(implicit c: C) = { this._a = v; this }
| def a_=(v: V[Int]) = this.a(v.v)(v.c)
| }
defined class B
scala> val b = new B
b: B = B@1ddf7713
scala> b.a = 1
<console>:14: error: value V is not a member of object $iw
b.a = 1
^
scala> b.a(1)
<console>:15: error: could not find implicit value for parameter c: C
b.a(1)
^
scala> implicit val c = new C
c: C = C@494a8227
scala> b.a(1)
res5: B = B@1ddf7713
scala> b.a
res6: Int = 1
scala> b.a = 2
b.a: Int = 2
scala> b.a
res7: Int = 2 |
The error message in line 14 looks somewhat ugly though. |
Good, looking forward the integration into Scaloid! |
Currently we don't have any shortcut for [void setTextAppearance(Context, Int)](https://developer.android.com/reference/android/widget/TextView.html#setTextAppearance(android.content.Context, int)) as it takes
Context
as one of args. Is there any way to support this by Scaloid DSL?Because it refers to another attr, it's hard to be automatically converted from XML.
The text was updated successfully, but these errors were encountered: