Add separator to accounts menu

This commit is contained in:
Shadowfacts 2022-01-16 11:17:30 -05:00
parent 0450fe2c0e
commit df00108dae
1 changed files with 5 additions and 1 deletions

View File

@ -34,7 +34,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
override func buildMenu(with builder: UIMenuBuilder) { override func buildMenu(with builder: UIMenuBuilder) {
if builder.system == .main { if builder.system == .main {
var children: [UIMenuElement] = LocalData.accounts.map { account in
var children = [UIMenuElement]()
let accounts: [UIMenuElement] = LocalData.accounts.map { account in
var title = account.instanceURL.host! var title = account.instanceURL.host!
if let port = account.instanceURL.port, port != 80 && port != 443 { if let port = account.instanceURL.port, port != 80 && port != 443 {
title += ":\(port)" title += ":\(port)"
@ -56,6 +59,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: options, errorHandler: nil) UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: options, errorHandler: nil)
} }
} }
children.append(UIMenu(options: .displayInline, children: accounts))
children.append(UIAction(title: "Add Account...", handler: { _ in children.append(UIAction(title: "Add Account...", handler: { _ in
let activity = NSUserActivity.addAccount() let activity = NSUserActivity.addAccount()
let options = UIScene.ActivationRequestOptions() let options = UIScene.ActivationRequestOptions()