计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
share-card【效率与协作】Generates shareable card images from app content (achievements, stats, quotes) for social media sharing. Use when user wants to create share images, social cards, shareable content cards, or export app content as images with ShareLink integration.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Generate a production share card system that renders app content (achievements, statistics, quotes, milestones) as shareable images with SwiftUI ImageRenderer, customizable styles, optional QR code overlays, and native ShareLink integration.
Use this skill when the user:
ImageRenderer)Search for existing share/export code:
Glob: **/*ShareCard*.swift, **/*ShareImage*.swift, **/*SocialCard*.swift
Grep: "ImageRenderer" or "ShareLink" or "UIGraphicsImageRenderer" or "share.*image"
If existing share infrastructure found:
Determine if generating for iOS (UIImage) or macOS (NSImage) or both (cross-platform PlatformImage typealias).
Ask user via AskUserQuestion:
Card style?
Share destinations?
Card size preset?
Include QR code?
Content types? (multi-select)
Read templates.md for production Swift code.
Generate these files:
ShareCardContent.swift — Protocol and concrete content types (achievement, statistics, quote)ShareCardStyle.swift — Enum with predefined styles, colors, fonts, layout configurationShareCardRenderer.swift — @MainActor renderer using ImageRenderer to convert SwiftUI views to imagesShareCardView.swift — The SwiftUI view that composes the card layout (background, content, branding)ShareCardSheet.swift — Complete sharing sheet with style picker, live preview, and ShareLinkBased on configuration:
QRCodeOverlay.swift — If QR code selected (CoreImage-based QR generator)ShareCardPreview.swift — SwiftUI Preview helpers for design iterationCheck project structure:
Sources/ exists -> Sources/ShareCard/App/ exists -> App/ShareCard/ShareCard/After generation, provide:
ShareCard/
├── ShareCardContent.swift # Protocol + concrete content types
├── ShareCardStyle.swift # Style enum with colors, fonts, layout
├── ShareCardRenderer.swift # ImageRenderer-based rendering
├── ShareCardView.swift # Card layout SwiftUI view
├── ShareCardSheet.swift # Share sheet with preview + ShareLink
├── QRCodeOverlay.swift # CoreImage QR code (optional)
└── ShareCardPreview.swift # Preview helpers (optional)
Share an achievement:
struct AchievementDetailView: View {
let achievement: Achievement
@State private var showShareCard = false
var body: some View {
VStack {
// ... achievement detail content ...
Button("Share Achievement") {
showShareCard = true
}
}
.sheet(isPresented: $showShareCard) {
ShareCardSheet(
content: AchievementCardContent(
title: achievement.title,
subtitle: achievement.description,
metric: "\(achievement.points) pts",
iconName: achievement.iconName,
brandName: "MyApp"
)
)
}
}
}
Share statistics:
ShareCardSheet(
content: StatisticsCardContent(
title: "Weekly Progress",
stats: [
StatItem(label: "Steps", value: "52,340"),
StatItem(label: "Calories", value: "3,200"),
StatItem(label: "Distance", value: "28.5 km"),
],
brandName: "FitTracker"
)
)
Share a quote:
ShareCardSheet(
content: QuoteCardContent(
quote: "The only way to do great work is to love what you do.",
attribution: "Steve Jobs",
brandName: "DailyQuotes"
)
)
Inline ShareLink (without sheet):
struct QuickShareButton: View {
let content: any ShareCardContent
@State private var renderedImage: PlatformImage?
var body: some View {
Group {
if let image = renderedImage {
ShareLink(
item: Image(platformImage: image),
preview: SharePreview(content.title, image: Image(platformImage: image))
)
} else {
ProgressView()
}
}
.task {
let renderer = ShareCardRenderer()
renderedImage = await renderer.render(content: content, style: .branded)
}
}
}
@Test
func rendersAchievementCard() async throws {
let content = AchievementCardContent(
title: "First Run",
subtitle: "Completed your first 5K run",
metric: "500 pts",
iconName: "figure.run",
brandName: "FitApp"
)
let renderer = ShareCardRenderer()
let image = await renderer.render(content: content, style: .branded)
#expect(image != nil)
#expect(image!.size.width > 0)
#expect(image!.size.height > 0)
}
@Test
func allStylesRenderSuccessfully() async throws {
let content = QuoteCardContent(
quote: "Test quote",
attribution: "Author",
brandName: "App"
)
let renderer = ShareCardRenderer()
for style in ShareCardStyle.allCases {
let image = await renderer.render(content: content, style: style)
#expect(image != nil, "Style \(style) failed to render")
}
}
@Test
func qrCodeGeneratesValidImage() throws {
let image = QRCodeGenerator.generate(
from: "https://example.com/share/123",
size: CGSize(width: 100, height: 100)
)
#expect(image != nil)
}
Best for: gamification, milestones, unlockables.
Best for: fitness, finance, productivity apps.
Best for: reading, journaling, social apps.
@2x scale factor in ImageRenderer for Retina-quality outputrenderer.scale = UIScreen.main.scale (iOS) or NSScreen.main?.backingScaleFactor (macOS)@3x scale = 3240x5760 pixels = ~75 MB in memory@2x maximum for share cards — social platforms compress anywayautoreleasepool if generating multiple cards in sequenceImageRenderer is @MainActor — must be called from the main threadMap, Camera, or WebView contentScrollView content beyond visible bounds is not renderedImageRenderer produces NSImage via nsImage propertyuiImage propertyPlatformImage typealias pattern for shared codeUIGraphicsImageRenderer is UIKit-only — prefer ImageRenderer for SwiftUI cross-platform codeShareLink requires the shared item to conform to TransferableImage conforms to Transferable on iOS 16+ / macOS 13+Transferable with DataRepresentationShareLink renders as a button — style it to match your UIgenerators/image-loading — Cache rendered share card imagesios/deep-linking — Generate deep links for QR codes