diff --git a/WooCommerce/Classes/Extensions/UIButton+Helpers.swift b/WooCommerce/Classes/Extensions/UIButton+Helpers.swift index c8118559489..dccce5d365c 100644 --- a/WooCommerce/Classes/Extensions/UIButton+Helpers.swift +++ b/WooCommerce/Classes/Extensions/UIButton+Helpers.swift @@ -22,17 +22,17 @@ extension UIButton { let normalBackgroundImage = UIImage.renderBackgroundImage(fill: .primaryButtonBackground, border: .primaryButtonBorder) - .applyTintColorToiOS13(.primaryButtonBackground) + .withTintColor(.primaryButtonBackground) setBackgroundImage(normalBackgroundImage, for: .normal) let highlightedBackgroundImage = UIImage.renderBackgroundImage(fill: .primaryButtonDownBackground, border: .primaryButtonDownBorder) - .applyTintColorToiOS13(.primaryButtonDownBackground) + .withTintColor(.primaryButtonDownBackground) setBackgroundImage(highlightedBackgroundImage, for: .highlighted) let disabledBackgroundImage = UIImage.renderBackgroundImage(fill: .buttonDisabledBackground, border: .buttonDisabledBorder) - .applyTintColorToiOS13(.buttonDisabledBorder) // Use border as tint color since the background is clear + .withTintColor(.buttonDisabledBorder) // Use border as tint color since the background is clear setBackgroundImage(disabledBackgroundImage, for: .disabled) } @@ -54,17 +54,17 @@ extension UIButton { let normalBackgroundImage = UIImage.renderBackgroundImage(fill: .secondaryButtonBackground, border: .secondaryButtonBorder) - .applyTintColorToiOS13(.secondaryButtonBackground) + .withTintColor(.secondaryButtonBackground) setBackgroundImage(normalBackgroundImage, for: .normal) let highlightedBackgroundImage = UIImage.renderBackgroundImage(fill: .secondaryButtonDownBackground, border: .secondaryButtonDownBorder) - .applyTintColorToiOS13(.secondaryButtonDownBackground) + .withTintColor(.secondaryButtonDownBackground) setBackgroundImage(highlightedBackgroundImage, for: .highlighted) let disabledBackgroundImage = UIImage.renderBackgroundImage(fill: .buttonDisabledBackground, border: .buttonDisabledBorder) - .applyTintColorToiOS13(.buttonDisabledBackground) + .withTintColor(.buttonDisabledBackground) setBackgroundImage(disabledBackgroundImage, for: .disabled) } @@ -110,25 +110,25 @@ extension UIButton { let normalBackgroundImage = UIImage.renderBackgroundImage(fill: .tertiarySystemBackground, border: .secondaryButtonBorder) - .applyTintColorToiOS13(.tertiarySystemBackground) + .withTintColor(.tertiarySystemBackground) setBackgroundImage(normalBackgroundImage, for: .normal) let highlightedBackgroundImage = UIImage.renderBackgroundImage(fill: .secondaryButtonDownBackground, border: .secondaryButtonDownBorder) - .applyTintColorToiOS13(.secondaryButtonDownBackground) + .withTintColor(.secondaryButtonDownBackground) setBackgroundImage(highlightedBackgroundImage, for: .highlighted) let disabledBackgroundImage = UIImage.renderBackgroundImage(fill: .buttonDisabledBackground, border: .buttonDisabledBorder) - .applyTintColorToiOS13(.buttonDisabledBackground) + .withTintColor(.buttonDisabledBackground) setBackgroundImage(disabledBackgroundImage, for: .disabled) } /// Applies the Single-Color Icon Button Style: accent/accent dark tint color /// func applyIconButtonStyle(icon: UIImage) { - let normalImage = icon.applyTintColor(.accent) - let highlightedImage = icon.applyTintColor(.accentDark) + let normalImage = icon.withTintColor(.accent) + let highlightedImage = icon.withTintColor(.accentDark) setImage(normalImage, for: .normal) setImage(highlightedImage, for: .highlighted) tintColor = .accent diff --git a/WooCommerce/Classes/Extensions/UIImage+TintColor.swift b/WooCommerce/Classes/Extensions/UIImage+TintColor.swift deleted file mode 100644 index 2c9896d414e..00000000000 --- a/WooCommerce/Classes/Extensions/UIImage+TintColor.swift +++ /dev/null @@ -1,16 +0,0 @@ -import UIKit - -extension UIImage { - /// If iOS 13+, returns an image with a tint color applied to the original image. - /// For the image to react to Light/Dark mode changes in iOS 13+, we have to call the iOS 13+ API `withTintColor`. - /// - func applyTintColorToiOS13(_ color: UIColor) -> UIImage? { - return withTintColor(color) - } - - /// Returns an image with a tint color applied to the original image. - /// - func applyTintColor(_ color: UIColor) -> UIImage? { - return withTintColor(color) - } -} diff --git a/WooCommerce/Classes/Extensions/UIImage+Woo.swift b/WooCommerce/Classes/Extensions/UIImage+Woo.swift index 56e0cafb7b1..3657380c0cc 100644 --- a/WooCommerce/Classes/Extensions/UIImage+Woo.swift +++ b/WooCommerce/Classes/Extensions/UIImage+Woo.swift @@ -67,7 +67,7 @@ extension UIImage { static var cameraImage: UIImage { return UIImage.gridicon(.camera) .imageFlippedForRightToLeftLayoutDirection() - .applyTintColor(.placeholderImage)! + .withTintColor(.placeholderImage) } /// Product categories Icon @@ -329,7 +329,7 @@ extension UIImage { static var giftWithTopRightRedDotImage: UIImage { guard let image = UIImage.gridicon(.gift, size: CGSize(width: 24, height: 24)) // Applies a constant gray color that looks fine in both Light/Dark modes, since we are generating an image with multiple colors. - .applyTintColor(.gray(.shade30))? + .withTintColor(.gray(.shade30)) .imageWithTopRightDot(imageOrigin: CGPoint(x: 0, y: 2), finalSize: CGSize(width: 26, height: 26)) else { fatalError() diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index ff8fd50f05e..c23af19bdaa 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -136,7 +136,6 @@ 0236BCA425087B660043EB43 /* ProductFormRemoteActionUseCaseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0236BCA325087B660043EB43 /* ProductFormRemoteActionUseCaseTests.swift */; }; 023930612918F36400B2632F /* DomainSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023930602918F36400B2632F /* DomainSelectorView.swift */; }; 02393069291A065000B2632F /* DomainRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02393068291A065000B2632F /* DomainRowView.swift */; }; - 02396251239948470096F34C /* UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02396250239948470096F34C /* UIImage+TintColor.swift */; }; 023A059A24135F2600E3FC99 /* ReviewsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023A059824135F2600E3FC99 /* ReviewsViewController.swift */; }; 023A059B24135F2600E3FC99 /* ReviewsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 023A059924135F2600E3FC99 /* ReviewsViewController.xib */; }; 023D1DD124AB2D05002B03A3 /* ProductListSelectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023D1DD024AB2D05002B03A3 /* ProductListSelectorViewController.swift */; }; @@ -463,8 +462,8 @@ 035C6DEB273EA12D00F70406 /* SoftwareUpdateTypeProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 035C6DEA273EA12D00F70406 /* SoftwareUpdateTypeProperty.swift */; }; 035F2308275690970019E1B0 /* CardPresentModalConnectingFailedUpdatePostalCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 035F2307275690970019E1B0 /* CardPresentModalConnectingFailedUpdatePostalCode.swift */; }; 0366EAE12909A37800B51755 /* JustInTimeMessageAnnouncementCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0366EAE02909A37800B51755 /* JustInTimeMessageAnnouncementCardViewModel.swift */; }; - 036CA6F129229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036CA6F029229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift */; }; 036CA6B9291E8D4B00E4DF4F /* CardPresentModalPreparingReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036CA6B8291E8D4B00E4DF4F /* CardPresentModalPreparingReader.swift */; }; + 036CA6F129229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036CA6F029229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift */; }; 036F6EA6281847D5006D84F8 /* PaymentCaptureOrchestratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 036F6EA5281847D5006D84F8 /* PaymentCaptureOrchestratorTests.swift */; }; 0371C3682875E47B00277E2C /* FeatureAnnouncementCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0371C3672875E47B00277E2C /* FeatureAnnouncementCardViewModel.swift */; }; 0371C36A2876DBCA00277E2C /* FeatureAnnouncementCardViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0371C3692876DBCA00277E2C /* FeatureAnnouncementCardViewModelTests.swift */; }; @@ -2103,7 +2102,6 @@ 0236BCA325087B660043EB43 /* ProductFormRemoteActionUseCaseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductFormRemoteActionUseCaseTests.swift; sourceTree = ""; }; 023930602918F36400B2632F /* DomainSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainSelectorView.swift; sourceTree = ""; }; 02393068291A065000B2632F /* DomainRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainRowView.swift; sourceTree = ""; }; - 02396250239948470096F34C /* UIImage+TintColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+TintColor.swift"; sourceTree = ""; }; 023A059824135F2600E3FC99 /* ReviewsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewsViewController.swift; sourceTree = ""; }; 023A059924135F2600E3FC99 /* ReviewsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReviewsViewController.xib; sourceTree = ""; }; 023D1DD024AB2D05002B03A3 /* ProductListSelectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductListSelectorViewController.swift; sourceTree = ""; }; @@ -2433,8 +2431,8 @@ 035C6DEA273EA12D00F70406 /* SoftwareUpdateTypeProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoftwareUpdateTypeProperty.swift; sourceTree = ""; }; 035F2307275690970019E1B0 /* CardPresentModalConnectingFailedUpdatePostalCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPresentModalConnectingFailedUpdatePostalCode.swift; sourceTree = ""; }; 0366EAE02909A37800B51755 /* JustInTimeMessageAnnouncementCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JustInTimeMessageAnnouncementCardViewModel.swift; sourceTree = ""; }; - 036CA6F029229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndefiniteCircularProgressViewStyle.swift; sourceTree = ""; }; 036CA6B8291E8D4B00E4DF4F /* CardPresentModalPreparingReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPresentModalPreparingReader.swift; sourceTree = ""; }; + 036CA6F029229C9E00E4DF4F /* IndefiniteCircularProgressViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndefiniteCircularProgressViewStyle.swift; sourceTree = ""; }; 036F6EA5281847D5006D84F8 /* PaymentCaptureOrchestratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentCaptureOrchestratorTests.swift; sourceTree = ""; }; 0371C3672875E47B00277E2C /* FeatureAnnouncementCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureAnnouncementCardViewModel.swift; sourceTree = ""; }; 0371C3692876DBCA00277E2C /* FeatureAnnouncementCardViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureAnnouncementCardViewModelTests.swift; sourceTree = ""; }; @@ -7827,7 +7825,6 @@ 039D948E276113490044EF38 /* UIView+SuperviewConstraints.swift */, D88CA757237D1C27005D2F44 /* Ghost+Woo.swift */, 02784A02238B8BC800BDD6A8 /* UIView+Border.swift */, - 02396250239948470096F34C /* UIImage+TintColor.swift */, F997174323DC065900592D8E /* XLPagerStrip+AccessibilityIdentifier.swift */, 0215320A24231D5A003F2BBD /* UIStackView+Subviews.swift */, 029BFD4E24597D4B00FDDEEC /* UIButton+TitleAndImage.swift */, @@ -10395,7 +10392,6 @@ 45D1CF4723BAC89A00945A36 /* ProductTaxStatusListSelectorCommand.swift in Sources */, 453DBF9023882814006762A5 /* ProductImagesFlowLayout.swift in Sources */, 024DF30E23742A70006658FE /* AztecBoldFormatBarCommand.swift in Sources */, - 02396251239948470096F34C /* UIImage+TintColor.swift in Sources */, DEE6437826D8DAD900888A75 /* InProgressView.swift in Sources */, 0290E275238E4F8100B5C466 /* PaginatedListSelectorViewController.swift in Sources */, B958A7D628B5310100823EEF /* URLOpener.swift in Sources */,