diff --git a/WooCommerce/Classes/Extensions/UIButton+TitleAndImage.swift b/WooCommerce/Classes/Extensions/UIButton+TitleAndImage.swift deleted file mode 100644 index 85eee45d77c..00000000000 --- a/WooCommerce/Classes/Extensions/UIButton+TitleAndImage.swift +++ /dev/null @@ -1,22 +0,0 @@ -import UIKit - -extension UIButton { - /// Sets a spacing between button title and image. - /// - Parameters: - /// - spacing: spacing between the title and image. - /// - layoutDirection: layout direction of the button (LTR/RTL). - func distributeTitleAndImage(spacing: CGFloat, layoutDirection: UIUserInterfaceLayoutDirection = UIApplication.shared.userInterfaceLayoutDirection) { - let insetAmount = spacing / 2.0 - - switch layoutDirection { - case .rightToLeft: - imageEdgeInsets = UIEdgeInsets(top: imageEdgeInsets.top, left: insetAmount, bottom: imageEdgeInsets.bottom, right: -insetAmount) - titleEdgeInsets = UIEdgeInsets(top: titleEdgeInsets.top, left: -insetAmount, bottom: titleEdgeInsets.bottom, right: insetAmount) - contentEdgeInsets = UIEdgeInsets(top: contentEdgeInsets.top, left: -insetAmount, bottom: contentEdgeInsets.bottom, right: -insetAmount) - default: - imageEdgeInsets = UIEdgeInsets(top: imageEdgeInsets.top, left: -insetAmount, bottom: imageEdgeInsets.bottom, right: insetAmount) - titleEdgeInsets = UIEdgeInsets(top: titleEdgeInsets.top, left: insetAmount, bottom: titleEdgeInsets.bottom, right: -insetAmount) - contentEdgeInsets = UIEdgeInsets(top: contentEdgeInsets.top, left: insetAmount, bottom: contentEdgeInsets.bottom, right: insetAmount) - } - } -} diff --git a/WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift b/WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift index 41a4f1a85dd..17b40baf328 100644 --- a/WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift +++ b/WooCommerce/Classes/ViewRelated/CardPresentPayments/CardPresentPaymentsModalViewController.swift @@ -293,7 +293,9 @@ private extension CardPresentPaymentsModalViewController { auxiliaryButton.setAttributedTitle(viewModel.auxiliaryAttributedButtonTitle, for: .normal) auxiliaryButton.setImage(viewModel.auxiliaryButtonimage, for: .normal) if viewModel.auxiliaryButtonimage != nil { - auxiliaryButton.distributeTitleAndImage(spacing: 8.0) + var config = UIButton.Configuration.plain() + config.imagePadding = Constants.buttonTitleAndImageSpacing + auxiliaryButton.configuration = config } view.layoutIfNeeded() } @@ -389,6 +391,7 @@ private extension CardPresentPaymentsModalViewController { static let extraInfoCustomInsets = UIEdgeInsets(top: 12, left: 10, bottom: 12, right: 10) static let modalHeight: CGFloat = 382 static let modalWidth: CGFloat = 280 + static let buttonTitleAndImageSpacing: CGFloat = 8 } } diff --git a/WooCommerce/Classes/ViewRelated/Containers/BottomButtonContainer/BottomButtonContainerView.swift b/WooCommerce/Classes/ViewRelated/Containers/BottomButtonContainer/BottomButtonContainerView.swift index c128d63f62e..caf89590761 100644 --- a/WooCommerce/Classes/ViewRelated/Containers/BottomButtonContainer/BottomButtonContainerView.swift +++ b/WooCommerce/Classes/ViewRelated/Containers/BottomButtonContainer/BottomButtonContainerView.swift @@ -71,14 +71,14 @@ private extension BottomButtonContainerView { case .primary: button.applyPrimaryButtonStyle() case .link: + if let image = viewModel.image { + var configuration = UIButton.Configuration.plain() + button.setImage(image, for: .normal) + configuration.imagePadding = Constants.buttonTitleAndImageSpacing + button.configuration = configuration + } button.applyLinkButtonStyle() button.contentHorizontalAlignment = .leading - button.contentEdgeInsets = .zero - } - - if let image = viewModel.image { - button.setImage(image, for: .normal) - button.distributeTitleAndImage(spacing: Constants.buttonTitleAndImageSpacing) } } diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerInfoTableViewCell.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerInfoTableViewCell.swift index 73a78a7f556..70549bb83f5 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerInfoTableViewCell.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerInfoTableViewCell.swift @@ -125,8 +125,10 @@ private extension CustomerInfoTableViewCell { addButton.setImage(.plusImage, for: .normal) addButton.contentHorizontalAlignment = .leading addButton.contentVerticalAlignment = .bottom - addButton.contentEdgeInsets = .zero - addButton.distributeTitleAndImage(spacing: Constants.buttonTitleAndImageSpacing) + var configuration = UIButton.Configuration.plain() + configuration.contentInsets = .init(.zero) + configuration.imagePadding = Constants.buttonTitleAndImageSpacing + addButton.configuration = configuration addButton.addTarget(self, action: #selector(addButtonTapped), for: .touchUpInside) } diff --git a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift index 2ace3ee219e..841c5a275d6 100644 --- a/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift +++ b/WooCommerce/Classes/ViewRelated/Orders/Order Details/Customer Section/CustomerNoteTableViewCell.swift @@ -130,8 +130,8 @@ private extension CustomerNoteTableViewCell { addButton.contentVerticalAlignment = .bottom var configuration = UIButton.Configuration.plain() configuration.contentInsets = .init(.zero) + configuration.imagePadding = Constants.buttonTitleAndImageSpacing addButton.configuration = configuration - addButton.distributeTitleAndImage(spacing: Constants.buttonTitleAndImageSpacing) addButton.addTarget(self, action: #selector(addButtonTapped), for: .touchUpInside) } diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 933598a1846..79128583ed9 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -307,7 +307,6 @@ 0298431225936DFC00979CAE /* ShippingLabelsTopBannerFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0298431125936DFC00979CAE /* ShippingLabelsTopBannerFactoryTests.swift */; }; 029A9C672535873000BECEC5 /* AppCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029A9C662535873000BECEC5 /* AppCoordinatorTests.swift */; }; 029B0F57234197B80010C1F3 /* ProductSearchUICommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029B0F56234197B80010C1F3 /* ProductSearchUICommand.swift */; }; - 029BFD4F24597D4B00FDDEEC /* UIButton+TitleAndImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029BFD4E24597D4B00FDDEEC /* UIButton+TitleAndImage.swift */; }; 029D444922F13F8A00DEFA8A /* DashboardUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029D444822F13F8A00DEFA8A /* DashboardUI.swift */; }; 029F29FA24D93E9E004751CA /* EditableProductModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029F29F924D93E9E004751CA /* EditableProductModel.swift */; }; 029F29FC24D94106004751CA /* EditableProductVariationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 029F29FB24D94106004751CA /* EditableProductVariationModel.swift */; }; @@ -2268,7 +2267,6 @@ 0298431125936DFC00979CAE /* ShippingLabelsTopBannerFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelsTopBannerFactoryTests.swift; sourceTree = ""; }; 029A9C662535873000BECEC5 /* AppCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppCoordinatorTests.swift; sourceTree = ""; }; 029B0F56234197B80010C1F3 /* ProductSearchUICommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductSearchUICommand.swift; sourceTree = ""; }; - 029BFD4E24597D4B00FDDEEC /* UIButton+TitleAndImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+TitleAndImage.swift"; sourceTree = ""; }; 029D444822F13F8A00DEFA8A /* DashboardUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardUI.swift; sourceTree = ""; }; 029F29F924D93E9E004751CA /* EditableProductModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditableProductModel.swift; sourceTree = ""; }; 029F29FB24D94106004751CA /* EditableProductVariationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditableProductVariationModel.swift; sourceTree = ""; }; @@ -7794,7 +7792,6 @@ 02396250239948470096F34C /* UIImage+TintColor.swift */, F997174323DC065900592D8E /* XLPagerStrip+AccessibilityIdentifier.swift */, 0215320A24231D5A003F2BBD /* UIStackView+Subviews.swift */, - 029BFD4E24597D4B00FDDEEC /* UIButton+TitleAndImage.swift */, 57612988245888E2007BB2D9 /* NumberFormatter+LocalizedOrNinetyNinePlus.swift */, 02BA12842461674B008D8325 /* Optional+String.swift */, 02B8650E24A9E2D800265779 /* Product+SwiftUIPreviewHelpers.swift */, @@ -9809,7 +9806,6 @@ DE8C94662646990000C94823 /* PluginListViewController.swift in Sources */, B6E851F3276320C70041D1BA /* RefundFeesDetailsViewModel.swift in Sources */, 024DF31F23743045006658FE /* Header+AztecFormatting.swift in Sources */, - 029BFD4F24597D4B00FDDEEC /* UIButton+TitleAndImage.swift in Sources */, AE7C957B27C3D5DA007E8E12 /* FeeLineDetails.swift in Sources */, B5A8F8AD20B88D9900D211DE /* LoginPrologueViewController.swift in Sources */, B5D1AFC620BC7B7300DB0E8C /* StorePickerViewController.swift in Sources */,