//
//  ShareableURL.swift
//  App
//
//  Created by James Magahern on 4/28/21.
//

import Foundation

class ShareableURL : NSObject, UIActivityItemSource
{
    let url: URL
    let title: String
    let favicon: UIImage?
    
    init(url: URL, title: String, favicon: UIImage?) {
        self.url = url
        self.title = title
        self.favicon = favicon
        
        super.init()
    }
    
    func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
        return self.url
    }
    
    func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
        return self.url
    }
    
    func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String {
        return self.title
    }
    
    func activityViewController(_ activityViewController: UIActivityViewController, thumbnailImageForActivityType activityType: UIActivity.ActivityType?, suggestedSize size: CGSize) -> UIImage? {
        return self.favicon
    }
}
