forked from shadowfacts/Tusker
Add compose key command
This commit is contained in:
parent
4bccbe254b
commit
72217cde51
|
@ -10,21 +10,32 @@ import UIKit
|
|||
|
||||
struct MenuController {
|
||||
|
||||
static func composeCommand() -> UIKeyCommand {
|
||||
let selector: Selector
|
||||
if #available(iOS 14.0, *) {
|
||||
selector = #selector(MainSplitViewController.presentCompose)
|
||||
} else {
|
||||
selector = #selector(MainTabBarViewController.presentCompose)
|
||||
}
|
||||
return UIKeyCommand(title: "Compose", action: selector, input: "n", modifierFlags: .command)
|
||||
}
|
||||
|
||||
static func refreshCommand(discoverabilityTitle: String?) -> UIKeyCommand {
|
||||
return UIKeyCommand(title: "Refresh", action: #selector(RefreshableViewController.refresh), input: "r", modifierFlags: .command, discoverabilityTitle: discoverabilityTitle)
|
||||
}
|
||||
|
||||
static func buildMainMenu(builder: UIMenuBuilder) {
|
||||
builder.insertChild(buildViewMenu(), atEndOfMenu: .view)
|
||||
builder.insertChild(buildFileMenu(), atStartOfMenu: .file)
|
||||
}
|
||||
|
||||
private static func buildViewMenu() -> UIMenu {
|
||||
private static func buildFileMenu() -> UIMenu {
|
||||
return UIMenu(
|
||||
title: "",
|
||||
image: nil,
|
||||
identifier: nil,
|
||||
options: .displayInline,
|
||||
children: [
|
||||
composeCommand(),
|
||||
refreshCommand(discoverabilityTitle: nil),
|
||||
]
|
||||
)
|
||||
|
|
|
@ -56,6 +56,8 @@ class MainSplitViewController: UISplitViewController {
|
|||
|
||||
tabBarViewController = MainTabBarViewController(mastodonController: mastodonController)
|
||||
setViewController(tabBarViewController, for: .compact)
|
||||
|
||||
addKeyCommand(MenuController.composeCommand())
|
||||
}
|
||||
|
||||
func select(item: MainSidebarViewController.Item) {
|
||||
|
@ -315,7 +317,7 @@ fileprivate extension MainSidebarViewController.Item {
|
|||
|
||||
@available(iOS 14.0, *)
|
||||
extension MainSplitViewController: TuskerRootViewController {
|
||||
func presentCompose() {
|
||||
@objc func presentCompose() {
|
||||
let vc = ComposeHostingController(mastodonController: mastodonController)
|
||||
let nav = EnhancedNavigationViewController(rootViewController: vc)
|
||||
nav.presentationController?.delegate = vc
|
||||
|
|
|
@ -156,7 +156,7 @@ extension MainTabBarViewController: FastAccountSwitcherViewControllerDelegate {
|
|||
}
|
||||
|
||||
extension MainTabBarViewController: TuskerRootViewController {
|
||||
func presentCompose() {
|
||||
@objc func presentCompose() {
|
||||
let vc = ComposeHostingController(mastodonController: mastodonController)
|
||||
let nav = EnhancedNavigationViewController(rootViewController: vc)
|
||||
nav.presentationController?.delegate = vc
|
||||
|
|
Loading…
Reference in New Issue