Guest User

Untitled

a guest
Apr 17th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. import Foundation
  2. import UIKit
  3.  
  4. var hasMovedToWindow = false
  5. var style: Int = 0;
  6. var animateAlways: Bool = false;
  7. var duration: TimeInterval = 0.5;
  8.  
  9. @objc class HookUIScrollView : UIScrollView {
  10. @objc func hook__scrollViewWillBeginDragging(){
  11. hasMovedToWindow = false;
  12. return orig__scrollViewWillBeginDragging();
  13. }
  14. @objc func hook_isDragging() -> Bool {
  15. let orig = orig_isDragging();
  16. hasMovedToWindow = !orig;
  17. return orig;
  18. }
  19. }
  20.  
  21.  
  22. @objc class HookUITableView : UITableView {
  23.  
  24. func animatedTable(_ result: UITableViewCell) -> UITableViewCell {
  25. switch style {
  26. case 1:
  27. DispatchQueue.main.async(execute: {
  28. let original = result.alpha
  29. result.alpha = 0.0
  30. UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  31. result.alpha = original
  32. })
  33. })
  34. case 2:
  35. DispatchQueue.main.async(execute: {
  36. let original = result.layer.transform;
  37. result.layer.transform = CATransform3DMakeRotation(.pi, 1, 0, 0)
  38. UIView.animate(withDuration: duration, delay: 0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  39. result.layer.transform = original
  40. })
  41. })
  42. case 3:
  43. DispatchQueue.main.async(execute: {
  44. let original = result.transform
  45. result.transform = CGAffineTransform(scaleX: 0.01, y: 1.0)
  46. UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 10.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  47. result.transform = original
  48. })
  49. })
  50. case 4:
  51. DispatchQueue.main.async(execute: {
  52. let original = result.transform
  53. result.transform = CGAffineTransform(scaleX: 0.3, y: 0.5)
  54. UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 10.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  55. result.transform = original
  56. })
  57. })
  58. case 5:
  59. DispatchQueue.main.async(execute: {
  60. let original = result.transform
  61. result.transform = CGAffineTransform(rotationAngle: 360)
  62. UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  63. result.transform = original
  64. })
  65. })
  66. case 6:
  67. DispatchQueue.main.async(execute: {
  68. let original = result.transform
  69. result.transform = CGAffineTransform(scaleX: 0.01, y: 1.0)
  70. UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  71. result.transform = original
  72. })
  73. })
  74. case 7:
  75. DispatchQueue.main.async(execute: {
  76. let original = result.frame
  77. var newFrame = original
  78. newFrame.origin.x += original.size.width
  79. result.frame = newFrame
  80. UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
  81. result.frame = original
  82. })
  83. })
  84. default:
  85. break;
  86. }
  87. return result;
  88. }
  89.  
  90. @objc func hook__createPreparedCellForGlobalRow(_ globalRow: Int, withIndexPath: IndexPath, willDisplay: Bool) -> UITableViewCell {
  91.  
  92. // let result = self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay); Dosen't work?
  93.  
  94. if hasMovedToWindow && !animateAlways {
  95. return self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay);
  96. }
  97.  
  98. // return result;
  99. return animatedTable(self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay));
  100. }
  101. }
  102.  
  103. @objc (Cask) public class Cask : NSObject {
  104.  
  105. @objc func loadPrefs() {
  106. let prefs = NSDictionary(contentsOfFile: "/var/mobile/Library/Preferences/com.ryannair05.caskprefs.plist")
  107. style = prefs!.value(forKey: "style") as! Int
  108. duration = prefs!.value(forKey: "duration") as! TimeInterval
  109. animateAlways = prefs!.value(forKey: "animateAlways") as! Bool
  110. }
  111.  
  112. @objc func initPrefs() {
  113. let path = "/User/Library/Preferences/com.ryannair05.caskprefs.plist"
  114. let pathDefault = "/Library/PreferenceBundles/caskprefs.bundle/defaults.plist"
  115. let fileManager = FileManager.default
  116.  
  117. if !fileManager.fileExists(atPath: path) {
  118. do {
  119. try fileManager.copyItem(atPath: pathDefault, toPath: path)
  120. } catch {
  121. }
  122. }
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment