Skip to content

Commit 73f14e6

Browse files
authored
Expose ChannelsScreen isBackPressEnabled config flag. (#6228)
1 parent 167b04d commit 73f14e6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ public final class io/getstream/chat/android/compose/ui/channel/info/GroupChanne
11921192
}
11931193

11941194
public final class io/getstream/chat/android/compose/ui/channels/ChannelsScreenKt {
1195-
public static final fun ChannelsScreen (Lio/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory;Ljava/lang/String;Ljava/lang/String;ZLio/getstream/chat/android/compose/ui/channels/SearchMode;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;III)V
1195+
public static final fun ChannelsScreen (Lio/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory;Ljava/lang/String;Ljava/lang/String;ZLio/getstream/chat/android/compose/ui/channels/SearchMode;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;ZLandroidx/compose/runtime/Composer;III)V
11961196
}
11971197

11981198
public final class io/getstream/chat/android/compose/ui/channels/SearchMode : java/lang/Enum {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ import io.getstream.chat.android.ui.common.state.channels.actions.ViewInfo
7979
* @param onChannelClick Handler for Channel item clicks.
8080
* @param onViewChannelInfoAction Handler for when the user selects the [ViewInfo] option for a [Channel].
8181
* @param onBackPressed Handler for back press action.
82+
* @param isBackPressEnabled Indicator if the default back handler is enabled. Set to `false` to fully disable the back
83+
* handling and catch the back-press event in a [BackHandler] higher in the compose hierarchy. Default: `true`.
8284
*/
8385
@Composable
8486
@Suppress("LongMethod")
@@ -94,6 +96,7 @@ public fun ChannelsScreen(
9496
onSearchMessageItemClick: (Message) -> Unit = {},
9597
onViewChannelInfoAction: (Channel) -> Unit = {},
9698
onBackPressed: () -> Unit = {},
99+
isBackPressEnabled: Boolean = true,
97100
) {
98101
val listViewModel: ChannelListViewModel = viewModel(
99102
ChannelListViewModel::class.java,
@@ -105,7 +108,7 @@ public fun ChannelsScreen(
105108
val user by listViewModel.user.collectAsState()
106109
val connectionState by listViewModel.connectionState.collectAsState()
107110

108-
BackHandler(enabled = true) {
111+
BackHandler(enabled = isBackPressEnabled) {
109112
if (selectedChannel != null) {
110113
listViewModel.selectChannel(null)
111114
} else {

0 commit comments

Comments
 (0)