2021-03-02 09:27:11 +01:00
|
|
|
//
|
|
|
|
// UITableView.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by Cirno MainasuK on 2021-3-2.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
2022-01-27 14:23:39 +01:00
|
|
|
import MastodonAsset
|
|
|
|
import MastodonLocalization
|
2021-03-02 09:27:11 +01:00
|
|
|
|
|
|
|
extension UITableView {
|
|
|
|
|
|
|
|
func deselectRow(with transitionCoordinator: UIViewControllerTransitionCoordinator?, animated: Bool) {
|
|
|
|
guard let indexPathForSelectedRow = indexPathForSelectedRow else { return }
|
|
|
|
|
|
|
|
guard let transitionCoordinator = transitionCoordinator else {
|
|
|
|
deselectRow(at: indexPathForSelectedRow, animated: animated)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
transitionCoordinator.animate(alongsideTransition: { _ in
|
|
|
|
self.deselectRow(at: indexPathForSelectedRow, animated: animated)
|
|
|
|
}, completion: { context in
|
|
|
|
if context.isCancelled {
|
|
|
|
self.selectRow(at: indexPathForSelectedRow, animated: animated, scrollPosition: .none)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func blinkRow(at indexPath: IndexPath) {
|
|
|
|
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 1) { [weak self] in
|
|
|
|
guard let self = self else { return }
|
|
|
|
guard let cell = self.cellForRow(at: indexPath) else { return }
|
|
|
|
let backgroundColor = cell.backgroundColor
|
|
|
|
|
|
|
|
UIView.animate(withDuration: 0.3) {
|
2021-06-22 14:52:30 +02:00
|
|
|
cell.backgroundColor = Asset.Colors.brandBlue.color.withAlphaComponent(0.5)
|
2021-03-02 09:27:11 +01:00
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
|
|
UIView.animate(withDuration: 0.3) {
|
|
|
|
cell.backgroundColor = backgroundColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|