Skip to content

Commit

Permalink
chore(ios): include list state reference in “movestart” event (#13655)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Dec 12, 2022
1 parent f000f3b commit ffee75d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
15 changes: 14 additions & 1 deletion apidoc/Titanium/UI/ListView.yml
Expand Up @@ -387,9 +387,22 @@ events:
- name: movestart
summary: Fired when a list row has started moving.
description: |
This property can be used to change the UI once a new drag-and-drop interaction starts.
This event can be used to change the UI once a new drag-and-drop interaction starts.
The event properties are available in Titanium SDK 12.0.0+
since: "11.1.0"
platforms: [android, iphone, ipad, macos]
properties:
- name: section
summary: List section from which the item is moved.
type: Titanium.UI.ListSection

- name: sectionIndex
summary: section index of the reference item.
type: Number

- name: itemIndex
summary: section item index of the reference item.
type: Number

- name: moveend
summary: Fired when a list row has ended moving.
Expand Down
16 changes: 15 additions & 1 deletion iphone/Classes/TiUIListView.m
Expand Up @@ -1108,7 +1108,21 @@ - (BOOL)canMoveRowAtIndexPath:(NSIndexPath *)indexPath
UIDragItem *dragItem = [[UIDragItem alloc] initWithItemProvider:itemProvider];
dragItem.localObject = identifier;

[[self proxy] fireEvent:@"movestart"];
// Fire an event to react to the move start
NSIndexPath *realIndexPath = [self pathForSearchPath:indexPath];
TiUIListSectionProxy *theSection = [[self.listViewProxy sectionForIndex:realIndexPath.section] retain];
NSDictionary *theItem = [[theSection itemAtIndex:realIndexPath.row] retain];
NSMutableDictionary *eventObject = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
theSection, @"section",
NUMINTEGER(realIndexPath.section), @"sectionIndex",
NUMINTEGER(realIndexPath.row), @"itemIndex",
nil];

[[self proxy] fireEvent:@"movestart" withObject:eventObject];

[eventObject release];
[theItem release];
[theSection release];

return @[ dragItem ];
}
Expand Down

0 comments on commit ffee75d

Please sign in to comment.