-
Notifications
You must be signed in to change notification settings - Fork 109
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: Prepare list view and viewmodel to be reusable #13639
Custom Fields: Prepare list view and viewmodel to be reusable #13639
Conversation
📲 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.
Since the UI is essentially the same for the custom field row except for the line limit and the chevron, can we just use the same view but add a bool to update the view as needed?
I also left a few suggestions in the comments.
@@ -1,19 +1,28 @@ | |||
import SwiftUI | |||
|
|||
struct OrderCustomFieldsDetails: View { | |||
struct CustomFieldsDetails: View { |
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: Please rename the view to clarify that it's a view. The postfix View
is usually used for this.
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.
Sure, updated in 27ec9b5
@Environment(\.presentationMode) var presentationMode | ||
|
||
let customFields: [OrderCustomFieldsViewModel] | ||
let viewEditCustomFieldsInProductsAndOrdersEnabled: Bool |
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.
Super nit: the naming is a bit verbose making it hard to follow. How about isEditable
?
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.
Done in e23c6d2
.padding([.top, .bottom], Constants.hStackPadding) | ||
.padding(.horizontal, Constants.hStackPadding) |
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: this can be combined into .padding(Constants.hStackPadding)
to set the same padding for all edges.
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.
Updated as part of 1706a3f
.padding([.top, .bottom], Constants.hStackPadding) | ||
.padding(.horizontal, Constants.hStackPadding) |
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.
Same comment as above about padding.
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.
Updated as part of 1706a3f
private extension EditableCustomFieldRow { | ||
enum Constants { | ||
static let spacing: CGFloat = 8 | ||
static let vStackPadding: CGFloat = 16 | ||
static let hStackPadding: CGFloat = 10 | ||
static let height: CGFloat = 64 | ||
} | ||
} |
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: instead of duplicating the constants, you can bring the enum to CustomFieldsDetails
extension and reuse it for both CustomFieldRow
and EditableCustomFieldRow
.
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.
Updated as part of 1706a3f
That makes sense. I was thinking that it's simpler to reason about when there's a separate view, instead of having to check for multiple bool checks, but I think in this case it's not too complicated. Added in 1706a3f |
* trunk: (115 commits) Fix typo in System Status Report Add barcode scanner icon update to 20.1 release notes Update to SF Symbols barcode scanner icon Rename text field variables and improve comments with the explanation Update naming Remove unnecessary keyboard focusing on PercentageView appear Revert unnecessary naming changes Added comment for checkIfNavigationBarShouldPop Fix unit test failure Fix unit test failures Check if navigation item is exact one Remove parameters for checkIfNavigationBarShouldPop Call super.shouldPopOnBackButton() Add order discard confirmation to 20.1 release notes Bump version number Update metadata translations Update app translations – `Localizable.strings` Fix compiler merge issues Fix compiler merge issues Keep ItemListView in the same state when doing pull to refresh ...
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 - LGTM
Part of: #13493
Description
This PR mainly updates
OrderCustomFieldsDetails
and its related viewmodel to beCustomFieldsDetails
by renaming them, moving the path out of Order, and generally making it to be usable by Products later on, too.Additionally this also adds
EditableCustomFieldRow
, which is a new design for each custom field row, gated behind feature flag. It's intentionally similar to the original field, just limiting the value to three lines max, and adding a chevron. The design is still under discussion so it doesn't need too much attention for now, it just needs to be there for future uses.Steps to reproduce
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: