fix: In a single pane view the Settings item gets the selected background color
This commit is contained in:
parent
77d1e70244
commit
81ac31e4fb
|
@ -22,17 +22,16 @@ import com.artemchep.keyguard.ui.Avatar
|
||||||
import com.artemchep.keyguard.ui.FlatItemLayout
|
import com.artemchep.keyguard.ui.FlatItemLayout
|
||||||
import com.artemchep.keyguard.ui.FlatItemTextContent
|
import com.artemchep.keyguard.ui.FlatItemTextContent
|
||||||
import com.artemchep.keyguard.ui.icons.ChevronIcon
|
import com.artemchep.keyguard.ui.icons.ChevronIcon
|
||||||
import com.artemchep.keyguard.ui.theme.selectedContainer
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingListItem(
|
fun SettingListItem(
|
||||||
item: SettingsItem,
|
item: SettingsItem,
|
||||||
selected: Boolean,
|
backgroundColor: Color,
|
||||||
onClick: (SettingsItem) -> Unit,
|
onClick: () -> Unit,
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
FlatItemLayout(
|
FlatItemLayout(
|
||||||
backgroundColor = if (selected) MaterialTheme.colorScheme.selectedContainer else Color.Unspecified,
|
backgroundColor = backgroundColor,
|
||||||
leading = {
|
leading = {
|
||||||
Avatar {
|
Avatar {
|
||||||
when {
|
when {
|
||||||
|
@ -86,9 +85,7 @@ fun SettingListItem(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
onClick = {
|
onClick = onClick,
|
||||||
onClick(item)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if (item.content != null) {
|
if (item.content != null) {
|
||||||
Row(
|
Row(
|
||||||
|
|
|
@ -31,6 +31,7 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import com.artemchep.keyguard.common.usecase.GetAccountsHasError
|
import com.artemchep.keyguard.common.usecase.GetAccountsHasError
|
||||||
|
@ -49,12 +50,13 @@ import com.artemchep.keyguard.feature.home.vault.component.Section
|
||||||
import com.artemchep.keyguard.feature.localization.TextHolder
|
import com.artemchep.keyguard.feature.localization.TextHolder
|
||||||
import com.artemchep.keyguard.feature.localization.textResource
|
import com.artemchep.keyguard.feature.localization.textResource
|
||||||
import com.artemchep.keyguard.feature.navigation.LocalNavigationController
|
import com.artemchep.keyguard.feature.navigation.LocalNavigationController
|
||||||
import com.artemchep.keyguard.feature.navigation.LocalNavigationRouter
|
|
||||||
import com.artemchep.keyguard.feature.navigation.NavigationIcon
|
import com.artemchep.keyguard.feature.navigation.NavigationIcon
|
||||||
import com.artemchep.keyguard.feature.navigation.NavigationIntent
|
import com.artemchep.keyguard.feature.navigation.NavigationIntent
|
||||||
import com.artemchep.keyguard.feature.navigation.Route
|
import com.artemchep.keyguard.feature.navigation.Route
|
||||||
|
import com.artemchep.keyguard.feature.navigation.navigationNextEntryOrNull
|
||||||
import com.artemchep.keyguard.feature.onboarding.SmallOnboardingCard
|
import com.artemchep.keyguard.feature.onboarding.SmallOnboardingCard
|
||||||
import com.artemchep.keyguard.feature.onboarding.onboardingItemsPremium
|
import com.artemchep.keyguard.feature.onboarding.onboardingItemsPremium
|
||||||
|
import com.artemchep.keyguard.feature.twopane.LocalHasDetailPane
|
||||||
import com.artemchep.keyguard.platform.CurrentPlatform
|
import com.artemchep.keyguard.platform.CurrentPlatform
|
||||||
import com.artemchep.keyguard.platform.isStandalone
|
import com.artemchep.keyguard.platform.isStandalone
|
||||||
import com.artemchep.keyguard.platform.util.hasAutofill
|
import com.artemchep.keyguard.platform.util.hasAutofill
|
||||||
|
@ -66,6 +68,7 @@ import com.artemchep.keyguard.ui.ScaffoldLazyColumn
|
||||||
import com.artemchep.keyguard.ui.icons.IconBox
|
import com.artemchep.keyguard.ui.icons.IconBox
|
||||||
import com.artemchep.keyguard.ui.icons.KeyguardPremium
|
import com.artemchep.keyguard.ui.icons.KeyguardPremium
|
||||||
import com.artemchep.keyguard.ui.pulltosearch.PullToSearch
|
import com.artemchep.keyguard.ui.pulltosearch.PullToSearch
|
||||||
|
import com.artemchep.keyguard.ui.theme.selectedContainer
|
||||||
import com.artemchep.keyguard.ui.toolbar.LargeToolbar
|
import com.artemchep.keyguard.ui.toolbar.LargeToolbar
|
||||||
import dev.icerock.moko.resources.compose.stringResource
|
import dev.icerock.moko.resources.compose.stringResource
|
||||||
import org.kodein.di.compose.rememberInstance
|
import org.kodein.di.compose.rememberInstance
|
||||||
|
@ -230,14 +233,6 @@ private fun SettingListScreenContent(
|
||||||
items: List<SettingsItem2>,
|
items: List<SettingsItem2>,
|
||||||
) {
|
) {
|
||||||
val q = LocalNavigationController.current
|
val q = LocalNavigationController.current
|
||||||
val l = LocalNavigationRouter.current.value
|
|
||||||
val s = l
|
|
||||||
.indexOfLast { it.id == "settings" }
|
|
||||||
val t = if (s != -1) {
|
|
||||||
l.subList(fromIndex = s, toIndex = l.size)
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
|
|
||||||
val pullRefreshState = rememberPullRefreshState(
|
val pullRefreshState = rememberPullRefreshState(
|
||||||
refreshing = false,
|
refreshing = false,
|
||||||
|
@ -289,13 +284,26 @@ private fun SettingListScreenContent(
|
||||||
items(items, key = { it.id }) {
|
items(items, key = { it.id }) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is SettingsItem -> {
|
is SettingsItem -> {
|
||||||
|
val backgroundColor = run {
|
||||||
|
if (LocalHasDetailPane.current) {
|
||||||
|
val nextEntry = navigationNextEntryOrNull()
|
||||||
|
val nextRoute = nextEntry?.route
|
||||||
|
|
||||||
|
val selected = it.route === nextRoute
|
||||||
|
if (selected) {
|
||||||
|
return@run MaterialTheme.colorScheme.selectedContainer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color.Unspecified
|
||||||
|
}
|
||||||
SettingListItem(
|
SettingListItem(
|
||||||
selected = it.route === t.getOrNull(1)?.route,
|
backgroundColor = backgroundColor,
|
||||||
item = it,
|
item = it,
|
||||||
onClick = {
|
onClick = {
|
||||||
val intent = NavigationIntent.Composite(
|
val intent = NavigationIntent.Composite(
|
||||||
listOf(
|
listOf(
|
||||||
NavigationIntent.PopById("settings"),
|
NavigationIntent.PopById(SettingsRoute.ROUTER_NAME),
|
||||||
NavigationIntent.NavigateToRoute(it.route),
|
NavigationIntent.NavigateToRoute(it.route),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,8 @@ import androidx.compose.runtime.Composable
|
||||||
import com.artemchep.keyguard.feature.navigation.Route
|
import com.artemchep.keyguard.feature.navigation.Route
|
||||||
|
|
||||||
object SettingsRoute : Route {
|
object SettingsRoute : Route {
|
||||||
|
const val ROUTER_NAME = "settings"
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
SettingsScreen()
|
SettingsScreen()
|
||||||
|
|
|
@ -18,7 +18,7 @@ fun SettingsScreen() {
|
||||||
LocalNavigationNodeVisualStack provides visualStack,
|
LocalNavigationNodeVisualStack provides visualStack,
|
||||||
) {
|
) {
|
||||||
NavigationRouter(
|
NavigationRouter(
|
||||||
id = "settings",
|
id = SettingsRoute.ROUTER_NAME,
|
||||||
initial = SettingListRoute,
|
initial = SettingListRoute,
|
||||||
) { backStack ->
|
) { backStack ->
|
||||||
TwoPaneNavigationContent(backStack)
|
TwoPaneNavigationContent(backStack)
|
||||||
|
|
Loading…
Reference in New Issue