Skip to content

試験的機能としてポートレートモードを追加 - #6204

Merged
TinyKitten merged 6 commits into
devfrom
claude/portrait-mode-optimization-mvcgpj
Jun 12, 2026
Merged

TinyKitten merged 6 commits into
devfrom
claude/portrait-mode-optimization-mvcgpj

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 12, 2026 •

Copy link
Copy Markdown
Member

概要

変更の種類

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

変更内容

  • 設定画面の「通知」直下に「試験的機能」メニューを新設(AppSettings.tsx。カナリアリリース(isDevApp)限定で表示。項目挿入に強いよう、パーソナライズ節のレンダリングを map ベースに整理)
  • ポートレートモードをトグルできる試験的機能設定画面 ExperimentalSettings.tsx を追加(portraitModeEnabledAtom + AsyncStorage @TrainLCD:portraitModeEnabled で永続化し、起動時に Permitted.tsx で読み込み。保存失敗時はatom状態をロールバック)
  • ポートレートモード有効かつ端末が縦向きの間、Main画面をテーマ非依存の縦画面最適化レイアウト PortraitMain.tsx に切り替え(路線カード/状態テキスト+駅名+ナンバリング/停車駅の縦リスト。横向きに戻すと従来表示。閲覧専用の簡易表示とし、路線・種別変更の導線は対象外)
  • 日英の翻訳キーと、ユニットテストを追加(ExperimentalSettings.test.tsx: トグル永続化・保存失敗時ロールバック、PortraitMain.test.tsx: 表示要素・通過駅ラベル・データ未取得時の分岐)

テスト

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

関連Issue

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

https://claude.ai/code/session_01Nv3odSWJubXwE8s4jewpQw

Summary by CodeRabbit

  • 新機能

    • 縦向き表示(Portrait)専用レイアウトを追加。端末が縦向きかつ有効時に専用画面で主要駅情報を表示(通過駅表示を含む)。
    • 実験設定画面を追加し、縦向きモードをトグルで有効/無効にできる。
  • 多言語対応

    • 実験設定、縦向きモードの見出し/説明、通過ラベルの日本語/英語文言を追加。
  • 改善

    • 設定画面のパーソナライズ項目表示を整理し、起動時に保存済み設定を反映。
  • テスト

    • 縦向きモード関連の単体テストと表示テストを追加。

@TinyKitten TinyKitten self-assigned this Jun 12, 2026
@github-actions github-actions Bot added the react label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19f3568a-495a-4561-9a50-ad7b779e156e

📥 Commits

Reviewing files that changed from the base of the PR and between d0fde57 and 8fa48a8.

📒 Files selected for processing (1)
  • src/screens/ExperimentalSettings.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/screens/ExperimentalSettings.test.tsx

📝 Walkthrough

Walkthrough

ポートレートモード表示を試験的機能として実装した PR。Jotai 状態管理、実験設定画面、AsyncStorage 永続化、ポートレイト専用 UI、メイン画面の条件分岐、多言語対応、および AppSettings への項目追加を含む。

Changes

Portrait Mode Experimental Feature

Layer / File(s) Summary
状態管理と設定基盤
src/store/atoms/experimental.ts, src/constants/asyncStorage.ts, src/components/Permitted.tsx
Jotai で portraitModeEnabledAtom を定義し、AsyncStorage キー PORTRAIT_MODE_ENABLED を追加。起動時に loadSettings でストレージから値を読み込み、状態に反映。
実験設定画面の実装
src/screens/ExperimentalSettings.tsx, src/screens/ExperimentalSettings.test.tsx
ポートレートモード切り替え UI、トグル押下時の状態更新と AsyncStorage 保存、失敗時のロールバックとエラー表示、テストケース(ON/OFF 遷移と保存検証)を実装。
ポートレイト UI コンポーネント
src/components/PortraitMain.tsx, src/components/PortraitMain.test.tsx
縦画面専用レイアウト実装。静的カラーパレット、包括的スタイルシート、路線情報ヘッダ、駅表示、停車駅スクロールリスト、通過駅ラベル、駅番号表示と表示テスト。
設定画面への実験項目統合
src/screens/AppSettings.tsx
実験設定項目を personalizeItems に追加。パーソナライズセクション描画をループ方式に置き換え、スポットライト計測用 View ラッパーを item.id で選択。
ナビゲーションとメイン画面への統合
src/stacks/MainStack.tsx, src/screens/Main.tsx
MainStack へ ExperimentalSettings ルート追加。Main 画面に縦向き&ポートレートモード有効時の PortraitMain 描画分岐を追加(DevOverlay の重畳も維持)。
多言語対応
assets/translations/en.json, assets/translations/ja.json
実験設定、ポートレートモード、通過駅ラベルの翻訳キーを英日両言語で追加。

Sequence Diagram(s)

sequenceDiagram
  participant UI as ExperimentalSettings UI
  participant Handler as handleToggleChange
  participant Atom as portraitModeEnabledAtom
  participant AsyncStorage
  UI->>Handler: トグル操作
  Handler->>Atom: set(newBoolean)
  Handler->>AsyncStorage: setItem(PORTRAIT_MODE_ENABLED, 'true'/'false')
  AsyncStorage-->>Handler: 成功/失敗
  Handler-->>UI: 更新完了 / エラー表示
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6030: 両 PR とも src/screens/Main.tsx のポートレイト時レイアウト分岐に関連する変更があり、コードレベルで影響し得ます。

Suggested labels

react

Poem

縦の画面、駅灯る夜明け 🚃
うさぎがぴょんとトグルを押すよ🐇
設定は保存、風に揺れて
試験の旅路、景色を並べる
小さな機能、大きな一歩 ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは試験的機能としてのポートレートモード追加を正確に要約しており、変更セット全体の主要な目的を明確に表現しています。
Description check ✅ Passed PR 説明は必須セクション(概要、変更の種類、変更内容、テスト)をすべて記入しており、詳細な変更内容とテスト実施の確認がされています。
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/portrait-mode-optimization-mvcgpj

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

@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: 2

🧹 Nitpick comments (1)
src/components/PortraitMain.tsx (1)

1-393: ⚡ Quick win

テストファイルを追加することを推奨します。

ポートレート UI の新規追加に伴い、ユニットテストまたは統合テストを同階層に .test.tsx として配置することで、停車駅リストのレンダリング、通過駅判定、駅番号表示の条件分岐、乗り換え線ドット表示などの重要なロジックの正確性を保証できます。

コーディングガイドラインに基づき、テストファイルは対象モジュールと同じ階層に配置してください。

🤖 Prompt for 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.

In `@src/components/PortraitMain.tsx` around lines 1 - 393, Add a new test file
PortraitMain.test.tsx alongside PortraitMain.tsx that mounts the PortraitMain
component (and/or renders the StopRow via PortraitMain) and covers: rendering
the stop list from leftStations, pass/train-stop branching using getIsPass,
station numbering display via NumberingIcon when useStationNumberIndexFunc
yields a station number, and transfer dot rendering using
useTransferLinesFromStation (including limiting to 8). Mock hooks
useHeaderCommonData, useCurrentLine, useCurrentTrainType,
useStationNumberIndexFunc, useTransferLinesFromStation and the leftStationsAtom
to control scenarios for current/first/last stops, pass vs stop, with/without
stationNumber and transfer lines; assert DOM/text presence, conditional elements
(passLabel, stopNameCurrent, stopNumbering, transferDots), and that line/train
colors are applied.

Source: Coding guidelines

🤖 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 `@src/screens/ExperimentalSettings.tsx`:
- Around line 97-109: The optimistic update in handleTogglePortraitMode
currently sets the atom via setPortraitModeEnabled(flag) before awaiting
AsyncStorage.setItem but doesn't revert the atom on failure; fix this by
capturing the previous state (e.g., const prev = portraitModeEnabled) before
calling setPortraitModeEnabled(flag), then try to save with AsyncStorage.setItem
and on catch call setPortraitModeEnabled(prev) to rollback and still show the
Alert; reference handleTogglePortraitMode, setPortraitModeEnabled, and
AsyncStorage.setItem when making the change.

In `@src/screens/Main.tsx`:
- Around line 697-706: The portrait-mode branch currently returns only
<PortraitMain /> (plus DevOverlay) so SelectBoundModal and the
bottomState-driven TypeChangeNotify never render; either (A) render
<SelectBoundModal ... /> and the TypeChangeNotify conditional (driven by
bottomState === 'TYPE_CHANGE') alongside <PortraitMain /> in the portrait-mode
return so the existing modal/notify flow is preserved, or (B) move the
modal/notify rendering into PortraitMain and wire up the same props/handlers
(state getters/setters, e.g. bottomState, onSelectBound/onTypeChange) so
portrait has equivalent interaction; locate usage points by searching for
SelectBoundModal, TypeChangeNotify, bottomState, portraitModeEnabled,
windowHeight/windowWidth and ensure required props/state/handlers are passed
through or lifted into PortraitMain.

---

Nitpick comments:
In `@src/components/PortraitMain.tsx`:
- Around line 1-393: Add a new test file PortraitMain.test.tsx alongside
PortraitMain.tsx that mounts the PortraitMain component (and/or renders the
StopRow via PortraitMain) and covers: rendering the stop list from leftStations,
pass/train-stop branching using getIsPass, station numbering display via
NumberingIcon when useStationNumberIndexFunc yields a station number, and
transfer dot rendering using useTransferLinesFromStation (including limiting to
8). Mock hooks useHeaderCommonData, useCurrentLine, useCurrentTrainType,
useStationNumberIndexFunc, useTransferLinesFromStation and the leftStationsAtom
to control scenarios for current/first/last stops, pass vs stop, with/without
stationNumber and transfer lines; assert DOM/text presence, conditional elements
(passLabel, stopNameCurrent, stopNumbering, transferDots), and that line/train
colors are applied.
🪄 Autofix (Beta)

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: dd7eea95-3816-4f4a-b52e-a654abe01dad

📥 Commits

Reviewing files that changed from the base of the PR and between 374e26b and e87e113.

📒 Files selected for processing (11)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/Permitted.tsx
  • src/components/PortraitMain.tsx
  • src/constants/asyncStorage.ts
  • src/screens/AppSettings.tsx
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/ExperimentalSettings.tsx
  • src/screens/Main.tsx
  • src/stacks/MainStack.tsx
  • src/store/atoms/experimental.ts

Comment thread src/screens/ExperimentalSettings.tsx Resolved
Comment thread src/screens/Main.tsx Resolved

@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 `@src/screens/ExperimentalSettings.test.tsx`:
- Around line 65-86: Mock Alert.alert in the test setup and assert it and
console.error are called when AsyncStorage.setItem rejects: add a mock for
Alert.alert (and restore it after) before running the test (or in the file-level
mocks), ensure the test case that simulates AsyncStorage.setItem rejecting still
spies on console.error and then assert both Alert.alert and console.error were
invoked after the rollback, referencing the existing AsyncStorage.setItem mock,
the renderWithStore/getByLabelText interaction, and the portraitModeEnabledAtom
state check to locate where to add the assertions and mock restore calls.
🪄 Autofix (Beta)

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: 6d4acdba-11bd-41d7-b3f5-7817e23ab69c

📥 Commits

Reviewing files that changed from the base of the PR and between e5ea18e and d0fde57.

📒 Files selected for processing (3)
  • src/components/PortraitMain.test.tsx
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/ExperimentalSettings.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/screens/ExperimentalSettings.tsx

@TinyKitten
TinyKitten merged commit 03e76a7 into dev Jun 12, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/portrait-mode-optimization-mvcgpj branch June 12, 2026 07:50
@TinyKitten TinyKitten mentioned this pull request Jun 12, 2026
4 of 9 tasks
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