Skip to content

Commit 7a8b2f6

Browse files
committed
fix: move switch to end of SwitchText and make text fill space
1 parent 4a3b117 commit 7a8b2f6

File tree

1 file changed

+16
-13
lines changed
  • base/src/main/java/io/github/sds100/keymapper/base/utils/ui/compose

1 file changed

+16
-13
lines changed

base/src/main/java/io/github/sds100/keymapper/base/utils/ui/compose/SwitchText.kt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package io.github.sds100.keymapper.base.utils.ui.compose
22

33
import androidx.compose.foundation.clickable
44
import androidx.compose.foundation.layout.Row
5+
import androidx.compose.foundation.layout.Spacer
56
import androidx.compose.foundation.layout.padding
7+
import androidx.compose.foundation.layout.width
68
import androidx.compose.material3.MaterialTheme
79
import androidx.compose.material3.Surface
810
import androidx.compose.material3.Switch
@@ -25,24 +27,16 @@ fun SwitchText(
2527
Surface(
2628
modifier = modifier,
2729
shape = MaterialTheme.shapes.medium,
28-
color = Color.Companion.Transparent,
30+
color = Color.Transparent,
2931
) {
3032
Row(
31-
modifier = Modifier.Companion
33+
modifier = Modifier
3234
.clickable(enabled = isEnabled) { onCheckedChange(!isChecked) }
3335
.padding(8.dp),
34-
verticalAlignment = Alignment.Companion.CenterVertically,
36+
verticalAlignment = Alignment.CenterVertically,
3537
) {
36-
Switch(
37-
enabled = isEnabled,
38-
checked = isChecked,
39-
// This is null so tapping on the checkbox highlights the whole row.
40-
onCheckedChange = null,
41-
)
42-
4338
Text(
44-
modifier = Modifier.Companion.padding(horizontal = 12.dp),
45-
39+
modifier = Modifier.weight(1f),
4640
text = text,
4741
style = if (isEnabled) {
4842
MaterialTheme.typography.bodyLarge
@@ -54,7 +48,16 @@ fun SwitchText(
5448
)
5549
},
5650
maxLines = 2,
57-
overflow = TextOverflow.Companion.Ellipsis,
51+
overflow = TextOverflow.Ellipsis,
52+
)
53+
54+
Spacer(Modifier.width(16.dp))
55+
56+
Switch(
57+
enabled = isEnabled,
58+
checked = isChecked,
59+
// This is null so tapping on the checkbox highlights the whole row.
60+
onCheckedChange = null,
5861
)
5962
}
6063
}

0 commit comments

Comments
 (0)