From 9854b6472773bec4e33de2fe9e0872ee71b7ba6d Mon Sep 17 00:00:00 2001 From: Martin Mitrevski Date: Mon, 10 Feb 2025 16:44:34 +0100 Subject: [PATCH] Fixed visibility of tabbar when reactions are shown (#750) --- CHANGELOG.md | 3 ++- .../ChatChannel/ChatChannelView.swift | 4 ++-- .../StreamChatSwiftUI/Utils/Modifiers.swift | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28cbca54..b13b2349 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). # Upcoming -### 🔄 Changed +### 🐞 Fixed +- Fix visibility of tabbar when reactions are shown [#750](https://github.com/GetStream/stream-chat-swiftui/pull/750) # [4.72.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.72.0) _February 04, 2025_ diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift index a847fa10..d8a858fd 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift @@ -89,10 +89,10 @@ public struct ChatChannelView: View, KeyboardReadable { Divider() .navigationBarBackButtonHidden(viewModel.reactionsShown) .if(viewModel.reactionsShown, transform: { view in - view.navigationBarHidden(true) + view.changeBarsVisibility(shouldShow: false) }) .if(!viewModel.reactionsShown, transform: { view in - view.navigationBarHidden(false) + view.changeBarsVisibility(shouldShow: true) }) .if(viewModel.channelHeaderType == .regular) { view in view.modifier(factory.makeChannelHeaderViewModifier(for: channel)) diff --git a/Sources/StreamChatSwiftUI/Utils/Modifiers.swift b/Sources/StreamChatSwiftUI/Utils/Modifiers.swift index 9796bfe9..5765d767 100644 --- a/Sources/StreamChatSwiftUI/Utils/Modifiers.swift +++ b/Sources/StreamChatSwiftUI/Utils/Modifiers.swift @@ -79,6 +79,24 @@ struct IconOverImageModifier: ViewModifier { } } +struct ChangeBarsVisibilityModifier: ViewModifier { + + @Injected(\.utils) private var utils + + var shouldShow: Bool + + func body(content: Content) -> some View { + if #available(iOS 16, *), !utils.messageListConfig.handleTabBarVisibility { + content + .navigationBarHidden(!shouldShow) + .toolbar(shouldShow ? .visible : .hidden, for: .tabBar) + } else { + content + .navigationBarHidden(!shouldShow) + } + } +} + extension View { /// View extension that applies default padding to elements. public func standardPadding() -> some View { @@ -92,6 +110,10 @@ extension View { public func applyDefaultIconOverlayStyle() -> some View { modifier(IconOverImageModifier()) } + + public func changeBarsVisibility(shouldShow: Bool) -> some View { + modifier(ChangeBarsVisibilityModifier(shouldShow: shouldShow)) + } } extension Image {