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