-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make navigation buttons in PaymentSheet have a tap target of 44x44 (#942
- Loading branch information
1 parent
727bc71
commit cfceb88
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SheetNavigationButton.swift | ||
// StripeiOS | ||
// | ||
// Created by Nick Porter on 4/1/22. | ||
// Copyright © 2022 Stripe, Inc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
/// A simple button that increases the tap target for small buttons used in the navigation bar of PaymentSheet | ||
/// /// For internal SDK use only | ||
@objc(STP_Internal_SheetNavigationButton) | ||
class SheetNavigationButton: UIButton { | ||
|
||
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { | ||
// increase the hit frame to be at least as big as `minimumHitArea` | ||
let buttonSize = self.bounds.size | ||
let widthToAdd = max(PaymentSheetUI.minimumHitArea.width - buttonSize.width, 0) | ||
let heightToAdd = max(PaymentSheetUI.minimumHitArea.height - buttonSize.height, 0) | ||
let largerFrame = self.bounds.insetBy(dx: -widthToAdd / 2, dy: -heightToAdd / 2) | ||
|
||
// perform hit test on larger frame | ||
return largerFrame.contains(point) | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters