Set the maximum width of mostly empty list screens to a lower value

This commit is contained in:
Artem Chepurnoy 2024-02-19 15:28:44 +02:00
parent 50448c195a
commit 99af43928d
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
10 changed files with 47 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import androidx.compose.runtime.remember
import com.artemchep.keyguard.feature.duplicates.list.DuplicatesListRoute import com.artemchep.keyguard.feature.duplicates.list.DuplicatesListRoute
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun DuplicatesScreen( fun DuplicatesScreen(
@ -19,6 +20,9 @@ fun DuplicatesScreen(
id = DuplicatesRoute.ROUTER_NAME, id = DuplicatesRoute.ROUTER_NAME,
initial = initialRoute, initial = initialRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.generator.wordlist.list.WordlistListRoute import com.artemchep.keyguard.feature.generator.wordlist.list.WordlistListRoute
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun WordlistsScreen() { fun WordlistsScreen() {
@ -11,6 +12,9 @@ fun WordlistsScreen() {
id = WordlistsRoute.ROUTER_NAME, id = WordlistsRoute.ROUTER_NAME,
initial = WordlistListRoute, initial = WordlistListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -5,6 +5,7 @@ import androidx.compose.runtime.CompositionLocalProvider
import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun SettingsScreen() { fun SettingsScreen() {
@ -21,7 +22,10 @@ fun SettingsScreen() {
id = SettingsRoute.ROUTER_NAME, id = SettingsRoute.ROUTER_NAME,
initial = SettingListRoute, initial = SettingListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }
} }

View File

@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun AccountsScreen() { fun AccountsScreen() {
@ -20,7 +21,10 @@ fun AccountsScreen() {
id = "accounts", id = "accounts",
initial = AccountListRoute, initial = AccountListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
// } // }
} }

View File

@ -3,6 +3,7 @@ package com.artemchep.keyguard.feature.justdeleteme.directory
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun TwoFaServicesScreen() { fun TwoFaServicesScreen() {
@ -10,6 +11,9 @@ fun TwoFaServicesScreen() {
id = JustDeleteMeServicesRoute.ROUTER_NAME, id = JustDeleteMeServicesRoute.ROUTER_NAME,
initial = JustDeleteMeServiceListRoute, initial = JustDeleteMeServiceListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -3,6 +3,7 @@ package com.artemchep.keyguard.feature.justgetdata.directory
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun JustGetMyDataServicesScreen() { fun JustGetMyDataServicesScreen() {
@ -10,6 +11,9 @@ fun JustGetMyDataServicesScreen() {
id = JustGetMyDataServicesRoute.ROUTER_NAME, id = JustGetMyDataServicesRoute.ROUTER_NAME,
initial = JustGetMyDataListRoute, initial = JustGetMyDataListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -3,6 +3,7 @@ package com.artemchep.keyguard.feature.passkeys.directory
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun TwoFaServicesScreen() { fun TwoFaServicesScreen() {
@ -10,6 +11,9 @@ fun TwoFaServicesScreen() {
id = PasskeysServicesRoute.ROUTER_NAME, id = PasskeysServicesRoute.ROUTER_NAME,
initial = PasskeysServiceListRoute, initial = PasskeysServiceListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -3,6 +3,7 @@ package com.artemchep.keyguard.feature.tfa.directory
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.artemchep.keyguard.feature.navigation.NavigationRouter import com.artemchep.keyguard.feature.navigation.NavigationRouter
import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent import com.artemchep.keyguard.feature.twopane.TwoPaneNavigationContent
import com.artemchep.keyguard.ui.screenMaxWidthCompact
@Composable @Composable
fun TwoFaServicesScreen() { fun TwoFaServicesScreen() {
@ -10,6 +11,9 @@ fun TwoFaServicesScreen() {
id = TwoFaServicesRoute.ROUTER_NAME, id = TwoFaServicesRoute.ROUTER_NAME,
initial = TwoFaServiceListRoute, initial = TwoFaServiceListRoute,
) { backStack -> ) { backStack ->
TwoPaneNavigationContent(backStack) TwoPaneNavigationContent(
backStack,
detailPaneMaxWidth = screenMaxWidthCompact,
)
} }
} }

View File

@ -2,17 +2,22 @@ package com.artemchep.keyguard.feature.twopane
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.unit.Dp
import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack import com.artemchep.keyguard.feature.navigation.LocalNavigationNodeVisualStack
import com.artemchep.keyguard.feature.navigation.NavigationEntry import com.artemchep.keyguard.feature.navigation.NavigationEntry
import com.artemchep.keyguard.feature.navigation.NavigationNode import com.artemchep.keyguard.feature.navigation.NavigationNode
import com.artemchep.keyguard.ui.screenMaxWidth
import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
@Composable @Composable
fun TwoPaneNavigationContent( fun TwoPaneNavigationContent(
backStack: PersistentList<NavigationEntry>, backStack: PersistentList<NavigationEntry>,
detailPaneMaxWidth: Dp = screenMaxWidth,
) {
TwoPaneScaffold(
detailPaneMaxWidth = detailPaneMaxWidth,
) { ) {
TwoPaneScaffold {
if (backStack.isEmpty()) { if (backStack.isEmpty()) {
// Nothing to draw, the back stack is empty. // Nothing to draw, the back stack is empty.
return@TwoPaneScaffold return@TwoPaneScaffold

View File

@ -84,6 +84,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlin.math.log10 import kotlin.math.log10
val screenMaxWidth = 768.dp val screenMaxWidth = 768.dp
val screenMaxWidthCompact = 480.dp
private val screenPaddingTop = 8.dp private val screenPaddingTop = 8.dp
private val screenPaddingBottom = 8.dp private val screenPaddingBottom = 8.dp