Skip to content
Snippets Groups Projects
Commit 14c95c2c authored by Taras's avatar Taras
Browse files

Add menu on Circles tab

parent 48b84d69
No related branches found
No related tags found
No related merge requests found
package org.futo.circles.feature.circles package org.futo.circles.feature.circles
import android.annotation.SuppressLint
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View import android.view.View
import androidx.appcompat.view.menu.MenuBuilder
import androidx.core.view.MenuProvider
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
...@@ -25,7 +31,7 @@ import org.futo.circles.feature.circles.list.CirclesListAdapter ...@@ -25,7 +31,7 @@ import org.futo.circles.feature.circles.list.CirclesListAdapter
import org.futo.circles.model.CircleListItem import org.futo.circles.model.CircleListItem
@AndroidEntryPoint @AndroidEntryPoint
class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms) { class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms), MenuProvider {
private val viewModel by viewModels<CirclesViewModel>() private val viewModel by viewModels<CirclesViewModel>()
private val binding by viewBinding(FragmentRoomsBinding::bind) private val binding by viewBinding(FragmentRoomsBinding::bind)
...@@ -37,6 +43,7 @@ class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms) ...@@ -37,6 +43,7 @@ class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms)
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupViews() setupViews()
setupObservers() setupObservers()
activity?.addMenuProvider(this, viewLifecycleOwner)
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -50,6 +57,20 @@ class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms) ...@@ -50,6 +57,20 @@ class CirclesFragment : Fragment(org.futo.circles.core.R.layout.fragment_rooms)
listAdapter = null listAdapter = null
} }
@SuppressLint("RestrictedApi")
override fun onCreateMenu(menu: Menu, inflater: MenuInflater) {
(menu as? MenuBuilder)?.setOptionalIconsVisible(true)
menu.clear()
inflater.inflate(R.menu.circles_tab_menu, menu)
}
override fun onMenuItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.help -> CirclesExplanationDialog(requireContext(), CircleRoomTypeArg.Circle).show()
}
return true
}
private fun setupViews() { private fun setupViews() {
binding.rvRooms.apply { binding.rvRooms.apply {
setEmptyView(EmptyTabPlaceholderView(requireContext()).apply { setEmptyView(EmptyTabPlaceholderView(requireContext()).apply {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment