7f6e35908c
- 移除自定义 UI 字体,界面统一系统原生:删 BrandFonts.swift(Orbit/Maple woff2 运行期 CTFontManager 注册 + UIKit 外观代理)+ AppDelegate 的 register 调用 + CDropApp 全局 .environment(\.font, .oBody);9 视图 .font(.o语义) → .font(.语义) 系统语义(日志 LogView 消息行本就 .caption.monospaced() 原生等宽);删 Sources/Fonts/(Orbit/Maple woff2 ~20MB)。仅留品牌字标 Fredoka(logo Wordmark),Justfile ios-fonts 改 Fredoka-only、.gitignore 收窄、新增 Shared/Fonts/README.md - iPad 适配:RootView TabView 加 .tabViewStyle(.sidebarAdaptable)(iPad 常规宽度侧边栏 / iPhone 底部标签栏)+ ConversationView 消息线程 maxWidth 680 居中;project.yml 补方向键 UISupportedInterfaceOrientations(iPhone 竖 + 横)/ ~ipad(全 4 向),消除 iPad 多任务方向构建告警 - 登录页内容约束 maxWidth 420 居中,避免 iPad 宽屏主登录按钮 / 二维码区横向拉满(iPhone 不受影响) - 文档:ios/PLAN.md §11.2 改系统原生字体 + 新增 §13 iPad;ios/PARITY.md 字体分叉条目回退 + 导航条目加 iPad + 2026-07-07 漂移行 - 已装 iPhone 15 Pro C + iPad Pro 13" M4 双端、用户确认
109 lines
4.3 KiB
Swift
109 lines
4.3 KiB
Swift
import SwiftUI
|
||
|
||
// 发送预览表单:列出待发文件(名 + 大小)+ 选择目标设备 + 发送。手动选文件(TransferListView)与
|
||
// 分享交接(RootView)共用此一表单——即「选文件 → 预览 → 选设备 → 发送」。纯 UI:不感知文件来源
|
||
// (手动安全作用域 URL / 图库临时文件 / 分享 App Group),实际发送由调用方经 onSend(设备名) 实现
|
||
// (手动 loop engine.sendFile;分享 engine.sendShares),故同一表单复用零分叉。
|
||
struct PreviewFile: Identifiable
|
||
{
|
||
let id = UUID()
|
||
let name: String
|
||
let size: Int
|
||
}
|
||
|
||
struct SendComposeSheet: View
|
||
{
|
||
let files: [PreviewFile]
|
||
let devices: [DeviceItem]
|
||
let sendLabel: (DeviceItem) -> String
|
||
let onSend: (String) -> Void // 目标设备名
|
||
let onCancel: () -> Void
|
||
|
||
// 选中的目标设备名。onAppear 默认选第一个可达设备,减少一次点击。
|
||
@State private var selected = ""
|
||
|
||
var body: some View
|
||
{
|
||
NavigationStack
|
||
{
|
||
Form
|
||
{
|
||
Section(t("ios.send.files"))
|
||
{
|
||
ForEach(files)
|
||
{ file in
|
||
HStack(spacing: 10)
|
||
{
|
||
Image(systemName: "doc")
|
||
.foregroundStyle(.secondary)
|
||
Text(file.name)
|
||
.lineLimit(1)
|
||
Spacer()
|
||
Text(formatBytes(file.size))
|
||
.font(.caption)
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
}
|
||
}
|
||
Section(t("ios.send.pickDevice"))
|
||
{
|
||
if devices.isEmpty
|
||
{
|
||
Text(t("ios.send.noDevices"))
|
||
.foregroundStyle(.secondary)
|
||
}
|
||
else
|
||
{
|
||
ForEach(devices)
|
||
{ dev in
|
||
Button { selected = dev.name }
|
||
label:
|
||
{
|
||
HStack(spacing: 10)
|
||
{
|
||
Image(systemName: deviceSymbol(dev.type))
|
||
.foregroundStyle(dev.online ? Color.green : Color.secondary)
|
||
Text(sendLabel(dev))
|
||
.foregroundStyle(.primary)
|
||
Spacer()
|
||
if selected == dev.name
|
||
{
|
||
Image(systemName: "checkmark")
|
||
.foregroundStyle(Color.cdropAccent)
|
||
}
|
||
}
|
||
}
|
||
.buttonStyle(.plain)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.navigationTitle(t("ios.send.previewTitle"))
|
||
.navigationBarTitleDisplayMode(.inline)
|
||
.toolbar
|
||
{
|
||
ToolbarItem(placement: .topBarLeading)
|
||
{
|
||
Button(t("common.cancel")) { onCancel() }
|
||
}
|
||
ToolbarItem(placement: .topBarTrailing)
|
||
{
|
||
Button(t("ios.send.send")) { onSend(selected) }
|
||
.fontWeight(.semibold)
|
||
.disabled(selected.isEmpty || files.isEmpty)
|
||
}
|
||
}
|
||
.onAppear { if selected.isEmpty { selected = devices.first?.name ?? "" } }
|
||
}
|
||
}
|
||
}
|
||
|
||
// 读文件字节大小(供发送预览展示)。安全作用域 URL(文件选择器)须临时声明访问才能读属性;
|
||
// 临时文件 / App Group 文件无须声明(startAccessing 返回 false,仍可正常读),故统一走此函数。
|
||
func fileByteSize(_ url: URL) -> Int
|
||
{
|
||
let access = url.startAccessingSecurityScopedResource()
|
||
defer { if access { url.stopAccessingSecurityScopedResource() } }
|
||
return (try? url.resourceValues(forKeys: [ .fileSizeKey ]))?.fileSize ?? 0
|
||
}
|