UIView-DragDrop icon indicating copy to clipboard operation
UIView-DragDrop copied to clipboard

Delegate vs dropviews principle

Open jakubknejzlik opened this issue 10 years ago • 2 comments

One question/suggestion. I would like to know your opinion about leaving the decision of what view can be dropped in another view to the delegate and the interface shoudl be:

@interface UIView (DragDrop)

  • (void) makeDraggable;
  • (void) makeDroppable;
  • (void) setDragDropDelegate:(id<UIViewDragDropDelegate>)delegate;
  • (void) setDragMode:(UIViewDragDropMode)mode; @end

@protocol UIViewDragDropDelegate <NSObject> .... @optional

  • (BOOL)draggableView:(UIView *)view shoudDropOnDroppableView:(UIView *)view;

.... @end

Looks easier to me when using it (i can dynamicaly add draggables/droppables and all is handled in delegate). Also method for destroying the draggable/droppable behaviour of view could be useful (something like -(void)destroyDraggable; -(void)destroyDroppable;)

Also if You are interested in any contribution It'll be my pleasure :)

Cheers

jakubknejzlik avatar Nov 08 '14 23:11 jakubknejzlik

Hey @jakubknejzlik. My apologies for taking so long to reply to your issues and pull request.

I think draggableView:shouldDropOnDroppableView: is a great idea and would greatly increase the flexibility of this little category.

I also agree that methods should be added for removing dropViews and drag functionality, though I don't think I like the word "destroy".

Perhaps something like this:

@interface UIView (DragDrop)

...
// remove the drag functionality from a UIView
- (void) removeDraggable;

// remove a specific dropView from the draggable view's list of drop views
- (void) removeDropView:(UIView *)dropView;

// remove all dropViews from a draggableView
- (void) removeAllDropViews; 

@end

What do you think? If you're still interested in contributing, please do! I will do my best to merge future pull requests and get the cocaopod updated in a more timely manner :)

ryanmeisters avatar Nov 26 '14 16:11 ryanmeisters

Sure, remove sound much less aggressive than destroy...I'm currently busy on few projects, but I'll do my best :)

jakubknejzlik avatar Nov 26 '14 16:11 jakubknejzlik