Last active
August 10, 2021 13:10
-
-
Save ibrajix/b6253183eb142193ded37b1d37b8816f to your computer and use it in GitHub Desktop.
StoriesFragment
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
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