Skip to content

Commit

Permalink
chore(ios): changed Ti.UI.Shortcut back to ObjcProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jquick-axway authored and sgtcoolguy committed Aug 6, 2020
1 parent 5fc1ebd commit 7c64db3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 31 deletions.
19 changes: 6 additions & 13 deletions iphone/Classes/TiUIShortcutProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,26 @@

#if defined(USE_TI_UISHORTCUT) || defined(USE_TI_UISHORTCUTITEM)

#import <TitaniumKit/TiProxy.h>
#import <TitaniumKit/ObjcProxy.h>

@class TiUIShortcutItemProxy;

@interface TiUIShortcutProxy : TiProxy {
@private
}

NS_ASSUME_NONNULL_BEGIN

/*
@protocol TiUIShortcutProxyExports <JSExport>
READONLY_PROPERTY(NSArray<TiUIShortcutItemProxy *> *, items, Items);
READONLY_PROPERTY(NSArray<TiUIShortcutItemProxy *> *, staticItems, StaticItems);

- (TiUIShortcutItemProxy *)getById:(NSString *)identifier;

- (void)remove:(TiUIShortcutItemProxy *)shortcut;

- (void)removeAll;
- (void)add:(TiUIShortcutItemProxy *)shortcut;
*/

@property (nonatomic, readonly) NSArray<TiUIShortcutItemProxy *> *items;
@property (nonatomic, readonly) NSArray<TiUIShortcutItemProxy *> *staticItems;
@end

- (TiUIShortcutItemProxy *)getById:(id)args;
- (void)remove:(id)args;
- (void)removeAll:(id)unused;
- (void)add:(id)args;
@interface TiUIShortcutProxy : ObjcProxy <TiUIShortcutProxyExports>

@end

Expand Down
19 changes: 5 additions & 14 deletions iphone/Classes/TiUIShortcutProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ - (void)_listenerRemoved:(NSString *)type count:(int)count
return shortcutsToReturn;
}

- (TiUIShortcutItemProxy *)getById:(id)args
- (TiUIShortcutItemProxy *)getById:(NSString *)identifier
{
ENSURE_SINGLE_ARG(args, NSString)
NSString *identifier = [TiUtils stringValue:args];

NSArray<UIApplicationShortcutItem *> *shortcuts = [UIApplication sharedApplication].shortcutItems;
for (UIApplicationShortcutItem *item in shortcuts) {
if ([item.type isEqualToString:[TiUtils stringValue:identifier]]) {
Expand All @@ -110,11 +107,8 @@ - (TiUIShortcutItemProxy *)getById:(id)args
return nil;
}

- (void)remove:(id)args
- (void)remove:(TiUIShortcutItemProxy *)shortcut
{
ENSURE_SINGLE_ARG(args, TiUIShortcutItemProxy)
TiUIShortcutItemProxy *shortcut = args;

NSString *key = [shortcut shortcutItem].type;

NSMutableArray<UIApplicationShortcutItem *> *shortcuts = (NSMutableArray<UIApplicationShortcutItem *> *)[UIApplication sharedApplication].shortcutItems;
Expand All @@ -127,16 +121,13 @@ - (void)remove:(id)args
[UIApplication sharedApplication].shortcutItems = shortcuts;
}

- (void)removeAll:(id)unused
- (void)removeAll
{
[UIApplication sharedApplication].shortcutItems = nil;
}

- (void)add:(id)args
- (void)add:(TiUIShortcutItemProxy *)shortcut
{
ENSURE_SINGLE_ARG(args, TiUIShortcutItemProxy)
TiUIShortcutItemProxy *shortcut = args;

NSMutableArray<UIApplicationShortcutItem *> *shortcuts = (NSMutableArray<UIApplicationShortcutItem *> *)[UIApplication sharedApplication].shortcutItems;

// Remove previous shortcutitem of same id if exists
Expand All @@ -161,7 +152,7 @@ - (void)didReceiveShortcutNotification:(NSNotification *)info
localizedSubtitle:userInfo[@"subtitle"]
icon:nil
userInfo:userInfo[@"userInfo"]] autorelease];
[self fireEvent:@"click" withObject:@{ @"item" : [[[TiUIShortcutItemProxy alloc] initWithShortcutItem:shortcut] autorelease] }];
[self fireEvent:@"click" withDict:@{ @"item" : [[[TiUIShortcutItemProxy alloc] initWithShortcutItem:shortcut] autorelease] }];
}
}
@end
Expand Down
5 changes: 1 addition & 4 deletions iphone/Classes/UIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ - (void)didReceiveMemoryWarning:(NSNotification *)notification
#endif
#ifdef USE_TI_UICLIPBOARD
RELEASE_TO_NIL(clipboard);
#endif
#if defined(USE_TI_UISHORTCUT) || defined(USE_TI_UISHORTCUTITEM)
RELEASE_TO_NIL(shortcut);
#endif
[super didReceiveMemoryWarning:notification];
}
Expand Down Expand Up @@ -749,7 +746,7 @@ - (NSString *)CLIPBOARD_OPTION_EXPIRATION_DATE
- (TiUIShortcutProxy *)Shortcut
{
if (shortcut == nil) {
shortcut = [[TiUIShortcutProxy alloc] _initWithPageContext:[self executionContext]];
shortcut = [[TiUIShortcutProxy alloc] init];
}
return shortcut;
}
Expand Down

0 comments on commit 7c64db3

Please sign in to comment.