Skip to content

Commit

Permalink
[feat] #8 현재 fragment에 따른 바텀 네비게이션 visibility 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 15, 2024
1 parent 2953f10 commit fdd9e9d
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
package org.sopt.kream.presentation.ui.main

import android.os.Bundle
import android.view.View
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import org.sopt.kream.R
import org.sopt.kream.databinding.ActivityMainBinding
import org.sopt.kream.util.base.BindingActivity

class MainActivity : BindingActivity<ActivityMainBinding>({ ActivityMainBinding.inflate(it) })
class MainActivity : BindingActivity<ActivityMainBinding>({ ActivityMainBinding.inflate(it) }) {
private lateinit var navController: NavController

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fcv_main) as NavHostFragment
navController = navHostFragment.findNavController()

navController.addOnDestinationChangedListener { _, destination, _ ->
if (destination.id == R.id.recommend_fragment || destination.id == R.id.release_fragment) {
binding.bnvMain.visibility = View.VISIBLE
} else if (destination.id == R.id.search_fragment || destination.id == R.id.product_detail_fragment) {
binding.bnvMain.visibility = View.GONE
}
}
}
}

0 comments on commit fdd9e9d

Please sign in to comment.