Repository navigation
JR九州風テーマ実装 - #4396
JR九州風テーマ実装#4396
Conversation
|
""" Walkthrough新たなる「JR九州風」テーマが追加され、Header、LineBoard、TrainTypeBox等の主要コンポーネントに専用の実装が加わった。翻訳ファイルやテーマ選択肢、TTSテキスト生成ロジックも拡張され、テーマ識別子の追加と共に多言語・アニメーション対応の新規UIが導入された。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant Header
participant HeaderJRKyushu
participant LineBoard
participant LineBoardJRKyushu
participant TrainTypeBoxJRKyushu
User->>App: テーマを「JR_KYUSHU」に設定
App->>Header: テーマ判定
Header->>HeaderJRKyushu: JR_KYUSHU時に描画
App->>LineBoard: テーマ判定
LineBoard->>LineBoardJRKyushu: JR_KYUSHU時に描画
HeaderJRKyushu->>TrainTypeBoxJRKyushu: 種別表示
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (1)
src/hooks/useTTSText.ts (1)
1093-1100: 英語の案内も同様の問題を抱えておる!英語版でも同じくJR西日本のテンプレートを流用している。これも修正が必要である。
🧹 Nitpick comments (4)
src/components/ChervronTY.tsx (1)
17-18: 黒色の実装、朕の審美眼に適う!新たなBLACK色オプションの実装は適切である。グラデーションの値も他の色と調和している。
ただし、朕は提案する。色の定義を定数として外部に切り出すことで、さらなる保守性の向上が期待できる:
+const COLOR_GRADIENTS = { + RED: ['#be3d03', '#c21705', '#333', '#be3d03'], + BLUE: ['#3fa9f5', '#1d67e0', '#333', '#1765d4'], + BLACK: ['#333', '#333', '#666', '#333'], + WHITE: ['#aaa', '#aaa', '#aaa', '#aaa'], +} as const; const colors = useMemo(() => { switch (color) { case 'RED': - return ['#be3d03', '#c21705', '#333', '#be3d03']; + return COLOR_GRADIENTS.RED; case 'BLUE': - return ['#3fa9f5', '#1d67e0', '#333', '#1765d4']; + return COLOR_GRADIENTS.BLUE; case 'BLACK': - return ['#333', '#333', '#666', '#333']; + return COLOR_GRADIENTS.BLACK; case 'WHITE': - return ['#aaa', '#aaa', '#aaa', '#aaa']; + return COLOR_GRADIENTS.WHITE; default: - return ['#aaa', '#aaa', '#aaa', '#aaa']; + return COLOR_GRADIENTS.WHITE; } }, [color]);src/components/HeaderJRKyushu.tsx (1)
143-648: 朕は警告する!この巨大な建造物は維持が困難になる恐れがある。649行に及ぶこのコンポーネントは複雑すぎる。アニメーションロジックやスタイル計算を別のカスタムフックに分離することを検討せよ。
以下の分割を提案する:
useHeaderAnimations: アニメーションロジック用のカスタムフックuseHeaderTexts: テキスト計算ロジック用のカスタムフック- サブコンポーネントへの分割(例:HeaderState、StationName、BoundInfo)
これにより、保守性と再利用性が向上するであろう。
src/components/TrainTypeBoxJRKyushu.tsx (1)
119-131: 朕が観察するに、この文字間隔の調整は巧妙だが、一考の余地がある2文字の列車種別名に対して文字間隔を8に設定し、iOSでは左マージンも8に調整している。しかし、なぜ2文字の場合のみこの調整が必要なのか、またなぜ8という値なのかについて説明がない。
以下の改善を提案する:
const letterSpacing = useMemo(() => { + // 2文字の列車種別名の場合、視覚的バランスを改善するため文字間隔を調整 if (trainTypeName?.length === 2) { return 8; } return 0; }, [trainTypeName?.length]); const marginLeft = useMemo(() => { + // iOSでは文字間隔調整時に左マージンも調整が必要 if (trainTypeName?.length === 2 && Platform.OS === 'ios') { return 8; } return 0; }, [trainTypeName?.length]);src/components/LineBoardJRKyushu.tsx (1)
28-52: 朕が観察するに、このuseBarStylesフックは効率的だが、改善の余地があるバーのスタイリング計算が適切に実装されているが、マジックナンバーの説明が不足している。
以下の改善を提案する:
const useBarStyles = ({ index, }: { index?: number; }): { left: number; width: number } => { const left = useMemo(() => { if (index === 0) { + // 最初の駅のバーは少し左にずらす return widthScale(-32); } + // 通常の駅のバー位置 return widthScale(-20); }, [index]); const width = useMemo(() => { if (isTablet) { if (index === 0) { + // タブレットでの最初の駅のバー幅 return widthScale(200); } if (index === 1) { + // タブレットでの2番目の駅のバー幅 return widthScale(61.75); } } + // デフォルトのバー幅 return widthScale(62); }, [index]); return { left, width }; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
assets/translations/en.json(1 hunks)assets/translations/ja.json(1 hunks)src/components/ChervronTY.tsx(1 hunks)src/components/Header.tsx(2 hunks)src/components/HeaderJRKyushu.tsx(1 hunks)src/components/LineBoard.tsx(2 hunks)src/components/LineBoardJRKyushu.tsx(1 hunks)src/components/NumberingIconSquare.tsx(1 hunks)src/components/TrainTypeBoxJRKyushu.tsx(1 hunks)src/hooks/useTTSText.ts(5 hunks)src/models/Theme.ts(1 hunks)src/utils/theme.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4249
File: __tests__/hooks/useTelemetrySender.enabled.test.tsx:54-68
Timestamp: 2025-05-07T23:04:31.413Z
Learning: TinyKitten is working on implementing a queue for movement logs in the TrainLCD mobile app, but realized the implementation differed from their original intention.
src/components/NumberingIconSquare.tsx (1)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
assets/translations/en.json (1)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#0
File: :0-0
Timestamp: 2024-12-18T00:29:05.817Z
Learning: 翻訳ファイル(`assets/translations/en.json` と `assets/translations/ja.json`)の変更を要約する際、`backgroundPermissionDenied` のようなキーが追加されているのか削除されているのかを正確に確認する。
assets/translations/ja.json (1)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#0
File: :0-0
Timestamp: 2024-12-18T00:29:05.817Z
Learning: 翻訳ファイル(`assets/translations/en.json` と `assets/translations/ja.json`)の変更を要約する際、`backgroundPermissionDenied` のようなキーが追加されているのか削除されているのかを正確に確認する。
src/components/Header.tsx (2)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
src/components/LineBoard.tsx (1)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
src/hooks/useTTSText.ts (1)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
src/components/ChervronTY.tsx (2)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
src/components/LineBoardJRKyushu.tsx (2)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
src/components/TrainTypeBoxJRKyushu.tsx (2)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
src/components/HeaderJRKyushu.tsx (2)
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.
Learnt from: TinyKitten
PR: TrainLCD/MobileApp#4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
🧬 Code Graph Analysis (6)
src/components/Header.tsx (1)
src/models/Theme.ts (1)
APP_THEME(1-12)
src/utils/theme.ts (2)
src/translation.ts (1)
translate(7-12)src/models/Theme.ts (1)
APP_THEME(1-12)
src/components/LineBoard.tsx (1)
src/models/Theme.ts (1)
APP_THEME(1-12)
src/hooks/useTTSText.ts (1)
src/models/Theme.ts (1)
APP_THEME(1-12)
src/components/TrainTypeBoxJRKyushu.tsx (3)
src/translation.ts (1)
translate(7-12)src/constants/regexp.ts (1)
parenthesisRegexp(1-1)src/hooks/index.ts (1)
usePrevious(45-45)
src/components/HeaderJRKyushu.tsx (6)
src/utils/rfValue.ts (1)
RFValue(3-18)src/constants/regexp.ts (1)
parenthesisRegexp(1-1)src/translation.ts (1)
translate(7-12)src/hooks/index.ts (1)
usePrevious(45-45)src/utils/numbering.ts (1)
getNumberingColor(3-16)src/constants/size.ts (1)
STATION_NAME_FONT_SIZE(3-3)
🔇 Additional comments (21)
src/components/NumberingIconSquare.tsx (1)
120-120: 朕、この変更を認める!transformOriginを'bottom'から'center'に変更することで、スケーリング時の視覚的な中心配置が改善される。JR九州テーマの実装において、番号アイコンの表示がより美しく調整されることであろう。
assets/translations/en.json (1)
180-181: 朕、この翻訳の追加を承認する!新たなJR九州テーマに対応する翻訳キー"jrKyushuLike"の追加は適切である。既存のテーマ命名規則に従い、JSON構文も正しく維持されている。
src/models/Theme.ts (1)
11-11: 朕、新たなテーマ定数の追加を嘉す!JR_KYUSHU テーマ定数の追加は既存のパターンに従っており、適切に実装されている。AppTheme型も自動的にこの新しい値を含むことになる。
assets/translations/ja.json (1)
181-182: 朕、日本語翻訳の追加を許可する!"jrKyushuLike": "JR九州風"の追加は適切であり、既存のテーマ翻訳パターン(「〜風」の使用)に従っている。英語版との整合性も保たれている。
src/components/Header.tsx (2)
6-6: 朕、新たなヘッダーコンポーネントの導入を認める!HeaderJRKyushuコンポーネントのインポートは適切に行われている。
38-39: 承認:JR_KYUSHUテーマ追加およびHeaderJRKyushu実装確認済朕、以下を確認せり:
- src/components/Header.tsx における
APP_THEME.JR_KYUSHUケースの追加は既存パターンに準拠し、正しく実装されておる。- src/components/HeaderJRKyushu.tsx が存在し、
const HeaderJRKyushu: React.FC定義及びexport default React.memo(HeaderJRKyushu)によるエクスポートを確認したぞ。テーマ切り替えロジックの拡張は完全なり。よって朕、これを以て承認す。
src/utils/theme.ts (1)
58-62: 朕は認める!新たなる九州の領土が我が帝国に加わったぞ!この実装は見事である。既存のテーマ配列に適切に統合されており、翻訳キーも正しく使用されている。
src/components/LineBoard.tsx (2)
14-14: よきかな!新たなる臣下の導入は正しく行われておる。LineBoardJRKyushuコンポーネントのインポートは適切に配置されている。
127-134: 朕の目に狂いはない。この実装は完璧である!JR_KYUSHUテーマのケースが他のテーマと同様のパターンで実装されており、必要なプロパティ(stations、lineColors、hasTerminus)が正しく渡されている。
src/hooks/useTTSText.ts (1)
35-35: 朕の臣民よ、空のテンプレートの追加は適切である。EMPTY_TTS_TEXTへのJR_KYUSHU追加は他のテーマと一貫性を保っている。
src/components/ChervronTY.tsx (1)
1-1: 朕は褒める!useIdとuseMemoの導入は賢明な判断である。色の計算をuseMemoでメモ化し、switch文を使用することで、より効率的で読みやすいコードとなっている。
Also applies to: 11-24
src/components/HeaderJRKyushu.tsx (2)
1-38: 朕は認める!必要な輸入品はすべて適切に準備されている。インポート文は整理されており、必要な依存関係がすべて含まれている。
159-260: 朕は感心した!言語対応の実装は見事である。多言語対応(日本語、ひらがな、英語、中国語、韓国語)が適切に実装されており、各ケースが丁寧に処理されている。
src/components/TrainTypeBoxJRKyushu.tsx (4)
1-21: 朕が見るところ、この輸入宣言は適切に整理されておる依存関係の構成が整然としており、必要な機能のみを輸入している。特に
react-native-reanimatedのアニメーション機能と多言語対応のための翻訳機能が適切に配置されている。
69-84: 朕が認める、この言語状態管理は見事である
headerLangStateの抽出とlocalTypeTextの多言語対応が適切に実装されている。4つの言語(日本語、英語、中国語、韓国語)に対応し、デフォルトケースも考慮されている。
185-224: 朕が承認する、このレンダリング構造は適切であるアニメーション付きの二重テキスト表示構造が正しく実装されている。現在のテキストと前のテキストの透明度を反転させることで、スムーズな遷移を実現している。
React.memoによる最適化も適切である。
148-167: useLazyPreviousの実装とエクスポートを確認せり
朕が審査したところ、src/hooks/useLazyPrevious.tsにてvalueとshouldUpdateを監視し、shouldUpdateが真の折にのみvalを更新する正しき実装が確認された。また、src/hooks/index.ts上でのエクスポートも問題なし。依存配列、アニメーション制御ともに支障なしと断ずるゆえ、これ以上の修正は不要なり。src/components/LineBoardJRKyushu.tsx (4)
1-25: 朕が査閲するに、この輸入宣言は適切に構成されている必要な依存関係が適切に輸入されており、特に
LinearGradientとアニメーション関連のコンポーネントが正しく配置されている。
175-236: 朕が承認する、このStationNameコンポーネントは多言語対応が適切である日本語、英語、中国語、韓国語の表示切り替えが正しく実装されており、縦書きと横書きの対応も適切である。通過駅のグレースケール表示も正しく実装されている。
631-644: 朕が承認する、この配列操作とレンダリング構造は効率的である8つの固定スロットを持つ配列の生成と、各スロットのレンダリング処理が適切に実装されている。空のスロットに対する
EmptyStationNameCellの使用も正しい。
246-289: 朕が検証するに、LineDotの条件分岐およびgetIsPassの実装に問題なしなり
- getIsPassは
src/utils/isPass.tsにてexport default getIsPassとして定義され、station.stopConditionをもとに通過駅を正しく判定しておる- LineDotの
getIsPass(station)による分岐は意図どおり動作し、修正は不要なり
close #4365
Summary by CodeRabbit
新機能
改善
スタイル