Skip to content

Commit

Permalink
fix: remove conversations title on import media screen [WPB-1860] (#2111
Browse files Browse the repository at this point in the history
)

Co-authored-by: Michał Saleniuk <30429749+saleniuk@users.noreply.github.com>
Co-authored-by: Michał Saleniuk <saleniuk@gmail.com>
  • Loading branch information
3 people committed Aug 17, 2023
1 parent 02e5794 commit 37d7257
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fun ConversationList(
header = when (conversationFolder) {
is ConversationFolder.Predefined -> context.getString(conversationFolder.folderNameResId)
is ConversationFolder.Custom -> conversationFolder.folderName
is ConversationFolder.WithoutHeader -> null
},
items = conversationList.associateBy {
it.conversationId.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import androidx.annotation.StringRes
import com.wire.android.R

sealed class ConversationFolder {
sealed class Predefined(@StringRes val folderNameResId: Int): ConversationFolder() {
object Conversations: Predefined(R.string.conversation_label_conversations)
object Favorites: Predefined(R.string.conversation_label_favorites)
object NewActivities: Predefined(R.string.conversation_label_new_activity)
sealed class Predefined(@StringRes val folderNameResId: Int) : ConversationFolder() {
data object Conversations : Predefined(R.string.conversation_label_conversations)
data object Favorites : Predefined(R.string.conversation_label_favorites)
data object NewActivities : Predefined(R.string.conversation_label_new_activity)
}
data class Custom(val folderName: String): ConversationFolder()
data class Custom(val folderName: String) : ConversationFolder()
data object WithoutHeader : ConversationFolder()
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private fun ImportMediaContent(
modifier = Modifier.weight(1f),
lazyListState = lazyListState,
conversationListItems = persistentMapOf(
ConversationFolder.Predefined.Conversations to state.shareableConversationListState.searchResult
ConversationFolder.WithoutHeader to state.shareableConversationListState.searchResult
),
conversationsAddedToGroup = state.selectedConversationItem,
isSelectableList = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,50 @@
package com.wire.android.util.extension

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.wire.android.ui.home.conversationslist.common.FolderHeader

@OptIn(ExperimentalFoundationApi::class)
inline fun <T, K : Any> LazyListScope.folderWithElements(
header: String,
headerColor: Color? = null,
header: String? = null,
items: Map<K, T>,
crossinline divider: @Composable () -> Unit = {},
crossinline factory: @Composable (T) -> Unit
) {
val list = items.entries.toList()

if (items.isNotEmpty()) {
item(key = "header:$header") {
if (header.isNotEmpty()) {
FolderHeader(
name = header,
modifier = Modifier
.fillMaxWidth()
.run { headerColor?.let { background(color = it) } ?: this }
.animateItemPlacement()
)
if (header != null) {
item(key = "header:$header") {
if (header.isNotEmpty()) {
FolderHeader(
name = header,
modifier = Modifier
.fillMaxWidth()
.animateItemPlacement()
)
}
}
}
itemsIndexed(
items = list,
key = { _: Int, item: Map.Entry<K, T> -> "$header:${item.key}" })
{ index: Int, item: Map.Entry<K, T> ->
key = { _: Int, item: Map.Entry<K, T> -> "$header:${item.key}" }
) { index: Int, item: Map.Entry<K, T> ->
Box(
modifier = Modifier
.wrapContentSize()
.animateItemPlacement()
) {
factory(item.value)
if (index <= list.lastIndex)
if (index <= list.lastIndex) {
divider()
}
}
}
}
Expand Down

0 comments on commit 37d7257

Please sign in to comment.