Skip to content

refactor: extract PlayerView into smaller reusable components#27

Merged
joshhbk merged 1 commit intomainfrom
refactor/extract-playerview-components
Jan 31, 2026
Merged

refactor: extract PlayerView into smaller reusable components#27
joshhbk merged 1 commit intomainfrom
refactor/extract-playerview-components

Conversation

@joshhbk
Copy link
Owner

@joshhbk joshhbk commented Jan 31, 2026

Summary

  • Extract PlayerView (597 lines) into focused, composable components
  • PlayerView main struct reduced to ~143 lines (orchestration only)
  • Eliminates 4 duplicate switch statements on PlaybackState
  • Makes layout experimentation straightforward

New Components

File Lines Purpose
PlayerActions.swift 11 Callback container for player actions
PlayerProgressState.swift 34 Timer-based progress tracking (@observable)
ThemeController.swift 59 Theme switching + swipe gesture (@observable)
PlaybackStateContent.swift 24 Generic switch eliminator for PlaybackState
SongInfoDisplay.swift 89 Song title/artist/progress display
PlayerTopBar.swift 43 Add/Settings buttons
PlayerControlsPanel.swift 26 ClickWheel in ShuffleBody wrapper
ClassicPlayerLayout.swift 58 Composes all components into current layout

Benefits

  • Separates timer/gesture/lifecycle code from view code
  • Each component is independently testable and reusable
  • Layout experimentation is now simple (swap ClassicPlayerLayout for alternatives)

Test plan

  • Build succeeds
  • App looks identical to before
  • Play/pause, skip, volume controls work
  • Theme swipe gesture works
  • Status bar safe area respected

🤖 Generated with Claude Code

Extract PlayerView (597 lines) into focused, composable components:

New components:
- PlayerActions: Callback container for player actions
- PlayerProgressState: Timer-based progress tracking (@observable)
- ThemeController: Theme switching + swipe gesture (@observable)
- PlaybackStateContent: Generic switch eliminator for PlaybackState
- SongInfoDisplay: Song title/artist/progress display
- PlayerTopBar: Add/Settings buttons
- PlayerControlsPanel: ClickWheel in ShuffleBody wrapper
- ClassicPlayerLayout: Composes all components into current layout

Benefits:
- PlayerView main struct reduced to ~143 lines (orchestration only)
- Eliminates 4 duplicate switch statements on PlaybackState
- Separates timer/gesture/lifecycle code from view code
- Makes layout experimentation straightforward (swap ClassicPlayerLayout)
- Each component is independently testable and reusable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@joshhbk joshhbk merged commit d0d8748 into main Jan 31, 2026
1 check failed
@joshhbk joshhbk deleted the refactor/extract-playerview-components branch January 31, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants