// // MenuController.swift // Tusker // // Created by Shadowfacts on 11/14/20. // Copyright © 2020 Shadowfacts. All rights reserved. // 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(buildFileMenu(), atStartOfMenu: .file) } private static func buildFileMenu() -> UIMenu { return UIMenu( title: "", image: nil, identifier: nil, options: .displayInline, children: [ composeCommand(), refreshCommand(discoverabilityTitle: nil), ] ) } }