Skip to content

feat(eew): add iOS EEW Live Activity prototype - #610

Draft
YinCheng0106 wants to merge 7 commits into
mainfrom
feat/ios-eew-live-activity-prototype
Draft

YinCheng0106 wants to merge 7 commits into
mainfrom
feat/ios-eew-live-activity-prototype

Conversation

@YinCheng0106

@YinCheng0106 YinCheng0106 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

加入 iOS 地震速報 Live Activity 用戶端原型,讓團隊先審查 ActivityKit 狀態、鎖定畫面、動態島及明確到波提醒。所有操作都來自 DEBUG 開發者頁面的本機 mock;這份 PR 保持 Draft,尚不具備正式 EEW 服務能力。

正式程式碼:

  • Phase 1:ios/Shared/EEWActivityAttributes.swift 定義活動與內容狀態;ios/Runner/EEWLiveActivityManager.swift、EEWLiveActivityPlugin.swift 及 lib/core/platform/eew_live_activity.dart 提供 mock 開始、報數更新、明確到波、結束與重啟後辨識既有活動。ios/DPIPWidgets/EEWLiveActivity.swift 提供 Lock Screen、Dynamic Island Expanded、Compact/Minimal,以及當地震度/報告最大震度、ETA 缺漏、TEST 提示與無障礙語意。
  • 註冊與資源:ios/Runner/AppDelegate.swift 僅在 DEBUG 註冊 Flutter bridge;Info.plist 宣告 Live Activities 支援。沿用 DPIPWidgetsBundle.swift 的既有 extension,project.pbxproj 將 EEW 共用檔案加入 Runner 與 DPIPWidgetsExtension,並加入原生測試及提醒字串資源;沒有新增 extension target。ios/DPIPWidgets/Localizable.xcstrings 僅新增 EEW 使用的字串,既有 Weather Widget 字串未變動。
  • Phase 2A:明確的 waveArrived 更新可附帶 AlertConfiguration,提醒文案由 ios/Runner/EEWLiveActivityAlerts.xcstrings 提供。lib/features/settings/presentation/pages/developer_page.dart 提供 DEBUG 立即與延遲 8 秒到波提醒 QA;延遲工作處理重複排程、取消、活動結束及背景工作到期,背景工作只結束一次。Triggered 代表 ActivityKit 更新已送出,不等於系統已呈現提醒、展開動態島或播放音效。
  • 自適應動態島:ios/Shared/EEWIslandLayout.swift 依系統提議的寬度選擇完整候選;iOS 27 寬度限制提示有 availability guard,較舊版本使用尺寸選擇。Compact/Minimal 依序減少裝飾及資訊,保留完整弱/強分類,最後退為圖示,避免裁切文字。
  • 彩色震度徽章:ios/Shared/EEWPresentation.swift 沿用 DPIP 標準視覺的 0–9 離散震度色票,保留 5弱、5強、6弱、6強,依背景選擇黑/白文字。徽章、完整純文字及波形圖示依可用寬度退讓;TEST 裝飾退讓時仍保留測試用途的無障礙提示。
  • 倒數寬度與對齊:以隱藏的等寬數字包絡量測並預留倒數寬度,將實際 timer 置中,安全留白納入 fitting。小數秒先向上取整再計算分鐘位數,修正 599.9 秒顯示 10:00 時的包絡不足。

倒數保留系統管理的 m:ss:Text(timerInterval:) 已在受測情境中呈現可靠的自動倒數更新。秒數限定格式曾被調查,但其背景更新、總秒數格式、零點停止及 OS 相容性未獲充分驗證,因此保留已驗證的系統 timer。完整倒數放不下時,自適應佈局改用時鐘圖示。0:00 與時鐘圖示都不表示地震波已抵達;到波必須由明確狀態更新設定 waveArrived。 沒有新增每秒 Timer、每秒 Activity.update 迴圈或每秒推播。

測試與正式程式碼分開:

  • ios/RunnerTests/EEWPresentationTests.swift 涵蓋震度色票、至少 4.5:1 的徽章文字對比、弱/強與 spoken mapping、正常/受限/極窄寬度、大字級、ETA 缺漏、明確到波、9:59/10:00、小數秒進位、時鐘 fallback 與倒數置中。timer 字形以 ImageRenderer 比較受限與完整參考圖,另用獨立 m:ss 對照確保 fixture 未退化為只有零秒。
  • ios/RunnerTests/EEWLiveActivityManagerTests.swift 涵蓋 silent/alert 到波、重複與非有效活動拒絕、到波保留、提醒資源,以及可控制延遲的排程、取消、背景到期與清理。倒數過期不會自動推導到波或觸發提醒。

本 PR 未實作:正式 EEW 事件串接、伺服器端活動生命週期、push-to-start token 註冊、遠端 ActivityKit 更新、正式 APNs 傳送、正式端到端驗證。Activity.request 使用 pushType: nil;沒有後端 API 變更,也沒有修改無關 Weather Widget 功能、相依套件或生成檔。

相關 issue

怎麼驗

本次於 2026-10-15,針對 HEAD 19317cfd926e1f105cf60fee8338637a4fff0e19 執行:

  • 已 fetch 最新 origin/main(9645d7b07c9b43653e0bbb95c2275eada880f6b5);分支領先 4、落後 0,沒有 merge commit。
  • DPIP_NO_CACHE=1 tool/commit.sh --push 通過,實際執行完整 tool/check.sh:格式檢查 1,090 個檔案、0 變更,靜態分析無問題;tooling、l10n、lockfile、通知音效、build info、Widget 鄉鎮資源、layering、storage、codegen 全部通過;codegen 寫入 0 個輸出;Flutter coverage 測試 3,151 通過、10 跳過。
  • tool/check/commits.sh origin/main..HEAD 獨立重跑通過,四則 commit 訊息有效。git diff --check、staged 及 origin/main...HEAD 的 whitespace 檢查通過。
  • tool/dev/build.sh ios --debug --simulator 建置成功;產物包含 DPIPWidgetsExtension 與 DPIPWidgetIntentsExtension,Live Activities 宣告正確。已核對共用 EEW sources、Widget 同步群組、原生 tests 及提醒資源的 target membership。
  • tool/dev/test_ios.sh 於 iPhone 18 Pro/iOS 27.0 模擬器完整執行,使用獨立 DerivedData 與 result bundle;xcresulttool get test-results summary 確認 400 通過、0 失敗、0 跳過。未將既有 iOS 18.6 紀錄當成本次重跑結果。
  • 編譯仍有套件及測試 framework/deployment target 警告,未抑制警告或進行範圍外修正。原生完整測試指令退出碼為 0,result bundle 結果為 Passed。
  • 工作目錄與暫存區保持乾淨,HEAD 與四則提交未改寫;8 筆既有 stash 及其 reflog 均保留。檢查產生的 build_info.g.dart 已還原原始位元組,SHA-256、index blob 與 skip-worktree 旗標核對一致。沒有提交生成檔、QA 產物或建置輸出。

既有手動模擬器 QA(2026-10-14 草稿紀錄):使用者回報在 iPhone 18 Pro/iOS 27 模擬器確認彩色震度徽章、雙/三活動佈局、系統倒數持續更新與窄幅時鐘 fallback,受測組合中原有裁切已排除。本次 PR 準備未重做這些手動情境。像素/尺寸測試不等同於 SpringBoard 自主更新、提醒自動展開或 VoiceOver 實際操作驗證。沒有實機測試。

本次 diff 未修改 EEW 推估、警報門檻、一般通知路徑或背景定位;完整 Dart 回歸檢查涵蓋既有測試。提醒自動展開、音效、VoiceOver 操作、實機背景行為及正式 APNs 仍待驗證。UI 前後及深色模式截圖尚未附上,列為 Draft 審查待補項目。

遠端 GitHub Actions 需在 PR 建立後另行核對;這份說明不把本機成功當成遠端 CI 已通過。

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事(Phase 1、Phase 2A、Swift actor boundary 修正、自適應呈現修正各自獨立)
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過
    —— 實際依 repository 規範使用 tool/ 腳本。
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
    —— 原生文字使用 String Catalog;DEBUG QA 控制明確標示 l10n-ignore,尚未完成 Flutter 文案正式化。
  • 有 UI 變更的話:用的是 AppSpacing / AppRadius / AppMotion,深色模式看過,文字對比度可接受
    —— Flutter 開發者頁沿用 tokens,原生 SwiftUI 徽章對比有測試;未取得獨立深色模式 QA 與 UI 前後截圖證據。

Platform: ios

New(zh-Hant): 開發者頁面可測試地震速報即時動態,檢視鎖定畫面與動態島的震度、倒數及資料未提供狀態
New(en-US): preview mock EEW Live Activities from the developer page with intensity, countdown, and unavailable states on the Lock Screen and Dynamic Island
Platform: ios

New(zh-Hant): 開發者頁面可立即或延遲 8 秒測試地震速報即時動態的到波提醒
New(en-US): test EEW Live Activity arrival alerts immediately or after an 8-second delay from the developer page
Platform: ios

Fix(zh-Hant): 修正地震速報延遲抵達提醒的背景工作處理
Fix(en-US): fix background task handling for delayed EEW arrival alerts
Platform: ios

Fix(zh-Hant): 地震速報動態島依可用寬度顯示彩色震度徽章與完整倒數,空間不足時改用時鐘圖示,避免文字裁切
Fix(en-US): show colored intensity badges and complete countdowns in the EEW Dynamic Island, with a clock fallback when space is limited to prevent clipping
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.45%. Comparing base (9645d7b) to head (5441f1d).

☔ 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 self-assigned this Oct 14, 2026
@YinCheng0106 YinCheng0106 added the ios Issues or pull requests related to the iOS platform. label Oct 14, 2026
@YinCheng0106 YinCheng0106 added this to the V26.5 milestone Oct 14, 2026
@YinCheng0106 YinCheng0106 linked an issue Oct 14, 2026 that may be closed by this pull request
Platform: ios

Fix(zh-Hant): 修正地震速報動態島在 iOS 26 SDK 的建置相容性
Fix(en-US): restore earthquake alert Dynamic Island build compatibility with the iOS 26 SDK
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 4 issue(s) in this PR.

  • ✅ Successfully posted inline: 4 comment(s)

Comment thread lib/features/settings/presentation/pages/developer_page.dart
Comment thread lib/features/settings/presentation/pages/developer_page.dart
Comment thread lib/features/settings/presentation/pages/developer_page.dart
Comment thread lib/features/settings/presentation/pages/developer_page.dart
Platform: ios

Fix(zh-Hant): 修正地震速報開發者測試遇到非預期錯誤時無法正常顯示錯誤與恢復操作的問題

Fix(en-US): fix error reporting and recovery when EEW developer mock controls encounter unexpected failures

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.

能有彈出通知來倒數計時EEW抵達的時間

1 participant