-
Notifications
You must be signed in to change notification settings - Fork 112
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
Custom fields: Entry point logic in Product Details #14068
Custom fields: Entry point logic in Product Details #14068
Conversation
- If product already has custom fields, show it in the settings row. - If not, show it in "Add more details" action bottom sheet instead.
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
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.
I tested on simulator iPhone 15 Pro iOS 17.4 and confirmed that custom fields are available when editing and viewing readonly products of all types. I wonder if we should keep the custom field list non-editable if a product is readonly?
The navigation to the custom field list is not smooth due to the switch of the toolbar. I left a comment with more details and suggestions below.
WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormActionsFactory.swift
Outdated
Show resolved
Hide resolved
self?.navigationController?.setNavigationBarHidden(false, animated: true) | ||
}) | ||
) | ||
|
||
// Hide the navigation bar as `CustomFieldsListView` will create its own toolbar. | ||
navigationController?.setNavigationBarHidden(true, animated: true) |
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.
The animation causes unwanted jiggling between transitions, so setting animated
to false
might help.
For a smoother experience, please consider adding a separate type CustomFieldsListHostingController
and set the navigation items for the Save and Add buttons in that controller if it's editable. That way you can reuse the back button and avoid having a thinner chevron icon on this screen compared to the product form screen.
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.
Thanks, Paolo also raised something similar here #14059 (review) and I'll quote my reply:
I agree with that, though, and in hindsight it would've been more consistent to copy Blaze's method of creating navigation coordinator (
BlazeCampaignCreationCoordinator
) and use UIKit navigation still. While I do find that the experience of setting up navigation using SwiftUI'sNavigationStack
to be more intuitive and concise, it's also unfortunate that connecting it with UIKit's navigation isn't as smooth as possible.
An improvement here would be to refactor the navigation to use coordinator. Given what's already set up, this would be a decently sized task, so let's keep this for now. In the meanwhile I'll add a bit more things like turning off animation and making the back icon bolder, to make the back navigation look less odd.
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.
I added cfd6c47 to:
- remove animations
- make the back button thicker (good catch on this! This is also done in other parts of the code that uses the chevron)
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.
Something I'm not able to fix is that the placement of the back arrow has an extra leading padding in the list view, compared to the back button on the product details view or custom fields editor view:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-10-01.at.12.23.03.mp4
I tried a few things:
- adding negative padding: this works but make the target area smaller and taps don't register on the left side
- using
.topBarLeading
instead of.cancellationAction
as placement - using
ToolbarItemGroup
But none of them fixes the problem. It's odd because the back button generated automatically by SwiftUI (in the editor view) has the correct placement similar to UIKit's back button (in the product details view). It's just the the back button created with Toolbar
that has a different leading padding. This feels like a SwiftUI bug to me, and as it's a bit odd but not breaking functionality, I think we can keep it like that for now.
...ceTests/ViewRelated/Products/Actions Factory/ProductFormActionsFactory+VisibilityTests.swift
Outdated
Show resolved
Hide resolved
...ceTests/ViewRelated/Products/Actions Factory/ProductFormActionsFactory+VisibilityTests.swift
Outdated
Show resolved
Hide resolved
…ields list look smoother.
…during .edit, and not in .add or .readonly mode.
@itsmeichigo This is good for another review. Thanks especially for your mention about readonly mode. I've tested it by finding an Order and refunding it, then going to the refund details and tapping the product. Whether the product has custom fields or not, the custom fields row was not shown in the readonly-mode product details. Please also test this use case 🙏🏼 |
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.
Thanks for the updates Hafiz. I left a few comments following up with your latest changes below.
Regarding this response:
I agree with that, though, and in hindsight it would've been more consistent to copy Blaze's method of creating navigation coordinator (BlazeCampaignCreationCoordinator) and use UIKit navigation still. While I do find that the experience of setting up navigation using SwiftUI's NavigationStack to be more intuitive and concise, it's also unfortunate that connecting it with UIKit's navigation isn't as smooth as possible.
Can you explain why creating a coordinator would be relevant here? If you look closely at the BlazeCampaignCreationCoordinator
, the navigateToNativeCampaignCreation
method includes navigating to BlazeCampaignCreationFormHostingController
, which is also what I suggested above to create a hosting controller and let it manage the navigation items instead of using SwiftUI toolbar.
WooCommerce/Classes/ViewModels/Order Details/OrderDetailsViewModel.swift
Outdated
Show resolved
Hide resolved
WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift
Outdated
Show resolved
Hide resolved
I think we're talking about the same thing here but I didn't make it clear. I am aware that |
Thanks for catching that. The duplicate writing was a bug that I fixed in aa0ccd5 The behavior should now match Android (see screenshots in woocommerce/woocommerce-android#12682 ) We discussed about what to show in the subtitle here p1726234051128759/1726231756.826709-slack-C03L1NF1EA3 and for now ended up deciding to just show a fixed string "View and edit ..." . Thanks for the feedback, though, I'll put it in for further discussion and future iteration. |
Good for another review @itsmeichigo . thank you! |
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.
Thanks again for the updates Hafiz!
The thing is that the navigation to update here is not just for the navigation into the fields list, but also between fields list and field editor. So if I'm making hosting controller for the fields list, I'll need to do the same for the editor view, and at that point having a coordinator for all the custom fields context makes sense to me.
I see your point. I think it would be simpler to only make the hosting controller for the field list, and present the editor view modally. The custom field editing feels like a separate flow so I think it makes sense to present it as a modal.
Please give my suggestion some consideration - I'm approving this PR anyway to avoid blocking development for too long.
Version |
This is a good point and I see another flow in Order Details that's exactly like that. I'll work on this on a separate PR as I need to consolidate other work related to saving flow first, just to avoid conflicts. |
Closes: #14067
Please do not merge until base is trunk
Description
This PR adds various logic related to the Custom Fields entry point in Product Details.
Steps to reproduce
Testing information
I tested this in Simulator with iOS 17.5, with all different product types generated by Smooth Generator.
Screenshots
Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: