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

[S] Allow SwiftUI content view to size up until maximum width #241

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

Grimlock257
Copy link
Contributor

Change Description

This PR should allow a SwiftUI view that is being used within the PopTip to resize a little better. Previously if the content of a SwiftUI content view was too wide it would just run of the screen, or if given a fixed width (using the .frame(width: 200) view modifier on the SwiftUI itself) then text would truncate instead of wrapping onto new lines. Hopefully this change should improve this behaviour by modifying the frame calculation for the UIHostingViewController view within the show method. Essentially a maximum width is calculated which is the width of the device minus padding/margin/etc. so that the full thing is still visible, and then the height is derived using the UIView method sizeThatFits. This is not a perfect solution, but is an improvement in my opinion - thoughts?

This could be improved to work better with different directions, and applied to the other variants of PopTip.

This partially addresses the issue I mentioned at the end of my last PR #239.

Testing

Testing this functionality should be possible by playing around with the SwiftUI views within SwiftUIView.swift. A second view has been added which utilises different behaviours, and it automatically toggles when tapping the topLeft button (so it will now cycle between custom view and a SwiftUI view where the SwiftUI view also alternates each time).

Closing notes

If there are any issues, or questions around these changes, please let me know! If all is good with this @andreamazz, it'd be great to be able to have it merged and the version bumped as appropriate - it does change the existing behaviour for those that use it, so may be worth doing a decent bump! 😄

Only does proper width calculation for direction up and down
@andreamazz andreamazz merged commit cf9e151 into andreamazz:main Aug 26, 2022
@andreamazz
Copy link
Owner

Hey @Grimlock257
Sorry it took me a while to get to this. I appreciate the contribution, and I agree that this solution looks good enough for now.
I'll bump and release.

👍

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