Skip to content

iOSのプリセットウィジェットを高さに収まるだけ表示しsystemSmallは縦積みにする - #6589

Merged
TinyKitten merged 2 commits into
devfrom
claude/home-widget-preset-stations-7u8cxv
Aug 7, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/home-widget-preset-stations-7u8cxv

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

概要

iOS のプリセットウィジェットが余白を持て余していた点を改善しました。#6585 / #6586 のフォローアップです。

  • systemMedium / systemLarge: 件数の決め打ちをやめ、実際の描画高に収まるだけ行を詰めるようにしました。
  • systemSmall: 1 件表示は維持しつつ、横一列だった「始発駅 → 終着駅」を縦積みに変更し、余白を使い切るようにしました。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他(UI 調整)

変更内容

表示件数を実測ベースに変更

これまでは compactRowCount = 2 / largeRowCount = 5 とファミリーごとに決め打ちしていました。この方式では端末サイズ差で余白が出たり見切れたりするため、GeometryReader で実際の描画高を測り、rowHeight / rowSpacing / headerHeight から収まる行数を求める形に変更しています。

行の高さは PresetsWidgetRow に .frame(height: rowHeight) を付けて固定したので、計算値と実際の描画が一致します。Android 側で高さを dp で見積もって破綻した経緯がありますが、そちらは OS から渡る値が端末・ランチャー・向きで変わるのが原因でした。iOS は自分が指定した行高を自分で数えるだけなのでずれません。

systemSmall を縦積みに変更

systemSmall はウィジェット全体が単一のタップ領域で、行ごとの Link が個別のタップ先になりません。行を並べても 1 件しか開けないため件数は 1 件のままとし、代わりにレイアウトを作り直しました(PresetsWidgetFeatured)。

正方形の領域に「始発駅 → 終着駅」を横一列で置くと横幅で先に頭打ちになり、駅名がすぐ省略されます。そこで以下の順に縦へ積み、1 駅あたりの幅をフルに使うようにしました。

⬤ JY          ← ナンバリングサークル(36pt)
通勤           ← プリセット名 (caption, secondary)
東京           ← 始発駅 (title3, bold)
 ↓
新宿           ← 終着駅 (title3, bold)

Spacer で余白を均し、上下どちらかに寄った空きが残らないようにしています。駅名が未取得のプリセットでは従来どおり路線名のみを表示します。

その他

  • ウィジェットギャラリーのプレビュー用ダミーデータを 2 件から 6 件に増やしました。systemLarge のプレビューが空きだらけになるのを防ぐためです。
  • PresetsWidgetItem.hasStations を追加し、駅名の有無判定を routeDescription と縦積み表示で共有しています。
  • docs/home-screen-widgets.md のサイズ・表示件数の記述を更新しました。

Android 側は変更していません。

回帰リスクと緩和

  • 表示件数の算出: rowHeight などの定数はレイアウトの実寸と対応させる必要があるため、行の見た目を変えたら合わせて更新する旨をコメントとドキュメントに明記しています。GeometryReader の高さが 0 以下の場合は 1 行にフォールバックします。
  • タップ挙動: systemMedium / systemLarge の行ごとの Link、systemSmall の widgetURL はいずれも従来の経路のままで、ディープリンクの組み立て(presetURL)にも変更はありません。
  • 同期処理: JS 側・App Group への書き込み経路には一切触れていません。

ローカルで実行したコマンド

npm run lint      # Checked 624 files / エラーなし
npm test          # 212 suites / 2219 tests 全て pass
npm run typecheck # エラーなし
npx markdownlint-cli2 docs/home-screen-widgets.md  # 指摘なし

本 PR は iOS の Swift とドキュメントのみの変更で、JS/TS には手を入れていません(上記は影響が無いことの確認として実行)。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

ネイティブビルド環境が無いため、実機での表示確認は未実施です。

関連Issue

#6585 / #6586 のフォローアップ

スクリーンショット(任意)

ネイティブビルド環境が無いため未添付です。


Generated by Claude Code

Summary by CodeRabbit

  • 改善

    • iOSウィジェットの表示件数を、ウィジェットの実際の高さに合わせて自動調整するよう改善しました。
    • 中サイズ・大サイズでは、画面に収まる分だけプリセットを表示します。
    • 小サイズでは、注目プリセットを1件、縦型レイアウトで表示します。
    • 駅名が登録されていない場合は、路線名を表示するようになりました。
  • ドキュメント

    • ウィジェットの固定表示上限に関する案内を更新しました。

@TinyKitten TinyKitten self-assigned this Aug 7, 2026
@github-actions github-actions Bot added the ios label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7ec0992-9632-48e9-be9f-5627f2afc385

📥 Commits

Reviewing files that changed from the base of the PR and between 8888653 and 2788527.

📒 Files selected for processing (2)
  • docs/home-screen-widgets.md
  • ios/RideSessionActivity/PresetsWidget.swift
📝 Walkthrough

Walkthrough

iOSウィジェットの表示件数を固定値から実描画高に基づく計算へ変更しました。systemSmall は専用ビューで1件を表示し、systemMedium と systemLarge は収容可能な行数を表示します。駅名がない場合は路線名を表示します。

Changes

ウィジェットレイアウト変更

Layer / File(s) Summary
表示仕様とプリセットデータ
ios/RideSessionActivity/PresetsWidget.swift
レイアウト定数と駅情報の表示判定を追加しました。systemLarge用のプレースホルダーを4件追加しました。
systemSmall専用表示
ios/RideSessionActivity/PresetsWidget.swift
路線円、プリセット名、駅名または路線名を縦方向に表示するPresetsWidgetFeaturedを追加しました。
実描画高に基づく一覧表示
ios/RideSessionActivity/PresetsWidget.swift, docs/home-screen-widgets.md
GeometryReaderで高さを測定し、rowHeightとrowSpacingから表示行数を計算します。固定表示上限の説明を削除しました。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PresetsWidget
  participant GeometryReader
  participant PresetsWidgetFeatured
  participant PresetLink
  PresetsWidget->>GeometryReader: ウィジェット高を測定
  GeometryReader->>PresetsWidget: rowCountを計算
  PresetsWidget->>PresetsWidgetFeatured: systemSmallを1件表示
  PresetsWidget->>PresetLink: systemMedium/systemLargeを行数分表示
Loading

Possibly related PRs

  • TrainLCD/MobileApp#6573: 既存のiOSホーム画面ウィジェットを追加したPRで、本変更はそのレイアウトと行数表示を更新します。

Poem

ぴょんと跳ねれば、行数が決まる
高さを測って、枠にぴたり
小さな窓には、ひとつを縦に
駅名がなくても、路線を表示
うさぎも便利で、耳をすませる 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、表示件数の動的計算とsystemSmallの縦積みという主要変更を明確に示しています。
Description check ✅ Passed 概要、変更内容、テスト結果、関連Issue、未実施の実機確認を含み、テンプレートの必須項目を十分に満たしています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/home-widget-preset-stations-7u8cxv

Comment @coderabbitai help to get the list of available commands.

@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ios/RideSessionActivity/PresetsWidget.swift`:
- Around line 31-33: Update the header view construction and sizing logic around
the header and rowCount(for:) so the rendered header height always matches
headerHeight (18pt): constrain the header to that fixed height and limit its
title to one line, ensuring the row-count calculation and final-row layout
cannot reserve less space than the header occupies.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c8ad0b8f-acd3-4c0c-9dc8-6f4aea33cce4

📥 Commits

Reviewing files that changed from the base of the PR and between 7e5ecea and 8888653.

📒 Files selected for processing (2)
  • docs/home-screen-widgets.md
  • ios/RideSessionActivity/PresetsWidget.swift

@TinyKitten
TinyKitten merged commit 4799900 into dev Aug 7, 2026
3 checks passed
@TinyKitten
TinyKitten deleted the claude/home-widget-preset-stations-7u8cxv branch August 7, 2026 02:47
This was referenced Aug 7, 2026
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