Skip to content

Commit

Permalink
fix: Group local and remote add actions (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Sep 14, 2024
1 parent e5e875f commit 43757d0
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions OpoLua/View Controllers/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ import UIKit
class BrowserViewController: UICollectionViewController {

internal lazy var addBarButtonItem: UIBarButtonItem = {
let actions = actions()
let softwareIndexAction = UIAction(title: "Psion Software Index",
image: UIImage(systemName: "list.dash.header.rectangle")) { [weak self] action in
self?.showSoftwareIndex()
}
let addFolderAction = UIAction(title: "Add Folder",
image: UIImage(systemName: "folder.badge.plus")) { [weak self] action in
self?.addFolder()
}
let localActionsMenu = UIMenu(options: [.displayInline], children: [softwareIndexAction])
let remoteActionsMenu = UIMenu(options: [.displayInline], children: [addFolderAction])
let actions = [
localActionsMenu,
remoteActionsMenu,
]
let menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actions)
let addBarButtonItem = UIBarButtonItem(title: nil,
image: UIImage(systemName: "plus"),
Expand All @@ -43,21 +56,6 @@ class BrowserViewController: UICollectionViewController {
fatalError("init(coder:) has not been implemented")
}

func actions() -> [UIMenuElement] {
let softwareIndexAction = UIAction(title: "Psion Software Index",
image: UIImage(systemName: "list.dash.header.rectangle")) { [weak self] action in
self?.showSoftwareIndex()
}
let addFolderAction = UIAction(title: "Add Folder",
image: UIImage(systemName: "folder.badge.plus")) { [weak self] action in
self?.addFolder()
}
return [UIMenu(options: [.displayInline], children: [
softwareIndexAction,
addFolderAction,
])]
}

@objc func showSoftwareIndex() {
let softwareIndexViewController = SoftwareIndexViewController()
softwareIndexViewController.delegate = self
Expand Down

0 comments on commit 43757d0

Please sign in to comment.