Skip to content

Commit cd1565a

Browse files
authored
Add: Trailing chevron on tappable preference rows (#152)
1 parent a8a2b85 commit cd1565a

17 files changed

Lines changed: 83 additions & 93 deletions

File tree

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/PathwayButtonsComponent.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,15 @@ private fun <T : PathwayButtonItem> SelectableButton(
196196
Text(label.buttonLabel)
197197
}
198198
} else {
199-
OutlinedButton(modifier = modifier, onClick = { onClick(index, label) }) {
200-
Text(label.buttonLabel)
199+
OutlinedButton(
200+
modifier = modifier,
201+
onClick = { onClick(index, label) }
202+
) {
203+
Text(
204+
text = label.buttonLabel,
205+
// Force text color to onSurface to keep the same text style as the selected button.
206+
color = MaterialTheme.colorScheme.onSurface
207+
)
201208
}
202209
}
203210
}

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/BasePreference.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import androidx.compose.foundation.layout.defaultMinSize
2222
import androidx.compose.foundation.layout.fillMaxHeight
2323
import androidx.compose.foundation.layout.height
2424
import androidx.compose.foundation.layout.padding
25+
import androidx.compose.foundation.layout.size
2526
import androidx.compose.foundation.layout.width
27+
import androidx.compose.material.icons.Icons
28+
import androidx.compose.material.icons.automirrored.outlined.KeyboardArrowRight
29+
import androidx.compose.material3.Icon
2630
import androidx.compose.material3.MaterialTheme
2731
import androidx.compose.material3.Surface
2832
import androidx.compose.material3.Text
@@ -31,6 +35,7 @@ import androidx.compose.runtime.Composable
3135
import androidx.compose.ui.Alignment
3236
import androidx.compose.ui.Modifier
3337
import androidx.compose.ui.text.font.FontWeight
38+
import androidx.compose.ui.text.style.TextAlign
3439
import androidx.compose.ui.unit.dp
3540
import androidx.compose.ui.tooling.preview.Preview
3641

@@ -84,15 +89,20 @@ internal fun BaseTextPreference(
8489
label = label,
8590
value = description,
8691
hideDivider = true,
87-
action = if (value != null) {
88-
{
92+
action = {
93+
if (value != null) {
8994
Text(
9095
text = value,
96+
textAlign = TextAlign.Center,
9197
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Bold)
9298
)
9399
}
94-
} else {
95-
null
100+
Icon(
101+
imageVector = Icons.AutoMirrored.Outlined.KeyboardArrowRight,
102+
contentDescription = null,
103+
modifier = Modifier.padding(start = 4.dp, end = 12.dp).size(24.dp),
104+
tint = MaterialTheme.colorScheme.onSurfaceVariant
105+
)
96106
}
97107
)
98108
}
@@ -110,15 +120,15 @@ internal fun BasicPreference(
110120
.defaultMinSize(minHeight = 64.dp)
111121
.height(IntrinsicSize.Min)
112122
.then(modifier)
113-
.padding(start = 16.dp, end = 16.dp, top = 12.dp, bottom = 12.dp),
123+
.padding(start = 16.dp, end = if (action != null) { 0.dp } else { 16.dp }, top = 12.dp, bottom = 12.dp),
114124
verticalAlignment = Alignment.CenterVertically
115125
) {
116126
Column(modifier = Modifier.weight(1f)) {
117127
Text(text = label, style = MaterialTheme.typography.bodyLarge)
118128
Text(
119129
text = value,
120130
style = MaterialTheme.typography.bodyMedium,
121-
color = MaterialTheme.colorScheme.secondary
131+
color = MaterialTheme.colorScheme.onSurfaceVariant
122132
)
123133
}
124134
if (action != null) {

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/CcrSetpointPreference.kt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,14 @@ fun CcrSetpointPreference(
7373
"$setpoint bar"
7474
}
7575

76-
BasicPreference(
77-
modifier = modifier.clickable { showDialog = true },
76+
BaseTextPreference(
77+
modifier = modifier,
7878
label = label,
79-
value = description,
80-
hideDivider = true,
81-
action = {
82-
Text(
83-
text = summary,
84-
textAlign = TextAlign.Center,
85-
style = typography.bodyMedium.copy(fontWeight = FontWeight.Bold)
86-
)
87-
}
88-
)
79+
description = description,
80+
value = summary,
81+
) {
82+
showDialog = true
83+
}
8984
}
9085

9186
@Composable

composeApp/src/commonMain/kotlin/org/neotech/app/abysner/presentation/component/preferences/DecimalNumberPreference.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,14 @@ fun DecimalNumberPreference(
6767
)
6868
}
6969

70-
BasicPreference(
71-
modifier = modifier.clickable { showDialog = true },
70+
BaseTextPreference(
71+
modifier = modifier,
7272
label = label,
73-
value = description,
74-
hideDivider = true,
75-
action = {
76-
Text(
77-
text = valueFormatter(initialValue),
78-
style = typography.bodyMedium.copy(fontWeight = FontWeight.Bold)
79-
)
80-
}
81-
)
73+
description = description,
74+
value = valueFormatter(initialValue)
75+
) {
76+
showDialog = true
77+
}
8278
}
8379

8480
@Composable

0 commit comments

Comments
 (0)