Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-18379][TIMOB-18378] OptionDialog Fixes #6573

Merged
merged 2 commits into from
Jan 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions iphone/Classes/TiUIOptionDialogProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ -(void)show:(id)args
curIndex++;
}

if ([TiUtils isIPad] && (cancelButtonIndex == -1)) {
UIAlertAction* theAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action){
[self fireClickEventWithAction:action];
}];
[alertController addAction:theAction];
}
BOOL isPopover = NO;

if ([TiUtils isIPad]) {
Expand Down Expand Up @@ -240,6 +248,7 @@ - (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popover

//Fell through.
UIViewController* presentingController = [alertController presentingViewController];
popoverPresentationController.permittedArrowDirections = 0;
popoverPresentationController.sourceView = [presentingController view];
popoverPresentationController.sourceRect = (CGRectEqualToRect(CGRectZero, dialogRect)?CGRectMake(presentingController.view.bounds.size.width/2, presentingController.view.bounds.size.height/2, 1, 1):dialogRect);;
}
Expand Down Expand Up @@ -297,10 +306,15 @@ - (void)actionSheet:(UIActionSheet *)actionSheet_ didDismissWithButtonIndex:(NSI
-(void) fireClickEventWithAction:(UIAlertAction*)theAction
{
if ([self _hasListeners:@"click"]) {
NSUInteger indexOfAction = [[alertController actions] indexOfObject:theAction];
NSArray *actions = [alertController actions];
NSInteger indexOfAction = [actions indexOfObject:theAction];

if ([TiUtils isIPad] && (cancelButtonIndex == -1) && (indexOfAction == ([actions count]-1)) ) {
indexOfAction = cancelButtonIndex;
}

NSMutableDictionary *event = [NSMutableDictionary dictionaryWithObjectsAndKeys:
NUMUINTEGER(indexOfAction),@"index",
NUMINTEGER(indexOfAction),@"index",
NUMINT(cancelButtonIndex),@"cancel",
NUMINT(destructiveButtonIndex),@"destructive",
nil];
Expand Down