scenic icon indicating copy to clipboard operation
scenic copied to clipboard

Text only uses theme inside components

Open lawik opened this issue 6 years ago • 3 comments

Checklist

  • [x ] Check other issues and make sure that it is not reported yet.

Versions and Environment

Elixir: 1.8.1-otp-21 Erlang: 21.2.2 Scenic: 0.10.0 OS: MacOS

Steps to reproduce

Graph.build(font_size: 22, font: :roboto_mono, theme: :light)
  |> text("System")
  |> button("System")

Expected Behavior

Text would default to a dark color for the light theme and be visible.

Actual Behavior

Text is not a component, it is a primitive, which means it ignores the theme and renders white by default. The text ends up invisible. The text inside the button is handled as expected and visible.

Additional Comments

After some discussion with Emilio I believe this works as intended but I'd say it doesn't work the way you'd expect. I think following the theme is the work of the component, not the primitive. But the default way of putting arbitrary text on the screen is using the primitive. So we get no good default for the theming. Would it be reasonable for text to pick up the theme for default text color?

I think there is a potential for UI developer incredulity at why text just doesn't respect the theme setting. Do we want a component that simply wraps text and does the theming? What is that called? A Label? A ThemedText?

lawik avatar May 21 '19 12:05 lawik

I see the point you are making. Good question on if it should be a change to the text primitive to pick up the default from them or a label control.

I'm leaning toward updating the primitive itself.

boydm avatar May 21 '19 12:05 boydm

I took a brief look at it hoping I could throw a PR in here for that case. But I didn't quite follow where that piece of action would have to happen from my brief attempt.

If you could point me in the right direction I'd be happy to make a proof-of-concept we could consider.

lawik avatar May 21 '19 13:05 lawik

This isn't so straight-forward. Text is just a primitive and thus doesn't have a natural place to add code telling to pick up the contents of a theme. Instead it just inherits whatever the current font styles are form above it in the graph tree.

Probably the best place is if a theme is set during the Graph.build(...) function, then extract and set the font styles. Assuming they are not already set explicitly by the dev.

Memory is fuzzy. May have already done this? Need to take a look.

boydm avatar Jul 02 '19 07:07 boydm