@@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
1515import androidx.compose.ui.Alignment
1616import androidx.compose.ui.Modifier
1717import androidx.compose.ui.graphics.Color
18+ import androidx.compose.ui.platform.testTag
1819import androidx.compose.ui.res.painterResource
1920import androidx.compose.ui.text.style.TextOverflow
2021import androidx.compose.ui.tooling.preview.Preview
@@ -38,6 +39,7 @@ fun SettingsSwitchRow(
3839 subtitle : String? = null,
3940 iconRes : Int? = null,
4041 iconTint : Color = Color .Unspecified ,
42+ switchTestTag : String? = null,
4143 colors : SwitchColors = AppSwitchDefaults .colors
4244) {
4345 SettingsSwitchRowCore (
@@ -47,6 +49,7 @@ fun SettingsSwitchRow(
4749 enabled = enabled,
4850 subtitle = subtitle,
4951 colors = colors,
52+ switchTestTag = switchTestTag,
5053 icon = if (iconRes != null ) {
5154 {
5255 Icon (
@@ -73,6 +76,7 @@ fun SettingsSwitchRow(
7376 modifier : Modifier = Modifier ,
7477 enabled : Boolean = true,
7578 subtitle : String? = null,
79+ switchTestTag : String? = null,
7680 colors : SwitchColors = AppSwitchDefaults .colors
7781) {
7882 SettingsSwitchRowCore (
@@ -82,6 +86,7 @@ fun SettingsSwitchRow(
8286 enabled = enabled,
8387 subtitle = subtitle,
8488 colors = colors,
89+ switchTestTag = switchTestTag,
8590 icon = {
8691 icon()
8792 HorizontalSpacer (8 .dp)
@@ -99,6 +104,7 @@ private fun SettingsSwitchRowCore(
99104 enabled : Boolean = true,
100105 subtitle : String? = null,
101106 icon : (@Composable () -> Unit )? = null,
107+ switchTestTag : String? = null,
102108 colors : SwitchColors = AppSwitchDefaults .colors
103109) {
104110 Column (modifier = modifier) {
@@ -131,6 +137,7 @@ private fun SettingsSwitchRowCore(
131137 onCheckedChange = null , // handled by parent
132138 enabled = enabled,
133139 colors = colors,
140+ modifier = switchTestTag?.let { Modifier .testTag(it) } ? : Modifier
134141 )
135142 }
136143 HorizontalDivider (color = Colors .White10 )
0 commit comments