mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
Still working on the janky animation
This commit is contained in:
parent
44569d36b5
commit
c5186c47f8
10 changed files with 628 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ enum ActivityType {
|
|||
case mediaPlayback
|
||||
case charging
|
||||
case download
|
||||
case recording
|
||||
}
|
||||
|
||||
struct LiveActivityModifier<Left: View, Right: View>: ViewModifier {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,13 @@ struct DynamicIslandHeader: View {
|
|||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
||||
// Screen Recording Indicator
|
||||
if Defaults[.enableScreenRecordingDetection] && Defaults[.showRecordingIndicator] {
|
||||
RecordingIndicator()
|
||||
.frame(width: 30, height: 30) // Same size as other header elements
|
||||
}
|
||||
|
||||
if Defaults[.showBatteryIndicator] {
|
||||
DynamicIslandBatteryView(
|
||||
batteryWidth: 30,
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ struct GeneralSettings: View {
|
|||
@State private var screens: [String] = NSScreen.screens.compactMap { $0.localizedName }
|
||||
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||
@ObservedObject var coordinator = DynamicIslandViewCoordinator.shared
|
||||
@ObservedObject var recordingManager = ScreenRecordingManager.shared
|
||||
|
||||
@Default(.mirrorShape) var mirrorShape
|
||||
@Default(.showEmojis) var showEmojis
|
||||
|
|
@ -162,6 +163,8 @@ struct GeneralSettings: View {
|
|||
@Default(.automaticallySwitchDisplay) var automaticallySwitchDisplay
|
||||
@Default(.enableGestures) var enableGestures
|
||||
@Default(.openNotchOnHover) var openNotchOnHover
|
||||
@Default(.enableScreenRecordingDetection) var enableScreenRecordingDetection
|
||||
@Default(.showRecordingIndicator) var showRecordingIndicator
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
|
|
@ -192,6 +195,36 @@ struct GeneralSettings: View {
|
|||
} header: {
|
||||
Text("System features")
|
||||
}
|
||||
|
||||
Section {
|
||||
Defaults.Toggle("Enable Screen Recording Detection", key: .enableScreenRecordingDetection)
|
||||
|
||||
Defaults.Toggle("Show Recording Indicator", key: .showRecordingIndicator)
|
||||
.disabled(!enableScreenRecordingDetection)
|
||||
|
||||
if recordingManager.isMonitoring {
|
||||
HStack {
|
||||
Text("Detection Status")
|
||||
Spacer()
|
||||
if recordingManager.isRecording {
|
||||
HStack(spacing: 4) {
|
||||
Circle()
|
||||
.fill(Color.red)
|
||||
.frame(width: 8, height: 8)
|
||||
Text("Recording Detected")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
} else {
|
||||
Text("Active - No Recording")
|
||||
.foregroundColor(.green)
|
||||
}
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
Text("Privacy & Security")
|
||||
} footer: {
|
||||
Text("Screen recording detection shows a red indicator when your screen is being captured. Detection uses minimal system resources and can be disabled at any time.")
|
||||
}
|
||||
|
||||
Section {
|
||||
Picker(selection: $notchHeightMode, label:
|
||||
|
|
|
|||
172
DynamicIsland/components/UI/RecordingIndicator.swift
Normal file
172
DynamicIsland/components/UI/RecordingIndicator.swift
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
//
|
||||
// RecordingIndicator.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Created for screen recording detection feature
|
||||
// Displays a red pulsing dot when screen recording is active
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RecordingIndicator: View {
|
||||
@ObservedObject var recordingManager = ScreenRecordingManager.shared
|
||||
@State private var isPulsing = false
|
||||
|
||||
// MARK: - Configuration
|
||||
private let indicatorSize: CGFloat = 6
|
||||
private let glowSize: CGFloat = 2
|
||||
private let animationDuration: Double = 0.8
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if recordingManager.isRecording {
|
||||
ZStack {
|
||||
// Glow effect
|
||||
Circle()
|
||||
.fill(Color.red.opacity(0.3))
|
||||
.frame(width: indicatorSize + glowSize * 2, height: indicatorSize + glowSize * 2)
|
||||
.blur(radius: glowSize)
|
||||
.scaleEffect(isPulsing ? 1.2 : 1.0)
|
||||
|
||||
// Main indicator dot
|
||||
Circle()
|
||||
.fill(Color.red)
|
||||
.frame(width: indicatorSize, height: indicatorSize)
|
||||
.opacity(isPulsing ? 1.0 : 0.6)
|
||||
}
|
||||
.onAppear {
|
||||
startPulsingAnimation()
|
||||
}
|
||||
.onDisappear {
|
||||
stopPulsingAnimation()
|
||||
}
|
||||
.transition(.asymmetric(
|
||||
insertion: .scale.combined(with: .opacity),
|
||||
removal: .scale.combined(with: .opacity)
|
||||
))
|
||||
}
|
||||
}
|
||||
.animation(.easeInOut(duration: 0.3), value: recordingManager.isRecording)
|
||||
}
|
||||
|
||||
// MARK: - Private Methods
|
||||
|
||||
private func startPulsingAnimation() {
|
||||
isPulsing = false
|
||||
withAnimation(.easeInOut(duration: animationDuration).repeatForever(autoreverses: true)) {
|
||||
isPulsing = true
|
||||
}
|
||||
}
|
||||
|
||||
private func stopPulsingAnimation() {
|
||||
withAnimation(.easeInOut(duration: 0.2)) {
|
||||
isPulsing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preview
|
||||
|
||||
struct RecordingIndicator_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
// Recording state preview
|
||||
VStack {
|
||||
Text("Recording Active")
|
||||
.font(.caption)
|
||||
RecordingIndicator()
|
||||
.onAppear {
|
||||
ScreenRecordingManager.shared.isRecording = true
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color.black)
|
||||
.previewDisplayName("Recording Active")
|
||||
|
||||
// Non-recording state preview
|
||||
VStack {
|
||||
Text("Not Recording")
|
||||
.font(.caption)
|
||||
RecordingIndicator()
|
||||
.onAppear {
|
||||
ScreenRecordingManager.shared.isRecording = false
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color.black)
|
||||
.previewDisplayName("Not Recording")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Alternative Indicator Styles
|
||||
|
||||
struct RecordingIndicatorLarge: View {
|
||||
@ObservedObject var recordingManager = ScreenRecordingManager.shared
|
||||
@State private var isPulsing = false
|
||||
|
||||
private let indicatorSize: CGFloat = 10
|
||||
private let glowSize: CGFloat = 3
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if recordingManager.isRecording {
|
||||
ZStack {
|
||||
// Outer glow
|
||||
Circle()
|
||||
.fill(Color.red.opacity(0.2))
|
||||
.frame(width: indicatorSize + glowSize * 4, height: indicatorSize + glowSize * 4)
|
||||
.blur(radius: glowSize)
|
||||
.scaleEffect(isPulsing ? 1.3 : 1.0)
|
||||
|
||||
// Inner glow
|
||||
Circle()
|
||||
.fill(Color.red.opacity(0.4))
|
||||
.frame(width: indicatorSize + glowSize * 2, height: indicatorSize + glowSize * 2)
|
||||
.blur(radius: glowSize / 2)
|
||||
.scaleEffect(isPulsing ? 1.1 : 1.0)
|
||||
|
||||
// Main indicator
|
||||
Circle()
|
||||
.fill(Color.red)
|
||||
.frame(width: indicatorSize, height: indicatorSize)
|
||||
.opacity(isPulsing ? 1.0 : 0.7)
|
||||
}
|
||||
.onAppear {
|
||||
withAnimation(.easeInOut(duration: 0.8).repeatForever(autoreverses: true)) {
|
||||
isPulsing = true
|
||||
}
|
||||
}
|
||||
.transition(.asymmetric(
|
||||
insertion: .scale.combined(with: .opacity),
|
||||
removal: .scale.combined(with: .opacity)
|
||||
))
|
||||
}
|
||||
}
|
||||
.animation(.easeInOut(duration: 0.3), value: recordingManager.isRecording)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subtle Indicator for Closed State
|
||||
|
||||
struct RecordingIndicatorSubtle: View {
|
||||
@ObservedObject var recordingManager = ScreenRecordingManager.shared
|
||||
@State private var opacity: Double = 0.5
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if recordingManager.isRecording {
|
||||
Circle()
|
||||
.fill(Color.red)
|
||||
.frame(width: 4, height: 4)
|
||||
.opacity(opacity)
|
||||
.onAppear {
|
||||
withAnimation(.easeInOut(duration: 1.0).repeatForever(autoreverses: true)) {
|
||||
opacity = 1.0
|
||||
}
|
||||
}
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
.animation(.easeInOut(duration: 0.2), value: recordingManager.isRecording)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue