Skip to content

Commit 3e84fe2

Browse files
Configuration for stack based navigation for iPads
1 parent 873fc1a commit 3e84fe2

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6-
### 🔄 Changed
6+
### ✅ Added
7+
- Configuration for stack based navigation for iPads
78

89
# [4.21.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.21.0)
910
_September 02, 2022_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public struct MessageListConfig {
2121
becomesFirstResponderOnOpen: Bool = false,
2222
updateChannelsFromMessageList: Bool = false,
2323
maxTimeIntervalBetweenMessagesInGroup: TimeInterval = 60,
24-
cacheSizeOnChatDismiss: Int = 1024 * 1024 * 100
24+
cacheSizeOnChatDismiss: Int = 1024 * 1024 * 100,
25+
iPadSplitViewEnabled: Bool = true
2526
) {
2627
self.messageListType = messageListType
2728
self.typingIndicatorPlacement = typingIndicatorPlacement
@@ -36,6 +37,7 @@ public struct MessageListConfig {
3637
self.updateChannelsFromMessageList = updateChannelsFromMessageList
3738
self.maxTimeIntervalBetweenMessagesInGroup = maxTimeIntervalBetweenMessagesInGroup
3839
self.cacheSizeOnChatDismiss = cacheSizeOnChatDismiss
40+
self.iPadSplitViewEnabled = iPadSplitViewEnabled
3941
}
4042

4143
public let messageListType: MessageListType
@@ -51,6 +53,7 @@ public struct MessageListConfig {
5153
public let updateChannelsFromMessageList: Bool
5254
public let maxTimeIntervalBetweenMessagesInGroup: TimeInterval
5355
public let cacheSizeOnChatDismiss: Int
56+
public let iPadSplitViewEnabled: Bool
5457
}
5558

5659
/// Contains information about the message paddings.

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SwiftUI
99
public struct ChatChannelListView<Factory: ViewFactory>: View {
1010
@Injected(\.fonts) private var fonts
1111
@Injected(\.colors) private var colors
12+
@Injected(\.utils) private var utils
1213

1314
@StateObject private var viewModel: ChatChannelListViewModel
1415
@State private var tabBar: UITabBar?
@@ -90,7 +91,7 @@ public struct ChatChannelListView<Factory: ViewFactory>: View {
9091
}
9192
.overlay(viewModel.customAlertShown ? customViewOverlay() : nil)
9293
.accentColor(colors.tintColor)
93-
.if(isIphone, transform: { view in
94+
.if(isIphone || !utils.messageListConfig.iPadSplitViewEnabled, transform: { view in
9495
view.navigationViewStyle(.stack)
9596
})
9697
.background(

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ open class ChatChannelListViewModel: ObservableObject, ChatChannelListController
360360
}
361361

362362
private func setInitialChannelIfSplitView() {
363-
if isIPad && selectedChannel == nil {
363+
if isIPad && selectedChannel == nil && utils.messageListConfig.iPadSplitViewEnabled {
364364
selectedChannel = channels.first?.channelSelectionInfo
365365
}
366366
}

0 commit comments

Comments
 (0)