Skip to content

Commit

Permalink
add explicit type
Browse files Browse the repository at this point in the history
  • Loading branch information
Momo Ozawa committed Oct 24, 2023
1 parent 67b8085 commit 4972e37
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions WordPress/Classes/ViewRelated/Post/PostMenuHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct PostMenuHelper {
let post = statusViewModel.post

return buttons.map { button in
UIAction(title: button.title(for: post), image: button.icon, attributes: button.attributes, handler: { [weak delegate] _ in
UIAction(title: button.title(for: post), image: button.icon, attributes: button.attributes ?? [], handler: { [weak delegate] _ in
guard let delegate else { return }
button.performAction(for: post, view: presentingView, delegate: delegate)
})
Expand All @@ -53,7 +53,7 @@ struct PostMenuHelper {

protocol PostMenuAction {
var icon: UIImage? { get }
var attributes: UIMenuElement.Attributes { get }
var attributes: UIMenuElement.Attributes? { get }
func title(for post: Post) -> String
func performAction(for post: Post, view: UIView, delegate: InteractivePostViewDelegate)
}
Expand All @@ -76,10 +76,12 @@ extension PostCardStatusViewModel.Button: PostMenuAction {
}
}

var attributes: UIMenuElement.Attributes {
var attributes: UIMenuElement.Attributes? {
switch self {
case .trash: [.destructive]
default: []
case .trash:
return [UIMenuElement.Attributes.destructive]
default:
return nil
}
}

Expand Down

0 comments on commit 4972e37

Please sign in to comment.