Skip to content

Commit

Permalink
add tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Dec 6, 2021
1 parent c87b56a commit 4f602bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.sigmai.stylemento.R

class CoordinatorFragment : Fragment() {
class CoordinatorHostFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>() {
binding.viewModel = viewModel

viewModel.startNext.observe(this, Observer {
findNavController().navigate(LoginFragmentDirections.actionLoginToSignup())
findNavController().navigate(R.id.action_login_to_signup)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import com.sigmai.stylemento.global.base.BaseFragment
class MainFragment : BaseFragment<FragmentMainBinding>() {
override val layoutResourceId = R.layout.fragment_main

private val outlinedIcons = arrayListOf(R.drawable.ic_tab_outlined_notification, R.drawable.ic_tab_outlined_coordinator,
R.drawable.ic_tab_outlined_home, R.drawable.ic_tab_outlined_chat, R.drawable.ic_tab_outlined_my_page)
private val filledIcons = arrayListOf(R.drawable.ic_tab_filled_notification, R.drawable.ic_tab_filled_coordinator,
R.drawable.ic_tab_filled_home, R.drawable.ic_tab_filled_chat, R.drawable.ic_tab_fillted_my_page)

override fun initState() {
super.initState()

Expand All @@ -23,7 +28,7 @@ class MainFragment : BaseFragment<FragmentMainBinding>() {

viewPager?.adapter = pagerAdapter
TabLayoutMediator(tabs!!, viewPager!!) { tab, position ->
tab.text = "TAB"
tab.setIcon(outlinedIcons[position])
}.attach()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package com.sigmai.stylemento.feature.main
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.sigmai.stylemento.feature.coordinator.CoordinatorHostFragment
import com.sigmai.stylemento.feature.home.HomeFragment
import com.sigmai.stylemento.feature.home.HomeHostFragment

class MainPagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
override fun getItemCount(): Int = 2
override fun getItemCount(): Int = 5
override fun createFragment(position: Int): Fragment {
return when(position) {
0 -> HomeHostFragment()
1 -> HomeHostFragment()
2 -> HomeHostFragment()
3 -> HomeHostFragment()
4 -> HomeHostFragment()
else -> HomeHostFragment()
}
}
Expand Down

0 comments on commit 4f602bc

Please sign in to comment.