Skip to content

Commit d8a2388

Browse files
exposed configuration for mentions and giphy symbol
1 parent 6295145 commit d8a2388

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/CommandsConfig.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import StreamChat
88
/// Configuration for the commands in the composer.
99
public protocol CommandsConfig {
1010

11+
/// The symbol that invokes mentions command.
12+
var mentionsSymbol: String { get }
13+
14+
/// The symbol that invokes giphy command.
15+
var giphySymbol: String { get }
16+
1117
/// Creates the main commands handler.
1218
/// - Parameter channelController: the controller of the channel.
1319
/// - Returns: `CommandsHandler`.
@@ -17,16 +23,19 @@ public protocol CommandsConfig {
1723
}
1824

1925
/// Default commands configuration.
20-
public struct DefaultCommandsConfig: CommandsConfig {
26+
public class DefaultCommandsConfig: CommandsConfig {
2127

2228
public init() {}
2329

30+
public let mentionsSymbol: String = "@"
31+
public let giphySymbol: String = "/"
32+
2433
public func makeCommandsHandler(
2534
with channelController: ChatChannelController
2635
) -> CommandsHandler {
2736
let mentionsCommand = MentionsCommandHandler(
2837
channelController: channelController,
29-
commandSymbol: "@",
38+
commandSymbol: mentionsSymbol,
3039
mentionAllAppUsers: false
3140
)
3241
return CommandsHandler(commands: [mentionsCommand])

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/MentionUsersView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public struct MentionUsersView: View {
4747
public struct MentionUserView: View {
4848
@Injected(\.fonts) private var fonts
4949
@Injected(\.colors) private var colors
50+
@Injected(\.utils) private var utils
5051

5152
var user: ChatUser
5253
var userSelected: (ChatUser) -> Void
@@ -61,7 +62,7 @@ public struct MentionUserView: View {
6162
.lineLimit(1)
6263
.font(fonts.bodyBold)
6364
Spacer()
64-
Text("@")
65+
Text(utils.commandsConfig.mentionsSymbol)
6566
.font(fonts.title)
6667
.foregroundColor(colors.tintColor)
6768
}

0 commit comments

Comments
 (0)