diff --git a/app/src/main/java/com/android/go/sopt/winey/data/interceptor/AuthInterceptor.kt b/app/src/main/java/com/android/go/sopt/winey/data/interceptor/AuthInterceptor.kt index a0614057..9bafce6c 100644 --- a/app/src/main/java/com/android/go/sopt/winey/data/interceptor/AuthInterceptor.kt +++ b/app/src/main/java/com/android/go/sopt/winey/data/interceptor/AuthInterceptor.kt @@ -21,6 +21,6 @@ class AuthInterceptor @Inject constructor( companion object { private const val HEADER_TOKEN = "userId" - const val USER_ID = "24" + const val USER_ID = "1" } } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt index 48cb046e..69c72cef 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/MainActivity.kt @@ -22,6 +22,7 @@ class MainActivity : BindingActivity(R.layout.activity_main navigateTo() initBnvItemSelectedListener() + syncBottomNavigationSelection() } private fun initBnvItemSelectedListener() { @@ -35,7 +36,23 @@ class MainActivity : BindingActivity(R.layout.activity_main } } - private inline fun navigateTo() { + fun syncBottomNavigationSelection() { + supportFragmentManager.addOnBackStackChangedListener { + syncBottomNavigation() + } + } + + fun syncBottomNavigation() { + val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_main) + when (currentFragment) { + is WineyFeedFragment -> binding.bnvMain.selectedItemId = R.id.menu_feed + is RecommendFragment -> binding.bnvMain.selectedItemId = R.id.menu_recommend + is MyPageFragment -> binding.bnvMain.selectedItemId = R.id.menu_mypage + // 다른 프래그먼트도 추가가능 + } + } + + inline fun navigateTo() { supportFragmentManager.commit { replace(R.id.fcv_main, T::class.simpleName) } diff --git a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDialogFragment.kt b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDialogFragment.kt index e96851ee..41edc06e 100644 --- a/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDialogFragment.kt +++ b/app/src/main/java/com/android/go/sopt/winey/presentation/main/feed/WineyFeedDialogFragment.kt @@ -7,9 +7,11 @@ import com.android.go.sopt.winey.R import com.android.go.sopt.winey.databinding.FragmentWineyfeedNoGoalDialogBinding import com.android.go.sopt.winey.presentation.main.mypage.MyPageFragment import com.android.go.sopt.winey.util.binding.BindingDialogFragment +import com.google.android.material.bottomnavigation.BottomNavigationView class WineyFeedDialogFragment : BindingDialogFragment(R.layout.fragment_wineyfeed_no_goal_dialog) { + private lateinit var bottomNav: BottomNavigationView override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) initButtonClickListener() @@ -29,6 +31,8 @@ class WineyFeedDialogFragment : parentFragmentManager.commit { replace(R.id.fcv_main, MyPageFragment()) } + bottomNav = requireActivity().findViewById(R.id.bnv_main) + bottomNav.selectedItemId = R.id.menu_mypage } companion object {