-
Notifications
You must be signed in to change notification settings - Fork 305
Message members from the member bottom sheet of channel info screen #5797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andremion
merged 12 commits into
develop
from
AND-567-message-members-from-the-member-modal-sheet-of-channel-info-screen
Jun 17, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
85e0871
Fix loading transition
andremion 8a1ab9e
Clarify that adaptive layout is experimental
andremion 3ccae13
Navigate to distinct channel
andremion 13c1101
Navigate to new channel
andremion 0128702
Refactor: Convert `ChannelInfoMemberViewController.state` to use `sta…
andremion 667a70b
Refactor: Use full `cid` instead of `channelId` for channel navigation
andremion ac805ef
Test MessageMember event
andremion 38e53c2
Update queryChannels call in `ChannelInfoMemberViewControllerTest`
andremion fdacd5c
Refactor: Convert `ChannelInfoMemberViewController.state` to use `sta…
andremion ddbde8f
Refactor: Navigate to draft channel instead of creating a new direct …
andremion 1024faa
apiDump
andremion 0183722
CHANGELOG
andremion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...va/io/getstream/chat/android/compose/sample/feature/channel/draft/DraftChannelActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.sample.feature.channel.draft | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.widget.Toast | ||
| import androidx.activity.compose.setContent | ||
| import androidx.activity.viewModels | ||
| import androidx.compose.foundation.layout.systemBarsPadding | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.ui.Modifier | ||
| import io.getstream.chat.android.compose.sample.R | ||
| import io.getstream.chat.android.compose.sample.ui.BaseConnectedActivity | ||
| import io.getstream.chat.android.compose.sample.ui.MessagesActivity | ||
| import io.getstream.chat.android.compose.ui.theme.ChatTheme | ||
| import io.getstream.chat.android.ui.common.feature.channel.draft.DraftChannelViewEvent | ||
| import kotlinx.coroutines.flow.collectLatest | ||
|
|
||
| class DraftChannelActivity : BaseConnectedActivity() { | ||
|
|
||
| companion object { | ||
| private const val KEY_MEMBER_IDS = "memberIds" | ||
|
|
||
| /** | ||
| * Creates an [Intent] for starting the [DraftChannelActivity]. | ||
| * | ||
| * @param context The calling [Context], used for building the [Intent]. | ||
| * @param memberIds The list of member IDs to be used for creating the channel. | ||
| */ | ||
| fun createIntent(context: Context, memberIds: List<String>) = | ||
| Intent(context, DraftChannelActivity::class.java) | ||
| .putExtra(KEY_MEMBER_IDS, memberIds.toTypedArray()) | ||
| } | ||
|
|
||
| private val viewModelFactory by lazy { | ||
| DraftChannelViewModelFactory( | ||
| memberIds = requireNotNull(intent.getStringArrayExtra(KEY_MEMBER_IDS)).toList(), | ||
andremion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
| private val viewModel by viewModels<DraftChannelViewModel> { viewModelFactory } | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContent { | ||
| ChatTheme { | ||
| DraftChannelScreen( | ||
| modifier = Modifier.systemBarsPadding(), | ||
| viewModel = viewModel, | ||
| onNavigationIconClick = ::finish, | ||
| ) | ||
| LaunchedEffect(viewModel) { | ||
| viewModel.events.collectLatest { event -> | ||
| when (event) { | ||
| is DraftChannelViewEvent.NavigateToChannel -> { | ||
| startActivity( | ||
| MessagesActivity.createIntent( | ||
| context = applicationContext, | ||
| channelId = event.cid, | ||
| ), | ||
| ) | ||
| finish() | ||
| } | ||
|
|
||
| is DraftChannelViewEvent.DraftChannelError -> | ||
| Toast.makeText( | ||
| applicationContext, | ||
| R.string.draft_channel_error, | ||
| Toast.LENGTH_SHORT, | ||
| ).show() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
130 changes: 130 additions & 0 deletions
130
...java/io/getstream/chat/android/compose/sample/feature/channel/draft/DraftChannelScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.sample.feature.channel.draft | ||
|
|
||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import androidx.lifecycle.viewmodel.compose.viewModel | ||
| import io.getstream.chat.android.compose.ui.components.LoadingIndicator | ||
| import io.getstream.chat.android.compose.ui.messages.composer.MessageComposer | ||
| import io.getstream.chat.android.compose.ui.messages.header.MessageListHeader | ||
| import io.getstream.chat.android.compose.ui.theme.ChatTheme | ||
| import io.getstream.chat.android.compose.viewmodel.channel.ChannelHeaderViewModel | ||
| import io.getstream.chat.android.compose.viewmodel.channel.ChannelHeaderViewModelFactory | ||
| import io.getstream.chat.android.compose.viewmodel.messages.MessageComposerViewModel | ||
| import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory | ||
| import io.getstream.chat.android.ui.common.feature.channel.draft.DraftChannelViewAction | ||
| import io.getstream.chat.android.ui.common.state.channel.draft.DraftChannelViewState | ||
| import io.getstream.chat.android.ui.common.state.messages.list.ChannelHeaderViewState | ||
|
|
||
| @Composable | ||
| fun DraftChannelScreen( | ||
| viewModel: DraftChannelViewModel, | ||
| onNavigationIconClick: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| val state by viewModel.state.collectAsStateWithLifecycle() | ||
|
|
||
| DraftChannelContent( | ||
| modifier = modifier, | ||
| state = state, | ||
| onNavigationIconClick = onNavigationIconClick, | ||
| onViewAction = viewModel::onViewAction, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| private fun DraftChannelContent( | ||
| state: DraftChannelViewState, | ||
| onNavigationIconClick: () -> Unit, | ||
| onViewAction: (action: DraftChannelViewAction) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| when (state) { | ||
| is DraftChannelViewState.Loading -> LoadingIndicator( | ||
| modifier = modifier.fillMaxSize(), | ||
| ) | ||
|
|
||
| is DraftChannelViewState.Content -> Scaffold( | ||
| modifier = modifier, | ||
| topBar = { | ||
| DraftChannelTopBar( | ||
| cid = state.channel.cid, | ||
| onNavigationIconClick = onNavigationIconClick, | ||
| ) | ||
| }, | ||
| bottomBar = { | ||
| DraftChannelBottomBar( | ||
| cid = state.channel.cid, | ||
| onMessageSent = { onViewAction(DraftChannelViewAction.MessageSent) }, | ||
| ) | ||
| }, | ||
| containerColor = ChatTheme.colors.appBackground, | ||
| ) { padding -> | ||
| ChatTheme.componentFactory.MessageListEmptyContent( | ||
| modifier = Modifier | ||
| .padding(padding) | ||
| .fillMaxSize(), | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun DraftChannelTopBar( | ||
| cid: String, | ||
| onNavigationIconClick: () -> Unit, | ||
| ) { | ||
| val viewModel = viewModel<ChannelHeaderViewModel>(factory = ChannelHeaderViewModelFactory(cid)) | ||
| val state by viewModel.state.collectAsStateWithLifecycle() | ||
|
|
||
| when (val content = state) { | ||
| is ChannelHeaderViewState.Loading -> LoadingIndicator( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| ) | ||
|
|
||
| is ChannelHeaderViewState.Content -> MessageListHeader( | ||
| channel = content.channel, | ||
| currentUser = content.currentUser, | ||
| connectionState = content.connectionState, | ||
| onBackPressed = onNavigationIconClick, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun DraftChannelBottomBar( | ||
| cid: String, | ||
| onMessageSent: () -> Unit, | ||
| ) { | ||
| val context = LocalContext.current | ||
| val viewModel = viewModel<MessageComposerViewModel>(key = cid, factory = MessagesViewModelFactory(context, cid)) | ||
| MessageComposer( | ||
| viewModel = viewModel, | ||
| onSendMessage = { message -> | ||
| viewModel.sendMessage(message) | ||
| onMessageSent() | ||
| }, | ||
| ) | ||
| } |
59 changes: 59 additions & 0 deletions
59
...a/io/getstream/chat/android/compose/sample/feature/channel/draft/DraftChannelViewModel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| @file:OptIn(InternalStreamChatApi::class) | ||
|
|
||
| package io.getstream.chat.android.compose.sample.feature.channel.draft | ||
|
|
||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import io.getstream.chat.android.core.internal.InternalStreamChatApi | ||
| import io.getstream.chat.android.ui.common.feature.channel.draft.DraftChannelViewAction | ||
| import io.getstream.chat.android.ui.common.feature.channel.draft.DraftChannelViewController | ||
| import io.getstream.chat.android.ui.common.feature.channel.draft.DraftChannelViewEvent | ||
| import io.getstream.chat.android.ui.common.state.channel.draft.DraftChannelViewState | ||
| import kotlinx.coroutines.flow.SharedFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
|
|
||
| class DraftChannelViewModel( | ||
| private val memberIds: List<String>, | ||
| controllerProvider: ViewModel.() -> DraftChannelViewController = { | ||
| DraftChannelViewController( | ||
| memberIds = memberIds, | ||
| scope = viewModelScope, | ||
| ) | ||
| }, | ||
| ) : ViewModel() { | ||
|
|
||
| private val controller: DraftChannelViewController by lazy { controllerProvider() } | ||
|
|
||
| /** | ||
| * @see [DraftChannelViewController.state] | ||
| */ | ||
| val state: StateFlow<DraftChannelViewState> = controller.state | ||
|
|
||
| /** | ||
| * @see [DraftChannelViewController.events] | ||
| */ | ||
| val events: SharedFlow<DraftChannelViewEvent> = controller.events | ||
|
|
||
| /** | ||
| * @see [DraftChannelViewController.onViewAction] | ||
| */ | ||
| fun onViewAction(action: DraftChannelViewAction) { | ||
| controller.onViewAction(action) | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
...tstream/chat/android/compose/sample/feature/channel/draft/DraftChannelViewModelFactory.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
| * | ||
| * Licensed under the Stream License; | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.chat.android.compose.sample.feature.channel.draft | ||
|
|
||
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.ViewModelProvider | ||
| import io.getstream.chat.android.core.internal.InternalStreamChatApi | ||
|
|
||
| class DraftChannelViewModelFactory(private val memberIds: List<String>) : ViewModelProvider.Factory { | ||
| @OptIn(InternalStreamChatApi::class) | ||
| override fun <T : ViewModel> create(modelClass: Class<T>): T { | ||
| require(modelClass == DraftChannelViewModel::class.java) { | ||
| "DraftChannelViewModelFactory can only create instances of DraftChannelViewModel" | ||
| } | ||
| @Suppress("UNCHECKED_CAST") | ||
| return DraftChannelViewModel(memberIds) as T | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.