Skip to content

Commit

Permalink
Replace old UIBarButtonItem with @objc annotation with modern API
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Nov 15, 2024
1 parent 0a2af26 commit 0666e50
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ final class DeckListPresenter: DeckListPresenterProtocol {
}

func setupNavigationItems(completion: ([UIBarButtonItem]?) -> Void) {
let addCardBarItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addButtonTouched(_:)))
let primaryAction = UIAction { [weak self] _ in
self?.insert(deck: DeckDTO())
}

let addCardBarItem = UIBarButtonItem(systemItem: .add, primaryAction: primaryAction)

completion([addCardBarItem])
}

Expand All @@ -49,13 +54,6 @@ final class DeckListPresenter: DeckListPresenterProtocol {
func navigateToDeckBuilder(with deck: DeckDTO) {
navigator.navigate(to: .deckBuilder(database: database, with: deck))
}

// MARK: - UIBarButton Actions

@objc
private func addButtonTouched(_ sender: Any) {
insert(deck: DeckDTO())
}
}

extension DeckListPresenter: DeckListProtocol {
Expand Down

0 comments on commit 0666e50

Please sign in to comment.