Bryan Herbst
11/12/2020, 5:10 PMandroidx.compose.material
named as though they are the the canonical implementation, when the messaging so far is that Material is an implementation of a specific design system?
Text
is a great example- it’s name alone ensures that it will be the first text Composable that most engineers reach for, but that presents two problems in my mind:
• Today, any project with its own design system has the burden of ensuring its engineers use their design system’s text instead of the innocent and generic sounding Text
• When a new Android-default design system inevitably comes along in the future, we have a similar problem- does the new design system create a HoloText
, create its own Composable named Text
, or does Material rename Text
to something else?
Contrast that with the Material Components library with View
s, which explicitly labels the material-themed components e.g. MaterialRadioButton
. There are some tricks under the hood to swap them in for framework components in some cases, but they still get a clear name in the library.Ian Lake
11/12/2020, 5:14 PMText
in your own package namespace? Not including the material library (as it is a purposefully a separate artifact) would be enough to prevent confusion.Mark Murphy
11/12/2020, 5:15 PMmaterial
by transitive dependenciesIan Lake
11/12/2020, 5:17 PMBryan Herbst
11/12/2020, 5:17 PMText
as well, but I see a few challenges there- first is that if developers are searching for documentation on a Text
composable they may not realize which package it is coming from so differences in the public API may cause unneeded confusionZach Klippenstein (he/him) [MOD]
11/12/2020, 5:17 PMBryan Herbst
11/12/2020, 5:20 PMBryan Herbst
11/12/2020, 5:22 PMButton
instead of the Material button, I don’t necessarily want to stop them from using a RippleIndication
from MaterialBryan Herbst
11/12/2020, 5:23 PMRippleIndication
)Mark Murphy
11/12/2020, 5:23 PMimplementation
and not api
. Ideally, I would have hair. 👴🏼
My guess is that there will be a cottage industry for Lint rules to enforce usage of the right composables.Bryan Herbst
11/12/2020, 5:24 PMMy guess is that there will be a cottage industry for Lint rules to enforce usage of the right composables.Absolutely. We already have one, and @Alexjlockwood has made one for his team as well
Alexjlockwood
11/12/2020, 5:28 PMAlexjlockwood
11/12/2020, 5:35 PMTextField
vs. MaterialTextField
component names. @Louis Pullen-Freilich [G]’s response:
That used to be the case, but then we heard the opposite feedback - developers would intuitively reach forlink to thread: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1599499510158400?thread_ts=1599494195.155900&cid=CJLTWPH7Sfirst, and be confused because it has no opinionated UX or styling, and requires a lot of work to look like a Material TextField. The current rename was to point developers to the opinionated component first, as this is usually the desired component.TextField
Alexjlockwood
11/12/2020, 5:38 PMimplementation
dependency on material entirely (cc @matvei)Alexjlockwood
11/12/2020, 5:40 PM.idea/codeInsightSettings.xml
. here’s what i have so far (note this currently hides RippleIndication
from auto-complete… i havent fixed that yet 😅)
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaProjectCodeInsightSettings">
<excluded-names>
<name>android.graphics.drawable.Icon</name>
<name>android.inputmethodservice.Keyboard.Row</name>
<name>android.preference.PreferenceActivity.Header</name>
<name>android.preference.SwitchPreference</name>
<name>android.provider.CalendarContract.Colors</name>
<name>android.text.Layout.Alignment</name>
<name>android.view.Surface</name>
<name>android.widget.Button</name>
<name>android.widget.CheckBox</name>
<name>android.widget.GridLayout.Alignment</name>
<name>android.widget.RadioButton</name>
<name>android.widget.Switch</name>
<name>android.widget.ToggleButton</name>
<name>androidx.compose.foundation.AmbientContentColor</name>
<name>androidx.compose.foundation.AmbientTextStyle</name>
<name>androidx.compose.foundation.Icon</name>
<name>androidx.compose.foundation.ProvideTextStyle</name>
<name>androidx.compose.foundation.Text</name>
<name>androidx.compose.foundation.contentColor</name>
<name>androidx.compose.foundation.layout.Spacer</name>
<name>androidx.compose.material.*</name>
<name>androidx.compose.material.icons.*</name>
<name>androidx.compose.ui.text.input.KeyboardType.Text</name>
<name>java.lang.reflect.Modifier</name>
<name>java.nio.file.WatchEvent.Modifier</name>
<name>java.time.format.TextStyle</name>
<name>org.w3c.dom.Text</name>
</excluded-names>
</component>
</project>
matvei
11/12/2020, 5:44 PMZach Klippenstein (he/him) [MOD]
11/12/2020, 6:57 PMJan Skrasek
11/12/2020, 8:45 PMIf you are building your own design system, wouldn't you just also useWell, if that would be usable practically, Compose foundations wouldn't have BasicText and the same the TextField should be without prefix, shouldn't be? The reality is that including material (at least the compose's) is a must and we and probably majority of others build upon it. Personally, this is one of my open questions if I should (re)name my components with prefix our let them just namespaced. At the same time, we know we wouldn't wrap everything, so it seems pretty weird to have TextField and CompanyButton.in your own package namespace? Not including the material library (as it is a purposefully a separate artifact) would be enough to prevent confusion.Text
Alexjlockwood
11/12/2020, 8:47 PMBryan Herbst
11/12/2020, 9:41 PMandroidx.compose.material.Button
-> com.target.design.Button
)matvei
11/13/2020, 11:29 AMYourCompanyDesignSystem
, just build by compose team.
Therefore, using YourCompanysDesignSystem
should feel as natural as using material or any other design system, without prefixes like MyCompanyLibrary
. This way the code is cleaner and the right practices are being promoted.
We don't want anyone to end up there:
fun C() {
Column(Modifier.materialClickable(...)) {
MaterialButton(onClick = {}) {
MaterialText("Click me")
}
MaterialText("Click this button")
}
}
Javier
11/13/2020, 11:46 AMimport foundation.Text
import material.Text as MaterialText