Skip to content

Commit b95c4ad

Browse files
Fix buttons in navigation bar on iOS 26 (#912)
1 parent 5104f3a commit b95c4ad

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public struct CustomChannelHeader: ToolbarContent {
3030
Image(uiImage: images.messageActionEdit)
3131
.resizable()
3232
.scaledToFit()
33+
.frame(width: 24, height: 24)
3334
.foregroundColor(Color.white)
3435
.padding(.all, 8)
3536
.background(colors.tintColor)
@@ -41,9 +42,12 @@ public struct CustomChannelHeader: ToolbarContent {
4142
Button {
4243
actionsPopupShown = true
4344
} label: {
44-
StreamLazyImage(url: currentUserController.currentUser?.imageURL)
45-
.accessibilityLabel("Account Actions")
46-
.accessibilityAddTraits(.isButton)
45+
StreamLazyImage(
46+
url: currentUserController.currentUser?.imageURL,
47+
size: CGSize(width: 36, height: 36)
48+
)
49+
.accessibilityLabel("Account Actions")
50+
.accessibilityAddTraits(.isButton)
4751
}
4852
}
4953
}
@@ -62,13 +66,27 @@ struct CustomChannelModifier: ChannelListHeaderViewModifier {
6266

6367
func body(content: Content) -> some View {
6468
ZStack {
65-
content.toolbar {
66-
CustomChannelHeader(
67-
title: title,
68-
currentUserController: chatClient.currentUserController(),
69-
isNewChatShown: $isNewChatShown,
70-
actionsPopupShown: $actionsPopupShown
71-
)
69+
if #available(iOS 26, *) {
70+
content.toolbar {
71+
CustomChannelHeader(
72+
title: title,
73+
currentUserController: chatClient.currentUserController(),
74+
isNewChatShown: $isNewChatShown,
75+
actionsPopupShown: $actionsPopupShown
76+
)
77+
#if compiler(>=6.2)
78+
.sharedBackgroundVisibility(.hidden)
79+
#endif
80+
}
81+
} else {
82+
content.toolbar {
83+
CustomChannelHeader(
84+
title: title,
85+
currentUserController: chatClient.currentUserController(),
86+
isNewChatShown: $isNewChatShown,
87+
actionsPopupShown: $actionsPopupShown
88+
)
89+
}
7290
}
7391

7492
NavigationLink(isActive: $blockedUsersShown) {

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,27 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
108108
}
109109

110110
public func body(content: Content) -> some View {
111-
content.toolbar {
112-
DefaultChatChannelHeader(
113-
factory: factory,
114-
channel: channel,
115-
headerImage: channelHeaderLoader.image(for: channel),
116-
isActive: $isActive
117-
)
111+
if #available(iOS 26, *) {
112+
content.toolbar {
113+
DefaultChatChannelHeader(
114+
factory: factory,
115+
channel: channel,
116+
headerImage: channelHeaderLoader.image(for: channel),
117+
isActive: $isActive
118+
)
119+
#if compiler(>=6.2)
120+
.sharedBackgroundVisibility(.hidden)
121+
#endif
122+
}
123+
} else {
124+
content.toolbar {
125+
DefaultChatChannelHeader(
126+
factory: factory,
127+
channel: channel,
128+
headerImage: channelHeaderLoader.image(for: channel),
129+
isActive: $isActive
130+
)
131+
}
118132
}
119133
}
120134
}

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ public struct ChatChannelView<Factory: ViewFactory>: View, KeyboardReadable {
209209
}
210210

211211
private var generatingSnapshot: Bool {
212-
tabBarAvailable && messageDisplayInfo != nil && !viewModel.reactionsShown
212+
if #available(iOS 26, *) {
213+
return false
214+
} else {
215+
return tabBarAvailable && messageDisplayInfo != nil && !viewModel.reactionsShown
216+
}
213217
}
214218

215219
private var bottomPadding: CGFloat {

0 commit comments

Comments
 (0)