// // KMTransitionInfo.swift // PDF Reader Pro // // Created by liujiajie on 2024/1/17. // import Foundation let SKPasteboardTypeTransition = "net.sourceforge.skim-app.pasteboard.transition" class KMTransitionInfo: NSObject{ var transitionStyle: SKAnimationTransitionStyle = .noTransition var duration: Float = 0.0 var shouldRestrict = false var thumbnail: KMThumbnail? var label: String = "" var title: String {return NSLocalizedString("Page Transition", comment: "Box title")} var properties: NSDictionary?{ get{ return [SKStyleNameKey: SKTransitionController.name(for: transitionStyle) ?? "", SKDurationKey: NSNumber(value: duration), SKShouldRestrictKey: NSNumber(value: shouldRestrict)] as [String : Any] as NSDictionary } set{ if let value = newValue?[SKStyleNameKey] { transitionStyle = SKTransitionController.style(forName: value as? String) } if let value = newValue?[SKDurationKey] { duration = value as! Float } if let value = newValue?[SKShouldRestrictKey] { shouldRestrict = value as! Bool } } } override init() { super.init() transitionStyle = .noTransition duration = 1.0 shouldRestrict = false thumbnail = nil label = "" } init(propertyList: NSDictionary, ofType: String) { super.init() if ofType == SKPasteboardTypeTransition { self.properties = propertyList } else { } } override var description: String { return "<\(type(of: self)) \(Unmanaged.passUnretained(self).toOpaque())> \(properties)" } class func readableTypesForPasteboard(pasteboard: NSPasteboard) -> NSArray { return NSArray(objects: SKPasteboardTypeTransition) } class func readingOptionsForType(type: String, pasteboard: NSPasteboard) -> NSPasteboard.ReadingOptions { if type == SKPasteboardTypeTransition { return .asPropertyList } return .asData } func writableTypesForPasteboard(pasteboard: NSPasteboard) -> NSArray { return NSArray(objects: SKPasteboardTypeTransition) } func pasteboardPropertyListForType(type: String) -> Any? { if type == SKPasteboardTypeTransition { return properties } return nil } }