Skip to content

Commit baae8e0

Browse files
Open ChannelInfoViewModel control properties (#1018)
1 parent a5ae622 commit baae8e0

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoHelperViews.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ public struct ChatInfoOptionsView<Factory: ViewFactory>: View {
7676

7777
Divider()
7878

79-
ChannelInfoItemView(
80-
icon: images.muted,
81-
title: viewModel.mutedText,
82-
verticalPadding: 12
83-
) {
84-
Toggle(isOn: $viewModel.muted) {
85-
EmptyView()
79+
if viewModel.shouldShowMuteChannelButton {
80+
ChannelInfoItemView(
81+
icon: images.muted,
82+
title: viewModel.mutedText,
83+
verticalPadding: 12
84+
) {
85+
Toggle(isOn: $viewModel.muted) {
86+
EmptyView()
87+
}
8688
}
8789
}
8890

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ open class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDele
4343
channel.ownCapabilities.contains(.leaveChannel)
4444
}
4545
}
46+
47+
open var shouldShowMuteChannelButton: Bool {
48+
channel.ownCapabilities.contains(.muteChannel)
49+
}
4650

4751
open var canRenameChannel: Bool {
4852
channel.ownCapabilities.contains(.updateChannel)
@@ -87,15 +91,15 @@ open class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDele
8791
}
8892
}
8993

90-
public var leaveButtonTitle: String {
94+
open var leaveButtonTitle: String {
9195
if channel.isDirectMessageChannel {
9296
L10n.Alert.Actions.deleteChannelTitle
9397
} else {
9498
L10n.Alert.Actions.leaveGroupTitle
9599
}
96100
}
97101

98-
public var leaveConversationDescription: String {
102+
open var leaveConversationDescription: String {
99103
if channel.isDirectMessageChannel {
100104
L10n.Alert.Actions.deleteChannelMessage
101105
} else {

0 commit comments

Comments
 (0)