https://kotlinlang.org logo
#compose
Title
# compose
m

Manuel Wrage

12/25/2019, 1:35 PM
Is it planned to provide a style ambient for each material component? E.g. a ButtonStyleAmbient to change the default style of all buttons. Because it looks like code can get a bit messy if there will be no way for global theming.
a

Adam Powell

12/25/2019, 2:39 PM
No. The existence of this in the current style and theme XML system is a regret that caused a lot of abstraction problems.
☝️ 1
The material theming is limited to globally applicable properties like colors and shapes that are more universal across components, not targeting specific components from outside
m

Manuel Wrage

12/25/2019, 2:42 PM
So what's the recommended way to achieve consistent theming troughout parts of the ui? My guess is we have to create something like @Composable fun MyThemedButton()
a

Adam Powell

12/25/2019, 2:46 PM
The color, shape and typography theming will get you quite far. The problem with theme settings for specific widgets is that it becomes more inconsistent in a hurry. It's easier to theme things consistently without them 🙂
And yes, you can also always write your own composables that express your own style and use those consistently in a part of your UI
Coming back to this with a real keyboard rather than phone keyboard - the problem that things like
android:attr/defaultButtonStyle
created is that it targets implementation details of composite widgets rather than a generally applicable api
it made composite widgets fairly difficult to create with views while maintaining expectations that this sort of thing would work. See the Android date and time pickers over the years for a good example
Whether a composite date picker uses a raised or outlined button for a confirm button is an implementation detail of the picker and not necessarily something that the embedding app should be able to theme out from under the picker (unless the picker exposes an API for it)
m

Manuel Wrage

12/27/2019, 5:45 PM
I understand your points thanks for your response.
👍 1