-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Port the media layout algorithm from the Android app #992
base: develop
Are you sure you want to change the base?
Conversation
I think you need to call |
Nope, it made no difference =/ |
MediaLayoutResult.Tile(colSpan: 1, rowSpan: 1, startCol: 2, startRow: 1) | ||
]) | ||
} else { | ||
// One on the left, three smaller ones on the right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean 4 attachments will never be rendered as a 2x2 grid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's always 1 bigger one and 3 smaller ones
MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift
Outdated
Show resolved
Hide resolved
MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift
Outdated
Show resolved
Hide resolved
MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift
Outdated
Show resolved
Hide resolved
Another interesting observation — if a post has a broken layout, but I then tap it to open separately, that screen has a correct layout. Might it be that images loading asynchronously affect the layout inside MediaView somehow? |
As discussed, I tried to port the media layout algorithm from the Android app. Android sources: the layout algorithm itself and the custom ViewGroup that actually puts the views on the screen. This new layout algorithm works with up to 10 media attachments.
I'm not familiar with Swift and UIKit, and definitely not with ReactiveSwift that permeates the entire codebase of the app. I might have done something stupid.
This PR isn't quite ready for merging. There's something inside
MediaView
that doesn't respect its frame and won't crop vertically, resulting in overlapping views:There's also a bug I don't know how to fix because I don't know where to hook into either the app or UIKit to re-run the layout with new
maxSize
when the view size changes. Android would automatically measure and then lay out the view subtree when the dimensions of its parentViewGroup
change, but iOS apparently doesn't do that? To reproduce, open an attachment, rotate the device to landscape orientation, then close the attachment.