Skip to content

端末が portrait のままでも Main 画面を横長表示で維持する - #6030

Merged
TinyKitten merged 2 commits into
devfrom
feature/keep-landscape-on-portrait
May 25, 2026
Merged

TinyKitten merged 2 commits into
devfrom
feature/keep-landscape-on-portrait

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 25, 2026 •

Copy link
Copy Markdown
Member

概要

端末側で画面回転がロックされている等で OS が portrait のままになっても、Main 画面を横長レイアウトで表示し続けるようにする。

変更の種類

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

変更内容

  • Main 画面のラッパー View で物理 portrait を検出したときだけ 90deg 回転 transform を当てて横長表示を維持
  • ScreenOrientation.lockAsync / unlockAsync の呼び出しを全廃 (Main / Permitted / useQuickActions / SelectLineScreen)
  • 未使用となった useLockLandscapeOnActive と対応するテストを削除
  • 回転内サブツリーが論理的な横長サイズで採寸できるよう useLandscapeWindowDimensions フックを新設し、useScale および Main 配下で useWindowDimensions を使っていた箇所 (Header* / LineBoard* / Transfers / TypeChangeNotify / TrainTypeBox / DevOverlay / PadArch / Marquee / shared StationName) を一括置換

テスト

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

関連Issue

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

Summary by CodeRabbit

  • Refactor
    • ランドスケープ前提の画面寸法取得フックを導入し、複数コンポーネントのレイアウト計算を横向き基準へ統一しました。
    • システム向きロック呼び出しを削除し、レイアウトで横表示を維持する方式へ切替えました。
  • Tests
    • テストモックをランドスケープ寸法に合わせて更新。該当フックのテストやいくつかのローテーション関連テストを整理しました。

Review Change Stack

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

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

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: a3936452-a00e-422e-81f7-7802b6f5c534

📥 Commits

Reviewing files that changed from the base of the PR and between a78a4f0 and da665dd.

📒 Files selected for processing (24)
  • jest.setup.js
  • src/components/DevOverlay.test.tsx
  • src/components/Header.test.tsx
  • src/components/HeaderE231.test.tsx
  • src/components/HeaderEast/HeaderEast.test.tsx
  • src/components/HeaderJRKyushu.test.tsx
  • src/components/HeaderJRWest.test.tsx
  • src/components/HeaderLED.test.tsx
  • src/components/HeaderOdakyu.test.tsx
  • src/components/HeaderSaikyo.test.tsx
  • src/components/HeaderTY.test.tsx
  • src/components/HeaderTokyoMetro.test.tsx
  • src/components/LineBoard.test.tsx
  • src/components/LineBoardEast.test.tsx
  • src/components/LineBoardJO.test.tsx
  • src/components/LineBoardJRKyushu.test.tsx
  • src/components/LineBoardLED.test.tsx
  • src/components/LineBoardSaikyo.test.tsx
  • src/components/LineBoardToei.test.tsx
  • src/components/LineBoardWest.test.tsx
  • src/components/LineBoardYamanotePad.test.tsx
  • src/components/SelectBoundModal.render.test.tsx
  • src/components/TrainTypeBoxE231.test.tsx
  • src/components/TypeChangeNotify.test.tsx
✅ Files skipped from review due to trivial changes (3)
  • jest.setup.js
  • src/components/HeaderSaikyo.test.tsx
  • src/components/LineBoardToei.test.tsx

📝 Walkthrough

Walkthrough

ウィンドウ dimensions 取得を landscape-aware に統一し、expo-screen-orientation への依存を廃止。新 useLandscapeWindowDimensions フックで物理サイズを正規化し、16のコンポーネントで置き換え。Main.tsx で CSS-based な回転表示維持に切り替え。

Changes

Landscape-aware dimensions と向き制御リファクタリング

Layer / File(s) Summary
Landscape-aware dimension hook の実装とエクスポート
src/hooks/useLandscapeWindowDimensions.ts, src/hooks/index.ts
useLandscapeWindowDimensions フックを新規作成し、useWindowDimensions() が返す width/height を Math.max/Math.min で長辺/短辺として正規化して返す。hooks index から useLockLandscapeOnActive をエクスポート削除、新フックをエクスポート追加。
useScale フックの dimension 入力更新
src/hooks/useScale.ts
myWidth/myHeight 取得元を useWindowDimensions から useLandscapeWindowDimensions に切り替え。react-native import を useWindowDimensions から PixelRatio に変更。スケール計算と依存配列は維持。
コンポーネント系での dimension hook 置き換え
src/components/DevOverlay.tsx, src/components/HeaderEast/HeaderEast.tsx, src/components/HeaderLED.tsx, src/components/LineBoard/shared/components/StationName.tsx, src/components/LineBoardE231.tsx, src/components/LineBoardEast.tsx, src/components/LineBoardJO.tsx, src/components/LineBoardJRKyushu.tsx, src/components/LineBoardSaikyo.tsx, src/components/LineBoardToei.tsx, src/components/LineBoardWest.tsx, src/components/Marquee.tsx, src/components/PadArch.tsx, src/components/TrainTypeBox.tsx, src/components/TransfersYamanote.tsx, src/components/TypeChangeNotify.tsx
Header、LineBoard テーマ群、その他 UI コンポーネント計16ファイルで useWindowDimensions を useLandscapeWindowDimensions に統一。import 調整と各コンポーネント内の dim/windowWidth/windowHeight 参照先をランドスケープ用に置き換え。レイアウト計算ロジック自体は維持。
Screen orientation 制御の削除と回転表示維持の刷新
src/screens/Main.tsx, src/hooks/useQuickActions.ts, src/components/Permitted.tsx, src/screens/SelectLineScreen.tsx, src/hooks/useLockLandscapeOnActive.ts, src/hooks/useLockLandscapeOnActive.test.tsx, src/screens/SelectLineScreen.render.test.tsx
expo-screen-orientation の lockAsync/unlockAsync 呼び出しを全て削除。Main.tsx で useWindowDimensions から landscapeKeepStyle (絶対配置+90deg 回転) を useMemo で生成し、landscape 表示を維持。isRotated 状態と依存する複数の notification useEffect を削除・簡素化。useLockLandscapeOnActive フック実装とテストを削除。SelectLineScreen でのマウント時 unlock 処理と jest mock を削除。Permitted の共有/報告フローから orientation 制御呼び出しを削除。
テストモック・セットアップの更新
jest.setup.js, src/components/*/*.test.tsx, src/components/*.test.tsx
Jest の hooks モックに useLandscapeWindowDimensions を追加し固定の { width: 812, height: 375 } を返すよう設定。各コンポーネントテストのモック定義を更新し、useLockLandscapeOnActive のテスト削除や SelectLineScreen のモック調整を実施。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

react

Poem

🐰 Landscape の風が吹けば
角度はコードで整えられ
幅と高さ、長辺を抱きしめて
回転は CSS に任せよう
新しい朝の表示よ、よろしくな

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは「端末が portrait のままでも Main 画面を横長表示で維持する」と、このPRの主要な変更内容(物理的なportrait状態でも論理的に横長レイアウトを維持する機能)を明確かつ簡潔に表現しており、変更セットの中心的な目的と完全に一致しています。
Description check ✅ Passed PR説明は「概要」「変更の種類」「変更内容」「テスト」の主要セクションが実装されており、特に「変更内容」セクションではuseLandscapeWindowDimensionsフックの新設、ScreenOrientation呼び出しの全廃、複数コンポーネントの置換といった具体的な実装詳細が詳述されており、テスト実施状況も明記されています。
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 feature/keep-landscape-on-portrait

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

🤖 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/components/HeaderEast/HeaderEast.tsx`:
- Line 122: テストのパイプラインで useLandscapeWindowDimensions が undefined
になっているので、テスト側のモックで ../../hooks(または ~/hooks)に useLandscapeWindowDimensions
を追加して返り値を定義してください;具体的には HeaderEast.tsx が呼んでいる useLandscapeWindowDimensions をテストの
jest.mock()/手動モックに含め、期待する形(幅・高さやフラグなどコンポーネントが利用するプロパティ)を返すように実装してテスト実行時に
undefined にならないようにしてください。

In `@src/components/LineBoardJO.tsx`:
- Line 38: The test mock for the hooks module is missing a mock implementation
for useLandscapeWindowDimensions, causing useLandscapeWindowDimensions() in
LineBoardJO to be undefined; update the jest.mock for the hooks module in the
LineBoardJO test (the jest.mock(...) that currently stubs the hooks) to either
add useLandscapeWindowDimensions: () => ({ width: 1920, height: 1080 }) or
switch to a partial mock using ...jest.requireActual('~/hooks') and override
only what’s needed so that useLandscapeWindowDimensions is defined for the test.
🪄 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: 4e241270-791d-4cf0-9c95-1c5bc8281628

📥 Commits

Reviewing files that changed from the base of the PR and between 0059d24 and a78a4f0.

📒 Files selected for processing (26)
  • src/components/DevOverlay.tsx
  • src/components/HeaderEast/HeaderEast.tsx
  • src/components/HeaderLED.tsx
  • src/components/LineBoard/shared/components/StationName.tsx
  • src/components/LineBoardE231.tsx
  • src/components/LineBoardEast.tsx
  • src/components/LineBoardJO.tsx
  • src/components/LineBoardJRKyushu.tsx
  • src/components/LineBoardSaikyo.tsx
  • src/components/LineBoardToei.tsx
  • src/components/LineBoardWest.tsx
  • src/components/Marquee.tsx
  • src/components/PadArch.tsx
  • src/components/Permitted.tsx
  • src/components/TrainTypeBox.tsx
  • src/components/TransfersYamanote.tsx
  • src/components/TypeChangeNotify.tsx
  • src/hooks/index.ts
  • src/hooks/useLandscapeWindowDimensions.ts
  • src/hooks/useLockLandscapeOnActive.test.tsx
  • src/hooks/useLockLandscapeOnActive.ts
  • src/hooks/useQuickActions.ts
  • src/hooks/useScale.ts
  • src/screens/Main.tsx
  • src/screens/SelectLineScreen.render.test.tsx
  • src/screens/SelectLineScreen.tsx
💤 Files with no reviewable changes (6)
  • src/hooks/useLockLandscapeOnActive.ts
  • src/hooks/useLockLandscapeOnActive.test.tsx
  • src/hooks/useQuickActions.ts
  • src/screens/SelectLineScreen.tsx
  • src/screens/SelectLineScreen.render.test.tsx
  • src/components/Permitted.tsx

Comment thread src/components/LineBoardJO.tsx Resolved
@TinyKitten
TinyKitten merged commit 75c80ab into dev May 25, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the feature/keep-landscape-on-portrait branch May 25, 2026 01:22
This was referenced May 25, 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.

1 participant