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

Support constraintsBlock for showToast method #206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

audrl1010
Copy link

@audrl1010 audrl1010 commented Nov 9, 2023

Hello there! I am a dedicated user of this library :)

The current custom toast view layout in the library is processed based on frames. Thus, when the toast is positioned at the bottom of the screen, there might be an issue where part of it gets clipped if the height of the toast's superview changes.

To prevent this situation, it would be beneficial to delegate the toast layout task in a callback format, enabling the use of flexible positioning methods such as auto-layout.

Here's an example of how this can be implemented.

let customToast = ....
self.view.showToast(customToast, constraints: { container, toast in
	toast.translatesAutoresizingMaskIntoConstraints = false
	toast.leftAnchor.constraint(equalTo: container.leftAnchor, constant: 20).isActive = true
	toast.rightAnchor.constraint(equalTo: container.rightAnchor, constant: -20).isActive = true
	toast.bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: -40).isActive = true
})

--- Video

autolayout.mov

Once you have a look at it and provide feedback, I would appreciate it. Thank you.

@audrl1010 audrl1010 closed this Nov 9, 2023
@audrl1010 audrl1010 reopened this Nov 9, 2023
@audrl1010 audrl1010 changed the title Add custom toast view using autoLayout Support showToast method constraintsBlock Nov 9, 2023
@audrl1010 audrl1010 changed the title Support showToast method constraintsBlock Support constraintsBlock for showToast method Nov 9, 2023
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

Successfully merging this pull request may close these issues.

2 participants