Repository navigation
Conversation
Platform: all New(zh-Hant): 地震報告圖可以儲存到相簿了 New(en-US): the report image can now be saved to your photo library
Codecov Report❌ Patch coverage is
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
這個 PR 做了什麼
地震報告詳情頁最下方的「地震報告圖」重新可以儲存了:圖片下方多一顆「儲存圖片」按鈕,按下後把中央氣象署的原始報告 PNG 寫進系統相簿,並用 SnackBar 回報結果(已儲存/沒有相簿權限/儲存失敗)。
這是 Discord 問題回報 ET-2026-0197 的需求(3.2.0 版可以存,26.x 改版後不見了)。
正式程式碼
lib/core/platform/photo_library.dart(新):gal的薄封裝。先hasAccess,沒有才requestAccess,被拒絕回permissionDenied(不丟例外給 UI);GalException一律映射成PhotoSaveOutcome,並用Log.error留下紀錄。lib/features/earthquake/presentation/pages/report_detail_page.dart:_ReportImageCard載入成功時,圖片下方加一顆下載圖示的TextButton。儲存中按鈕停用並顯示轉圈圈,避免連點寫兩張。ios/Runner/Info.plist:NSPhotoLibraryAddUsageDescription(只申請「加入相簿」,不讀整個相簿)。android/app/src/main/AndroidManifest.xml:WRITE_EXTERNAL_STORAGE加maxSdkVersion="28";Android 10+ 走 MediaStore 不需要權限,minSdk 26 才保留這行。pubspec.yaml/pubspec.lock:加gal ^2.3.3(2.3.1 起有 Swift Package Manager 支援,這個專案沒有 CocoaPods)。測試
test/core/platform/photo_library_test.dart:mockgal的 method channel,5 個案例(已授權、詢問後授權、拒絕、原生ACCESS_DENIED、其他原生錯誤)。l10n
reportDetailImageSave/reportDetailImageSaved/reportDetailImageSavePermission/reportDetailImageSaveFailed),12 個 ARB 都補齊,tool/check/l10n.sh通過。沒做的、要留意的
reportImageUrl),不是截圖,所以畫質是原始解析度。gal把名字當originalFilename傳、不帶副檔名;內容本身是 PNG,相簿顯示正常。flutter test時有 13 個test/tool/*失敗,原因是這台環境沒有 mise(腳本回 126),與這個改動無關;CI 有 mise 會正常執行。相關 issue
怎麼驗
dart analyze(全 repo):No issues foundflutter test test/core/platform/photo_library_test.dart:5 個通過tool/check/{l10n,layering,storage,wall_clock,pubspec_lock,notification_sounds,tooling}.sh全部通過tool/check/commits.sh origin/main..HEAD:OK檢查清單
tool/check/commits.sh origin/main..HEAD通過dart analyze與flutter test(本機能跑的部分)通過AppLocalizationsAppSpacing,但深色模式尚未在實機看過