Skip to content

Commit 768725b

Browse files
Added support for controlling tabbar visibility
1 parent 9ffda58 commit 768725b

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
### ✅ Added
77
- Customizing padding for message bubble modifier
88
- Customizing padding for message text view
9+
- Possibility to control tab bar visibility
910

1011
### 🐞 Fixed
1112
- Fixed a bug with canceled backswipe

DemoAppSwiftUI/CustomChannelHeader.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public struct CustomChannelHeader: ToolbarContent {
2626
ToolbarItem(placement: .navigationBarTrailing) {
2727
Button {
2828
isNewChatShown = true
29+
notifyHideTabBar()
2930
} label: {
3031
Image(uiImage: images.messageActionEdit)
3132
.resizable()

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListViewModel.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
136136
}
137137
setupChannelListController()
138138
observeChannelDismiss()
139+
observeHideTabBar()
139140
}
140141

141142
/// Returns the name for the specified channel.
@@ -427,17 +428,36 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
427428
)
428429
}
429430

431+
private func observeHideTabBar() {
432+
NotificationCenter.default.addObserver(
433+
self,
434+
selector: #selector(handleHideTabBar),
435+
name: NSNotification.Name(hideTabBarNotification),
436+
object: nil
437+
)
438+
}
439+
430440
@objc private func dismissPresentedChannel() {
431441
selectedChannel = nil
432442
}
443+
444+
@objc private func handleHideTabBar() {
445+
hideTabBar = true
446+
}
433447
}
434448

435449
private let dismissChannel = "io.getstream.dismissChannel"
436450

451+
private let hideTabBarNotification = "io.getstream.hideTabBar"
452+
437453
func notifyChannelDismiss() {
438454
NotificationCenter.default.post(name: NSNotification.Name(dismissChannel), object: nil)
439455
}
440456

457+
public func notifyHideTabBar() {
458+
NotificationCenter.default.post(name: NSNotification.Name(hideTabBarNotification), object: nil)
459+
}
460+
441461
/// Enum for the type of alert presented in the channel list view.
442462
public enum ChannelAlertType {
443463
case deleteChannel(ChatChannel)

StreamChatSwiftUITests/Tests/ChatChannelList/ChatChannelListViewModel_Tests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ class ChatChannelListViewModel_Tests: StreamChatTestCase {
260260
XCTAssert(viewModel.selectedChannel == nil)
261261
}
262262

263+
func test_channelListVM_hideTabBar() {
264+
// Given
265+
let viewModel = makeDefaultChannelListVM()
266+
267+
// When
268+
notifyHideTabBar()
269+
270+
// Then
271+
XCTAssert(viewModel.hideTabBar == true)
272+
}
273+
263274
// MARK: - private
264275

265276
private func makeChannelListController(

0 commit comments

Comments
 (0)