Skip to content

Commit

Permalink
adjust disabled settings item
Browse files Browse the repository at this point in the history
  • Loading branch information
X1nto committed Oct 29, 2023
1 parent 57c5c27 commit 32d28e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.xinto.mauth.ui.screen.settings.component

import androidx.compose.foundation.clickable
import androidx.compose.material3.ListItem
import androidx.compose.material3.ListItemDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -10,12 +11,24 @@ import androidx.compose.ui.unit.dp

@Composable
fun SettingsItem(
title: @Composable () -> Unit,
modifier: Modifier = Modifier,
title: @Composable () -> Unit,
description: (@Composable () -> Unit)? = null,
trailing: (@Composable () -> Unit)? = null,
icon: (@Composable () -> Unit)? = null,
enabled: Boolean = true,
) {
val colors = ListItemDefaults.colors(
headlineColor = MaterialTheme.colorScheme.onSurface.let {
if (!enabled) it.copy(alpha = 0.3f) else it
},
leadingIconColor = MaterialTheme.colorScheme.onSurface.let {
if (!enabled) it.copy(alpha = 0.38f) else it
},
trailingIconColor = MaterialTheme.colorScheme.onSurface.let {
if (!enabled) it.copy(alpha = 0.38f) else it
},
)
ListItem(
modifier = Modifier
.clip(MaterialTheme.shapes.medium)
Expand All @@ -24,19 +37,20 @@ fun SettingsItem(
trailingContent = trailing,
supportingContent = description,
headlineContent = title,
tonalElevation = 1.dp
tonalElevation = 1.dp,
colors = colors,
)
}

@Composable
fun SettingsItem(
onClick: () -> Unit,
title: @Composable () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
title: @Composable () -> Unit,
description: (@Composable () -> Unit)? = null,
trailing: (@Composable () -> Unit)? = null,
icon: (@Composable () -> Unit)? = null,
enabled: Boolean = true,
) {
SettingsItem(
modifier = modifier
Expand All @@ -47,6 +61,7 @@ fun SettingsItem(
icon = icon,
description = description,
title = title,
trailing = trailing
trailing = trailing,
enabled = enabled,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fun SettingsSwitchItem(
enabled = enabled,
thumbContent = thumbContent
)
}
},
enabled = enabled
)
}

0 comments on commit 32d28e4

Please sign in to comment.