Benoit code review fixes.

This commit is contained in:
Onuray Sahin 2020-10-12 18:32:31 +03:00
parent f82aee6089
commit d6b94802d8
2 changed files with 14 additions and 17 deletions

View File

@ -58,6 +58,15 @@ class RoomMemberListFragment @Inject constructor(
setupSearchView() setupSearchView()
setupInviteUsersButton() setupInviteUsersButton()
recyclerView.configureWith(roomMemberListController, hasFixedSize = true) recyclerView.configureWith(roomMemberListController, hasFixedSize = true)
viewModel.selectSubscribe(this, RoomMemberListViewState::actionsPermissions) {
invalidateOptionsMenu()
}
}
private fun setupInviteUsersButton() {
inviteUsersButton.debouncedClicks {
navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
}
// Hide FAB when list is scrolling // Hide FAB when list is scrolling
recyclerView.addOnScrollListener( recyclerView.addOnScrollListener(
object : RecyclerView.OnScrollListener() { object : RecyclerView.OnScrollListener() {
@ -76,15 +85,6 @@ class RoomMemberListFragment @Inject constructor(
} }
} }
) )
viewModel.selectSubscribe(this, RoomMemberListViewState::actionsPermissions) {
invalidateOptionsMenu()
}
}
private fun setupInviteUsersButton() {
inviteUsersButton.debouncedClicks {
navigator.openInviteUsersToRoom(requireContext(), roomProfileArgs.roomId)
}
} }
private fun setupSearchView() { private fun setupSearchView() {
@ -110,6 +110,7 @@ class RoomMemberListFragment @Inject constructor(
override fun invalidate() = withState(viewModel) { viewState -> override fun invalidate() = withState(viewModel) { viewState ->
roomMemberListController.setData(viewState) roomMemberListController.setData(viewState)
renderRoomSummary(viewState) renderRoomSummary(viewState)
inviteUsersButton.isVisible = viewState.actionsPermissions.canInvite
} }
override fun onRoomMemberClicked(roomMember: RoomMemberSummary) { override fun onRoomMemberClicked(roomMember: RoomMemberSummary) {
@ -137,6 +138,5 @@ class RoomMemberListFragment @Inject constructor(
roomSettingsToolbarTitleView.text = it.displayName roomSettingsToolbarTitleView.text = it.displayName
avatarRenderer.render(it.toMatrixItem(), roomSettingsToolbarAvatarImageView) avatarRenderer.render(it.toMatrixItem(), roomSettingsToolbarAvatarImageView)
} }
inviteUsersButton.isVisible = state.actionsPermissions.canInvite
} }
} }

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -11,14 +10,12 @@
android:id="@+id/inviteUsersButton" android:id="@+id/inviteUsersButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:contentDescription="@string/add_members_to_room" android:contentDescription="@string/add_members_to_room"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_fab_add_members" android:src="@drawable/ic_fab_add_members"
app:layout_constraintBottom_toBottomOf="parent" app:maxImageSize="36dp" />
app:layout_constraintEnd_toEndOf="parent"
app:maxImageSize="36dp"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout> </FrameLayout>