Skip to content

Commit

Permalink
Hide bottom bar in home screen when posts list is scrolled (#831)
Browse files Browse the repository at this point in the history
This will increase the screen real estate in the home screen for the content. We will bring back the bottom bar when the content is scroll down.
  • Loading branch information
msasikanth authored Feb 25, 2025
1 parent 287c94f commit dca3227
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.core.view.WindowCompat
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.defaultComponentContext
import dev.sasikanth.rss.reader.app.App
Expand All @@ -40,22 +41,30 @@ class MainActivity : ComponentActivity() {

FileKit.init(this)

enableEdgeToEdge()
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT)
)

val activityComponent = ActivityComponent::class.create(activity = this)

setContent {
activityComponent.app { useDarkTheme ->
enableEdgeToEdge(
statusBarStyle =
if (useDarkTheme) {
SystemBarStyle.dark(Color.TRANSPARENT)
} else {
SystemBarStyle.light(Color.TRANSPARENT, Color.TRANSPARENT)
},
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT)
)
}
activityComponent.app(
{ useDarkTheme ->
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars =
useDarkTheme.not()
WindowCompat.getInsetsController(window, window.decorView)
.isAppearanceLightNavigationBars = false
},
{ isLightStatusBar ->
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars =
isLightStatusBar
},
{ isLightNavBar ->
WindowCompat.getInsetsController(window, window.decorView)
.isAppearanceLightNavigationBars = isLightNavBar
}
)
}
}
}
Expand Down
22 changes: 15 additions & 7 deletions shared/src/commonMain/kotlin/dev/sasikanth/rss/reader/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import coil3.ImageLoader
import coil3.annotation.ExperimentalCoilApi
import coil3.compose.setSingletonImageLoaderFactory
import com.arkivanov.decompose.extensions.compose.stack.Children
import com.arkivanov.decompose.extensions.compose.stack.animation.StackAnimation
Expand Down Expand Up @@ -63,18 +62,26 @@ import dev.sasikanth.rss.reader.utils.LocalWindowSizeClass
import me.tatarka.inject.annotations.Assisted
import me.tatarka.inject.annotations.Inject

typealias App = @Composable (onThemeChange: (useDarkTheme: Boolean) -> Unit) -> Unit
typealias App =
@Composable
(
onThemeChange: (useDarkTheme: Boolean) -> Unit,
toggleLightStatusBar: (isLightStatusBar: Boolean) -> Unit,
toggleLightNavBar: (isLightNavBar: Boolean) -> Unit,
) -> Unit

@Inject
@Composable
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class, ExperimentalCoilApi::class)
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
fun App(
appPresenter: AppPresenter,
shareHandler: ShareHandler,
linkHandler: LinkHandler,
imageLoader: ImageLoader,
dispatchersProvider: DispatchersProvider,
@Assisted onThemeChange: (useDarkTheme: Boolean) -> Unit
@Assisted onThemeChange: (useDarkTheme: Boolean) -> Unit,
@Assisted toggleLightStatusBar: (isLightStatusBar: Boolean) -> Unit,
@Assisted toggleLightNavBar: (isLightNavBar: Boolean) -> Unit,
) {
setSingletonImageLoaderFactory { imageLoader }

Expand Down Expand Up @@ -127,15 +134,16 @@ fun App(
useDarkTheme = useDarkTheme,
modifier = fillMaxSizeModifier,
onBottomSheetStateChanged = { sheetValue ->
val tempUseDarkTheme =
val showDarkStatusBar =
if (sheetValue == SheetValue.Expanded) {
true
} else {
useDarkTheme
}

onThemeChange(tempUseDarkTheme)
}
toggleLightStatusBar(showDarkStatusBar.not())
},
onBottomSheetHidden = { isHidden -> toggleLightNavBar(isHidden) },
)
}
is Screen.Search -> {
Expand Down
Loading

0 comments on commit dca3227

Please sign in to comment.