mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Adjust HitTestExpandedButton to MinimumHitTargetButton, which enforces minimum hit target size of 44x44
Contributes to IOS-143
This commit is contained in:
parent
d84b5474c4
commit
f28751872d
@ -30,8 +30,8 @@ public final class DiscoveryIntroBannerView: UIView {
|
||||
return label
|
||||
}()
|
||||
|
||||
let closeButton: HitTestExpandedButton = {
|
||||
let button = HitTestExpandedButton(type: .system)
|
||||
let closeButton: MinimumHitTargetButton = {
|
||||
let button = MinimumHitTargetButton(type: .system)
|
||||
button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal)
|
||||
button.tintColor = Asset.Colors.Label.secondary.color
|
||||
return button
|
||||
|
@ -86,7 +86,7 @@ public final class NotificationView: UIView {
|
||||
public let dateLabel = MetaLabel(style: .statusUsername)
|
||||
|
||||
public let menuButton: UIButton = {
|
||||
let button = HitTestExpandedButton(type: .system)
|
||||
let button = MinimumHitTargetButton(type: .system)
|
||||
button.tintColor = Asset.Colors.Label.secondary.color
|
||||
let image = UIImage(systemName: "ellipsis", withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 15)))
|
||||
button.setImage(image, for: .normal)
|
||||
|
@ -21,7 +21,7 @@ final class ProfileFieldAddEntryCollectionViewCell: UICollectionViewCell {
|
||||
let containerStackView = UIStackView()
|
||||
|
||||
let editButton: UIButton = {
|
||||
let button = HitTestExpandedButton(type: .custom)
|
||||
let button = MinimumHitTargetButton(type: .custom)
|
||||
button.setImage(ProfileFieldAddEntryCollectionViewCell.insertButtonImage, for: .normal)
|
||||
button.contentMode = .center
|
||||
button.tintColor = .systemGreen
|
||||
|
@ -29,7 +29,7 @@ final class ProfileFieldEditCollectionViewCell: UICollectionViewCell {
|
||||
let containerStackView = UIStackView()
|
||||
|
||||
let editButton: UIButton = {
|
||||
let button = HitTestExpandedButton(type: .custom)
|
||||
let button = MinimumHitTargetButton(type: .custom)
|
||||
button.setImage(ProfileFieldEditCollectionViewCell.removeButtonImage, for: .normal)
|
||||
button.contentMode = .center
|
||||
button.tintColor = .systemRed
|
||||
|
@ -1,18 +0,0 @@
|
||||
//
|
||||
// HitTestExpandedButton.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by sxiaojian on 2021/2/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public final class HitTestExpandedButton: UIButton {
|
||||
|
||||
public var expandEdgeInsets = UIEdgeInsets(top: -10, left: -10, bottom: -10, right: -10)
|
||||
|
||||
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||
return bounds.inset(by: expandEdgeInsets).contains(point)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
//
|
||||
// HitTestExpandedButton.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by sxiaojian on 2021/2/1.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
public final class MinimumHitTargetButton: UIButton {
|
||||
|
||||
public var minimumTappableSize: CGSize = CGSize(width: 44, height: 44)
|
||||
|
||||
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
||||
let sizeDiff = CGSize(width: minimumTappableSize.width - bounds.width, height: minimumTappableSize.height - bounds.height)
|
||||
let expandedBounds = bounds.insetBy(dx: min(0, -(sizeDiff.width / 2)), dy: min(0, -(sizeDiff.height / 2)))
|
||||
return expandedBounds.contains(point)
|
||||
}
|
||||
|
||||
}
|
@ -41,8 +41,7 @@ public class StatusAuthorView: UIStackView {
|
||||
public let dateLabel = MetaLabel(style: .statusUsername)
|
||||
|
||||
public let menuButton: UIButton = {
|
||||
let button = HitTestExpandedButton(type: .system)
|
||||
button.expandEdgeInsets = UIEdgeInsets(top: -20, left: -10, bottom: -10, right: -10)
|
||||
let button = MinimumHitTargetButton(type: .system)
|
||||
button.tintColor = Asset.Colors.Label.secondary.color
|
||||
let image = UIImage(systemName: "ellipsis", withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 15)))
|
||||
button.setImage(image, for: .normal)
|
||||
@ -51,8 +50,7 @@ public class StatusAuthorView: UIStackView {
|
||||
}()
|
||||
|
||||
public let contentSensitiveeToggleButton: UIButton = {
|
||||
let button = HitTestExpandedButton(type: .system)
|
||||
button.expandEdgeInsets = UIEdgeInsets(top: -20, left: -10, bottom: -10, right: -10)
|
||||
let button = MinimumHitTargetButton(type: .system)
|
||||
button.tintColor = Asset.Colors.Label.secondary.color
|
||||
button.imageView?.contentMode = .scaleAspectFit
|
||||
let image = UIImage(systemName: "eye.slash.fill")
|
||||
|
@ -394,7 +394,7 @@ public final class StatusView: UIView {
|
||||
return label
|
||||
}()
|
||||
let pollVoteButton: UIButton = {
|
||||
let button = HitTestExpandedButton()
|
||||
let button = MinimumHitTargetButton()
|
||||
button.titleLabel?.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 14, weight: .semibold))
|
||||
button.setTitle(L10n.Common.Controls.Status.Poll.vote, for: .normal)
|
||||
button.setTitleColor(Asset.Colors.Brand.blurple.color, for: .normal)
|
||||
|
Loading…
x
Reference in New Issue
Block a user