woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
258 stars 108 forks source link

Adds "Draft" label below the image on the product editing screen #4741

Closed iamgabrielma closed 2 years ago

iamgabrielma commented 2 years ago

Fixes #4544

Description

When editing a draft product we want to show a “Draft” label below the product image for consistency with the Android app:

completed

Changes

Draft products status Other product status
Screenshot 2021-08-09 at 14 50 05 Screenshot 2021-08-07 at 16 53 25
Landscape View
Screenshot 2021-08-09 at 14 50 15
Example of LTR screen & Localized strings
Screenshot 2021-08-09 at 15 05 49

I've added a new UILabel to ProductImagesHeaderTableViewCell.xib via the Interface Builder . Then within the ProductFormTableViewDataSource I'm performing a check to see if the product status is a draft, so this label will only be displayed if the product status is set to draft, no label will be shown otherwise.

I used existing styles that we use elsewhere in order to apply some sort of design, in this case using the same style as completed orders via applyStyle(for: .completed) seemed appropriate as fits the the style shown in the Android version of the app.

Work in progress:

Testing steps

Update release notes:

peril-woocommerce[bot] commented 2 years ago

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

peril-woocommerce[bot] commented 2 years ago

You can trigger an installable build for these changes by visiting CircleCI here.

iamgabrielma commented 2 years ago

With the latest commit the label is now more similar to its Android version (white text & grey background):

Screenshot 2021-08-09 at 18 50 27 Screenshot 2021-08-09 at 18 50 39
iamgabrielma commented 2 years ago

It seems the holder is using autoresizing masks instead of layout constraints, which seems to work initially, but it won't adapt to a different size when using accessibility font sizes or when the text is localized: It also doesn't look right on dark mode, but I'm not sure what the right colors should be for that, so I'd ping a designer for a UI review as well. For the layout, you probably want to set constraints to pin the view to the bottom leading edge (perhaps with some offset), but then let the holder grow as the text gets larger. For that, the label should use one of the dynamic fonts. Again, not sure of which one since I can't see this label in the design files, so maybe @woocommerce/mobile-designers can help with the exact font/color/dimensions here.

Thanks for the pointers! With the latest commit I believe to have resolved this by setting layout constraints indeed, rather than the existing autoresizing mask, for now I haven't modified the colours in dark mode as seems we're not modifying them neither in other places like Order statuses, however is true that the current grey/white combination is not great with a black background.

I'll give it a few more tests and wait for @woocommerce/mobile-designers feedback on styling the labels before requesting a new review

English label Localized Label Dark mode
autolayout-english autolayout-spanish Screenshot 2021-08-11 at 15 48 05
Garance91540 commented 2 years ago

Hi! @adamzelinski do you have some time to provide some designs for this issue this week?

iamgabrielma commented 2 years ago
Light mode Dark mode Dark mode with no images
update_20210813_Screenshot 2021-08-13 at 12 03 45 update_20210813_Screenshot 2021-08-13 at 12 03 24 update_20210813_Screenshot 2021-08-13 at 12 02 28

Latest changes:

Happy to make any further modifications!

ghost commented 2 years ago

Hi, @iamgabrielma here is the design for adding the draft tag. Can we please just use the current status pills we use next to the Product name.

Thanks!

Screen Shot 2021-08-13 at 4 05 27 pm
iamgabrielma commented 2 years ago

Thanks for the pointers @adamzelinski ! I have a question before proceeding: Would we consider to use an icon rather than a label with text?

While checking the current textfield that is being used for the product text I realized that there's already some code in place that is not being used and its purpose is precisely to show an icon when necessary.

This is the current structure of the field:

tttvcell-before

If we add the label with a text, this is how it would be:

tttvcell-after

By using one of Apple's Human Interface Guideline icons here rather than label and text we could avoid the clutter as well as potential problems like the length of a localized text overlapping or pushing the product name.

This is roughly how it would look like ( I used the .square.and.pencil icon, and applied a generic grey just for testing ):

Screenshot 2021-08-15 at 19 44 52

Let me know if that would make sense, or if we should stick to the original idea of using a label & text.

ghost commented 2 years ago

Hey @iamgabrielma, I think we should just use the label instead of an icon for now as it's an existing component we use to display the status of something. Definitely, something we will keep in mind though so thanks for looking into this :)

iamgabrielma commented 2 years ago

I'm moving this PR back to draft for the moment, as the latest changes require to redo it from zero 😅

At this stage I had to choices for the new implementation: To create a new cell, or reuse an existing one. TitleAndTextFieldTableViewCell seems to adapt well however this cell is already being used across the app and I can't modify it without affecting other places, so I opted to create a new cell for this: LabeledTextViewTableViewCell based on this one.

TODO:

iamgabrielma commented 2 years ago

Alright, I believe this should be good (or pretty close) now:

Draft Product Draft Product (Dark Mode) Localized No label
Simulator Screen Shot - iPhone 8 - 2021-08-29 at 15 52 14 Simulator Screen Shot - iPhone 8 - 2021-08-29 at 16 03 06 Simulator Screen Shot - iPhone 8 - 2021-08-29 at 16 04 59 Simulator Screen Shot - iPhone 8 - 2021-08-29 at 15 52 57

Let me know if needs further iterations 👍

ghost commented 2 years ago

@iamgabrielma looking good so far thanks! Just noticed a few little things to tweak.

Screen Shot 2021-08-30 at 2 06 32 pm
koke commented 2 years ago

Also, I'm seeing some auto layout errors:

2021-08-31 09:27:22.362020+0200 WooCommerce[1094:716536] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x282189180 H:[UIView:0x11e5b5a90]-(5)-[WooCommerce.EnhancedTextView:0x10c93c000'Wapuu Plush Toy']   (active)>",
    "<NSLayoutConstraint:0x28218a080 'UISV-spacing' H:[UIView:0x11e5b5a90]-(42)-[WooCommerce.EnhancedTextView:0x10c93c000'Wapuu Plush Toy']   (active)>"
)

It looks like there is a manual constraint for the spacing between the status holder and the product name (5), but the stack view that contains them would already manage the spacing between children, so there's a conflict there. You can remove that constraint and adjust the stack view's spacing to 5 to achieve the same effect.

iamgabrielma commented 2 years ago

Changes:

Screenshot 2021-09-04 at 18 41 14
iamgabrielma commented 2 years ago

Latest changes:

Screenshot 2021-09-24 at 14 25 36
iamgabrielma commented 2 years ago

One thing I noticed is that the text doesn't left-align with the other cells when there's no badge, but we can handle that as we solve the other alignment issue.

Thanks for the review! I'll be sure to add this bit to the new issue as well :D