APReorderableStackView icon indicating copy to clipboard operation
APReorderableStackView copied to clipboard

Added horizontal support

Open OscarFridh opened this issue 6 years ago • 3 comments

Here's a new PR that strictly addresses adding horizontal support. I wasn't sure how you want to handle delegation in this case, so currently If the stack view is set up to be horizontal the delegate method (didDragToReorder) is called in the same way where 'up' represents right and 'Y' represents X.

OscarFridh avatar Jul 02 '19 07:07 OscarFridh

I think I would either create an alternative delegate method:

@objc optional func didDragHorizontalToReorder(inRightDirection right: Bool, maxX: CGFloat, minX: CGFloat)

Or introduce enum:

@objc public enum DragDirection: Int {
  case up, down, left, right
}

And use that in the delegate?

@objc optional func didDragToReorder(direction: APRedorderableStackView.DragDirection, max: CGFloat, min: CGFloat)

teameh avatar Jul 02 '19 08:07 teameh

Good idea! I think I prefer the alternative delegate method because then the caller can check the direction on the boolean instead of switching over an enum. The stack view will be either horizontal or vertical so it's unnecessary to switch over four cases. Or what do you think?

OscarFridh avatar Jul 02 '19 09:07 OscarFridh

Yeah that makes sense :)

teameh avatar Jul 02 '19 12:07 teameh