Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
-----
- [*] Add Products: A new view is display to celebrate when the first product is created in a store. [https://github.com/woocommerce/woocommerce-ios/pull/9790]
- [*] Product form: a share action is shown in the navigation bar if the product can be shared and no more than one action is displayed, in addition to the more menu > Share. [https://github.com/woocommerce/woocommerce-ios/pull/9789]

- [*] My Store: A new button to share the current store is added on the top right of the screen. [https://github.com/woocommerce/woocommerce-ios/pull/9796]

13.7
-----
- [Internal] Adds guidance for new Customs rule when shipping to some EU countries. [https://github.com/woocommerce/woocommerce-ios/pull/9715]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ final class DashboardViewController: UIViewController {
return view
}()

private lazy var shareButton = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(shareStore))

/// Stores an animator for showing/hiding the header view while there is an animation in progress
/// so we can interrupt and reverse if needed
private var headerAnimator: UIViewPropertyAnimator?
Expand Down Expand Up @@ -303,6 +305,7 @@ private extension DashboardViewController {
configureTitle()
configureContainerStackView()
configureHeaderStackView()
configureShareButton()
}

func configureTabBarItem() {
Expand All @@ -315,6 +318,24 @@ private extension DashboardViewController {
navigationItem.title = Localization.title
}

func configureShareButton() {
// Only show share button if the site is public.
guard let site = ServiceLocator.stores.sessionManager.defaultSite, site.isPublic else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Moving this to view model will allow us to unit test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this in 1ec15ac 👍

return
}
navigationItem.rightBarButtonItem = shareButton
}

@objc
func shareStore() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This logic could be moved to view model as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updated in 1ec15ac.

guard let site = ServiceLocator.stores.sessionManager.defaultSite,
let url = URL(string: site.url) else {
return
}
SharingHelper.shareURL(url: url, from: shareButton, in: self)
ServiceLocator.analytics.track(.dashboardShareStoreButtonTapped)
}

func configureContainerStackView() {
containerStackView.axis = .vertical
containerView.addSubview(containerStackView)
Expand Down