mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
Make some changes: fixes and stuff
This commit is contained in:
parent
05d41f6bb7
commit
d0448ec2cb
10 changed files with 209 additions and 150 deletions
|
|
@ -0,0 +1 @@
|
|||
// Legacy placeholder file superseded by LockScreenLiveActivityOverlay.swift.
|
||||
|
|
@ -1,89 +1,57 @@
|
|||
//
|
||||
// LockScreenLiveActivityOverlay.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Mirrors the closed-notch live activity layout on the macOS lock screen.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum LockLiveActivityState: Equatable {
|
||||
case locked
|
||||
case unlocking
|
||||
}
|
||||
|
||||
final class LockScreenLiveActivityOverlayViewModel: ObservableObject {
|
||||
@Published var expansion: CGFloat = 1
|
||||
final class LockScreenLiveActivityOverlayModel: ObservableObject {
|
||||
@Published var iconName: String = "lock.fill"
|
||||
@Published var scale: CGFloat = 0.6
|
||||
@Published var opacity: Double = 0
|
||||
}
|
||||
|
||||
struct LockScreenLiveActivityOverlay: View {
|
||||
let state: LockLiveActivityState
|
||||
let notchSize: CGSize
|
||||
@ObservedObject var viewModel: LockScreenLiveActivityOverlayViewModel
|
||||
@ObservedObject var model: LockScreenLiveActivityOverlayModel
|
||||
let notchSize: CGSize
|
||||
|
||||
private var indicatorSize: CGFloat {
|
||||
max(0, notchSize.height - 12)
|
||||
}
|
||||
private var indicatorSize: CGFloat {
|
||||
max(0, notchSize.height - 12)
|
||||
}
|
||||
|
||||
private var horizontalPadding: CGFloat {
|
||||
cornerRadiusInsets.closed.bottom
|
||||
}
|
||||
private var horizontalPadding: CGFloat {
|
||||
cornerRadiusInsets.closed.bottom
|
||||
}
|
||||
|
||||
private var baseWidth: CGFloat {
|
||||
notchSize.width + (indicatorSize * 2)
|
||||
}
|
||||
private var totalWidth: CGFloat {
|
||||
notchSize.width + (indicatorSize * 2) + (horizontalPadding * 2)
|
||||
}
|
||||
|
||||
private var totalWidth: CGFloat {
|
||||
baseWidth + (horizontalPadding * 2)
|
||||
}
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
Color.clear
|
||||
.overlay(alignment: .leading) {
|
||||
Image(systemName: model.iconName)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: indicatorSize, height: indicatorSize)
|
||||
}
|
||||
.frame(width: indicatorSize, height: notchSize.height)
|
||||
|
||||
private var iconName: String {
|
||||
state == .locked ? "lock.fill" : "lock.open.fill"
|
||||
}
|
||||
Rectangle()
|
||||
.fill(.black)
|
||||
.frame(width: notchSize.width, height: notchSize.height)
|
||||
|
||||
private var iconColor: Color { .white }
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
Color.clear
|
||||
.overlay(alignment: .leading) {
|
||||
Image(systemName: iconName)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundStyle(iconColor)
|
||||
.frame(width: indicatorSize, height: indicatorSize)
|
||||
}
|
||||
.frame(width: indicatorSize, height: notchSize.height, alignment: .top)
|
||||
|
||||
Color.clear
|
||||
.frame(width: notchSize.width, height: notchSize.height, alignment: .top)
|
||||
|
||||
Color.clear
|
||||
.frame(width: indicatorSize, height: notchSize.height, alignment: .top)
|
||||
}
|
||||
.frame(width: baseWidth, height: notchSize.height)
|
||||
.padding(.horizontal, horizontalPadding)
|
||||
.background(Color.black)
|
||||
.clipShape(
|
||||
NotchShape(
|
||||
topCornerRadius: cornerRadiusInsets.closed.top,
|
||||
bottomCornerRadius: cornerRadiusInsets.closed.bottom
|
||||
)
|
||||
)
|
||||
.frame(width: totalWidth, height: notchSize.height)
|
||||
.scaleEffect(x: max(0.05, viewModel.expansion), y: 1, anchor: .center)
|
||||
.opacity(min(1, max(0.2, viewModel.expansion * 5)))
|
||||
.animation(.spring(response: 0.45, dampingFraction: 0.85), value: state)
|
||||
.animation(.spring(response: 0.5, dampingFraction: 0.85), value: viewModel.expansion)
|
||||
.drawingGroup()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
let model = LockScreenLiveActivityOverlayViewModel()
|
||||
return VStack(spacing: 24) {
|
||||
LockScreenLiveActivityOverlay(state: .locked, notchSize: CGSize(width: 220, height: 32), viewModel: model)
|
||||
LockScreenLiveActivityOverlay(state: .unlocking, notchSize: CGSize(width: 220, height: 32), viewModel: model)
|
||||
}
|
||||
.padding()
|
||||
.background(Color.gray.opacity(0.2))
|
||||
Color.clear
|
||||
.frame(width: indicatorSize, height: notchSize.height)
|
||||
}
|
||||
.frame(width: notchSize.width + (indicatorSize * 2), height: notchSize.height)
|
||||
.padding(.horizontal, horizontalPadding)
|
||||
.background(Color.black)
|
||||
.clipShape(
|
||||
NotchShape(
|
||||
topCornerRadius: cornerRadiusInsets.closed.top,
|
||||
bottomCornerRadius: cornerRadiusInsets.closed.bottom
|
||||
)
|
||||
)
|
||||
.frame(width: totalWidth, height: notchSize.height)
|
||||
.scaleEffect(x: model.scale, y: 1, anchor: .center)
|
||||
.opacity(model.opacity)
|
||||
.drawingGroup()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ struct LockScreenMusicPanel: View {
|
|||
@State private var lastDragged: Date = .distantPast
|
||||
@State private var isActive = true
|
||||
|
||||
private let panelWidth: CGFloat = 460
|
||||
private let panelHeight: CGFloat = 180
|
||||
private let cornerRadius: CGFloat = 28
|
||||
|
||||
var body: some View {
|
||||
if isActive {
|
||||
panelContent
|
||||
|
|
@ -23,14 +27,14 @@ struct LockScreenMusicPanel: View {
|
|||
}
|
||||
} else {
|
||||
Color.clear
|
||||
.frame(width: 420, height: 150)
|
||||
.frame(width: panelWidth, height: panelHeight)
|
||||
}
|
||||
}
|
||||
|
||||
private var panelContent: some View {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 12) {
|
||||
// Header area with album art
|
||||
HStack(alignment: .center, spacing: 10) {
|
||||
HStack(alignment: .center, spacing: 16) {
|
||||
// Album art
|
||||
Button {
|
||||
musicManager.openMusicApp()
|
||||
|
|
@ -38,8 +42,8 @@ struct LockScreenMusicPanel: View {
|
|||
Image(nsImage: musicManager.albumArt)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 50, height: 50)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
.frame(width: 60, height: 60)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 16))
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.opacity(musicManager.isPlaying ? 1 : 0.4)
|
||||
|
|
@ -71,30 +75,30 @@ struct LockScreenMusicPanel: View {
|
|||
.frame(width: 20, height: 16)
|
||||
}
|
||||
}
|
||||
.frame(height: 50)
|
||||
.frame(height: 60)
|
||||
|
||||
// Progress bar
|
||||
progressBar
|
||||
.padding(.top, 6)
|
||||
.padding(.top, 4)
|
||||
|
||||
// Playback controls
|
||||
playbackControls
|
||||
.padding(.top, 4)
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 8)
|
||||
.frame(width: 420, height: 150)
|
||||
.padding(.horizontal, 20)
|
||||
.padding(.vertical, 16)
|
||||
.frame(width: panelWidth, height: panelHeight)
|
||||
.background {
|
||||
if #available(macOS 26.0, *) {
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.glassEffect(in: .rect(cornerRadius: 20))
|
||||
RoundedRectangle(cornerRadius: cornerRadius)
|
||||
.glassEffect(in: .rect(cornerRadius: cornerRadius))
|
||||
.onAppear {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm:ss.SSS"
|
||||
print("[\(formatter.string(from: Date()))] LockScreenMusicPanel: ✨ Using macOS 26.0+ Liquid Glass effect")
|
||||
}
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
RoundedRectangle(cornerRadius: cornerRadius)
|
||||
.fill(.ultraThinMaterial)
|
||||
.onAppear {
|
||||
let formatter = DateFormatter()
|
||||
|
|
@ -103,6 +107,10 @@ struct LockScreenMusicPanel: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.overlay {
|
||||
RoundedRectangle(cornerRadius: cornerRadius)
|
||||
.stroke(Color.white.opacity(0.35), lineWidth: 1.4)
|
||||
}
|
||||
.shadow(color: Color.black.opacity(0.3), radius: 20, x: 0, y: 10)
|
||||
.onAppear {
|
||||
sliderValue = musicManager.elapsedTime
|
||||
|
|
@ -233,7 +241,9 @@ struct LockScreenMusicPanel: View {
|
|||
Image(systemName: musicManager.isPlaying ? "pause.fill" : "play.fill")
|
||||
.font(.system(size: 24, weight: .semibold))
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 50, height: 50)
|
||||
.frame(width: 54, height: 54)
|
||||
.background(Color.white.opacity(0.15))
|
||||
.clipShape(Circle())
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue