349d94aa8f
- 原生数据面 libwebrtc(PLAN 决策 F):新增 Engine/LibWebRtcEngine.swift(RTCPeerConnection,端口 engine.go/session.go 线协议 + 水位背压 + ack 完成 + 不冲突落盘);NativeTransfer.swift 的 P2PEventsBridge 改 conform P2PEngineDelegate(去 gomobile);EngineController 4 个 p2p RPC 改调新引擎(completion-based + resolveOnMain)。stasel/WebRTC M149 经 SPM(exactVersion 149.0.0)。环回端到端 20MB 逐字节测过(Tests/) - UX 改造(PARITY 残余项 1/2):新增 SendComposeSheet(发送预览=文件名 + 选设备,手动多选与分享共用);分享直入预览 + scenePhase .active 兜底(修“分享后必须重启 app”);重写 MessagesView(按设备会话 + 每设备未读红点 + 删单条 / 删整设备历史);EngineController 加 conversations / unread 模型 - 品牌 logo:新增 Shared/Brand.swift(BrandMark / Wordmark / BrandLockup / BrandHero)+ Brand.xcassets/LogoMark;登录页 / 传输空态 / 设置头 / 控制中心控件接 logo;Theme 加 cdropAmber - 字体(对齐 web,仅主 app):新增 BrandFonts.swift(Orbit Gothic + Maple Mono woff2 运行期 CTFontManager 注册 + UIKit 外观代理 + .oXxx / .maple 助手);Fredoka SemiBold 字标;7 视图 .font sweep。字体不入库——.gitignore 排除 + just ios-fonts 构建前从 CDN / Google Fonts 拉取,见 Sources/Fonts/README.md - 分享引导:新增 Share/ShareGuideView(吉祥物卡 + “打开 Commilitia Drop”);ShareViewController 健壮 staging(文件 / 数据双路)+ 响应链 IMP 唤起宿主 - 全平台平均速度:传输完成态显平均速度(总字节 / 总耗时)而非末次瞬时——web store/slices/transfer.ts + TransferRow.tsx + iOS RootView 卡片 / 详情;i18n 加 transfer.avgRate - 工程:project.yml 接 SPM WebRTC + CDropTests + Fredoka UIAppFonts + Share i18n;Justfile 加 ios-sim-build + ios-fonts / ios-fonts-fredoka 配方 - 文档:ios/PLAN.md(决策 F + §10 UX + §11 品牌/字体 + §12 平均速度)、ios/PARITY.md(字体分叉条目更新 + 2026-06-28 漂移行)
119 lines
4.2 KiB
Swift
119 lines
4.2 KiB
Swift
import AppIntents
|
||
import SwiftUI
|
||
import WidgetKit
|
||
|
||
// 主屏 / 锁屏小组件「云剪贴板」(#6):在控制中心两控件之外,提供一个可放主屏的交互式小组件,含上传 /
|
||
// 拉取两个按钮(iOS 17+ 交互式小组件,按钮直接跑 AppIntent,无需打开 app)。触发结果经 WidgetFeedback
|
||
// 弹本地通知反馈。按钮复用与控制中心相同的 Upload/PullClipboardIntent。
|
||
struct ClipboardWidgetEntry: TimelineEntry
|
||
{
|
||
let date: Date
|
||
}
|
||
|
||
// 纯按钮小组件,无动态内容:单条永不刷新的时间线即可(交互由按钮的 AppIntent 驱动)。
|
||
struct ClipboardWidgetProvider: TimelineProvider
|
||
{
|
||
func placeholder(in context: Context) -> ClipboardWidgetEntry { ClipboardWidgetEntry(date: Date()) }
|
||
|
||
func getSnapshot(in context: Context, completion: @escaping (ClipboardWidgetEntry) -> Void)
|
||
{
|
||
completion(ClipboardWidgetEntry(date: Date()))
|
||
}
|
||
|
||
func getTimeline(in context: Context, completion: @escaping (Timeline<ClipboardWidgetEntry>) -> Void)
|
||
{
|
||
completion(Timeline(entries: [ ClipboardWidgetEntry(date: Date()) ], policy: .never))
|
||
}
|
||
}
|
||
|
||
struct ClipboardWidgetView: View
|
||
{
|
||
@Environment(\.widgetFamily) private var family
|
||
var entry: ClipboardWidgetEntry
|
||
|
||
var body: some View
|
||
{
|
||
Group
|
||
{
|
||
if family == .systemMedium { mediumLayout } else { smallLayout }
|
||
}
|
||
.containerBackground(for: .widget) { brandBackground }
|
||
}
|
||
|
||
// 小尺寸:slim 品牌 header(吉祥物 + 名)+ 两个全宽按钮填满余下高度(最大化利用空间、大点按区)。
|
||
private var smallLayout: some View
|
||
{
|
||
VStack(spacing: 10)
|
||
{
|
||
HStack(spacing: 8)
|
||
{
|
||
BrandMark(size: 30)
|
||
Text(t("ios.widget.clipboardName"))
|
||
.font(.subheadline).bold()
|
||
.lineLimit(1)
|
||
Spacer(minLength: 0)
|
||
}
|
||
actionButton(t("ios.control.upload"), "square.and.arrow.up", UploadClipboardIntent())
|
||
actionButton(t("ios.control.pull"), "square.and.arrow.down", PullClipboardIntent())
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
.padding(14)
|
||
}
|
||
|
||
// 中尺寸:左侧大吉祥物作视觉锚,右侧名 + 两按钮竖排,吃满横向空间。
|
||
private var mediumLayout: some View
|
||
{
|
||
HStack(spacing: 18)
|
||
{
|
||
BrandMark(size: 72)
|
||
VStack(alignment: .leading, spacing: 9)
|
||
{
|
||
Text(t("ios.widget.clipboardName"))
|
||
.font(.headline)
|
||
.lineLimit(1)
|
||
actionButton(t("ios.control.upload"), "square.and.arrow.up", UploadClipboardIntent())
|
||
actionButton(t("ios.control.pull"), "square.and.arrow.down", PullClipboardIntent())
|
||
}
|
||
.frame(maxWidth: .infinity, alignment: .leading)
|
||
}
|
||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||
.padding(16)
|
||
}
|
||
|
||
// 品牌底:淡品牌色斜向渐变(取代原 .fill.tertiary 灰底),与吉祥物 / 按钮同色系。
|
||
private var brandBackground: some View
|
||
{
|
||
LinearGradient(
|
||
colors: [ Color.cdropAccent.opacity(0.18), Color.cdropAccent.opacity(0.05) ],
|
||
startPoint: .topLeading, endPoint: .bottomTrailing)
|
||
}
|
||
|
||
private func actionButton(_ title: String, _ symbol: String, _ intent: some AppIntent) -> some View
|
||
{
|
||
Button(intent: intent)
|
||
{
|
||
Label(title, systemImage: symbol)
|
||
.font(.caption).fontWeight(.semibold)
|
||
.lineLimit(1)
|
||
.frame(maxWidth: .infinity)
|
||
.padding(.vertical, 3)
|
||
}
|
||
.buttonStyle(.borderedProminent)
|
||
.tint(.cdropAccent)
|
||
}
|
||
}
|
||
|
||
struct CloudClipboardWidget: Widget
|
||
{
|
||
var body: some WidgetConfiguration
|
||
{
|
||
StaticConfiguration(kind: "net.commilitia.cdrop.widget.clipboard", provider: ClipboardWidgetProvider())
|
||
{ entry in
|
||
ClipboardWidgetView(entry: entry)
|
||
}
|
||
.configurationDisplayName(t("ios.widget.clipboardName"))
|
||
.description(t("ios.widget.clipboardDesc"))
|
||
.supportedFamilies([ .systemSmall, .systemMedium ])
|
||
}
|
||
}
|