Skip to content

Commit 77a4a20

Browse files
authored
Remove pinned channel items customization from the demo (#6340)
* Remove custom background for pinned channel items * Remove sorting by pinned_at * Disable channel pinning * Spotless
1 parent a2f6a7b commit 77a4a20

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/feature/channel/list/ChannelsActivity.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ import io.getstream.chat.android.compose.ui.channels.info.SelectedChannelMenu
8383
import io.getstream.chat.android.compose.ui.channels.list.ChannelItem
8484
import io.getstream.chat.android.compose.ui.channels.list.ChannelList
8585
import io.getstream.chat.android.compose.ui.components.SearchInput
86-
import io.getstream.chat.android.compose.ui.components.channels.ChannelOptionItemVisibility
8786
import io.getstream.chat.android.compose.ui.components.channels.buildDefaultChannelActions
8887
import io.getstream.chat.android.compose.ui.mentions.MentionList
89-
import io.getstream.chat.android.compose.ui.theme.ChannelOptionsTheme
9088
import io.getstream.chat.android.compose.ui.theme.ChatTheme
9189
import io.getstream.chat.android.compose.ui.threads.ThreadList
9290
import io.getstream.chat.android.compose.viewmodel.channels.ChannelListViewModel
@@ -116,9 +114,7 @@ class ChannelsActivity : ComponentActivity() {
116114
val currentUserId = chatClient.getCurrentUser()?.id ?: ""
117115
ChannelListViewModelFactory(
118116
chatClient = chatClient,
119-
querySort = QuerySortByField
120-
.descByName<Channel>("pinned_at") // pinned channels first
121-
.desc("last_updated"), // then by last updated
117+
querySort = QuerySortByField.descByName("last_updated"),
122118
filters = Filters.and(
123119
Filters.eq("type", "messaging"),
124120
Filters.`in`("members", listOf(currentUserId)),
@@ -159,11 +155,6 @@ class ChannelsActivity : ComponentActivity() {
159155
dateFormatter = ChatApp.dateFormatter,
160156
allowUIAutomationTest = true,
161157
componentFactory = CustomChatComponentFactory(),
162-
channelOptionsTheme = ChannelOptionsTheme.defaultTheme(
163-
optionVisibility = ChannelOptionItemVisibility(
164-
isPinChannelVisible = true,
165-
),
166-
),
167158
) {
168159
val user by channelsViewModel.user.collectAsStateWithLifecycle()
169160
val drawerState = rememberDrawerState(DrawerValue.Closed)

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/chats/ChatsActivity.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ class ChatsActivity : ComponentActivity() {
134134
val currentUserId = chatClient.getCurrentUser()?.id ?: ""
135135
ChannelListViewModelFactory(
136136
chatClient = chatClient,
137-
querySort = QuerySortByField
138-
.descByName<Channel>("pinned_at") // pinned channels first
139-
.desc("last_updated"), // then by last updated
137+
querySort = QuerySortByField.descByName("last_updated"),
140138
filters = Filters.and(
141139
Filters.eq("type", "messaging"),
142140
Filters.`in`("members", listOf(currentUserId)),
@@ -167,7 +165,6 @@ class ChatsActivity : ComponentActivity() {
167165
channelOptionsTheme = ChannelOptionsTheme.defaultTheme(
168166
optionVisibility = ChannelOptionItemVisibility(
169167
isViewInfoVisible = AdaptiveLayoutInfo.singlePaneWindow(),
170-
isPinChannelVisible = true,
171168
),
172169
),
173170
) {

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/component/CustomChatComponentFactory.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616

1717
package io.getstream.chat.android.compose.sample.ui.component
1818

19-
import androidx.compose.foundation.background
2019
import androidx.compose.foundation.lazy.LazyItemScope
2120
import androidx.compose.runtime.Composable
2221
import androidx.compose.ui.Modifier
23-
import io.getstream.chat.android.client.extensions.isPinned
2422
import io.getstream.chat.android.compose.sample.ui.location.LocationComponentFactory
2523
import io.getstream.chat.android.compose.sample.vm.SharedLocationViewModelFactory
2624
import io.getstream.chat.android.compose.ui.channels.list.ChannelItem
@@ -40,11 +38,6 @@ class CustomChatComponentFactory(
4038
override fun LazyItemScope.ChannelListItemContent(params: ChannelListItemContentParams) {
4139
val coordinator = LocalSwipeRevealCoordinator.current
4240
val swipeEnabled = ChatTheme.config.channelList.swipeActionsEnabled && coordinator != null
43-
val pinnedModifier = if (params.channelItem.channel.isPinned()) {
44-
Modifier.background(color = ChatTheme.colors.backgroundCoreHighlight)
45-
} else {
46-
Modifier
47-
}
4841

4942
if (swipeEnabled) {
5043
SwipeableChannelItem(
@@ -54,7 +47,6 @@ class CustomChatComponentFactory(
5447
swipeActions = { ChannelSwipeActions(ChannelSwipeActionsParams(params.channelItem)) },
5548
) {
5649
ChannelItem(
57-
modifier = pinnedModifier,
5850
channelItem = params.channelItem,
5951
currentUser = params.currentUser,
6052
onChannelClick = params.onChannelClick,
@@ -63,7 +55,7 @@ class CustomChatComponentFactory(
6355
}
6456
} else {
6557
ChannelItem(
66-
modifier = Modifier.animateItem().then(pinnedModifier),
58+
modifier = Modifier.animateItem(),
6759
channelItem = params.channelItem,
6860
currentUser = params.currentUser,
6961
onChannelClick = params.onChannelClick,

0 commit comments

Comments
 (0)