mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Added subject to email sharing and light boxed the social media share dialogs. Issue #276
This commit is contained in:
@@ -14,7 +14,7 @@ import RSCore
|
||||
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
|
||||
@IBOutlet var toolbarDelegate: MainWindowToolbarDelegate?
|
||||
private let sharingServicePickerDelegate = SharingServicePickerDelegate()
|
||||
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
|
||||
|
||||
private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: "MainWindow")
|
||||
static var didPositionWindowOnFirstRun = false
|
||||
@@ -39,6 +39,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
|
||||
super.windowDidLoad()
|
||||
|
||||
sharingServicePickerDelegate = SharingServicePickerDelegate(self.window)
|
||||
|
||||
if !AppDefaults.shared.showTitleOnMainWindow {
|
||||
window?.titleVisibility = .hidden
|
||||
}
|
||||
|
||||
42
NetNewsWire/MainWindow/SharingServiceDelegate.swift
Normal file
42
NetNewsWire/MainWindow/SharingServiceDelegate.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SharingServiceDelegate.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 9/7/18.
|
||||
// Copyright © 2018 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
@objc final class SharingServiceDelegate: NSObject, NSSharingServiceDelegate {
|
||||
|
||||
weak var window: NSWindow?
|
||||
|
||||
init(_ window: NSWindow?) {
|
||||
self.window = window
|
||||
}
|
||||
|
||||
func sharingService(_ sharingService: NSSharingService, willShareItems items: [Any]) {
|
||||
|
||||
var subject = ""
|
||||
|
||||
for (index, item) in items.enumerated() {
|
||||
|
||||
guard let writer = item as? ArticlePasteboardWriter,
|
||||
let title = writer.article.title else {
|
||||
continue
|
||||
}
|
||||
|
||||
subject += index != 0 ? ", \(title)" : title
|
||||
|
||||
}
|
||||
|
||||
sharingService.subject = subject
|
||||
|
||||
}
|
||||
|
||||
func sharingService(_ sharingService: NSSharingService, sourceWindowForShareItems items: [Any], sharingContentScope: UnsafeMutablePointer<NSSharingService.SharingContentScope>) -> NSWindow? {
|
||||
return window
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,10 +9,21 @@
|
||||
import AppKit
|
||||
|
||||
@objc final class SharingServicePickerDelegate: NSObject, NSSharingServicePickerDelegate {
|
||||
|
||||
|
||||
private let sharingServiceDelegate: SharingServiceDelegate
|
||||
|
||||
init(_ window: NSWindow?) {
|
||||
sharingServiceDelegate = SharingServiceDelegate(window)
|
||||
}
|
||||
|
||||
func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, sharingServicesForItems items: [Any], proposedSharingServices proposedServices: [NSSharingService]) -> [NSSharingService] {
|
||||
|
||||
return proposedServices + SharingServicePickerDelegate.customSharingServices(for: items)
|
||||
|
||||
}
|
||||
|
||||
func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> NSSharingServiceDelegate? {
|
||||
return sharingServiceDelegate
|
||||
}
|
||||
|
||||
static func customSharingServices(for items: [Any]) -> [NSSharingService] {
|
||||
|
||||
Reference in New Issue
Block a user