Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyboardTrackingView causes a small space under bottom-style view #483

Closed
kientux opened this issue Sep 29, 2021 · 2 comments
Closed

KeyboardTrackingView causes a small space under bottom-style view #483

kientux opened this issue Sep 29, 2021 · 2 comments

Comments

@kientux
Copy link

kientux commented Sep 29, 2021

When I add KeyboardTrackingView to config and show a bottom-style view, there is a small space under it.

let messageView = BaseView(frame: .zero)

let backgroundView = CornerRoundingView()
backgroundView.cornerRadius = 12
backgroundView.layer.masksToBounds = true
messageView.installBackgroundView(backgroundView)

let contentView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 128))
contentView.backgroundColor = .white
messageView.installContentView(contentView)

messageView.layoutMarginAdditions = .zero
messageView.respectSafeArea = false

var config = SwiftMessages.defaultConfig
config.keyboardTrackingView = KeyboardTrackingView()
config.dimMode = .color(color: UIColor(white: 0, alpha: 0.55), interactive: true)

config.presentationStyle = .bottom
config.duration = .forever
config.interactiveHide = false

config.presentationContext = .window(windowLevel: .statusBar)

// alertPresenter = SwiftMessages()
alertPresenter.show(config: config, view: messageView)

respectSafeArea = false is for iPhone with notch so we can clearly see it. I tried on normal iPhones and this still happens.

Screenshots:

With KeyboardTrackingView:

Simulator Screen Shot - iPhone 11 - 2021-09-29 at 16 14 19

Without:

Simulator Screen Shot - iPhone 11 - 2021-09-29 at 16 14 06

@wtmoose
Copy link
Member

wtmoose commented Sep 29, 2021

Can you try the work/9.0.5 branch?

Here's an explanation if you're interested. By default, the bottom presentation places the message view 5pt below the screen so that the spring animation doesn't show a gap under the view when it overshoots. This behavior is intended for cases where the message view has a background color. However, you're using a clear message view with a background view that provides the visible region of the view. The background view's constraints negate the 5pt offset, so it aligns with the bottom of the screen. However, when you add the keyboard tracking view, the entire message view, along with the background view, is pushed up by 5pt.

You can fix this by setting the following:

messageView.bounceAnimationOffset = 0

But on the work/9.0.5 branch, I've accounted for bounceAnimationOffset with the keyboard tracking view, so the above setting isn't needed.

@kientux
Copy link
Author

kientux commented Sep 30, 2021

Thank you, I tried the work/9.0.5 branch and it worked as expected. Anyway, I use a custom TopBottomAnimation to disable the spring damping so setting bounceAnimationOffset = 0 also do the work.

@kientux kientux closed this as completed Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants