Skip to content

Commit 1a54572

Browse files
authored
Add Channel Search documentation to SwiftUI (#3471)
1 parent 55fe259 commit 1a54572

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

docusaurus/docs/iOS/swiftui/channel-list-components/channel-list-search.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,34 @@
22
title: Channel List Search
33
---
44

5-
By default, the channel list component shows a search bar at the top. This component lets you search through messages matching the search term inside the channels. When you tap on a search result, the corresponding channel is opened, automatically scrolling to the searched message.
5+
### Basic Usage
6+
7+
The channel list component shows a search bar at the top that lets you search through messages or channels depending on the `searchType` provided when creating the `ChatChannelListView` component. By default, the search type is set to `.messages`, which means that the search will be performed on messages inside the channels and threads.
8+
9+
If you want to change the search type to `.channels`, you can do so by setting the `searchType` parameter when creating the `ChatChannelListView` component:
10+
11+
```swift
12+
ChatChannelListView(
13+
viewFactory: CustomAppFactory.shared,
14+
searchType: .channels
15+
)
16+
```
17+
18+
:::note
19+
The `searchType` parameter is only available on the SwiftUI SDK since version [4.66.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.66.0).
20+
:::
21+
22+
### Navigation
23+
24+
When a user taps on a search result, the corresponding channel is opened, automatically scrolling to the searched message or channel depending on the `searchType`.
625

726
The SwiftUI components can also scroll to a message that is not available in the local database at that moment. In those cases, the messages around that message are also loaded. The scrolling in these cases can happen in both directions - up (for loading older messages) and down (for loading newer messages).
827

928
You can also search for messages that are part of message threads. In those cases, first the channel is opened, and then the corresponding message thread is shown, scrolling to the searched message.
1029

11-
In order to replace this component with your own (or completely remove it by returning an EmptyView), you need to implement the `makeChannelListTopView` method:
30+
### Search Bar
31+
32+
In order to replace the search bar with your own (or completely remove it by returning an EmptyView), you need to implement the `makeChannelListTopView` method:
1233

1334
```swift
1435
func makeChannelListTopView(
@@ -22,7 +43,7 @@ In this method, a binding of the search text is provided, in case you want to im
2243

2344
### Message Search Controller
2445

25-
Under the hood, the channel list search uses the `MessageSearchController`, that you can also use to provide search in your custom UI components.
46+
Under the hood, the channel list search uses the `MessageSearchController` when the `searchType` is set to `.messages`, so that you can also use it to provide search in your custom UI components.
2647

2748
Here's an example how to search for a particular search text:
2849

0 commit comments

Comments
 (0)