Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import UIKit
- var hasMovedToWindow = false
- var style: Int = 0;
- var animateAlways: Bool = false;
- var duration: TimeInterval = 0.5;
- @objc class HookUIScrollView : UIScrollView {
- @objc func hook__scrollViewWillBeginDragging(){
- hasMovedToWindow = false;
- return orig__scrollViewWillBeginDragging();
- }
- @objc func hook_isDragging() -> Bool {
- let orig = orig_isDragging();
- hasMovedToWindow = !orig;
- return orig;
- }
- }
- @objc class HookUITableView : UITableView {
- func animatedTable(_ result: UITableViewCell) -> UITableViewCell {
- switch style {
- case 1:
- DispatchQueue.main.async(execute: {
- let original = result.alpha
- result.alpha = 0.0
- UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.alpha = original
- })
- })
- case 2:
- DispatchQueue.main.async(execute: {
- let original = result.layer.transform;
- result.layer.transform = CATransform3DMakeRotation(.pi, 1, 0, 0)
- UIView.animate(withDuration: duration, delay: 0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.layer.transform = original
- })
- })
- case 3:
- DispatchQueue.main.async(execute: {
- let original = result.transform
- result.transform = CGAffineTransform(scaleX: 0.01, y: 1.0)
- UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 10.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.transform = original
- })
- })
- case 4:
- DispatchQueue.main.async(execute: {
- let original = result.transform
- result.transform = CGAffineTransform(scaleX: 0.3, y: 0.5)
- UIView.animate(withDuration: duration, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 10.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.transform = original
- })
- })
- case 5:
- DispatchQueue.main.async(execute: {
- let original = result.transform
- result.transform = CGAffineTransform(rotationAngle: 360)
- UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.transform = original
- })
- })
- case 6:
- DispatchQueue.main.async(execute: {
- let original = result.transform
- result.transform = CGAffineTransform(scaleX: 0.01, y: 1.0)
- UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.transform = original
- })
- })
- case 7:
- DispatchQueue.main.async(execute: {
- let original = result.frame
- var newFrame = original
- newFrame.origin.x += original.size.width
- result.frame = newFrame
- UIView.animate(withDuration: duration, delay: 0.0, options: [.allowUserInteraction, .allowAnimatedContent, .curveEaseOut], animations: {
- result.frame = original
- })
- })
- default:
- break;
- }
- return result;
- }
- @objc func hook__createPreparedCellForGlobalRow(_ globalRow: Int, withIndexPath: IndexPath, willDisplay: Bool) -> UITableViewCell {
- // let result = self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay); Dosen't work?
- if hasMovedToWindow && !animateAlways {
- return self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay);
- }
- // return result;
- return animatedTable(self.orig__createPreparedCell(forGlobalRow: globalRow, withIndexPath : withIndexPath, willDisplay : willDisplay));
- }
- }
- @objc (Cask) public class Cask : NSObject {
- @objc func loadPrefs() {
- let prefs = NSDictionary(contentsOfFile: "/var/mobile/Library/Preferences/com.ryannair05.caskprefs.plist")
- style = prefs!.value(forKey: "style") as! Int
- duration = prefs!.value(forKey: "duration") as! TimeInterval
- animateAlways = prefs!.value(forKey: "animateAlways") as! Bool
- }
- @objc func initPrefs() {
- let path = "/User/Library/Preferences/com.ryannair05.caskprefs.plist"
- let pathDefault = "/Library/PreferenceBundles/caskprefs.bundle/defaults.plist"
- let fileManager = FileManager.default
- if !fileManager.fileExists(atPath: path) {
- do {
- try fileManager.copyItem(atPath: pathDefault, toPath: path)
- } catch {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment