Skip to content

Commit

Permalink
Remove more uses of flipInsetsForRightToLeftLayoutDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Nov 14, 2024
1 parent ae0dce8 commit 9772eb1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
23 changes: 0 additions & 23 deletions WordPress/Classes/Extensions/UIEdgeInsets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,10 @@ extension UIEdgeInsets {
guard UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft else {
return self
}

return flippedForRightToLeftLayoutDirection()
}

func flippedForRightToLeftLayoutDirection() -> UIEdgeInsets {
return UIEdgeInsets(top: top, left: right, bottom: bottom, right: left)
}
}

extension UIButton {

@objc func flipInsetsForRightToLeftLayoutDirection() {
guard userInterfaceLayoutDirection() == .rightToLeft else {
return
}
contentEdgeInsets = contentEdgeInsets.flippedForRightToLeftLayoutDirection()
imageEdgeInsets = imageEdgeInsets.flippedForRightToLeftLayoutDirection()
titleEdgeInsets = titleEdgeInsets.flippedForRightToLeftLayoutDirection()
}
}

// Hack: Since UIEdgeInsets is a struct in ObjC, you can't have methods on it.
// You can't also export top level functions from Swift.
// 🙄
@objc(InsetsHelper)
class _InsetsHelper: NSObject {
@objc static func flipForRightToLeftLayoutDirection(_ insets: UIEdgeInsets) -> UIEdgeInsets {
return insets.flippedForRightToLeftLayoutDirection()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ private extension CommentContentTableViewCell {
replyButton?.setTitleColor(Style.reactionButtonTextColor, for: .normal)
replyButton?.setImage(Style.replyIconImage, for: .normal)
replyButton?.addTarget(self, action: #selector(replyButtonTapped), for: .touchUpInside)
replyButton?.flipInsetsForRightToLeftLayoutDirection()
replyButton?.adjustsImageSizeForAccessibilityContentSizeCategory = true
adjustImageAndTitleEdgeInsets(for: replyButton)
replyButton?.sizeToFit()
Expand All @@ -397,7 +396,6 @@ private extension CommentContentTableViewCell {
likeButton?.titleLabel?.adjustsFontForContentSizeCategory = true
likeButton?.setTitleColor(Style.reactionButtonTextColor, for: .normal)
likeButton?.addTarget(self, action: #selector(likeButtonTapped), for: .touchUpInside)
likeButton?.flipInsetsForRightToLeftLayoutDirection()
likeButton?.adjustsImageSizeForAccessibilityContentSizeCategory = true
adjustImageAndTitleEdgeInsets(for: likeButton)
updateLikeButton(liked: false, numberOfLikes: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class JetpackButton: CircularImageButton {
imageEdgeInsets = Appearance.iconInsets
contentEdgeInsets = Appearance.contentInsets
imageView?.contentMode = .scaleAspectFit
flipInsetsForRightToLeftLayoutDirection()
setImageBackgroundColor(imageBackgroundColor)
}

Expand Down

0 comments on commit 9772eb1

Please sign in to comment.