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

New generic TabView with drag and drop + state fix #1535

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Wouter01
Copy link
Member

@Wouter01 Wouter01 commented Dec 28, 2023

Description

A new ReorderableTabView, which replaces AreaTabBarAlt.

Why?

  • It's designed to work like a built-in View. No custom protocols, but instead a generic view. Options are provided with modifiers.
  • It fixes multiple state issues. Tab state is now kept when tabs are switched (e.g. scroll position of file tree)
  • Local drag and drop. This was in the previous version too but it's more efficient here.
  • Global drag and drop. This wasn't in the previous version, and allows the item to be dragged outside the view.
  • Drop Target. The view can act like a drop target, and can accept new tabs that are dragged over it. This makes it easy to support multi-pane tabs.
  • All the drag and drop functionality uses the built-in SwiftUI ForEach modifiers, such as onMove, onInsert, and onDelete. This makes it easier to control view state.
  • Additional layout modes. The view makes it possible to place the tab bar at the top, bottom, left or right.

Note that this PR adds the possibility to add all this functionality, but doesn't implement all of it. For example, global drag and drop is possible (and is enabled for the navigator), but isn't used yet as a second navigator tabview isn't present yet. Thanks to this PR, it can be added later on with just a few code changes.

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Related issues

@Wouter01 Wouter01 added bug Something isn't working enhancement New feature or request labels Dec 28, 2023
Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple comments

@@ -61,3 +85,9 @@ enum NavigatorTab: AreaTab {
}
}
}

import UniformTypeIdentifiers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports should be at the top of the file.


extension AnyVariadicView.Subview {
var onMove: ((IndexSet, Int) -> Void)? {
self["s7SwiftUI14OnMoveTraitKeyV", as: ((IndexSet, Int) -> Void).self]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are mad sketchy, can we add a test for this so we can be notified quickly if they change in a future SwiftUI release?

@austincondiff
Copy link
Collaborator

@CodeEditApp/maintainers What do we want to do with this at this point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants