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,7 +93,8 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback, O
} }


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



View File

@ -19,6 +19,8 @@ package im.vector.riotredesign.features.home.room.list.widget
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import androidx.constraintlayout.motion.widget.MotionLayout 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.R
import im.vector.riotredesign.features.themes.ThemeUtils import im.vector.riotredesign.features.themes.ThemeUtils
import kotlinx.android.synthetic.main.motion_fab_menu_merge.view.* import kotlinx.android.synthetic.main.motion_fab_menu_merge.view.*
@ -62,14 +64,17 @@ class FabMenuView @JvmOverloads constructor(context: Context, attrs: AttributeSe
} }


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

createRoomButton.show() createRoomButton.show()
} }


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


private fun closeFabMenu() { private fun closeFabMenu() {

View File

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


<OnClick <OnClick
motion:clickAction="toggle" motion:clickAction="toggle"
motion:targetId="@+id/createRoomButton" /> 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> </Transition>


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