2020-04-07 22:25:33 +02:00
|
|
|
//
|
|
|
|
// ExtensionPoint.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 4/7/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2020-04-16 15:25:40 +02:00
|
|
|
#if os(macOS)
|
|
|
|
import AppKit
|
|
|
|
#else
|
|
|
|
import UIKit
|
|
|
|
#endif
|
2020-04-07 22:25:33 +02:00
|
|
|
import RSCore
|
|
|
|
|
2020-04-08 17:12:06 +02:00
|
|
|
protocol ExtensionPoint {
|
|
|
|
|
2020-04-14 23:47:05 +02:00
|
|
|
static var isSinglton: Bool { get }
|
2020-04-22 21:16:50 +02:00
|
|
|
static var isDeveloperBuildRestricted: Bool { get }
|
2020-04-14 23:47:05 +02:00
|
|
|
static var title: String { get }
|
|
|
|
static var templateImage: RSImage { get }
|
|
|
|
static var description: NSAttributedString { get }
|
|
|
|
|
2020-04-15 05:33:05 +02:00
|
|
|
var title: String { get }
|
2020-04-08 17:12:06 +02:00
|
|
|
var extensionPointID: ExtensionPointIdentifer { get }
|
|
|
|
|
|
|
|
}
|
2020-04-07 22:25:33 +02:00
|
|
|
|
2020-04-08 17:12:06 +02:00
|
|
|
extension ExtensionPoint {
|
|
|
|
|
2020-04-15 05:33:05 +02:00
|
|
|
var templateImage: RSImage {
|
2020-04-15 06:03:08 +02:00
|
|
|
return extensionPointID.extensionPointType.templateImage
|
2020-04-08 17:12:06 +02:00
|
|
|
}
|
2020-04-14 23:47:05 +02:00
|
|
|
|
2020-04-15 05:33:05 +02:00
|
|
|
var description: NSAttributedString {
|
2020-04-15 06:03:08 +02:00
|
|
|
return extensionPointID.extensionPointType.description
|
2020-04-15 05:33:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 23:47:05 +02:00
|
|
|
static func makeAttrString(_ text: String) -> NSMutableAttributedString {
|
|
|
|
let paragraphStyle = NSMutableParagraphStyle()
|
|
|
|
paragraphStyle.alignment = .center
|
|
|
|
|
2020-04-16 15:25:40 +02:00
|
|
|
#if os(macOS)
|
2020-04-14 23:47:05 +02:00
|
|
|
let attrs = [
|
|
|
|
NSAttributedString.Key.paragraphStyle: paragraphStyle,
|
|
|
|
NSAttributedString.Key.font: NSFont.systemFont(ofSize: NSFont.systemFontSize),
|
|
|
|
NSAttributedString.Key.foregroundColor: NSColor.textColor
|
|
|
|
]
|
2020-04-16 15:25:40 +02:00
|
|
|
#else
|
|
|
|
let attrs = [
|
|
|
|
NSAttributedString.Key.paragraphStyle: paragraphStyle,
|
|
|
|
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body),
|
|
|
|
NSAttributedString.Key.foregroundColor: UIColor.label
|
|
|
|
]
|
|
|
|
#endif
|
2020-04-14 23:47:05 +02:00
|
|
|
|
|
|
|
return NSMutableAttributedString(string: text, attributes: attrs)
|
|
|
|
}
|
2020-04-08 17:12:06 +02:00
|
|
|
|
2020-04-07 22:25:33 +02:00
|
|
|
}
|