Skip to content

Commit

Permalink
#7 Update: BottomNavigationBar
Browse files Browse the repository at this point in the history
  • Loading branch information
0se0 committed Nov 14, 2024
1 parent e0cc77e commit 465839e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions app/src/main/java/org/sopt/and/feature/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
Expand All @@ -22,6 +24,7 @@ import org.sopt.and.feature.mypage.MyPageViewModel
import org.sopt.and.feature.search.SearchRoute
import org.sopt.and.feature.signup.SignUpRoute
import org.sopt.and.feature.signup.SignUpViewModel
import org.sopt.and.network.ServicePool.userService
import org.sopt.and.ui.theme.ANDANDROIDTheme

class MainActivity : ComponentActivity() {
Expand All @@ -30,19 +33,28 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
userRepository = UserRepository(this)
userRepository = UserRepository(userService, applicationContext)

setContent {
val isLoggedIn = remember { mutableStateOf(userRepository.isLoggedIn()) }

ANDANDROIDTheme {
ChangeStatusBarColor()
val navController = rememberNavController()

navController.addOnDestinationChangedListener { _, _, _ ->
isLoggedIn.value = userRepository.isLoggedIn()
}


Scaffold(
modifier = Modifier.fillMaxSize(),
bottomBar = {
if (userRepository.isLoggedIn()) {
BottomNavigationBar(navController = navController)
Modifier.navigationBarsPadding()
if (isLoggedIn.value) {
BottomNavigationBar(
navController = navController,
modifier = Modifier.navigationBarsPadding()
)
}
}
) { innerPadding ->
Expand Down

0 comments on commit 465839e

Please sign in to comment.