Skip to content

Commit 946611c

Browse files
committed
Remove ChannelOptionsTheme and move options visibility to config
1 parent 6971069 commit 946611c

9 files changed

Lines changed: 244 additions & 314 deletions

File tree

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import androidx.compose.ui.Modifier
2525
import androidx.compose.ui.semantics.semantics
2626
import androidx.compose.ui.semantics.testTagsAsResourceId
2727
import io.getstream.chat.android.compose.sample.ChatApp
28-
import io.getstream.chat.android.compose.ui.theme.ChannelOptionsTheme
2928
import io.getstream.chat.android.compose.ui.theme.ChatComponentFactory
3029
import io.getstream.chat.android.compose.ui.theme.ChatTheme
3130
import io.getstream.chat.android.compose.ui.theme.ChatUiConfig
@@ -38,15 +37,13 @@ import io.getstream.chat.android.compose.ui.theme.ChatUiConfig
3837
internal fun SampleChatTheme(
3938
config: ChatUiConfig = ChatUiConfig(),
4039
componentFactory: ChatComponentFactory = object : ChatComponentFactory {},
41-
channelOptionsTheme: ChannelOptionsTheme = ChannelOptionsTheme.defaultTheme(),
4240
content: @Composable () -> Unit,
4341
) {
4442
Box(modifier = Modifier.semantics { testTagsAsResourceId = true }) {
4543
ChatTheme(
4644
dateFormatter = ChatApp.dateFormatter,
4745
config = config,
4846
componentFactory = componentFactory,
49-
channelOptionsTheme = channelOptionsTheme,
5047
content = content,
5148
)
5249
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ import io.getstream.chat.android.compose.ui.channels.SearchMode
6868
import io.getstream.chat.android.compose.ui.chats.ChatListContentMode
6969
import io.getstream.chat.android.compose.ui.chats.ChatMessageSelection
7070
import io.getstream.chat.android.compose.ui.chats.ChatsScreen
71-
import io.getstream.chat.android.compose.ui.components.channels.ChannelOptionItemVisibility
72-
import io.getstream.chat.android.compose.ui.theme.ChannelOptionsTheme
71+
import io.getstream.chat.android.compose.ui.components.channels.ChannelOptionsVisibility
72+
import io.getstream.chat.android.compose.ui.theme.ChannelListConfig
7373
import io.getstream.chat.android.compose.ui.theme.ChatComponentFactory
7474
import io.getstream.chat.android.compose.ui.theme.ChatTheme
75+
import io.getstream.chat.android.compose.ui.theme.ChatUiConfig
7576
import io.getstream.chat.android.compose.ui.theme.CompoundComponentFactory
7677
import io.getstream.chat.android.compose.ui.theme.DirectChannelInfoTopBarParams
7778
import io.getstream.chat.android.compose.ui.theme.GroupChannelInfoTopBarParams
@@ -159,9 +160,11 @@ class ChatsActivity : ComponentActivity() {
159160

160161
setContent {
161162
SampleChatTheme(
162-
channelOptionsTheme = ChannelOptionsTheme.defaultTheme(
163-
optionVisibility = ChannelOptionItemVisibility(
164-
isViewInfoVisible = AdaptiveLayoutInfo.singlePaneWindow(),
163+
config = ChatUiConfig(
164+
channelList = ChannelListConfig(
165+
optionsVisibility = ChannelOptionsVisibility(
166+
isViewInfoVisible = AdaptiveLayoutInfo.singlePaneWindow(),
167+
),
165168
),
166169
),
167170
) {

stream-chat-android-compose/api/stream-chat-android-compose.api

Lines changed: 228 additions & 245 deletions
Large diffs are not rendered by default.

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private fun rememberPrimarySwipeAction(
9292
): ChannelAction? {
9393
val resources = LocalResources.current
9494
val handlerState = rememberUpdatedState(handler)
95-
val canMute = ChatTheme.channelOptionsTheme.optionVisibility.isMuteChannelVisible &&
95+
val canMute = ChatTheme.config.channelList.optionsVisibility.isMuteChannelVisible &&
9696
channel.ownCapabilities.contains(ChannelCapabilities.MUTE_CHANNEL)
9797

9898
return remember(channel.cid, isMuted, canMute) {

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public fun buildDefaultChannelActions(
114114
viewModel: ChannelListViewModel,
115115
onViewInfoAction: (Channel) -> Unit,
116116
): List<ChannelAction> {
117-
val optionVisibility = ChatTheme.channelOptionsTheme.optionVisibility
117+
val optionVisibility = ChatTheme.config.channelList.optionsVisibility
118118
val currentUser by viewModel.user.collectAsState()
119119
val channelName = ChatTheme.channelNameFormatter.formatChannelName(
120120
selectedChannel,
@@ -154,7 +154,7 @@ private fun buildDmChannelActions(
154154
selectedChannel: Channel,
155155
currentUser: User?,
156156
ownCapabilities: Set<String>,
157-
optionVisibility: ChannelOptionItemVisibility,
157+
optionVisibility: ChannelOptionsVisibility,
158158
channelName: String,
159159
viewModel: ChannelListViewModel,
160160
onViewInfoAction: (Channel) -> Unit,
@@ -298,7 +298,7 @@ private fun buildDmDeleteAction(
298298
private fun buildGroupChannelActions(
299299
selectedChannel: Channel,
300300
ownCapabilities: Set<String>,
301-
optionVisibility: ChannelOptionItemVisibility,
301+
optionVisibility: ChannelOptionsVisibility,
302302
channelName: String,
303303
viewModel: ChannelListViewModel,
304304
onViewInfoAction: (Channel) -> Unit,

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility.kt renamed to stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionsVisibility.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ package io.getstream.chat.android.compose.ui.components.channels
2929
*
3030
* @see [ChannelOptions]
3131
*/
32-
public data class ChannelOptionItemVisibility(
32+
public data class ChannelOptionsVisibility(
3333
val isViewInfoVisible: Boolean = true,
3434
val isLeaveChannelVisible: Boolean = true,
3535
val isMuteChannelVisible: Boolean = true,

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChannelOptionsTheme.kt

Lines changed: 0 additions & 42 deletions
This file was deleted.

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatTheme.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ private val LocalSearchResultNameFormatter = compositionLocalOf<SearchResultName
108108
private val LocalMessageAlignmentProvider = compositionLocalOf<MessageAlignmentProvider> {
109109
error("No MessageAlignmentProvider provided! Make sure to wrap all usages of Stream components in a ChatTheme.")
110110
}
111-
private val LocalChannelOptionsTheme = compositionLocalOf<ChannelOptionsTheme> {
112-
error("No ChannelOptionsTheme provided! Make sure to wrap all usages of Stream components in a ChatTheme.")
113-
}
114111

115112
private val LocalStreamCdnImageResizing = compositionLocalOf<StreamCdnImageResizing> {
116113
error(
@@ -142,7 +139,6 @@ private val LocalStreamMediaRecorder = compositionLocalOf<StreamMediaRecorder> {
142139
* @param searchResultNameFormatter [SearchResultNameFormatter] Used to format names in search results.
143140
* @param imageLoaderFactory A factory that creates new Coil [ImageLoader] instances.
144141
* @param messageAlignmentProvider [MessageAlignmentProvider] Used to provide message alignment for the given message.
145-
* @param channelOptionsTheme [ChannelOptionsTheme] Theme for the channel option list in the channel info screen.
146142
* @param streamCdnImageResizing Sets the strategy for resizing images hosted on Stream's CDN. Disabled by default,
147143
* set [StreamCdnImageResizing.imageResizingEnabled] to true if you wish to enable resizing images. Note that resizing
148144
* applies only to images hosted on Stream's CDN which contain the original height (oh) and width (ow) query parameters.
@@ -178,7 +174,6 @@ public fun ChatTheme(
178174
searchResultNameFormatter: SearchResultNameFormatter = SearchResultNameFormatter.defaultFormatter(),
179175
imageLoaderFactory: StreamCoilImageLoaderFactory = StreamCoilImageLoaderFactory.defaultFactory(),
180176
messageAlignmentProvider: MessageAlignmentProvider = MessageAlignmentProvider.defaultMessageAlignmentProvider(),
181-
channelOptionsTheme: ChannelOptionsTheme = ChannelOptionsTheme.defaultTheme(),
182177
streamCdnImageResizing: StreamCdnImageResizing = StreamCdnImageResizing.defaultStreamCdnImageResizing(),
183178
messageTextFormatter: MessageTextFormatter = MessageTextFormatter.defaultFormatter(
184179
autoTranslationEnabled = config.translation.enabled,
@@ -225,7 +220,6 @@ public fun ChatTheme(
225220
LocalSearchResultNameFormatter provides searchResultNameFormatter,
226221
LocalStreamImageLoader provides imageLoader,
227222
LocalMessageAlignmentProvider provides messageAlignmentProvider,
228-
LocalChannelOptionsTheme provides channelOptionsTheme,
229223
LocalStreamCdnImageResizing provides streamCdnImageResizing,
230224
LocalStreamMediaRecorder provides streamMediaRecorder,
231225
) {
@@ -358,14 +352,6 @@ public object ChatTheme {
358352
@ReadOnlyComposable
359353
get() = LocalMessageAlignmentProvider.current
360354

361-
/**
362-
* Retrieves the current [ChannelOptionsTheme] at the call site's position in the hierarchy.
363-
*/
364-
public val channelOptionsTheme: ChannelOptionsTheme
365-
@Composable
366-
@ReadOnlyComposable
367-
get() = LocalChannelOptionsTheme.current
368-
369355
/**
370356
* Retrieves the value of [StreamCdnImageResizing] at the call site's position in the hierarchy.
371357
*/

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatUiConfig.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import io.getstream.chat.android.compose.state.messages.attachments.CommandPicke
2323
import io.getstream.chat.android.compose.state.messages.attachments.FilePickerMode
2424
import io.getstream.chat.android.compose.state.messages.attachments.GalleryPickerMode
2525
import io.getstream.chat.android.compose.state.messages.attachments.PollPickerMode
26+
import io.getstream.chat.android.compose.ui.components.channels.ChannelOptionsVisibility
2627
import io.getstream.chat.android.compose.ui.components.messageoptions.MessageActionsOptionsVisibility
2728
import kotlinx.parcelize.Parcelize
2829

@@ -42,10 +43,12 @@ public enum class MuteIndicatorPosition {
4243
*
4344
* @param muteIndicatorPosition Where the mute icon is placed in the channel list item.
4445
* @param swipeActionsEnabled Whether swipe-to-reveal actions are enabled on channel list items.
46+
* @param optionsVisibility Controls which options are visible in the channel options menu.
4547
*/
4648
public data class ChannelListConfig(
4749
val muteIndicatorPosition: MuteIndicatorPosition = MuteIndicatorPosition.InlineTitle,
4850
val swipeActionsEnabled: Boolean = true,
51+
val optionsVisibility: ChannelOptionsVisibility = ChannelOptionsVisibility(),
4952
)
5053

5154
/**

0 commit comments

Comments
 (0)