|
17 | 17 | #ifdef USE_TI_UIREFRESHCONTROL
|
18 | 18 | #import "TiUIRefreshControlProxy.h"
|
19 | 19 | #endif
|
| 20 | +#import <MobileCoreServices/MobileCoreServices.h> |
20 | 21 | #import <TitaniumKit/ImageLoader.h>
|
21 | 22 |
|
22 | 23 | @interface TiUIListView ()
|
@@ -203,12 +204,19 @@ - (UITableView *)tableView
|
203 | 204 | {
|
204 | 205 | if (_tableView == nil) {
|
205 | 206 | UITableViewStyle style = [TiUtils intValue:[self.proxy valueForKey:@"style"] def:UITableViewStylePlain];
|
| 207 | + BOOL requiresEditingToMove = [TiUtils boolValue:[self.proxy valueForKey:@"requiresEditingToMove"] def:YES]; |
206 | 208 |
|
207 | 209 | _tableView = [[UITableView alloc] initWithFrame:self.bounds style:style];
|
208 | 210 | _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
209 | 211 | _tableView.delegate = self;
|
210 | 212 | _tableView.dataSource = self;
|
211 | 213 |
|
| 214 | + if (!requiresEditingToMove) { |
| 215 | + _tableView.dragDelegate = self; |
| 216 | + _tableView.dropDelegate = self; |
| 217 | + _tableView.dragInteractionEnabled = YES; |
| 218 | + } |
| 219 | + |
212 | 220 | // Fixes incorrect heights in iOS 11 as we calculate them internally already
|
213 | 221 | _tableView.estimatedRowHeight = 0;
|
214 | 222 | _tableView.estimatedSectionFooterHeight = 0;
|
@@ -2553,6 +2561,33 @@ + (UITableViewRowAnimation)animationStyleForProperties:(NSDictionary *)propertie
|
2553 | 2561 | return animate ? UITableViewRowAnimationFade : UITableViewRowAnimationNone;
|
2554 | 2562 | }
|
2555 | 2563 |
|
| 2564 | +- (nonnull NSArray<UIDragItem *> *)tableView:(nonnull UITableView *)tableView itemsForBeginningDragSession:(nonnull id<UIDragSession>)session atIndexPath:(nonnull NSIndexPath *)indexPath |
| 2565 | +{ |
| 2566 | + NSItemProvider *itemProvider = [NSItemProvider new]; |
| 2567 | + NSString *identifier = [NSString stringWithFormat:@"%lu_%lu", indexPath.section, indexPath.row]; |
| 2568 | + |
| 2569 | + [itemProvider registerDataRepresentationForTypeIdentifier:(NSString *)kUTTypePlainText |
| 2570 | + visibility:NSItemProviderRepresentationVisibilityAll |
| 2571 | + loadHandler:^NSProgress *_Nullable(void (^_Nonnull completionHandler)(NSData *_Nullable, NSError *_Nullable)) { |
| 2572 | + return nil; |
| 2573 | + }]; |
| 2574 | + |
| 2575 | + UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider]; |
| 2576 | + dragItem.localObject = identifier; |
| 2577 | + |
| 2578 | + return @[ dragItem ]; |
| 2579 | +} |
| 2580 | + |
| 2581 | +- (void)tableView:(UITableView *)tableView performDropWithCoordinator:(id<UITableViewDropCoordinator>)coordinator |
| 2582 | +{ |
| 2583 | + // NO-OP right now |
| 2584 | +} |
| 2585 | + |
| 2586 | +- (BOOL)tableView:(UITableView *)tableView canHandleDropSession:(id<UIDropSession>)session |
| 2587 | +{ |
| 2588 | + return [session canLoadObjectsOfClass:[NSString class]]; |
| 2589 | +} |
| 2590 | + |
2556 | 2591 | @end
|
2557 | 2592 |
|
2558 | 2593 | static TiViewProxy *FindViewProxyWithBindIdContainingPoint(UIView *view, CGPoint point)
|
|
0 commit comments