WIP: local handoff implementation
Local work on the social.io handoff before merging the claude worktree branch. Includes the full per-spec Sources/Core/Design module (8 files), watchOS target under WatchApp/, Live Activity + widget extension, entitlements, scheme, and asset catalog. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>$(WATCHOS_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,82 @@
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct WatchUnreadEntry: TimelineEntry {
|
||||
let date: Date
|
||||
let unreadCount: Int
|
||||
}
|
||||
|
||||
struct WatchUnreadProvider: TimelineProvider {
|
||||
func placeholder(in context: Context) -> WatchUnreadEntry {
|
||||
WatchUnreadEntry(date: .now, unreadCount: 3)
|
||||
}
|
||||
|
||||
func getSnapshot(in context: Context, completion: @escaping (WatchUnreadEntry) -> Void) {
|
||||
completion(makeEntry())
|
||||
}
|
||||
|
||||
func getTimeline(in context: Context, completion: @escaping (Timeline<WatchUnreadEntry>) -> Void) {
|
||||
completion(Timeline(entries: [makeEntry()], policy: .after(.now.addingTimeInterval(900))))
|
||||
}
|
||||
|
||||
private func makeEntry() -> WatchUnreadEntry {
|
||||
let unreadCount = MockMailService().previewThreads().filter { $0.mailbox == .inbox && $0.isUnread }.count
|
||||
return WatchUnreadEntry(date: .now, unreadCount: unreadCount)
|
||||
}
|
||||
}
|
||||
|
||||
struct WatchUnreadComplication: Widget {
|
||||
let kind = "SocialIOWatchUnreadComplication"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: WatchUnreadProvider()) { entry in
|
||||
WatchUnreadComplicationView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("social.io Inbox")
|
||||
.description("Unread social.io mail at a glance.")
|
||||
.supportedFamilies([.accessoryRectangular, .accessoryCircular, .accessoryCorner])
|
||||
}
|
||||
}
|
||||
|
||||
private struct WatchUnreadComplicationView: View {
|
||||
let entry: WatchUnreadEntry
|
||||
|
||||
var body: some View {
|
||||
switch widgetFamily {
|
||||
case .accessoryCircular:
|
||||
ZStack {
|
||||
AccessoryWidgetBackground()
|
||||
VStack(spacing: 2) {
|
||||
Image(systemName: "envelope.fill")
|
||||
Text(entry.unreadCount, format: .number)
|
||||
.font(.caption2.weight(.bold))
|
||||
}
|
||||
}
|
||||
.widgetURL(URL(string: "socialio://mailbox/inbox"))
|
||||
|
||||
case .accessoryCorner:
|
||||
Text("\(entry.unreadCount)")
|
||||
.font(.caption.weight(.bold))
|
||||
.widgetURL(URL(string: "socialio://mailbox/inbox"))
|
||||
|
||||
default:
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("social.io")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("\(entry.unreadCount) unread")
|
||||
.font(.caption.weight(.semibold))
|
||||
}
|
||||
.widgetURL(URL(string: "socialio://mailbox/inbox"))
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(\.widgetFamily) private var widgetFamily
|
||||
}
|
||||
|
||||
@main
|
||||
struct SocialIOWatchWidgets: WidgetBundle {
|
||||
var body: some Widget {
|
||||
WatchUnreadComplication()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user