Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Context Menus break Auto Layout #77

Closed
alexeyprimechaev opened this issue Jan 14, 2020 · 5 comments
Closed

Context Menus break Auto Layout #77

alexeyprimechaev opened this issue Jan 14, 2020 · 5 comments

Comments

@alexeyprimechaev
Copy link

alexeyprimechaev commented Jan 14, 2020

Preface

Not really this library's problem, but it could help solve it by bringing in support for UIKit Context Menu as opposed to relying on SwiftUI's problematic implementation.

Issue

The issue is as follows: whenever a Context Menu is accessed, Xcode throws an error regarding some broken constraints — on any view in any configuration (screenshots attached), but sometimes a context menu preview is recovered by being placed on top of the source view.

If, however, a view has dynamic content/Button in it, it's simply not displayed.

Proposed Solution

Implement per-cell Context Menus using UICollectionView API.

I think that you have created a fantastic framework that is simply necessary to create any sort of a complex and dynamic user interface in SwiftUI (at least until Apple adds a CollectionView analog) and it would greatly increase its value by providing a solution to this issue. Pretty Please?

To Reproduce

Interact with a Context Menu

Screenshots

Code
Screen Shot 2020-01-14 at 11 58 31 PM

Rendered Result
One

Example with dynamic content/Button
IMG_1E51CA355FDF-1

Xcode Output
image

Xcode Version:

13.3.1

Simulator, Device, Both?

Both

@1234igor
Copy link

+1

Struggling with same issue and don’t know what should I do.

@apptekstudios
Copy link
Owner

I'm currently overseas but will have a look into this as soon as I can! Should be relatively straightforward to implement support via UIKit :)

@apptekstudios
Copy link
Owner

@alexeyprimechaev @1234igor

I've made a start by adding support for UIContextMenuConfiguration to the dev branch. See the 'magazineLayout' demo page for an example 🎉.

We could wrap it further to make a clearer struct-based API, however the UIKit method is relatively straightforward and allows for complexities such as nested menus - so I'll leave it be for now 👍

Interestingly, during my testing I found that constraints were broken even in a pure UIKit Collectionview using contextMenus (with no ASCollectionView or swiftUI involved). So sounds like there's also a UIKit bug :/ gladly it's just an annoying log message!

@apptekstudios
Copy link
Owner

I should also note that this seems to fix the SwiftUI bug with dynamicContent/Buttons not displaying 🎉

@alexeyprimechaev
Copy link
Author

Wow! I also think that it’s a great implementation as is (miles better than the SwiftUI one which has no support for sections, and nesting, and can’t properly display icons, etc.). Thanks for investing your time in it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants