Skip to content
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

Products: Grouping design for product creation type sheet #12273

Merged
merged 13 commits into from
Jun 11, 2024

Conversation

hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented Mar 13, 2024

Closes: #11361, #11211

Description

This PR is the second part of the product type creation bottom sheet.

Specifically, it now groups the "Manual product creation" into three categories:

  1. Standard
    • Physical product
    • Virtual product
    • Variable product
  2. Subscription
    • Simple subscription
    • Variable subscription
  3. Other
    • Grouped product
    • External product

Testing instructions

  1. Go to Products tab,
  2. Create new product,
  3. Ensure that the bottom sheet demo matches the video below, and with the design video on Products: Improve the bottom sheet for product type selection #11361 (comment)
  4. Additionally, test with a site that doesn't have subscriptions support. Ensure that the subscriptions category and its product types are not shown.

Video

Simulator.Screen.Recording.-.iPhone.15.-.2024-03-14.at.19.46.45.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 13, 2024

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr12273-f1b37ed
Version19.0
Bundle IDcom.automattic.alpha.woocommerce
Commitf1b37ed
App Center BuildWooCommerce - Prototype Builds #9549
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@hafizrahman hafizrahman added this to the 17.8 milestone Mar 14, 2024
@hafizrahman hafizrahman added the feature: add/edit products Related to adding or editing products. label Mar 14, 2024
@hafizrahman hafizrahman force-pushed the feat/11361-product-creation-grouping branch from 5ce53b1 to 65acb1d Compare March 14, 2024 13:07
@@ -77,13 +76,13 @@ public enum BottomSheetProductType: Hashable, Identifiable {
case .simple(let isVirtual):
if isVirtual {
return NSLocalizedString(
"bottomSheetProductType.simpleVirtual.title",
value: "Simple virtual product",
"bottomSheetProductType.simpleVirtualProduct.title",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have to also change the key for the string value change to apply. Not completely sure why, but without doing this, the string change doesn't appear in the simulator.

@hafizrahman hafizrahman marked this pull request as ready for review March 14, 2024 13:13
@iamgabrielma iamgabrielma modified the milestones: 17.8, 17.9 Mar 15, 2024
@itsmeichigo itsmeichigo self-assigned this Mar 18, 2024
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

The update looks good! I wonder if we should also replace the bottom sheet for the case where AI is not eligible to use the same sheet but without the AI option. Currently, when testing for such sites, I still see the old sheet. Please feel free to file an issue for this as an enhancement separately though.

I left a few suggestions for code improvements below, but I'm pre-approving this PR.

.padding(.bottom, Constants.categoryVerticalSpacing)
.padding(.horizontal, Constants.horizontalSpacing)

ForEach(productTypes, id: \.self) { productType in
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: BottomSheetProductType is already conforming to Identifiable, so we can omit the id parameter here.

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 in 34442d1

Comment on lines +26 to +28
Text(category.label)
.subheadlineStyle()
.textCase(.uppercase)
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL about the .textCase modifier. Normally I would simply use Text(category.label.uppercased) to transform the string directly.

ForEach(productTypes, id: \.self) { productType in
HStack(alignment: .top, spacing: Constants.margin) {
Image(uiImage: productType.actionSheetImage.withRenderingMode(.alwaysTemplate))
.font(.title3)
Copy link
Contributor

Choose a reason for hiding this comment

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

The modifier font will work only with system images. With custom assets, you might need to set the size explicitly with theframe modifier. To make it scalable, you'd need to get the scale from ScaleMetric property wrapper.

As you see above, the custom icons are not scaled in large font sizes.

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 in 34442d1

}
}
}
}

private extension ManualProductTypeOptions {
enum Constants {
// List of product categories. The ordering dictates how the categories are displayed.
static let productCategoriesOrder: [BottomSheetProductType.ProductCreationCategory] = [.standard, .subscription, .other]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: You can omit this if you make BottomSheetProductType.ProductCreationCategory conform to CaseIterable. Then you can get the list of cases in the order declared in the enum with BottomSheetProductType.ProductCreationCategory.allCases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in f1b37ed also this comment is related to this #12273 (comment)

Comment on lines 203 to 212
var productCreationCategory: ProductCreationCategory {
switch self {
case .simple, .blank, .variable:
return .standard
case .subscription, .variableSubscription:
return .subscription
case .custom, .grouped, .affiliate:
return .other
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: you can avoid having to filter and match the category types if you replace this with a helper variable in ProductCreationCategory instead:

extension ProductCreationCategory {
    var productTypes: BottomSheetProductType {
        // return the respective types for each category.
    }
}

Then in ManualProductTypeOptions you can get rid of groupedProductTypes and build the view by directly traversing the categories:

ForEach(BottomSheetProductType.ProductCreationCategory.allCases, id: \.self) { category in
     ForEach(category.productTypes) { type in
          // TODO
     }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some refactor on f1b37ed based on your ideas here, but it doesn't fully implement your suggestion as I understood it.

The main thing is that the ManualProductTypeOptions receives supportedProductTypes that contains only the supported product types (calculated in presentActionSheetWithAI() in AddProductCoordinator), so filtering things based on it is inevitable.

@bozidarsevo bozidarsevo modified the milestones: 17.9, 18.0 Mar 21, 2024
@jaclync jaclync modified the milestones: 18.0, 18.1 Mar 29, 2024
@pmusolino pmusolino modified the milestones: 18.1, 18.2 Apr 5, 2024
@itsmeichigo itsmeichigo modified the milestones: 18.2, 18.3 Apr 12, 2024
@rachelmcr rachelmcr modified the milestones: 18.3, 18.4 Apr 19, 2024
@rachelmcr
Copy link
Contributor

@hafizrahman Is this PR being actively worked on? Just checking because it has been moved to a future milestone a handful of times already. (I'll go ahead and move it to the next milestone for now.)

@rachelmcr rachelmcr modified the milestones: 18.4, 18.5 Apr 26, 2024
@hafizrahman
Copy link
Contributor Author

@rachelmcr this was a hack week project that I didn't end up having enough time to complete, then got deprioritized over other tasks. Thanks for the reminder, I'll set as draft for now and come back to it next hack week.

@hafizrahman hafizrahman marked this pull request as draft April 26, 2024 10:37
@iamgabrielma iamgabrielma modified the milestones: 18.5, 18.6 May 3, 2024
@joshheald joshheald removed this from the 18.6 milestone May 10, 2024
@itsmeichigo
Copy link
Contributor

@hafizrahman It would be great to wrap this PR for this HACK week as well, it has been around for quite a while.

@hafizrahman hafizrahman marked this pull request as ready for review June 11, 2024 09:32
@hafizrahman hafizrahman added this to the 19.1 milestone Jun 11, 2024
@hafizrahman hafizrahman merged commit 2599216 into trunk Jun 11, 2024
23 checks passed
@hafizrahman hafizrahman deleted the feat/11361-product-creation-grouping branch June 11, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: add/edit products Related to adding or editing products.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Products: Improve the bottom sheet for product type selection
9 participants