Compare commits
19
Commits
0.0.4
...
c61115cab3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c61115cab3 | ||
|
|
95cead5863 | ||
|
|
68d9363f0a | ||
|
|
52f803e8db | ||
|
|
1422461224 | ||
|
|
a17164d1a9 | ||
|
|
1bde945d36 | ||
|
|
5a19cfde14 | ||
|
|
7c16647306 | ||
|
|
d56e99a83f | ||
|
|
fed34da246 | ||
|
|
72c1f8d89c | ||
|
|
822949f6cc | ||
|
|
6a0a1223b1 | ||
|
|
adc24d3f36 | ||
|
|
8ccb7157b2 | ||
|
|
063a493b18 | ||
|
|
d7fcda345d | ||
|
|
d5a7755702 |
@@ -0,0 +1,90 @@
|
|||||||
|
---
|
||||||
|
name: commit-git-changes
|
||||||
|
description: 审查当前 Git 工作区,安全选择本次任务文件,生成包含问题背景、根因和修改方案的详细中文提交说明,并提交及按用户要求推送到 Git 服务器。默认不执行构建或测试;用户要求“提交代码”“提交并推送”“同步到 Git”“上传当前修改”或要求生成详细 commit message 时使用。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 提交 Git 改动
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
在不混入无关修改、不泄露敏感信息、不改写远端历史的前提下,完成“审查—暂存—提交—推送—确认”闭环,并用提交说明解释为什么修改以及如何解决,而不只是罗列文件。
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 读取仓库级 `AGENTS.md`、当前分支、远端和工作区状态。
|
||||||
|
2. 检查暂存与未暂存差异:
|
||||||
|
- 使用 `git status --short` 确认全部改动。
|
||||||
|
- 使用 `git diff` 和 `git diff --cached` 理解真实行为变化。
|
||||||
|
- 必要时查看相关源码和测试,不能仅依据文件名编写提交说明。
|
||||||
|
3. 划定本次提交范围:
|
||||||
|
- 只纳入当前用户任务直接相关的文件。
|
||||||
|
- 保留用户已有或其他任务产生的无关修改。
|
||||||
|
- 优先显式 `git add <path...>`;仅在确认所有改动均属本次提交时使用 `git add -A`。
|
||||||
|
- 发现密钥、令牌、证书、个人配置、大型生成物或疑似敏感数据时停止提交并说明。
|
||||||
|
4. 不默认执行构建、测试或项目级验证;仅在用户明确要求时执行。
|
||||||
|
5. 暂存后再次检查:
|
||||||
|
- 执行 `git diff --cached --check`。
|
||||||
|
- 执行 `git diff --cached --stat` 和 `git diff --cached`。
|
||||||
|
- 确认暂存区没有无关文件、调试残留和意外格式变化。
|
||||||
|
6. 编写详细中文提交说明并创建提交。
|
||||||
|
7. 用户要求提交到服务器或同步远端时推送:
|
||||||
|
- 有 upstream 时推送当前分支。
|
||||||
|
- 没有 upstream 且远端、目标分支明确时,使用 `git push -u <remote> <branch>`。
|
||||||
|
- 远端或目标分支不明确时先询问,不猜测。
|
||||||
|
- 禁止 force push;除非用户明确要求且风险已说明。
|
||||||
|
8. 提交后确认提交哈希、提交标题、当前分支、推送结果和剩余未提交改动。
|
||||||
|
|
||||||
|
## 提交说明规范
|
||||||
|
|
||||||
|
提交说明使用“标题 + 空行 + 详细正文”的结构。
|
||||||
|
|
||||||
|
### 标题
|
||||||
|
|
||||||
|
- 用一句中文概括用户可感知的问题和修复结果。
|
||||||
|
- 优先写清触发条件、异常表现和结果,例如:
|
||||||
|
`修复无训练点普通课程完成后重进播放页回退为未完成`
|
||||||
|
- 使用明确动词,如“修复”“新增”“调整”“重构”“移除”。
|
||||||
|
- 不使用“修改代码”“优化问题”“更新若干内容”等空泛描述。
|
||||||
|
- 保持单行,不以句号结尾,不添加无依据的工单号或模块前缀。
|
||||||
|
|
||||||
|
### 正文
|
||||||
|
|
||||||
|
用完整段落解释以下内容:
|
||||||
|
|
||||||
|
1. **问题背景与影响**:什么场景触发、用户看到什么、影响哪些路径。
|
||||||
|
2. **根因**:原有数据流、状态条件或实现约束为什么导致问题。
|
||||||
|
3. **修改方案**:关键行为如何改变,为什么选择该方案,必要时说明兼容和边界处理。
|
||||||
|
|
||||||
|
正文应描述行为和因果关系,不要把 `git diff --stat` 改写成文件清单。多个紧密相关的修改可以分段说明,但不要堆砌逐文件 bullet。
|
||||||
|
|
||||||
|
若用户明确要求并实际执行了构建、测试或其他验证,可以在正文末尾如实补充;未执行时不需要添加“验证:未执行”之类的说明。
|
||||||
|
|
||||||
|
### 示例
|
||||||
|
|
||||||
|
```text
|
||||||
|
修复无训练点普通课程完成后重进播放页回退为未完成
|
||||||
|
|
||||||
|
课件完成态本地记录的保存不区分训练点,但读取端仅在存在
|
||||||
|
trainPointModel 时才创建合并器,导致班级、训练和项目均为空的普通课程
|
||||||
|
重进播放页后无法读取本地完成记录。
|
||||||
|
|
||||||
|
改为始终创建完成态合并器:无训练点时使用空维度合并;由于该场景没有
|
||||||
|
服务端完成态可供对账,将本地记录作为唯一持久来源并跳过超期回收,保持
|
||||||
|
重新进入播放页后的完成状态稳定。
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
根据真实改动改写示例内容,禁止照抄未发生的场景或验证结论。
|
||||||
|
|
||||||
|
## 提交与推送约束
|
||||||
|
|
||||||
|
- 不使用 `git reset --hard`、`git checkout --`、`git clean` 等破坏性命令处理工作区。
|
||||||
|
- 不使用 `--amend`、rebase、历史改写或强制推送,除非用户明确授权。
|
||||||
|
- 不跳过 hooks;hook 失败时先分析原因,不使用 `--no-verify` 绕过。
|
||||||
|
- 提交失败后保留暂存区,修复可控问题并重试;不要重复创建等价提交。
|
||||||
|
- 推送被拒绝时先获取并解释分支差异,不自动合并、变基或覆盖远端。
|
||||||
|
- 若没有可提交差异,直接说明,不创建空提交。
|
||||||
|
|
||||||
|
## 交付
|
||||||
|
|
||||||
|
报告提交哈希和标题、推送的远端分支,以及仍留在工作区的未提交修改。若只完成本地提交而未推送,必须明确说明。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "提交 Git 代码"
|
||||||
|
short_description: "安全审查改动并生成详细中文说明,完成 Git 提交与远端推送"
|
||||||
|
default_prompt: "使用 $commit-git-changes 审查当前改动,生成详细中文提交说明并提交到 Git 服务器。"
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
name: discuss-sdk-feature-solution
|
||||||
|
description: 讨论 ReadViewSDK 的新功能、修复或重构方案,核验 EPUB/PDF 阅读器源码,比较实现路径并收敛为可直接开发的计划。用户说“先讨论”“先给方案”“比较方案”“不要改代码”,或接口、缓存、渲染路径、持久化兼容存在会改变实现方式的灰区时使用;路径已明确且用户要求直接修改时不要使用。
|
||||||
|
---
|
||||||
|
|
||||||
|
# SDK 功能方案讨论
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
在编码前用仓库事实收敛决策,输出最小、可验证、能交给开发 Skill 直接执行的方案。本 Skill 默认不修改业务代码。
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 检查工作区并定位目标模块、入口、相邻实现和对应文档。
|
||||||
|
2. 区分已锁定决定、阻塞决定、实现假设、后续项与非范围。
|
||||||
|
3. 按根目录 `AGENTS.md` 读取所需文档;结论必须由真实路径、类型、方法和调用链支撑。
|
||||||
|
4. 方案未定时给出 2–4 个可行路径,比较改动面、公开 API、缓存/持久化、渲染路径、性能、回归和维护成本,并明确推荐一个。
|
||||||
|
5. 用户已选定方案时只细化该方案,不继续横向发散。
|
||||||
|
6. 方案至少覆盖:
|
||||||
|
- EPUB:`.textReflowable`、`.webInteractive`、`.webFixedLayout` 中受影响的路径
|
||||||
|
- PDF:宿主图片 Provider 与内置 PDFKit Provider 中受影响的路径
|
||||||
|
- 公共 API、Codable/磁盘格式、缓存版本和 CocoaPods 集成影响
|
||||||
|
- 异步乱序、取消、生命周期、内存压力和失败降级
|
||||||
|
7. 收敛为文件级任务、数据/状态流、成功标准、验证方式、风险和回滚点。
|
||||||
|
|
||||||
|
## 输出
|
||||||
|
|
||||||
|
默认在对话中给出:
|
||||||
|
|
||||||
|
- 需求、范围与非范围
|
||||||
|
- 已确认决定、阻塞项和必要假设
|
||||||
|
- 方案对比或已选方案拆解
|
||||||
|
- 涉及文件、调用链、复用点和兼容策略
|
||||||
|
- 风险、回滚点与验证清单
|
||||||
|
- 建议交给 `start-sdk-feature-dev-lite` 或 `start-sdk-feature-dev` 的执行摘要
|
||||||
|
|
||||||
|
用户要求落文档,或方案需要跨会话执行时,写入 `Doc/FeatureSolution/`,并在存在文档索引时同步 `Doc/index.md`。
|
||||||
|
|
||||||
|
## 边界
|
||||||
|
|
||||||
|
- 不为未确认的未来需求预埋抽象。
|
||||||
|
- 必要改动、可选优化和后续治理必须分开。
|
||||||
|
- 未核验的系统 API、第三方能力、文件格式或缓存行为不得写成事实。
|
||||||
|
- 文档与源码冲突时以当前源码为事实,并明确指出文档待同步项。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "SDK 功能方案讨论"
|
||||||
|
short_description: "核验当前仓库事实,比较实现路径并输出可直接开发的完整方案"
|
||||||
|
default_prompt: "Use $discuss-sdk-feature-solution to compare implementation paths and produce an executable handoff."
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: generate-module-code-style-doc
|
||||||
|
description: 基于真实源码生成或更新 ReadViewSDK 指定模块的代码组织、命名、分层、UI、状态、缓存和复用规范,适用于 EPUBCore、EPUBTextRendering、ReaderView、EPUBUI、RDPDFReaderView 或 Demo。全局规范使用 generate-sdk-code-style-doc。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 生成模块代码规范
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 确定目标模块、关注范围和输出文件;优先增量更新 `Doc/` 中现有对应文档。
|
||||||
|
2. 读取目标模块源码、对应 code reference、`Doc/CONVENTIONS.md` 和必要架构章节。
|
||||||
|
3. 抽样入口、协议、模型、View/Cell、Controller、Coordinator/Service、缓存和 Extension;不存在的层级不要补造。
|
||||||
|
4. 提炼真实且重复出现的模式,并区分当前约定、特殊例外及原因、尚未落地的建议。
|
||||||
|
5. 记录目录职责、命名、可见性、依赖方向、状态管理、布局、回调、缓存、失败处理、公共 API 和跨模块边界。
|
||||||
|
6. 对 EPUB 模块说明适用的渲染路径;对 PDF 模块说明自定义 Provider 与 PDFKit 路径差异。
|
||||||
|
7. 增量更新文档,检查与全局规范、podspec、架构和源码是否冲突。
|
||||||
|
8. 文档新增、移动或重命名时同步 `Doc/index.md`。
|
||||||
|
|
||||||
|
## 边界
|
||||||
|
|
||||||
|
- 只描述目标模块,不把局部模式提升为全局事实。
|
||||||
|
- 不虚构理想分层、协议或不存在的调用链。
|
||||||
|
- 默认不修改业务代码;发现问题时作为建议或 finding 单独列出。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "生成模块代码规范"
|
||||||
|
short_description: "基于真实源码生成指定 EPUB、PDF 或 Demo 模块的局部规范文档"
|
||||||
|
default_prompt: "Use $generate-module-code-style-doc to document the coding patterns of this ReadViewSDK module."
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
name: generate-module-implementation-logic
|
||||||
|
description: 从 ReadViewSDK 真实源码生成或更新指定模块或场景的入口、调用链、数据流、状态流、渲染流、缓存、持久化、异步回调和异常分支文档。用户要求梳理实现逻辑、调用链、分页或缓存流程时使用;代码风格规范改用对应 code-style Skill。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 生成模块实现逻辑
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 确定目标模块、用户场景和输出路径;优先复用 `Doc/` 中现有专题或 code reference。
|
||||||
|
2. 读取目标入口、现有文档,以及 `AGENTS.md` 路由出的架构、API 或测试资料。
|
||||||
|
3. 用引用搜索沿真实关系追踪:
|
||||||
|
- 页面、控制器、协议或服务入口及触发条件
|
||||||
|
- 数据模型、状态所有者和线程/队列
|
||||||
|
- EPUB 解析/排版/分页/章节窗口,或 PDF Provider/渲染/OCR/标注
|
||||||
|
- 内存与磁盘缓存、键、版本、驱逐和恢复
|
||||||
|
- 通知、回调、delegate、持久化和跨模块依赖
|
||||||
|
- 空值、失败、取消、重试、超时、迟到结果和兼容分支
|
||||||
|
4. 对关键链路至少双向核验一次:从入口跟到结果,再从结果或回调查回调用方。
|
||||||
|
5. 区分当前实现、历史兼容层、仅文档中的计划和待确认事实。
|
||||||
|
6. 增量更新文档,保留正确内容,删除或标记失效链路。
|
||||||
|
7. 结论引用真实文件、类型和方法;不确定信息明确标为待确认。
|
||||||
|
8. 文档新增、移动或重命名时同步 `Doc/index.md`。
|
||||||
|
|
||||||
|
## 推荐结构
|
||||||
|
|
||||||
|
- 适用范围与模块职责
|
||||||
|
- 入口和主要对象
|
||||||
|
- 主流程与数据/状态/渲染变化
|
||||||
|
- 缓存、持久化和并发模型
|
||||||
|
- 异常、取消、重试和兼容处理
|
||||||
|
- 维护风险与验证要点
|
||||||
|
|
||||||
|
纯文档任务不修改业务代码;源码暴露的缺陷应单独报告,不把建议写成已实现事实。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "生成模块实现逻辑"
|
||||||
|
short_description: "梳理指定阅读器模块的入口、调用链、状态流、缓存及异常分支"
|
||||||
|
default_prompt: "Use $generate-module-implementation-logic to document this module's verified implementation flow."
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
name: generate-sdk-code-style-doc
|
||||||
|
description: 基于 ReadViewSDK 当前 EPUB、PDF 和 Demo 源码生成或更新全局代码规范、目录职责、命名、分层、UIKit/SnapKit、并发、缓存、公共 API 与测试约定。用户要求项目级编码规范或更新 Doc/CONVENTIONS.md 时使用;单模块规范改用 generate-module-code-style-doc。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 生成 SDK 全局代码规范
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 明确输出路径;未指定时增量更新 `Doc/CONVENTIONS.md`。
|
||||||
|
2. 读取现有目标文档、`Doc/ARCHITECTURE.md`、`Doc/index.md` 和两个 podspec。
|
||||||
|
3. 从 EPUBCore、EPUBTextRendering、ReaderView、EPUBUI、RDPDFReaderView 与 Demo/UITests 抽样真实源码。
|
||||||
|
4. 把结论分为:
|
||||||
|
- 多模块源码验证的现行约定
|
||||||
|
- 仅适用于 EPUB、PDF 或 Demo 的局部模式
|
||||||
|
- 明确标记为建议、尚未成为项目事实的待统一项
|
||||||
|
5. 覆盖目录职责、命名与可见性、公共 API、UIKit/SnapKit、异步与取消、缓存/持久化、错误处理、测试、注释和 CocoaPods 约定。
|
||||||
|
6. 增量保留仍正确内容,删除失效描述;使用真实路径、类型和方法作为证据。
|
||||||
|
7. 新增、移动或重命名文档时同步 `Doc/index.md`,最后检查链接和源码一致性。
|
||||||
|
|
||||||
|
## 边界
|
||||||
|
|
||||||
|
- 不把 EPUB 的局部模式提升为 PDF 的全局规范,反之亦然。
|
||||||
|
- 不以旧 `.claude/skills` 或过期文档替代当前源码事实。
|
||||||
|
- 不把个人偏好写成现行规范。
|
||||||
|
- 文档任务默认不修改业务代码;发现缺陷时单独报告。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "生成 SDK 全局规范"
|
||||||
|
short_description: "从当前 EPUB 与 PDF 源码证据生成或更新项目级代码规范文档"
|
||||||
|
default_prompt: "Use $generate-sdk-code-style-doc to update the project-wide coding conventions from source evidence."
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
name: review-swift-ios-sdk
|
||||||
|
description: 对 ReadViewSDK 的 Swift/iOS 代码进行专项审查,覆盖并发、主线程、生命周期、内存、缓存、渲染性能、可访问性、安全、公共 API 和持久化兼容。用户要求继续检查隐藏问题、代码审查、性能或内存审计时使用;普通功能开发和纯文档任务不要单独使用。
|
||||||
|
---
|
||||||
|
|
||||||
|
# Swift/iOS SDK 专项审查
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 明确审查范围和修改授权;只要求审查时不得修改代码。
|
||||||
|
2. 检查工作区和最近改动,读取目标代码、相邻实现及 `AGENTS.md` 路由出的文档。
|
||||||
|
3. 沿入口、异步回调、持久化和渲染结果双向追踪,不只检查单个函数。
|
||||||
|
4. 仅报告能由当前源码证明、可触发且值得行动的问题。
|
||||||
|
|
||||||
|
## 检查维度
|
||||||
|
|
||||||
|
### 并发与生命周期
|
||||||
|
|
||||||
|
- UI 是否回到主线程,迟到结果是否会覆盖新状态。
|
||||||
|
- token、重试、超时和取消是否保证恰好一次完成。
|
||||||
|
- 闭包、Task、通知、定时器、观察者、WKWebView 和 Vision 请求是否释放。
|
||||||
|
- PDFKit、缓存字典和持久化文件是否在正确队列或锁内访问。
|
||||||
|
|
||||||
|
### 性能与内存
|
||||||
|
|
||||||
|
- 滚动、缩放、绘画和分页热点是否包含同步 IO、重复解码或重复排版。
|
||||||
|
- EPUB 章节窗口、页图缓存、PDF 页面位图和绘画缓存是否有明确边界。
|
||||||
|
- 内存警告后可见内容能否恢复,驱逐后迟到回调是否重新撑大缓存。
|
||||||
|
- 图片像素成本、NSCache 限额、autoreleasepool 和大对象生命周期是否合理。
|
||||||
|
|
||||||
|
### SDK 兼容性
|
||||||
|
|
||||||
|
- `public` API、协议要求、初始化方法和默认行为是否意外 breaking。
|
||||||
|
- Codable、文件名、缓存键、book identifier 和 schema version 是否可迁移。
|
||||||
|
- EPUB 三种渲染路径和 PDF 两种 Provider 路径是否行为一致。
|
||||||
|
- podspec 是否包含新增源码、资源、系统 framework 和依赖。
|
||||||
|
|
||||||
|
### 交互、安全与可访问性
|
||||||
|
|
||||||
|
- 缩放锚点、Cell 复用、双页布局、手势竞争和绘画图层是否稳定。
|
||||||
|
- 图标按钮、自定义控件、动态字体和 VoiceOver 语义是否完整。
|
||||||
|
- 日志、文件路径和错误信息是否泄露敏感数据。
|
||||||
|
|
||||||
|
## 输出
|
||||||
|
|
||||||
|
按严重程度列出 findings;每条包含位置、触发条件、用户影响、根因和最小修复建议。没有发现问题时明确说明,并列出尚未覆盖的运行时验证空白。
|
||||||
|
|
||||||
|
若用户同时要求修改,沿用对应开发 Skill 的实现、验证和交付规则。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "Swift/iOS SDK 专项审查"
|
||||||
|
short_description: "审查并发、生命周期、性能、内存及公开 API 风险"
|
||||||
|
default_prompt: "Use $review-swift-ios-sdk to audit this ReadViewSDK code for iOS-specific risks."
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: start-sdk-feature-dev-lite
|
||||||
|
description: 实现 ReadViewSDK 的单模块功能、Bug 修复、UI 调整、局部重构、编译修复或小范围 CocoaPods 变更,并完成必要验证。作为默认开发入口;跨 EPUB/PDF 模块、改变公共协议或持久化格式、需要迁移回滚或严格执行完整方案时使用 start-sdk-feature-dev。
|
||||||
|
---
|
||||||
|
|
||||||
|
# SDK 轻量开发
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
用最小改动完成边界清晰的任务,形成“实现—验证—交付”闭环。
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 检查工作区,识别并保留用户已有修改。
|
||||||
|
2. 定位目标源码、现有相邻模式和 `AGENTS.md` 路由出的文档。
|
||||||
|
3. 若用户提供方案,完整读取并执行已锁定决定;源码事实使方案不可行时先说明冲突。
|
||||||
|
4. 明确 In Scope、Out of Scope、成功标准和短执行清单。
|
||||||
|
5. 按模块边界实施最小修改:
|
||||||
|
- EPUB 解析与资源:`Sources/RDEpubReaderView/EPUBCore`
|
||||||
|
- EPUB 文本排版:`Sources/RDEpubReaderView/EPUBTextRendering`
|
||||||
|
- EPUB 翻页容器:`Sources/RDEpubReaderView/ReaderView`
|
||||||
|
- EPUB 成品 UI:`Sources/RDEpubReaderView/EPUBUI`
|
||||||
|
- PDF 阅读器:`Sources/RDPDFReaderView`
|
||||||
|
- 集成与回归入口:`ReadViewDemo`
|
||||||
|
6. 自检空值、失败分支、异步乱序、取消语义、主线程、生命周期、Cell 复用、缓存边界、内存警告和可访问性。
|
||||||
|
7. 检查公共 API、持久化模型、缓存键/版本、资源路径及 podspec 是否被意外改变。
|
||||||
|
8. 按风险执行构建或定向 UI 测试;编译错误应修复并重试。
|
||||||
|
9. 代码行为显著变化时更新最接近的 `Doc/` 文档。
|
||||||
|
|
||||||
|
## 升级条件
|
||||||
|
|
||||||
|
出现以下任一情况时切换到 `start-sdk-feature-dev` 并说明:
|
||||||
|
|
||||||
|
- 同时改变 EPUB 与 PDF 阅读器,或改变多个 EPUB 层级的职责。
|
||||||
|
- 修改宿主可见协议、公共初始化方法或需要兼容迁移。
|
||||||
|
- 改变持久化格式、缓存架构、分页主流程或跨模块状态流。
|
||||||
|
- 用户要求逐项执行完整开发方案。
|
||||||
|
|
||||||
|
## 交付
|
||||||
|
|
||||||
|
最终简洁说明完成内容、关键取舍、主要文件、验证结果、未覆盖风险和同步文档;不强制套固定模板。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "SDK 轻量开发"
|
||||||
|
short_description: "完成局部功能、Bug 修复、小范围重构及对应构建验证闭环"
|
||||||
|
default_prompt: "Use $start-sdk-feature-dev-lite to implement this scoped ReadViewSDK change and verify it."
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
name: start-sdk-feature-dev
|
||||||
|
description: 实现 ReadViewSDK 的跨层或跨阅读器改造、分页/缓存/持久化系统性重构、公共 API 演进、复杂联调,或严格执行用户提供的完整方案文档。单模块功能、UI 微调、Bug 修复和局部改动优先使用 start-sdk-feature-dev-lite。
|
||||||
|
---
|
||||||
|
|
||||||
|
# SDK 完整开发
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
对复杂任务建立可追溯计划,控制接口兼容、依赖、迁移和回滚风险,完成实现、联调、验证与文档同步。
|
||||||
|
|
||||||
|
## 工作流
|
||||||
|
|
||||||
|
1. 检查工作区,区分本任务改动和用户已有改动。
|
||||||
|
2. 明确主改动模块、受影响模块、In Scope、Out of Scope、联调依赖和完成标准。
|
||||||
|
3. 按 `AGENTS.md` 读取架构、公共 API、目标子系统和测试文档,并用源码复核。
|
||||||
|
4. 用户提供方案时:
|
||||||
|
- 完整读取并提取锁定决定、任务清单、文件清单、限制和验收标准。
|
||||||
|
- 逐项执行,不自行替换技术路径、数据模型或文件布局。
|
||||||
|
- 方案与源码冲突时暂停,说明影响和最小修订建议。
|
||||||
|
5. 没有方案时制定最小可落地计划,明确执行顺序、数据/状态流、风险、回滚点和验证。
|
||||||
|
6. 实施时区分计划内修改、不可避免的“必要补齐”和可选后续项;会改变方案的偏差先确认。
|
||||||
|
7. 做跨模块自检:
|
||||||
|
- EPUB 四层依赖方向和三种渲染路径
|
||||||
|
- PDF 自定义 Provider 与 PDFKit 直读路径
|
||||||
|
- 公共 API 的源码兼容与行为兼容
|
||||||
|
- Codable/磁盘格式迁移、缓存键、版本和失效策略
|
||||||
|
- 异步 token、取消、迟到回调、主线程和生命周期
|
||||||
|
- 大图、排版产物、章节窗口和内存警告处理
|
||||||
|
- CocoaPods source/resource/framework 配置和 Demo 集成
|
||||||
|
8. 同步架构、API、子系统或测试文档;文档新增或移动时更新索引。
|
||||||
|
9. 执行构建和与风险相称的定向回归,记录无法自动覆盖的联调项。
|
||||||
|
|
||||||
|
## 方案控制
|
||||||
|
|
||||||
|
- 用户确认的方案不能被“更简单的建议”静默覆盖。
|
||||||
|
- 不以顺手治理为由扩大重构范围。
|
||||||
|
- 涉及线上数据、缓存迁移或公共 API 时必须写明兼容、回滚或降级方式。
|
||||||
|
- 新增依赖、资源或公开类型前必须确认 podspec 和宿主集成影响。
|
||||||
|
|
||||||
|
## 交付
|
||||||
|
|
||||||
|
最终说明范围和计划完成情况、关键实现与偏差、改动模块、构建/测试结果、兼容与回滚策略、未覆盖风险和同步文档。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface:
|
||||||
|
display_name: "SDK 完整开发"
|
||||||
|
short_description: "执行跨阅读器模块改造、复杂联调、兼容评估与完整验证交付"
|
||||||
|
default_prompt: "Use $start-sdk-feature-dev to implement this cross-module ReadViewSDK plan with full verification."
|
||||||
Symlink
+1
@@ -0,0 +1 @@
|
|||||||
|
../.agents/skills
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
---
|
|
||||||
name: "Discuss SDK Feature Solution"
|
|
||||||
description: "方案讨论优先 skill:用于 ReadViewSDK 新需求的实现方案分析、路径对比、取舍沟通、已定方案细化和实现交接。"
|
|
||||||
argument-hint: "粘贴需求、目标模块、约束、已知备选方案;可附加:是否已确定方案 / 是否需要推荐方案 / 是否需要落方案文档。"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Discuss SDK Feature Solution
|
|
||||||
|
|
||||||
## Purpose
|
|
||||||
|
|
||||||
面向 ReadViewSDK 的"实现方案讨论入口" skill。
|
|
||||||
用于在正式开发前,先把需求、约束、可选实现路径和关键取舍聊透;若方案已经确定,则只围绕已选方案继续细化,再交接给开发 skill 进入实现。
|
|
||||||
|
|
||||||
该 skill 借鉴 spec-driven 工作流思想:讨论阶段专门捕获灰区决策,计划阶段必须经过代码 / 文档事实核验,最终输出能直接喂给开发 skill 的结构化方案文档,避免"聊完还是不能开发"。
|
|
||||||
|
|
||||||
该 skill 的职责固定为:
|
|
||||||
- 先理解需求与约束
|
|
||||||
- 捕获灰区问题和实现假设
|
|
||||||
- 用现有代码 / 文档核验方案可行性
|
|
||||||
- 未定方案时:输出 2-4 个可行实现方案,并做对比
|
|
||||||
- 已定方案时:只围绕确认方案展开实现讨论,不再继续扩展其他方案
|
|
||||||
- 最后给出交接到开发 skill 的明确指令
|
|
||||||
- 最终必须产出一份可直接供开发 skill 使用的开发详细文档,或一段可直接执行的开发详细描述
|
|
||||||
|
|
||||||
## Core Discussion Rules
|
|
||||||
|
|
||||||
- Rule 1 — Think Before Coding
|
|
||||||
- 在提出方案前先核对代码和文档事实,不静默假设
|
|
||||||
- 必须显式写出关键假设、主要取舍和已知风险
|
|
||||||
- 遇到会改变实现路径的关键灰区,先提出并请求确认,不靠猜测补完整个方案
|
|
||||||
- 若存在更简单且满足目标的实现路径,必须主动指出并优先推荐
|
|
||||||
- Rule 2 — Simplicity First
|
|
||||||
- 推荐方案优先选择最小可落地路径,而不是概念上更"完整"的设计
|
|
||||||
- 不为了未来可能性预埋推测性扩展,不为单次使用引入抽象
|
|
||||||
- 若某个方案明显过度设计,必须直接指出并解释为什么不推荐
|
|
||||||
- Rule 3 — Surgical Changes
|
|
||||||
- 方案只覆盖完成当前目标所必需的改动面
|
|
||||||
- 不把无关重构、顺手统一风格或额外治理动作夹带进推荐方案
|
|
||||||
- 若确有相邻改动依赖,必须明确标注"必要改动"与"可选优化"的边界
|
|
||||||
- Rule 4 — Goal-Driven Execution
|
|
||||||
- 讨论输出必须先定义成功标准和验证方式,再给实现交接建议
|
|
||||||
- 不把讨论步骤本身当结果,重点是产出可执行、可验证的方案
|
|
||||||
- 交接给开发 skill 时,必须让对方清楚"做到什么算完成"
|
|
||||||
|
|
||||||
## When To Use
|
|
||||||
|
|
||||||
当用户提出以下类型需求时使用:
|
|
||||||
- "先讨论一下这个需求怎么实现"
|
|
||||||
- "这个功能可能有多种实现方式,先分析方案"
|
|
||||||
- "先别写代码,先帮我想实现路径"
|
|
||||||
- "先比较几种方案,再决定怎么做"
|
|
||||||
|
|
||||||
适用场景:
|
|
||||||
- 同一个需求可以通过多种技术路径实现
|
|
||||||
- 需要权衡 SDK 分层(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)、复用、维护成本、回归影响
|
|
||||||
- 需要在实现前先明确推荐方案和待确认细节
|
|
||||||
- 已经明确采用某个方案,但还需要继续细化实现边界、拆解落地路径和交接开发
|
|
||||||
|
|
||||||
不适用场景:
|
|
||||||
- 用户已经明确要直接实现,且实现路径基本单一时,优先使用开发类 skill
|
|
||||||
- 用户只想生成文档,不需要方案讨论时,优先使用文档类 skill
|
|
||||||
|
|
||||||
## Inputs
|
|
||||||
|
|
||||||
推荐输入:
|
|
||||||
- 需求描述
|
|
||||||
- 目标模块或 Feature(属于哪一层:EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI / Legacy)
|
|
||||||
- 已知约束(兼容性、性能、API 兼容、CocoaPods 发布等)
|
|
||||||
- 已有备选方案(如有)
|
|
||||||
- 已确认方案(如已决定)
|
|
||||||
- 是否需要推荐方案
|
|
||||||
- 是否需要最终落方案文档
|
|
||||||
|
|
||||||
若信息不足:
|
|
||||||
- 先通过代码和文档补齐可发现事实
|
|
||||||
- 再围绕真正影响方案选择的灰区进行澄清
|
|
||||||
- 若用户不想继续问答,必须显式列出"实现假设",并把假设写入方案或交接摘要
|
|
||||||
|
|
||||||
若用户已经明确指定"采用方案 X / 就按这个方案做":
|
|
||||||
- 视为进入"已定方案模式"
|
|
||||||
- 后续输出禁止继续罗列其他候选方案、备选实现或横向对比
|
|
||||||
- 仅允许在必要时补充"当前方案的风险、前提、边界和实现细化"
|
|
||||||
|
|
||||||
## Scope / Required Context
|
|
||||||
|
|
||||||
默认先读:
|
|
||||||
1. `Doc/ARCHITECTURE.md` — 四层架构、数据流、分页模式、位置模型、已知限制
|
|
||||||
2. `Doc/CODING_STYLE.md` — 命名规范(RD/RDEPUB 前缀)、分层规则、extension 拆分规则、SS→RD 迁移计划
|
|
||||||
3. `Doc/EPUB_MAINTENANCE.md` — 文件职责表、DTCoreText 渲染管线、常见排查场景
|
|
||||||
|
|
||||||
按需再读:
|
|
||||||
- 涉及 EPUB 解析时:`Sources/RDReaderView/EPUBCore/` 下相关文件
|
|
||||||
- 涉及文本渲染时:`Sources/RDReaderView/EPUBTextRendering/` 下相关文件
|
|
||||||
- 涉及阅读器容器时:`Sources/RDReaderView/RDReaderView.swift` 及同级文件
|
|
||||||
- 涉及 UI 层时:`Sources/RDReaderView/EPUBUI/` 下相关文件
|
|
||||||
- 涉及遗留代码时:`Sources/RDReaderView/LegacyRDReaderController/` 下相关文件
|
|
||||||
- 涉及 JS 桥接时:`Sources/RDReaderView/Resources/epub-bridge.js`
|
|
||||||
|
|
||||||
若文档与代码不一致:
|
|
||||||
- 以代码事实为准做方案讨论
|
|
||||||
- 在推荐方案中指出不一致点和可能影响
|
|
||||||
|
|
||||||
方案文档落地目录约束:
|
|
||||||
- 讨论型方案文档统一落到 `Doc/FeatureSolution/`(若目录不存在则创建)
|
|
||||||
- 不要把方案讨论文档写入其他目录
|
|
||||||
|
|
||||||
## SDK-Specific Discussion Rules
|
|
||||||
|
|
||||||
讨论时必须考虑的 SDK 特有约束:
|
|
||||||
|
|
||||||
- **分层边界**:方案必须明确落在哪一层,不得跨层引入反向依赖(上层依赖下层允许,反之不允许)
|
|
||||||
- **Public API 兼容性**:若改动涉及公共接口(`RDReaderView`、`RDReaderDataSource`、`RDURLReaderController`、`RDEPUBReaderController` 等),必须评估对宿主 App 的 breaking change 影响
|
|
||||||
- **渲染路径差异**:方案必须考虑三种渲染路径(`webFixedLayout` / `webInteractive` / `textReflowable`)的适用性,不能只覆盖单一路径
|
|
||||||
- **CocoaPods 发布影响**:若方案涉及新增依赖、资源文件或模块结构调整,必须评估 podspec 变更
|
|
||||||
- **RD 前缀规范**:所有新增类型必须使用 `RD` 前缀,EPUB 相关使用 `RDEPUB` 前缀
|
|
||||||
- **Legacy 层边界**:不在 Legacy 层新增功能;若方案涉及 Legacy 代码,必须明确是迁移还是在新层实现
|
|
||||||
|
|
||||||
## GSD-Inspired Discussion Rules
|
|
||||||
|
|
||||||
讨论阶段要像 `discuss -> plan -> verify` 闭环一样,先捕获决策,再验证计划,而不是直接跳到实现建议。
|
|
||||||
|
|
||||||
必须执行:
|
|
||||||
- 灰区捕获:先识别布局、接口形态、数据结构、错误态、路由、持久化、兼容性、回归范围等不明确点
|
|
||||||
- 事实核验:方案落地前必须用本仓库代码和 `Doc/` 文档确认入口、复用点、约束和风险
|
|
||||||
- 假设显式化:不能确认的问题必须写成 `Assumption`,不得藏在方案正文里
|
|
||||||
- 阻塞分级:会改变实现路径的问题标记为 `Blocking Decision`,不会改变路径的问题标记为 `Follow-up`
|
|
||||||
- 审计留痕:若落方案文档,必须包含"讨论结论 / 关键决策 / 假设 / 非范围 / 验证清单 / 开发交接指令"
|
|
||||||
- 计划可执行:最终方案必须足够小,能被开发 skill 直接逐项执行
|
|
||||||
|
|
||||||
禁止行为:
|
|
||||||
- 不得只输出宽泛建议,必须落到文件、类、方法、数据流或协议层面的执行点
|
|
||||||
- 不得在用户已确认方案后继续展开新方案,除非用户明确要求重新比较
|
|
||||||
- 不得把未经核验的包、SDK、接口能力写成已确认事实
|
|
||||||
- 不得把需要用户拍板的关键决策伪装成默认实现
|
|
||||||
|
|
||||||
## Required Workflow
|
|
||||||
|
|
||||||
### Phase 1 — 识别需求、范围、约束、现状
|
|
||||||
|
|
||||||
- 明确目标价值、影响模块(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI / Legacy)、In Scope / Out of Scope
|
|
||||||
- 识别当前项目里已有的实现模式、相邻能力和复用点
|
|
||||||
- 判断这是单层需求还是跨层需求
|
|
||||||
- 建立灰区清单,区分 `Blocking Decision` 与 `Follow-up`
|
|
||||||
|
|
||||||
### Phase 2 — 判断讨论模式
|
|
||||||
|
|
||||||
- 若方案未定:进入"多方案对比模式"
|
|
||||||
- 若方案已定:进入"单方案细化模式"
|
|
||||||
- 一旦用户已确认方案,后续同一轮讨论默认保持"单方案细化模式",除非用户明确要求重新打开方案比较
|
|
||||||
|
|
||||||
### Phase 3 — Research / Verify:核验代码与文档事实
|
|
||||||
|
|
||||||
- 对照当前仓库确认真实入口、调用链、数据模型、复用的 cell / view / handler / controller / protocol
|
|
||||||
- 若方案涉及新增文件,必须确认所属目录层级和是否需要更新 podspec 的 source_files
|
|
||||||
- 若方案涉及接口或数据字段,必须明确字段来源、空值策略和兼容策略
|
|
||||||
- 若方案涉及 JS 桥接,必须确认 epub-bridge.js 的交互契约
|
|
||||||
- 若发现文档和代码不一致,必须标注为风险或阻塞项
|
|
||||||
- 若核验结果推翻原方案,必须暂停说明,不得继续包装成可执行方案
|
|
||||||
|
|
||||||
### Phase 4A — 多方案对比模式:列出多种实现路径
|
|
||||||
|
|
||||||
- 至少提出 2 个可行方案,推荐 2-4 个方案
|
|
||||||
- 每个方案都要有清晰的实现方向,而不是抽象建议
|
|
||||||
- 优先从现有项目模式和复用能力出发
|
|
||||||
|
|
||||||
### Phase 4B — 多方案对比模式:比较方案优缺点和影响范围
|
|
||||||
|
|
||||||
- 比较每个方案的:
|
|
||||||
- 核心思路
|
|
||||||
- 落在哪一层(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)
|
|
||||||
- 适用前提
|
|
||||||
- 优点
|
|
||||||
- 风险 / 成本
|
|
||||||
- 对 SDK 分层、Public API、podspec、回归范围的影响
|
|
||||||
- 明确哪些差异会真正影响后续实现和维护
|
|
||||||
|
|
||||||
### Phase 5A — 多方案对比模式:提出推荐方案,并列出待确认细节
|
|
||||||
|
|
||||||
- 必须明确推荐一个默认方案,不能只平铺选项
|
|
||||||
- 待确认项只保留真正影响实现的关键决策
|
|
||||||
- 默认产物为对话输出;若用户明确要求,再可选落到 `Doc/FeatureSolution/` 下方案文档
|
|
||||||
|
|
||||||
### Phase 5B — 单方案细化模式:围绕确认方案展开
|
|
||||||
|
|
||||||
- 不再输出"方案 A / 方案 B / 方案 C"式内容
|
|
||||||
- 不再补充"其他也可以这样做"的备选实现,除非用户明确要求回到方案比较
|
|
||||||
- 只讨论以下内容:
|
|
||||||
- 当前方案的实现拆解(文件 / 类 / 方法 / 协议)
|
|
||||||
- SDK 分层内的模块边界与职责分配
|
|
||||||
- 关键数据流 / 状态流 / 渲染流
|
|
||||||
- 复用点、依赖点、回归点
|
|
||||||
- 对三种渲染路径的覆盖情况
|
|
||||||
- 风险、前提、灰度方式、验证要点
|
|
||||||
- 交接给开发 skill 的实现摘要
|
|
||||||
|
|
||||||
### Phase 6 — 输出实现交接建议
|
|
||||||
|
|
||||||
- 在方案确认后,明确下一步应交给哪个开发 skill:
|
|
||||||
- 小中型、单层、MVP 优先:轻量开发 skill
|
|
||||||
- 跨层、复杂联调、完整交付:完整开发 skill
|
|
||||||
- 无论是否落文档,最终都必须产出开发交接载体,且二选一不能缺失:
|
|
||||||
- 完整开发 skill:产出可直接执行的开发详细文档,默认落到 `Doc/FeatureSolution/`
|
|
||||||
- 轻量开发 skill:产出可直接粘贴执行的开发详细描述,覆盖实现目标、范围、代码落点、关键步骤、验收标准和自测要点
|
|
||||||
- 给出可直接粘贴给开发 skill 的实现摘要;若已有更完整的详细文档/描述,则摘要必须引用它而不是只给一句话概括
|
|
||||||
- 若落方案文档,必须让开发指令引用该文档的真实路径,并提醒开发 skill 严格按计划执行
|
|
||||||
|
|
||||||
## Output Contract
|
|
||||||
|
|
||||||
默认输出结构按模式区分:
|
|
||||||
|
|
||||||
若方案未定:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 灰区问题与实现假设
|
|
||||||
- C. 当前实现与约束
|
|
||||||
- D. 可选方案对比
|
|
||||||
- E. 推荐方案
|
|
||||||
- F. 待确认实现细节
|
|
||||||
- G. 实现交接建议
|
|
||||||
|
|
||||||
若方案已定:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 灰区问题与实现假设
|
|
||||||
- C. 当前实现与约束
|
|
||||||
- D. 确认方案拆解
|
|
||||||
- E. 实现风险与关键细节
|
|
||||||
- F. 实现交接建议
|
|
||||||
|
|
||||||
其中要求:
|
|
||||||
- 未定方案时:
|
|
||||||
- `B. 灰区问题与实现假设` 必须区分 Blocking Decision / Follow-up / Assumption
|
|
||||||
- `D. 可选方案对比` 至少给出 2 个方案,推荐 2-4 个
|
|
||||||
- `E. 推荐方案` 必须明确推荐一个默认方案
|
|
||||||
- `F. 待确认实现细节` 只保留会改变实现路径的关键问题
|
|
||||||
- `G. 实现交接建议` 必须明确下一步交给哪个开发 skill
|
|
||||||
- `G. 实现交接建议` 必须附带可供开发 skill 直接使用的交接内容:
|
|
||||||
- 若下一步是完整开发 skill,必须提供开发详细文档路径或完整文档正文
|
|
||||||
- 若下一步是轻量开发 skill,必须提供开发详细描述正文
|
|
||||||
- 已定方案时:
|
|
||||||
- `B. 灰区问题与实现假设` 必须列出阻塞项、假设和后续项
|
|
||||||
- `D. 确认方案拆解` 只能围绕确认方案展开,禁止附带其他方案信息
|
|
||||||
- `E. 实现风险与关键细节` 只讨论该方案落地所需信息
|
|
||||||
- `F. 实现交接建议` 必须明确下一步交给哪个开发 skill,并附带可直接执行的详细文档或详细描述
|
|
||||||
|
|
||||||
若用户要求落方案文档,文档必须包含:
|
|
||||||
- 需求目标
|
|
||||||
- 讨论结论
|
|
||||||
- 关键决策
|
|
||||||
- 实现假设
|
|
||||||
- 非范围
|
|
||||||
- SDK 分层落点(文件 / 类 / 方法 / 协议)
|
|
||||||
- 数据流 / 状态流 / 渲染流
|
|
||||||
- 开发任务清单
|
|
||||||
- 验收标准
|
|
||||||
- 自测清单
|
|
||||||
- 待确认项
|
|
||||||
- 给开发 skill 的执行指令
|
|
||||||
|
|
||||||
若未落方案文档,但下一步要交给轻量开发 skill,则最终输出中的"开发详细描述"至少必须包含:
|
|
||||||
- 实现目标
|
|
||||||
- In Scope / Out of Scope
|
|
||||||
- SDK 分层落点(文件 / 类 / 方法 / 协议)
|
|
||||||
- 实现步骤
|
|
||||||
- 关键约束与复用点
|
|
||||||
- 对三种渲染路径的覆盖说明
|
|
||||||
- 验收标准
|
|
||||||
- 自测清单
|
|
||||||
- 待确认项或实现假设
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
|
|
||||||
- 本 skill 默认只做方案讨论,不直接进入代码实现
|
|
||||||
- 默认不修改仓库文件;只有用户明确要求时,才可选落方案文档到 `Doc/FeatureSolution/`
|
|
||||||
- 即使不落方案文档,最终回复也必须包含一份可直接交给开发 skill 使用的详细交接内容,不能只停留在高层方案结论
|
|
||||||
- 若本次调用只做讨论或只新增方案文档,可不执行构建验证
|
|
||||||
- 若新增或移动方案文档,建议同步更新目录索引
|
|
||||||
- 若后续进入代码实现,则由对应开发 skill 负责执行项目默认构建验证(`xcodebuild` 或 CocoaPods 集成验证)
|
|
||||||
- 若用户已确认方案,则默认进入单方案细化模式,除非用户明确要求重新比较备选方案
|
|
||||||
|
|
||||||
## Maintenance Rules
|
|
||||||
|
|
||||||
- 该 skill 的职责是"讨论后交接实现",不和开发 skill、文档类 skill 重叠
|
|
||||||
- 优先复用 `Doc/` 作为知识源,不新增独立 references 体系
|
|
||||||
- 方案文档目录固定为 `Doc/FeatureSolution/`
|
|
||||||
- 持续保持 `discuss -> research/verify -> plan handoff` 的轻量闭环,避免退化成只聊天不交付的建议列表
|
|
||||||
- 若该 skill 的默认输出结构、交接规则或适用边界调整,必须同步更新对应文档
|
|
||||||
- SDK 四层架构(EPUBCore → EPUBTextRendering → RDReaderView → EPUBUI)是方案讨论的核心参照框架,任何方案都必须明确标注落点层级
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
---
|
|
||||||
name: "Start SDK Feature Dev Lite"
|
|
||||||
description: "轻量开发主控 skill:用于 ReadViewSDK 的小中型功能开发、单层改动、局部重构、文档同步与编译修复。"
|
|
||||||
argument-hint: "粘贴需求、目标层级、验收标准;可附加:仅 MVP / 禁止新增依赖 / 指定渲染路径。"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Start SDK Feature Dev Lite
|
|
||||||
|
|
||||||
## Purpose
|
|
||||||
|
|
||||||
面向 ReadViewSDK 的轻量开发入口 skill。
|
|
||||||
用于在现有项目约束下完成"小到中型"需求,遵循"先识别范围、再按需读文档、后实现、再验证、最后交付"的闭环。
|
|
||||||
|
|
||||||
该 skill 是默认开发入口,优先覆盖:
|
|
||||||
- 单层内的新功能 MVP 实现
|
|
||||||
- 小范围重构或代码整理
|
|
||||||
- 文档同步更新
|
|
||||||
- 编译错误定位与修复
|
|
||||||
- 单个模块的 bug 修复或行为调整
|
|
||||||
- podspec 小幅调整
|
|
||||||
|
|
||||||
默认吸收项目 `Doc/CODING_STYLE.md` 中的 Swift/iOS 通用规则;若任务重点落在并发、性能、可访问性或安全,再额外展开该专项的检查项。
|
|
||||||
|
|
||||||
## Core Execution Rules
|
|
||||||
|
|
||||||
- Rule 1 — Think Before Coding
|
|
||||||
- 先核对代码和文档事实,不静默假设
|
|
||||||
- 必须显式写出关键假设、主要取舍和已知风险
|
|
||||||
- 遇到会改变实现路径的关键灰区,先暂停确认,不靠猜测继续推进
|
|
||||||
- 若存在更简单且满足目标的实现路径,必须主动指出并优先采用
|
|
||||||
- Rule 2 — Simplicity First
|
|
||||||
- 只做满足需求和验收标准的最小实现
|
|
||||||
- 不增加推测性功能,不为单次使用引入抽象
|
|
||||||
- 若方案让资深工程师也会觉得过度设计,必须继续简化
|
|
||||||
- Rule 3 — Surgical Changes
|
|
||||||
- 只修改完成当前需求所必需的文件和代码
|
|
||||||
- 不顺手重构无关代码,不扩散到相邻层做"顺便优化"
|
|
||||||
- 非必要不改注释、格式或既有结构,新增代码保持现有风格
|
|
||||||
- Rule 4 — Goal-Driven Execution
|
|
||||||
- 先定义成功标准,再围绕成功标准实施和验证
|
|
||||||
- 不给自己堆步骤,重点是闭环达到验收结果
|
|
||||||
- 修改后必须验证,未验证通过前不能视为完成
|
|
||||||
|
|
||||||
## When To Use
|
|
||||||
|
|
||||||
当用户提出以下类型需求时使用:
|
|
||||||
- "使用 start-sdk-feature-dev-lite 完成这个功能"
|
|
||||||
- 在 ReadViewSDK 中开发单一功能或单层变更
|
|
||||||
- 需要修复局部编译错误或行为问题
|
|
||||||
- 需要同步更新文档
|
|
||||||
- 需要小幅调整 podspec
|
|
||||||
|
|
||||||
不适用场景:
|
|
||||||
- 需求跨多个 SDK 层级、涉及多阶段联调或需要完整项目级方案时,改用 `start-sdk-feature-dev`
|
|
||||||
- 目标是只生成文档而不改业务代码时,优先使用文档类 skill
|
|
||||||
- 目标是方案讨论而不进入实现时,优先使用 `discuss-sdk-feature-solution`
|
|
||||||
|
|
||||||
## Inputs
|
|
||||||
|
|
||||||
推荐输入:
|
|
||||||
- 功能名称
|
|
||||||
- 目标 / 用户价值
|
|
||||||
- 范围(In Scope)
|
|
||||||
- 非范围(Out of Scope)
|
|
||||||
- 目标层级(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)
|
|
||||||
- 详细需求
|
|
||||||
- 验收标准
|
|
||||||
- 约束(兼容性 / 性能 / 禁止新增依赖 / 指定渲染路径)
|
|
||||||
|
|
||||||
若信息不足:
|
|
||||||
- 先基于代码和文档补齐可发现事实
|
|
||||||
- 再列最多 5 条关键假设
|
|
||||||
- 基于假设继续推进 MVP,并在交付中标注待确认项
|
|
||||||
|
|
||||||
## Scope / Required Context
|
|
||||||
|
|
||||||
仅针对 ReadViewSDK 现有架构执行。
|
|
||||||
|
|
||||||
SDK 四层架构参照:
|
|
||||||
- Layer 1 — EPUBCore(`Sources/RDReaderView/EPUBCore/`):EPUB 解析引擎
|
|
||||||
- Layer 2 — EPUBTextRendering(`Sources/RDReaderView/EPUBTextRendering/`):文本渲染路径
|
|
||||||
- Layer 3 — RDReaderView(`Sources/RDReaderView/` 根目录):分页阅读器容器
|
|
||||||
- Layer 4 — EPUBUI(`Sources/RDReaderView/EPUBUI/`):开箱即用 UI
|
|
||||||
- Legacy(`Sources/RDReaderView/LegacyRDReaderController/`):遗留代码,不在其上新增功能
|
|
||||||
|
|
||||||
分层依赖规则(上→下允许,下→上禁止):
|
|
||||||
- EPUBUI → RDReaderView → EPUBTextRendering → EPUBCore
|
|
||||||
|
|
||||||
默认先读:
|
|
||||||
1. `Doc/ARCHITECTURE.md` — 四层架构、数据流、分页模式、位置模型
|
|
||||||
2. `Doc/CODING_STYLE.md` — 命名规范、分层规则、extension 拆分规则
|
|
||||||
3. `Doc/EPUB_MAINTENANCE.md` — 文件职责表、渲染管线、排查场景
|
|
||||||
|
|
||||||
按需再读:
|
|
||||||
- `Doc/FeatureSolution/*.md`(若有方案文档)
|
|
||||||
- 涉及哪一层就读该层目录下的相关源码
|
|
||||||
- 涉及 JS 桥接时:`Sources/RDReaderView/Resources/epub-bridge.js`
|
|
||||||
- 涉及 podspec 时:`RDReaderView.podspec`
|
|
||||||
|
|
||||||
若文档与代码不一致:
|
|
||||||
- 以代码事实为准完成本次实现
|
|
||||||
- 在交付中标注不一致点,并指出建议更新的文档
|
|
||||||
|
|
||||||
## Required Workflow
|
|
||||||
|
|
||||||
### Phase 1 — 识别需求和范围
|
|
||||||
|
|
||||||
- 明确目标价值、影响层级(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)、In Scope / Out of Scope
|
|
||||||
- 优先做最小可落地实现,不做需求外重构
|
|
||||||
- 若需求信息不足,先通过仓库事实补齐,再基于假设推进
|
|
||||||
|
|
||||||
### Phase 2 — 按需读取 Doc 与代码事实
|
|
||||||
|
|
||||||
- 先读默认 Doc(ARCHITECTURE / CODING_STYLE / EPUB_MAINTENANCE)
|
|
||||||
- 根据需求类型补读对应层级的源码
|
|
||||||
- 用源码确认真实入口、调用链和复用点,不只依赖文档
|
|
||||||
|
|
||||||
### Phase 3 — 形成最小实现方案
|
|
||||||
|
|
||||||
- 保持分层边界:
|
|
||||||
- EPUB 解析逻辑在 EPUBCore
|
|
||||||
- 文本渲染逻辑在 EPUBTextRendering
|
|
||||||
- 分页容器逻辑在 RDReaderView
|
|
||||||
- 开箱即用 UI 在 EPUBUI
|
|
||||||
- 不在 Legacy 层新增功能
|
|
||||||
- 命名、注释、日志风格遵循 `Doc/CODING_STYLE.md`
|
|
||||||
- Swift / iOS 默认规则:
|
|
||||||
- 新增 Swift 类型遵循 `RD` / `RDEPUB` 前缀和层级目录归属
|
|
||||||
- 避免新增强制解包;确需使用时必须先收敛前置条件
|
|
||||||
- 不为"现代化"而重写稳定代码;仅在本次需求明确受益时再迁移系统 API
|
|
||||||
- 当前项目默认保持 UIKit + Auto Layout + 既有组件风格,SDK 层不使用 SnapKit
|
|
||||||
- 注释和日志使用中文
|
|
||||||
- Debug 输出放在 `#if DEBUG` 守卫下
|
|
||||||
- 不在日志中输出敏感信息
|
|
||||||
- 异步闭包默认 `[weak self]`,UI 更新回到主线程
|
|
||||||
- 通知 / 定时器 / 回调在生命周期结束时必须清理
|
|
||||||
- 数据模型用 `struct` + `Codable` + `Equatable`,服务对象用 `final class`
|
|
||||||
- 可见性按最小原则:`private` > `fileprivate` > `internal` > `public`
|
|
||||||
- 错误使用 `enum` + `LocalizedError`,禁止 force unwrap
|
|
||||||
- 单文件若预计超过 600 行,需主动拆分扩展文件
|
|
||||||
|
|
||||||
### Phase 4 — 执行修改与文档同步
|
|
||||||
|
|
||||||
- 所有代码改动遵循最小改动原则
|
|
||||||
- 修改代码时必须补充必要注释,重点说明关键逻辑、边界条件和不直观处理;不要省略应有注释,也不要添加无信息量的描述性注释
|
|
||||||
- 默认补做轻量 SDK 自检:
|
|
||||||
- 新增类型是否使用正确前缀和层级归属
|
|
||||||
- 本次改动涉及的渲染路径是否正常工作
|
|
||||||
- Public API 是否有意外 breaking change
|
|
||||||
- podspec 是否需要更新(新增文件时)
|
|
||||||
- 生命周期、通知/定时器/回调清理是否完整
|
|
||||||
- 异步闭包是否考虑 `[weak self]`
|
|
||||||
- 修改代码后必须同步更新受影响文档,不能只停留在代码实现
|
|
||||||
- 若本次改动涉及 EPUB 维护相关,必须回写 `Doc/EPUB_MAINTENANCE.md`
|
|
||||||
- 若本次是方案讨论文档交接落地,方案类文档统一放到 `Doc/FeatureSolution/`
|
|
||||||
- 若新增、重命名或移动文档,必须同步更新目录索引
|
|
||||||
|
|
||||||
### Phase 5 — 构建验证与交付
|
|
||||||
|
|
||||||
- 完成修改后,按项目默认命令执行编译验证
|
|
||||||
- 若出现编译错误,自动修复并重编译
|
|
||||||
- 若遇构建锁问题,自动重试
|
|
||||||
- 交付时固定输出:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 开发计划
|
|
||||||
- C. 开发实施
|
|
||||||
- D. 验证结果
|
|
||||||
- E. 交付摘要
|
|
||||||
|
|
||||||
## Output Contract
|
|
||||||
|
|
||||||
最终回复必须完整输出以下 5 个板块,标题保持一致:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 开发计划
|
|
||||||
- C. 开发实施
|
|
||||||
- D. 验证结果
|
|
||||||
- E. 交付摘要
|
|
||||||
|
|
||||||
各板块内容要求:
|
|
||||||
- A:3-6 条,覆盖目标价值、范围、目标层级、限制
|
|
||||||
- B:按"方案对齐 / MVP 实现 / 验证与交付"三阶段组织
|
|
||||||
- C:描述实际改动、关键实现取舍,以及本次补充了哪些关键代码注释
|
|
||||||
- D:给出构建结果、关键路径验证、未覆盖风险
|
|
||||||
- E:列出改动文件、关键取舍、已同步文档与具体文档落点、后续建议
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
|
|
||||||
若本次调用修改了任何 Swift / Objective-C / 工程配置 / podspec 文件,必须执行构建验证。
|
|
||||||
|
|
||||||
验证方式:
|
|
||||||
- 若 Demo 工程可用:
|
|
||||||
```bash
|
|
||||||
xcodebuild build -workspace ReadViewSDKDemo/ReadViewSDKDemo.xcworkspace -scheme ReadViewSDKDemo -sdk iphonesimulator -derivedDataPath /private/tmp/readview-sdk-derived
|
|
||||||
```
|
|
||||||
- 若仅有 SDK 源码(无 workspace):
|
|
||||||
```bash
|
|
||||||
pod lib lint RDReaderView.podspec --allow-warnings
|
|
||||||
```
|
|
||||||
|
|
||||||
验证规则:
|
|
||||||
- 编译失败时必须自行修复并重试
|
|
||||||
- 遇到 `database is locked` 等锁问题时自动重试,建议最多 5 次
|
|
||||||
- 直到 `BUILD SUCCEEDED` 或 `pod lib lint passed` 才可交付
|
|
||||||
- 如果本次仅修改文档或 skill 文件,可跳过构建,但要在交付中明确说明原因
|
|
||||||
|
|
||||||
## Maintenance Rules
|
|
||||||
|
|
||||||
- 优先复用 `Doc/`,不要把项目级规则复制进多个 skill 造成双份维护
|
|
||||||
- 新增项目约束时,优先更新 `Doc/CODING_STYLE.md`、`Doc/ARCHITECTURE.md` 等主文档,再调整 skill
|
|
||||||
- 轻量与完整要保持"轻重不同、规则不冲突",其中完整版应在轻量版闭环基础上扩展跨层与联调要求,而不是另起一套风格
|
|
||||||
- 变更默认流程、输出格式或适用场景时,必须同步更新相关文档
|
|
||||||
- 本 skill 持续作为默认开发入口,保持"轻量、清晰、可直接执行"
|
|
||||||
- SDK 四层架构是执行的核心参照框架,单层改动也必须明确标注落点层级
|
|
||||||
@@ -1,309 +0,0 @@
|
|||||||
---
|
|
||||||
name: "Start SDK Feature Dev"
|
|
||||||
description: "完整开发主控 skill:用于 ReadViewSDK 的跨层功能开发、多阶段联调、结构性重构与完整交付。"
|
|
||||||
argument-hint: "粘贴完整需求,建议包含:背景、目标、范围、目标层级、交互说明、数据约束、验收标准、渲染路径覆盖要求。"
|
|
||||||
---
|
|
||||||
|
|
||||||
# Start SDK Feature Dev
|
|
||||||
|
|
||||||
## Purpose
|
|
||||||
|
|
||||||
面向 ReadViewSDK 的完整开发主控 skill。
|
|
||||||
用于复杂度高于单层修改的需求,遵循"先识别范围、再按需读文档、后对齐既定开发计划、再严格执行、再验证、最后交付"的闭环,并补充跨层联调、风险控制、回滚点和完整交付要求。
|
|
||||||
|
|
||||||
该 skill 优先覆盖:
|
|
||||||
- 跨多个 SDK 层级(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)的功能开发
|
|
||||||
- 多阶段联调与完整交付
|
|
||||||
- 结构性重构或系统性收敛
|
|
||||||
- 涉及 EPUB 解析、渲染管线、阅读器容器、UI 层协同改造的需求
|
|
||||||
- 需要更完整风险说明、文档同步和验收闭环的开发任务
|
|
||||||
|
|
||||||
默认吸收项目 `Doc/CODING_STYLE.md` 中的 Swift/iOS 通用规则;若任务重点落在并发、性能、可访问性或安全,再额外展开该专项的检查项。
|
|
||||||
|
|
||||||
## Core Execution Rules
|
|
||||||
|
|
||||||
- Rule 1 — Think Before Coding
|
|
||||||
- 先核对代码、文档和计划事实,不静默假设
|
|
||||||
- 必须显式写出关键假设、主要取舍和已知风险
|
|
||||||
- 遇到会改变计划或实现路径的关键灰区,先暂停确认,不靠猜测继续推进
|
|
||||||
- 若存在更简单且满足目标的实现路径,只能作为建议提出;有既定计划时不得自行改用
|
|
||||||
- Rule 2 — Simplicity First
|
|
||||||
- 只做满足需求、计划和验收标准的最小实现
|
|
||||||
- 不增加推测性功能,不为单次使用引入抽象
|
|
||||||
- 若方案让资深工程师也会觉得过度设计,必须继续简化或回到计划边界内
|
|
||||||
- Rule 3 — Surgical Changes
|
|
||||||
- 只修改完成当前需求和计划项所必需的文件与代码
|
|
||||||
- 不顺手重构无关代码,不扩散到相邻层做"顺便优化"
|
|
||||||
- 非必要不改注释、格式或既有结构,新增代码保持现有风格
|
|
||||||
- Rule 4 — Goal-Driven Execution
|
|
||||||
- 先定义成功标准,再围绕成功标准实施和验证
|
|
||||||
- 计划只是约束,不是目标本身;目标是按计划完成验收闭环
|
|
||||||
- 修改后必须验证,未验证通过前不能视为完成
|
|
||||||
|
|
||||||
## Plan Execution Rule
|
|
||||||
|
|
||||||
若用户提供了开发计划文档、方案文档或明确引用 `Doc/FeatureSolution/*.md` 中的开发方案,本 skill 必须把该文档视为本次实现的主计划来源。
|
|
||||||
|
|
||||||
严格执行规则:
|
|
||||||
- 必须先完整读取用户指定的开发计划文档,再开始代码修改
|
|
||||||
- 必须从计划中抽取任务清单、文件清单、实现边界、非范围和验收标准
|
|
||||||
- 必须按计划逐项实现,不得自行更换方案、合并步骤、替换文件布局、改变数据模型设计或引入计划外抽象
|
|
||||||
- 必须遵守计划中的"不做 / 不新增 / 不使用 / 暂不实现"等限制项
|
|
||||||
- 若计划与代码事实冲突,或计划中某项无法直接落地,必须暂停并向用户说明冲突点、影响和可选处理方式;不得自行选择替代方案继续实现
|
|
||||||
- 若发现更优实现方式,只能作为"建议"在交付或暂停说明中提出,不得在本次实现中自由采用
|
|
||||||
- 若计划未覆盖某个必要细节,只允许做最小补齐;补齐内容必须在交付中明确标注为"计划未写明,按最小必要实现补齐"
|
|
||||||
- 若用户要求"严格按照开发计划执行 / 不要自由发挥",必须把偏离计划视为阻塞项处理
|
|
||||||
|
|
||||||
## When To Use
|
|
||||||
|
|
||||||
当用户提出以下类型需求时使用:
|
|
||||||
- "使用 start-sdk-feature-dev 实现这个需求"
|
|
||||||
- 一个需求影响多个 SDK 层级(跨 EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI)
|
|
||||||
- 需要完整计划、实现、联调、回归和文档交付
|
|
||||||
- 需要跨 EPUB 解析、渲染、阅读器容器、UI 的协同改造
|
|
||||||
- 需要明确阶段性计划、回滚点和完整验收说明
|
|
||||||
|
|
||||||
Lite 与 Full 的边界:
|
|
||||||
- 轻量开发 skill:单层、小中型、MVP 优先
|
|
||||||
- 本 skill(start-sdk-feature-dev):跨层、复杂联调、需要更完整方案和验收
|
|
||||||
|
|
||||||
## Inputs
|
|
||||||
|
|
||||||
推荐输入模板:
|
|
||||||
- 功能名称
|
|
||||||
- 背景与目标
|
|
||||||
- 用户故事
|
|
||||||
- 详细需求
|
|
||||||
- 非范围
|
|
||||||
- 目标层级(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI / Legacy)
|
|
||||||
- 交互说明(含空态 / 错误态 / 加载态)
|
|
||||||
- 渲染路径覆盖要求(webFixedLayout / webInteractive / textReflowable / 不限)
|
|
||||||
- 数据与接口约束
|
|
||||||
- 验收标准(Given-When-Then)
|
|
||||||
- 兼容性要求(Public API 是否 breaking、podspec 变更等)
|
|
||||||
- 性能与安全要求
|
|
||||||
- 发布时间或优先级
|
|
||||||
|
|
||||||
若信息不足:
|
|
||||||
- 先基于代码和文档补齐可发现事实
|
|
||||||
- 再列最多 5 条关键假设
|
|
||||||
- 若没有既定开发计划,可基于假设继续推进最小可落地实现,并在交付中标注待确认项
|
|
||||||
- 若已有开发计划,信息不足时不得自行扩展方案;只能做计划内实现或暂停确认
|
|
||||||
|
|
||||||
## Scope / Required Context
|
|
||||||
|
|
||||||
仅针对 ReadViewSDK 现有架构执行。
|
|
||||||
|
|
||||||
SDK 四层架构参照:
|
|
||||||
- Layer 1 — EPUBCore(`Sources/RDReaderView/EPUBCore/`):EPUB 解析引擎,ZIP 解压、OPF 解析、manifest/spine/TOC、资源 URL 解析、离屏 WKWebView 分页、阅读会话状态机、JS 桥接
|
|
||||||
- Layer 2 — EPUBTextRendering(`Sources/RDReaderView/EPUBTextRendering/`):文本渲染路径,DTCoreText 转 NSAttributedString 后按字符范围分页
|
|
||||||
- Layer 3 — RDReaderView(`Sources/RDReaderView/` 根目录 6 个文件):分页阅读器容器 UIView,支持 pageCurl / horizontalScroll / verticalScroll / horizontalCoverScroll 四种模式
|
|
||||||
- Layer 4 — EPUBUI(`Sources/RDReaderView/EPUBUI/`):开箱即用 UI,工具栏、目录面板、高亮管理、设置面板、阅读位置持久化
|
|
||||||
- Legacy(`Sources/RDReaderView/LegacyRDReaderController/`):遗留代码,不在其上新增功能
|
|
||||||
|
|
||||||
分层依赖规则:
|
|
||||||
- 上层可依赖下层,下层不得依赖上层
|
|
||||||
- EPUBUI 可依赖 RDReaderView、EPUBTextRendering、EPUBCore
|
|
||||||
- RDReaderView 可依赖 EPUBTextRendering、EPUBCore
|
|
||||||
- EPUBTextRendering 可依赖 EPUBCore
|
|
||||||
- EPUBCore 不依赖任何上层
|
|
||||||
|
|
||||||
若确需跨层改动:
|
|
||||||
- 必须在计划中写明影响范围
|
|
||||||
- 必须在交付中写明回滚点或回退策略
|
|
||||||
|
|
||||||
默认先读:
|
|
||||||
1. `Doc/ARCHITECTURE.md` — 四层架构、数据流、分页模式、位置模型、已知限制
|
|
||||||
2. `Doc/CODING_STYLE.md` — 命名规范(RD/RDEPUB 前缀)、分层规则、extension 拆分、SS→RD 迁移计划
|
|
||||||
3. `Doc/EPUB_MAINTENANCE.md` — 文件职责表、DTCoreText 渲染管线、常见排查场景
|
|
||||||
|
|
||||||
按需再读:
|
|
||||||
- `Doc/FeatureSolution/*.md`(若有方案文档)
|
|
||||||
- 涉及 EPUB 解析时:`Sources/RDReaderView/EPUBCore/` 下相关文件
|
|
||||||
- 涉及文本渲染时:`Sources/RDReaderView/EPUBTextRendering/` 下相关文件
|
|
||||||
- 涉及阅读器容器时:`Sources/RDReaderView/RDReaderView.swift` 及同级文件
|
|
||||||
- 涉及 UI 层时:`Sources/RDReaderView/EPUBUI/` 下相关文件
|
|
||||||
- 涉及遗留代码时:`Sources/RDReaderView/LegacyRDReaderController/` 下相关文件
|
|
||||||
- 涉及 JS 桥接时:`Sources/RDReaderView/Resources/epub-bridge.js`
|
|
||||||
- 涉及 podspec 时:`RDReaderView.podspec`
|
|
||||||
|
|
||||||
若文档与代码不一致:
|
|
||||||
- 以代码事实为准落地
|
|
||||||
- 在交付中说明不一致点和建议更新的文档项
|
|
||||||
|
|
||||||
若开发计划文档与代码不一致:
|
|
||||||
- 不得直接以代码事实替换计划继续开发
|
|
||||||
- 必须先判断不一致是否影响计划执行
|
|
||||||
- 会影响计划执行时,暂停并向用户说明冲突点和建议调整项
|
|
||||||
- 不影响计划执行时,按计划继续,并在交付中标注该不一致点
|
|
||||||
|
|
||||||
## SDK-Specific Execution Rules
|
|
||||||
|
|
||||||
### 命名与可见性
|
|
||||||
- 所有新增类型必须使用 `RD` 前缀,EPUB 相关使用 `RDEPUB` 前缀
|
|
||||||
- 新增类型归属正确层级目录,不得随意放置
|
|
||||||
- 可见性按最小原则:`private` > `fileprivate` > `internal` > `public`
|
|
||||||
- 数据模型用 `struct` + `Codable` + `Equatable`
|
|
||||||
- 服务对象用 `final class`
|
|
||||||
|
|
||||||
### 代码组织
|
|
||||||
- 单文件超过 600 行需主动拆分 `TypeName+Feature.swift` 扩展文件
|
|
||||||
- 大型 Controller 超过 1000 行必须拆分
|
|
||||||
- extension 文件承担独立子职责,不只做"行数搬运"
|
|
||||||
|
|
||||||
### 内存与并发
|
|
||||||
- 异步闭包默认 `[weak self]`
|
|
||||||
- UI 更新必须回到主线程
|
|
||||||
- 通知 / 定时器 / 回调在 deinit 或生命周期结束时必须清理
|
|
||||||
|
|
||||||
### 渲染路径覆盖
|
|
||||||
- 新增功能必须评估对三种渲染路径的影响:
|
|
||||||
- `webFixedLayout`:固定版式 EPUB(漫画、绘本)— WKWebView 渲染
|
|
||||||
- `webInteractive`:可重排 + 交互脚本 EPUB — WKWebView 渲染
|
|
||||||
- `textReflowable`:纯文本可重排 EPUB — DTCoreText 渲染
|
|
||||||
- 若功能仅适用于部分路径,必须在交付中明确标注适用范围和不适用路径的处理方式
|
|
||||||
|
|
||||||
### Public API 兼容性
|
|
||||||
- 涉及公共接口(`RDReaderView`、`RDReaderDataSource`、`RDURLReaderController`、`RDEPUBReaderController` 等)的改动,必须评估 breaking change
|
|
||||||
- 若存在 breaking change,必须在交付中标注并给出迁移指引
|
|
||||||
- 新增 public API 需考虑 Objective-C 互操作(`@objc`、`@objcMembers`)
|
|
||||||
|
|
||||||
### CocoaPods 发布影响
|
|
||||||
- 新增源文件:确认 podspec `source_files` glob 是否已覆盖
|
|
||||||
- 新增资源文件:确认 podspec `resource` / `resource_bundles` 是否已覆盖
|
|
||||||
- 新增依赖:确认 podspec `dependency` 是否已声明,评估对宿主 App 的依赖传递影响
|
|
||||||
- 模块目录结构调整:必须同步更新 podspec
|
|
||||||
|
|
||||||
### JS 桥接
|
|
||||||
- 涉及 `epub-bridge.js` 的改动,必须确认 JS ↔ Swift 消息契约的一致性
|
|
||||||
- JS 侧新增消息类型时,Swift 侧必须有对应处理分支
|
|
||||||
- 修改已有消息类型时,必须评估向后兼容
|
|
||||||
|
|
||||||
### 错误处理
|
|
||||||
- 使用 `enum` + `LocalizedError` 定义错误类型
|
|
||||||
- 禁止 force unwrap(`!`),确需使用时必须先收敛前置条件
|
|
||||||
- 关键路径的错误必须向调用方传递,不得静默吞掉
|
|
||||||
|
|
||||||
## Required Workflow
|
|
||||||
|
|
||||||
### Phase 1 — 识别需求和范围
|
|
||||||
|
|
||||||
- 明确目标价值、影响层级(EPUBCore / EPUBTextRendering / RDReaderView / EPUBUI / Legacy)、In Scope / Out of Scope
|
|
||||||
- 判断是否涉及跨层、跨渲染路径、跨模块联调
|
|
||||||
- 若用户提供开发计划文档,先确认本次执行的唯一计划来源,并提取计划任务清单
|
|
||||||
- 优先做计划内最小可落地实现,不做需求外重构
|
|
||||||
- 若需求信息不足,先通过仓库事实补齐,再基于假设推进
|
|
||||||
|
|
||||||
### Phase 2 — 按需读取 Doc 与代码事实
|
|
||||||
|
|
||||||
- 若用户指定开发计划文档,必须先完整读取该文档
|
|
||||||
- 先读默认 Doc(ARCHITECTURE / CODING_STYLE / EPUB_MAINTENANCE)
|
|
||||||
- 根据需求类型补读各层源码和相关文档
|
|
||||||
- 用源码确认真实入口、调用链、数据流、状态流和复用点,不只依赖文档
|
|
||||||
|
|
||||||
### Phase 3 — 对齐并锁定开发计划
|
|
||||||
|
|
||||||
- 若已有开发计划,必须按计划锁定实现路径,不重新设计方案
|
|
||||||
- 若没有开发计划,才允许形成最小可落地方案:先复用现有模式与能力,再考虑新增抽象
|
|
||||||
- 保持分层边界:
|
|
||||||
- EPUB 解析逻辑在 EPUBCore
|
|
||||||
- 文本渲染逻辑在 EPUBTextRendering
|
|
||||||
- 分页容器逻辑在 RDReaderView
|
|
||||||
- 开箱即用 UI 在 EPUBUI
|
|
||||||
- 不在 Legacy 层新增功能
|
|
||||||
- 命名、注释、日志风格遵循 `Doc/CODING_STYLE.md`
|
|
||||||
- Swift / iOS 默认规则:
|
|
||||||
- 新增 Swift 类型遵循 `RD` / `RDEPUB` 前缀和层级目录归属
|
|
||||||
- 避免新增强制解包;确需使用时必须先收敛前置条件
|
|
||||||
- 不为"现代化"而重写稳定代码;仅在本次需求明确受益时再迁移系统 API
|
|
||||||
- 当前项目默认保持 UIKit + Auto Layout + 既有组件风格,SDK 层不使用 SnapKit
|
|
||||||
- 注释和日志使用中文
|
|
||||||
- Debug 输出放在 `#if DEBUG` 守卫下
|
|
||||||
- 不在日志中输出敏感信息
|
|
||||||
- 单文件预计超过 600 行需主动拆分,超过 1000 行必须拆分
|
|
||||||
- 若为跨层需求,计划中必须写清:
|
|
||||||
- 主改动层级
|
|
||||||
- 被影响层级
|
|
||||||
- 渲染路径覆盖范围
|
|
||||||
- 联调依赖点
|
|
||||||
- 关键风险
|
|
||||||
- 回滚点或降级方式
|
|
||||||
- 开始编码前必须形成内部执行清单,清单项必须能追溯到开发计划;计划外项只能标记为"必要补齐"或"待确认",不能直接实施
|
|
||||||
|
|
||||||
### Phase 4 — 执行修改与文档同步
|
|
||||||
|
|
||||||
- 所有代码改动遵循计划内最小改动原则
|
|
||||||
- 严格按开发计划清单逐项修改;不得临时改换实现方式或增加计划外功能
|
|
||||||
- 若执行中需要偏离计划,必须暂停确认,不能先改后说明
|
|
||||||
- 修改代码时必须补充必要注释,重点说明关键逻辑、边界条件和不直观处理
|
|
||||||
- 默认补做 SDK 自检:
|
|
||||||
- 检查新增类型是否使用正确前缀和层级归属
|
|
||||||
- 检查三种渲染路径的覆盖情况
|
|
||||||
- 检查 Public API 是否有意外 breaking change
|
|
||||||
- 检查 podspec 是否需要更新
|
|
||||||
- 检查 JS 桥接消息契约是否一致
|
|
||||||
- 关键页面或组件检查生命周期、通知/定时器/回调清理是否完整
|
|
||||||
- 新增 UI 检查长文本、图标按钮语义、重要状态是否只靠颜色表达
|
|
||||||
- 异步闭包默认考虑 `[weak self]`,UI 更新回到主线程
|
|
||||||
- 修改代码后必须同步更新受影响文档,不能只停留在代码实现
|
|
||||||
- 若本次改动涉及 EPUB 维护相关,必须回写 `Doc/EPUB_MAINTENANCE.md`
|
|
||||||
- 若本次是方案讨论文档交接落地,方案类文档统一放到 `Doc/FeatureSolution/`
|
|
||||||
- 若新增、重命名或移动文档,必须同步更新目录索引
|
|
||||||
|
|
||||||
### Phase 5 — 构建验证与交付
|
|
||||||
|
|
||||||
- 完成修改后,按项目默认命令执行编译验证
|
|
||||||
- 若出现编译错误,自动修复并重编译
|
|
||||||
- 若遇构建锁问题,自动重试(建议最多 5 次)
|
|
||||||
- 若是跨层需求,除构建外还应补充关键联调路径说明
|
|
||||||
- 交付时固定输出:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 开发计划
|
|
||||||
- C. 开发实施
|
|
||||||
- D. 验证结果
|
|
||||||
- E. 交付摘要
|
|
||||||
|
|
||||||
## Output Contract
|
|
||||||
|
|
||||||
最终回复必须完整输出以下 5 个固定板块:
|
|
||||||
- A. 需求理解
|
|
||||||
- B. 开发计划
|
|
||||||
- C. 开发实施
|
|
||||||
- D. 验证结果
|
|
||||||
- E. 交付摘要
|
|
||||||
|
|
||||||
各板块内容要求:
|
|
||||||
- A:3-8 条,覆盖目标价值、范围、目标层级、渲染路径覆盖、交互流、限制
|
|
||||||
- B:按"计划来源 / 计划任务清单 / 执行顺序 / 验证与交付"组织;若有开发计划文档,必须逐条对应计划项
|
|
||||||
- C:描述实现过程、复用点、关键取舍,以及本次补充了哪些关键代码注释;若有计划未写明但必须补齐的内容,必须单独标注
|
|
||||||
- D:给出编译结果、关键路径验证、自动重试/自动修复情况、未覆盖风险
|
|
||||||
- E:列出改动文件、计划符合情况、关键取舍、回滚点或降级方式、已同步文档与具体文档落点、后续建议
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
|
|
||||||
若本次调用修改了任何 Swift / Objective-C / 工程配置 / podspec 文件,必须执行构建验证。
|
|
||||||
|
|
||||||
验证方式:
|
|
||||||
- 若 Demo 工程可用:
|
|
||||||
```bash
|
|
||||||
xcodebuild build -workspace ReadViewSDKDemo/ReadViewSDKDemo.xcworkspace -scheme ReadViewSDKDemo -sdk iphonesimulator -derivedDataPath /private/tmp/readview-sdk-derived
|
|
||||||
```
|
|
||||||
- 若仅有 SDK 源码(无 workspace):
|
|
||||||
```bash
|
|
||||||
pod lib lint RDReaderView.podspec --allow-warnings
|
|
||||||
```
|
|
||||||
|
|
||||||
验证规则:
|
|
||||||
- 若出现编译错误,必须自动修复并重编译
|
|
||||||
- 若遇到 `database is locked` 等构建锁问题,自动重试,建议最多 5 次
|
|
||||||
- 直到 `BUILD SUCCEEDED` 或 `pod lib lint passed` 才可进入交付阶段
|
|
||||||
- 若本次只改文档或 skill 文件,可跳过编译,但要在交付中明确说明
|
|
||||||
|
|
||||||
## Maintenance Rules
|
|
||||||
|
|
||||||
- 优先复用 `Doc/`,不要把项目级规则复制进多个 skill 造成双份维护
|
|
||||||
- 新增项目约束时,优先更新 `Doc/CODING_STYLE.md`、`Doc/ARCHITECTURE.md` 等主文档,再调整 skill
|
|
||||||
- 轻量与完整要保持"轻重不同、规则不冲突",其中完整版应在轻量版闭环基础上扩展跨层与联调要求,而不是另起一套风格
|
|
||||||
- 变更默认流程、输出格式或适用边界时,必须同步更新相关文档
|
|
||||||
- 本 skill 持续作为完整开发入口,保持"可执行、可联调、可回滚、可交付"
|
|
||||||
- SDK 四层架构(EPUBCore → EPUBTextRendering → RDReaderView → EPUBUI)是执行的核心参照框架,所有改动必须明确标注落点层级和依赖方向
|
|
||||||
+33
@@ -6,3 +6,36 @@ xcuserdata/
|
|||||||
.artifacts/
|
.artifacts/
|
||||||
.deriveddata/
|
.deriveddata/
|
||||||
.swift-module-cache/
|
.swift-module-cache/
|
||||||
|
ReadViewDemo/build/
|
||||||
|
|
||||||
|
# This repository checks in the Demo Pods project. Keep generated files for the
|
||||||
|
# local RDEpubReaderView/RDPDFReaderView pods and vendored SnapKit visible even
|
||||||
|
# when a global gitignore excludes Pods.
|
||||||
|
!ReadViewDemo/Pods/
|
||||||
|
!ReadViewDemo/Pods/Local Podspecs/
|
||||||
|
!ReadViewDemo/Pods/Local Podspecs/RDEpubReaderView.podspec.json
|
||||||
|
!ReadViewDemo/Pods/Local Podspecs/RDPDFReaderView.podspec.json
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/RDEpubReaderView/
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/RDEpubReaderView/**
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/RDPDFReaderView/
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/RDPDFReaderView/**
|
||||||
|
!ReadViewDemo/Pods/SnapKit/
|
||||||
|
!ReadViewDemo/Pods/SnapKit/**
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/SnapKit/
|
||||||
|
!ReadViewDemo/Pods/Target Support Files/SnapKit/**
|
||||||
|
|
||||||
|
# macOS system files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Local backup directories
|
||||||
|
*手动解包备份*
|
||||||
|
|
||||||
|
# AI tool output
|
||||||
|
_ssoft-output/
|
||||||
|
.claude/*
|
||||||
|
!.claude/skills
|
||||||
|
|
||||||
|
# Python bytecode
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|||||||
@@ -1,3 +1,67 @@
|
|||||||
# AGENTS.md
|
# ReadViewSDK AI 开发规则
|
||||||
|
|
||||||
- If using XcodeBuildMCP, use the installed XcodeBuildMCP skill before calling XcodeBuildMCP tools.
|
## 适用范围与语言
|
||||||
|
|
||||||
|
- 默认处理当前仓库的 EPUB SDK、PDF SDK、Demo 和测试。
|
||||||
|
- 计划、交付说明、`Doc/` 与项目 Markdown 使用中文。
|
||||||
|
- 代码标识符、文件名、API 和配置键保持英文;代码注释、Docstring 和提交信息使用中文。
|
||||||
|
- 只做当前目标所需的最小改动,保留工作区内与任务无关的未提交修改。
|
||||||
|
- 任何写文件的 agent 必须先读取 `CONTEXT.md`。
|
||||||
|
|
||||||
|
## 自动选择项目 Skill
|
||||||
|
|
||||||
|
根据用户意图选择 `.agents/skills/` 中最匹配的 Skill:
|
||||||
|
|
||||||
|
- 先讨论、比较方案、不要改代码:`discuss-sdk-feature-solution`
|
||||||
|
- 单模块功能、Bug 修复、UI 调整、局部重构、构建修复:`start-sdk-feature-dev-lite`
|
||||||
|
- 跨层/跨阅读器改造、公共 API 或持久化迁移、复杂联调、完整方案执行:`start-sdk-feature-dev`
|
||||||
|
- 隐藏问题、并发、生命周期、性能、内存、缓存或兼容性审查:`review-swift-ios-sdk`
|
||||||
|
- 全局代码规范:`generate-sdk-code-style-doc`
|
||||||
|
- 单模块代码规范:`generate-module-code-style-doc`
|
||||||
|
- 模块调用链、状态流、分页或缓存实现逻辑:`generate-module-implementation-logic`
|
||||||
|
- 审查改动、生成详细中文提交说明并提交或推送 Git:`commit-git-changes`
|
||||||
|
|
||||||
|
不要为简单任务叠加多个 Skill。用户明确指定 Skill 时优先使用;任务边界扩大时再切换或补充,并说明原因。
|
||||||
|
|
||||||
|
## 文档按需读取
|
||||||
|
|
||||||
|
先定位源码,再读取直接相关文档,不默认全文加载整个 `Doc/`:
|
||||||
|
|
||||||
|
| 任务 | 必读资料 |
|
||||||
|
| --- | --- |
|
||||||
|
| 任意代码修改 | `CONTEXT.md`、`Doc/CONVENTIONS.md` 相关章节 |
|
||||||
|
| 分层或跨模块改造 | `Doc/ARCHITECTURE.md` |
|
||||||
|
| 公共 API | `Doc/API_REFERENCE.md` 与真实 public 声明 |
|
||||||
|
| EPUB 解析/排版/分页/UI | 对应 `Doc/*_CODE_REFERENCE.md` 或专题文档 |
|
||||||
|
| PDF 阅读器 | `Sources/RDPDFReaderView` 源码;现有文档不足时以源码为准 |
|
||||||
|
| 测试与回归 | `Doc/TESTING.md` |
|
||||||
|
| 用户指定方案 | 指定文档,必须完整读取 |
|
||||||
|
|
||||||
|
`Doc/index.md` 用于路由。文档与源码冲突时以当前源码为事实,并指出待同步项。
|
||||||
|
|
||||||
|
## 模块边界
|
||||||
|
|
||||||
|
- EPUB:`EPUBCore` → `EPUBTextRendering` → `ReaderView` → `EPUBUI`,禁止下层反向依赖上层。
|
||||||
|
- PDF:通用分页容器位于 `Sources/RDPDFReaderView/ReaderView`,成品能力位于 `Sources/RDPDFReaderView/Sources`。
|
||||||
|
- Demo 和 UITests 只承担集成、样例与回归,不承载 SDK 核心业务。
|
||||||
|
- 保持 UIKit、SnapKit 和当前 CocoaPods 结构;新增依赖、资源或系统 framework 时同步检查对应 podspec。
|
||||||
|
- 新增类型遵循现有 `RD`、`RDEPUB`、`RDPDF` 前缀和最小可见性。
|
||||||
|
|
||||||
|
## SDK 兼容与质量
|
||||||
|
|
||||||
|
- 修改 public API 前评估宿主源码兼容、默认行为和迁移方式。
|
||||||
|
- 修改 Codable、持久化文件、缓存键或 book identifier 时提供版本与失效/迁移策略。
|
||||||
|
- UI 更新回主线程;异步任务处理取消、超时、迟到结果、恰好一次完成和生命周期。
|
||||||
|
- EPUB 改动检查 `.textReflowable`、`.webInteractive`、`.webFixedLayout` 的影响。
|
||||||
|
- PDF 改动检查宿主图片 Provider 与内置 PDFKit Provider 的影响。
|
||||||
|
- 滚动、缩放、分页和绘画热点避免同步 IO、重复解码、无界缓存和大对象长期驻留。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
修改 Swift、工程配置或 podspec 后默认执行:
|
||||||
|
|
||||||
|
`xcodebuild -workspace ReadViewDemo/ReadViewDemo.xcworkspace -scheme ReadViewDemo -configuration Debug -sdk iphonesimulator CODE_SIGNING_ALLOWED=NO build`
|
||||||
|
|
||||||
|
按风险补充 `Doc/TESTING.md` 中的定向 UI 测试。仅修改文档、规则或 Skill 时可跳过 Xcode 构建,但必须执行结构、引用和格式检查。
|
||||||
|
|
||||||
|
如果使用 XcodeBuildMCP,调用其工具前必须先读取已安装的 XcodeBuildMCP Skill,并先检查 session defaults。
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
# ReadViewSDK 代码审查报告
|
# ReadViewSDK 代码审查报告
|
||||||
|
|
||||||
> 审查日期:2026-06-26
|
> 审查日期:2026-06-26
|
||||||
> 审查范围:Sources/RDReaderView 全部源码
|
> 审查范围:Sources/RDEpubReaderView 全部源码
|
||||||
> 审查方法:逐文件阅读 + 交叉验证 + 线程模型分析
|
> 审查方法:逐文件阅读 + 交叉验证 + 线程模型分析
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -148,4 +148,4 @@ func currentTextPageSize() -> CGSize {
|
|||||||
| 🟡 P2 | P2-2 | javaScriptStringLiteral 实现依赖隐式假设 | 可维护性 |
|
| 🟡 P2 | P2-2 | javaScriptStringLiteral 实现依赖隐式假设 | 可维护性 |
|
||||||
| 🔵 P3 | P3-1 | 后台线程同步 hop 主线程获取布局信息 | 线程模型 |
|
| 🔵 P3 | P3-1 | 后台线程同步 hop 主线程获取布局信息 | 线程模型 |
|
||||||
|
|
||||||
**整体评价**: SDK 架构设计良好,模块分层清晰,引用管理(unowned/weak)使用正确,分页取消机制有 `paginationToken` + `cancellationController` 兜底。主要值得修复的是三个性能类 P1 问题(主线程阻塞搜索、资源加载阻塞、缓存无清理),两个 P2 鲁棒性/可维护性问题,以及一个 P3 线程模型优化建议。
|
**整体评价**: SDK 架构设计良好,模块分层清晰,引用管理(unowned/weak)使用正确,分页取消机制有 `paginationToken` + `cancellationController` 兜底。主要值得修复的是三个性能类 P1 问题(主线程阻塞搜索、资源加载阻塞、缓存无清理),两个 P2 鲁棒性/可维护性问题,以及一个 P3 线程模型优化建议。
|
||||||
|
|||||||
+27
-27
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
## 1. RDEPUBReaderController — 入口控制器
|
## 1. RDEPUBReaderController — 入口控制器
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift` 及扩展
|
**文件**:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderController.swift` 及扩展
|
||||||
|
|
||||||
### 1.1 初始化
|
### 1.1 初始化
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ func nativeTextSemanticSummary() -> String?
|
|||||||
|
|
||||||
## 2. RDEPUBReaderDelegate — 委托协议
|
## 2. RDEPUBReaderDelegate — 委托协议
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBUI/RDEPUBReaderDelegate.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderDelegate.swift`
|
||||||
|
|
||||||
所有方法均有默认空实现,可按需实现。
|
所有方法均有默认空实现,可按需实现。
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ public protocol RDEPUBReaderDelegate: AnyObject {
|
|||||||
|
|
||||||
## 3. RDEPUBReaderPersistence — 持久化协议
|
## 3. RDEPUBReaderPersistence — 持久化协议
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBUI/RDEPUBReaderPersistence.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderPersistence.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public protocol RDEPUBReaderPersistence: AnyObject {
|
public protocol RDEPUBReaderPersistence: AnyObject {
|
||||||
@@ -264,7 +264,7 @@ public protocol RDEPUBReaderPersistence: AnyObject {
|
|||||||
|
|
||||||
## 4. RDEPUBReaderConfiguration — 配置模型
|
## 4. RDEPUBReaderConfiguration — 配置模型
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBUI/Settings/RDEPUBReaderConfiguration.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBUI/Settings/RDEPUBReaderConfiguration.swift`
|
||||||
|
|
||||||
| 属性 | 类型 | 默认值 | 说明 |
|
| 属性 | 类型 | 默认值 | 说明 |
|
||||||
|------|------|--------|------|
|
|------|------|--------|------|
|
||||||
@@ -273,7 +273,7 @@ public protocol RDEPUBReaderPersistence: AnyObject {
|
|||||||
| `fontChoice` | `RDEPUBReaderFontChoice` | `.system` | 字体选择(system/serif/rounded/monospaced) |
|
| `fontChoice` | `RDEPUBReaderFontChoice` | `.system` | 字体选择(system/serif/rounded/monospaced) |
|
||||||
| `numberOfColumns` | `Int` | `1` | 每页列数(1 或 2) |
|
| `numberOfColumns` | `Int` | `1` | 每页列数(1 或 2) |
|
||||||
| `columnGap` | `CGFloat` | `20` | 列间距 |
|
| `columnGap` | `CGFloat` | `20` | 列间距 |
|
||||||
| `displayType` | `RDReaderView.DisplayType` | `.pageCurl` | 翻页模式 |
|
| `displayType` | `RDEpubReaderView.DisplayType` | `.pageCurl` | 翻页模式 |
|
||||||
| `landscapeDualPageEnabled` | `Bool` | `true` | 横屏双页 |
|
| `landscapeDualPageEnabled` | `Bool` | `true` | 横屏双页 |
|
||||||
| `showsTableOfContents` | `Bool` | `true` | 显示目录 |
|
| `showsTableOfContents` | `Bool` | `true` | 显示目录 |
|
||||||
| `allowsHighlights` | `Bool` | `true` | 允许高亮 |
|
| `allowsHighlights` | `Bool` | `true` | 允许高亮 |
|
||||||
@@ -301,50 +301,50 @@ public protocol RDEPUBReaderPersistence: AnyObject {
|
|||||||
|
|
||||||
## 5. 翻页容器协议
|
## 5. 翻页容器协议
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/ReaderView/RDReaderViewProtocols.swift`
|
**文件**:`Sources/RDEpubReaderView/ReaderView/RDEpubReaderViewProtocols.swift`
|
||||||
|
|
||||||
### 5.1 RDReaderPageProvider(推荐)
|
### 5.1 RDEpubReaderPageProvider(推荐)
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderPageProvider: NSObjectProtocol {
|
@objc public protocol RDEpubReaderPageProvider: NSObjectProtocol {
|
||||||
|
|
||||||
/// 总页数
|
/// 总页数
|
||||||
func numberOfPages(in readerView: RDReaderView) -> Int
|
func numberOfPages(in readerView: RDEpubReaderView) -> Int
|
||||||
|
|
||||||
/// 返回指定页的视图
|
/// 返回指定页的视图
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - index: 页码索引(0-based)
|
/// - index: 页码索引(0-based)
|
||||||
/// - reusableView: 可复用的旧视图(可能为 nil)
|
/// - reusableView: 可复用的旧视图(可能为 nil)
|
||||||
func readerView(_ readerView: RDReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView
|
func readerView(_ readerView: RDEpubReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView
|
||||||
|
|
||||||
/// 页面标识符(用于缓存去重)
|
/// 页面标识符(用于缓存去重)
|
||||||
@objc optional func pageIdentifier(in readerView: RDReaderView, index: Int) -> String?
|
@objc optional func pageIdentifier(in readerView: RDEpubReaderView, index: Int) -> String?
|
||||||
|
|
||||||
/// 顶部工具栏视图
|
/// 顶部工具栏视图
|
||||||
@objc optional func readerViewTopChrome(_ readerView: RDReaderView) -> UIView?
|
@objc optional func readerViewTopChrome(_ readerView: RDEpubReaderView) -> UIView?
|
||||||
|
|
||||||
/// 底部工具栏视图
|
/// 底部工具栏视图
|
||||||
@objc optional func readerViewBottomChrome(_ readerView: RDReaderView) -> UIView?
|
@objc optional func readerViewBottomChrome(_ readerView: RDEpubReaderView) -> UIView?
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.2 RDReaderDelegate
|
### 5.2 RDEpubReaderDelegate
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderDelegate: NSObjectProtocol {
|
@objc public protocol RDEpubReaderDelegate: NSObjectProtocol {
|
||||||
|
|
||||||
/// 页面变化回调
|
/// 页面变化回调
|
||||||
func pageNum(readerView: RDReaderView, pageNum: Int)
|
func pageNum(readerView: RDEpubReaderView, pageNum: Int)
|
||||||
|
|
||||||
/// 屏幕方向即将变化
|
/// 屏幕方向即将变化
|
||||||
@objc optional func readerViewOrientationWillChange(readerView: RDReaderView, isLandscape: Bool)
|
@objc optional func readerViewOrientationWillChange(readerView: RDEpubReaderView, isLandscape: Bool)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.3 RDReaderPageNavigating
|
### 5.3 RDEpubReaderPageNavigating
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public protocol RDReaderPageNavigating: AnyObject {
|
public protocol RDEpubReaderPageNavigating: AnyObject {
|
||||||
|
|
||||||
/// 当前页码
|
/// 当前页码
|
||||||
var currentPage: Int { get }
|
var currentPage: Int { get }
|
||||||
@@ -357,19 +357,19 @@ public protocol RDReaderPageNavigating: AnyObject {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5.4 RDReaderDataSource(遗留)
|
### 5.4 RDEpubReaderDataSource(遗留)
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderDataSource: NSObjectProtocol {
|
@objc public protocol RDEpubReaderDataSource: NSObjectProtocol {
|
||||||
func pageCountOfReaderView(readerView: RDReaderView) -> Int
|
func pageCountOfReaderView(readerView: RDEpubReaderView) -> Int
|
||||||
func pageContentView(readerView: RDReaderView, pageNum: Int, containerView: UIView?) -> UIView
|
func pageContentView(readerView: RDEpubReaderView, pageNum: Int, containerView: UIView?) -> UIView
|
||||||
func pageIdentifier(readerView: RDReaderView, pageNum: Int) -> String?
|
func pageIdentifier(readerView: RDEpubReaderView, pageNum: Int) -> String?
|
||||||
@objc optional func topToolView(readerView: RDReaderView) -> UIView?
|
@objc optional func topToolView(readerView: RDEpubReaderView) -> UIView?
|
||||||
@objc optional func bottomToolView(readerView: RDReaderView) -> UIView?
|
@objc optional func bottomToolView(readerView: RDEpubReaderView) -> UIView?
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
通过 `RDReaderLegacyDataSourceAdapter` 自动适配到 `RDReaderPageProvider`。
|
通过 `RDEpubReaderLegacyDataSourceAdapter` 自动适配到 `RDEpubReaderPageProvider`。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+25
-25
@@ -22,7 +22,7 @@ ReadViewSDK 是一个 iOS EPUB 阅读器 SDK,支持文本重排(Reflowable
|
|||||||
│ ReadViewDemo (Demo App) │
|
│ ReadViewDemo (Demo App) │
|
||||||
│ ViewController · LaunchAutomationPlan · UITests │
|
│ ViewController · LaunchAutomationPlan · UITests │
|
||||||
└──────────────────────────────┬──────────────────────────────┘
|
└──────────────────────────────┬──────────────────────────────┘
|
||||||
│ imports RDReaderView
|
│ imports RDEpubReaderView
|
||||||
┌──────────────────────────────▼──────────────────────────────┐
|
┌──────────────────────────────▼──────────────────────────────┐
|
||||||
│ EPUBUI 层 │
|
│ EPUBUI 层 │
|
||||||
│ RDEPUBReaderController · Coordinators · Settings · TextPage │
|
│ RDEPUBReaderController · Coordinators · Settings · TextPage │
|
||||||
@@ -30,8 +30,8 @@ ReadViewSDK 是一个 iOS EPUB 阅读器 SDK,支持文本重排(Reflowable
|
|||||||
└──────────────────────────────┬──────────────────────────────┘
|
└──────────────────────────────┬──────────────────────────────┘
|
||||||
│
|
│
|
||||||
┌──────────────────────────────▼──────────────────────────────┐
|
┌──────────────────────────────▼──────────────────────────────┐
|
||||||
│ RDReaderView 层 │
|
│ RDEpubReaderView 层 │
|
||||||
│ RDReaderView · FlowLayout · PreloadController │
|
│ RDEpubReaderView · FlowLayout · PreloadController │
|
||||||
│ SpreadResolver · TapRegionHandler · PagingController │
|
│ SpreadResolver · TapRegionHandler · PagingController │
|
||||||
└──────────────────────────────┬──────────────────────────────┘
|
└──────────────────────────────┬──────────────────────────────┘
|
||||||
│
|
│
|
||||||
@@ -54,7 +54,7 @@ ReadViewSDK 是一个 iOS EPUB 阅读器 SDK,支持文本重排(Reflowable
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **EPUBCore** | EPUB 文件解析、资源管理、WebView 渲染、JS 桥接 | `RDEPUBParser`, `RDEPUBPublication`, `RDEPUBWebView` |
|
| **EPUBCore** | EPUB 文件解析、资源管理、WebView 渲染、JS 桥接 | `RDEPUBParser`, `RDEPUBPublication`, `RDEPUBWebView` |
|
||||||
| **EPUBTextRendering** | HTML→NSAttributedString 转换、排版、分页、全书构建 | `RDEPUBTextBookBuilder`, `RDEPUBCoreTextPageFrameFactory` |
|
| **EPUBTextRendering** | HTML→NSAttributedString 转换、排版、分页、全书构建 | `RDEPUBTextBookBuilder`, `RDEPUBCoreTextPageFrameFactory` |
|
||||||
| **RDReaderView** | 通用翻页容器、手势识别、页面预加载、双页布局 | `RDReaderView`, `RDReaderFlowLayout`, `RDReaderPreloadController` |
|
| **RDEpubReaderView** | 通用翻页容器、手势识别、页面预加载、双页布局 | `RDEpubReaderView`, `RDEpubReaderFlowLayout`, `RDEpubReaderPreloadController` |
|
||||||
| **EPUBUI** | 阅读器控制器、协调器模式、设置面板、按需加载、磁盘缓存 | `RDEPUBReaderController`, `RDEPUBReaderPaginationCoordinator` |
|
| **EPUBUI** | 阅读器控制器、协调器模式、设置面板、按需加载、磁盘缓存 | `RDEPUBReaderController`, `RDEPUBReaderPaginationCoordinator` |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -310,10 +310,10 @@ RDEPUBWebView (UIView)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 7. 翻页容器架构(RDReaderView)
|
## 7. 翻页容器架构(RDEpubReaderView)
|
||||||
|
|
||||||
```
|
```
|
||||||
RDReaderView (UIView)
|
RDEpubReaderView (UIView)
|
||||||
│
|
│
|
||||||
├─ 三种翻页模式:
|
├─ 三种翻页模式:
|
||||||
│ ├─ .pageCurl → UIPageViewController (翻页动画)
|
│ ├─ .pageCurl → UIPageViewController (翻页动画)
|
||||||
@@ -321,14 +321,14 @@ RDReaderView (UIView)
|
|||||||
│ └─ .verticalScroll → UICollectionView (垂直滚动)
|
│ └─ .verticalScroll → UICollectionView (垂直滚动)
|
||||||
│
|
│
|
||||||
├─ 组合对象:
|
├─ 组合对象:
|
||||||
│ ├─ RDReaderPagingController // 翻页状态管理、请求队列
|
│ ├─ RDEpubReaderPagingController // 翻页状态管理、请求队列
|
||||||
│ ├─ RDReaderPreloadController // 页面预加载、缓存管理
|
│ ├─ RDEpubReaderPreloadController // 页面预加载、缓存管理
|
||||||
│ ├─ RDReaderSpreadResolver // 双页展开计算
|
│ ├─ RDEpubReaderSpreadResolver // 双页展开计算
|
||||||
│ └─ RDReaderTapRegionHandler // 点击区域分类(左/中/右)
|
│ └─ RDEpubReaderTapRegionHandler // 点击区域分类(左/中/右)
|
||||||
│
|
│
|
||||||
├─ 数据源协议:
|
├─ 数据源协议:
|
||||||
│ ├─ RDReaderPageProvider (新) // 格式无关,优先级高
|
│ ├─ RDEpubReaderPageProvider (新) // 格式无关,优先级高
|
||||||
│ └─ RDReaderDataSource (旧) // 遗留兼容,通过 Adapter 适配
|
│ └─ RDEpubReaderDataSource (旧) // 遗留兼容,通过 Adapter 适配
|
||||||
│
|
│
|
||||||
└─ 手势流:
|
└─ 手势流:
|
||||||
点击 → TapRegionHandler → 分类(左/中/右)
|
点击 → TapRegionHandler → 分类(左/中/右)
|
||||||
@@ -351,7 +351,7 @@ struct RDEPUBReaderConfiguration {
|
|||||||
var numberOfColumns: Int // 1 或 2
|
var numberOfColumns: Int // 1 或 2
|
||||||
var columnGap: CGFloat // 默认 20
|
var columnGap: CGFloat // 默认 20
|
||||||
var theme: ReaderTheme // 6 种主题
|
var theme: ReaderTheme // 6 种主题
|
||||||
var displayType: RDReaderView.DisplayType // pageCurl/horizontal/vertical
|
var displayType: RDEpubReaderView.DisplayType // pageCurl/horizontal/vertical
|
||||||
var onDemandChapterWindowSize: Int // 默认 3(奇数,最小 3,最大 15)
|
var onDemandChapterWindowSize: Int // 默认 3(奇数,最小 3,最大 15)
|
||||||
var metadataParsingConcurrency: Int // 默认 CPU 核心数
|
var metadataParsingConcurrency: Int // 默认 CPU 核心数
|
||||||
var chapterWindowRadius: Int // 内存缓存窗口半径
|
var chapterWindowRadius: Int // 内存缓存窗口半径
|
||||||
@@ -374,7 +374,7 @@ struct RDEPUBReaderConfiguration {
|
|||||||
## 9. 目录结构
|
## 9. 目录结构
|
||||||
|
|
||||||
```
|
```
|
||||||
Sources/RDReaderView/
|
Sources/RDEpubReaderView/
|
||||||
├── EPUBCore/ # EPUB 解析与 WebView 渲染
|
├── EPUBCore/ # EPUB 解析与 WebView 渲染
|
||||||
│ ├── Models/ # 数据模型
|
│ ├── Models/ # 数据模型
|
||||||
│ │ ├── RDEPUBAnnotationModels.swift
|
│ │ ├── RDEPUBAnnotationModels.swift
|
||||||
@@ -428,19 +428,19 @@ Sources/RDReaderView/
|
|||||||
│ ├── RDEPUBDTCoreTextRenderer.swift # DTCoreText 渲染器实现
|
│ ├── RDEPUBDTCoreTextRenderer.swift # DTCoreText 渲染器实现
|
||||||
│ ├── RDEPUBChapterData.swift # 章节查询门面
|
│ ├── RDEPUBChapterData.swift # 章节查询门面
|
||||||
│ ├── RDEPUBTextIndexTable.swift # 全书索引表
|
│ ├── RDEPUBTextIndexTable.swift # 全书索引表
|
||||||
│ └── RDPlainTextBookBuilder.swift # 纯文本 (.txt) 构建器
|
│ └── RDEpubPlainTextBookBuilder.swift # 纯文本 (.txt) 构建器
|
||||||
│
|
│
|
||||||
├── ReaderView/ # 通用翻页容器
|
├── ReaderView/ # 通用翻页容器
|
||||||
│ ├── Paging/ # 翻页子系统
|
│ ├── Paging/ # 翻页子系统
|
||||||
│ │ ├── RDReaderPagingController.swift
|
│ │ ├── RDEpubReaderPagingController.swift
|
||||||
│ │ ├── RDReaderPreloadController.swift
|
│ │ ├── RDEpubReaderPreloadController.swift
|
||||||
│ │ ├── RDReaderSpreadResolver.swift
|
│ │ ├── RDEpubReaderSpreadResolver.swift
|
||||||
│ │ └── RDReaderTapRegionHandler.swift
|
│ │ └── RDEpubReaderTapRegionHandler.swift
|
||||||
│ ├── RDReaderView.swift # 主容器视图
|
│ ├── RDEpubReaderView.swift # 主容器视图
|
||||||
│ ├── RDReaderView+*.swift # 扩展(CollectionView/PageCurl/ToolView/ContentAccess)
|
│ ├── RDEpubReaderView+*.swift # 扩展(CollectionView/PageCurl/ToolView/ContentAccess)
|
||||||
│ ├── RDReaderFlowLayout.swift # 自定义 CollectionView 布局
|
│ ├── RDEpubReaderFlowLayout.swift # 自定义 CollectionView 布局
|
||||||
│ ├── RDReaderContentCell.swift # 滚动模式 Cell
|
│ ├── RDEpubReaderContentCell.swift # 滚动模式 Cell
|
||||||
│ └── RDReaderPageChildViewController.swift // 翻页模式子 VC
|
│ └── RDEpubReaderPageChildViewController.swift // 翻页模式子 VC
|
||||||
│
|
│
|
||||||
└── EPUBUI/ # 阅读器 UI
|
└── EPUBUI/ # 阅读器 UI
|
||||||
├── ReaderController/ # 控制器与协调器
|
├── ReaderController/ # 控制器与协调器
|
||||||
@@ -494,7 +494,7 @@ Sources/RDReaderView/
|
|||||||
| **Builder** | `RDEPUBBookPageMap.Builder` 增量构建页码映射 |
|
| **Builder** | `RDEPUBBookPageMap.Builder` 增量构建页码映射 |
|
||||||
| **Strategy** | `RDEPUBTextRenderer` 协议,可替换渲染器实现 |
|
| **Strategy** | `RDEPUBTextRenderer` 协议,可替换渲染器实现 |
|
||||||
| **Pipeline** | `RDEPUBTextTypesetterPipeline` 排版管线(8 个逻辑阶段,封装为 5-6 个顶层调用) |
|
| **Pipeline** | `RDEPUBTextTypesetterPipeline` 排版管线(8 个逻辑阶段,封装为 5-6 个顶层调用) |
|
||||||
| **Adapter** | `RDReaderLegacyDataSourceAdapter` 适配旧数据源协议 |
|
| **Adapter** | `RDEpubReaderLegacyDataSourceAdapter` 适配旧数据源协议 |
|
||||||
| **三级缓存** | 内存 → 磁盘摘要 → 全书分页,逐级降级 |
|
| **三级缓存** | 内存 → 磁盘摘要 → 全书分页,逐级降级 |
|
||||||
| **Token 取消** | `paginationToken` 确保过期异步任务不干扰新任务 |
|
| **Token 取消** | `paginationToken` 确保过期异步任务不干扰新任务 |
|
||||||
| **Frozen Parameters** | 后台任务冻结 `renderSignature`,避免运行中参数漂移 |
|
| **Frozen Parameters** | 后台任务冻结 `renderSignature`,避免运行中参数漂移 |
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
# ReadViewSDK 代码审查报告
|
# ReadViewSDK 代码审查报告
|
||||||
|
|
||||||
> 审查范围:`Sources/RDReaderView/` 全部 184 个 Swift 文件(约 32,300 行)
|
> 审查范围:`Sources/RDEpubReaderView/` 全部 184 个 Swift 文件(约 32,300 行)
|
||||||
> 审查维度:并发安全、内存管理、API 正确性、Swift/iOS 平台特定、架构与依赖
|
> 审查维度:并发安全、内存管理、API 正确性、Swift/iOS 平台特定、架构与依赖
|
||||||
> 审查日期:2026-06-26
|
> 审查日期:2026-06-26
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ let stillChanged = abs(currentSize.width - self.lastTextPaginationPageSize!.widt
|
|||||||
|
|
||||||
### H-10 · 依赖版本未锁定
|
### H-10 · 依赖版本未锁定
|
||||||
|
|
||||||
`RDReaderView.podspec` 中 DTCoreText、SnapKit、SSAlertSwift 无版本约束:
|
`RDEpubReaderView.podspec` 中 DTCoreText、SnapKit、SSAlertSwift 无版本约束:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
s.dependency 'ZIPFoundation', '~> 0.9' # ✅ 已锁定
|
s.dependency 'ZIPFoundation', '~> 0.9' # ✅ 已锁定
|
||||||
@@ -143,7 +143,7 @@ s.dependency 'SnapKit' # ❌ 无约束
|
|||||||
s.dependency 'SSAlertSwift' # ❌ 无约束
|
s.dependency 'SSAlertSwift' # ❌ 无约束
|
||||||
```
|
```
|
||||||
|
|
||||||
**位置:** `RDReaderView.podspec:17-20`
|
**位置:** `RDEpubReaderView.podspec:17-20`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -298,14 +298,14 @@ return builder.build()
|
|||||||
|
|
||||||
**触发条件:** `landscapeDualPageEnabled && isLandscape && !verticalScroll`
|
**触发条件:** `landscapeDualPageEnabled && isLandscape && !verticalScroll`
|
||||||
|
|
||||||
**页面配对逻辑(RDReaderSpreadResolver):**
|
**页面配对逻辑(RDEpubReaderSpreadResolver):**
|
||||||
|
|
||||||
- 有封面页:封面独占一屏,后续页面两两配对
|
- 有封面页:封面独占一屏,后续页面两两配对
|
||||||
- 配对规则:`(coverIndex, nil)`, `(1, 2)`, `(3, 4)`, ...
|
- 配对规则:`(coverIndex, nil)`, `(1, 2)`, `(3, 4)`, ...
|
||||||
- 无封面页:标准偶奇配对
|
- 无封面页:标准偶奇配对
|
||||||
- 配对规则:`(0, 1)`, `(2, 3)`, `(4, 5)`, ...
|
- 配对规则:`(0, 1)`, `(2, 3)`, `(4, 5)`, ...
|
||||||
|
|
||||||
**封面感知布局(RDReaderFlowLayout):**
|
**封面感知布局(RDEpubReaderFlowLayout):**
|
||||||
|
|
||||||
```
|
```
|
||||||
封面页: [====全屏宽度====]
|
封面页: [====全屏宽度====]
|
||||||
@@ -314,7 +314,7 @@ return builder.build()
|
|||||||
|
|
||||||
### 5.3 页面预加载
|
### 5.3 页面预加载
|
||||||
|
|
||||||
`RDReaderPreloadController` 管理两个缓存:
|
`RDEpubReaderPreloadController` 管理两个缓存:
|
||||||
- `preloadedPageViews` - 预渲染的页面视图
|
- `preloadedPageViews` - 预渲染的页面视图
|
||||||
- `pageCurlCachedViews` - 当前显示的页面视图
|
- `pageCurlCachedViews` - 当前显示的页面视图
|
||||||
|
|
||||||
@@ -580,7 +580,7 @@ protocol RDEPUBReaderPersistence {
|
|||||||
|
|
||||||
## 9. 纯文本 (.txt) 支持
|
## 9. 纯文本 (.txt) 支持
|
||||||
|
|
||||||
`RDPlainTextBookBuilder` 复用 EPUB 渲染管线处理 .txt 文件:
|
`RDEpubPlainTextBookBuilder` 复用 EPUB 渲染管线处理 .txt 文件:
|
||||||
|
|
||||||
1. **解码:** 依次尝试 UTF-8 → GB18030 → GBK
|
1. **解码:** 依次尝试 UTF-8 → GB18030 → GBK
|
||||||
2. **分章:** 正则匹配 `^(第[零一二三四五六七八九十百千万\d]+[章节回卷].*)$`
|
2. **分章:** 正则匹配 `^(第[零一二三四五六七八九十百千万\d]+[章节回卷].*)$`
|
||||||
|
|||||||
+13
-13
@@ -34,7 +34,7 @@ epubcfi(/6/4!ch01.xhtml/4/2/1:3)
|
|||||||
|
|
||||||
顶层 CFI 模型,对应一个完整的 `epubcfi(...)` 字符串。
|
顶层 CFI 模型,对应一个完整的 `epubcfi(...)` 字符串。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFI.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFI.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public struct RDEPUBCFI: Codable, Equatable, Hashable {
|
public struct RDEPUBCFI: Codable, Equatable, Hashable {
|
||||||
@@ -66,7 +66,7 @@ public enum RDEPUBCFISideBias: String, Codable {
|
|||||||
|
|
||||||
路径模型,由一组 `RDEPUBCFIStep` 组成,描述从根节点到目标节点的遍历序列。
|
路径模型,由一组 `RDEPUBCFIStep` 组成,描述从根节点到目标节点的遍历序列。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIPath.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIPath.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public struct RDEPUBCFIPath: Codable, Equatable, Hashable {
|
public struct RDEPUBCFIPath: Codable, Equatable, Hashable {
|
||||||
@@ -95,7 +95,7 @@ public struct RDEPUBCFIStep: Codable, Equatable, Hashable {
|
|||||||
|
|
||||||
范围模型,表示文档中的一个连续区域,由父级 CFI 和起止 CFI 组成。
|
范围模型,表示文档中的一个连续区域,由父级 CFI 和起止 CFI 组成。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIRange.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIRange.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public struct RDEPUBCFIRange: Codable, Equatable, Hashable {
|
public struct RDEPUBCFIRange: Codable, Equatable, Hashable {
|
||||||
@@ -116,7 +116,7 @@ public struct RDEPUBCFIRange: Codable, Equatable, Hashable {
|
|||||||
|
|
||||||
将 CFI 字符串解析为结构化模型。
|
将 CFI 字符串解析为结构化模型。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIParser.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIParser.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFIParser {
|
public enum RDEPUBCFIParser {
|
||||||
@@ -154,7 +154,7 @@ print(cfi.textAssertion?.exact) // Optional("目标文本")
|
|||||||
|
|
||||||
将 CFI 模型序列化为标准字符串。
|
将 CFI 模型序列化为标准字符串。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFISerializer.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFISerializer.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFISerializer {
|
public enum RDEPUBCFISerializer {
|
||||||
@@ -192,7 +192,7 @@ let serialized = RDEPUBCFISerializer.serialize(cfi)
|
|||||||
|
|
||||||
将 CFI 解析为可直接用于资源定位的结果。
|
将 CFI 解析为可直接用于资源定位的结果。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIResolver.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIResolver.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public struct RDEPUBCFIResolverResult: Equatable {
|
public struct RDEPUBCFIResolverResult: Equatable {
|
||||||
@@ -228,7 +228,7 @@ print(result.chapterOffset) // Optional(80)
|
|||||||
|
|
||||||
从已知的章节信息生成 CFI。
|
从已知的章节信息生成 CFI。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIGenerator.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIGenerator.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFIGenerator {
|
public enum RDEPUBCFIGenerator {
|
||||||
@@ -274,7 +274,7 @@ public enum RDEPUBCFIGenerator {
|
|||||||
|
|
||||||
从 HTML 源码中提取带有 `id` 属性的元素路径映射。
|
从 HTML 源码中提取带有 `id` 属性的元素路径映射。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIDOMPathBuilder.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIDOMPathBuilder.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFIDOMPathBuilder {
|
public enum RDEPUBCFIDOMPathBuilder {
|
||||||
@@ -296,7 +296,7 @@ public enum RDEPUBCFIDOMPathBuilder {
|
|||||||
|
|
||||||
当 CFI 精确定位失败时(如 DOM 结构变更),恢复引擎通过多级降级策略尝试找到最佳匹配位置。
|
当 CFI 精确定位失败时(如 DOM 结构变更),恢复引擎通过多级降级策略尝试找到最佳匹配位置。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIRecoveryEngine.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIRecoveryEngine.swift`
|
||||||
|
|
||||||
### 5.1 恢复置信度
|
### 5.1 恢复置信度
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ let result = RDEPUBCFIRecoveryEngine.recover(
|
|||||||
|
|
||||||
文本断言用于在 CFI 定位后验证所指位置的文本内容是否符合预期,增强定位鲁棒性。
|
文本断言用于在 CFI 定位后验证所指位置的文本内容是否符合预期,增强定位鲁棒性。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFITextAssertion.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFITextAssertion.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public struct RDEPUBCFITextAssertion: Codable, Equatable, Hashable {
|
public struct RDEPUBCFITextAssertion: Codable, Equatable, Hashable {
|
||||||
@@ -393,7 +393,7 @@ print(assertion?.suffix) // Optional("后续内容")
|
|||||||
|
|
||||||
提供宽松解析接口,兼容非标准 CFI 格式。
|
提供宽松解析接口,兼容非标准 CFI 格式。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFICompatibility.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFICompatibility.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFICompatibility {
|
public enum RDEPUBCFICompatibility {
|
||||||
@@ -418,7 +418,7 @@ public enum RDEPUBCFICompatibility {
|
|||||||
|
|
||||||
CFI 映射是章节级别的索引结构,将 CFI 路径映射到章节文本偏移量,是容错恢复引擎的核心数据源。
|
CFI 映射是章节级别的索引结构,将 CFI 路径映射到章节文本偏移量,是容错恢复引擎的核心数据源。
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIMap.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIMap.swift`
|
||||||
|
|
||||||
### 8.1 RDEPUBCFIMap
|
### 8.1 RDEPUBCFIMap
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ public struct RDEPUBCFITokenAnchor: Codable, Equatable {
|
|||||||
|
|
||||||
## 9. 错误类型(RDEPUBCFIError)
|
## 9. 错误类型(RDEPUBCFIError)
|
||||||
|
|
||||||
**文件**:`Sources/RDReaderView/EPUBCore/CFI/RDEPUBCFIError.swift`
|
**文件**:`Sources/RDEpubReaderView/EPUBCore/CFI/RDEPUBCFIError.swift`
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public enum RDEPUBCFIError: Error, Equatable {
|
public enum RDEPUBCFIError: Error, Equatable {
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
- 渐进补全:后台逐步补全所有章节的页码信息
|
- 渐进补全:后台逐步补全所有章节的页码信息
|
||||||
|
|
||||||
**关键文件**:
|
**关键文件**:
|
||||||
- `Sources/RDReaderView/EPUBUI/ReaderController/ChapterRuntime/` 目录
|
- `Sources/RDEpubReaderView/EPUBUI/ReaderController/ChapterRuntime/` 目录
|
||||||
- `Sources/RDReaderView/EPUBUI/ReaderController/RDEPUBReaderPaginationCoordinator.swift`
|
- `Sources/RDEpubReaderView/EPUBUI/ReaderController/RDEPUBReaderPaginationCoordinator.swift`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -105,15 +105,15 @@
|
|||||||
## Evidence(仓库路径)
|
## Evidence(仓库路径)
|
||||||
|
|
||||||
- Build flags:`Podfile`
|
- Build flags:`Podfile`
|
||||||
- Pod metadata/toolchain:`RDReaderView.podspec`
|
- Pod metadata/toolchain:`RDEpubReaderView.podspec`
|
||||||
- Archive extraction:`Sources/RDReaderView/EPUBCore/RDEPUBParser+Archive.swift`
|
- Archive extraction:`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser+Archive.swift`
|
||||||
- Resource path validation(post-extraction):`Sources/RDReaderView/EPUBCore/RDEPUBParser+Resources.swift`
|
- Resource path validation(post-extraction):`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser+Resources.swift`
|
||||||
- Scheme handler reads full file bytes:`Sources/RDReaderView/EPUBCore/RDEPUBResourceURLSchemeHandler.swift`
|
- Scheme handler reads full file bytes:`Sources/RDEpubReaderView/EPUBCore/RDEPUBResourceURLSchemeHandler.swift`
|
||||||
- WebView bridge + message handling:`Sources/RDReaderView/EPUBCore/RDEPUBWebView+JavaScriptBridge.swift`
|
- WebView bridge + message handling:`Sources/RDEpubReaderView/EPUBCore/RDEPUBWebView+JavaScriptBridge.swift`
|
||||||
- External link opening:`Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift`
|
- External link opening:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderController.swift`
|
||||||
- UserDefaults persistence implementation:`Sources/RDReaderView/EPUBUI/RDEPUBReaderPersistence.swift`
|
- UserDefaults persistence implementation:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderPersistence.swift`
|
||||||
- Hidden paginator web view:`Sources/RDReaderView/EPUBCore/RDEPUBPaginator.swift`
|
- Hidden paginator web view:`Sources/RDEpubReaderView/EPUBCore/RDEPUBPaginator.swift`
|
||||||
- Debug logging:`Sources/RDReaderView/EPUBCore/RDEPUBWebViewDebug.swift`
|
- Debug logging:`Sources/RDEpubReaderView/EPUBCore/RDEPUBWebViewDebug.swift`
|
||||||
- Vendored dependencies:`Pods/`、`ReadViewDemo/Pods/`
|
- Vendored dependencies:`Pods/`、`ReadViewDemo/Pods/`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
+23
-23
@@ -6,43 +6,43 @@
|
|||||||
|
|
||||||
## 语言与工程约束
|
## 语言与工程约束
|
||||||
|
|
||||||
- **主要语言**:Swift(Podspec 声明 `s.swift_versions = ["5.10"]`,见 `RDReaderView.podspec`)
|
- **主要语言**:Swift(Podspec 声明 `s.swift_versions = ["5.10"]`,见 `RDEpubReaderView.podspec`)
|
||||||
- **最低系统版本**:Podspec `iOS 15.0`(`RDReaderView.podspec`),示例工程 Podfile/构建设置里常见为 `iOS 15.6`(`Podfile`)
|
- **最低系统版本**:Podspec `iOS 15.0`(`RDEpubReaderView.podspec`),示例工程 Podfile/构建设置里常见为 `iOS 15.6`(`ReadViewDemo/Podfile`)
|
||||||
- **依赖管理**:CocoaPods(`Podfile`、`ReadViewDemo/Podfile`、`Podfile.lock`)
|
- **依赖管理**:CocoaPods(`ReadViewDemo/Podfile`、`ReadViewDemo/Podfile.lock`)
|
||||||
|
|
||||||
## 命名约定
|
## 命名约定
|
||||||
|
|
||||||
**文件/类型命名(Swift):**
|
**文件/类型命名(Swift):**
|
||||||
- 以类型名为文件名的单文件组织较常见:`Sources/RDReaderView/EPUBCore/RDEPUBParser.swift`
|
- 以类型名为文件名的单文件组织较常见:`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser.swift`
|
||||||
- 大量使用前缀区分模块域:
|
- 大量使用前缀区分模块域:
|
||||||
- `RD...`:阅读器 UI/控制器相关(如 `Sources/RDReaderView/RDReaderView.swift`、`Sources/RDReaderView/RDURLReaderController.swift`)
|
- `RD...`:阅读器 UI/控制器相关(如 `Sources/RDEpubReaderView/RDEpubReaderView.swift`、`Sources/RDEpubReaderView/RDEpubURLReaderController.swift`)
|
||||||
- `RDEPUB...`:EPUB Core/UI/渲染相关(如 `Sources/RDReaderView/EPUBCore/RDEPUBModels.swift`)
|
- `RDEPUB...`:EPUB Core/UI/渲染相关(如 `Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift`)
|
||||||
- Extension 文件使用 `+` 命名:`Sources/RDReaderView/EPUBUI/RDEPUBReaderController+ContentDelegates.swift`
|
- Extension 文件使用 `+` 命名:`Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderController+ContentDelegates.swift`
|
||||||
|
|
||||||
**变量/函数命名:**
|
**变量/函数命名:**
|
||||||
- 基本遵循 Swift lowerCamelCase:`parse(epubURL:)`(`Sources/RDReaderView/EPUBCore/RDEPUBParser.swift`)
|
- 基本遵循 Swift lowerCamelCase:`parse(epubURL:)`(`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser.swift`)
|
||||||
- 常量多用 `static let`:`kRDEPUBHighlightAttributeName`(`Sources/RDReaderView/EPUBCore/Models/RDEPUBAnnotationModels.swift`)
|
- 常量多用 `static let`:`kRDEPUBHighlightAttributeName`(`Sources/RDEpubReaderView/EPUBCore/Models/RDEPUBAnnotationModels.swift`)
|
||||||
|
|
||||||
## 代码风格与排版(从现有代码归纳)
|
## 代码风格与排版(从现有代码归纳)
|
||||||
|
|
||||||
**缩进与换行:**
|
**缩进与换行:**
|
||||||
- 多数文件使用 4 空格缩进(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift`、`Sources/RDReaderView/EPUBCore/RDEPUBModels.swift`)
|
- 多数文件使用 4 空格缩进(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift`、`Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift`)
|
||||||
- 历史代码中更常见”强制换行/多行括号”风格
|
- 历史代码中更常见”强制换行/多行括号”风格
|
||||||
|
|
||||||
**空行与分组:**
|
**空行与分组:**
|
||||||
- UI 相关文件常用空行分隔属性/初始化/布局段落
|
- UI 相关文件常用空行分隔属性/初始化/布局段落
|
||||||
- `// MARK:` 用于分区组织(示例:`Sources/RDReaderView/RDReaderGestureController.swift`、`Sources/RDReaderView/EPUBTextRendering/RDPlainTextBookBuilder.swift`)
|
- `// MARK:` 用于分区组织(示例:`Sources/RDEpubReaderView/RDEpubReaderGestureController.swift`、`Sources/RDEpubReaderView/EPUBTextRendering/RDEpubPlainTextBookBuilder.swift`)
|
||||||
|
|
||||||
**类型组织:**
|
**类型组织:**
|
||||||
- 偏好用 `extension` 拆分职责/协议实现(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift` 的 `UITableViewDataSource/Delegate`)
|
- 偏好用 `extension` 拆分职责/协议实现(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift` 的 `UITableViewDataSource/Delegate`)
|
||||||
- API 暴露处使用 `public`、`public final class`、`public enum/struct`(示例:`Sources/RDReaderView/EPUBCore/RDEPUBModels.swift`)
|
- API 暴露处使用 `public`、`public final class`、`public enum/struct`(示例:`Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift`)
|
||||||
- “对外只读、内部可写”常用 `public internal(set)`(示例:`Sources/RDReaderView/EPUBCore/RDEPUBParser.swift`)
|
- “对外只读、内部可写”常用 `public internal(set)`(示例:`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser.swift`)
|
||||||
|
|
||||||
## 导入与依赖使用
|
## 导入与依赖使用
|
||||||
|
|
||||||
**import:**
|
**import:**
|
||||||
- UIKit/UI 文件:`import UIKit`(大量文件)
|
- UIKit/UI 文件:`import UIKit`(大量文件)
|
||||||
- Core/模型文件:`import Foundation`(如 `Sources/RDReaderView/EPUBCore/RDEPUBModels.swift`)
|
- Core/模型文件:`import Foundation`(如 `Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift`)
|
||||||
- 三方依赖按需引入:
|
- 三方依赖按需引入:
|
||||||
- `SnapKit`:布局
|
- `SnapKit`:布局
|
||||||
- `SSAlertSwift`:弹窗/提示
|
- `SSAlertSwift`:弹窗/提示
|
||||||
@@ -52,15 +52,15 @@
|
|||||||
|
|
||||||
## 错误处理与日志
|
## 错误处理与日志
|
||||||
|
|
||||||
- Core 解析层倾向用 `throws` + 自定义 `Error`(示例:`Sources/RDReaderView/EPUBCore/RDEPUBParser.swift`、`Sources/RDReaderView/EPUBCore/RDEPUBModels.swift` 的 `RDEPUBParserError`)
|
- Core 解析层倾向用 `throws` + 自定义 `Error`(示例:`Sources/RDEpubReaderView/EPUBCore/RDEPUBParser.swift`、`Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift` 的 `RDEPUBParserError`)
|
||||||
- UI/控制器层常见 `guard` 早返回(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift`)
|
- UI/控制器层常见 `guard` 早返回(示例:`ReadViewDemo/ReadViewDemo/ViewController.swift`)
|
||||||
- 未检测到统一日志框架(未发现专用 logging package/config);出现时以系统 API/局部输出为主(需按具体文件核对)。
|
- 未检测到统一日志框架(未发现专用 logging package/config);出现时以系统 API/局部输出为主(需按具体文件核对)。
|
||||||
|
|
||||||
## 注释与文档
|
## 注释与文档
|
||||||
|
|
||||||
- **项目规则(强约束)**:代码标识符保持英文,但**代码注释/文档/提交信息使用中文**(见 `CONTEXT.md`)。
|
- **项目规则(强约束)**:代码标识符保持英文,但**代码注释/文档/提交信息使用中文**(见 `CONTEXT.md`)。
|
||||||
- 历史文件常带 Xcode 头部注释块(示例:`Sources/RDReaderView/ReaderView/RDReaderView.swift`)。
|
- 历史文件常带 Xcode 头部注释块(示例:`Sources/RDEpubReaderView/ReaderView/RDEpubReaderView.swift`)。
|
||||||
- 公共 API 处存在少量三斜线文档注释(示例:`Sources/RDReaderView/RDReaderView.swift` 的中文说明)。
|
- 公共 API 处存在少量三斜线文档注释(示例:`Sources/RDEpubReaderView/RDEpubReaderView.swift` 的中文说明)。
|
||||||
|
|
||||||
## Lint / Formatter / 静态检查
|
## Lint / Formatter / 静态检查
|
||||||
|
|
||||||
@@ -76,10 +76,10 @@
|
|||||||
## Evidence(关键证据文件)
|
## Evidence(关键证据文件)
|
||||||
|
|
||||||
- `CONTEXT.md`
|
- `CONTEXT.md`
|
||||||
- `Podfile`
|
- `ReadViewDemo/Podfile`
|
||||||
- `RDReaderView.podspec`
|
- `RDEpubReaderView.podspec`
|
||||||
- `ReadViewDemo/ReadViewDemo/ViewController.swift`
|
- `ReadViewDemo/ReadViewDemo/ViewController.swift`
|
||||||
- `Sources/RDReaderView/ReaderView/RDReaderView.swift`
|
- `Sources/RDEpubReaderView/ReaderView/RDEpubReaderView.swift`
|
||||||
- `Sources/RDReaderView/EPUBCore/RDEPUBParser.swift`
|
- `Sources/RDEpubReaderView/EPUBCore/RDEPUBParser.swift`
|
||||||
- `Sources/RDReaderView/EPUBCore/RDEPUBModels.swift`
|
- `Sources/RDEpubReaderView/EPUBCore/RDEPUBModels.swift`
|
||||||
- `Sources/RDReaderView/EPUBUI/RDEPUBReaderController.swift`
|
- `Sources/RDEpubReaderView/EPUBUI/RDEPUBReaderController.swift`
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ final class RDEPUBTextSearchEngine: RDEPUBSearchEngine {
|
|||||||
|
|
||||||
## 9. 纯文本构建器
|
## 9. 纯文本构建器
|
||||||
|
|
||||||
**文件:** `RDPlainTextBookBuilder.swift`
|
**文件:** `RDEpubPlainTextBookBuilder.swift`
|
||||||
|
|
||||||
从纯文本(.txt)文件构建 `RDEPUBTextBook`,用于支持 TXT 格式阅读。
|
从纯文本(.txt)文件构建 `RDEPUBTextBook`,用于支持 TXT 格式阅读。
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public final class RDEPUBReaderController: UIViewController {
|
|||||||
let epubURL: URL // EPUB 文件路径
|
let epubURL: URL // EPUB 文件路径
|
||||||
let persistence: RDEPUBReaderPersistence? // 持久化代理
|
let persistence: RDEPUBReaderPersistence? // 持久化代理
|
||||||
let dependencies: RDEPUBReaderDependencies // 依赖注入
|
let dependencies: RDEPUBReaderDependencies // 依赖注入
|
||||||
let readerView = RDReaderView() // 翻页容器
|
let readerView = RDEpubReaderView() // 翻页容器
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public final class RDEPUBReaderController: UIViewController {
|
|||||||
| 文件 | 职责 |
|
| 文件 | 职责 |
|
||||||
|------|------|
|
|------|------|
|
||||||
| `RDEPUBReaderController+PublicAPI.swift` | 公开 API(跳转、搜索、标注、书签) |
|
| `RDEPUBReaderController+PublicAPI.swift` | 公开 API(跳转、搜索、标注、书签) |
|
||||||
| `RDEPUBReaderController+DataSource.swift` | `RDReaderPageProvider` 实现 |
|
| `RDEPUBReaderController+DataSource.swift` | `RDEpubReaderPageProvider` 实现 |
|
||||||
| `RDEPUBReaderController+ContentDelegates.swift` | WebView/TextContentView 代理路由 |
|
| `RDEPUBReaderController+ContentDelegates.swift` | WebView/TextContentView 代理路由 |
|
||||||
| `RDEPUBReaderController+LocationResolution.swift` | 页码/位置解析、阅读状态同步 |
|
| `RDEPUBReaderController+LocationResolution.swift` | 页码/位置解析、阅读状态同步 |
|
||||||
| `RDEPUBReaderController+ExternalLinks.swift` | 外部链接处理(白名单、确认弹窗) |
|
| `RDEPUBReaderController+ExternalLinks.swift` | 外部链接处理(白名单、确认弹窗) |
|
||||||
@@ -120,7 +120,7 @@ public protocol RDEPUBReaderPersistence: AnyObject {
|
|||||||
```swift
|
```swift
|
||||||
final class RDEPUBReaderContext {
|
final class RDEPUBReaderContext {
|
||||||
weak var controller: RDEPUBReaderController?
|
weak var controller: RDEPUBReaderController?
|
||||||
weak var readerView: RDReaderView?
|
weak var readerView: RDEpubReaderView?
|
||||||
var dependencies: RDEPUBReaderDependencies
|
var dependencies: RDEPUBReaderDependencies
|
||||||
var runtime: RDEPUBReaderRuntime?
|
var runtime: RDEPUBReaderRuntime?
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ public struct RDEPUBReaderDependencies {
|
|||||||
public var makeParser: () -> RDEPUBParser
|
public var makeParser: () -> RDEPUBParser
|
||||||
public var makePaginator: () -> RDEPUBPaginator
|
public var makePaginator: () -> RDEPUBPaginator
|
||||||
public var makeTextBookBuilder: (RDEPUBTextRenderer, RDEPUBTextBookCache?, RDEPUBTextLayoutConfig) -> RDEPUBTextBookBuilder
|
public var makeTextBookBuilder: (RDEPUBTextRenderer, RDEPUBTextBookCache?, RDEPUBTextLayoutConfig) -> RDEPUBTextBookBuilder
|
||||||
public var makePlainTextBookBuilder: (RDEPUBTextRenderer, RDEPUBTextLayoutConfig) -> RDPlainTextBookBuilder
|
public var makePlainTextBookBuilder: (RDEPUBTextRenderer, RDEPUBTextLayoutConfig) -> RDEpubPlainTextBookBuilder
|
||||||
public var makeTextRenderer: (RDEPUBTextRenderingEngine) -> RDEPUBTextRenderer
|
public var makeTextRenderer: (RDEPUBTextRenderingEngine) -> RDEPUBTextRenderer
|
||||||
|
|
||||||
public static var live: RDEPUBReaderDependencies // 默认实现
|
public static var live: RDEPUBReaderDependencies // 默认实现
|
||||||
@@ -659,9 +659,9 @@ struct RDEPUBReaderUIState {
|
|||||||
|
|
||||||
页图协调器(按需分页与全量分页的结果合并)。
|
页图协调器(按需分页与全量分页的结果合并)。
|
||||||
|
|
||||||
### 10.6 RDURLReaderController
|
### 10.6 RDEpubURLReaderController
|
||||||
|
|
||||||
**文件:** `RDURLReaderController.swift`
|
**文件:** `RDEpubURLReaderController.swift`
|
||||||
|
|
||||||
URL 阅读器控制器(用于打开单个 URL)。
|
URL 阅读器控制器(用于打开单个 URL)。
|
||||||
|
|
||||||
@@ -715,12 +715,12 @@ RDEPUBReaderRuntime.applyParsedPublication()
|
|||||||
│
|
│
|
||||||
├── RDEPUBBookPageMap 生成
|
├── RDEPUBBookPageMap 生成
|
||||||
│
|
│
|
||||||
└── RDReaderView.transitionToPage() → 显示页面
|
└── RDEpubReaderView.transitionToPage() → 显示页面
|
||||||
|
|
||||||
用户翻页
|
用户翻页
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
RDReaderView.currentPage 变化
|
RDEpubReaderView.currentPage 变化
|
||||||
│
|
│
|
||||||
├── RDEPUBReaderLocationCoordinator.recordPageChangeIfNeeded()
|
├── RDEPUBReaderLocationCoordinator.recordPageChangeIfNeeded()
|
||||||
│ └── persistence.saveLocation()
|
│ └── persistence.saveLocation()
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
生成点:
|
生成点:
|
||||||
|
|
||||||
- `Sources/RDReaderView/EPUBUI/ReaderController/ChapterRuntime/RDEPUBChapterLoader.swift:494`(`buildPagesFromRanges`)
|
- `Sources/RDEpubReaderView/EPUBUI/ReaderController/ChapterRuntime/RDEPUBChapterLoader.swift:494`(`buildPagesFromRanges`)
|
||||||
- `Sources/RDReaderView/EPUBTextRendering/BuildPipeline/RDEPUBTextBookBuilder.swift:294`
|
- `Sources/RDEpubReaderView/EPUBTextRendering/BuildPipeline/RDEPUBTextBookBuilder.swift:294`
|
||||||
- `Sources/RDReaderView/EPUBTextRendering/RDPlainTextBookBuilder.swift:78`
|
- `Sources/RDEpubReaderView/EPUBTextRendering/RDEpubPlainTextBookBuilder.swift:78`
|
||||||
|
|
||||||
现存全部消费点(已盘点确认,仅 3 处):
|
现存全部消费点(已盘点确认,仅 3 处):
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
**任务**:
|
**任务**:
|
||||||
|
|
||||||
- [x] 将 `RDEPUBTextPage.content` 改为按需构造:已改为基于 `chapterContent` + `contentRange` 的计算属性(带范围钳制),公开读取 API 不变
|
- [x] 将 `RDEPUBTextPage.content` 改为按需构造:已改为基于 `chapterContent` + `contentRange` 的计算属性(带范围钳制),公开读取 API 不变
|
||||||
- [x] 三个构造点(`RDEPUBChapterLoader` / `RDEPUBTextBookBuilder` / `RDPlainTextBookBuilder`)不再生成每页子串;消费点经计算属性透明按需构造
|
- [x] 三个构造点(`RDEPUBChapterLoader` / `RDEPUBTextBookBuilder` / `RDEpubPlainTextBookBuilder`)不再生成每页子串;消费点经计算属性透明按需构造
|
||||||
- [x] `Equatable` 确认:`content` 为派生值,由 `contentRange` + `chapterContent` 判等覆盖,语义不变
|
- [x] `Equatable` 确认:`content` 为派生值,由 `contentRange` + `chapterContent` 判等覆盖,语义不变
|
||||||
|
|
||||||
**API 兼容性注意**:
|
**API 兼容性注意**:
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
### P0-3 保持现有缓存限制,防止错误复用
|
### P0-3 保持现有缓存限制,防止错误复用
|
||||||
|
|
||||||
- [x] `shouldAvoidReaderPageCaching`(`RDEPUBTextContentView.swift:319`)保持现状,已补注释说明放开的前置条件是 P1-1 落地
|
- [x] `shouldAvoidReaderPageCaching`(`RDEPUBTextContentView.swift:319`)保持现状,已补注释说明放开的前置条件是 P1-1 落地
|
||||||
- [x] 本阶段未改 `RDReaderPreloadController` 行为
|
- [x] 本阶段未改 `RDEpubReaderPreloadController` 行为
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
前置:P1-1~P1-3 全部落地后,页面视图不再持有整章副本。
|
前置:P1-1~P1-3 全部落地后,页面视图不再持有整章副本。
|
||||||
|
|
||||||
- [ ] 调整 `shouldAvoidReaderPageCaching` 判定,允许轻量化后的文本页进入 `RDReaderPreloadController` 缓存
|
- [ ] 调整 `shouldAvoidReaderPageCaching` 判定,允许轻量化后的文本页进入 `RDEpubReaderPreloadController` 缓存
|
||||||
- [ ] 对比放开前后的翻页流畅度与峰值内存,数据不佳则回退此项
|
- [ ] 对比放开前后的翻页流畅度与峰值内存,数据不佳则回退此项
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -6,54 +6,54 @@
|
|||||||
|
|
||||||
## 1. 模块概述
|
## 1. 模块概述
|
||||||
|
|
||||||
`ReaderView` 是 ReadViewSDK 的**通用翻页容器层**,位于 EPUBUI 层之下。它提供与 EPUB 内容无关的页面展示、翻页动画、手势识别、页面预加载和双页布局能力。上层通过 `RDReaderPageProvider` 协议提供页面内容视图,ReaderView 负责容器管理和翻页调度。
|
`ReaderView` 是 ReadViewSDK 的**通用翻页容器层**,位于 EPUBUI 层之下。它提供与 EPUB 内容无关的页面展示、翻页动画、手势识别、页面预加载和双页布局能力。上层通过 `RDEpubReaderPageProvider` 协议提供页面内容视图,ReaderView 负责容器管理和翻页调度。
|
||||||
|
|
||||||
**文件清单(14 个 Swift 文件):**
|
**文件清单(14 个 Swift 文件):**
|
||||||
|
|
||||||
| 文件 | 核心类型 | 职责 |
|
| 文件 | 核心类型 | 职责 |
|
||||||
|------|----------|------|
|
|------|----------|------|
|
||||||
| `RDReaderView.swift` | `RDReaderView` | 主容器视图,协调所有子组件 |
|
| `RDEpubReaderView.swift` | `RDEpubReaderView` | 主容器视图,协调所有子组件 |
|
||||||
| `RDReaderViewProtocols.swift` | 协议 + 枚举 | 数据源、代理、导航协议定义 |
|
| `RDEpubReaderViewProtocols.swift` | 协议 + 枚举 | 数据源、代理、导航协议定义 |
|
||||||
| `RDReaderFlowLayout.swift` | `RDReaderFlowLayout` | UICollectionView 自定义布局 |
|
| `RDEpubReaderFlowLayout.swift` | `RDEpubReaderFlowLayout` | UICollectionView 自定义布局 |
|
||||||
| `RDReaderGestureController.swift` | `RDReaderGestureController` | 手势控制器(预留) |
|
| `RDEpubReaderGestureController.swift` | `RDEpubReaderGestureController` | 手势控制器(预留) |
|
||||||
| `RDReaderContentCell.swift` | `RDReaderContentCell` | CollectionView 内容 Cell |
|
| `RDEpubReaderContentCell.swift` | `RDEpubReaderContentCell` | CollectionView 内容 Cell |
|
||||||
| `RDReaderPageChildViewController.swift` | `RDReaderPageChildViewController` | PageCurl 模式子 VC |
|
| `RDEpubReaderPageChildViewController.swift` | `RDEpubReaderPageChildViewController` | PageCurl 模式子 VC |
|
||||||
| `RDReaderView+PageCurl.swift` | Extension | UIPageViewController 数据源/代理 |
|
| `RDEpubReaderView+PageCurl.swift` | Extension | UIPageViewController 数据源/代理 |
|
||||||
| `RDReaderView+CollectionView.swift` | Extension | UICollectionView 数据源/布局代理 |
|
| `RDEpubReaderView+CollectionView.swift` | Extension | UICollectionView 数据源/布局代理 |
|
||||||
| `RDReaderView+ContentAccess.swift` | Extension | 内容视图访问与复用 |
|
| `RDEpubReaderView+ContentAccess.swift` | Extension | 内容视图访问与复用 |
|
||||||
| `RDReaderView+ToolView.swift` | Extension | 工具栏安装与动画 |
|
| `RDEpubReaderView+ToolView.swift` | Extension | 工具栏安装与动画 |
|
||||||
| `Paging/RDReaderPagingController.swift` | `RDReaderPagingController` | 翻页状态机 |
|
| `Paging/RDEpubReaderPagingController.swift` | `RDEpubReaderPagingController` | 翻页状态机 |
|
||||||
| `Paging/RDReaderPreloadController.swift` | `RDReaderPreloadController` | 页面预加载与缓存 |
|
| `Paging/RDEpubReaderPreloadController.swift` | `RDEpubReaderPreloadController` | 页面预加载与缓存 |
|
||||||
| `Paging/RDReaderSpreadResolver.swift` | `RDReaderSpreadResolver` | 双页展开计算 |
|
| `Paging/RDEpubReaderSpreadResolver.swift` | `RDEpubReaderSpreadResolver` | 双页展开计算 |
|
||||||
| `Paging/RDReaderTapRegionHandler.swift` | `RDReaderTapRegionHandler` | 点击区域判定 |
|
| `Paging/RDEpubReaderTapRegionHandler.swift` | `RDEpubReaderTapRegionHandler` | 点击区域判定 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. 协议定义(RDReaderViewProtocols.swift)
|
## 2. 协议定义(RDEpubReaderViewProtocols.swift)
|
||||||
|
|
||||||
### 2.1 RDReaderDataSource(旧版数据源,已废弃)
|
### 2.1 RDEpubReaderDataSource(旧版数据源,已废弃)
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderDataSource: NSObjectProtocol {
|
@objc public protocol RDEpubReaderDataSource: NSObjectProtocol {
|
||||||
func pageCountOfReaderView(readerView: RDReaderView) -> Int
|
func pageCountOfReaderView(readerView: RDEpubReaderView) -> Int
|
||||||
func pageContentView(readerView: RDReaderView, pageNum: Int, containerView: UIView?) -> UIView
|
func pageContentView(readerView: RDEpubReaderView, pageNum: Int, containerView: UIView?) -> UIView
|
||||||
func pageIdentifier(readerView: RDReaderView, pageNum: Int) -> String?
|
func pageIdentifier(readerView: RDEpubReaderView, pageNum: Int) -> String?
|
||||||
@objc optional func topToolView(readerView: RDReaderView) -> UIView?
|
@objc optional func topToolView(readerView: RDEpubReaderView) -> UIView?
|
||||||
@objc optional func bottomToolView(readerView: RDReaderView) -> UIView?
|
@objc optional func bottomToolView(readerView: RDEpubReaderView) -> UIView?
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> 向后兼容保留,新代码应使用 `RDReaderPageProvider`。
|
> 向后兼容保留,新代码应使用 `RDEpubReaderPageProvider`。
|
||||||
|
|
||||||
### 2.2 RDReaderPageProvider(推荐数据源)
|
### 2.2 RDEpubReaderPageProvider(推荐数据源)
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderPageProvider: NSObjectProtocol {
|
@objc public protocol RDEpubReaderPageProvider: NSObjectProtocol {
|
||||||
func numberOfPages(in readerView: RDReaderView) -> Int
|
func numberOfPages(in readerView: RDEpubReaderView) -> Int
|
||||||
func readerView(_ readerView: RDReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView
|
func readerView(_ readerView: RDEpubReaderView, viewForPageAt index: Int, reusableView: UIView?) -> UIView
|
||||||
@objc optional func pageIdentifier(in readerView: RDReaderView, index: Int) -> String?
|
@objc optional func pageIdentifier(in readerView: RDEpubReaderView, index: Int) -> String?
|
||||||
@objc optional func readerViewTopChrome(_ readerView: RDReaderView) -> UIView?
|
@objc optional func readerViewTopChrome(_ readerView: RDEpubReaderView) -> UIView?
|
||||||
@objc optional func readerViewBottomChrome(_ readerView: RDReaderView) -> UIView?
|
@objc optional func readerViewBottomChrome(_ readerView: RDEpubReaderView) -> UIView?
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -65,31 +65,31 @@
|
|||||||
| `readerViewTopChrome(_:)` | 返回顶部工具栏视图 |
|
| `readerViewTopChrome(_:)` | 返回顶部工具栏视图 |
|
||||||
| `readerViewBottomChrome(_:)` | 返回底部工具栏视图 |
|
| `readerViewBottomChrome(_:)` | 返回底部工具栏视图 |
|
||||||
|
|
||||||
### 2.3 RDReaderDelegate
|
### 2.3 RDEpubReaderDelegate
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@objc public protocol RDReaderDelegate: NSObjectProtocol {
|
@objc public protocol RDEpubReaderDelegate: NSObjectProtocol {
|
||||||
func pageNum(readerView: RDReaderView, pageNum: Int)
|
func pageNum(readerView: RDEpubReaderView, pageNum: Int)
|
||||||
@objc optional func readerViewOrientationWillChange(readerView: RDReaderView, isLandscape: Bool)
|
@objc optional func readerViewOrientationWillChange(readerView: RDEpubReaderView, isLandscape: Bool)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.4 RDReaderPageNavigating
|
### 2.4 RDEpubReaderPageNavigating
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public protocol RDReaderPageNavigating: AnyObject {
|
public protocol RDEpubReaderPageNavigating: AnyObject {
|
||||||
var currentPage: Int { get }
|
var currentPage: Int { get }
|
||||||
func reloadPages()
|
func reloadPages()
|
||||||
func transition(to page: Int, animated: Bool)
|
func transition(to page: Int, animated: Bool)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`RDReaderView` 遵循此协议,提供统一的页面导航接口。
|
`RDEpubReaderView` 遵循此协议,提供统一的页面导航接口。
|
||||||
|
|
||||||
### 2.5 枚举类型
|
### 2.5 枚举类型
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
extension RDReaderView {
|
extension RDEpubReaderView {
|
||||||
public enum DisplayType {
|
public enum DisplayType {
|
||||||
case pageCurl // 仿真翻页(UIPageViewController)
|
case pageCurl // 仿真翻页(UIPageViewController)
|
||||||
case horizontalScroll // 水平滑动(UICollectionView)
|
case horizontalScroll // 水平滑动(UICollectionView)
|
||||||
@@ -105,13 +105,13 @@ extension RDReaderView {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3. 核心类:RDReaderView
|
## 3. 核心类:RDEpubReaderView
|
||||||
|
|
||||||
**文件:** `RDReaderView.swift`
|
**文件:** `RDEpubReaderView.swift`
|
||||||
|
|
||||||
`RDReaderView` 是一个 `UIView` 子类,作为翻页容器的主入口。内部管理两种翻页引擎:
|
`RDEpubReaderView` 是一个 `UIView` 子类,作为翻页容器的主入口。内部管理两种翻页引擎:
|
||||||
- **PageCurl 模式**:使用 `UIPageViewController` 实现仿真翻页
|
- **PageCurl 模式**:使用 `UIPageViewController` 实现仿真翻页
|
||||||
- **Scroll 模式**:使用 `UICollectionView` + 自定义 `RDReaderFlowLayout` 实现滑动翻页
|
- **Scroll 模式**:使用 `UICollectionView` + 自定义 `RDEpubReaderFlowLayout` 实现滑动翻页
|
||||||
|
|
||||||
### 3.1 关键属性
|
### 3.1 关键属性
|
||||||
|
|
||||||
@@ -124,16 +124,16 @@ extension RDReaderView {
|
|||||||
| `coverPageIndex` | `Int?` | 封面页索引(独占一屏) |
|
| `coverPageIndex` | `Int?` | 封面页索引(独占一屏) |
|
||||||
| `pagesPerScreen` | `Int` | 每屏页数(横屏双页时为 2) |
|
| `pagesPerScreen` | `Int` | 每屏页数(横屏双页时为 2) |
|
||||||
| `preloadRadius` | `Int` | 预加载半径(默认 1) |
|
| `preloadRadius` | `Int` | 预加载半径(默认 1) |
|
||||||
| `dataSource` | `RDReaderDataSource?` | 旧版数据源 |
|
| `dataSource` | `RDEpubReaderDataSource?` | 旧版数据源 |
|
||||||
| `pageProvider` | `RDReaderPageProvider?` | 推荐数据源 |
|
| `pageProvider` | `RDEpubReaderPageProvider?` | 推荐数据源 |
|
||||||
| `delegate` | `RDReaderDelegate?` | 事件代理 |
|
| `delegate` | `RDEpubReaderDelegate?` | 事件代理 |
|
||||||
| `toolViewAnimationDuration` | `TimeInterval` | 工具栏动画时长(0.3s) |
|
| `toolViewAnimationDuration` | `TimeInterval` | 工具栏动画时长(0.3s) |
|
||||||
|
|
||||||
### 3.2 关键方法
|
### 3.2 关键方法
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
/// 切换显示模式(pageCurl / horizontalScroll / verticalScroll)
|
/// 切换显示模式(pageCurl / horizontalScroll / verticalScroll)
|
||||||
public func switchReaderDisplayType(_ displayType: RDReaderView.DisplayType)
|
public func switchReaderDisplayType(_ displayType: RDEpubReaderView.DisplayType)
|
||||||
|
|
||||||
/// 跳转到指定页
|
/// 跳转到指定页
|
||||||
public func transitionToPage(pageNum: Int, animated: Bool = false)
|
public func transitionToPage(pageNum: Int, animated: Bool = false)
|
||||||
@@ -154,22 +154,22 @@ public func isFullScreenPage(_ pageNum: Int) -> Bool
|
|||||||
|------|------|------|
|
|------|------|------|
|
||||||
| `pageViewController` | `UIPageViewController` | PageCurl 翻页引擎 |
|
| `pageViewController` | `UIPageViewController` | PageCurl 翻页引擎 |
|
||||||
| `collectionView` | `UICollectionView` | Scroll 翻页引擎 |
|
| `collectionView` | `UICollectionView` | Scroll 翻页引擎 |
|
||||||
| `layout` | `RDReaderFlowLayout` | CollectionView 自定义布局 |
|
| `layout` | `RDEpubReaderFlowLayout` | CollectionView 自定义布局 |
|
||||||
| `spreadResolver` | `RDReaderSpreadResolver` | 双页配对计算 |
|
| `spreadResolver` | `RDEpubReaderSpreadResolver` | 双页配对计算 |
|
||||||
| `tapRegionHandler` | `RDReaderTapRegionHandler` | 点击区域判定 |
|
| `tapRegionHandler` | `RDEpubReaderTapRegionHandler` | 点击区域判定 |
|
||||||
| `preloadController` | `RDReaderPreloadController` | 页面预加载与缓存 |
|
| `preloadController` | `RDEpubReaderPreloadController` | 页面预加载与缓存 |
|
||||||
| `pagingController` | `RDReaderPagingController` | 翻页状态管理 |
|
| `pagingController` | `RDEpubReaderPagingController` | 翻页状态管理 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 4. 翻页状态机:RDReaderPagingController
|
## 4. 翻页状态机:RDEpubReaderPagingController
|
||||||
|
|
||||||
**文件:** `Paging/RDReaderPagingController.swift`
|
**文件:** `Paging/RDEpubReaderPagingController.swift`
|
||||||
|
|
||||||
管理 PageCurl 模式下的翻页请求队列,防止动画冲突。
|
管理 PageCurl 模式下的翻页请求队列,防止动画冲突。
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
struct RDReaderPagingController {
|
struct RDEpubReaderPagingController {
|
||||||
struct PageTransitionRequest: Equatable {
|
struct PageTransitionRequest: Equatable {
|
||||||
let pageNum: Int
|
let pageNum: Int
|
||||||
let animated: Bool
|
let animated: Bool
|
||||||
@@ -180,7 +180,7 @@ struct RDReaderPagingController {
|
|||||||
var didBuildUI: Bool // UI 是否已构建
|
var didBuildUI: Bool // UI 是否已构建
|
||||||
|
|
||||||
/// 判断是否应排队请求(PageCurl 模式下动画中返回 true)
|
/// 判断是否应排队请求(PageCurl 模式下动画中返回 true)
|
||||||
mutating func shouldQueuePageTransition(_ request: PageTransitionRequest, currentDisplayType: RDReaderView.DisplayType) -> Bool
|
mutating func shouldQueuePageTransition(_ request: PageTransitionRequest, currentDisplayType: RDEpubReaderView.DisplayType) -> Bool
|
||||||
|
|
||||||
/// 完成翻页动画,返回待处理的请求
|
/// 完成翻页动画,返回待处理的请求
|
||||||
mutating func finishPageCurlTransition() -> PageTransitionRequest?
|
mutating func finishPageCurlTransition() -> PageTransitionRequest?
|
||||||
@@ -192,9 +192,9 @@ struct RDReaderPagingController {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. 页面预加载:RDReaderPreloadController
|
## 5. 页面预加载:RDEpubReaderPreloadController
|
||||||
|
|
||||||
**文件:** `Paging/RDReaderPreloadController.swift`
|
**文件:** `Paging/RDEpubReaderPreloadController.swift`
|
||||||
|
|
||||||
负责在当前页周围预渲染页面视图,减少翻页时的白屏时间。
|
负责在当前页周围预渲染页面视图,减少翻页时的白屏时间。
|
||||||
|
|
||||||
@@ -224,27 +224,27 @@ func invalidate(environment: Environment)
|
|||||||
|
|
||||||
```swift
|
```swift
|
||||||
struct Environment {
|
struct Environment {
|
||||||
let displayType: RDReaderView.DisplayType
|
let displayType: RDEpubReaderView.DisplayType
|
||||||
let isLandscape: Bool
|
let isLandscape: Bool
|
||||||
let pagesPerScreen: Int
|
let pagesPerScreen: Int
|
||||||
let boundsSize: CGSize
|
let boundsSize: CGSize
|
||||||
let landscapeDualPageEnabled: Bool
|
let landscapeDualPageEnabled: Bool
|
||||||
let coverPageIndex: Int?
|
let coverPageIndex: Int?
|
||||||
let totalPages: Int
|
let totalPages: Int
|
||||||
let spreadResolver: RDReaderSpreadResolver
|
let spreadResolver: RDEpubReaderSpreadResolver
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 6. 双页展开计算:RDReaderSpreadResolver
|
## 6. 双页展开计算:RDEpubReaderSpreadResolver
|
||||||
|
|
||||||
**文件:** `Paging/RDReaderSpreadResolver.swift`
|
**文件:** `Paging/RDEpubReaderSpreadResolver.swift`
|
||||||
|
|
||||||
纯函数式结构体,负责双页模式下的页面配对和导航计算。
|
纯函数式结构体,负责双页模式下的页面配对和导航计算。
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
struct RDReaderSpreadResolver {
|
struct RDEpubReaderSpreadResolver {
|
||||||
/// 判断是否为全屏页(封面页独占一屏)
|
/// 判断是否为全屏页(封面页独占一屏)
|
||||||
func isFullScreenPage(_ pageNum: Int, landscapeDualPageEnabled: Bool, isLandscape: Bool, coverPageIndex: Int?) -> Bool
|
func isFullScreenPage(_ pageNum: Int, landscapeDualPageEnabled: Bool, isLandscape: Bool, coverPageIndex: Int?) -> Bool
|
||||||
|
|
||||||
@@ -265,15 +265,15 @@ struct RDReaderSpreadResolver {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 7. 点击区域判定:RDReaderTapRegionHandler
|
## 7. 点击区域判定:RDEpubReaderTapRegionHandler
|
||||||
|
|
||||||
**文件:** `Paging/RDReaderTapRegionHandler.swift`
|
**文件:** `Paging/RDEpubReaderTapRegionHandler.swift`
|
||||||
|
|
||||||
将屏幕三等分,判定点击属于左/中/右区域。
|
将屏幕三等分,判定点击属于左/中/右区域。
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
struct RDReaderTapRegionHandler {
|
struct RDEpubReaderTapRegionHandler {
|
||||||
func resolveTapEvent(point: CGPoint, viewFrame: CGRect, isToolViewVisible: Bool) -> RDReaderView.TapEvent
|
func resolveTapEvent(point: CGPoint, viewFrame: CGRect, isToolViewVisible: Bool) -> RDEpubReaderView.TapEvent
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -284,9 +284,9 @@ struct RDReaderTapRegionHandler {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 8. 流式布局:RDReaderFlowLayout
|
## 8. 流式布局:RDEpubReaderFlowLayout
|
||||||
|
|
||||||
**文件:** `RDReaderFlowLayout.swift`
|
**文件:** `RDEpubReaderFlowLayout.swift`
|
||||||
|
|
||||||
`UICollectionViewFlowLayout` 子类,支持水平滚动和垂直滚动两种模式。
|
`UICollectionViewFlowLayout` 子类,支持水平滚动和垂直滚动两种模式。
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ struct RDReaderTapRegionHandler {
|
|||||||
|
|
||||||
| 属性 | 类型 | 说明 |
|
| 属性 | 类型 | 说明 |
|
||||||
|------|------|------|
|
|------|------|------|
|
||||||
| `displayType` | `RDReaderView.DisplayType` | 布局模式 |
|
| `displayType` | `RDEpubReaderView.DisplayType` | 布局模式 |
|
||||||
| `isLandscapeDualPage` | `Bool` | 是否横屏双页 |
|
| `isLandscapeDualPage` | `Bool` | 是否横屏双页 |
|
||||||
| `coverPageIndex` | `Int?` | 封面页索引 |
|
| `coverPageIndex` | `Int?` | 封面页索引 |
|
||||||
| `pagesPerScreen` | `Int` | 每屏页数 |
|
| `pagesPerScreen` | `Int` | 每屏页数 |
|
||||||
@@ -302,12 +302,12 @@ struct RDReaderTapRegionHandler {
|
|||||||
### 8.2 协议
|
### 8.2 协议
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
public protocol RDReaderFlowLayoutDataSoure: NSObjectProtocol {
|
public protocol RDEpubReaderFlowLayoutDataSoure: NSObjectProtocol {
|
||||||
func heigtOfVerticalScrollPage(flowLayout: RDReaderFlowLayout, pageIndex: Int) -> CGFloat?
|
func heigtOfVerticalScrollPage(flowLayout: RDEpubReaderFlowLayout, pageIndex: Int) -> CGFloat?
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public protocol RDReaderFlowLayoutDelegate: NSObjectProtocol {
|
@objc public protocol RDEpubReaderFlowLayoutDelegate: NSObjectProtocol {
|
||||||
func pageNum(flowLayout: RDReaderFlowLayout, pageIndex: Int)
|
func pageNum(flowLayout: RDEpubReaderFlowLayout, pageIndex: Int)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -324,28 +324,28 @@ func currentContentOffset(count: Int) -> CGPoint
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 9. 内容 Cell:RDReaderContentCell
|
## 9. 内容 Cell:RDEpubReaderContentCell
|
||||||
|
|
||||||
**文件:** `RDReaderContentCell.swift`
|
**文件:** `RDEpubReaderContentCell.swift`
|
||||||
|
|
||||||
`UICollectionViewCell` 子类,用于 Scroll 模式下承载页面内容视图。
|
`UICollectionViewCell` 子类,用于 Scroll 模式下承载页面内容视图。
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
class RDReaderContentCell: UICollectionViewCell {
|
class RDEpubReaderContentCell: UICollectionViewCell {
|
||||||
var containerView: UIView? // 设置时自动添加到 contentView,移除旧视图
|
var containerView: UIView? // 设置时自动添加到 contentView,移除旧视图
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 10. PageCurl 子控制器:RDReaderPageChildViewController
|
## 10. PageCurl 子控制器:RDEpubReaderPageChildViewController
|
||||||
|
|
||||||
**文件:** `RDReaderPageChildViewController.swift`
|
**文件:** `RDEpubReaderPageChildViewController.swift`
|
||||||
|
|
||||||
`UIViewController` 子类,作为 `UIPageViewController` 的页面 VC。
|
`UIViewController` 子类,作为 `UIPageViewController` 的页面 VC。
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
class RDReaderPageChildViewController: UIViewController {
|
class RDEpubReaderPageChildViewController: UIViewController {
|
||||||
var contentView: UIView? // 内容视图,设置时自动安装到容器
|
var contentView: UIView? // 内容视图,设置时自动安装到容器
|
||||||
var pageNum: Int // 对应页码
|
var pageNum: Int // 对应页码
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ class RDReaderPageChildViewController: UIViewController {
|
|||||||
|
|
||||||
## 11. Extension 汇总
|
## 11. Extension 汇总
|
||||||
|
|
||||||
### 11.1 RDReaderView+PageCurl
|
### 11.1 RDEpubReaderView+PageCurl
|
||||||
|
|
||||||
实现 `UIPageViewControllerDataSource` 和 `UIPageViewControllerDelegate`:
|
实现 `UIPageViewControllerDataSource` 和 `UIPageViewControllerDelegate`:
|
||||||
|
|
||||||
@@ -367,18 +367,18 @@ class RDReaderPageChildViewController: UIViewController {
|
|||||||
- `pageViewController(_:willTransitionTo:)` — 即将翻页时预加载
|
- `pageViewController(_:willTransitionTo:)` — 即将翻页时预加载
|
||||||
|
|
||||||
**特殊页码:**
|
**特殊页码:**
|
||||||
- `RDReaderView.blankPageNum`(`Int.max`)— 双页模式下的空白页
|
- `RDEpubReaderView.blankPageNum`(`Int.max`)— 双页模式下的空白页
|
||||||
- `RDReaderView.blankEndPageNum`(`Int.max - 1`)— 末尾空白页
|
- `RDEpubReaderView.blankEndPageNum`(`Int.max - 1`)— 末尾空白页
|
||||||
|
|
||||||
### 11.2 RDReaderView+CollectionView
|
### 11.2 RDEpubReaderView+CollectionView
|
||||||
|
|
||||||
实现 `UICollectionViewDataSource`、`RDReaderFlowLayoutDelegate`、`RDReaderFlowLayoutDataSoure`:
|
实现 `UICollectionViewDataSource`、`RDEpubReaderFlowLayoutDelegate`、`RDEpubReaderFlowLayoutDataSoure`:
|
||||||
|
|
||||||
- `collectionView(_:cellForItemAt:)` — 复用预加载视图或创建新 Cell
|
- `collectionView(_:cellForItemAt:)` — 复用预加载视图或创建新 Cell
|
||||||
- `collectionView(_:numberOfItemsInSection:)` — 返回总页数
|
- `collectionView(_:numberOfItemsInSection:)` — 返回总页数
|
||||||
- `pageNum(flowLayout:pageIndex:)` — 滚动时更新当前页码
|
- `pageNum(flowLayout:pageIndex:)` — 滚动时更新当前页码
|
||||||
|
|
||||||
### 11.3 RDReaderView+ContentAccess
|
### 11.3 RDEpubReaderView+ContentAccess
|
||||||
|
|
||||||
提供内容视图的注册、复用和查询:
|
提供内容视图的注册、复用和查询:
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ public func pageContentView(pageNum: Int) -> UIView?
|
|||||||
public func resolvedSinglePageSize(pageNum: Int? = nil) -> CGSize
|
public func resolvedSinglePageSize(pageNum: Int? = nil) -> CGSize
|
||||||
```
|
```
|
||||||
|
|
||||||
### 11.4 RDReaderView+ToolView
|
### 11.4 RDEpubReaderView+ToolView
|
||||||
|
|
||||||
管理顶部/底部工具栏的安装、显示/隐藏动画:
|
管理顶部/底部工具栏的安装、显示/隐藏动画:
|
||||||
|
|
||||||
@@ -420,11 +420,11 @@ func updateToolViewHeightConstraintsIfNeeded()
|
|||||||
| 模式 | 应用 |
|
| 模式 | 应用 |
|
||||||
|------|------|
|
|------|------|
|
||||||
| **策略模式** | `DisplayType` 切换 PageCurl / Scroll 两种翻页策略 |
|
| **策略模式** | `DisplayType` 切换 PageCurl / Scroll 两种翻页策略 |
|
||||||
| **适配器模式** | `RDReaderLegacyDataSourceAdapter` 将旧 `RDReaderDataSource` 适配为 `RDReaderPageProvider` |
|
| **适配器模式** | `RDEpubReaderLegacyDataSourceAdapter` 将旧 `RDEpubReaderDataSource` 适配为 `RDEpubReaderPageProvider` |
|
||||||
| **命令队列** | `RDReaderPagingController` 管理翻页请求队列 |
|
| **命令队列** | `RDEpubReaderPagingController` 管理翻页请求队列 |
|
||||||
| **缓存签名** | `RDReaderPreloadController.CacheSignature` 检测环境变化自动失效 |
|
| **缓存签名** | `RDEpubReaderPreloadController.CacheSignature` 检测环境变化自动失效 |
|
||||||
| **关注点分离** | Extension 将不同功能拆分到独立文件 |
|
| **关注点分离** | Extension 将不同功能拆分到独立文件 |
|
||||||
| **纯函数** | `RDReaderSpreadResolver` 和 `RDReaderTapRegionHandler` 无状态计算 |
|
| **纯函数** | `RDEpubReaderSpreadResolver` 和 `RDEpubReaderTapRegionHandler` 无状态计算 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -434,7 +434,7 @@ func updateToolViewHeightConstraintsIfNeeded()
|
|||||||
用户点击屏幕
|
用户点击屏幕
|
||||||
│
|
│
|
||||||
▼
|
▼
|
||||||
RDReaderTapRegionHandler.resolveTapEvent()
|
RDEpubReaderTapRegionHandler.resolveTapEvent()
|
||||||
│
|
│
|
||||||
├── .left → goPreviousPage() ──→ spreadResolver.nextPage(forward: false)
|
├── .left → goPreviousPage() ──→ spreadResolver.nextPage(forward: false)
|
||||||
├── .right → goNextPage() ──→ spreadResolver.nextPage(forward: true)
|
├── .right → goNextPage() ──→ spreadResolver.nextPage(forward: true)
|
||||||
|
|||||||
+4
-4
@@ -64,13 +64,13 @@
|
|||||||
|
|
||||||
### CocoaPods 依赖准备
|
### CocoaPods 依赖准备
|
||||||
|
|
||||||
> 仓库包含示例工程 `ReadViewDemo`,并已提交 `Pods/` 与 `Podfile.lock`。如本地环境未同步,可在仓库根或示例工程目录运行:
|
> 仓库包含示例工程 `ReadViewDemo`,并已提交 `ReadViewDemo/Pods/` 与 `ReadViewDemo/Podfile.lock`。如本地环境未同步,请在示例工程目录运行:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pod install
|
cd ReadViewDemo && pod install
|
||||||
```
|
```
|
||||||
|
|
||||||
(依赖入口:`Podfile`、`ReadViewDemo/Podfile`)
|
(依赖入口:`ReadViewDemo/Podfile`)
|
||||||
|
|
||||||
### 运行 UI 测试
|
### 运行 UI 测试
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ xcodebuild test \
|
|||||||
建议同时记录以下观测项:
|
建议同时记录以下观测项:
|
||||||
|
|
||||||
- `prepareOnDemandChapter` 主线程 wall clock
|
- `prepareOnDemandChapter` 主线程 wall clock
|
||||||
- `RDReaderPreloadController` 预加载命中率
|
- `RDEpubReaderPreloadController` 预加载命中率
|
||||||
- `bookPageMap` partial extension / full replacement 次数
|
- `bookPageMap` partial extension / full replacement 次数
|
||||||
- 页面静态底图缓存命中率
|
- 页面静态底图缓存命中率
|
||||||
- CFI 延迟构建完成次数与耗时
|
- CFI 延迟构建完成次数与耗时
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
**输出**:`RDEPUBTypesettingOutput`(渲染请求、诊断信息、兼容性报告)
|
**输出**:`RDEPUBTypesettingOutput`(渲染请求、诊断信息、兼容性报告)
|
||||||
|
|
||||||
**关键文件**:`Sources/RDReaderView/EPUBTextRendering/Typesetter/`
|
**关键文件**:`Sources/RDEpubReaderView/EPUBTextRendering/Typesetter/`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+28
-28
@@ -31,12 +31,12 @@ graph TB
|
|||||||
IndexTable[RDEPUBTextIndexTable]
|
IndexTable[RDEPUBTextIndexTable]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph RDReaderView
|
subgraph RDEpubReaderView
|
||||||
ReaderView[RDReaderView]
|
ReaderView[RDEpubReaderView]
|
||||||
FlowLayout[RDReaderFlowLayout]
|
FlowLayout[RDEpubReaderFlowLayout]
|
||||||
Preload[RDReaderPreloadController]
|
Preload[RDEpubReaderPreloadController]
|
||||||
Spread[RDReaderSpreadResolver]
|
Spread[RDEpubReaderSpreadResolver]
|
||||||
TapRegion[RDReaderTapRegionHandler]
|
TapRegion[RDEpubReaderTapRegionHandler]
|
||||||
end
|
end
|
||||||
|
|
||||||
subgraph EPUBUI
|
subgraph EPUBUI
|
||||||
@@ -297,11 +297,11 @@ classDiagram
|
|||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
classDiagram
|
classDiagram
|
||||||
class RDReaderView {
|
class RDEpubReaderView {
|
||||||
+currentPage: Int
|
+currentPage: Int
|
||||||
+currentDisplayType: DisplayType
|
+currentDisplayType: DisplayType
|
||||||
+pageProvider: RDReaderPageProvider?
|
+pageProvider: RDEpubReaderPageProvider?
|
||||||
+delegate: RDReaderDelegate?
|
+delegate: RDEpubReaderDelegate?
|
||||||
+landscapeDualPageEnabled: Bool
|
+landscapeDualPageEnabled: Bool
|
||||||
+pageDirection: PageDirection
|
+pageDirection: PageDirection
|
||||||
+coverPageIndex: Int?
|
+coverPageIndex: Int?
|
||||||
@@ -318,14 +318,14 @@ classDiagram
|
|||||||
verticalScroll
|
verticalScroll
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderPageProvider {
|
class RDEpubReaderPageProvider {
|
||||||
<<protocol>>
|
<<protocol>>
|
||||||
+numberOfPages(in:) Int
|
+numberOfPages(in:) Int
|
||||||
+readerView(_:viewForPageAt:reusableView:) UIView
|
+readerView(_:viewForPageAt:reusableView:) UIView
|
||||||
+pageIdentifier(in:index:) String?
|
+pageIdentifier(in:index:) String?
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderFlowLayout {
|
class RDEpubReaderFlowLayout {
|
||||||
+displayType: DisplayType
|
+displayType: DisplayType
|
||||||
+isLandscapeDualPage: Bool
|
+isLandscapeDualPage: Bool
|
||||||
+coverPageIndex: Int?
|
+coverPageIndex: Int?
|
||||||
@@ -333,7 +333,7 @@ classDiagram
|
|||||||
+currentPage: Int
|
+currentPage: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderPreloadController {
|
class RDEpubReaderPreloadController {
|
||||||
+radius: Int
|
+radius: Int
|
||||||
+pageViewForDisplay(pageNum:environment:contentViewProvider:) UIView?
|
+pageViewForDisplay(pageNum:environment:contentViewProvider:) UIView?
|
||||||
+takePreloadedView(for:) UIView?
|
+takePreloadedView(for:) UIView?
|
||||||
@@ -341,13 +341,13 @@ classDiagram
|
|||||||
+invalidate(environment:)
|
+invalidate(environment:)
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderSpreadResolver {
|
class RDEpubReaderSpreadResolver {
|
||||||
+isFullScreenPage(...) Bool
|
+isFullScreenPage(...) Bool
|
||||||
+dualPagePair(for:totalPages:coverPageIndex:) (Int, Int?)
|
+dualPagePair(for:totalPages:coverPageIndex:) (Int, Int?)
|
||||||
+nextPage(from:totalPages:pagesPerScreen:coverPageIndex:forward:) Int?
|
+nextPage(from:totalPages:pagesPerScreen:coverPageIndex:forward:) Int?
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderTapRegionHandler {
|
class RDEpubReaderTapRegionHandler {
|
||||||
+resolveTapEvent(point:viewFrame:isToolViewVisible:) TapEvent
|
+resolveTapEvent(point:viewFrame:isToolViewVisible:) TapEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ classDiagram
|
|||||||
right
|
right
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderPagingController {
|
class RDEpubReaderPagingController {
|
||||||
+isTransitioning: Bool
|
+isTransitioning: Bool
|
||||||
+didBuildUI: Bool
|
+didBuildUI: Bool
|
||||||
+pendingTransitionRequest: PageTransitionRequest?
|
+pendingTransitionRequest: PageTransitionRequest?
|
||||||
@@ -367,25 +367,25 @@ classDiagram
|
|||||||
+finishPageCurlTransition() PageTransitionRequest?
|
+finishPageCurlTransition() PageTransitionRequest?
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderContentCell {
|
class RDEpubReaderContentCell {
|
||||||
+containerView: UIView?
|
+containerView: UIView?
|
||||||
}
|
}
|
||||||
|
|
||||||
class RDReaderPageChildViewController {
|
class RDEpubReaderPageChildViewController {
|
||||||
+contentView: UIView?
|
+contentView: UIView?
|
||||||
+pageNum: Int
|
+pageNum: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
RDReaderView --> DisplayType : uses
|
RDEpubReaderView --> DisplayType : uses
|
||||||
RDReaderView --> RDReaderPageProvider : delegates
|
RDEpubReaderView --> RDEpubReaderPageProvider : delegates
|
||||||
RDReaderView --> RDReaderFlowLayout : owns
|
RDEpubReaderView --> RDEpubReaderFlowLayout : owns
|
||||||
RDReaderView --> RDReaderPreloadController : owns
|
RDEpubReaderView --> RDEpubReaderPreloadController : owns
|
||||||
RDReaderView --> RDReaderSpreadResolver : owns
|
RDEpubReaderView --> RDEpubReaderSpreadResolver : owns
|
||||||
RDReaderView --> RDReaderTapRegionHandler : owns
|
RDEpubReaderView --> RDEpubReaderTapRegionHandler : owns
|
||||||
RDReaderView --> RDReaderPagingController : owns
|
RDEpubReaderView --> RDEpubReaderPagingController : owns
|
||||||
RDReaderView --> RDReaderContentCell : creates
|
RDEpubReaderView --> RDEpubReaderContentCell : creates
|
||||||
RDReaderView --> RDReaderPageChildViewController : creates
|
RDEpubReaderView --> RDEpubReaderPageChildViewController : creates
|
||||||
RDReaderTapRegionHandler --> TapEvent : produces
|
RDEpubReaderTapRegionHandler --> TapEvent : produces
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -403,7 +403,7 @@ classDiagram
|
|||||||
+highlights: [RDEPUBHighlight]
|
+highlights: [RDEPUBHighlight]
|
||||||
+bookmarks: [RDEPUBBookmark]
|
+bookmarks: [RDEPUBBookmark]
|
||||||
+tableOfContents: [EPUBTableOfContentsItem]
|
+tableOfContents: [EPUBTableOfContentsItem]
|
||||||
+readerView: RDReaderView
|
+readerView: RDEpubReaderView
|
||||||
+readerContext: RDEPUBReaderContext
|
+readerContext: RDEPUBReaderContext
|
||||||
+runtime: RDEPUBReaderRuntime?
|
+runtime: RDEPUBReaderRuntime?
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
## 项目信息
|
## 项目信息
|
||||||
|
|
||||||
- **模块总数:** 4 个(EPUBCore、EPUBTextRendering、RDReaderView、EPUBUI)
|
- **模块总数:** 4 个(EPUBCore、EPUBTextRendering、RDEpubReaderView、EPUBUI)
|
||||||
- **Swift 文件数:** 142 个(SDK Sources)
|
- **Swift 文件数:** 142 个(SDK Sources)
|
||||||
- **测试用例数:** 23 个测试类,约 99 个测试方法(UI 测试)
|
- **测试用例数:** 23 个测试类,约 99 个测试方法(UI 测试)
|
||||||
- **最低 iOS 版本:** 15.6
|
- **最低 iOS 版本:** 15.6
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
platform :ios, '15.6'
|
|
||||||
use_frameworks!
|
|
||||||
|
|
||||||
workspace 'ReadViewSDK.xcworkspace'
|
|
||||||
project 'ReadViewSDK.xcodeproj'
|
|
||||||
|
|
||||||
target 'ReadViewSDK' do
|
|
||||||
pod 'RDReaderView', :path => '..'
|
|
||||||
end
|
|
||||||
|
|
||||||
post_install do |installer|
|
|
||||||
apply_settings = lambda do |config|
|
|
||||||
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
|
|
||||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.6'
|
|
||||||
end
|
|
||||||
|
|
||||||
# Pods project (Pods.xcodeproj)
|
|
||||||
installer.pods_project.build_configurations.each { |c| apply_settings.call(c) }
|
|
||||||
installer.pods_project.targets.each { |t| t.build_configurations.each { |c| apply_settings.call(c) } }
|
|
||||||
|
|
||||||
installer.aggregate_targets.each do |at|
|
|
||||||
p = at.user_project
|
|
||||||
next unless p
|
|
||||||
|
|
||||||
# User project(s) that integrate Pods (e.g. ReadViewDemo / ReadViewSDK)
|
|
||||||
p.build_configurations.each { |c| apply_settings.call(c) }
|
|
||||||
p.targets.each { |t| t.build_configurations.each { |c| apply_settings.call(c) } }
|
|
||||||
p.save
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = "RDEpubReaderView"
|
||||||
|
s.module_name = "RDEpubReaderView"
|
||||||
|
s.version = "0.0.1"
|
||||||
|
s.summary = "A reader view for EPUB and plain-text books"
|
||||||
|
s.platform = :ios, "15.0"
|
||||||
|
s.swift_versions = ["5.10"]
|
||||||
|
s.homepage = "http://192.168.21.200:8418/4v5u09Z5a4Yuc/ReadViewSDK.git"
|
||||||
|
s.author = { "shenlei" => "shenlei@touchread.com" }
|
||||||
|
s.source = { :git => "http://192.168.21.200:8418/4v5u09Z5a4Yuc/ReadViewSDK.git", :tag => "#{s.version}" }
|
||||||
|
s.license = "MIT"
|
||||||
|
s.source_files = "Sources/RDEpubReaderView/**/*.{swift}"
|
||||||
|
s.resource_bundles = {
|
||||||
|
"RDEpubReaderViewAssets" => ["Sources/RDEpubReaderView/EPUBCore/Resources/**/*"]
|
||||||
|
}
|
||||||
|
s.dependency "ZIPFoundation", "~> 0.9"
|
||||||
|
s.dependency "DTCoreText", "~> 1.6"
|
||||||
|
s.requires_arc = true
|
||||||
|
end
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
Pod::Spec.new do |s|
|
|
||||||
s.name = "RDReaderView"
|
|
||||||
s.version = "0.0.1"
|
|
||||||
s.summary = "A reader view for novel"
|
|
||||||
s.platform = :ios, "15.6"
|
|
||||||
s.swift_versions = ["5.10"]
|
|
||||||
s.homepage = "https://github.com/namesubai/RDReaderView.git"
|
|
||||||
s.author = { "subai" => "804663401@qq.com" }
|
|
||||||
s.source = { :git => "https://github.com/namesubai/RDReaderView.git", :tag => "#{s.version}"}
|
|
||||||
s.license = "MIT"
|
|
||||||
s.source_files = 'Sources/RDReaderView/**/*.{swift}'
|
|
||||||
s.resource_bundles = {
|
|
||||||
'RDReaderViewAssets' => ['Sources/RDReaderView/EPUBCore/Resources/**/*']
|
|
||||||
}
|
|
||||||
s.dependency 'ZIPFoundation', '~> 0.9'
|
|
||||||
s.dependency 'DTCoreText', '~> 1.6'
|
|
||||||
s.requires_arc = true
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -3,14 +3,15 @@ platform :ios, '15.6'
|
|||||||
target 'ReadViewDemo' do
|
target 'ReadViewDemo' do
|
||||||
# Comment the next line if you don't want to use dynamic frameworks
|
# Comment the next line if you don't want to use dynamic frameworks
|
||||||
use_frameworks!
|
use_frameworks!
|
||||||
pod 'RDReaderView', :path => '..'
|
pod 'RDEpubReaderView', :path => '../Sources/RDEpubReaderView'
|
||||||
|
pod 'RDPDFReaderView', :path => '../Sources/RDPDFReaderView'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
post_install do |installer|
|
post_install do |installer|
|
||||||
apply_settings = lambda do |config|
|
apply_settings = lambda do |config|
|
||||||
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
|
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
|
||||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.6'
|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pods project (Pods.xcodeproj)
|
# Pods project (Pods.xcodeproj)
|
||||||
|
|||||||
@@ -16,30 +16,40 @@ PODS:
|
|||||||
- DTFoundation/Core
|
- DTFoundation/Core
|
||||||
- DTFoundation/UIKit (1.7.19):
|
- DTFoundation/UIKit (1.7.19):
|
||||||
- DTFoundation/Core
|
- DTFoundation/Core
|
||||||
- RDReaderView (0.0.1):
|
- RDEpubReaderView (0.0.2):
|
||||||
- DTCoreText (~> 1.6)
|
- DTCoreText (~> 1.6)
|
||||||
|
- SnapKit (~> 5.7)
|
||||||
- ZIPFoundation (~> 0.9)
|
- ZIPFoundation (~> 0.9)
|
||||||
|
- RDPDFReaderView (0.0.1):
|
||||||
|
- SnapKit (~> 5.7)
|
||||||
|
- SnapKit (5.7.1)
|
||||||
- ZIPFoundation (0.9.20)
|
- ZIPFoundation (0.9.20)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- RDReaderView (from `..`)
|
- RDEpubReaderView (from `../Sources/RDEpubReaderView`)
|
||||||
|
- RDPDFReaderView (from `../Sources/RDPDFReaderView`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
trunk:
|
trunk:
|
||||||
- DTCoreText
|
- DTCoreText
|
||||||
- DTFoundation
|
- DTFoundation
|
||||||
|
- SnapKit
|
||||||
- ZIPFoundation
|
- ZIPFoundation
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
RDReaderView:
|
RDEpubReaderView:
|
||||||
:path: ".."
|
:path: "../Sources/RDEpubReaderView"
|
||||||
|
RDPDFReaderView:
|
||||||
|
:path: "../Sources/RDPDFReaderView"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
DTCoreText: 11b7fe2104f476f82e75a4e3dbdde74d7186cecb
|
DTCoreText: 11b7fe2104f476f82e75a4e3dbdde74d7186cecb
|
||||||
DTFoundation: 76b624967cf5bcaae6bb057d622c536c36ef36d0
|
DTFoundation: 76b624967cf5bcaae6bb057d622c536c36ef36d0
|
||||||
RDReaderView: 2e0eeeff4bcfe8bbc09642344d326440af280ed5
|
RDEpubReaderView: 5a09a7856f04b6f2f8610aa6fd965d35cadb8e17
|
||||||
|
RDPDFReaderView: f7c2d0ea7c129aa4ab15ae7f9daad2974573d749
|
||||||
|
SnapKit: d612e99e678a2d3b95bf60b0705ed0a35c03484a
|
||||||
ZIPFoundation: dfd3d681c4053ff7e2f7350bc4e53b5dba3f5351
|
ZIPFoundation: dfd3d681c4053ff7e2f7350bc4e53b5dba3f5351
|
||||||
|
|
||||||
PODFILE CHECKSUM: 775f5c8c488024e24d494aad6331e9fef8f9e2e5
|
PODFILE CHECKSUM: c39db27dbc9c6a96a33f22e78ce1b22dcd48d75f
|
||||||
|
|
||||||
COCOAPODS: 1.16.2
|
COCOAPODS: 1.16.2
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "RDEpubReaderView",
|
||||||
|
"module_name": "RDEpubReaderView",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"summary": "A reader view for EPUB, TXT, MOBI, and CBZ books",
|
||||||
|
"platforms": {
|
||||||
|
"ios": "15.0"
|
||||||
|
},
|
||||||
|
"swift_versions": [
|
||||||
|
"5.10"
|
||||||
|
],
|
||||||
|
"homepage": "http://192.168.21.200:8418/4v5u09Z5a4Yuc/ReadViewSDK.git",
|
||||||
|
"authors": {
|
||||||
|
"shenlei": "shenlei@touchread.com"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"git": "http://192.168.21.200:8418/4v5u09Z5a4Yuc/ReadViewSDK.git",
|
||||||
|
"tag": "0.0.2"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"source_files": "**/*.swift",
|
||||||
|
"resource_bundles": {
|
||||||
|
"RDEpubReaderViewAssets": [
|
||||||
|
"EPUBCore/Resources/**/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ZIPFoundation": [
|
||||||
|
"~> 0.9"
|
||||||
|
],
|
||||||
|
"DTCoreText": [
|
||||||
|
"~> 1.6"
|
||||||
|
],
|
||||||
|
"SnapKit": [
|
||||||
|
"~> 5.7"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"requires_arc": true,
|
||||||
|
"swift_version": "5.10"
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "RDPDFReaderView",
|
||||||
|
"module_name": "RDPDFReaderView",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"summary": "UIKit PDF reader supporting host images and direct PDFKit parsing",
|
||||||
|
"platforms": {
|
||||||
|
"ios": "15.0"
|
||||||
|
},
|
||||||
|
"swift_versions": [
|
||||||
|
"5.10"
|
||||||
|
],
|
||||||
|
"homepage": "https://example.invalid/RDPDFReaderView",
|
||||||
|
"authors": {
|
||||||
|
"readoor": "ios@touchread.com"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"path": "."
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"source_files": "{Sources,ReaderView}/**/*.swift",
|
||||||
|
"dependencies": {
|
||||||
|
"SnapKit": [
|
||||||
|
"~> 5.7"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"Vision",
|
||||||
|
"CoreImage",
|
||||||
|
"PDFKit"
|
||||||
|
],
|
||||||
|
"requires_arc": true,
|
||||||
|
"swift_version": "5.10"
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "RDReaderView",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"summary": "A reader view for novel",
|
|
||||||
"platforms": {
|
|
||||||
"ios": "15.6"
|
|
||||||
},
|
|
||||||
"swift_versions": [
|
|
||||||
"5.10"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/namesubai/RDReaderView.git",
|
|
||||||
"authors": {
|
|
||||||
"subai": "804663401@qq.com"
|
|
||||||
},
|
|
||||||
"source": {
|
|
||||||
"git": "https://github.com/namesubai/RDReaderView.git",
|
|
||||||
"tag": "0.0.1"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"source_files": "Sources/RDReaderView/**/*.{swift}",
|
|
||||||
"resource_bundles": {
|
|
||||||
"RDReaderViewAssets": [
|
|
||||||
"Sources/RDReaderView/EPUBCore/Resources/**/*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"ZIPFoundation": [
|
|
||||||
"~> 0.9"
|
|
||||||
],
|
|
||||||
"DTCoreText": [
|
|
||||||
"~> 1.6"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"requires_arc": true,
|
|
||||||
"swift_version": "5.10"
|
|
||||||
}
|
|
||||||
Generated
+16
-6
@@ -16,30 +16,40 @@ PODS:
|
|||||||
- DTFoundation/Core
|
- DTFoundation/Core
|
||||||
- DTFoundation/UIKit (1.7.19):
|
- DTFoundation/UIKit (1.7.19):
|
||||||
- DTFoundation/Core
|
- DTFoundation/Core
|
||||||
- RDReaderView (0.0.1):
|
- RDEpubReaderView (0.0.2):
|
||||||
- DTCoreText (~> 1.6)
|
- DTCoreText (~> 1.6)
|
||||||
|
- SnapKit (~> 5.7)
|
||||||
- ZIPFoundation (~> 0.9)
|
- ZIPFoundation (~> 0.9)
|
||||||
|
- RDPDFReaderView (0.0.1):
|
||||||
|
- SnapKit (~> 5.7)
|
||||||
|
- SnapKit (5.7.1)
|
||||||
- ZIPFoundation (0.9.20)
|
- ZIPFoundation (0.9.20)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- RDReaderView (from `..`)
|
- RDEpubReaderView (from `../Sources/RDEpubReaderView`)
|
||||||
|
- RDPDFReaderView (from `../Sources/RDPDFReaderView`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
trunk:
|
trunk:
|
||||||
- DTCoreText
|
- DTCoreText
|
||||||
- DTFoundation
|
- DTFoundation
|
||||||
|
- SnapKit
|
||||||
- ZIPFoundation
|
- ZIPFoundation
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
RDReaderView:
|
RDEpubReaderView:
|
||||||
:path: ".."
|
:path: "../Sources/RDEpubReaderView"
|
||||||
|
RDPDFReaderView:
|
||||||
|
:path: "../Sources/RDPDFReaderView"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
DTCoreText: 11b7fe2104f476f82e75a4e3dbdde74d7186cecb
|
DTCoreText: 11b7fe2104f476f82e75a4e3dbdde74d7186cecb
|
||||||
DTFoundation: 76b624967cf5bcaae6bb057d622c536c36ef36d0
|
DTFoundation: 76b624967cf5bcaae6bb057d622c536c36ef36d0
|
||||||
RDReaderView: 2e0eeeff4bcfe8bbc09642344d326440af280ed5
|
RDEpubReaderView: 5a09a7856f04b6f2f8610aa6fd965d35cadb8e17
|
||||||
|
RDPDFReaderView: f7c2d0ea7c129aa4ab15ae7f9daad2974573d749
|
||||||
|
SnapKit: d612e99e678a2d3b95bf60b0705ed0a35c03484a
|
||||||
ZIPFoundation: dfd3d681c4053ff7e2f7350bc4e53b5dba3f5351
|
ZIPFoundation: dfd3d681c4053ff7e2f7350bc4e53b5dba3f5351
|
||||||
|
|
||||||
PODFILE CHECKSUM: 775f5c8c488024e24d494aad6331e9fef8f9e2e5
|
PODFILE CHECKSUM: c39db27dbc9c6a96a33f22e78ce1b22dcd48d75f
|
||||||
|
|
||||||
COCOAPODS: 1.16.2
|
COCOAPODS: 1.16.2
|
||||||
|
|||||||
+3192
-2304
File diff suppressed because it is too large
Load Diff
Generated
+19
@@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
Generated
+155
@@ -0,0 +1,155 @@
|
|||||||
|
<img src="https://snapkit.github.io/SnapKit/images/banner.jpg" alt="" />
|
||||||
|
|
||||||
|
SnapKit is a DSL to make Auto Layout easy on both iOS and OS X.
|
||||||
|
|
||||||
|
[](https://travis-ci.org/SnapKit/SnapKit)
|
||||||
|
[](https://github.com/SnapKit/SnapKit)
|
||||||
|
[](https://cocoapods.org/pods/SnapKit)
|
||||||
|
[](https://github.com/Carthage/Carthage)
|
||||||
|
|
||||||
|
#### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️
|
||||||
|
#### ⚠️ **To use with Swift 5.x please ensure you are using >= 5.0.0** ⚠️
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
- [Requirements](#requirements)
|
||||||
|
- [Migration Guides](#migration-guides)
|
||||||
|
- [Communication](#communication)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Credits](#credits)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- iOS 12.0+ / Mac OS X 10.13+ / tvOS 10.0+
|
||||||
|
- Xcode 10.0+
|
||||||
|
- Swift 4.0+
|
||||||
|
|
||||||
|
## Migration Guides
|
||||||
|
|
||||||
|
- [SnapKit 3.0 Migration Guide](Documentation/SnapKit%203.0%20Migration%20Guide.md)
|
||||||
|
|
||||||
|
## Communication
|
||||||
|
|
||||||
|
- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/snapkit). (Tag 'snapkit')
|
||||||
|
- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/snapkit).
|
||||||
|
- If you **found a bug**, open an issue.
|
||||||
|
- If you **have a feature request**, open an issue.
|
||||||
|
- If you **want to contribute**, submit a pull request.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### CocoaPods
|
||||||
|
|
||||||
|
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ gem install cocoapods
|
||||||
|
```
|
||||||
|
|
||||||
|
> CocoaPods 1.1.0+ is required to build SnapKit 4.0.0+.
|
||||||
|
|
||||||
|
To integrate SnapKit into your Xcode project using CocoaPods, specify it in your `Podfile`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
source 'https://github.com/CocoaPods/Specs.git'
|
||||||
|
platform :ios, '10.0'
|
||||||
|
use_frameworks!
|
||||||
|
|
||||||
|
target '<Your Target Name>' do
|
||||||
|
pod 'SnapKit', '~> 5.7.0'
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ pod install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Carthage
|
||||||
|
|
||||||
|
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
|
||||||
|
|
||||||
|
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ brew update
|
||||||
|
$ brew install carthage
|
||||||
|
```
|
||||||
|
|
||||||
|
To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`:
|
||||||
|
|
||||||
|
```ogdl
|
||||||
|
github "SnapKit/SnapKit" ~> 5.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project.
|
||||||
|
|
||||||
|
### Swift Package Manager
|
||||||
|
|
||||||
|
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
|
||||||
|
|
||||||
|
> Xcode 11+ is required to build SnapKit using Swift Package Manager.
|
||||||
|
|
||||||
|
To integrate SnapKit into your Xcode project using Swift Package Manager, add it to the dependencies value of your `Package.swift`:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
dependencies: [
|
||||||
|
.package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "5.0.1"))
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manually
|
||||||
|
|
||||||
|
If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Quick Start
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import SnapKit
|
||||||
|
|
||||||
|
class MyViewController: UIViewController {
|
||||||
|
|
||||||
|
lazy var box = UIView()
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
self.view.addSubview(box)
|
||||||
|
box.backgroundColor = .green
|
||||||
|
box.snp.makeConstraints { (make) -> Void in
|
||||||
|
make.width.height.equalTo(50)
|
||||||
|
make.center.equalTo(self.view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Playground
|
||||||
|
You can try SnapKit in Playground.
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
> To try SnapKit in playground, open `SnapKit.xcworkspace` and build SnapKit.framework for any simulator first.
|
||||||
|
|
||||||
|
### Resources
|
||||||
|
|
||||||
|
- [Documentation](https://snapkit.github.io/SnapKit/docs/)
|
||||||
|
- [F.A.Q.](https://snapkit.github.io/SnapKit/faq/)
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
- Robert Payne ([@robertjpayne](https://twitter.com/robertjpayne))
|
||||||
|
- Many other contributors
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
SnapKit is released under the MIT license. See LICENSE for details.
|
||||||
+341
@@ -0,0 +1,341 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public final class Constraint {
|
||||||
|
|
||||||
|
internal let sourceLocation: (String, UInt)
|
||||||
|
internal let label: String?
|
||||||
|
|
||||||
|
private let from: ConstraintItem
|
||||||
|
private let to: ConstraintItem
|
||||||
|
private let relation: ConstraintRelation
|
||||||
|
private let multiplier: ConstraintMultiplierTarget
|
||||||
|
private var constant: ConstraintConstantTarget {
|
||||||
|
didSet {
|
||||||
|
self.updateConstantAndPriorityIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private var priority: ConstraintPriorityTarget {
|
||||||
|
didSet {
|
||||||
|
self.updateConstantAndPriorityIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var layoutConstraints: [LayoutConstraint]
|
||||||
|
|
||||||
|
public var isActive: Bool {
|
||||||
|
set {
|
||||||
|
if newValue {
|
||||||
|
activate()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deactivate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
for layoutConstraint in self.layoutConstraints {
|
||||||
|
if layoutConstraint.isActive {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Initialization
|
||||||
|
|
||||||
|
internal init(from: ConstraintItem,
|
||||||
|
to: ConstraintItem,
|
||||||
|
relation: ConstraintRelation,
|
||||||
|
sourceLocation: (String, UInt),
|
||||||
|
label: String?,
|
||||||
|
multiplier: ConstraintMultiplierTarget,
|
||||||
|
constant: ConstraintConstantTarget,
|
||||||
|
priority: ConstraintPriorityTarget) {
|
||||||
|
self.from = from
|
||||||
|
self.to = to
|
||||||
|
self.relation = relation
|
||||||
|
self.sourceLocation = sourceLocation
|
||||||
|
self.label = label
|
||||||
|
self.multiplier = multiplier
|
||||||
|
self.constant = constant
|
||||||
|
self.priority = priority
|
||||||
|
self.layoutConstraints = []
|
||||||
|
|
||||||
|
// get attributes
|
||||||
|
let layoutFromAttributes = self.from.attributes.layoutAttributes
|
||||||
|
let layoutToAttributes = self.to.attributes.layoutAttributes
|
||||||
|
|
||||||
|
// get layout from
|
||||||
|
let layoutFrom = self.from.layoutConstraintItem!
|
||||||
|
|
||||||
|
// get relation
|
||||||
|
let layoutRelation = self.relation.layoutRelation
|
||||||
|
|
||||||
|
for layoutFromAttribute in layoutFromAttributes {
|
||||||
|
// get layout to attribute
|
||||||
|
let layoutToAttribute: LayoutAttribute
|
||||||
|
#if canImport(UIKit)
|
||||||
|
if layoutToAttributes.count > 0 {
|
||||||
|
if self.from.attributes == .edges && self.to.attributes == .margins {
|
||||||
|
switch layoutFromAttribute {
|
||||||
|
case .left:
|
||||||
|
layoutToAttribute = .leftMargin
|
||||||
|
case .right:
|
||||||
|
layoutToAttribute = .rightMargin
|
||||||
|
case .top:
|
||||||
|
layoutToAttribute = .topMargin
|
||||||
|
case .bottom:
|
||||||
|
layoutToAttribute = .bottomMargin
|
||||||
|
default:
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
} else if self.from.attributes == .margins && self.to.attributes == .edges {
|
||||||
|
switch layoutFromAttribute {
|
||||||
|
case .leftMargin:
|
||||||
|
layoutToAttribute = .left
|
||||||
|
case .rightMargin:
|
||||||
|
layoutToAttribute = .right
|
||||||
|
case .topMargin:
|
||||||
|
layoutToAttribute = .top
|
||||||
|
case .bottomMargin:
|
||||||
|
layoutToAttribute = .bottom
|
||||||
|
default:
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
} else if self.from.attributes == .directionalEdges && self.to.attributes == .directionalMargins {
|
||||||
|
switch layoutFromAttribute {
|
||||||
|
case .leading:
|
||||||
|
layoutToAttribute = .leadingMargin
|
||||||
|
case .trailing:
|
||||||
|
layoutToAttribute = .trailingMargin
|
||||||
|
case .top:
|
||||||
|
layoutToAttribute = .topMargin
|
||||||
|
case .bottom:
|
||||||
|
layoutToAttribute = .bottomMargin
|
||||||
|
default:
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
} else if self.from.attributes == .directionalMargins && self.to.attributes == .directionalEdges {
|
||||||
|
switch layoutFromAttribute {
|
||||||
|
case .leadingMargin:
|
||||||
|
layoutToAttribute = .leading
|
||||||
|
case .trailingMargin:
|
||||||
|
layoutToAttribute = .trailing
|
||||||
|
case .topMargin:
|
||||||
|
layoutToAttribute = .top
|
||||||
|
case .bottomMargin:
|
||||||
|
layoutToAttribute = .bottom
|
||||||
|
default:
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
} else if self.from.attributes == self.to.attributes {
|
||||||
|
layoutToAttribute = layoutFromAttribute
|
||||||
|
} else {
|
||||||
|
layoutToAttribute = layoutToAttributes[0]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if self.to.target == nil && (layoutFromAttribute == .centerX || layoutFromAttribute == .centerY) {
|
||||||
|
layoutToAttribute = layoutFromAttribute == .centerX ? .left : .top
|
||||||
|
} else {
|
||||||
|
layoutToAttribute = layoutFromAttribute
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if self.from.attributes == self.to.attributes {
|
||||||
|
layoutToAttribute = layoutFromAttribute
|
||||||
|
} else if layoutToAttributes.count > 0 {
|
||||||
|
layoutToAttribute = layoutToAttributes[0]
|
||||||
|
} else {
|
||||||
|
layoutToAttribute = layoutFromAttribute
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// get layout constant
|
||||||
|
let layoutConstant: CGFloat = self.constant.constraintConstantTargetValueFor(layoutAttribute: layoutToAttribute)
|
||||||
|
|
||||||
|
// get layout to
|
||||||
|
var layoutTo: AnyObject? = self.to.target
|
||||||
|
|
||||||
|
// use superview if possible
|
||||||
|
if layoutTo == nil && layoutToAttribute != .width && layoutToAttribute != .height {
|
||||||
|
layoutTo = layoutFrom.superview
|
||||||
|
}
|
||||||
|
|
||||||
|
// create layout constraint
|
||||||
|
let layoutConstraint = LayoutConstraint(
|
||||||
|
item: layoutFrom,
|
||||||
|
attribute: layoutFromAttribute,
|
||||||
|
relatedBy: layoutRelation,
|
||||||
|
toItem: layoutTo,
|
||||||
|
attribute: layoutToAttribute,
|
||||||
|
multiplier: self.multiplier.constraintMultiplierTargetValue,
|
||||||
|
constant: layoutConstant
|
||||||
|
)
|
||||||
|
|
||||||
|
// set label
|
||||||
|
layoutConstraint.label = self.label
|
||||||
|
|
||||||
|
// set priority
|
||||||
|
layoutConstraint.priority = LayoutPriority(rawValue: self.priority.constraintPriorityTargetValue)
|
||||||
|
|
||||||
|
// set constraint
|
||||||
|
layoutConstraint.constraint = self
|
||||||
|
|
||||||
|
// append
|
||||||
|
self.layoutConstraints.append(layoutConstraint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Public
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"activate()")
|
||||||
|
public func install() {
|
||||||
|
self.activate()
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"deactivate()")
|
||||||
|
public func uninstall() {
|
||||||
|
self.deactivate()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func activate() {
|
||||||
|
self.activateIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func deactivate() {
|
||||||
|
self.deactivateIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func update(offset: ConstraintOffsetTarget) -> Constraint {
|
||||||
|
self.constant = offset.constraintOffsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func update(inset: ConstraintInsetTarget) -> Constraint {
|
||||||
|
self.constant = inset.constraintInsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@discardableResult
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
public func update(inset: ConstraintDirectionalInsetTarget) -> Constraint {
|
||||||
|
self.constant = inset.constraintDirectionalInsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func update(priority: ConstraintPriorityTarget) -> Constraint {
|
||||||
|
self.priority = priority.constraintPriorityTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func update(priority: ConstraintPriority) -> Constraint {
|
||||||
|
self.priority = priority.value
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"update(offset:)")
|
||||||
|
public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"update(inset:)")
|
||||||
|
public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"update(priority:)")
|
||||||
|
public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) }
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
|
||||||
|
public func updatePriorityRequired() -> Void {}
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
|
||||||
|
public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") }
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
|
||||||
|
public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") }
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.")
|
||||||
|
public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") }
|
||||||
|
|
||||||
|
// MARK: Internal
|
||||||
|
|
||||||
|
internal func updateConstantAndPriorityIfNeeded() {
|
||||||
|
for layoutConstraint in self.layoutConstraints {
|
||||||
|
let attribute = (layoutConstraint.secondAttribute == .notAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute
|
||||||
|
layoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: attribute)
|
||||||
|
|
||||||
|
let requiredPriority = ConstraintPriority.required.value
|
||||||
|
if (layoutConstraint.priority.rawValue < requiredPriority), (self.priority.constraintPriorityTargetValue != requiredPriority) {
|
||||||
|
layoutConstraint.priority = LayoutPriority(rawValue: self.priority.constraintPriorityTargetValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func activateIfNeeded(updatingExisting: Bool = false) {
|
||||||
|
guard let item = self.from.layoutConstraintItem else {
|
||||||
|
print("WARNING: SnapKit failed to get from item from constraint. Activate will be a no-op.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let layoutConstraints = self.layoutConstraints
|
||||||
|
|
||||||
|
if updatingExisting {
|
||||||
|
var existingLayoutConstraints: [LayoutConstraint] = []
|
||||||
|
for constraint in item.constraints {
|
||||||
|
existingLayoutConstraints += constraint.layoutConstraints
|
||||||
|
}
|
||||||
|
|
||||||
|
for layoutConstraint in layoutConstraints {
|
||||||
|
let existingLayoutConstraint = existingLayoutConstraints.first { $0 == layoutConstraint }
|
||||||
|
guard let updateLayoutConstraint = existingLayoutConstraint else {
|
||||||
|
fatalError("Updated constraint could not find existing matching constraint to update: \(layoutConstraint)")
|
||||||
|
}
|
||||||
|
|
||||||
|
let updateLayoutAttribute = (updateLayoutConstraint.secondAttribute == .notAnAttribute) ? updateLayoutConstraint.firstAttribute : updateLayoutConstraint.secondAttribute
|
||||||
|
updateLayoutConstraint.constant = self.constant.constraintConstantTargetValueFor(layoutAttribute: updateLayoutAttribute)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NSLayoutConstraint.activate(layoutConstraints)
|
||||||
|
item.add(constraints: [self])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func deactivateIfNeeded() {
|
||||||
|
guard let item = self.from.layoutConstraintItem else {
|
||||||
|
print("WARNING: SnapKit failed to get from item from constraint. Deactivate will be a no-op.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let layoutConstraints = self.layoutConstraints
|
||||||
|
NSLayoutConstraint.deactivate(layoutConstraints)
|
||||||
|
item.remove(constraints: [self])
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral {
|
||||||
|
|
||||||
|
typealias IntegerLiteralType = UInt
|
||||||
|
|
||||||
|
internal init(rawValue: UInt) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
internal init(_ rawValue: UInt) {
|
||||||
|
self.init(rawValue: rawValue)
|
||||||
|
}
|
||||||
|
internal init(nilLiteral: ()) {
|
||||||
|
self.rawValue = 0
|
||||||
|
}
|
||||||
|
internal init(integerLiteral rawValue: IntegerLiteralType) {
|
||||||
|
self.init(rawValue: rawValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal private(set) var rawValue: UInt
|
||||||
|
internal static var allZeros: ConstraintAttributes { return 0 }
|
||||||
|
internal static func convertFromNilLiteral() -> ConstraintAttributes { return 0 }
|
||||||
|
internal var boolValue: Bool { return self.rawValue != 0 }
|
||||||
|
|
||||||
|
internal func toRaw() -> UInt { return self.rawValue }
|
||||||
|
internal static func fromRaw(_ raw: UInt) -> ConstraintAttributes? { return self.init(raw) }
|
||||||
|
internal static func fromMask(_ raw: UInt) -> ConstraintAttributes { return self.init(raw) }
|
||||||
|
|
||||||
|
// normal
|
||||||
|
|
||||||
|
internal static let none: ConstraintAttributes = 0
|
||||||
|
internal static let left: ConstraintAttributes = ConstraintAttributes(UInt(1) << 0)
|
||||||
|
internal static let top: ConstraintAttributes = ConstraintAttributes(UInt(1) << 1)
|
||||||
|
internal static let right: ConstraintAttributes = ConstraintAttributes(UInt(1) << 2)
|
||||||
|
internal static let bottom: ConstraintAttributes = ConstraintAttributes(UInt(1) << 3)
|
||||||
|
internal static let leading: ConstraintAttributes = ConstraintAttributes(UInt(1) << 4)
|
||||||
|
internal static let trailing: ConstraintAttributes = ConstraintAttributes(UInt(1) << 5)
|
||||||
|
internal static let width: ConstraintAttributes = ConstraintAttributes(UInt(1) << 6)
|
||||||
|
internal static let height: ConstraintAttributes = ConstraintAttributes(UInt(1) << 7)
|
||||||
|
internal static let centerX: ConstraintAttributes = ConstraintAttributes(UInt(1) << 8)
|
||||||
|
internal static let centerY: ConstraintAttributes = ConstraintAttributes(UInt(1) << 9)
|
||||||
|
internal static let lastBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 10)
|
||||||
|
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
internal static let firstBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 11)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let leftMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 12)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let rightMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 13)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let topMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 14)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let bottomMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 15)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let leadingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 16)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let trailingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 17)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let centerXWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 18)
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let centerYWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 19)
|
||||||
|
|
||||||
|
// aggregates
|
||||||
|
|
||||||
|
internal static let edges: ConstraintAttributes = [.horizontalEdges, .verticalEdges]
|
||||||
|
internal static let horizontalEdges: ConstraintAttributes = [.left, .right]
|
||||||
|
internal static let verticalEdges: ConstraintAttributes = [.top, .bottom]
|
||||||
|
internal static let directionalEdges: ConstraintAttributes = [.directionalHorizontalEdges, .directionalVerticalEdges]
|
||||||
|
internal static let directionalHorizontalEdges: ConstraintAttributes = [.leading, .trailing]
|
||||||
|
internal static let directionalVerticalEdges: ConstraintAttributes = [.top, .bottom]
|
||||||
|
internal static let size: ConstraintAttributes = [.width, .height]
|
||||||
|
internal static let center: ConstraintAttributes = [.centerX, .centerY]
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let margins: ConstraintAttributes = [.leftMargin, .topMargin, .rightMargin, .bottomMargin]
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let directionalMargins: ConstraintAttributes = [.leadingMargin, .topMargin, .trailingMargin, .bottomMargin]
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
internal static let centerWithinMargins: ConstraintAttributes = [.centerXWithinMargins, .centerYWithinMargins]
|
||||||
|
|
||||||
|
internal var layoutAttributes:[LayoutAttribute] {
|
||||||
|
var attrs = [LayoutAttribute]()
|
||||||
|
if (self.contains(ConstraintAttributes.left)) {
|
||||||
|
attrs.append(.left)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.top)) {
|
||||||
|
attrs.append(.top)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.right)) {
|
||||||
|
attrs.append(.right)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.bottom)) {
|
||||||
|
attrs.append(.bottom)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.leading)) {
|
||||||
|
attrs.append(.leading)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.trailing)) {
|
||||||
|
attrs.append(.trailing)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.width)) {
|
||||||
|
attrs.append(.width)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.height)) {
|
||||||
|
attrs.append(.height)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.centerX)) {
|
||||||
|
attrs.append(.centerX)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.centerY)) {
|
||||||
|
attrs.append(.centerY)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.lastBaseline)) {
|
||||||
|
attrs.append(.lastBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
if (self.contains(ConstraintAttributes.firstBaseline)) {
|
||||||
|
attrs.append(.firstBaseline)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.leftMargin)) {
|
||||||
|
attrs.append(.leftMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.rightMargin)) {
|
||||||
|
attrs.append(.rightMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.topMargin)) {
|
||||||
|
attrs.append(.topMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.bottomMargin)) {
|
||||||
|
attrs.append(.bottomMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.leadingMargin)) {
|
||||||
|
attrs.append(.leadingMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.trailingMargin)) {
|
||||||
|
attrs.append(.trailingMargin)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.centerXWithinMargins)) {
|
||||||
|
attrs.append(.centerXWithinMargins)
|
||||||
|
}
|
||||||
|
if (self.contains(ConstraintAttributes.centerYWithinMargins)) {
|
||||||
|
attrs.append(.centerYWithinMargins)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return attrs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func + (left: ConstraintAttributes, right: ConstraintAttributes) -> ConstraintAttributes {
|
||||||
|
return left.union(right)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func +=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||||
|
left.formUnion(right)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func -=(left: inout ConstraintAttributes, right: ConstraintAttributes) {
|
||||||
|
left.subtract(right)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool {
|
||||||
|
return left.rawValue == right.rawValue
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
public typealias ConstraintInterfaceLayoutDirection = UIUserInterfaceLayoutDirection
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
public typealias ConstraintInterfaceLayoutDirection = NSUserInterfaceLayoutDirection
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public struct ConstraintConfig {
|
||||||
|
|
||||||
|
public static var interfaceLayoutDirection: ConstraintInterfaceLayoutDirection = .leftToRight
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGPoint: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGSize: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintInsets: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
extension ConstraintDirectionalInsets: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extension ConstraintConstantTarget {
|
||||||
|
|
||||||
|
internal func constraintConstantTargetValueFor(layoutAttribute: LayoutAttribute) -> CGFloat {
|
||||||
|
if let value = self as? CGFloat {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? Float {
|
||||||
|
return CGFloat(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? Double {
|
||||||
|
return CGFloat(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? Int {
|
||||||
|
return CGFloat(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? UInt {
|
||||||
|
return CGFloat(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? CGSize {
|
||||||
|
if layoutAttribute == .width {
|
||||||
|
return value.width
|
||||||
|
} else if layoutAttribute == .height {
|
||||||
|
return value.height
|
||||||
|
} else {
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? CGPoint {
|
||||||
|
#if canImport(UIKit)
|
||||||
|
switch layoutAttribute {
|
||||||
|
case .left, .right, .leading, .trailing, .centerX, .leftMargin, .rightMargin, .leadingMargin, .trailingMargin, .centerXWithinMargins:
|
||||||
|
return value.x
|
||||||
|
case .top, .bottom, .centerY, .topMargin, .bottomMargin, .centerYWithinMargins, .lastBaseline, .firstBaseline:
|
||||||
|
return value.y
|
||||||
|
case .width, .height, .notAnAttribute:
|
||||||
|
return 0.0
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default:
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
switch layoutAttribute {
|
||||||
|
case .left, .right, .leading, .trailing, .centerX:
|
||||||
|
return value.x
|
||||||
|
case .top, .bottom, .centerY, .lastBaseline, .firstBaseline:
|
||||||
|
return value.y
|
||||||
|
case .width, .height, .notAnAttribute:
|
||||||
|
return 0.0
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default:
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if let value = self as? ConstraintInsets {
|
||||||
|
#if canImport(UIKit)
|
||||||
|
switch layoutAttribute {
|
||||||
|
case .left, .leftMargin:
|
||||||
|
return value.left
|
||||||
|
case .top, .topMargin, .firstBaseline:
|
||||||
|
return value.top
|
||||||
|
case .right, .rightMargin:
|
||||||
|
return -value.right
|
||||||
|
case .bottom, .bottomMargin, .lastBaseline:
|
||||||
|
return -value.bottom
|
||||||
|
case .leading, .leadingMargin:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right
|
||||||
|
case .trailing, .trailingMargin:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left
|
||||||
|
case .centerX, .centerXWithinMargins:
|
||||||
|
return (value.left - value.right) / 2
|
||||||
|
case .centerY, .centerYWithinMargins:
|
||||||
|
return (value.top - value.bottom) / 2
|
||||||
|
case .width:
|
||||||
|
return -(value.left + value.right)
|
||||||
|
case .height:
|
||||||
|
return -(value.top + value.bottom)
|
||||||
|
case .notAnAttribute:
|
||||||
|
return 0.0
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default:
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
switch layoutAttribute {
|
||||||
|
case .left:
|
||||||
|
return value.left
|
||||||
|
case .top, .firstBaseline:
|
||||||
|
return value.top
|
||||||
|
case .right:
|
||||||
|
return -value.right
|
||||||
|
case .bottom, .lastBaseline:
|
||||||
|
return -value.bottom
|
||||||
|
case .leading:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right
|
||||||
|
case .trailing:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left
|
||||||
|
case .centerX:
|
||||||
|
return (value.left - value.right) / 2
|
||||||
|
case .centerY:
|
||||||
|
return (value.top - value.bottom) / 2
|
||||||
|
case .width:
|
||||||
|
return -(value.left + value.right)
|
||||||
|
case .height:
|
||||||
|
return -(value.top + value.bottom)
|
||||||
|
case .notAnAttribute:
|
||||||
|
return 0.0
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default:
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
if #available(iOS 11.0, tvOS 11.0, *), let value = self as? ConstraintDirectionalInsets {
|
||||||
|
switch layoutAttribute {
|
||||||
|
case .left, .leftMargin:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.leading : value.trailing
|
||||||
|
case .top, .topMargin, .firstBaseline:
|
||||||
|
return value.top
|
||||||
|
case .right, .rightMargin:
|
||||||
|
return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.trailing : -value.leading
|
||||||
|
case .bottom, .bottomMargin, .lastBaseline:
|
||||||
|
return -value.bottom
|
||||||
|
case .leading, .leadingMargin:
|
||||||
|
return value.leading
|
||||||
|
case .trailing, .trailingMargin:
|
||||||
|
return -value.trailing
|
||||||
|
case .centerX, .centerXWithinMargins:
|
||||||
|
return (value.leading - value.trailing) / 2
|
||||||
|
case .centerY, .centerYWithinMargins:
|
||||||
|
return (value.top - value.bottom) / 2
|
||||||
|
case .width:
|
||||||
|
return -(value.leading + value.trailing)
|
||||||
|
case .height:
|
||||||
|
return -(value.top + value.bottom)
|
||||||
|
case .notAnAttribute:
|
||||||
|
return 0.0
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default:
|
||||||
|
return 0.0
|
||||||
|
#else
|
||||||
|
default:
|
||||||
|
return 0.0
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+209
@@ -0,0 +1,209 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintDSL {
|
||||||
|
|
||||||
|
var target: AnyObject? { get }
|
||||||
|
|
||||||
|
func setLabel(_ value: String?)
|
||||||
|
func label() -> String?
|
||||||
|
|
||||||
|
}
|
||||||
|
extension ConstraintDSL {
|
||||||
|
|
||||||
|
public func setLabel(_ value: String?) {
|
||||||
|
objc_setAssociatedObject(self.target as Any, &labelKey, value, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||||
|
}
|
||||||
|
public func label() -> String? {
|
||||||
|
return objc_getAssociatedObject(self.target as Any, &labelKey) as? String
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private var labelKey: UInt8 = 0
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintBasicAttributesDSL : ConstraintDSL {
|
||||||
|
}
|
||||||
|
extension ConstraintBasicAttributesDSL {
|
||||||
|
|
||||||
|
// MARK: Basics
|
||||||
|
|
||||||
|
public var left: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.left)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var top: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var right: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.right)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var bottom: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var leading: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var trailing: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailing)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var width: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.width)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var height: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerX: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerX)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerY: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerY)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var edges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var directionalEdges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalEdges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var horizontalEdges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.horizontalEdges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var verticalEdges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.verticalEdges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var directionalHorizontalEdges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalHorizontalEdges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var directionalVerticalEdges: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalVerticalEdges)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var size: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var center: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.center)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol ConstraintAttributesDSL : ConstraintBasicAttributesDSL {
|
||||||
|
}
|
||||||
|
extension ConstraintAttributesDSL {
|
||||||
|
|
||||||
|
// MARK: Baselines
|
||||||
|
@available(*, deprecated, renamed:"lastBaseline")
|
||||||
|
public var baseline: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
public var lastBaseline: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
public var firstBaseline: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.firstBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Margins
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leftMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leftMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var topMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.topMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var rightMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.rightMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var bottomMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottomMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leadingMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.leadingMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var trailingMargin: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.trailingMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerXWithinMargins: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerXWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerYWithinMargins: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerYWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var margins: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var directionalMargins: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerWithinMargins: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class ConstraintDescription {
|
||||||
|
|
||||||
|
internal let item: LayoutConstraintItem
|
||||||
|
internal var attributes: ConstraintAttributes
|
||||||
|
internal var relation: ConstraintRelation? = nil
|
||||||
|
internal var sourceLocation: (String, UInt)? = nil
|
||||||
|
internal var label: String? = nil
|
||||||
|
internal var related: ConstraintItem? = nil
|
||||||
|
internal var multiplier: ConstraintMultiplierTarget = 1.0
|
||||||
|
internal var constant: ConstraintConstantTarget = 0.0
|
||||||
|
internal var priority: ConstraintPriorityTarget = 1000.0
|
||||||
|
internal lazy var constraint: Constraint? = {
|
||||||
|
guard let relation = self.relation,
|
||||||
|
let related = self.related,
|
||||||
|
let sourceLocation = self.sourceLocation else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
let from = ConstraintItem(target: self.item, attributes: self.attributes)
|
||||||
|
|
||||||
|
return Constraint(
|
||||||
|
from: from,
|
||||||
|
to: related,
|
||||||
|
relation: relation,
|
||||||
|
sourceLocation: sourceLocation,
|
||||||
|
label: self.label,
|
||||||
|
multiplier: self.multiplier,
|
||||||
|
constant: self.constant,
|
||||||
|
priority: self.priority
|
||||||
|
)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// MARK: Initialization
|
||||||
|
|
||||||
|
internal init(item: LayoutConstraintItem, attributes: ConstraintAttributes) {
|
||||||
|
self.item = item
|
||||||
|
self.attributes = attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
public protocol ConstraintDirectionalInsetTarget: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
extension ConstraintDirectionalInsets: ConstraintDirectionalInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintDirectionalInsetTarget {
|
||||||
|
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
internal var constraintDirectionalInsetTargetValue: ConstraintDirectionalInsets {
|
||||||
|
if let amount = self as? ConstraintDirectionalInsets {
|
||||||
|
return amount
|
||||||
|
} else {
|
||||||
|
return ConstraintDirectionalInsets(top: 0, leading: 0, bottom: 0, trailing: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
public typealias ConstraintDirectionalInsets = NSDirectionalEdgeInsets
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintInsetTarget: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintInsets: ConstraintInsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintInsetTarget {
|
||||||
|
|
||||||
|
internal var constraintInsetTargetValue: ConstraintInsets {
|
||||||
|
if let amount = self as? ConstraintInsets {
|
||||||
|
return amount
|
||||||
|
} else if let amount = self as? Float {
|
||||||
|
return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount))
|
||||||
|
} else if let amount = self as? Double {
|
||||||
|
return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount))
|
||||||
|
} else if let amount = self as? CGFloat {
|
||||||
|
return ConstraintInsets(top: amount, left: amount, bottom: amount, right: amount)
|
||||||
|
} else if let amount = self as? Int {
|
||||||
|
return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount))
|
||||||
|
} else if let amount = self as? UInt {
|
||||||
|
return ConstraintInsets(top: CGFloat(amount), left: CGFloat(amount), bottom: CGFloat(amount), right: CGFloat(amount))
|
||||||
|
} else {
|
||||||
|
return ConstraintInsets(top: 0, left: 0, bottom: 0, right: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
public typealias ConstraintInsets = UIEdgeInsets
|
||||||
|
#else
|
||||||
|
public typealias ConstraintInsets = NSEdgeInsets
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public final class ConstraintItem {
|
||||||
|
|
||||||
|
internal weak var target: AnyObject?
|
||||||
|
internal let attributes: ConstraintAttributes
|
||||||
|
|
||||||
|
internal init(target: AnyObject?, attributes: ConstraintAttributes) {
|
||||||
|
self.target = target
|
||||||
|
self.attributes = attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var layoutConstraintItem: LayoutConstraintItem? {
|
||||||
|
return self.target as? LayoutConstraintItem
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public func ==(lhs: ConstraintItem, rhs: ConstraintItem) -> Bool {
|
||||||
|
// pointer equality
|
||||||
|
guard lhs !== rhs else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// must both have valid targets and identical attributes
|
||||||
|
guard let target1 = lhs.target,
|
||||||
|
let target2 = rhs.target,
|
||||||
|
target1 === target2 && lhs.attributes == rhs.attributes else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
|
public extension ConstraintLayoutGuide {
|
||||||
|
|
||||||
|
var snp: ConstraintLayoutGuideDSL {
|
||||||
|
return ConstraintLayoutGuideDSL(guide: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@available(iOS 9.0, *)
|
||||||
|
public typealias ConstraintLayoutGuide = UILayoutGuide
|
||||||
|
#else
|
||||||
|
@available(OSX 10.11, *)
|
||||||
|
public typealias ConstraintLayoutGuide = NSLayoutGuide
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
|
public struct ConstraintLayoutGuideDSL: ConstraintAttributesDSL {
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
|
return ConstraintMaker.prepareConstraints(item: self.guide, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.makeConstraints(item: self.guide, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.remakeConstraints(item: self.guide, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.updateConstraints(item: self.guide, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removeConstraints() {
|
||||||
|
ConstraintMaker.removeConstraints(item: self.guide)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var target: AnyObject? {
|
||||||
|
return self.guide
|
||||||
|
}
|
||||||
|
|
||||||
|
internal let guide: ConstraintLayoutGuide
|
||||||
|
|
||||||
|
internal init(guide: ConstraintLayoutGuide) {
|
||||||
|
self.guide = guide
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public typealias ConstraintLayoutSupport = UILayoutSupport
|
||||||
|
#else
|
||||||
|
public class ConstraintLayoutSupport {}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public struct ConstraintLayoutSupportDSL: ConstraintDSL {
|
||||||
|
|
||||||
|
public var target: AnyObject? {
|
||||||
|
return self.support
|
||||||
|
}
|
||||||
|
|
||||||
|
internal let support: ConstraintLayoutSupport
|
||||||
|
|
||||||
|
internal init(support: ConstraintLayoutSupport) {
|
||||||
|
self.support = support
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public var top: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.top)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var bottom: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var height: ConstraintItem {
|
||||||
|
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
+224
@@ -0,0 +1,224 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public class ConstraintMaker {
|
||||||
|
|
||||||
|
public var left: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.left)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var top: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.top)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var bottom: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.bottom)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var right: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.right)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var leading: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var trailing: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.trailing)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var width: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.width)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var height: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerX: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.centerX)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerY: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.centerY)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"lastBaseline")
|
||||||
|
public var baseline: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.lastBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var lastBaseline: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.lastBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
public var firstBaseline: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.firstBaseline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leftMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.leftMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var rightMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.rightMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var topMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.topMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var bottomMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.bottomMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leadingMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.leadingMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var trailingMargin: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.trailingMargin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerXWithinMargins: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.centerXWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerYWithinMargins: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.centerYWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var edges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.edges)
|
||||||
|
}
|
||||||
|
public var horizontalEdges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.horizontalEdges)
|
||||||
|
}
|
||||||
|
public var verticalEdges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.verticalEdges)
|
||||||
|
}
|
||||||
|
public var directionalEdges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.directionalEdges)
|
||||||
|
}
|
||||||
|
public var directionalHorizontalEdges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.directionalHorizontalEdges)
|
||||||
|
}
|
||||||
|
public var directionalVerticalEdges: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.directionalVerticalEdges)
|
||||||
|
}
|
||||||
|
public var size: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.size)
|
||||||
|
}
|
||||||
|
public var center: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.center)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var margins: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.margins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var directionalMargins: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.directionalMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerWithinMargins: ConstraintMakerExtendable {
|
||||||
|
return self.makeExtendableWithAttributes(.centerWithinMargins)
|
||||||
|
}
|
||||||
|
|
||||||
|
public let item: LayoutConstraintItem
|
||||||
|
private var descriptions = [ConstraintDescription]()
|
||||||
|
|
||||||
|
internal init(item: LayoutConstraintItem) {
|
||||||
|
self.item = item
|
||||||
|
self.item.prepare()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func makeExtendableWithAttributes(_ attributes: ConstraintAttributes) -> ConstraintMakerExtendable {
|
||||||
|
let description = ConstraintDescription(item: self.item, attributes: attributes)
|
||||||
|
self.descriptions.append(description)
|
||||||
|
return ConstraintMakerExtendable(description)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static func prepareConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
|
let maker = ConstraintMaker(item: item)
|
||||||
|
closure(maker)
|
||||||
|
var constraints: [Constraint] = []
|
||||||
|
for description in maker.descriptions {
|
||||||
|
guard let constraint = description.constraint else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
constraints.append(constraint)
|
||||||
|
}
|
||||||
|
return constraints
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
let constraints = prepareConstraints(item: item, closure: closure)
|
||||||
|
for constraint in constraints {
|
||||||
|
constraint.activateIfNeeded(updatingExisting: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static func remakeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
self.removeConstraints(item: item)
|
||||||
|
self.makeConstraints(item: item, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static func updateConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
guard item.constraints.count > 0 else {
|
||||||
|
self.makeConstraints(item: item, closure: closure)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let constraints = prepareConstraints(item: item, closure: closure)
|
||||||
|
for constraint in constraints {
|
||||||
|
constraint.activateIfNeeded(updatingExisting: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static func removeConstraints(item: LayoutConstraintItem) {
|
||||||
|
let constraints = item.constraints
|
||||||
|
for constraint in constraints {
|
||||||
|
constraint.deactivateIfNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class ConstraintMakerEditable: ConstraintMakerPrioritizable {
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||||
|
self.description.multiplier = amount
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func dividedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable {
|
||||||
|
return self.multipliedBy(1.0 / amount.constraintMultiplierTargetValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func offset(_ amount: ConstraintOffsetTarget) -> ConstraintMakerEditable {
|
||||||
|
self.description.constant = amount.constraintOffsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func inset(_ amount: ConstraintInsetTarget) -> ConstraintMakerEditable {
|
||||||
|
self.description.constant = amount.constraintInsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@discardableResult
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
public func inset(_ amount: ConstraintDirectionalInsetTarget) -> ConstraintMakerEditable {
|
||||||
|
self.description.constant = amount.constraintDirectionalInsetTargetValue
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class ConstraintMakerExtendable: ConstraintMakerRelatable {
|
||||||
|
|
||||||
|
public var left: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .left
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var top: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .top
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var bottom: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .bottom
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var right: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .right
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var leading: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .leading
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var trailing: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .trailing
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var width: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .width
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var height: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .height
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerX: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .centerX
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var centerY: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .centerY
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"lastBaseline")
|
||||||
|
public var baseline: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .lastBaseline
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var lastBaseline: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .lastBaseline
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
public var firstBaseline: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .firstBaseline
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leftMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .leftMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var rightMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .rightMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var topMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .topMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var bottomMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .bottomMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var leadingMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .leadingMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var trailingMargin: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .trailingMargin
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerXWithinMargins: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .centerXWithinMargins
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerYWithinMargins: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .centerYWithinMargins
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var edges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .edges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var horizontalEdges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .horizontalEdges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var verticalEdges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .verticalEdges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var directionalEdges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .directionalEdges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var directionalHorizontalEdges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .directionalHorizontalEdges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var directionalVerticalEdges: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .directionalVerticalEdges
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
public var size: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .size
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var margins: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .margins
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var directionalMargins: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .directionalMargins
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public var centerWithinMargins: ConstraintMakerExtendable {
|
||||||
|
self.description.attributes += .centerWithinMargins
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class ConstraintMakerFinalizable {
|
||||||
|
|
||||||
|
internal let description: ConstraintDescription
|
||||||
|
|
||||||
|
internal init(_ description: ConstraintDescription) {
|
||||||
|
self.description = description
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func labeled(_ label: String) -> ConstraintMakerFinalizable {
|
||||||
|
self.description.label = label
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
public var constraint: Constraint {
|
||||||
|
return self.description.constraint!
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use ConstraintMakerPrioritizable instead.")
|
||||||
|
public typealias ConstraintMakerPriortizable = ConstraintMakerPrioritizable
|
||||||
|
|
||||||
|
public class ConstraintMakerPrioritizable: ConstraintMakerFinalizable {
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable {
|
||||||
|
self.description.priority = amount.value
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable {
|
||||||
|
self.description.priority = amount
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use priority(.required) instead.")
|
||||||
|
@discardableResult
|
||||||
|
public func priorityRequired() -> ConstraintMakerFinalizable {
|
||||||
|
return self.priority(.required)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use priority(.high) instead.")
|
||||||
|
@discardableResult
|
||||||
|
public func priorityHigh() -> ConstraintMakerFinalizable {
|
||||||
|
return self.priority(.high)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use priority(.medium) instead.")
|
||||||
|
@discardableResult
|
||||||
|
public func priorityMedium() -> ConstraintMakerFinalizable {
|
||||||
|
return self.priority(.medium)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, message:"Use priority(.low) instead.")
|
||||||
|
@discardableResult
|
||||||
|
public func priorityLow() -> ConstraintMakerFinalizable {
|
||||||
|
return self.priority(.low)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
extension ConstraintMakerRelatable {
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func equalToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(closure(other), relation: .equal, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func lessThanOrEqualToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(closure(other), relation: .lessThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func greaterThanOrEqualToSuperview<T: ConstraintRelatableTarget>(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(closure(other), relation: .greaterThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class ConstraintMakerRelatable {
|
||||||
|
|
||||||
|
internal let description: ConstraintDescription
|
||||||
|
|
||||||
|
internal init(_ description: ConstraintDescription) {
|
||||||
|
self.description = description
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func relatedTo(_ other: ConstraintRelatableTarget, relation: ConstraintRelation, file: String, line: UInt) -> ConstraintMakerEditable {
|
||||||
|
let related: ConstraintItem
|
||||||
|
let constant: ConstraintConstantTarget
|
||||||
|
|
||||||
|
if let other = other as? ConstraintItem {
|
||||||
|
guard other.attributes == ConstraintAttributes.none ||
|
||||||
|
other.attributes.layoutAttributes.count <= 1 ||
|
||||||
|
other.attributes.layoutAttributes == self.description.attributes.layoutAttributes ||
|
||||||
|
other.attributes == .edges && self.description.attributes == .margins ||
|
||||||
|
other.attributes == .margins && self.description.attributes == .edges ||
|
||||||
|
other.attributes == .directionalEdges && self.description.attributes == .directionalMargins ||
|
||||||
|
other.attributes == .directionalMargins && self.description.attributes == .directionalEdges else {
|
||||||
|
fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))");
|
||||||
|
}
|
||||||
|
|
||||||
|
related = other
|
||||||
|
constant = 0.0
|
||||||
|
} else if let other = other as? ConstraintView {
|
||||||
|
related = ConstraintItem(target: other, attributes: ConstraintAttributes.none)
|
||||||
|
constant = 0.0
|
||||||
|
} else if let other = other as? ConstraintConstantTarget {
|
||||||
|
related = ConstraintItem(target: nil, attributes: ConstraintAttributes.none)
|
||||||
|
constant = other
|
||||||
|
} else if #available(iOS 9.0, OSX 10.11, *), let other = other as? ConstraintLayoutGuide {
|
||||||
|
related = ConstraintItem(target: other, attributes: ConstraintAttributes.none)
|
||||||
|
constant = 0.0
|
||||||
|
} else {
|
||||||
|
fatalError("Invalid constraint. (\(file), \(line))")
|
||||||
|
}
|
||||||
|
|
||||||
|
let editable = ConstraintMakerEditable(self.description)
|
||||||
|
editable.description.sourceLocation = (file, line)
|
||||||
|
editable.description.relation = relation
|
||||||
|
editable.description.related = related
|
||||||
|
editable.description.constant = constant
|
||||||
|
return editable
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func equalTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
return self.relatedTo(other, relation: .equal, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func equalToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(other, relation: .equal, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func lessThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func lessThanOrEqualToSuperview(_ file: String = #file, _ line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(other, relation: .lessThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func greaterThanOrEqualTo(_ other: ConstraintRelatableTarget, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func greaterThanOrEqualToSuperview(_ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable {
|
||||||
|
guard let other = self.description.item.superview else {
|
||||||
|
fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.")
|
||||||
|
}
|
||||||
|
return self.relatedTo(other, relation: .greaterThanOrEqual, file: file, line: line)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
var constraintMultiplierTargetValue: CGFloat { get }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
public var constraintMultiplierTargetValue: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt: ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
public var constraintMultiplierTargetValue: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
public var constraintMultiplierTargetValue: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
public var constraintMultiplierTargetValue: CGFloat {
|
||||||
|
return CGFloat(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat: ConstraintMultiplierTarget {
|
||||||
|
|
||||||
|
public var constraintMultiplierTargetValue: CGFloat {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintOffsetTarget: ConstraintConstantTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: ConstraintOffsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt: ConstraintOffsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: ConstraintOffsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: ConstraintOffsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat: ConstraintOffsetTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintOffsetTarget {
|
||||||
|
|
||||||
|
internal var constraintOffsetTargetValue: CGFloat {
|
||||||
|
let offset: CGFloat
|
||||||
|
if let amount = self as? Float {
|
||||||
|
offset = CGFloat(amount)
|
||||||
|
} else if let amount = self as? Double {
|
||||||
|
offset = CGFloat(amount)
|
||||||
|
} else if let amount = self as? CGFloat {
|
||||||
|
offset = CGFloat(amount)
|
||||||
|
} else if let amount = self as? Int {
|
||||||
|
offset = CGFloat(amount)
|
||||||
|
} else if let amount = self as? UInt {
|
||||||
|
offset = CGFloat(amount)
|
||||||
|
} else {
|
||||||
|
offset = 0.0
|
||||||
|
}
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public struct ConstraintPriority : ExpressibleByFloatLiteral, Equatable, Strideable {
|
||||||
|
public typealias FloatLiteralType = Float
|
||||||
|
|
||||||
|
public let value: Float
|
||||||
|
|
||||||
|
public init(floatLiteral value: Float) {
|
||||||
|
self.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
public init(_ value: Float) {
|
||||||
|
self.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var required: ConstraintPriority {
|
||||||
|
return 1000.0
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var high: ConstraintPriority {
|
||||||
|
return 750.0
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var medium: ConstraintPriority {
|
||||||
|
#if os(OSX)
|
||||||
|
return 501.0
|
||||||
|
#else
|
||||||
|
return 500.0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var low: ConstraintPriority {
|
||||||
|
return 250.0
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func ==(lhs: ConstraintPriority, rhs: ConstraintPriority) -> Bool {
|
||||||
|
return lhs.value == rhs.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Strideable
|
||||||
|
|
||||||
|
public func advanced(by n: FloatLiteralType) -> ConstraintPriority {
|
||||||
|
return ConstraintPriority(floatLiteral: value + n)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func distance(to other: ConstraintPriority) -> FloatLiteralType {
|
||||||
|
return other.value - value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
var constraintPriorityTargetValue: Float { get }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return Float(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return Float(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return Float(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return Float(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
extension UILayoutPriority: ConstraintPriorityTarget {
|
||||||
|
|
||||||
|
public var constraintPriorityTargetValue: Float {
|
||||||
|
return self.rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Int: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UInt: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Float: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Double: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGFloat: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGSize: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension CGPoint: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintInsets: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
@available(iOS 11.0, tvOS 11.0, *)
|
||||||
|
extension ConstraintDirectionalInsets: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extension ConstraintItem: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintView: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
|
extension ConstraintLayoutGuide: ConstraintRelatableTarget {
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
internal enum ConstraintRelation : Int {
|
||||||
|
case equal = 1
|
||||||
|
case lessThanOrEqual
|
||||||
|
case greaterThanOrEqual
|
||||||
|
|
||||||
|
internal var layoutRelation: LayoutRelation {
|
||||||
|
get {
|
||||||
|
switch(self) {
|
||||||
|
case .equal:
|
||||||
|
return .equal
|
||||||
|
case .lessThanOrEqual:
|
||||||
|
return .lessThanOrEqual
|
||||||
|
case .greaterThanOrEqual:
|
||||||
|
return .greaterThanOrEqual
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public extension ConstraintView {
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.left")
|
||||||
|
var snp_left: ConstraintItem { return self.snp.left }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.top")
|
||||||
|
var snp_top: ConstraintItem { return self.snp.top }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.right")
|
||||||
|
var snp_right: ConstraintItem { return self.snp.right }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.bottom")
|
||||||
|
var snp_bottom: ConstraintItem { return self.snp.bottom }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.leading")
|
||||||
|
var snp_leading: ConstraintItem { return self.snp.leading }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.trailing")
|
||||||
|
var snp_trailing: ConstraintItem { return self.snp.trailing }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.width")
|
||||||
|
var snp_width: ConstraintItem { return self.snp.width }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.height")
|
||||||
|
var snp_height: ConstraintItem { return self.snp.height }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.centerX")
|
||||||
|
var snp_centerX: ConstraintItem { return self.snp.centerX }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.centerY")
|
||||||
|
var snp_centerY: ConstraintItem { return self.snp.centerY }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.baseline")
|
||||||
|
var snp_baseline: ConstraintItem { return self.snp.baseline }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.lastBaseline")
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.firstBaseline")
|
||||||
|
@available(iOS 8.0, OSX 10.11, *)
|
||||||
|
var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.leftMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_leftMargin: ConstraintItem { return self.snp.leftMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.topMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_topMargin: ConstraintItem { return self.snp.topMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.rightMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_rightMargin: ConstraintItem { return self.snp.rightMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.bottomMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.leadingMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.trailingMargin")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.centerXWithinMargins")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.centerYWithinMargins")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.edges")
|
||||||
|
var snp_edges: ConstraintItem { return self.snp.edges }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.size")
|
||||||
|
var snp_size: ConstraintItem { return self.snp.size }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.center")
|
||||||
|
var snp_center: ConstraintItem { return self.snp.center }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.margins")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_margins: ConstraintItem { return self.snp.margins }
|
||||||
|
|
||||||
|
@available(iOS, deprecated, renamed:"snp.centerWithinMargins")
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins }
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.prepareConstraints(_:)")
|
||||||
|
func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
|
return self.snp.prepareConstraints(closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.makeConstraints(_:)")
|
||||||
|
func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
self.snp.makeConstraints(closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.remakeConstraints(_:)")
|
||||||
|
func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
self.snp.remakeConstraints(closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.updateConstraints(_:)")
|
||||||
|
func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
self.snp.updateConstraints(closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(*, deprecated, renamed:"snp.removeConstraints()")
|
||||||
|
func snp_removeConstraints() {
|
||||||
|
self.snp.removeConstraints()
|
||||||
|
}
|
||||||
|
|
||||||
|
var snp: ConstraintViewDSL {
|
||||||
|
return ConstraintViewDSL(view: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
public typealias ConstraintView = UIView
|
||||||
|
#else
|
||||||
|
public typealias ConstraintView = NSView
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public struct ConstraintViewDSL: ConstraintAttributesDSL {
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
public func prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
|
||||||
|
return ConstraintMaker.prepareConstraints(item: self.view, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.makeConstraints(item: self.view, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.remakeConstraints(item: self.view, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
|
||||||
|
ConstraintMaker.updateConstraints(item: self.view, closure: closure)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func removeConstraints() {
|
||||||
|
ConstraintMaker.removeConstraints(item: self.view)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var contentHuggingHorizontalPriority: Float {
|
||||||
|
get {
|
||||||
|
return self.view.contentHuggingPriority(for: .horizontal).rawValue
|
||||||
|
}
|
||||||
|
nonmutating set {
|
||||||
|
self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .horizontal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var contentHuggingVerticalPriority: Float {
|
||||||
|
get {
|
||||||
|
return self.view.contentHuggingPriority(for: .vertical).rawValue
|
||||||
|
}
|
||||||
|
nonmutating set {
|
||||||
|
self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .vertical)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var contentCompressionResistanceHorizontalPriority: Float {
|
||||||
|
get {
|
||||||
|
return self.view.contentCompressionResistancePriority(for: .horizontal).rawValue
|
||||||
|
}
|
||||||
|
nonmutating set {
|
||||||
|
self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .horizontal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var contentCompressionResistanceVerticalPriority: Float {
|
||||||
|
get {
|
||||||
|
return self.view.contentCompressionResistancePriority(for: .vertical).rawValue
|
||||||
|
}
|
||||||
|
nonmutating set {
|
||||||
|
self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .vertical)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var target: AnyObject? {
|
||||||
|
return self.view
|
||||||
|
}
|
||||||
|
|
||||||
|
internal let view: ConstraintView
|
||||||
|
|
||||||
|
internal init(view: ConstraintView) {
|
||||||
|
self.view = view
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+169
@@ -0,0 +1,169 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public extension LayoutConstraint {
|
||||||
|
|
||||||
|
override var description: String {
|
||||||
|
var description = "<"
|
||||||
|
|
||||||
|
description += descriptionForObject(self)
|
||||||
|
|
||||||
|
if let firstItem = conditionalOptional(from: self.firstItem) {
|
||||||
|
description += " \(descriptionForObject(firstItem))"
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.firstAttribute != .notAnAttribute {
|
||||||
|
description += ".\(descriptionForAttribute(self.firstAttribute))"
|
||||||
|
}
|
||||||
|
|
||||||
|
description += " \(descriptionForRelation(self.relation))"
|
||||||
|
|
||||||
|
if let secondItem = self.secondItem {
|
||||||
|
description += " \(descriptionForObject(secondItem))"
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.secondAttribute != .notAnAttribute {
|
||||||
|
description += ".\(descriptionForAttribute(self.secondAttribute))"
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.multiplier != 1.0 {
|
||||||
|
description += " * \(self.multiplier)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.secondAttribute == .notAnAttribute {
|
||||||
|
description += " \(self.constant)"
|
||||||
|
} else {
|
||||||
|
if self.constant > 0.0 {
|
||||||
|
description += " + \(self.constant)"
|
||||||
|
} else if self.constant < 0.0 {
|
||||||
|
description += " - \(abs(self.constant))"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.priority.rawValue != 1000.0 {
|
||||||
|
description += " ^\(self.priority)"
|
||||||
|
}
|
||||||
|
|
||||||
|
description += ">"
|
||||||
|
|
||||||
|
return description
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private func descriptionForRelation(_ relation: LayoutRelation) -> String {
|
||||||
|
switch relation {
|
||||||
|
case .equal: return "=="
|
||||||
|
case .greaterThanOrEqual: return ">="
|
||||||
|
case .lessThanOrEqual: return "<="
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default: return "unknown"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
|
||||||
|
#if canImport(UIKit)
|
||||||
|
switch attribute {
|
||||||
|
case .notAnAttribute: return "notAnAttribute"
|
||||||
|
case .top: return "top"
|
||||||
|
case .left: return "left"
|
||||||
|
case .bottom: return "bottom"
|
||||||
|
case .right: return "right"
|
||||||
|
case .leading: return "leading"
|
||||||
|
case .trailing: return "trailing"
|
||||||
|
case .width: return "width"
|
||||||
|
case .height: return "height"
|
||||||
|
case .centerX: return "centerX"
|
||||||
|
case .centerY: return "centerY"
|
||||||
|
case .lastBaseline: return "lastBaseline"
|
||||||
|
case .firstBaseline: return "firstBaseline"
|
||||||
|
case .topMargin: return "topMargin"
|
||||||
|
case .leftMargin: return "leftMargin"
|
||||||
|
case .bottomMargin: return "bottomMargin"
|
||||||
|
case .rightMargin: return "rightMargin"
|
||||||
|
case .leadingMargin: return "leadingMargin"
|
||||||
|
case .trailingMargin: return "trailingMargin"
|
||||||
|
case .centerXWithinMargins: return "centerXWithinMargins"
|
||||||
|
case .centerYWithinMargins: return "centerYWithinMargins"
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default: return "unknown"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
switch attribute {
|
||||||
|
case .notAnAttribute: return "notAnAttribute"
|
||||||
|
case .top: return "top"
|
||||||
|
case .left: return "left"
|
||||||
|
case .bottom: return "bottom"
|
||||||
|
case .right: return "right"
|
||||||
|
case .leading: return "leading"
|
||||||
|
case .trailing: return "trailing"
|
||||||
|
case .width: return "width"
|
||||||
|
case .height: return "height"
|
||||||
|
case .centerX: return "centerX"
|
||||||
|
case .centerY: return "centerY"
|
||||||
|
case .lastBaseline: return "lastBaseline"
|
||||||
|
case .firstBaseline: return "firstBaseline"
|
||||||
|
#if swift(>=5.0)
|
||||||
|
@unknown default: return "unknown"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private func conditionalOptional<T>(from object: Optional<T>) -> Optional<T> {
|
||||||
|
return object
|
||||||
|
}
|
||||||
|
|
||||||
|
private func conditionalOptional<T>(from object: T) -> Optional<T> {
|
||||||
|
return Optional.some(object)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func descriptionForObject(_ object: AnyObject) -> String {
|
||||||
|
let pointerDescription = String(format: "%p", UInt(bitPattern: ObjectIdentifier(object)))
|
||||||
|
var desc = ""
|
||||||
|
|
||||||
|
desc += type(of: object).description()
|
||||||
|
|
||||||
|
if let object = object as? ConstraintView {
|
||||||
|
desc += ":\(object.snp.label() ?? pointerDescription)"
|
||||||
|
} else if let object = object as? LayoutConstraint {
|
||||||
|
desc += ":\(object.label ?? pointerDescription)"
|
||||||
|
} else {
|
||||||
|
desc += ":\(pointerDescription)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if let object = object as? LayoutConstraint, let file = object.constraint?.sourceLocation.0, let line = object.constraint?.sourceLocation.1 {
|
||||||
|
desc += "@\((file as NSString).lastPathComponent)#\(line)"
|
||||||
|
}
|
||||||
|
|
||||||
|
desc += ""
|
||||||
|
return desc
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class LayoutConstraint : NSLayoutConstraint {
|
||||||
|
|
||||||
|
public var label: String? {
|
||||||
|
get {
|
||||||
|
return self.identifier
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
self.identifier = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal weak var constraint: Constraint? = nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool {
|
||||||
|
// If firstItem or secondItem on either constraint has a dangling pointer
|
||||||
|
// this comparison can cause a crash. The solution for this is to ensure
|
||||||
|
// your layout code hold strong references to things like Views, LayoutGuides
|
||||||
|
// and LayoutAnchors as SnapKit will not keep strong references to any of these.
|
||||||
|
guard lhs.firstAttribute == rhs.firstAttribute &&
|
||||||
|
lhs.secondAttribute == rhs.secondAttribute &&
|
||||||
|
lhs.relation == rhs.relation &&
|
||||||
|
lhs.priority == rhs.priority &&
|
||||||
|
lhs.multiplier == rhs.multiplier &&
|
||||||
|
lhs.secondItem === rhs.secondItem &&
|
||||||
|
lhs.firstItem === rhs.firstItem else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public protocol LayoutConstraintItem: AnyObject {
|
||||||
|
}
|
||||||
|
|
||||||
|
@available(iOS 9.0, OSX 10.11, *)
|
||||||
|
extension ConstraintLayoutGuide : LayoutConstraintItem {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ConstraintView : LayoutConstraintItem {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extension LayoutConstraintItem {
|
||||||
|
|
||||||
|
internal func prepare() {
|
||||||
|
if let view = self as? ConstraintView {
|
||||||
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal var superview: ConstraintView? {
|
||||||
|
if let view = self as? ConstraintView {
|
||||||
|
return view.superview
|
||||||
|
}
|
||||||
|
|
||||||
|
if #available(iOS 9.0, OSX 10.11, *), let guide = self as? ConstraintLayoutGuide {
|
||||||
|
return guide.owningView
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
internal var constraints: [Constraint] {
|
||||||
|
return self.constraintsSet.allObjects as! [Constraint]
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func add(constraints: [Constraint]) {
|
||||||
|
let constraintsSet = self.constraintsSet
|
||||||
|
for constraint in constraints {
|
||||||
|
constraintsSet.add(constraint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func remove(constraints: [Constraint]) {
|
||||||
|
let constraintsSet = self.constraintsSet
|
||||||
|
for constraint in constraints {
|
||||||
|
constraintsSet.remove(constraint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var constraintsSet: NSMutableSet {
|
||||||
|
let constraintsSet: NSMutableSet
|
||||||
|
|
||||||
|
if let existing = objc_getAssociatedObject(self, &constraintsKey) as? NSMutableSet {
|
||||||
|
constraintsSet = existing
|
||||||
|
} else {
|
||||||
|
constraintsSet = NSMutableSet()
|
||||||
|
objc_setAssociatedObject(self, &constraintsKey, constraintsSet, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
||||||
|
}
|
||||||
|
return constraintsSet
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private var constraintsKey: UInt8 = 0
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?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>NSPrivacyTracking</key>
|
||||||
|
<false/>
|
||||||
|
<key>NSPrivacyAccessedAPITypes</key>
|
||||||
|
<array/>
|
||||||
|
<key>NSPrivacyCollectedDataTypes</key>
|
||||||
|
<array/>
|
||||||
|
<key>NSPrivacyTrackingDomains</key>
|
||||||
|
<array/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#if swift(>=4.2)
|
||||||
|
typealias LayoutRelation = NSLayoutConstraint.Relation
|
||||||
|
typealias LayoutAttribute = NSLayoutConstraint.Attribute
|
||||||
|
#else
|
||||||
|
typealias LayoutRelation = NSLayoutRelation
|
||||||
|
typealias LayoutAttribute = NSLayoutAttribute
|
||||||
|
#endif
|
||||||
|
typealias LayoutPriority = UILayoutPriority
|
||||||
|
#else
|
||||||
|
import AppKit
|
||||||
|
typealias LayoutRelation = NSLayoutConstraint.Relation
|
||||||
|
typealias LayoutAttribute = NSLayoutConstraint.Attribute
|
||||||
|
typealias LayoutPriority = NSLayoutConstraint.Priority
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// SnapKit
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
#if canImport(UIKit)
|
||||||
|
import UIKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@available(iOS 8.0, *)
|
||||||
|
public extension ConstraintLayoutSupport {
|
||||||
|
|
||||||
|
var snp: ConstraintLayoutSupportDSL {
|
||||||
|
return ConstraintLayoutSupportDSL(support: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
ReadViewDemo/Pods/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-acknowledgements.markdown
Generated
+23
@@ -53,6 +53,29 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
## SnapKit
|
||||||
|
|
||||||
|
Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
## ZIPFoundation
|
## ZIPFoundation
|
||||||
|
|
||||||
MIT License
|
MIT License
|
||||||
|
|||||||
Generated
+29
@@ -76,6 +76,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
<key>Type</key>
|
<key>Type</key>
|
||||||
<string>PSGroupSpecifier</string>
|
<string>PSGroupSpecifier</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>FooterText</key>
|
||||||
|
<string>Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
</string>
|
||||||
|
<key>License</key>
|
||||||
|
<string>MIT</string>
|
||||||
|
<key>Title</key>
|
||||||
|
<string>SnapKit</string>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>PSGroupSpecifier</string>
|
||||||
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>FooterText</key>
|
<key>FooterText</key>
|
||||||
<string>MIT License
|
<string>MIT License
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-frameworks.sh
|
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-frameworks.sh
|
||||||
${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework
|
${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework
|
||||||
${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework
|
${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework
|
||||||
${BUILT_PRODUCTS_DIR}/RDReaderView/RDReaderView.framework
|
${BUILT_PRODUCTS_DIR}/RDEpubReaderView/RDEpubReaderView.framework
|
||||||
|
${BUILT_PRODUCTS_DIR}/RDPDFReaderView/RDPDFReaderView.framework
|
||||||
|
${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
|
||||||
${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework
|
${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDReaderView.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDEpubReaderView.framework
|
||||||
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDPDFReaderView.framework
|
||||||
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ZIPFoundation.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ZIPFoundation.framework
|
||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-frameworks.sh
|
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-frameworks.sh
|
||||||
${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework
|
${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework
|
||||||
${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework
|
${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework
|
||||||
${BUILT_PRODUCTS_DIR}/RDReaderView/RDReaderView.framework
|
${BUILT_PRODUCTS_DIR}/RDEpubReaderView/RDEpubReaderView.framework
|
||||||
|
${BUILT_PRODUCTS_DIR}/RDPDFReaderView/RDPDFReaderView.framework
|
||||||
|
${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
|
||||||
${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework
|
${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDReaderView.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDEpubReaderView.framework
|
||||||
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RDPDFReaderView.framework
|
||||||
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
|
||||||
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ZIPFoundation.framework
|
${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ZIPFoundation.framework
|
||||||
+6
-2
@@ -178,13 +178,17 @@ code_sign_if_enabled() {
|
|||||||
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/RDReaderView/RDReaderView.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/RDEpubReaderView/RDEpubReaderView.framework"
|
||||||
|
install_framework "${BUILT_PRODUCTS_DIR}/RDPDFReaderView/RDPDFReaderView.framework"
|
||||||
|
install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework"
|
||||||
fi
|
fi
|
||||||
if [[ "$CONFIGURATION" == "Release" ]]; then
|
if [[ "$CONFIGURATION" == "Release" ]]; then
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/RDReaderView/RDReaderView.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/RDEpubReaderView/RDEpubReaderView.framework"
|
||||||
|
install_framework "${BUILT_PRODUCTS_DIR}/RDPDFReaderView/RDPDFReaderView.framework"
|
||||||
|
install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
|
||||||
install_framework "${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework"
|
install_framework "${BUILT_PRODUCTS_DIR}/ZIPFoundation/ZIPFoundation.framework"
|
||||||
fi
|
fi
|
||||||
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
|
if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
|
||||||
|
|||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-resources.sh
|
||||||
|
${PODS_CONFIGURATION_BUILD_DIR}/RDEpubReaderView/RDEpubReaderViewAssets.bundle
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RDEpubReaderViewAssets.bundle
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
${PODS_ROOT}/Target Support Files/Pods-ReadViewDemo/Pods-ReadViewDemo-resources.sh
|
||||||
|
${PODS_CONFIGURATION_BUILD_DIR}/RDEpubReaderView/RDEpubReaderViewAssets.bundle
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RDEpubReaderViewAssets.bundle
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user