-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 바텀 네비게이션 visibility 설정, 툴바 네비게이션 연결
- Loading branch information
1 parent
54c7a5e
commit 81be25e
Showing
4 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
39 changes: 35 additions & 4 deletions
39
presentation/src/main/java/com/gta/presentation/ui/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,50 @@ | ||
package com.gta.presentation.ui | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.navigation.fragment.NavHostFragment | ||
import androidx.navigation.ui.AppBarConfiguration | ||
import androidx.navigation.ui.setupActionBarWithNavController | ||
import androidx.navigation.ui.setupWithNavController | ||
import com.gta.presentation.R | ||
import com.gta.presentation.databinding.ActivityMainBinding | ||
import com.gta.presentation.ui.base.BaseActivity | ||
|
||
class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::inflate) { | ||
private val navHostFragment by lazy { supportFragmentManager.findFragmentById(R.id.fcv_main) as NavHostFragment } | ||
private val navController by lazy { navHostFragment.navController } | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val navHostFragment = | ||
supportFragmentManager.findFragmentById(R.id.fcv_home_fragment) as NavHostFragment | ||
val navController = navHostFragment.navController | ||
binding.bnvHomeBottomNav.setupWithNavController(navController) | ||
|
||
setSupportActionBar(binding.tbMain) | ||
|
||
setupWithBottomNavigation() | ||
|
||
setupWithAppBar() | ||
} | ||
|
||
private fun setupWithAppBar() { | ||
val appBarConfiguration = AppBarConfiguration(setOf(R.id.mapFragment, R.id.chattingFragment, R.id.myPageFragment)) | ||
setupActionBarWithNavController(navController, appBarConfiguration) | ||
} | ||
|
||
private fun setupWithBottomNavigation() { | ||
binding.bnvMain.setupWithNavController(navController) | ||
|
||
navController.addOnDestinationChangedListener { _, destination, _ -> | ||
when (destination.id) { | ||
R.id.mapFragment, R.id.chattingFragment, R.id.myPageFragment -> showBottomNav() | ||
else -> hideBottomNav() | ||
} | ||
} | ||
} | ||
|
||
private fun showBottomNav() { | ||
binding.bnvMain.visibility = View.VISIBLE | ||
} | ||
|
||
private fun hideBottomNav() { | ||
binding.bnvMain.visibility = View.GONE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<resources> | ||
<string name="app_name">니차내차</string> | ||
<string name="my_near">내주변</string> | ||
<string name="my_near">내 주변</string> | ||
<string name="chatting">채팅</string> | ||
<string name="my_page">마이페이지</string> | ||
</resources> |