diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt
index c271ee0d44..20b6cf089e 100644
--- a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt
+++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt
@@ -21,7 +21,9 @@ import android.os.Parcelable
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
+import androidx.recyclerview.widget.RecyclerView
import com.airbnb.mvrx.*
+import com.google.android.material.floatingactionbutton.FloatingActionButton
import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.room.model.RoomSummary
import im.vector.riotredesign.R
@@ -41,6 +43,8 @@ data class RoomListParams(
class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
+ lateinit var fabButton: FloatingActionButton
+
enum class DisplayMode(@StringRes val titleRes: Int) {
HOME(R.string.bottom_action_home),
PEOPLE(R.string.bottom_action_people),
@@ -63,8 +67,8 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
- setupRecyclerView()
setupCreateRoomButton()
+ setupRecyclerView()
roomListViewModel.subscribe { renderState(it) }
roomListViewModel.openRoomLiveData.observeEvent(this) {
navigator.openRoom(it)
@@ -72,14 +76,20 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
}
private fun setupCreateRoomButton() {
- createRoomButton.isVisible = roomListParams.displayMode == DisplayMode.HOME
- createChatRoomButton.isVisible = roomListParams.displayMode == DisplayMode.PEOPLE
- createGroupRoomButton.isVisible = roomListParams.displayMode == DisplayMode.ROOMS
+ fabButton = when (roomListParams.displayMode) {
+ DisplayMode.HOME -> createRoomButton
+ DisplayMode.PEOPLE -> createChatRoomButton
+ else -> createGroupRoomButton
+ }
+
+ fabButton.isVisible = true
createRoomButton.setOnClickListener {
+ // TODO Is it the expected action?
navigator.openRoomDirectory()
}
createChatRoomButton.setOnClickListener {
+ // TODO Is it the expected action?
navigator.openRoomDirectory()
}
createGroupRoomButton.setOnClickListener {
@@ -96,6 +106,26 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback {
roomController.addModelBuildListener { it.dispatchTo(stateRestorer) }
stateView.contentView = epoxyRecyclerView
epoxyRecyclerView.setController(roomController)
+ // Hide FAB when list is scrolling
+ epoxyRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
+ override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
+ fabButton.removeCallbacks(showFabRunnable)
+
+ when (newState) {
+ RecyclerView.SCROLL_STATE_IDLE -> {
+ fabButton.postDelayed(showFabRunnable, 1000)
+ }
+ RecyclerView.SCROLL_STATE_DRAGGING,
+ RecyclerView.SCROLL_STATE_SETTLING -> {
+ fabButton.hide()
+ }
+ }
+ }
+ })
+ }
+
+ private val showFabRunnable = Runnable {
+ fabButton.show()
}
private fun renderState(state: RoomListViewState) {
diff --git a/vector/src/main/res/drawable/red_dot.xml b/vector/src/main/res/drawable/red_dot.xml
new file mode 100644
index 0000000000..58e5454d5c
--- /dev/null
+++ b/vector/src/main/res/drawable/red_dot.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vector/src/main/res/layout/fragment_home_detail.xml b/vector/src/main/res/layout/fragment_home_detail.xml
index fa6d9e5beb..fd39b751f1 100644
--- a/vector/src/main/res/layout/fragment_home_detail.xml
+++ b/vector/src/main/res/layout/fragment_home_detail.xml
@@ -60,6 +60,7 @@
android:layout_width="0dp"
android:layout_height="48dp"
android:background="#FFFFFF"
+ app:itemIconSize="20dp"
app:itemIconTint="@color/home_bottom_nav_view_tint"
app:itemTextColor="@color/home_bottom_nav_view_tint"
app:labelVisibilityMode="unlabeled"
diff --git a/vector/src/main/res/layout/fragment_room_list.xml b/vector/src/main/res/layout/fragment_room_list.xml
index 852d7460a3..b94aceab66 100644
--- a/vector/src/main/res/layout/fragment_room_list.xml
+++ b/vector/src/main/res/layout/fragment_room_list.xml
@@ -22,7 +22,9 @@
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_fab_add"
- app:maxImageSize="14dp" />
+ android:visibility="gone"
+ app:maxImageSize="14dp"
+ tools:visibility="visible" />
+ tools:layout_margin="66dp"
+ tools:visibility="visible" />
+ tools:layout_margin="116dp"
+ tools:visibility="visible" />