ui: route the last raw buttons through OwButton, with a content slot
All checks were successful
android-ci / android (pull_request) Successful in 14m48s

Chat's send, Profile's save, and both Rotate actions were still material
Buttons — the 50%-rounded pill the design pass exists to remove. They now
take the design-system shape and height.

OwButton gains an optional RowScope content slot so a caller that needs a
spinner beside its label (chat send while a message is pending) keeps that
behaviour without dropping back to a raw Button. The slot is additive: the
existing text/leading-icon path is unchanged for every other caller.

Rotate's confirm is the Destructive tier — it destroys the current onion —
and the post-rotation action is labelled "Share the new invite" instead of
"Back — share the new invite": the top bar already owns the chevron back.
This commit is contained in:
apk-dev 2026-10-29 00:44:22 -04:00
commit dc45d9cb81
No known key found for this signature in database
4 changed files with 42 additions and 26 deletions

View file

@ -22,7 +22,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
@ -52,6 +51,7 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.siriusdevops.onionwire.R import com.siriusdevops.onionwire.R
import com.siriusdevops.onionwire.ui.components.OwButton
import com.siriusdevops.onionwire.ui.components.OwIconButton import com.siriusdevops.onionwire.ui.components.OwIconButton
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.siriusdevops.onionwire.WireViewModel import com.siriusdevops.onionwire.WireViewModel
@ -388,7 +388,8 @@ fun ChatScreen(
// Always drawn, never swapped out for a spinner: a button that // Always drawn, never swapped out for a spinner: a button that
// changes size under the thumb — or disappears — is how "I hit // changes size under the thumb — or disappears — is how "I hit
// send and nothing happened" gets reported. // send and nothing happened" gets reported.
Button( OwButton(
text = "Send",
enabled = draft.isNotBlank() && pending == null, enabled = draft.isNotBlank() && pending == null,
onClick = send, onClick = send,
modifier = Modifier.testTag("chat-send"), modifier = Modifier.testTag("chat-send"),

View file

@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
@ -34,6 +33,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.siriusdevops.onionwire.R import com.siriusdevops.onionwire.R
import com.siriusdevops.onionwire.ui.components.OwButton
import com.siriusdevops.onionwire.ui.components.OwIconButton import com.siriusdevops.onionwire.ui.components.OwIconButton
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.siriusdevops.onionwire.WireViewModel import com.siriusdevops.onionwire.WireViewModel
@ -240,7 +240,8 @@ fun ProfileScreen(
.padding(12.dp), .padding(12.dp),
horizontalArrangement = Arrangement.End, horizontalArrangement = Arrangement.End,
) { ) {
Button( OwButton(
text = if (busy) "Saving…" else "Save",
onClick = { onClick = {
addressError = null addressError = null
saveError = null saveError = null
@ -253,7 +254,7 @@ fun ProfileScreen(
} }
if (problem != null) { if (problem != null) {
addressError = problem addressError = problem
return@Button return@OwButton
} }
scope.launch { scope.launch {
busy = true busy = true
@ -300,9 +301,7 @@ fun ProfileScreen(
}, },
enabled = !busy && profileSaveEnabled(loaded, form), enabled = !busy && profileSaveEnabled(loaded, form),
modifier = Modifier.testTag("profile-save"), modifier = Modifier.testTag("profile-save"),
) { )
Text(if (busy) "Saving…" else "Save")
}
} }
status?.let { status?.let {

View file

@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
@ -32,6 +31,8 @@ import androidx.compose.ui.unit.dp
import com.siriusdevops.onionwire.R import com.siriusdevops.onionwire.R
import com.siriusdevops.onionwire.ui.components.Label import com.siriusdevops.onionwire.ui.components.Label
import com.siriusdevops.onionwire.ui.components.Mono import com.siriusdevops.onionwire.ui.components.Mono
import com.siriusdevops.onionwire.ui.components.OwButton
import com.siriusdevops.onionwire.ui.components.OwButtonVariant
import com.siriusdevops.onionwire.ui.components.OwIconButton import com.siriusdevops.onionwire.ui.components.OwIconButton
/** /**
@ -109,11 +110,13 @@ fun RotateScreen(
) )
Spacer(Modifier.height(12.dp)) Spacer(Modifier.height(12.dp))
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button( OwButton(
text = "Rotate",
variant = OwButtonVariant.Destructive,
enabled = typed.trim().equals("ROTATE", ignoreCase = true) && enabled = typed.trim().equals("ROTATE", ignoreCase = true) &&
!busy, !busy,
onClick = { busy = true; error = null }, onClick = { busy = true; error = null },
) { Text("Rotate") } )
if (busy) CircularProgressIndicator() if (busy) CircularProgressIndicator()
} }
} }
@ -151,7 +154,11 @@ fun RotateScreen(
color = MaterialTheme.colorScheme.onSurfaceVariant, color = MaterialTheme.colorScheme.onSurfaceVariant,
) )
Spacer(Modifier.height(16.dp)) Spacer(Modifier.height(16.dp))
Button(onClick = onBack) { Text("Back — share the new invite") } OwButton(
text = "Share the new invite",
variant = OwButtonVariant.Secondary,
onClick = onBack,
)
} }
} }
} }

View file

@ -58,6 +58,7 @@ fun OwButton(
variant: OwButtonVariant = OwButtonVariant.Primary, variant: OwButtonVariant = OwButtonVariant.Primary,
enabled: Boolean = true, enabled: Boolean = true,
leadingIconRes: Int? = null, leadingIconRes: Int? = null,
content: (@Composable androidx.compose.foundation.layout.RowScope.() -> Unit)? = null,
) { ) {
val height = when (variant) { val height = when (variant) {
OwButtonVariant.Outline -> OwSize.ButtonCompact OwButtonVariant.Outline -> OwSize.ButtonCompact
@ -69,13 +70,17 @@ fun OwButton(
OwButtonVariant.Outline -> Color.Transparent OwButtonVariant.Outline -> Color.Transparent
OwButtonVariant.Destructive -> OwColors.DangerTint OwButtonVariant.Destructive -> OwColors.DangerTint
} }
val content = when (variant) { val contentColor = when (variant) {
OwButtonVariant.Primary -> OwColors.Canvas OwButtonVariant.Primary -> OwColors.Canvas
OwButtonVariant.Secondary -> OwColors.TextPrimary OwButtonVariant.Secondary -> OwColors.TextPrimary
OwButtonVariant.Outline -> OwColors.TextPrimary OwButtonVariant.Outline -> OwColors.TextPrimary
OwButtonVariant.Destructive -> OwColors.Danger OwButtonVariant.Destructive -> OwColors.Danger
} }
val weight = if (variant == OwButtonVariant.Primary) FontWeight.SemiBold else FontWeight.Medium val weight = if (variant == OwButtonVariant.Primary) FontWeight.SemiBold else FontWeight.Medium
// A local val, not the parameter: a parameter captured by the Button's
// content lambda cannot be smart-cast, and the nullable-call error reads as
// a Compose problem when it is only a Kotlin capture rule.
val customContent = content
Button( Button(
onClick = onClick, onClick = onClick,
@ -89,7 +94,7 @@ fun OwButton(
}, },
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = container, containerColor = container,
contentColor = content, contentColor = contentColor,
disabledContainerColor = when (variant) { disabledContainerColor = when (variant) {
OwButtonVariant.Outline -> Color.Transparent OwButtonVariant.Outline -> Color.Transparent
OwButtonVariant.Primary -> OwColors.SurfaceInteractive OwButtonVariant.Primary -> OwColors.SurfaceInteractive
@ -101,19 +106,23 @@ fun OwButton(
elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp, pressedElevation = 0.dp), elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp, pressedElevation = 0.dp),
contentPadding = ButtonDefaults.ContentPadding, contentPadding = ButtonDefaults.ContentPadding,
) { ) {
Row( if (customContent != null) {
verticalAlignment = Alignment.CenterVertically, customContent()
horizontalArrangement = Arrangement.Center, } else {
) { Row(
if (leadingIconRes != null) { verticalAlignment = Alignment.CenterVertically,
Icon( horizontalArrangement = Arrangement.Center,
painter = painterResource(leadingIconRes), ) {
contentDescription = null, if (leadingIconRes != null) {
modifier = Modifier.size(18.dp), Icon(
) painter = painterResource(leadingIconRes),
Spacer(Modifier.width(8.dp)) contentDescription = null,
modifier = Modifier.size(18.dp),
)
Spacer(Modifier.width(8.dp))
}
Text(text, style = MaterialTheme.typography.labelLarge, fontWeight = weight)
} }
Text(text, style = MaterialTheme.typography.labelLarge, fontWeight = weight)
} }
} }
} }