Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/gradle/hilt-2.55
Browse files Browse the repository at this point in the history
  • Loading branch information
toquete authored Jan 20, 2025
2 parents c3520e7 + 11e42ff commit 4efd9c4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
tools:targetApi="31">
<activity
android:name=".ui.MainActivity"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/com/toquete/boxbox/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -59,7 +59,7 @@ class MainActivity : ComponentActivity() {
val isDynamicColors = shouldUseDynamicColors(uiState)
val navController = rememberNavController()

DisposableEffect(isDarkTheme) {
LaunchedEffect(isDarkTheme) {
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.auto(
Color.TRANSPARENT,
Expand All @@ -70,7 +70,6 @@ class MainActivity : ComponentActivity() {
DefaultDarkScrim
) { isDarkTheme }
)
onDispose { }
}

BoxBoxTheme(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.toquete.boxbox.feature.home.ui

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.BottomAppBarDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LinearProgressIndicator
Expand All @@ -13,8 +19,12 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -50,6 +60,12 @@ internal fun HomeScreen(
val homeViewState = rememberHomeViewState()
val topAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
val bottomAppBarScrollBehavior = BottomAppBarDefaults.exitAlwaysScrollBehavior()
val isBottomAppBarVisible by remember {
derivedStateOf {
bottomAppBarScrollBehavior.state.collapsedFraction != 1f
}
}

Scaffold(
modifier = Modifier
.nestedScroll(bottomAppBarScrollBehavior.nestedScrollConnection)
Expand All @@ -63,10 +79,25 @@ internal fun HomeScreen(
)
},
bottomBar = {
HomeNavigationBar(
homeViewState = homeViewState,
scrollBehavior = bottomAppBarScrollBehavior
)
Box(
modifier = Modifier
.fillMaxWidth()
.wrapContentSize()
) {
if (isBottomAppBarVisible) {
HomeNavigationBar(
homeViewState = homeViewState,
scrollBehavior = bottomAppBarScrollBehavior
)
}
Box(
modifier = Modifier
.windowInsetsBottomHeight(WindowInsets.navigationBars)
.fillMaxWidth()
.align(Alignment.BottomCenter)
.background(Color.Transparent)
)
}
},
snackbarHost = { SnackbarHost(hostState = homeViewState.snackbarHostState) }
) { paddingValues ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -30,6 +31,9 @@ internal fun HomeTopAppBar(
val title = homeViewState.currentHomeDestination?.titleTextId
CenterAlignedTopAppBar(
scrollBehavior = scrollBehavior,
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
scrolledContainerColor = MaterialTheme.colorScheme.surface
),
title = {
Text(
modifier = Modifier.testTag("Home AppBar Title"),
Expand Down

0 comments on commit 4efd9c4

Please sign in to comment.