Skip to content

Commit 91d9adc

Browse files
committedFeb 16, 2024
fix: In a two pane view the Account list item never gets selected background color
1 parent 81ac31e commit 91d9adc

File tree

1 file changed

+17
-1
lines changed
  • common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component

1 file changed

+17
-1
lines changed
 

‎common/src/commonMain/kotlin/com/artemchep/keyguard/feature/home/settings/accounts/component/AccountListItem.kt

+17-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ import androidx.compose.ui.Modifier
3030
import androidx.compose.ui.graphics.Color
3131
import androidx.compose.ui.text.style.TextOverflow
3232
import androidx.compose.ui.unit.dp
33+
import com.artemchep.keyguard.feature.auth.AccountViewRoute
3334
import com.artemchep.keyguard.feature.home.settings.accounts.model.AccountItem
3435
import com.artemchep.keyguard.feature.home.vault.component.Section
3536
import com.artemchep.keyguard.feature.home.vault.component.rememberSecretAccentColor
37+
import com.artemchep.keyguard.feature.justdeleteme.directory.JustDeleteMeServiceViewFullRoute
38+
import com.artemchep.keyguard.feature.navigation.navigationNextEntryOrNull
39+
import com.artemchep.keyguard.feature.twopane.LocalHasDetailPane
3640
import com.artemchep.keyguard.ui.AvatarBadgeIcon
3741
import com.artemchep.keyguard.ui.AvatarBuilder
3842
import com.artemchep.keyguard.ui.ExpandedIfNotEmptyForRow
@@ -74,7 +78,19 @@ fun AccountListItemText(
7478
val backgroundColor = when {
7579
item.isSelected -> MaterialTheme.colorScheme.primaryContainer
7680
item.isOpened -> MaterialTheme.colorScheme.selectedContainer
77-
else -> Color.Unspecified
81+
else -> run {
82+
if (LocalHasDetailPane.current) {
83+
val nextEntry = navigationNextEntryOrNull()
84+
val nextRoute = nextEntry?.route as? AccountViewRoute
85+
86+
val selected = nextRoute?.accountId?.id == item.id
87+
if (selected) {
88+
return@run MaterialTheme.colorScheme.selectedContainer
89+
}
90+
}
91+
92+
Color.Unspecified
93+
}
7894
}
7995
FlatItemLayout(
8096
backgroundColor = backgroundColor,

0 commit comments

Comments
 (0)
Please sign in to comment.