Skip to content

Commit ec8d76b

Browse files
committed
Add preview option in action sheet
1 parent bc7b9f4 commit ec8d76b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
229229
}
230230
}
231231

232+
if viewModel.canSaveAsDraft() || viewModel.productModel.status == .draft {
233+
actionSheet.addDefaultActionWithTitle(ActionSheetStrings.previewProduct) { [weak self] _ in
234+
if self?.viewModel.canSaveAsDraft() == true || self?.viewModel.hasUnsavedChanges() == true {
235+
self?.saveProduct(status: .draft) { result in
236+
if result.isSuccess {
237+
self?.displayProductPreview()
238+
}
239+
}
240+
} else {
241+
self?.displayProductPreview()
242+
}
243+
}
244+
}
245+
232246
/// The "View product in store" action will be shown only if the product is published.
233247
if viewModel.canViewProductInStore() {
234248
actionSheet.addDefaultActionWithTitle(ActionSheetStrings.viewProduct) { [weak self] _ in
@@ -780,6 +794,9 @@ private extension ProductFormViewController {
780794
SharingHelper.shareURL(url: url, title: product.name, from: view, in: self)
781795
}
782796

797+
func displayProductPreview() {
798+
}
799+
783800
func duplicateProduct() {
784801
showSavingProgress(.duplicate)
785802
viewModel.duplicateProduct(onCompletion: { [weak self] result in
@@ -1557,6 +1574,8 @@ private enum Localization {
15571574
private enum ActionSheetStrings {
15581575
static let saveProductAsDraft = NSLocalizedString("Save as draft",
15591576
comment: "Button title to save a product as draft in Product More Options Action Sheet")
1577+
static let previewProduct = NSLocalizedString("Preview",
1578+
comment: "Button title to open preview link for a product in Product More Options Action Sheet")
15601579
static let viewProduct = NSLocalizedString("View Product in Store",
15611580
comment: "Button title View product in store in Edit Product More Options Action Sheet")
15621581
static let share = NSLocalizedString("Share", comment: "Button title Share in Edit Product More Options Action Sheet")

0 commit comments

Comments
 (0)