Skip to content

Instantly share code, notes, and snippets.

@ibrajix
Last active August 10, 2021 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibrajix/b6253183eb142193ded37b1d37b8816f to your computer and use it in GitHub Desktop.
Save ibrajix/b6253183eb142193ded37b1d37b8816f to your computer and use it in GitHub Desktop.
StoriesFragment
class StoriesFragment : Fragment() {
private val binding by viewBinding(FragmentStoriesBinding::bind)
lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_stories, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
navController = Navigation.findNavController(view)
initView()
}
private fun initView(){
handleClicks()
}
private fun handleClicks(){
//on click stories, go to view stories fragment
binding.storiesView.setOnClickListener {
val action = StoriesFragmentDirections.actionStoriesFragmentToViewStoriesFragment()
navController.navigate(action)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment