Skip to content

Commit

Permalink
spotless: Apply spotless plugin in tv app module contents
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonlom committed Dec 26, 2024
1 parent 71a3863 commit 5bd0192
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/
package dev.marlonlom.cappajv.tv

import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.categories

import androidx.compose.runtime.mutableIntStateOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.di

import dev.marlonlom.cappajv.core.catalog.CatalogDataService
Expand Down Expand Up @@ -52,12 +51,12 @@ val appModule = module {
}
single<CatalogFavoritesRepository> {
CatalogFavoritesRepository(
localDataSource = get()
localDataSource = get(),
)
}
single<CatalogDetailRepository> {
CatalogDetailRepository(
localDataSource = get()
localDataSource = get(),
)
}
/* View models */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.browse

import androidx.compose.foundation.background
Expand Down Expand Up @@ -44,10 +43,7 @@ import timber.log.Timber
* @param modifier The modifier for this composable
*/
@Composable
fun CatalogBrowseScreen(
appState: CappajvTvUiState,
modifier: Modifier = Modifier
) {
fun CatalogBrowseScreen(appState: CappajvTvUiState, modifier: Modifier = Modifier) {
val catalogBrowseDrawerState = rememberDrawerState(DrawerValue.Closed)
val catalogBrowseStartWidth: Dp by remember {
derivedStateOf {
Expand Down Expand Up @@ -88,7 +84,7 @@ fun CatalogBrowseScreen(
},
onCategorySelected = { index ->
appState.changeHomeCategoryIndex(index)
}
},
)
}
}
Expand All @@ -107,7 +103,7 @@ fun CatalogBrowseScreen(
@Composable
private fun NavigationDrawerScope.CatalogBrowseDrawerContent(
appState: CappajvTvUiState,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) = Column(
modifier = modifier
.background(MaterialTheme.colorScheme.surfaceTint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ import dev.marlonlom.cappajv.tv.R
*/
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun CategoriesTabsRow(
selectedTabIndex: Int,
onTabSelected: (Int) -> Unit,
modifier: Modifier = Modifier
) = TabRow(
fun CategoriesTabsRow(selectedTabIndex: Int, onTabSelected: (Int) -> Unit, modifier: Modifier = Modifier) = TabRow(
modifier = modifier.focusRestorer(),
selectedTabIndex = selectedTabIndex,
indicator = { tabPositions, doesTabRowHaveFocus ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.common

import androidx.annotation.StringRes
Expand All @@ -23,10 +22,7 @@ import androidx.tv.material3.Text
* @param modifier The modifier for this composable.
*/
@Composable
fun CatalogGridCategoryText(
@StringRes categoryTitle: Int,
modifier: Modifier = Modifier
) = Text(
fun CatalogGridCategoryText(@StringRes categoryTitle: Int, modifier: Modifier = Modifier) = Text(
modifier = modifier.fillMaxWidth(),
text = stringResource(categoryTitle),
style = MaterialTheme.typography.titleMedium,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.common

import androidx.compose.foundation.background
Expand Down Expand Up @@ -39,11 +38,11 @@ import dev.marlonlom.cappajv.core.database.entities.CatalogItemTuple
fun CatalogGridItemCompactCard(
catalogItem: CatalogItemTuple,
onCatalogItemClicked: (CatalogItemTuple) -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) = CompactCard(
modifier = modifier
.background(
MaterialTheme.colorScheme.background
MaterialTheme.colorScheme.background,
),
image = {
AsyncImage(
Expand All @@ -58,7 +57,7 @@ fun CatalogGridItemCompactCard(
.background(Color.White)
.padding(20.dp)
.padding(bottom = 40.dp)
.clip(RoundedCornerShape(8.dp))
.clip(RoundedCornerShape(8.dp)),
)
},
title = {
Expand All @@ -70,10 +69,10 @@ fun CatalogGridItemCompactCard(
style = MaterialTheme.typography.titleMedium,
modifier = modifier
.fillMaxWidth()
.padding(10.dp)
.padding(10.dp),
)
},
onClick = {
onCatalogItemClicked(catalogItem)
}
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.common

import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -23,9 +22,7 @@ import androidx.tv.material3.Text
* @param modifier The modifier for this composable.
*/
@Composable
fun CatalogGridItemsLoadingIndicator(
modifier: Modifier = Modifier
) = Text(
fun CatalogGridItemsLoadingIndicator(modifier: Modifier = Modifier) = Text(
modifier = modifier
.fillMaxWidth()
.padding(20.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.common

import androidx.annotation.StringRes
Expand Down Expand Up @@ -40,7 +39,7 @@ fun CatalogLazyVerticalGrid(
onTabSelected: (Int) -> Unit,
catalogContent: LazyGridScope.() -> Unit,
startWidth: Dp,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) = LazyVerticalGrid(
state = rememberLazyGridState(),
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.details

import androidx.compose.foundation.background
Expand Down Expand Up @@ -52,14 +51,16 @@ import dev.marlonlom.cappajv.tv.R
*/
@Composable
internal fun CatalogDetailHeadingInfoSlot(
foundDetail: CatalogDetail, onMarkedFavorite: (CatalogItem, Boolean) -> Unit, modifier: Modifier = Modifier
foundDetail: CatalogDetail,
onMarkedFavorite: (CatalogItem, Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier
.fillMaxWidth(0.5f)
.padding(vertical = 10.dp),
horizontalArrangement = Arrangement.spacedBy(20.dp),
verticalAlignment = Alignment.Bottom
verticalAlignment = Alignment.Bottom,
) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current).data(foundDetail.product.picture).crossfade(true).build(),
Expand All @@ -70,7 +71,7 @@ internal fun CatalogDetailHeadingInfoSlot(
.background(Color.White, RoundedCornerShape(20.dp))
.aspectRatio(2f / 3F)
.clip(RoundedCornerShape(20.dp))
.clipToBounds()
.clipToBounds(),
)

Column(
Expand All @@ -94,25 +95,25 @@ internal fun CatalogDetailHeadingInfoSlot(
OutlinedButton(
onClick = {
onMarkedFavorite(foundDetail.product, !foundDetail.isFavorite)
}, colors = OutlinedButtonDefaults.colors(
},
colors = OutlinedButtonDefaults.colors(
contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
containerColor = MaterialTheme.colorScheme.primaryContainer,
)
),
) {
(if (foundDetail.isFavorite) Icons.Rounded.Favorite else Icons.Rounded.FavoriteBorder).also {
Icon(
imageVector = it,
contentDescription = stringResource(R.string.text_detail_toggle_favorite_desc),
modifier = Modifier.size(ButtonDefaults.IconSize),
tint = MaterialTheme.colorScheme.onPrimaryContainer
tint = MaterialTheme.colorScheme.onPrimaryContainer,
)
}
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
Text(
text = stringResource(R.string.text_detail_label_like),
color = MaterialTheme.colorScheme.onPrimaryContainer
color = MaterialTheme.colorScheme.onPrimaryContainer,
)

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.details

import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -33,9 +32,7 @@ import dev.marlonlom.cappajv.tv.R
* @param points List of catalog points for an item.
*/
@Composable
internal fun CatalogDetailInfoPointsSlot(
points: List<CatalogPunctuation>
) = Column(
internal fun CatalogDetailInfoPointsSlot(points: List<CatalogPunctuation>) = Column(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 40.dp),
Expand All @@ -55,7 +52,7 @@ internal fun CatalogDetailInfoPointsSlot(
) {
items(
items = points,
key = { pt -> pt.id }
key = { pt -> pt.id },
) { pt ->
CompactCard(
modifier = Modifier
Expand All @@ -79,7 +76,8 @@ internal fun CatalogDetailInfoPointsSlot(
val subtitleText = when {
pt.label.indexOfFirst { t -> t == '(' } >= 0 -> pt.label.substring(
0,
pt.label.indexOfFirst { t -> t == '(' })
pt.label.indexOfFirst { t -> t == '(' },
)

else -> pt.label
}.trim()
Expand All @@ -92,10 +90,10 @@ internal fun CatalogDetailInfoPointsSlot(
text = subtitleText,
maxLines = 1,
textAlign = TextAlign.Center,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
)
},
image = {}
image = {},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.details

import android.content.Context
Expand Down Expand Up @@ -41,12 +40,12 @@ import dev.marlonlom.cappajv.tv.ui.util.tvSafeContentPadding
internal fun CatalogDetailInfoSlot(
foundDetail: CatalogDetail,
onMarkedFavorite: (CatalogItem, Boolean) -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
) {
val context = LocalContext.current
val detailBackgroundRes = findBackgroundForItemCategory(
context = context,
categoryText = foundDetail.product.category
categoryText = foundDetail.product.category,
)

Column(
Expand All @@ -57,18 +56,17 @@ internal fun CatalogDetailInfoSlot(
contentScale = ContentScale.FillBounds,
colorFilter = ColorFilter.tint(
color = MaterialTheme.colorScheme.background,
blendMode = BlendMode.Softlight
)
blendMode = BlendMode.Softlight,
),
)
.tvSafeContentPadding(),
horizontalAlignment = Alignment.Start,
) {

Spacer(modifier = modifier.weight(1.0f))

CatalogDetailHeadingInfoSlot(
foundDetail = foundDetail,
onMarkedFavorite = onMarkedFavorite
onMarkedFavorite = onMarkedFavorite,
)

Text(
Expand All @@ -81,7 +79,6 @@ internal fun CatalogDetailInfoSlot(
)

CatalogDetailInfoPointsSlot(foundDetail.points)

}

Spacer(modifier.height(48.dp))
Expand Down Expand Up @@ -109,4 +106,3 @@ fun findBackgroundForItemCategory(context: Context, categoryText: String): Int {
else -> R.drawable.img_details_background_hot_drinks
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright 2024 Marlonlom
* SPDX-License-Identifier: Apache-2.0
*/

package dev.marlonlom.cappajv.tv.features.catalog.details

import androidx.compose.foundation.layout.Arrangement
Expand All @@ -18,12 +17,10 @@ import androidx.tv.material3.MaterialTheme
import androidx.tv.material3.Text

@Composable
internal fun CatalogDetailNotFoundSlot(
modifier: Modifier = Modifier
) = Column(
internal fun CatalogDetailNotFoundSlot(modifier: Modifier = Modifier) = Column(
modifier = modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
verticalArrangement = Arrangement.Center,
) {
Text(
modifier = Modifier.fillMaxWidth(),
Expand Down
Loading

0 comments on commit 5bd0192

Please sign in to comment.