Skip to content

feat(weather): add configurable iOS weather widget locations - #579

Open
YinCheng0106 wants to merge 1 commit into
feat/ios-widget-configurationfrom
feat/ios-widget-intent-configuration
Open

YinCheng0106 wants to merge 1 commit into
feat/ios-widget-configurationfrom
feat/ios-widget-intent-configuration

Conversation

@YinCheng0106

Copy link
Copy Markdown

這個 PR 做了什麼

讓每個 iOS Weather Widget instance 可以獨立選擇:

  • 所在地 / Current Location
  • DPIP 已儲存的地點

並將目前天氣 snapshot 從單一全域檔案擴充為 per-location cache,使多個 Widget 可以同時顯示不同地點。

此 PR 是 Widget 開發堆疊的第三階段,建立可設定 Widget 與 per-location snapshot contract;Widget Extension 自行抓取天氣則由後續 PR 處理。

主要變更

Widget configuration

  • 新增 WeatherWidgetConfigurationIntent
  • 新增 Intents Extension
  • Widget 改用 IntentConfiguration
  • 動態讀取 App Group location catalog
  • 支援 en-US / zh-Hant
  • Current Location 在繁中顯示為「所在地」

Location target

穩定 identifier:

  • current-location
  • region:<regionCode>

無效或未知 identifier 會 fail closed,不會自動 fallback 到所在地。

Per-location snapshot

目前天氣 snapshot schema 升級至 v5,新增:

sourceIdentifier

檔案範例:

  • WidgetSnapshots/current-weather/current-location.json
  • WidgetSnapshots/current-weather/region-242.json

每個 Widget instance 只讀取與自身 target 相符的 snapshot。

Migration

舊的:

WidgetSnapshots/current-weather.json

暫時保留 migration fallback,但只有來源可以被證明與 Widget target 相符時才會顯示。

安全與一致性

  • saved region identifier 僅接受 3 個 ASCII 數字。
  • 無效 identifier / 路徑穿越輸入會拒絕。
  • saved target 同時核對 sourceIdentifier 與 payload regionCode
  • schema v5 缺少 sourceIdentifier 會拒絕。
  • v2–v4 可維持 decode 相容,但無法證明來源時不會被錯誤顯示。
  • 未知未來 schema 會 fail closed。
  • current weather write 會依 sourceIdentifier 寫入對應 per-location cache。

已人工驗證

可同時建立多個 Widget,分別顯示不同地點,例如:

  • 所在地
  • 新莊區
  • 沙鹿區

且彼此 snapshot 不會互相覆蓋。

測試涵蓋

  • Intent dynamic options
  • location catalog decoding
  • identifier parsing / validation
  • path traversal protection
  • schema v2–v5 compatibility
  • per-location snapshot addressing
  • mismatched target rejection
  • migration fallback
  • multi-instance isolation
  • MethodChannel write contract
  • native snapshot file handling

不包含

目前 Widget Extension 尚不會自行向天氣 API 取得資料。

若該地點尚未由 DPIP App 載入並發布 snapshot,Widget 不會自行更新。

此 PR 不包含

  • native weather networking
  • CoreLocation self-refresh
  • WidgetKit refresh scheduling
  • stale-while-revalidate
  • Medium / Large Widget
  • hourly / weekly forecast UI
  • onboarding

Native self-refresh 將由下一支 PR:

feat/ios-widget-weather-refresh

處理。

PR Stack

依賴:

後續:

  • feat/ios-widget-weather-refresh
    • native weather fetch
    • Widget self-refresh(開發中)

此 PR 目前以 stacked PR 方式建立,base 是 feat/ios-widget-configuration。待父 PR 合併後再 rebase / retarget。

檢查清單

  • Per-widget location configuration 已建立
  • Intents Extension 已建立
  • Per-location snapshot cache 已建立
  • Schema v5 / migration / validation tests 已加入
  • 多 Widget 不同地點已人工驗證
  • 父 PR 合併後 rebase / retarget
  • 合併前重新執行 repository gates

Platform: ios

New(zh-Hant): 天氣小工具支援每個實例選擇所在地或已儲存地區,並使用獨立地區快取
New(en-US): Allow each iOS weather widget to select Current Location or a saved region with independent per-location snapshots
@YinCheng0106 YinCheng0106 self-assigned this Sep 20, 2026
@YinCheng0106 YinCheng0106 added the ios Issues or pull requests related to the iOS platform. label Sep 20, 2026
@YinCheng0106
YinCheng0106 added this pull request to stack #581 September 20, 2026 16:07
@YinCheng0106 YinCheng0106 added this to the v26.3 milestone Sep 20, 2026
@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.31%. Comparing base (cb1fb1a) to head (b058cf6).

☔ 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 September 22, 2026 03:01
Copilot AI balanced review requested due to automatic review settings September 22, 2026 03:01

This comment was marked as low quality.

@lowrt lowrt modified the milestones: v26.3, v26.4 Sep 23, 2026

This branch has not been deployed

No deployments
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