Skip to content

Commit 25775f3

Browse files
authored
Merge pull request #774 from sheep-q/chat/change_bar_visibility
Move `ChangeBarsVisibilityModifier ` into `ViewFactory` for better customization
2 parents ac7fd36 + 03a8a7d commit 25775f3

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010
### 🔄 Changed
1111
- Uploading a HEIC photo from the library is now converted to JPEG for better compatibility [#767](https://github.com/GetStream/stream-chat-swiftui/pull/767)
1212
- Customizing the message avatar view is reflected in all views that use it [#772](https://github.com/GetStream/stream-chat-swiftui/pull/772)
13+
- Move `ChangeBarsVisibilityModifier` into `ViewFactory` for better customization [#774](https://github.com/GetStream/stream-chat-swiftui/pull/774)
1314

1415
# [4.73.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.73.0)
1516
_February 28, 2025_

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
9494
Divider()
9595
.navigationBarBackButtonHidden(viewModel.reactionsShown)
9696
.if(viewModel.reactionsShown, transform: { view in
97-
view.changeBarsVisibility(shouldShow: false)
97+
view.modifier(factory.makeChannelBarsVisibilityViewModifier(shouldShow: false))
9898
})
9999
.if(!viewModel.reactionsShown, transform: { view in
100-
view.changeBarsVisibility(shouldShow: true)
100+
view.modifier(factory.makeChannelBarsVisibilityViewModifier(shouldShow: true))
101101
})
102102
.if(viewModel.channelHeaderType == .regular) { view in
103103
view.modifier(factory.makeChannelHeaderViewModifier(for: channel))

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ extension ViewFactory {
301301
DefaultChannelHeaderModifier(factory: self, channel: channel)
302302
}
303303

304+
public func makeChannelBarsVisibilityViewModifier(shouldShow: Bool) -> some ViewModifier {
305+
ChangeChannelBarsVisibilityModifier(shouldShow: shouldShow)
306+
}
307+
304308
public func makeChannelLoadingView() -> some View {
305309
LoadingView()
306310
}

Sources/StreamChatSwiftUI/Utils/Modifiers.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct IconOverImageModifier: ViewModifier {
7979
}
8080
}
8181

82-
struct ChangeBarsVisibilityModifier: ViewModifier {
82+
struct ChangeChannelBarsVisibilityModifier: ViewModifier {
8383

8484
@Injected(\.utils) private var utils
8585

@@ -110,10 +110,6 @@ extension View {
110110
public func applyDefaultIconOverlayStyle() -> some View {
111111
modifier(IconOverImageModifier())
112112
}
113-
114-
public func changeBarsVisibility(shouldShow: Bool) -> some View {
115-
modifier(ChangeBarsVisibilityModifier(shouldShow: shouldShow))
116-
}
117113
}
118114

119115
extension Image {

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ public protocol ViewFactory: AnyObject {
282282
/// - Parameter channel: the displayed channel.
283283
func makeChannelHeaderViewModifier(for channel: ChatChannel) -> ChatHeaderViewModifier
284284

285+
associatedtype ChangeBarsVisibilityModifier: ViewModifier
286+
/// Creates a view modifier that changes the visibility of bars.
287+
/// - Parameter shouldShow: A Boolean value indicating whether the bars should be shown.
288+
/// - Returns: A view modifier that changes the visibility of bars.
289+
func makeChannelBarsVisibilityViewModifier(shouldShow: Bool) -> ChangeBarsVisibilityModifier
290+
285291
associatedtype ChannelLoadingViewType: View
286292
/// Creates a loading view for the channel.
287293
func makeChannelLoadingView() -> ChannelLoadingViewType

0 commit comments

Comments
 (0)