Fix / visibility bug after scroll

+ refine animation
This commit is contained in:
Valere 2019-06-11 15:43:40 +02:00
parent 90a011c4e4
commit 1206107a73
3 changed files with 61 additions and 23 deletions

View File

@ -93,25 +93,26 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback, O
}

// Hide FAB when list is scrolling
epoxyRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
createChatFabMenu.removeCallbacks(showFabRunnable)
epoxyRecyclerView.addOnScrollListener(
object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
createChatFabMenu.removeCallbacks(showFabRunnable)

when (newState) {
RecyclerView.SCROLL_STATE_IDLE -> {
createChatFabMenu.postDelayed(showFabRunnable, 1000)
}
RecyclerView.SCROLL_STATE_DRAGGING,
RecyclerView.SCROLL_STATE_SETTLING -> {
when (roomListParams.displayMode) {
DisplayMode.HOME -> createChatFabMenu.hide()
DisplayMode.PEOPLE -> createChatRoomButton.hide()
else -> createGroupRoomButton.hide()
when (newState) {
RecyclerView.SCROLL_STATE_IDLE -> {
createChatFabMenu.postDelayed(showFabRunnable, 1000)
}
RecyclerView.SCROLL_STATE_DRAGGING,
RecyclerView.SCROLL_STATE_SETTLING -> {
when (roomListParams.displayMode) {
DisplayMode.HOME -> createChatFabMenu.hide()
DisplayMode.PEOPLE -> createChatRoomButton.hide()
else -> createGroupRoomButton.hide()
}
}
}
}
}
}
})
})
}


@ -220,7 +221,7 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback, O
return super.onBackPressed()
}

// RoomSummaryController.Callback **************************************************************
// RoomSummaryController.Callback **************************************************************

override fun onRoomSelected(room: RoomSummary) {
roomListViewModel.accept(RoomListActions.SelectRoom(room))

View File

@ -19,6 +19,8 @@ package im.vector.riotredesign.features.home.room.list.widget
import android.content.Context
import android.util.AttributeSet
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.view.isVisible
import com.google.android.material.floatingactionbutton.FloatingActionButton
import im.vector.riotredesign.R
import im.vector.riotredesign.features.themes.ThemeUtils
import kotlinx.android.synthetic.main.motion_fab_menu_merge.view.*
@ -62,14 +64,17 @@ class FabMenuView @JvmOverloads constructor(context: Context, attrs: AttributeSe
}

fun show() {
// Ensure visibility is well restored
// FIXME It does not work, FAB is not visible, alpha is 0... And cannot set it to 1

isVisible = true
createRoomButton.show()
}

fun hide() {
createRoomButton.hide()
createRoomButton.hide(object : FloatingActionButton.OnVisibilityChangedListener() {
override fun onHidden(fab: FloatingActionButton?) {
super.onHidden(fab)
isVisible = false
}
})
}

private fun closeFabMenu() {

View File

@ -6,12 +6,44 @@
<Transition
motion:constraintSetEnd="@+id/constraint_set_fab_menu_open"
motion:constraintSetStart="@+id/constraint_set_fab_menu_close"
motion:duration="200">
motion:motionInterpolator="easeInOut"
motion:duration="300">

<OnClick
motion:clickAction="toggle"
motion:targetId="@+id/createRoomButton" />

<KeyFrameSet>

<!-- First icon goes up quickly to let room for other-->
<KeyPosition
motion:motionTarget="@id/createRoomItemGroup"
motion:framePosition="50"
motion:percentX="0.8"
motion:percentY="0.8"
motion:keyPositionType="deltaRelative"
/>
<KeyPosition
motion:motionTarget="@id/createRoomItemGroupLabel"
motion:framePosition="50"
motion:percentX="0.9"
motion:percentY="0.8"
motion:keyPositionType="deltaRelative"
/>

<!-- Delay apparition of labels-->
<KeyAttribute
motion:motionTarget="@id/createRoomItemChatLabel"
android:alpha="0.4"
motion:framePosition="80"
/>
<KeyAttribute
motion:motionTarget="@id/createRoomItemGroupLabel"
android:alpha="0.4"
motion:framePosition="80"
/>

</KeyFrameSet>
</Transition>

<ConstraintSet android:id="@+id/constraint_set_fab_menu_close" >
@ -96,7 +128,7 @@

</ConstraintSet>

<ConstraintSet android:id="@+id/constraint_set_fab_menu_open">
<ConstraintSet android:id="@+id/constraint_set_fab_menu_open" >

<Constraint
android:id="@+id/createRoomTouchGuard"