Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Dec 3, 2025

Closes WOOMOB-1305

Description

This PR addresses iOS17 deprecation warnings in account and authentication flows, as well as settings. We address two types:

  • Usage of the one of the textView delegates
  • UI updates on trait changes

Changes

  • For trait changes, we just move to the new UITrait API
  • For the textView delegate, we update it with the recommendation. Looking at the UIKit.UITextView interface we've lost URL as a parameter, and the return type is no longer Bool but optional UIAction?, so we have to return nil to prevent the default action.
   @available(iOS, introduced: 10.0, deprecated: 17.0, message: "Replaced by primaryActionForTextItem: and menuConfigurationForTextItem: for additional customization options.")
    optional func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool 

...

    /**
     * Asks the delegate for the action to be performed when interacting with a text item. If a nil action is provided, the text view
     * will request a menu to be presented on primary action if possible.
     *
     * @param textView  The text view requesting the primary action.
     * @param textItem  The text item for performing said action.
     * @param defaultAction The default action for the text item. Return this to perform the default action.
     *
     * @return Return a UIAction to be performed when the text item is interacted with. Return @c nil to prevent the action from being performed.
     */
    @available(iOS 17.0, *)
    optional func textView(_ textView: UITextView, primaryActionFor textItem: UITextItem, defaultAction: UIAction) -> UIAction?

Test Steps

  • Unlock the orientation lock in your device
  • In the app, observe the main dashboard/tab bar responds normally when the device is set portrait/landscape
  • Go to Menu > Settings > Tap Privacy, and the web link. Should work normally.
  • Go to Menu > Settings > WooCommerce > Tap Work with us. Should work normally.
  • For login cases I wasn't quite sure which flows to test, the affected files for the trait orientations are "role error", "account miss-match", and "error on Unified Login flow". I tried a couple of incorrect logins from the smoke test list and worked fine (ie: incorrect credentials, wrong account)

Screenshots

ScreenRecording_12-04-2025.privacy.480p.mov

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 3, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr16427-de08354
Version23.8
Bundle IDcom.automattic.alpha.woocommerce
Commitde08354
Installation URL3ooih91h31r48
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma added type: task An internally driven task. type: technical debt Represents or solves tech debt of the project. labels Dec 4, 2025
@iamgabrielma iamgabrielma added this to the 23.9 milestone Dec 4, 2025
@iamgabrielma iamgabrielma marked this pull request as ready for review December 4, 2025 03:13
Copy link
Contributor

@RafaelKayumov RafaelKayumov left a comment

Choose a reason for hiding this comment

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

LGTM. Left only 1 nit comment

Comment on lines 105 to 111
registerForTraitChanges([UITraitVerticalSizeClass.self, UITraitUserInterfaceStyle.self]) { (self: Self, _) in
// Hide image in compact height sizes (e.g. landscape iPhones)
// With limited space, text description should have higher priority
self.imageView.isHidden = self.traitCollection.verticalSizeClass == .compact

self.updateViewAppearances()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Should we separately register for UITraitVerticalSizeClass.self and UITraitUserInterfaceStyle.self? Also should we check against the previous trait for the UITraitUserInterfaceStyle as it was done in the previous implementation?

registerForTraitChanges([UITraitVerticalSizeClass.self]) { (self: Self, _) in
    // Hide image in compact height sizes (e.g. landscape iPhones)
    // With limited space, text description should have higher priority
    self.imageView.isHidden = self.traitCollection.verticalSizeClass == .compact

    self.updateViewAppearances()
}

registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, previousTraitCollection) in
    gaurd previousTraitCollection.hasDifferentColorAppearance(comparedTo: traitCollection) else  {
        return
    }

    // handle dynamic color appearance changes.
    updateViewAppearances()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point, my change would slightly change the implementation, not just refactor from the old API. Updated de08354

@iamgabrielma iamgabrielma merged commit 6abd2f2 into trunk Dec 5, 2025
13 checks passed
@iamgabrielma iamgabrielma deleted the task/wcios17-trait-collections-wp-libraries branch December 5, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task. type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants