widgetkit-code-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WidgetKit Code Review

WidgetKit 代码评审

Quick Reference

快速参考

Issue TypeReference
TimelineProvider, entries, reload policiesreferences/timeline.md
Widget families, containerBackground, deep linkingreferences/views.md
AppIntentConfiguration, EntityQuery, @Parameterreferences/intents.md
Refresh budget, memory limits, cachingreferences/performance.md
问题类型参考链接
TimelineProvider、entries、重载策略references/timeline.md
Widget 系列、containerBackground、深度链接references/views.md
AppIntentConfiguration、EntityQuery、@Parameterreferences/intents.md
刷新预算、内存限制、缓存references/performance.md

Review Checklist

评审检查清单

  • placeholder(in:)
    returns immediately without async work
  • Timeline entries spaced at least 5 minutes apart
  • getSnapshot
    checks
    context.isPreview
    for gallery previews
  • containerBackground(for:)
    used for iOS 17+ compatibility
  • widgetURL
    used for systemSmall (not Link)
  • No Button views (use Link or widgetURL)
  • No AsyncImage or UIViewRepresentable in widget views
  • Images downsampled to widget display size (~30MB limit)
  • App Groups configured for data sharing between app and widget
  • EntityQuery implements
    defaultResult()
    for non-optional parameters
  • New intent parameters handle nil for existing widgets after updates
  • reloadTimelines
    called strategically (not on every data change)
  • placeholder(in:)
    立即返回,不执行异步操作
  • 时间线条目间隔至少5分钟
  • getSnapshot
    针对图库预览检查
    context.isPreview
  • 使用
    containerBackground(for:)
    以兼容iOS 17+
  • 针对systemSmall尺寸使用
    widgetURL
    (而非Link)
  • 不使用Button视图(改用Link或widgetURL)
  • 小组件视图中不使用AsyncImage或UIViewRepresentable
  • 图片已下采样至小组件显示尺寸(约30MB限制)
  • 已配置App Groups以实现应用与小组件之间的数据共享
  • EntityQuery 为非可选参数实现了
    defaultResult()
  • 新增的意图参数在更新后能处理现有小组件的nil值
  • 策略性调用
    reloadTimelines
    (而非每次数据变更都调用)

When to Load References

何时查阅参考资料

  • TimelineProvider implementation or refresh issues -> timeline.md
  • Widget sizes, Lock Screen, containerBackground -> views.md
  • Configurable widgets, AppIntent migration -> intents.md
  • Memory issues, caching, budget management -> performance.md
  • TimelineProvider 实现或刷新问题 -> timeline.md
  • 小组件尺寸、锁屏、containerBackground -> views.md
  • 可配置小组件、AppIntent 迁移 -> intents.md
  • 内存问题、缓存、预算管理 -> performance.md

Review Questions

评审问题

  1. Does the widget provide fallback entries for when system delays refresh?
  2. Are Lock Screen families (accessoryCircular/Rectangular/Inline) handled appropriately?
  3. Would migrating from IntentConfiguration break existing user widgets?
  4. Is timeline populated with future entries or does it rely on frequent refreshes?
  5. Is data cached via App Groups for widget access?
  1. 当系统延迟刷新时,小组件是否提供了备用条目?
  2. 锁屏系列(accessoryCircular/Rectangular/Inline)是否得到了恰当处理?
  3. 从IntentConfiguration迁移是否会破坏现有用户的小组件?
  4. 时间线是否填充了未来条目,还是依赖频繁刷新?
  5. 是否通过App Groups缓存数据以供小组件访问?