contacts: center nickname and company under the contact name (#886)
- Commit
a8caeda948a87d050e83389fb8d08d06af5d9f49- Author
- Vayun Mathur <[email protected]>
- When
- 2026-10-31 22:09 UTC (1 month ago)
- Parents
110dc93
The nickname (and company) line on the contact details header rendered flush against the start edge in portrait instead of centered under the name. Root cause: ProfileNameColumn's name FlowRow uses fillMaxWidth so wrapped name lines can centre, which stretches the enclosing Column to full width. That Column had no horizontalAlignment, so its wrap-content siblings (nickname, company Text) were placed at the start; their textAlign = Center had no effect because each Text was only as wide as its content. Fix: the Column now aligns its children CenterHorizontally in portrait (Start in the landscape header, unchanged). Shared-element keys and layout of the name parts are untouched. Verified: ./gradlew :contacts:compileDevKotlin, :contacts:lint clean.
Diff
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsHeaderLandscape.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsHeaderLandscape.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsHeaderLandscape.ktindex a0702e4611..501a2102ff 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsHeaderLandscape.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsHeaderLandscape.kt@@ -55,7 +55,17 @@ internal fun ProfileNameColumn( startAligned: Boolean, modifier: Modifier = Modifier, ) {- Column(modifier = modifier) {+ Column(+ modifier = modifier,+ // The full-width FlowRow stretches this column, so wrap-content siblings (nickname,+ // company) need the column itself to centre them; textAlign alone does nothing there.+ horizontalAlignment = if (startAligned) {+ androidx.compose.ui.Alignment.Start+ } else {+ androidx.compose.ui.Alignment.CenterHorizontally+ },+ ) {+ // Composed // Composed from the structured name rather than the joined display name, so that each part can // travel to the field that owns it when this page morphs into the editor. A single Text could // only ever land in one of them.