Skip to content

E231系テーマを追加 - #5723

Merged
TinyKitten merged 7 commits into
devfrom
feature/add-e231-theme
Mar 29, 2026
Merged

TinyKitten merged 7 commits into
devfrom
feature/add-e231-theme

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Mar 29, 2026 •

Copy link
Copy Markdown
Member

Summary

close #4492

  • E231系電車の車内LCD表示をイメージした新テーマを追加
  • ヘッダー、LineBoard、TrainTypeBox、Chevron、TransfersHeadingを独立コンポーネントとして実装
  • フラットなデザイン(グラデーション・アニメーションなし)、種別名の白抜き表示、路線色統一バー等

主な変更

  • APP_THEME.E231 を追加(テーマカラー: #FFD400)
  • HeaderE231 — グレー背景(#A6A4A5)、白枠駅名、種別名白抜きアウトライン、「現在時刻」ラベル付き時計
  • TrainTypeBoxE231 — kindベースの種別名フォールバック(4文字超対応)、polished getLuminanceによるストローク色切替
  • LineBoardE231 — フラット路線色バー(通過済みもグレー化なし)、四角LineDot、ChevronE231(緑グラデ矢印)、終端三角形
  • TransfersHeading — 紫青系カプセル型「のりかえのご案内」ヘッディング
  • resolveThemeForLine — 自動テーマ設定に りんかい線(99337)→SAIKYO、中央・総武線(11313)/中央快速線(11312)/京浜東北線(11332)→E231 を追加
  • TTS mapにE231エントリ追加(SAIKYOにフォールバック)
  • 翻訳キー追加(ja/en)
  • プレビュー画像追加(e231-sp.webp / e231-tablet.webp)

Test plan

  • npm run typecheck 通過
  • npm run lint 通過
  • npm test 全1387テスト通過
  • E231テーマに切り替えてヘッダー・LineBoard・乗換画面が正しく表示されることを確認
  • 各言語(JA/KANA/EN/ZH/KO)で種別名・行先・ステート・suffix表示を確認
  • 始発表示で行先が空欄、駅名に行先が表示されることを確認
  • タブレット・スマホ両方でレイアウトを確認
  • 自動テーマ設定で中央・総武線/中央快速線/京浜東北線でE231テーマが適用されることを確認
  • りんかい線で埼京線テーマが適用されることを確認
  • 他テーマに影響がないことを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

新機能

  • E231系テーマを追加: JR東日本のE231系電車をモデルにした新しいテーマを導入しました。該当する路線で自動的に適用され、駅情報や時刻表示が新デザインで表示されます。テーマ設定からも手動で選択できます。

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions github-actions Bot added the react label Mar 29, 2026
@coderabbitai

coderabbitai Bot commented Mar 29, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed72359d-6021-474b-b791-b7e22b6acecb

📥 Commits

Reviewing files that changed from the base of the PR and between 13d9b86 and efc62d6.

📒 Files selected for processing (3)
  • src/components/HeaderE231.test.tsx
  • src/utils/resolveThemeForLine.test.ts
  • src/utils/resolveThemeForLine.ts

📝 Walkthrough

Walkthrough

E231 テーマを新規追加。翻訳、テーマ定義、テーマ情報、TTS マッピング、Main 背景色を更新し、ChevronE231/HeaderE231/LineBoardE231/TrainTypeBoxE231 等の新コンポーネントを実装して既存表示ロジックへ統合した。

Changes

Cohort / File(s) Summary
翻訳リソース
assets/translations/en.json, assets/translations/ja.json
e231Like と themeDescriptionE231 の翻訳キーを追加。
新規 E231 ビジュアルコンポーネント
src/components/ChevronE231.tsx, src/components/HeaderE231.tsx, src/components/LineBoardE231.tsx, src/components/TrainTypeBoxE231.tsx
E231 専用の SVG/レイアウトコンポーネント群を追加。Header は時計・状態表示、LineBoard は駅一覧・通過表現・Chevron 位置計算、TrainTypeBox は列車種別ラベル(縁取り)を実装。
既存コンポーネントのテーマ分岐追加
src/components/Header.tsx, src/components/LineBoard.tsx, src/components/TransfersHeading.tsx
switch(theme) に APP_THEME.E231 ケースを追加して各コンポーネントを返すよう拡張。
テーマ定義・定数・メタデータ
src/models/Theme.ts, src/constants/theme.ts, src/utils/themeInfo.ts, src/utils/theme.ts
APP_THEME に E231 を追加。IN_USE_COLOR_MAP に E231: '#FFD400' を追加。themeInfo に themeDescriptionE231 と e231-sp.webp/e231-tablet.webp を追加。設定画面のテーマ一覧へ E231 を追加。
TTS / テンプレートマッピング
src/hooks/useTTSText.ts, src/hooks/useBusTTSText.ts
APP_THEME.E231 をテンプレート/EMPTY_TTS_TEXT に追加し、resolveTemplateTheme では SAIKYO にマップして既存テンプレートを再利用。
画面スタイル調整
src/screens/Main.tsx
Main の最上位 Pressable に E231 用の背景色 #E6E6E6 を条件適用。
ユニットテスト追加/更新
src/components/HeaderE231.test.tsx, src/utils/themeInfo.test.ts, src/utils/resolveThemeForLine.test.ts
HeaderE231 のレンダリングテスト追加。getThemeInfo テストに ODAKYU/E231 を追加。resolveThemeForLine のマッピング検証を追加。
テーマ解決マップ更新
src/utils/resolveThemeForLine.ts
LINE_ID_TO_THEME に E231 関連の line.id を追加し、特定路線で E231 を返すようにした。

Sequence Diagram(s)

sequenceDiagram
    participant App as App
    participant ThemeResolver as ThemeResolver
    participant Header as HeaderE231
    participant LineBoard as LineBoardE231
    participant Chevron as ChevronE231
    participant Assets as ThemeAssets

    App->>ThemeResolver: 現在のテーマを取得
    ThemeResolver-->>App: APP_THEME = E231
    App->>Header: HeaderE231 をレンダリング(commonData)
    App->>LineBoard: LineBoardE231 をレンダリング(stations, lineColors)
    LineBoard->>Chevron: ChevronE231 を描画要求(位置・状態)
    Chevron->>Assets: グラデーション id を参照して描画
    Header->>Assets: translate('themeDescriptionE231') を取得
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

小さなウサギが描くE231の夢、
グラデと矢印で道をつなぎ、
駅名と時刻がぴょんと揃い、
みんなで次のホームへ跳ねるよ、
ぽんぽこ走るよ、ぴょん🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトル「E231系テーマを追加」は変更内容の主要な目的(E231系テーマの追加)を簡潔かつ明確に表現しており、チェンジセットの主要な変更を正確に要約している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR説明は概要・主要な変更・テスト計画が記載されており、テンプレートの必須要素をおおむね満たしている。

✏️ 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/add-e231-theme

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

@TinyKitten TinyKitten self-assigned this Mar 29, 2026

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

🧹 Nitpick comments (2)
src/utils/themeInfo.ts (1)

72-77: TODOコメントを確認しました。

E231テーマ用のプレビュー画像がSaikyoテーマの画像でプレースホルダーとして設定されています。プレビュー画像の作成後に差し替えが必要です。

プレビュー画像の作成タスクを追跡するためのIssueを作成しましょうか?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/themeInfo.ts` around lines 72 - 77, The E231 theme entry in
themeInfo (APP_THEME.E231) uses Saikyo placeholder images (spImage/tabletImage
pointing at saikyo-*.webp); replace these with the real E231 preview assets once
created and update descriptionKey if needed; to track, create an Issue for "E231
preview images" and attach the new asset filenames so the maintainer can update
the spImage/tabletImage requires in themeInfo.ts (APP_THEME.E231) when the final
images are available.
src/components/LineBoardE231.tsx (1)

310-338: 8 枠補完のロジックが効いていません。

stationsWithEmpty で undefined を足していますが、stationNameCellForMap() が falsy を null で落とすので空セルは 1 つも描画されません。8 枠固定が必要なら placeholder を描画し、不要ならこの補完ごと削った方が読みやすいです。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/LineBoardE231.tsx` around lines 310 - 338, stationsWithEmpty
currently appends undefined entries so stationNameCellForMap returns null for
those and no placeholders render; either (A) make stationsWithEmpty fill with
explicit placeholder Station objects (e.g., with a unique id and an
isPlaceholder/isEmpty flag) so StationNameCell receives a real Station and can
render an empty cell, or (B) remove the padding and the stationsWithEmpty logic
if fixed-length slots are not required, or (C) change stationNameCellForMap to
treat a falsy s by returning a placeholder cell component instead of null;
update usages of stationsWithEmpty, StationNameCell, and stationNameCellForMap
accordingly so placeholders render when 8 slots are required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/ChevronE231.tsx`:
- Around line 1-4: The file uses React.FC in the component signature but never
imports React or FC; add a proper import from 'react' (either import React from
'react' or import type { FC } from 'react' and update the signature accordingly)
so the ChevronE231 component's type annotation (ChevronE231: React.FC) resolves
under strict type checking.

In `@src/components/HeaderE231.tsx`:
- Around line 151-162: The bound/first-stop logic clears the entire destination
text resulting in missing destination for始発; instead of emptying boundText,
preserve boundText and only append the language-specific suffix when needed.
Update the code paths that set boundText to '' (and the useMemo boundSuffixText)
so that boundText remains unchanged for firstStop and you concatenate
boundSuffixText (computed from headerLangState and firstStop for only
JA/KANA/KO) to the existing boundText; reference the boundSuffixText
computation, the headerLangState/firstStop inputs, and wherever boundText is
being set to '' (the boundText assignment locations) to implement this change.

In `@src/components/TrainTypeBoxE231.tsx`:
- Around line 98-111: The strokeColor computation can throw when getLuminance
receives an invalid color; update TrainTypeBoxE231.tsx so strokeColor is derived
safely by either calling the existing utility getTrainTypeTextColor() (which
normalizes color and handles errors) or by wrapping getLuminance(trainTypeColor)
in a try/catch and falling back to a safe value (e.g., '#555' or '#fff') when
normalization fails; locate the useMemo that computes trainTypeColor and the
strokeColor useMemo and replace the direct getLuminance call with a call to
getTrainTypeTextColor (or a guarded try/catch + normalized color) to ensure
invalid trainType.color values do not crash rendering.

In `@src/components/TransfersHeading.tsx`:
- Around line 74-79: TransfersHeading コンポーネントの見出しが LinearGradient
を使って4色グラデーションになっており、E231 テーマの単色方針と合っていません。LinearGradient
の使用をやめ、styles.headingContainerE231 を使うコンテナを単色背景に変更する(LinearGradient を View
に置き換えるか、LinearGradient の colors/locations を削除して styles.headingContainerE231 の
backgroundColor に E231 の指定色を入れる)ことで、他の E231 パーツと質感を揃えてください。対象の識別子:
TransfersHeading, LinearGradient, styles.headingContainerE231。

---

Nitpick comments:
In `@src/components/LineBoardE231.tsx`:
- Around line 310-338: stationsWithEmpty currently appends undefined entries so
stationNameCellForMap returns null for those and no placeholders render; either
(A) make stationsWithEmpty fill with explicit placeholder Station objects (e.g.,
with a unique id and an isPlaceholder/isEmpty flag) so StationNameCell receives
a real Station and can render an empty cell, or (B) remove the padding and the
stationsWithEmpty logic if fixed-length slots are not required, or (C) change
stationNameCellForMap to treat a falsy s by returning a placeholder cell
component instead of null; update usages of stationsWithEmpty, StationNameCell,
and stationNameCellForMap accordingly so placeholders render when 8 slots are
required.

In `@src/utils/themeInfo.ts`:
- Around line 72-77: The E231 theme entry in themeInfo (APP_THEME.E231) uses
Saikyo placeholder images (spImage/tabletImage pointing at saikyo-*.webp);
replace these with the real E231 preview assets once created and update
descriptionKey if needed; to track, create an Issue for "E231 preview images"
and attach the new asset filenames so the maintainer can update the
spImage/tabletImage requires in themeInfo.ts (APP_THEME.E231) when the final
images are available.
🪄 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: 440b15ac-ea14-485b-8c15-cb0a4c2f4255

📥 Commits

Reviewing files that changed from the base of the PR and between 9eb838f and 350339d.

📒 Files selected for processing (16)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/ChevronE231.tsx
  • src/components/Header.tsx
  • src/components/HeaderE231.tsx
  • src/components/LineBoard.tsx
  • src/components/LineBoardE231.tsx
  • src/components/TrainTypeBoxE231.tsx
  • src/components/TransfersHeading.tsx
  • src/constants/theme.ts
  • src/hooks/useBusTTSText.ts
  • src/hooks/useTTSText.ts
  • src/models/Theme.ts
  • src/screens/Main.tsx
  • src/utils/theme.ts
  • src/utils/themeInfo.ts

Comment thread src/components/ChevronE231.tsx Resolved
Comment thread src/components/HeaderE231.tsx Resolved
Comment thread src/components/TrainTypeBoxE231.tsx Resolved
Comment thread src/components/TransfersHeading.tsx Resolved
TinyKitten and others added 4 commits March 30, 2026 00:46
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@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.

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

116-118: headerLangState のパースはフォールバックを明示するとより安全です。

Line 117 は型アサーションで不正値を隠してしまうため、値を検証して JA にフォールバックすると将来の保守性が上がります。

差分案
-  const headerLangState = useMemo((): HeaderLangState => {
-    return headerState.split('_')[1] as HeaderLangState;
-  }, [headerState]);
+  const headerLangState = useMemo((): HeaderLangState => {
+    const lang = headerState.split('_')[1];
+    return lang === 'JA' || lang === 'EN' || lang === 'ZH' || lang === 'KO'
+      ? lang
+      : 'JA';
+  }, [headerState]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/TrainTypeBoxE231.tsx` around lines 116 - 118, The current
useMemo for headerLangState unsafely asserts headerState.split('_')[1] as
HeaderLangState, which can hide invalid values; validate the parsed part instead
and fall back to 'JA' when missing or not a valid HeaderLangState. Update the
memo block (the useMemo that defines headerLangState) to extract the token from
headerState.split('_')[1], check it against the allowed HeaderLangState values
(or a helper isValidHeaderLang function), and return the token if valid
otherwise return 'JA'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/TrainTypeBoxE231.tsx`:
- Around line 116-118: The current useMemo for headerLangState unsafely asserts
headerState.split('_')[1] as HeaderLangState, which can hide invalid values;
validate the parsed part instead and fall back to 'JA' when missing or not a
valid HeaderLangState. Update the memo block (the useMemo that defines
headerLangState) to extract the token from headerState.split('_')[1], check it
against the allowed HeaderLangState values (or a helper isValidHeaderLang
function), and return the token if valid otherwise return 'JA'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f18a2516-6d31-4ca5-b93c-1eca50d20371

📥 Commits

Reviewing files that changed from the base of the PR and between aedca24 and 152925b.

📒 Files selected for processing (2)
  • src/components/ChevronE231.tsx
  • src/components/TrainTypeBoxE231.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/components/ChevronE231.tsx

coderabbitai[bot]
coderabbitai Bot previously requested changes Mar 29, 2026

@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 the current code and only fix it if needed.

Inline comments:
In `@src/components/HeaderE231.test.tsx`:
- Around line 53-69: Add automated tests covering ZH and KO fallback branches in
the HeaderE231 tests: extend the existing test block that renders <HeaderE231
{...createMockHeaderProps({ stateText: '', headerLangState: ... })} /> to also
assert getByText('translated:nowStoppingAtZh') and
getByText('translated:nowStoppingAtKo'); ideally convert the JA/EN/ZH/KO cases
into a table-driven test (array of locale→expected key) and iterate to render
HeaderE231 and assert the expected fallback text for each locale so ZH and KO
regressions are detected.
🪄 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: 0f4ed029-9947-4d8d-bd48-122cde04c38f

📥 Commits

Reviewing files that changed from the base of the PR and between 152925b and 13d9b86.

📒 Files selected for processing (2)
  • src/components/HeaderE231.test.tsx
  • src/utils/themeInfo.test.ts
✅ Files skipped from review due to trivial changes (1)
  • src/utils/themeInfo.test.ts

Comment thread src/components/HeaderE231.test.tsx Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai 他にないならapproveしてください

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@TinyKitten 実装を確認しましたが、特に問題は見当たりませんでした。approveします!

[approve]


🧠 Learnings used
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4448
File: functions/src/funcs/tts.ts:214-232
Timestamp: 2025-08-11T20:23:23.071Z
Learning: PR `#4448` in TrainLCD/MobileApp is specifically about AI feedback summarization and labeling functionality, not about TTS (Text-to-Speech) improvements. The TTS code changes appear to be part of a modularization refactoring but are not the focus of this PR.

Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2026-03-07T12:40:27.212Z
Learning: Write commit messages in Japanese (e.g., `テレメトリー送信機をリファクタリングしてnull状態を回避`)

@TinyKitten
TinyKitten dismissed coderabbitai[bot]’s stale review March 29, 2026 16:10

なぜかapproveされていない表示になっているため

@TinyKitten
TinyKitten merged commit 85db4f4 into dev Mar 29, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the feature/add-e231-theme branch March 29, 2026 16:11
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.

E231系テーマを作る

1 participant