-
Notifications
You must be signed in to change notification settings - Fork 121
Add product: Show celebratory view when the first product is created #9790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f736175
Add a new view for celebrating first product
itsmeichigo 4bb3afa
Add new dependency ConfettiSwiftUI
itsmeichigo 7512de0
Add UI for the celebratory screen
itsmeichigo a48d241
Add confetti for the celebratory view
itsmeichigo 488011e
Make view scrollable
itsmeichigo 7373cc7
Add hosting controller
itsmeichigo a1910b7
Handle sharing product
itsmeichigo e1e2c84
Show celebratory view when the first product is created
itsmeichigo d996f32
Add missing param isFirstProduct
itsmeichigo 47aeb4e
Add tracks
itsmeichigo 32784fb
Update release notes
itsmeichigo c563c0b
Update event name
itsmeichigo 7debb5f
Remove redundant change
itsmeichigo 699773e
Update wording for the celebratory view message
itsmeichigo 022a58f
Update wording for the dismiss button on the first product created view
itsmeichigo f335c3c
Merge branch 'feat/9785-celebrate-first-product' of https://github.co…
itsmeichigo be7f1ea
Merge branch 'trunk' into feat/9785-celebrate-first-product
itsmeichigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
WooCommerce.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
103 changes: 103 additions & 0 deletions
103
WooCommerce/Classes/ViewRelated/Products/Add Product/FirstProductCreatedView.swift
This file contains hidden or 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,103 @@ | ||
| import ConfettiSwiftUI | ||
| import SwiftUI | ||
|
|
||
| final class FirstProductCreatedHostingController: UIHostingController<FirstProductCreatedView> { | ||
| init(productURL: URL) { | ||
| super.init(rootView: FirstProductCreatedView()) | ||
| rootView.onSharingProduct = { [weak self] in | ||
| guard let self else { return } | ||
| SharingHelper.shareURL(url: productURL, from: self.view, in: self) | ||
| ServiceLocator.analytics.track(.firstCreatedProductShareTapped) | ||
| } | ||
| } | ||
|
|
||
| @available(*, unavailable) | ||
| required dynamic init?(coder aDecoder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| configureTransparentNavigationBar() | ||
| navigationItem.leftBarButtonItem = UIBarButtonItem(title: Localization.cancel, style: .plain, target: self, action: #selector(dismissView)) | ||
| ServiceLocator.analytics.track(.firstCreatedProductShown) | ||
| } | ||
|
|
||
| @objc | ||
| private func dismissView() { | ||
| dismiss(animated: true) | ||
| } | ||
| } | ||
|
|
||
| private extension FirstProductCreatedHostingController { | ||
| enum Localization { | ||
| static let cancel = NSLocalizedString("Dismiss", comment: "Button to dismiss the first created product screen") | ||
| } | ||
| } | ||
|
|
||
| /// Celebratory screen after creating the first product 🎉 | ||
| /// | ||
| struct FirstProductCreatedView: View { | ||
| var onSharingProduct: () -> Void = {} | ||
| @State private var confettiCounter: Int = 0 | ||
|
|
||
| var body: some View { | ||
| GeometryReader { proxy in | ||
| ScrollableVStack(spacing: Constants.verticalSpacing) { | ||
| Spacer() | ||
| Text(Localization.title) | ||
| .titleStyle() | ||
| Image(uiImage: .welcomeImage) | ||
| Text(Localization.message) | ||
| .secondaryBodyStyle() | ||
| .multilineTextAlignment(.center) | ||
| Button(Localization.shareAction, | ||
| action: onSharingProduct) | ||
| .buttonStyle(PrimaryButtonStyle()) | ||
| .padding(.horizontal) | ||
| Spacer() | ||
| } | ||
| .padding() | ||
| .confettiCannon(counter: $confettiCounter, | ||
| num: Constants.confettiCount, | ||
| rainHeight: proxy.size.height, | ||
| radius: proxy.size.width) | ||
| } | ||
| .onAppear { | ||
| confettiCounter += 1 | ||
| } | ||
| .background(Color(uiColor: .systemBackground)) | ||
| } | ||
| } | ||
|
|
||
| private extension FirstProductCreatedView { | ||
| enum Constants { | ||
| static let verticalSpacing: CGFloat = 40 | ||
| static let confettiCount: Int = 100 | ||
| } | ||
| enum Localization { | ||
| static let title = NSLocalizedString( | ||
| "First product created 🎉", | ||
| comment: "Title of the celebratory screen after creating the first product" | ||
| ) | ||
| static let message = NSLocalizedString( | ||
| "Congratulations! You're one step closer to getting the new store ready.", | ||
| comment: "Message on the celebratory screen after creating first product" | ||
| ) | ||
| static let shareAction = NSLocalizedString( | ||
| "Share Product", | ||
| comment: "Title of the action button to share the first created product" | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| struct FirstProductCreatedView_Previews: PreviewProvider { | ||
| static var previews: some View { | ||
| FirstProductCreatedView() | ||
| .environment(\.colorScheme, .light) | ||
|
|
||
| FirstProductCreatedView() | ||
| .environment(\.colorScheme, .dark) | ||
| .previewInterfaceOrientation(.landscapeLeft) | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Is it possible to pass
onCompletionblock toSharingHelperand dismiss this screen from it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't get a callback when the user submitted any content in the share sheet, so it's not technically possible to handle
onCompletion.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, OK. I thought we could use the
onCompletionparameter. https://github.com/woocommerce/woocommerce-ios/blob/trunk/WooCommerce/Classes/Tools/SharingHelper.swift#L29