Skip to content

Commit 0bbf313

Browse files
authored
Feature/add navigation rail catalog home layout (#34)
* feat(mobile-app): Renamed old files * feat(mobile-app): Added catalog home layout when navigation rail is displayed and is in book mode
1 parent d91e0bf commit 0bbf313

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

apps/mobile-app/src/main/kotlin/dev/marlonlom/apps/cappajv/features/catalog_list/CatalogListContent.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dev.marlonlom.apps.cappajv.core.database.entities.CatalogItemTuple
1313
import dev.marlonlom.apps.cappajv.features.catalog_list.screens.CompactTableTopCatalogListScreen
1414
import dev.marlonlom.apps.cappajv.features.catalog_list.screens.DefaultPortraitCatalogListScreen
1515
import dev.marlonlom.apps.cappajv.features.catalog_list.screens.LandscapeCompactCatalogListScreen
16-
import dev.marlonlom.apps.cappajv.features.catalog_list.screens.TwoPaneCatalogListScreen
16+
import dev.marlonlom.apps.cappajv.features.catalog_list.screens.LandscapeTwoPaneCatalogListScreen
1717
import dev.marlonlom.apps.cappajv.ui.layout.DevicePosture
1818
import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
1919
import dev.marlonlom.apps.cappajv.ui.main.scaffold.ScaffoldContentType
@@ -47,8 +47,8 @@ fun CatalogListContent(
4747
when {
4848

4949
appState.isLandscape.and(appState.devicePosture == DevicePosture.Normal)
50-
.and(appState.navigationType == NavigationType.EXPANDED_NAV) -> {
51-
TwoPaneCatalogListScreen(
50+
.and(listOf(NavigationType.EXPANDED_NAV, NavigationType.NAVIGATION_RAIL).contains(appState.navigationType)) -> {
51+
LandscapeTwoPaneCatalogListScreen(
5252
appState = appState,
5353
catalogItemsListState = catalogItemsListState,
5454
catalogItems = catalogItems,
@@ -60,8 +60,16 @@ fun CatalogListContent(
6060
}
6161

6262
(appState.devicePosture is DevicePosture.Separating.Book).and(appState.isCompactHeight.not())
63-
.and(appState.isLandscape.not()) -> {
64-
63+
.and(appState.isLandscape) -> {
64+
LandscapeTwoPaneCatalogListScreen(
65+
appState = appState,
66+
catalogItemsListState = catalogItemsListState,
67+
catalogItems = catalogItems,
68+
categories = categories,
69+
selectedCategory = selectedCategory,
70+
onSelectedCategoryChanged = onSelectedCategoryChanged,
71+
onCatalogItemSelected = onCatalogItemSelected,
72+
)
6573
}
6674

6775
appState.isLandscape.and(appState.devicePosture == DevicePosture.Normal).and(appState.isCompactHeight) -> {

apps/mobile-app/src/main/kotlin/dev/marlonlom/apps/cappajv/features/catalog_list/parts/CatalogListHeadline.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.ui.text.font.FontWeight
2525
import androidx.compose.ui.unit.dp
2626
import dev.marlonlom.apps.cappajv.R
2727
import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
28+
import dev.marlonlom.apps.cappajv.ui.navigation.NavigationType
2829

2930
/**
3031
* Catalog listing headline composable ui.
@@ -45,18 +46,23 @@ fun CatalogListHeadline(
4546
else -> PaddingValues(top = 40.dp, bottom = 20.dp)
4647
}
4748

49+
val headlineTextStyle = when {
50+
appState.isLandscape.and(appState.navigationType == NavigationType.NAVIGATION_RAIL) -> MaterialTheme.typography.headlineSmall
51+
else -> MaterialTheme.typography.headlineLarge
52+
}
53+
4854
Row(
4955
modifier = modifier
50-
.background(MaterialTheme.colorScheme.surface)
51-
.fillMaxWidth()
52-
.padding(rowPaddingValues),
56+
.background(MaterialTheme.colorScheme.surface)
57+
.fillMaxWidth()
58+
.padding(rowPaddingValues),
5359
verticalAlignment = Alignment.Bottom,
5460
horizontalArrangement = Arrangement.SpaceBetween
5561
) {
5662
Text(
5763
modifier = Modifier.fillMaxWidth(0.75f),
5864
text = stringResource(R.string.text_catalog_list_title),
59-
style = MaterialTheme.typography.headlineLarge,
65+
style = headlineTextStyle,
6066
fontWeight = FontWeight.Bold,
6167
maxLines = 2
6268
)
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import dev.marlonlom.apps.cappajv.features.catalog_list.parts.CatalogListHeadlin
2525
import dev.marlonlom.apps.cappajv.features.catalog_list.slots.CatalogCategoriesChipGroup
2626
import dev.marlonlom.apps.cappajv.features.catalog_list.slots.CatalogListBanner
2727
import dev.marlonlom.apps.cappajv.features.catalog_list.slots.CatalogListTuplesSlot
28+
import dev.marlonlom.apps.cappajv.ui.layout.DevicePosture
2829
import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
2930

3031

@@ -45,7 +46,7 @@ import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
4546
@ExperimentalLayoutApi
4647
@ExperimentalFoundationApi
4748
@Composable
48-
fun TwoPaneCatalogListScreen(
49+
fun LandscapeTwoPaneCatalogListScreen(
4950
appState: CappajvAppState,
5051
catalogItemsListState: LazyListState,
5152
catalogItems: List<CatalogItemTuple>,
@@ -55,13 +56,17 @@ fun TwoPaneCatalogListScreen(
5556
onCatalogItemSelected: (Long) -> Unit,
5657
modifier: Modifier = Modifier,
5758
) {
59+
val listColumnWidthFraction = when {
60+
appState.devicePosture is DevicePosture.Separating.Book -> 0.4f
61+
else -> 0.33f
62+
}
5863
Row(
5964
modifier = modifier.fillMaxWidth(),
6065
verticalAlignment = Alignment.CenterVertically,
6166
horizontalArrangement = Arrangement.spacedBy(20.dp)
6267
) {
6368
Column(
64-
modifier = modifier.fillMaxWidth(0.33f)
69+
modifier = modifier.fillMaxWidth(listColumnWidthFraction)
6570
) {
6671
CatalogListHeadline(appState)
6772
CatalogListBanner(appState)

apps/mobile-app/src/main/kotlin/dev/marlonlom/apps/cappajv/features/catalog_list/slots/CatalogListBanner.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import androidx.compose.ui.unit.dp
3939
import androidx.compose.ui.util.lerp
4040
import dev.marlonlom.apps.cappajv.R
4141
import dev.marlonlom.apps.cappajv.ui.main.CappajvAppState
42+
import dev.marlonlom.apps.cappajv.ui.navigation.NavigationType
4243
import kotlinx.coroutines.delay
4344
import kotlinx.coroutines.yield
4445

@@ -75,12 +76,18 @@ fun CatalogListBanner(
7576
}
7677
}
7778

79+
val horizontalPagerHeight = when {
80+
appState.isLandscape.and(appState.navigationType == NavigationType.NAVIGATION_RAIL) -> 100.dp
81+
appState.isLandscape -> 120.dp
82+
else -> 160.dp
83+
}
84+
7885
Column {
7986
HorizontalPager(
8087
state = pagerState,
8188
contentPadding = PaddingValues(0.dp),
8289
modifier = modifier
83-
.height(if (appState.isLandscape) 120.dp else 160.dp)
90+
.height(horizontalPagerHeight)
8491
.fillMaxWidth()
8592
) { page ->
8693
BannerCard(

0 commit comments

Comments
 (0)