From ace7ff464b5ab0183e28c42984433fdd76e5cfad Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 Aug 2020 15:36:31 +0200 Subject: [PATCH] Banned users: use the counter as the title --- .../banned/RoomBannedMemberListController.kt | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/banned/RoomBannedMemberListController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/banned/RoomBannedMemberListController.kt index 51801af187..649a5eed4f 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/banned/RoomBannedMemberListController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/banned/RoomBannedMemberListController.kt @@ -51,42 +51,46 @@ class RoomBannedMemberListController @Inject constructor( override fun buildModels(data: RoomBannedMemberListViewState?) { val bannedList = data?.bannedMemberSummaries?.invoke() ?: return - buildProfileSection( - stringProvider.getString(R.string.room_settings_banned_users_title) - ) + val quantityString = stringProvider.getQuantityString(R.plurals.room_settings_banned_users_count, bannedList.size, bannedList.size) - bannedList.join( - each = { _, roomMember -> - val actionInProgress = data.onGoingModerationAction.contains(roomMember.userId) - profileMatrixItemWithProgress { - id(roomMember.userId) - matrixItem(roomMember.toMatrixItem()) - avatarRenderer(avatarRenderer) - apply { - if (actionInProgress) { - inProgress(true) - editable(false) - } else { - inProgress(false) - editable(true) - clickListener { _ -> - callback?.onUnbanClicked(roomMember) + if (bannedList.isEmpty()) { + buildProfileSection(stringProvider.getString(R.string.room_settings_banned_users_title)) + + genericFooterItem { + id("footer") + text(quantityString) + } + } else { + buildProfileSection(quantityString) + + bannedList.join( + each = { _, roomMember -> + val actionInProgress = data.onGoingModerationAction.contains(roomMember.userId) + profileMatrixItemWithProgress { + id(roomMember.userId) + matrixItem(roomMember.toMatrixItem()) + avatarRenderer(avatarRenderer) + apply { + if (actionInProgress) { + inProgress(true) + editable(false) + } else { + inProgress(false) + editable(true) + clickListener { _ -> + callback?.onUnbanClicked(roomMember) + } } } } + }, + between = { _, roomMemberBefore -> + dividerItem { + id("divider_${roomMemberBefore.userId}") + color(dividerColor) + } } - }, - between = { _, roomMemberBefore -> - dividerItem { - id("divider_${roomMemberBefore.userId}") - color(dividerColor) - } - } - ) - - genericFooterItem { - id("footer") - text(stringProvider.getQuantityString(R.plurals.room_settings_banned_users_count, bannedList.size, bannedList.size)) + ) } } }