blob: e39edd2b0f37b7dd73e5800dead02cf719bbf03c [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "FLTShortcutStateManager.h"
@implementation FLTShortcutStateManager
- (void)setShortcutItems:(NSArray *)items {
NSMutableArray<UIApplicationShortcutItem *> *newShortcuts = [[NSMutableArray alloc] init];
for (id item in items) {
UIApplicationShortcutItem *shortcut = [self deserializeShortcutItem:item];
[newShortcuts addObject:shortcut];
}
[UIApplication sharedApplication].shortcutItems = newShortcuts;
}
- (UIApplicationShortcutItem *)deserializeShortcutItem:(NSDictionary *)serialized {
UIApplicationShortcutIcon *icon =
[serialized[@"icon"] isKindOfClass:[NSNull class]]
? nil
: [UIApplicationShortcutIcon iconWithTemplateImageName:serialized[@"icon"]];
return [[UIApplicationShortcutItem alloc] initWithType:serialized[@"type"]
localizedTitle:serialized[@"localizedTitle"]
localizedSubtitle:nil
icon:icon
userInfo:nil];
}
@end