From 91d9adcbe23363a030ddb3049d7c11abd1e055a0 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Fri, 16 Feb 2024 12:26:49 +0200 Subject: [PATCH] fix: In a two pane view the Account list item never gets selected background color --- .../accounts/component/AccountListItem.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component/AccountListItem.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component/AccountListItem.kt index dba26b2b..bb330c01 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component/AccountListItem.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component/AccountListItem.kt @@ -30,9 +30,13 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow 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.vault.component.Section 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.AvatarBuilder import com.artemchep.keyguard.ui.ExpandedIfNotEmptyForRow @@ -74,7 +78,19 @@ fun AccountListItemText( val backgroundColor = when { item.isSelected -> MaterialTheme.colorScheme.primaryContainer 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( backgroundColor = backgroundColor,