Skip to content

fix: card - #523

Merged
whes1015 merged 1 commit into
mainfrom
fix-earthquake-report
Aug 11, 2026
Merged

fix: card#523
whes1015 merged 1 commit into
mainfrom
fix-earthquake-report

Conversation

@PiscesXD

Copy link
Copy Markdown
Member

修復:
地震報告 UI 顯示的排版問題

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

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

  • ✅ Successfully posted inline: 3 comment(s)

Comment on lines +446 to +449
if (_wasExpanded && !expanded) {
_scrollController?.jumpTo(0);
}
_wasExpanded = expanded;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[other · medium]
_scrollController 是在 DraggableScrollableSheetbuilder 執行時才被賦值,但在 onNotification 回調中會被使用。這存在生命週期上的風險:如果在 builder 尚未執行、或 Widget 正在銷毀/重建的階段,調用 _scrollController?.jumpTo(0),可能會因為 scrollController 為 null 或處於不穩定狀態而引發異常,或與 DraggableScrollableSheet 的內部滾動邏輯產生衝突。建議在調用前確保 _scrollController 已正確初始化且可控。

Comment on lines +479 to +482
final revealProgress =
((extent - _ReportSheet.peek) /
(_ReportSheet._expanded - _ReportSheet.peek))
.clamp(0.0, 1.0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[other · low]
revealProgress 的計算公式 ((extent - _ReportSheet.peek) / (_ReportSheet._expanded - _ReportSheet.peek)) 若分母為零(即 _expanded 等於 peek),會導致除以零的數學錯誤。雖然目前常量定義中 _expanded (1.0) 與 peek (0.32) 不相等,但為了代碼的健壯性,建議增加分母檢查或使用更安全的計算方式。

Suggestion:

Suggested change
final revealProgress =
((extent - _ReportSheet.peek) /
(_ReportSheet._expanded - _ReportSheet.peek))
.clamp(0.0, 1.0);
final revealProgress = (
(_ReportSheet._expanded - _ReportSheet.peek) > 0
? (extent - _ReportSheet.peek) / (_ReportSheet._expanded - _ReportSheet.peek)
: 0.0
).clamp(0.0, 1.0);

Comment on lines +507 to +526
Stack(
alignment: Alignment.topCenter,
children: [
Opacity(
opacity: revealProgress,
child: IgnorePointer(
ignoring: !expanded,
child: _expandedContent(context, report),
),
),
if (peekOpacity > 0)
Opacity(
opacity: peekOpacity,
child: IgnorePointer(
ignoring: expanded,
child: _peekContent(context, report),
),
),
],
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[other · medium]
Stack 中同時渲染 _expandedContent_peekContent 並進行透明度過渡,若內容包含複雜組件(例如 _ReportImageCard 中的圖片),在拖動過程中可能會因為同時對兩個複雜的 Widget Tree 進行重繪與透明度計算,而造成高負載,導致動畫掉幀(jank)。建議評估組件複雜度,或考慮是否能優化渲染路徑。

@whes1015
whes1015 merged commit af17463 into main Aug 11, 2026
6 checks passed
@whes1015
whes1015 deleted the fix-earthquake-report branch August 11, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants