fix: In a two pane view the Account list item never gets selected background color

This commit is contained in:
Artem Chepurnoy 2024-02-16 12:26:49 +02:00
parent 81ac31e4fb
commit 91d9adcbe2
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 17 additions and 1 deletions

View File

@ -30,9 +30,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.artemchep.keyguard.feature.auth.AccountViewRoute
import com.artemchep.keyguard.feature.home.settings.accounts.model.AccountItem import com.artemchep.keyguard.feature.home.settings.accounts.model.AccountItem
import com.artemchep.keyguard.feature.home.vault.component.Section import com.artemchep.keyguard.feature.home.vault.component.Section
import com.artemchep.keyguard.feature.home.vault.component.rememberSecretAccentColor import com.artemchep.keyguard.feature.home.vault.component.rememberSecretAccentColor
import com.artemchep.keyguard.feature.justdeleteme.directory.JustDeleteMeServiceViewFullRoute
import com.artemchep.keyguard.feature.navigation.navigationNextEntryOrNull
import com.artemchep.keyguard.feature.twopane.LocalHasDetailPane
import com.artemchep.keyguard.ui.AvatarBadgeIcon import com.artemchep.keyguard.ui.AvatarBadgeIcon
import com.artemchep.keyguard.ui.AvatarBuilder import com.artemchep.keyguard.ui.AvatarBuilder
import com.artemchep.keyguard.ui.ExpandedIfNotEmptyForRow import com.artemchep.keyguard.ui.ExpandedIfNotEmptyForRow
@ -74,7 +78,19 @@ fun AccountListItemText(
val backgroundColor = when { val backgroundColor = when {
item.isSelected -> MaterialTheme.colorScheme.primaryContainer item.isSelected -> MaterialTheme.colorScheme.primaryContainer
item.isOpened -> MaterialTheme.colorScheme.selectedContainer item.isOpened -> MaterialTheme.colorScheme.selectedContainer
else -> Color.Unspecified else -> run {
if (LocalHasDetailPane.current) {
val nextEntry = navigationNextEntryOrNull()
val nextRoute = nextEntry?.route as? AccountViewRoute
val selected = nextRoute?.accountId?.id == item.id
if (selected) {
return@run MaterialTheme.colorScheme.selectedContainer
}
}
Color.Unspecified
}
} }
FlatItemLayout( FlatItemLayout(
backgroundColor = backgroundColor, backgroundColor = backgroundColor,