-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f952c3
commit a840e90
Showing
7 changed files
with
124 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Classes/ObjectExplorers/Sections/Shortcuts/FLEXUIAppShortcuts.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// FLEXUIAppShortcuts.h | ||
// FLEX | ||
// | ||
// Created by Tanner on 5/25/20. | ||
// Copyright © 2020 Flipboard. All rights reserved. | ||
// | ||
|
||
#import "FLEXShortcutsSection.h" | ||
|
||
@interface FLEXUIAppShortcuts : FLEXShortcutsSection | ||
|
||
@end |
77 changes: 77 additions & 0 deletions
77
Classes/ObjectExplorers/Sections/Shortcuts/FLEXUIAppShortcuts.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// FLEXUIAppShortcuts.m | ||
// FLEX | ||
// | ||
// Created by Tanner on 5/25/20. | ||
// Copyright © 2020 Flipboard. All rights reserved. | ||
// | ||
|
||
#import "FLEXUIAppShortcuts.h" | ||
#import "FLEXRuntimeUtility.h" | ||
#import "FLEXShortcut.h" | ||
#import "FLEXAlert.h" | ||
|
||
@implementation FLEXUIAppShortcuts | ||
|
||
#pragma mark - Overrides | ||
|
||
+ (instancetype)forObject:(UIApplication *)application { | ||
return [self forObject:application additionalRows:@[ | ||
[FLEXActionShortcut title:@"Open URL…" | ||
subtitle:^NSString *(UIViewController *controller) { | ||
return nil; | ||
} | ||
selectionHandler:^void(UIViewController *host, UIApplication *app) { | ||
[FLEXAlert makeAlert:^(FLEXAlert *make) { | ||
make.title(@"Open URL"); | ||
make.message( | ||
@"This will call openURL: or openURL:options:completion: " | ||
"with the string below. 'Open if Universal' will only open " | ||
"the URL if it is a registered Universal Link." | ||
); | ||
|
||
make.textField(@"twitter://user?id=12345"); | ||
make.button(@"Open").handler(^(NSArray<NSString *> *strings) { | ||
[self openURL:strings[0] inApp:app onlyIfUniveral:NO host:host]; | ||
}); | ||
make.button(@"Open if Universal").handler(^(NSArray<NSString *> *strings) { | ||
[self openURL:strings[0] inApp:app onlyIfUniveral:YES host:host]; | ||
}); | ||
make.button(@"Cancel").cancelStyle(); | ||
} showFrom:host]; | ||
} | ||
accessoryType:^UITableViewCellAccessoryType(UIViewController *controller) { | ||
return UITableViewCellAccessoryDisclosureIndicator; | ||
} | ||
] | ||
]]; | ||
} | ||
|
||
+ (void)openURL:(NSString *)urlString | ||
inApp:(UIApplication *)app | ||
onlyIfUniveral:(BOOL)universalOnly | ||
host:(UIViewController *)host { | ||
NSURL *url = [NSURL URLWithString:urlString]; | ||
|
||
if (url) { | ||
if (@available(iOS 10, *)) { | ||
[app openURL:url options:@{ | ||
UIApplicationOpenURLOptionUniversalLinksOnly: @(universalOnly) | ||
} completionHandler:^(BOOL success) { | ||
if (!success) { | ||
[FLEXAlert showAlert:@"No Universal Link Handler" | ||
message:@"No installed application is registered to handle this link." | ||
from:host | ||
]; | ||
} | ||
}]; | ||
} else { | ||
[app openURL:url]; | ||
} | ||
} else { | ||
[FLEXAlert showAlert:@"Error" message:@"Invalid URL" from:host]; | ||
} | ||
} | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters