Skip to content

Commit 566e93d

Browse files
Fixed keyboard insets issue on iOS 16
1 parent 5b5c839 commit 566e93d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
- Customization of the reactions background
99
- Possibility to add custom snapshot generation logic
1010

11+
### 🐞 Fixed
12+
- iOS 16 keyboard insets issue on pushed screen
13+
1114
# [4.21.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.21.0)
1215
_September 02, 2022_
1316

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ public struct DefaultChatChannelHeader: ToolbarContent {
3636

3737
public var channel: ChatChannel
3838
public var headerImage: UIImage
39+
@Binding public var isActive: Bool
3940

40-
public init(channel: ChatChannel, headerImage: UIImage) {
41+
public init(
42+
channel: ChatChannel,
43+
headerImage: UIImage,
44+
isActive: Binding<Bool>
45+
) {
4146
self.channel = channel
4247
self.headerImage = headerImage
48+
_isActive = isActive
4349
}
4450

4551
public var body: some ToolbarContent {
@@ -54,14 +60,23 @@ public struct DefaultChatChannelHeader: ToolbarContent {
5460

5561
ToolbarItem(placement: .navigationBarTrailing) {
5662
ZStack {
57-
NavigationLink(destination: LazyView(ChatChannelInfoView(channel: channel, shownFromMessageList: true))) {
63+
Button {
64+
resignFirstResponder()
65+
isActive = true
66+
} label: {
5867
Rectangle()
5968
.fill(Color(colors.background))
6069
.contentShape(Rectangle())
6170
.frame(width: 36, height: 36)
6271
.clipShape(Circle())
6372
.offset(x: 8)
6473
}
74+
75+
NavigationLink(isActive: $isActive) {
76+
LazyView(ChatChannelInfoView(channel: channel, shownFromMessageList: true))
77+
} label: {
78+
EmptyView()
79+
}
6580

6681
ChannelAvatarView(
6782
avatar: headerImage,
@@ -79,14 +94,16 @@ public struct DefaultChatChannelHeader: ToolbarContent {
7994
/// The default header modifier.
8095
public struct DefaultChannelHeaderModifier: ChatChannelHeaderViewModifier {
8196
@StateObject private var channelHeaderLoader = ChannelHeaderLoader()
97+
@State private var isActive: Bool = false
8298

8399
public var channel: ChatChannel
84100

85101
public func body(content: Content) -> some View {
86102
content.toolbar {
87103
DefaultChatChannelHeader(
88104
channel: channel,
89-
headerImage: channelHeaderLoader.image(for: channel)
105+
headerImage: channelHeaderLoader.image(for: channel),
106+
isActive: $isActive
90107
)
91108
}
92109
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageRepliesView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public struct MessageRepliesView<Factory: ViewFactory>: View {
3030

3131
public var body: some View {
3232
Button {
33+
// NOTE: Needed because of a bug in iOS 16.
34+
resignFirstResponder()
3335
// NOTE: this is used to avoid breaking changes.
3436
// Will be updated in a major release.
3537
NotificationCenter.default.post(

0 commit comments

Comments
 (0)