-
Notifications
You must be signed in to change notification settings - Fork 121
Store creation M2: show store summary after store creation success #8109
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 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
94dbed0
Add image asset for store summary.
jaclync 89aabe1
Create `StoreCreationSummaryView` for store summary screen.
jaclync d21814b
Create a site after continuing with the domain selector screen and sh…
jaclync 002847d
Move post-domain logic to a separate function.
jaclync 10212ea
Actually present the site creation alert.
jaclync 972f47d
StoreCreationSummaryView: update comments.
jaclync ab890bf
Fix lint warning on trailing spaces.
jaclync 4cd296e
Save `stores` for site creation action.
jaclync 111fee4
IconTests: update test case name following the format.
jaclync b0b8bf9
StoreCreationSummaryView: mark `init?(coder aDecoder: NSCoder)` as un…
jaclync 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
153 changes: 153 additions & 0 deletions
153
WooCommerce/Classes/Authentication/Store Creation/StoreCreationSummaryView.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,153 @@ | ||
| import SwiftUI | ||
|
|
||
| /// Hosting controller that wraps the `StoreCreationSummaryView`. | ||
| final class StoreCreationSummaryHostingController: UIHostingController<StoreCreationSummaryView> { | ||
| private let onContinueToPayment: () -> Void | ||
|
|
||
| init(viewModel: StoreCreationSummaryViewModel, | ||
| onContinueToPayment: @escaping () -> Void) { | ||
| self.onContinueToPayment = onContinueToPayment | ||
| super.init(rootView: StoreCreationSummaryView(viewModel: viewModel)) | ||
|
|
||
| rootView.onContinueToPayment = { [weak self] in | ||
| self?.onContinueToPayment() | ||
| } | ||
| } | ||
|
|
||
| required dynamic init?(coder aDecoder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| configureNavigationBarAppearance() | ||
| } | ||
|
|
||
| /// Shows a transparent navigation bar without a bottom border. | ||
| func configureNavigationBarAppearance() { | ||
| navigationItem.title = Localization.title | ||
|
|
||
| let appearance = UINavigationBarAppearance() | ||
| appearance.configureWithTransparentBackground() | ||
| appearance.backgroundColor = .systemBackground | ||
|
|
||
| navigationItem.standardAppearance = appearance | ||
| navigationItem.scrollEdgeAppearance = appearance | ||
| navigationItem.compactAppearance = appearance | ||
| } | ||
| } | ||
|
|
||
| private extension StoreCreationSummaryHostingController { | ||
| enum Localization { | ||
| static let title = NSLocalizedString("My store", comment: "Title of the store creation summary screen.") | ||
| } | ||
| } | ||
|
|
||
| /// View model for `StoreCreationSummaryView`. | ||
| struct StoreCreationSummaryViewModel { | ||
| /// The name of the store. | ||
| let storeName: String | ||
| /// The URL slug of the store. | ||
| let storeSlug: String | ||
| } | ||
|
|
||
| /// Displays a summary of the store creation flow with the store information (e.g. store name, store slug). | ||
| struct StoreCreationSummaryView: View { | ||
| /// Set in the hosting controller. | ||
| var onContinueToPayment: (() -> Void) = {} | ||
|
|
||
| private let viewModel: StoreCreationSummaryViewModel | ||
|
|
||
| init(viewModel: StoreCreationSummaryViewModel) { | ||
| self.viewModel = viewModel | ||
| } | ||
|
|
||
| var body: some View { | ||
| VStack(alignment: .leading, spacing: 0) { | ||
| ScrollView { | ||
| VStack(alignment: .leading, spacing: Layout.spacingBetweenSubtitleAndStoreInfo) { | ||
| // Header label. | ||
| Text(Localization.subtitle) | ||
| .foregroundColor(Color(.secondaryLabel)) | ||
| .bodyStyle() | ||
|
|
||
| // Store info. | ||
| VStack(alignment: .leading, spacing: 0) { | ||
| // Image. | ||
| HStack { | ||
| Spacer() | ||
| Image(uiImage: .storeSummaryImage) | ||
| Spacer() | ||
| } | ||
| .background(Color(.systemColor(.systemGray6))) | ||
|
|
||
| VStack { | ||
| VStack(alignment: .leading, spacing: Layout.spacingBetweenStoreNameAndDomain) { | ||
| // Store name. | ||
| Text(viewModel.storeName) | ||
| .headlineStyle() | ||
| // Store URL slug. | ||
| Text(viewModel.storeSlug) | ||
| .foregroundColor(Color(.secondaryLabel)) | ||
| .bodyStyle() | ||
| } | ||
| } | ||
| .padding(Layout.storeInfoPadding) | ||
| } | ||
| .cornerRadius(Layout.storeInfoCornerRadius) | ||
| .overlay( | ||
| RoundedRectangle(cornerRadius: Layout.storeInfoCornerRadius) | ||
| .stroke(Color(.separator), lineWidth: 0.5) | ||
| ) | ||
| } | ||
| .padding(Layout.defaultPadding) | ||
| } | ||
|
|
||
| // Continue button. | ||
| Group { | ||
| Divider() | ||
| .frame(height: Layout.dividerHeight) | ||
| .foregroundColor(Color(.separator)) | ||
| Button(Localization.continueButtonTitle) { | ||
| onContinueToPayment() | ||
| } | ||
| .buttonStyle(PrimaryButtonStyle()) | ||
| .padding(Layout.defaultButtonPadding) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private extension StoreCreationSummaryView { | ||
| enum Layout { | ||
| static let spacingBetweenSubtitleAndStoreInfo: CGFloat = 40 | ||
| static let spacingBetweenStoreNameAndDomain: CGFloat = 4 | ||
| static let defaultHorizontalPadding: CGFloat = 16 | ||
| static let dividerHeight: CGFloat = 1 | ||
| static let defaultPadding: EdgeInsets = .init(top: 16, leading: 16, bottom: 16, trailing: 16) | ||
| static let defaultButtonPadding: EdgeInsets = .init(top: 10, leading: 16, bottom: 10, trailing: 16) | ||
| static let storeInfoPadding: EdgeInsets = .init(top: 16, leading: 16, bottom: 16, trailing: 16) | ||
| static let storeInfoCornerRadius: CGFloat = 8 | ||
| } | ||
|
|
||
| enum Localization { | ||
| static let subtitle = NSLocalizedString( | ||
| "Your store will be created based on the options of your choice!", | ||
| comment: "Subtitle of the store creation summary screen.") | ||
| static let continueButtonTitle = NSLocalizedString( | ||
| "Continue to Payment", | ||
| comment: "Title of the button on the store creation summary view to continue to payment." | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| struct StoreCreationSummaryView_Previews: PreviewProvider { | ||
| static var previews: some View { | ||
| StoreCreationSummaryView(viewModel: | ||
| .init(storeName: "Fruity shop", storeSlug: "fruityshop.com")) | ||
| StoreCreationSummaryView(viewModel: | ||
| .init(storeName: "Fruity shop", storeSlug: "fruityshop.com")) | ||
| .preferredColorScheme(.dark) | ||
| } | ||
| } | ||
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
15 changes: 15 additions & 0 deletions
15
WooCommerce/Resources/Images.xcassets/store-summary.imageset/Contents.json
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,15 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "store-summary.pdf", | ||
| "idiom" : "universal" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| }, | ||
| "properties" : { | ||
| "preserves-vector-representation" : true | ||
| } | ||
| } |
Binary file added
BIN
+568 KB
WooCommerce/Resources/Images.xcassets/store-summary.imageset/store-summary.pdf
Binary file not shown.
Oops, something went wrong.
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.
Nit: we can also add an
@availableattribute here to signal the compiler in compile-time that this initializer is not ready for use: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.
Nice, updated in b0b8bf9