Skip to content

Add notification settings screen for wrong direction alerts#5773

Merged
TinyKitten merged 5 commits intodevfrom
claude/add-notification-toggle-Vwo7a
Apr 6, 2026
Merged

Add notification settings screen for wrong direction alerts#5773
TinyKitten merged 5 commits intodevfrom
claude/add-notification-toggle-Vwo7a

Conversation

@TinyKitten
Copy link
Copy Markdown
Member

@TinyKitten TinyKitten commented Apr 6, 2026

概要

逆方向走行時の通知設定を管理する新しい設定画面を追加しました。ユーザーが逆方向走行時の通知のオン/オフを切り替えられるようになります。

変更の種類

  • 新機能
  • リファクタリング

変更内容

新規追加

  • NotificationSettingsScreen: 逆方向走行時の通知設定を管理する新しい画面
    • トグルボタンで通知のオン/オフを切り替え可能
    • AsyncStorageに設定を永続化
    • LED テーマ対応
    • アクセシビリティ対応(switch role)

既存ファイルの変更

  • AppSettings.tsx:

    • 通知設定へのナビゲーションメニューを追加
    • 個人設定セクションに「通知」オプションを追加
  • Permitted.tsx:

    • アプリ起動時に AsyncStorage から wrongDirectionNotifyEnabled 設定を読み込み
    • notifyState atom を初期化
  • MainStack.tsx:

    • NotificationSettings 画面をスタックに登録
  • notify.ts:

    • NotifyState インターフェースに wrongDirectionNotifyEnabled フィールドを追加
  • asyncStorage.ts:

    • WRONG_DIRECTION_NOTIFY_ENABLED キーを定数として追加
  • 翻訳ファイル (en.json, ja.json):

    • 通知設定関連の翻訳文字列を追加

テスト

  • npm run lint が通ること
  • npm run typecheck が通ること
  • 既存の設定画面と同様の構造で実装されているため、既存テストで対応

https://claude.ai/code/session_01GTPWXRZfVMsQWVchRxFW6n

Summary by CodeRabbit

  • 新機能
    • 「通知設定」画面を追加し、進行方向と逆方向の移動時に通知するかをオン/オフできるトグルを実装しました。設定は保存され、アプリ内で反映されます。
  • ローカライズ
    • 上記UI用の日本語・英語の文言を追加しました。

@github-actions github-actions Bot added the react label Apr 6, 2026
@TinyKitten TinyKitten self-assigned this Apr 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

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: 578e89fc-1124-496c-8b2a-ddd54648683e

📥 Commits

Reviewing files that changed from the base of the PR and between d666441 and 2050c3d.

📒 Files selected for processing (2)
  • src/hooks/useRefreshStation.ts
  • src/store/atoms/notify.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/store/atoms/notify.ts

📝 Walkthrough

Walkthrough

誤方向通知設定を追加。翻訳キーの追加、設定画面への遷移項目追加、新しい通知設定スクリーン、Jotai状態とAsyncStorageでの永続化、既存フローへの読み込み統合を実装。

Changes

Cohort / File(s) Summary
翻訳ファイル
assets/translations/en.json, assets/translations/ja.json
誤方向通知関連の3つの新しいUI文字列キー(notificationSettingswrongDirectionNotifyTogglewrongDirectionNotifyDescription)を追加。
状態管理定義
src/store/atoms/notify.ts, src/constants/asyncStorage.ts
NotifyStatewrongDirectionNotifyEnabled: booleanを追加。ASYNC_STORAGE_KEYSWRONG_DIRECTION_NOTIFY_ENABLED定数を追加。
初期化・設定読み込み
src/components/Permitted.tsx
起動時にWRONG_DIRECTION_NOTIFY_ENABLEDをAsyncStorageから読み込み、notifyState.wrongDirectionNotifyEnabledを初期化する処理を追加。
設定画面(親)変更
src/screens/AppSettings.tsx
SETTING_ITEM_ID_MAPpersonalize_notificationsを追加し、「personalize」セクションに通知設定へのナビゲーション項目を挿入。
新規画面
src/screens/NotificationSettings.tsx
誤方向通知トグルのUI、説明文、トグル押下でAsyncStorageへ保存しJotaiを更新するロジック、スクロール追跡、ヘッダー/フッターを持つ新規画面を追加(React.memoでエクスポート)。
ナビゲーション
src/stacks/MainStack.tsx
MainStackNotificationSettingsルートを追加。
フック修正
src/hooks/useRefreshStation.ts
誤方向通知の発火条件にwrongDirectionNotifyEnabledを加え、通知が無効なら通知処理を抑止。

Sequence Diagram

sequenceDiagram
    actor User
    participant NotificationSettings as NotificationSettings<br/>Screen
    participant JotaiState as Jotai<br/>notifyState
    participant AsyncStorage as AsyncStorage
    participant Navigation as Navigation

    User->>NotificationSettings: 通知設定画面を開く
    activate NotificationSettings
    NotificationSettings->>JotaiState: 読み取り(wrongDirectionNotifyEnabled)
    JotaiState-->>NotificationSettings: 現在値を返す
    NotificationSettings-->>User: トグルと説明を表示
    deactivate NotificationSettings

    User->>NotificationSettings: トグルを切り替え
    activate NotificationSettings
    NotificationSettings->>AsyncStorage: 新しい値を保存(WRONG_DIRECTION_NOTIFY_ENABLED)
    activate AsyncStorage
    AsyncStorage-->>NotificationSettings: 保存完了
    deactivate AsyncStorage
    NotificationSettings->>JotaiState: Atomを更新
    JotaiState-->>NotificationSettings: 更新完了
    NotificationSettings-->>User: UIを更新
    deactivate NotificationSettings

    User->>NotificationSettings: OKボタンで戻る
    activate NotificationSettings
    NotificationSettings->>Navigation: 前の画面へ戻る
    Navigation-->>User: 前画面表示
    deactivate NotificationSettings
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 ぴょんと追加、誤方向の知らせ
トグルで守る、ふわふわの設定箱
翻訳そえて、画面にぽんと並べる
AsyncStorageにそっと収めて
Jotaiが見守る、ぴょん♪

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは新しい通知設定画面の追加という主要な変更を明確に説明しており、変更内容と一致しています。
Description check ✅ Passed PRの説明は必須セクション(概要、変更の種類、変更内容、テスト)を全て含み、詳細で充実した内容です。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/add-notification-toggle-Vwo7a

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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/screens/NotificationSettings.tsx`:
- Around line 45-60: handleToggleWrongDirectionNotify correctly saves
wrongDirectionNotifyEnabled to AsyncStorage and state, but the notification
sender in useRefreshStation (hook functions around lines previously noted)
ignores this flag so wrong-direction alerts still send; update the sending logic
in useRefreshStation (the function(s) that decide and dispatch wrong-direction
notifications, e.g., the handler around the send/notify calls) to read the
persisted flag (from AsyncStorage or from your global/state store) and gate
sending: before invoking the wrong-direction notification dispatch, check the
flag and return early if false; ensure you reference the same storage key
ASYNC_STORAGE_KEYS.WRONG_DIRECTION_NOTIFY_ENABLED or the notify state
setter/getter used by NotificationSettings so the UI toggle actually controls
sending.
🪄 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: ffb15f18-7615-4eed-b517-253e8ad8cc19

📥 Commits

Reviewing files that changed from the base of the PR and between c64a911 and d666441.

📒 Files selected for processing (8)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/Permitted.tsx
  • src/constants/asyncStorage.ts
  • src/screens/AppSettings.tsx
  • src/screens/NotificationSettings.tsx
  • src/stacks/MainStack.tsx
  • src/store/atoms/notify.ts

Comment thread src/screens/NotificationSettings.tsx
@TinyKitten TinyKitten merged commit 7922a73 into dev Apr 6, 2026
6 checks passed
@TinyKitten TinyKitten deleted the claude/add-notification-toggle-Vwo7a branch April 6, 2026 11:25
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