Skip to content

Commit cc45812

Browse files
TabView support updates for iPad screens
1 parent f22c5b8 commit cc45812

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
106106
viewModel.onViewDissappear()
107107
}
108108
.background(
109-
Color.clear.background(
110-
TabBarAccessor { _ in
111-
self.tabBarAvailable = true
112-
}
113-
)
114-
.allowsHitTesting(false)
109+
isIphone ?
110+
Color.clear.background(
111+
TabBarAccessor { _ in
112+
self.tabBarAvailable = true
113+
}
114+
)
115+
.allowsHitTesting(false)
116+
: nil
115117
)
116118
.padding(.bottom, keyboardShown || !tabBarAvailable ? 0 : bottomPadding)
117119
.ignoresSafeArea(.container, edges: tabBarAvailable ? .bottom : [])

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelHelperViews.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ struct TabBarAccessor: UIViewControllerRepresentable {
104104
}
105105
}
106106
}
107+
108+
var isIphone: Bool {
109+
UIDevice.current.userInterfaceIdiom == .phone
110+
}

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListView.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,23 @@ public struct ChatChannelListView<Factory: ViewFactory>: View {
126126
view.navigationViewStyle(.stack)
127127
})
128128
.background(
129-
Color.clear.background(
130-
TabBarAccessor { tabBar in
131-
self.tabBar = tabBar
132-
}
133-
)
134-
.allowsHitTesting(false)
129+
isIphone ?
130+
Color.clear.background(
131+
TabBarAccessor { tabBar in
132+
self.tabBar = tabBar
133+
}
134+
)
135+
.allowsHitTesting(false)
136+
: nil
135137
)
136138
.onReceive(viewModel.$hideTabBar) { newValue in
137-
self.setupTabBarAppeareance()
138-
self.tabBar?.isHidden = newValue
139+
if isIphone {
140+
self.setupTabBarAppeareance()
141+
self.tabBar?.isHidden = newValue
142+
}
139143
}
140144
}
141145

142-
private var isIphone: Bool {
143-
UIDevice.current.userInterfaceIdiom == .phone
144-
}
145-
146146
private func setupTabBarAppeareance() {
147147
if #available(iOS 15.0, *) {
148148
let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()

0 commit comments

Comments
 (0)