Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11661 from leandroalonso/post_list_more_action_sheet
Replace "More" button behavior to show options in an Action Sheet
- Loading branch information
Showing
16 changed files
with
378 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "InteractivePostViewDelegate.h" | ||
|
||
@class Post; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
WordPress/Classes/ViewRelated/Post/InteractivePostViewDelegate.h
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
WordPress/Classes/ViewRelated/Post/InteractivePostViewDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
|
||
@objc protocol InteractivePostViewDelegate { | ||
func edit(_ post: AbstractPost) | ||
func view(_ post: AbstractPost) | ||
func stats(for post: AbstractPost) | ||
func publish(_ post: AbstractPost) | ||
func schedule(_ post: AbstractPost) | ||
func trash(_ post: AbstractPost) | ||
func restore(_ post: AbstractPost) | ||
func draft(_ post: AbstractPost) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Foundation | ||
|
||
@objc protocol PostActionSheetDelegate { | ||
func showActionSheet(_ post: AbstractPost, from view: UIView) | ||
} | ||
|
||
class PostActionSheet { | ||
|
||
weak var viewController: UIViewController? | ||
weak var interactivePostViewDelegate: InteractivePostViewDelegate? | ||
|
||
init(viewController: UIViewController, interactivePostViewDelegate: InteractivePostViewDelegate) { | ||
self.viewController = viewController | ||
self.interactivePostViewDelegate = interactivePostViewDelegate | ||
} | ||
|
||
func show(for post: Post, from view: UIView) { | ||
let actionSheetController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) | ||
|
||
actionSheetController.addCancelActionWithTitle(Titles.cancel) | ||
|
||
if post.status == BasePost.Status.publish || post.status == BasePost.Status.draft { | ||
actionSheetController.addDefaultActionWithTitle(Titles.stats) { [weak self] _ in | ||
self?.interactivePostViewDelegate?.stats(for: post) | ||
} | ||
} | ||
|
||
if post.status != BasePost.Status.draft { | ||
actionSheetController.addDefaultActionWithTitle(Titles.draft) { [weak self] _ in | ||
self?.interactivePostViewDelegate?.draft(post) | ||
} | ||
} | ||
|
||
let destructiveTitle = post.status == BasePost.Status.trash ? Titles.delete : Titles.trash | ||
actionSheetController.addDestructiveActionWithTitle(destructiveTitle) { [weak self] _ in | ||
self?.interactivePostViewDelegate?.trash(post) | ||
} | ||
|
||
if let presentationController = actionSheetController.popoverPresentationController { | ||
presentationController.permittedArrowDirections = .any | ||
presentationController.sourceView = view | ||
presentationController.sourceRect = view.bounds | ||
} | ||
|
||
viewController?.present(actionSheetController, animated: true) | ||
} | ||
|
||
struct Titles { | ||
static let cancel = NSLocalizedString("Cancel", comment: "Dismiss the post action sheet") | ||
static let stats = NSLocalizedString("Stats", comment: "Label for post stats option. Tapping displays statistics for a post.") | ||
static let draft = NSLocalizedString("Move to Draft", comment: "Label for an option that moves a post to the draft folder") | ||
static let delete = NSLocalizedString("Delete Permanently", comment: "Label for the delete post option. Tapping permanently deletes a post.") | ||
static let trash = NSLocalizedString("Move to Trash", comment: "Label for a option that moves a post to the trash folder") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.