-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 8: lock-screen lyrics (state L3) #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tirthfx
wants to merge
1
commit into
phase-7-lockscreen-expand
Choose a base branch
from
phase-8-lockscreen-lyrics
base: phase-7-lockscreen-expand
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
NotchBeat/PseudoLockScreenController/LockScreenLyricsView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| /// Lock-screen lyrics (PRD §3.2 L3, reference image 3): album art + controls | ||
| /// shifted to the left column, synced lyrics filling the right. The art carries | ||
| /// the same hero morph as the widget/expanded states, so it slides left and | ||
| /// shrinks as the lyrics reveal. Reuses LyricsService and the notch's | ||
| /// SyncedLyricsView (with larger fonts). | ||
| struct LockScreenLyricsView: View { | ||
| @ObservedObject var lyrics: LyricsService | ||
| let track: NowPlaying | ||
| let albumArt: NSImage? | ||
| let namespace: Namespace.ID | ||
| let onPlayPause: () -> Void | ||
| let onPrevious: () -> Void | ||
| let onNext: () -> Void | ||
| let onSeek: (TimeInterval) -> Void | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 56) { | ||
| VStack(spacing: 24) { | ||
| artwork | ||
| .frame(width: 220, height: 220) | ||
| .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous)) | ||
| .matchedGeometryEffect(id: LockScreenMorph.art, in: namespace) | ||
| .shadow(color: .black.opacity(0.5), radius: 26, y: 12) | ||
|
|
||
| LockScreenControlPill( | ||
| nowPlaying: track, | ||
| onPlayPause: onPlayPause, | ||
| onPrevious: onPrevious, | ||
| onNext: onNext, | ||
| onSeek: onSeek | ||
| ) | ||
| } | ||
| .frame(width: 360) | ||
|
|
||
| lyricsContent | ||
| .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) | ||
| } | ||
| .padding(.horizontal, 90) | ||
| .padding(.vertical, 70) | ||
| .task(id: track.trackID) { lyrics.load(for: track) } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var lyricsContent: some View { | ||
| switch lyrics.state { | ||
| case .idle, .loading: | ||
| centered { | ||
| ProgressView().controlSize(.large).tint(.white) | ||
| } | ||
| case .loaded(.synced(let lines)): | ||
| SyncedLyricsView( | ||
| lines: lines, | ||
| track: track, | ||
| currentSize: 26, | ||
| otherSize: 20, | ||
| lineSpacing: 16, | ||
| horizontalPadding: 0 | ||
| ) | ||
| case .loaded(.plain(let text)): | ||
| PlainLyricsView(text: text, fontSize: 20, horizontalPadding: 0) | ||
| case .loaded(.unavailable): | ||
| centered { | ||
| VStack(spacing: 12) { | ||
| Image(systemName: "music.note.list") | ||
| .font(.system(size: 34)) | ||
| .foregroundStyle(.white.opacity(0.5)) | ||
| Text("No lyrics found") | ||
| .font(.system(size: 17, weight: .medium)) | ||
| .foregroundStyle(.white.opacity(0.6)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func centered<Content: View>(@ViewBuilder _ content: () -> Content) -> some View { | ||
| content().frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var artwork: some View { | ||
| if let albumArt { | ||
| Image(nsImage: albumArt) | ||
| .resizable() | ||
| .aspectRatio(contentMode: .fill) | ||
| } else { | ||
| RoundedRectangle(cornerRadius: 14, style: .continuous) | ||
| .fill(Color(white: 0.22)) | ||
| .overlay { | ||
| Image(systemName: "music.note") | ||
| .font(.system(size: 56, weight: .medium)) | ||
| .foregroundStyle(.white.opacity(0.8)) | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize Performance by Avoiding Redundant Observations
LockScreenBackdropViewdoes not read any properties oflyricsdirectly; it only passes it down toLockScreenLyricsView(which already observes it via@ObservedObject). Markinglyricsas@ObservedObjecthere causes the entire backdrop view—including the heavyWallpaperViewand theClockView—to re-evaluate and re-render whenever the lyrics loading state updates. Changing this to a simpleletdependency avoids these redundant renders.