Scale pill when pressing (IOS-234)

This commit is contained in:
Nathan Mattes 2024-04-09 17:23:09 +02:00
parent 8884b326fc
commit 6e61e3ca25
1 changed files with 20 additions and 4 deletions

View File

@ -313,7 +313,9 @@ extension HomeTimelineViewController {
timelinePillHiddenTopAnchor, timelinePillCenterXAnchor
])
timelinePill.addTarget(self, action: #selector(HomeTimelineViewController.timelinePillPressed(_:)), for: .touchUpInside)
timelinePill.addTarget(self, action: #selector(HomeTimelineViewController.timelinePillTouched(_:)), for: .touchDown)
timelinePill.addTarget(self, action: #selector(HomeTimelineViewController.timelinePillPressedInside(_:)), for: .touchUpInside)
timelinePill.addTarget(self, action: #selector(HomeTimelineViewController.timelinePillTouchedOutside(_:)), for: .touchUpOutside)
self.timelinePillCenterXAnchor = timelinePillCenterXAnchor
self.timelinePillVisibleTopAnchor = timelinePillVisibleTopAnchor
@ -511,9 +513,25 @@ extension HomeTimelineViewController {
}
}
@objc private func timelinePillPressed(_ sender: TimelineStatusPill) {
@objc private func timelinePillTouched(_ sender: TimelineStatusPill) {
UIView.animate(withDuration: 0.05) {
sender.transform = CGAffineTransform.identity.scaledBy(x: 0.95, y: 0.95)
}
}
@objc private func timelinePillTouchedOutside(_ sender: TimelineStatusPill) {
UIView.animate(withDuration: 0.05) {
sender.transform = CGAffineTransform.identity.scaledBy(x: 100/95.0, y: 100/95.0)
}
}
@objc private func timelinePillPressedInside(_ sender: TimelineStatusPill) {
guard let reason = sender.reason else { return }
UIView.animate(withDuration: 0.05) {
sender.transform = CGAffineTransform.identity.scaledBy(x: 100/95.0, y: 100/95.0)
}
switch reason {
case .newPosts:
scrollToTop(animated: true)
@ -523,8 +541,6 @@ extension HomeTimelineViewController {
case .offline:
hideTimelinePill()
}
}
private func showTimelinePill() {