Skip to content

Layout, drag and drop, scroll, relative positioning features and more that SwiftUI is missing

License

Notifications You must be signed in to change notification settings

marcoboerner/OpenSwiftUIViews

Repository files navigation

OpenSwiftUIViews

This repository is a work in progress and should not be used directly yet.

You can clone, fork, or copy parts of the code and make it work for your projects. Feedback, bug reports or pull requests, any sort of collaboration efforts are welcome. Once again:

  • I do not recommend using it as a direct dependency
  • The code will have bugs
  • Using it as it is might cause unexpected behaviors
  • I'm constantly changing it while developing another project
  • Every change might be a breaking change, even bug fixes
  • There are no tests
  • The example app might not have example for all and is not always updated when the package changes
  • This help file might not be up to date either

Other than that I'm developing this package to implement some of the features I'm missing in SwiftUI the most or that are not implemented the way I find them useful.

OpenScrollView

As of early 2023 I recommend in most cases the native scroll view and scroll view reader with the UIKit scroll view override. See the example app for a basic implementation. Using simultaneous gestures, it seems other gestures (Not currently in the example app) or the scrolling are also no longer blocked if you use the right combination of gestures in recent iOS versions.

A non gesture blocking, non clipping by default custom scroll view implementation with example code.

This is an attempt for a custom scroll view in SwiftUI that will not block other gestures or be blocked by other gestures unless specified with a view modifier. I tried to implement some of the other scroll view features like a scroll view reader and proxy as well.

Ideally I'd like to find a way to use this view together with the regular ScrollView reader but I wasn't able to figure out the internals of it to make it work.

It does work for my purposes but could probably be extended and made more generic and simplified.

Related questions and answer on Stack Overflow

OpenDragAndDrop

Similar to the drag and drop capabilities that SwiftUI provides but only meant for within the app. Allowing views to be dragged and dropped with drop detection and an attached dragged object.

OpenAlignView

Introduced at WWDC 2022, there is now also a native version for that.

Allows to align the size of the frames of multiple views from multiple stacks in rows and cols.

OpenAlignOffset

Introduced at WWDC 2022, there is now also a native version for that.

Aligns the offset of multiple views organized in rows and cols, aligning both axes.

OpenRelativePosition and OpenRelativeOffset

Both allow the positioning of a view in another coordinate system. Relative position is using an internal position modifier, relative offset using an internal offset modifier.

Related questions and answer on Stack Overflow