Skip to content

Commit ffee75d

Browse files
authored
chore(ios): include list state reference in “movestart” event (#13655)
1 parent f000f3b commit ffee75d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

apidoc/Titanium/UI/ListView.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,22 @@ events:
387387
- name: movestart
388388
summary: Fired when a list row has started moving.
389389
description: |
390-
This property can be used to change the UI once a new drag-and-drop interaction starts.
390+
This event can be used to change the UI once a new drag-and-drop interaction starts.
391+
The event properties are available in Titanium SDK 12.0.0+
391392
since: "11.1.0"
392393
platforms: [android, iphone, ipad, macos]
394+
properties:
395+
- name: section
396+
summary: List section from which the item is moved.
397+
type: Titanium.UI.ListSection
398+
399+
- name: sectionIndex
400+
summary: section index of the reference item.
401+
type: Number
402+
403+
- name: itemIndex
404+
summary: section item index of the reference item.
405+
type: Number
393406

394407
- name: moveend
395408
summary: Fired when a list row has ended moving.

iphone/Classes/TiUIListView.m

+15-1
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,21 @@ - (BOOL)canMoveRowAtIndexPath:(NSIndexPath *)indexPath
11081108
UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider];
11091109
dragItem.localObject = identifier;
11101110

1111-
[[selfproxy] fireEvent:@"movestart"];
1111+
// Fire an event to react to the move start
1112+
NSIndexPath *realIndexPath = [selfpathForSearchPath:indexPath];
1113+
TiUIListSectionProxy *theSection = [[self.listViewProxy sectionForIndex:realIndexPath.section] retain];
1114+
NSDictionary *theItem = [[theSection itemAtIndex:realIndexPath.row] retain];
1115+
NSMutableDictionary *eventObject = [[NSMutableDictionaryalloc] initWithObjectsAndKeys:
1116+
theSection, @"section",
1117+
NUMINTEGER(realIndexPath.section), @"sectionIndex",
1118+
NUMINTEGER(realIndexPath.row), @"itemIndex",
1119+
nil];
1120+
1121+
[[selfproxy] fireEvent:@"movestart"withObject:eventObject];
1122+
1123+
[eventObject release];
1124+
[theItem release];
1125+
[theSection release];
11121126

11131127
return @[ dragItem ];
11141128
}

0 commit comments

Comments
 (0)
close