Skip to content

Commit

Permalink
Fix detekt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaygaba committed Jun 5, 2024
1 parent 5723051 commit 8a61e3f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ internal fun ComponentCard(
onClick: (() -> Unit)? = null,
darkMode: Boolean = false,
) {
// This is added to make sure that the navigation of the ShowkaseBrowser does not break
// when one of the previews has a back press handler in the implementation of the component.
val backPressedDispatcherOwner = rememberOnBackPressedDispatcherOwner()
CompositionLocalProvider(LocalOnBackPressedDispatcherOwner provides backPressedDispatcherOwner) {
val composableModifier = Modifier.generateComposableModifier(metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package com.airbnb.android.showkase.ui

import android.annotation.SuppressLint
import android.content.res.Configuration
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.expandIn
Expand Down Expand Up @@ -38,7 +35,6 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
Expand All @@ -47,7 +43,6 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.Lifecycle
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
Expand All @@ -64,6 +59,7 @@ import com.airbnb.android.showkase.models.ShowkaseCurrentScreen
import com.airbnb.android.showkase.models.insideGroup
import com.airbnb.android.showkase.ui.SemanticsUtils.lineCountVal

@Suppress("LongMethod")
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
@Composable
internal fun ShowkaseBrowserApp(
Expand All @@ -79,9 +75,6 @@ internal fun ShowkaseBrowserApp(
CompositionLocalProvider(
LocalConfiguration provides lightModeConfiguration,
LocalInspectionMode provides true,
// This is added to make sure that the navigation of the ShowkaseBrowser does not break
// when one of the previews has a back press handler in the implementation of the component.
// LocalOnBackPressedDispatcherOwner provides backPressedDispatcherOwner
) {
val navController = rememberNavController()
val navBackStackEntry by navController.currentBackStackEntryAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.airbnb.android.showkase.models.ShowkaseCurrentScreen
import com.airbnb.android.showkase.models.clear
import com.airbnb.android.showkase.models.clearActiveSearch

@Suppress("LongMethod")
@Composable
internal fun ShowkaseColorsInAGroupScreen(
groupedColorsMap: Map<String, List<ShowkaseBrowserColor>>,
Expand All @@ -51,7 +52,9 @@ internal fun ShowkaseColorsInAGroupScreen(
itemContent = { groupColorMetadata ->
Card(
modifier = Modifier.padding(
start = padding4x, end = padding4x, top = padding2x,
start = padding4x,
end = padding4x,
top = padding2x,
bottom = padding2x
)
) {
Expand Down Expand Up @@ -101,7 +104,8 @@ private fun goBackFromColorsInAGroupScreen(
) {
val isSearchActive = showkaseBrowserScreenMetadata.isSearchActive
when {
isSearchActive -> onUpdateShowkaseBrowserScreenMetadata(showkaseBrowserScreenMetadata.clearActiveSearch())
isSearchActive ->
onUpdateShowkaseBrowserScreenMetadata(showkaseBrowserScreenMetadata.clearActiveSearch())
else -> {
onUpdateShowkaseBrowserScreenMetadata(showkaseBrowserScreenMetadata.clear())
navigateTo(ShowkaseCurrentScreen.COLOR_GROUPS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ private fun DisplayScaledComponentCard(metadata: ShowkaseBrowserComponent) {

@Composable
private fun RTLComponentCard(metadata: ShowkaseBrowserComponent) {
// This is added to make sure that the navigation of the ShowkaseBrowser does not break
// when one of the previews has a back press handler in the implementation of the component.
val backPressedDispatcherOwner = rememberOnBackPressedDispatcherOwner()
CompositionLocalProvider(LocalOnBackPressedDispatcherOwner provides backPressedDispatcherOwner) {
ComponentCardTitle("${metadata.componentName} [RTL]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ internal fun ShowkaseComponentsInAGroupScreen(
)
}
BackHandler {
goBackFromComponentsInAGroupScreen(showkaseBrowserScreenMetadata, onUpdateShowkaseBrowserScreenMetadata, navigateTo)
goBackFromComponentsInAGroupScreen(
showkaseBrowserScreenMetadata = showkaseBrowserScreenMetadata,
onUpdateShowkaseBrowserScreenMetadata = onUpdateShowkaseBrowserScreenMetadata,
navigateTo = navigateTo
)
}
}

Expand Down

0 comments on commit 8a61e3f

Please sign in to comment.