Fixes bug where bottom sheet sometimes renders with the wrong height

This commit is contained in:
ericdecanini 2022-08-03 21:54:05 +02:00
parent aa24debd87
commit 5d183654b1
4 changed files with 91 additions and 86 deletions

View File

@ -64,6 +64,8 @@ class HomeRoomListFragment @Inject constructor(
private var concatAdapter = ConcatAdapter()
private var modelBuildListener: OnModelBuildFinishedListener? = null
private val spacesBottomSheet = SpacesBottomSheet()
private lateinit var stateRestorer: LayoutManagerStateRestorer
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding {
@ -120,7 +122,7 @@ class HomeRoomListFragment @Inject constructor(
views.newLayoutOpenSpacesButton.setOnClickListener {
// Click action for open spaces modal goes here
SpacesBottomSheet().show(requireActivity().supportFragmentManager, SpacesBottomSheet.TAG)
spacesBottomSheet.show(requireActivity().supportFragmentManager, SpacesBottomSheet.TAG)
}
// Hide FABs when list is scrolling

View File

@ -143,7 +143,7 @@ class SpaceListFragment @Inject constructor(
}
if (vectorFeatures.isNewAppLayoutEnabled()) {
newSpaceController.update(state)
newSpaceController.update(state).also { onUpdate?.invoke() }
} else {
spaceController.update(state)
}

View File

@ -31,13 +31,10 @@ class SpacesBottomSheet : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentSpacesBottomSheetBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
if (savedInstanceState == null) {
replaceChildFragment(R.id.space_list, SpaceListFragment::class.java)
}
return binding.root
}
companion object {

View File

@ -1,101 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<im.vector.app.core.platform.StateView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/stateView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground">
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/roomListView"
<im.vector.app.core.platform.StateView
android:id="@+id/stateView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always"
tools:itemCount="5"
tools:listitem="@layout/item_room" />
android:background="?android:colorBackground">
<im.vector.app.features.home.room.list.widget.NotifsFabMenuView
android:id="@+id/createChatFabMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:layoutDescription="@xml/motion_scene_notifs_fab_menu"
tools:showPaths="true"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/roomListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always"
tools:itemCount="5"
tools:listitem="@layout/item_room" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/createChatRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_direct_message"
android:scaleType="center"
android:src="@drawable/ic_fab_add_chat"
android:visibility="gone"
app:maxImageSize="34dp"
tools:layout_marginEnd="80dp"
tools:visibility="visible" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/createGroupRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_room"
android:src="@drawable/ic_fab_add_room"
android:visibility="gone"
app:maxImageSize="32dp"
tools:layout_marginEnd="144dp"
tools:visibility="visible" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutOpenSpacesButton"
style="@style/Widget.Vector.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
android:contentDescription="@string/a11y_create_room"
android:src="@drawable/ic_open_spaces"
<im.vector.app.features.home.room.list.widget.NotifsFabMenuView
android:id="@+id/createChatFabMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:backgroundTint="?attr/vctr_toolbar_background"
app:fabSize="mini"
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
app:tint="?attr/colorPrimary"
tools:visibility="visible"
tools:targetApi="lollipop_mr1" />
app:layoutDescription="@xml/motion_scene_notifs_fab_menu"
tools:showPaths="true"
tools:visibility="visible" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutCreateChatButton"
style="@style/Widget.Vector.FloatingActionButton"
android:id="@+id/createChatRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_direct_message"
android:scaleType="center"
android:src="@drawable/ic_fab_add_chat"
android:visibility="gone"
app:maxImageSize="34dp"
tools:layout_marginEnd="80dp"
tools:visibility="visible" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/createGroupRoomButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_room"
android:src="@drawable/ic_new_chat"
android:src="@drawable/ic_fab_add_room"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible"
tools:targetApi="lollipop_mr1" />
app:maxImageSize="32dp"
tools:layout_marginEnd="144dp"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom|end">
</im.vector.app.core.platform.StateView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutOpenSpacesButton"
style="@style/Widget.Vector.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
android:contentDescription="@string/a11y_create_room"
android:src="@drawable/ic_open_spaces"
android:visibility="gone"
app:backgroundTint="?attr/vctr_toolbar_background"
app:fabSize="mini"
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
app:tint="?attr/colorPrimary"
tools:targetApi="lollipop_mr1"
tools:visibility="visible" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/newLayoutCreateChatButton"
style="@style/Widget.Vector.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:accessibilityTraversalBefore="@id/roomListView"
android:contentDescription="@string/a11y_create_room"
android:src="@drawable/ic_new_chat"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:targetApi="lollipop_mr1"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</im.vector.app.core.platform.StateView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>