Skip to content

feat(weather): add interactive widget forecast refresh - #629

Merged
whes1015 merged 2 commits into
mainfrom
feat/ios-widget-interactive-forecast-refresh
Oct 18, 2026
Merged

whes1015 merged 2 commits into
mainfrom
feat/ios-widget-interactive-forecast-refresh

Conversation

@YinCheng0106

Copy link
Copy Markdown
Member

這個 PR 做了什麼

在既有 iOS 天氣小工具加入預報手動重新整理:iOS 17 以上的中型/大型小工具在預報較舊、過期或無可顯示時段時顯示按鈕;保留 WidgetKit 自動更新及原有地點設定。

正式程式碼:

  • RefreshForecastIntent 綁定小工具設定的 Current Location 或 Saved Location,驗證識別碼及已儲存地點目錄。Intent 不開啟 App、不直接呼叫 API、不寫快取、不額外呼叫 kind-wide reload;由 WidgetKit 在 Intent 完成後要求 timeline,沿用既有 Current Weather/Forecast API 更新流程。
  • ForecastWidgetExpiry 以校準後的 API 發布時間判定 Fresh/Stale/Expired:未滿 30 分鐘為 Fresh,30 分鐘至未滿 120 分鐘為 Stale,達 120 分鐘為 Expired。Stale 可顯示既有可用時段並標示「預報資料較舊」;Expired 不顯示預報。同一或較舊發布版本不能覆寫快取、改變原始 receivedAt 或延長效期。
  • Timeline 同時保留正常自動更新排程及 30/120 分鐘狀態轉換 entry,避免把網路重新載入時間視為執行保證。
  • ForecastWidgetSelection 以近期 Current Weather 觀測時間選取台北時間的下一整點;觀測缺少、無效、在未來或已達 30 分鐘時,改以校準時鐘選取。發布/接收時間只決定效期,不當作預報時段基準;保留 API 原始時段與既有 12 小時選取範圍。
  • 保留 IntentConfiguration、Saved/Current Location 隔離、原有 widgetURL、iOS 15/16 非互動 fallback 及 Small 不請求/不顯示預報的行為。新字串使用 Widget 原生 String Catalog,涵蓋既有五種語系。
  • 最後清理移除本次新增的逐次請求 UUID、HTTP/快取/timeline 調查紀錄,保留 main 原有 DEBUG 診斷。未變更相依套件、簽署設定、EEW 或鎖定檔。

測試:ForecastWidgetTests.swift 擴充發布效期邊界、同發布版本不延長效期、觀測時間對齊、時區/校準偏移、地點隔離、Intent 驗證及按鈕顯示條件的回歸案例;Xcode 專案僅補入測試 target 的新 Intent 檔案 membership 設定。

審查注意與已知限制:

  • WidgetKit 排程、預算與網路仍由系統決定,按鈕完成僅表示已提出更新要求,不保證立刻取得新資料。
  • iOS 17.0/17.1 的 AppIntent metadata 相容性仍需平台驗證,特別是目前 isDiscoverable 的 metadata 擷取/系統載入行為;較新 SDK 的建置成功不能證明這兩個版本可正常運作。
  • 本輪沒有新增 iOS 15/16、17.0/17.1 或實機的獨立系統驗證,也沒有重做模擬器 UI QA;使用者確認手動 QA 通過,但本次未取得裝置/系統版本矩陣。
  • Forecast API 仍沿用既有只有時鐘標籤的資料與選取策略;本 PR 未擴充為具絕對有效時間的逐時 API。
  • 截圖:未提供。

相關 issue

已搜尋 Widget/forecast refresh,沒有對應的 issue。

怎麼驗

既有驗證(沿用前輪結果,不是本輪重新執行的完整 hosted XCTest):

  • 92 個 focused XCTest 通過。
  • Widget Extension build、Swift 語法檢查、在地化檢查、git diff --check 通過。
  • 使用者已確認手動 QA 通過。

本輪最終清理後驗證:

  • 所有變更 Swift 檔案的 swiftc -frontend -parse 通過。
  • 新增 4 個 Widget 字串在既有 5 種語系均完整;tool/check/l10n.sh、Xcode 專案 plutil -lint、憑證樣式掃描及 staged diff whitespace 檢查通過。
  • tool/commit.sh --message 通過;當時 analyze/codegen/Dart coverage 使用既有成功快取。提交 hook 及提交後 commit 訊息檢查通過。
  • 正常推送保留 pre-push hook;新 commit 建置資訊使快取失效,依必要工作流程重新執行 format/analyze、codegen 與 Dart coverage,結果 3,620 個通過、11 個略過;所有本機 gate 通過。這不是新的一輪 Swift XCTest。
  • 未重跑完整 Swift suite、未執行模擬器 UI 自動化。受保護的 build_info 實體內容/索引/skip-worktree、兩份 Package.resolved 與 pubspec.lock 於流程結束核對保留。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過。
  • 一個 commit 一件事:Interactive Forecast Refresh MVP。
  • tool/dev/analyze.sh 與完整 Dart coverage 通過(由官方 pre-push hook 執行)。
  • 新的使用者可見字串均經在地化;原生 Widget 使用 String Catalog,非 Flutter AppLocalizations。
  • CI 全部通過:Draft 建立時尚待遠端結果;沒有全過不得合併。
  • UI 設計檢查:本次是原生 Widget,沿用 SwiftUI 版面而非 Flutter AppSpacing/AppRadius/AppMotion;手動 QA 由使用者確認通過,未提供深色模式截圖與完整平台矩陣。

Platform: ios

New(zh-Hant): iOS 天氣小工具可手動重新整理較舊或無法顯示的預報
New(en-US): iOS weather widgets can manually refresh outdated or unavailable forecasts
@YinCheng0106 YinCheng0106 self-assigned this Oct 17, 2026
@YinCheng0106 YinCheng0106 added the ios Issues or pull requests related to the iOS platform. label Oct 17, 2026
@YinCheng0106 YinCheng0106 added this to the v26.4 milestone Oct 17, 2026
@github-actions

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 8 selected item(s).

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.48%. Comparing base (bc4dc0e) to head (bf122f5).
⚠️ Report is 1 commits behind head on main.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@YinCheng0106
YinCheng0106 marked this pull request as ready for review October 17, 2026 18:01
Copilot AI balanced review requested due to automatic review settings October 17, 2026 18:01

This comment was marked as low quality.

@whes1015
whes1015 merged commit e6fe17b into main Oct 18, 2026
8 checks passed
@whes1015
whes1015 deleted the feat/ios-widget-interactive-forecast-refresh branch October 18, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ios Issues or pull requests related to the iOS platform. size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants