-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 7: lock-screen expand (state L2) #7
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-6-lockscreen-widget
Choose a base branch
from
phase-7-lockscreen-expand
base: phase-6-lockscreen-widget
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
67 changes: 52 additions & 15 deletions
67
NotchBeat/PseudoLockScreenController/LockScreenBackdropView.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
37 changes: 37 additions & 0 deletions
37
NotchBeat/PseudoLockScreenController/LockScreenControls.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,37 @@ | ||
| import SwiftUI | ||
|
|
||
| /// Shared matched-geometry id for the lock-screen album-art hero morph | ||
| /// (widget ↔ expanded). | ||
| enum LockScreenMorph { | ||
| static let art = "ls-art" | ||
| } | ||
|
|
||
| /// Shared prev / play-pause / next row used by the lock-screen widget (L1) and | ||
| /// the expanded view (L2), so the transport controls stay identical. | ||
| struct TransportButtons: View { | ||
| let isPlaying: Bool | ||
| let onPrevious: () -> Void | ||
| let onPlayPause: () -> Void | ||
| let onNext: () -> Void | ||
| var primarySize: CGFloat = 26 | ||
|
|
||
| var body: some View { | ||
| HStack(spacing: 40) { | ||
| button("backward.fill", primarySize * 0.7, onPrevious) | ||
| button(isPlaying ? "pause.fill" : "play.fill", primarySize, onPlayPause) | ||
| .contentTransition(.symbolEffect(.replace)) | ||
| button("forward.fill", primarySize * 0.7, onNext) | ||
| } | ||
| } | ||
|
|
||
| private func button(_ symbol: String, _ size: CGFloat, _ action: @escaping () -> Void) -> some View { | ||
| Button(action: action) { | ||
| Image(systemName: symbol) | ||
| .font(.system(size: size, weight: .semibold)) | ||
| .foregroundStyle(.white.opacity(0.95)) | ||
| .frame(width: size + 20, height: size + 16) | ||
| .contentShape(Rectangle()) | ||
| } | ||
| .buttonStyle(.plain) | ||
| } | ||
| } |
80 changes: 80 additions & 0 deletions
80
NotchBeat/PseudoLockScreenController/LockScreenExpandedView.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,80 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| /// Expanded lock-screen now-playing (PRD §3.2 L2, reference image 2): large | ||
| /// album art centered on the dimmed backdrop, with a frosted control pill | ||
| /// (title/artist, scrubber, transport) below it. The art carries the hero | ||
| /// morph from the compact widget. | ||
| struct LockScreenExpandedView: View { | ||
| let nowPlaying: 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 { | ||
| VStack(spacing: 28) { | ||
| artwork | ||
| .frame(width: 320, height: 320) | ||
| .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) | ||
| .matchedGeometryEffect(id: LockScreenMorph.art, in: namespace) | ||
| .shadow(color: .black.opacity(0.5), radius: 30, y: 14) | ||
|
|
||
| controlPill | ||
| } | ||
| } | ||
|
|
||
| private var controlPill: some View { | ||
| VStack(spacing: 14) { | ||
| VStack(spacing: 3) { | ||
| Text(nowPlaying.title) | ||
| .font(.system(size: 17, weight: .semibold)) | ||
| .foregroundStyle(.white) | ||
| Text(nowPlaying.artist) | ||
| .font(.system(size: 14)) | ||
| .foregroundStyle(.white.opacity(0.65)) | ||
| } | ||
| .lineLimit(1) | ||
|
|
||
| ScrubberView(nowPlaying: nowPlaying, onSeek: onSeek, onActivity: {}) | ||
|
|
||
| TransportButtons( | ||
| isPlaying: nowPlaying.isPlaying, | ||
| onPrevious: onPrevious, | ||
| onPlayPause: onPlayPause, | ||
| onNext: onNext, | ||
| primarySize: 30 | ||
| ) | ||
| .padding(.top, 2) | ||
| } | ||
| .padding(20) | ||
| .frame(width: 360) | ||
| .background { | ||
| let shape = RoundedRectangle(cornerRadius: 24, style: .continuous) | ||
| ZStack { | ||
| shape.fill(.ultraThinMaterial) | ||
| shape.fill(.black.opacity(0.28)) | ||
| } | ||
| } | ||
| .clipShape(RoundedRectangle(cornerRadius: 24, style: .continuous)) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var artwork: some View { | ||
| if let albumArt { | ||
| Image(nsImage: albumArt) | ||
| .resizable() | ||
| .aspectRatio(contentMode: .fill) | ||
| } else { | ||
| RoundedRectangle(cornerRadius: 16, style: .continuous) | ||
| .fill(Color(white: 0.22)) | ||
| .overlay { | ||
| Image(systemName: "music.note") | ||
| .font(.system(size: 80, weight: .medium)) | ||
| .foregroundStyle(.white.opacity(0.8)) | ||
| } | ||
| } | ||
| } | ||
| } |
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
62 changes: 62 additions & 0 deletions
62
NotchBeat/PseudoLockScreenController/LockScreenUIState.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,62 @@ | ||
| import SwiftUI | ||
|
|
||
| /// Interaction state for the lock-screen surface: which of the three states | ||
| /// (widget / expanded / lyrics) is presented, and the shared spring. Parallels | ||
| /// the notch's `NotchUIState`; closing is always opening reversed. | ||
| @MainActor | ||
| final class LockScreenUIState: ObservableObject { | ||
| enum Presentation: Equatable { | ||
| case widget // L1 | ||
| case expanded // L2 | ||
| case lyrics // L3 (phase 8) | ||
| } | ||
|
|
||
| /// Same feel as the notch's open/close (NotchUIState.spring). | ||
| static let spring = Animation.smooth(duration: 0.5, extraBounce: 0.12) | ||
|
|
||
| @Published private(set) var presentation: Presentation = .widget | ||
|
|
||
| /// L1 → L2: click the widget. | ||
| func expand() { | ||
| guard presentation == .widget else { return } | ||
| set(.expanded) | ||
| } | ||
|
|
||
| /// L2/L1 → L3: two-finger swipe (phase 8). | ||
| func showLyrics() { | ||
| guard presentation != .lyrics else { return } | ||
| set(.lyrics) | ||
| } | ||
|
|
||
| /// L3 → L2: swipe back (phase 8). | ||
| func returnToExpanded() { | ||
| guard presentation == .lyrics else { return } | ||
| set(.expanded) | ||
| } | ||
|
|
||
| /// Any → L1. | ||
| func collapse() { | ||
| set(.widget) | ||
| } | ||
|
|
||
| /// Esc / click-away steps down one level: lyrics → expanded → widget. The | ||
| /// controller hides the whole surface when this is called at the widget | ||
| /// level. | ||
| func stepDown() { | ||
| switch presentation { | ||
| case .lyrics: set(.expanded) | ||
| case .expanded: set(.widget) | ||
| case .widget: break | ||
| } | ||
| } | ||
|
|
||
| /// Instant reset (no animation) when the surface is hidden, so it reopens | ||
| /// at the widget state. | ||
| func reset() { | ||
| presentation = .widget | ||
| } | ||
|
|
||
| private func set(_ next: Presentation) { | ||
| withAnimation(Self.spring) { presentation = next } | ||
| } | ||
| } |
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.
The
primarySizeparameter is redundant here becauseTransportButtonsalready defaultsprimarySizeto26. Removing it simplifies the call site.