| | |
| | | } |
| | | } |
| | | |
| | | public enum SkeletonThumbnailPalette { |
| | | public static let headerAlpha: CGFloat = 0.10 |
| | | public static let contentRowAlpha: CGFloat = 0.075 |
| | | public static let accentStripeAlpha: CGFloat = 0.28 |
| | | public static let titleBandAlpha: CGFloat = 0.86 |
| | | } |
| | | |
| | | @MainActor |
| | | public final class NativeSkeletonThumbnailProvider: SkeletonThumbnailProviderProtocol { |
| | | public static let defaultSize = NSSize(width: 120, height: 80) |
| | |
| | | width: bounds.width, |
| | | height: template.headerHeight |
| | | ) |
| | | color(for: template.category).withAlphaComponent(0.22).setFill() |
| | | color(for: template.category).withAlphaComponent(SkeletonThumbnailPalette.headerAlpha).setFill() |
| | | NSBezierPath(roundedRect: header, xRadius: 6, yRadius: 6).fill() |
| | | } |
| | | |
| | |
| | | width: maxWidth * widthRatio, |
| | | height: rowHeight |
| | | ) |
| | | NSColor.secondaryLabelColor.withAlphaComponent(0.18).setFill() |
| | | NSColor.secondaryLabelColor.withAlphaComponent(SkeletonThumbnailPalette.contentRowAlpha).setFill() |
| | | NSBezierPath(roundedRect: rect, xRadius: 3, yRadius: 3).fill() |
| | | } |
| | | } |
| | |
| | | width: stripeWidth, |
| | | height: max(4, template.headerHeight - 10) |
| | | ) |
| | | color(for: template.category).withAlphaComponent(0.55).setFill() |
| | | color(for: template.category).withAlphaComponent(SkeletonThumbnailPalette.accentStripeAlpha).setFill() |
| | | NSBezierPath(roundedRect: rect, xRadius: 3, yRadius: 3).fill() |
| | | } |
| | | } |
| | | |
| | | private func drawTitle(_ title: String, in bounds: NSRect) { |
| | | let titleBand = NSRect(x: 0, y: 0, width: bounds.width, height: 24) |
| | | NSColor.windowBackgroundColor.withAlphaComponent(0.86).setFill() |
| | | NSColor.windowBackgroundColor.withAlphaComponent(SkeletonThumbnailPalette.titleBandAlpha).setFill() |
| | | NSBezierPath(roundedRect: titleBand, xRadius: 6, yRadius: 6).fill() |
| | | |
| | | let paragraph = NSMutableParagraphStyle() |