SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 741 forks source link

SwiftUI message shown under navigation bar is clipped at top #538

Open klanchman opened 7 months ago

klanchman commented 7 months ago

When displaying a SwiftUI-based message view below the navigation bar, the top of the message view is clipped by 5pts.

Here's a sample project that illustrates the issue: SwiftMessagesHostedTopMargin.zip

Simulator Screenshot - iPhone 15 Pro - 2023-11-30 at 00 08 40

I traced around and it looks like the 5pt offset is coming from TopBottomAnimation.swift around lines 93~101 (bounceOffset). For UIKit-based message views the adjustMargins() function mitigates this, but I guess the layoutMargins aren't making it through the UIHostingController for some reason. (I tried adding very large layoutMarginAdditions to the MessageHostingView and nothing happened.)

Once I found where the 5 was coming from, I felt satisfied with simply adding 5pts of padding to the top of my SwiftUI message view since I only ever present it below a navigation bar. But I assume that may not work for everyone 😄

wtmoose commented 7 months ago

Hmm, yeah. Thanks for bringing that up. The way SwiftMessages deals with safe area in UIKit is totally not applicable in SwiftUI. I need to think on it, but at least the workaround is pretty simple.