Skip to content

Commit

Permalink
Release V1: Add system-wide media playing support and new animations
Browse files Browse the repository at this point in the history
"""
- Added support for all sorts of media playing system-wide.
- Improved animations for a smoother user experience.
- Introduced new states for better functionality.
- Added a happy face animation to make the notch more fun.
"""
  • Loading branch information
theboringhumane committed Aug 3, 2024
1 parent 1fc7872 commit 6646ce9
Show file tree
Hide file tree
Showing 16 changed files with 534 additions and 190 deletions.
48 changes: 44 additions & 4 deletions boringNotch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@
/* Begin PBXBuildFile section */
147163982C5D35B70068B555 /* MusicVisualizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 147163972C5D35B70068B555 /* MusicVisualizer.swift */; };
1471639A2C5D35FF0068B555 /* MusicManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 147163992C5D35FF0068B555 /* MusicManager.swift */; };
1471639D2C5D364F0068B555 /* BottomRoundedRectangle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1471639C2C5D364F0068B555 /* BottomRoundedRectangle.swift */; };
1471639F2C5D368B0068B555 /* BoringNotch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1471639E2C5D368B0068B555 /* BoringNotch.swift */; };
147163AE2C5D7A080068B555 /* NowPlaying.scpt in Resources */ = {isa = PBXBuildFile; fileRef = 147163AB2C5D752E0068B555 /* NowPlaying.scpt */; };
14CEF4162C5CAED300855D72 /* boringNotchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14CEF4152C5CAED300855D72 /* boringNotchApp.swift */; };
14CEF4182C5CAED300855D72 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14CEF4172C5CAED300855D72 /* ContentView.swift */; };
14CEF41A2C5CAED400855D72 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14CEF4192C5CAED400855D72 /* Assets.xcassets */; };
14CEF41D2C5CAED400855D72 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14CEF41C2C5CAED400855D72 /* Preview Assets.xcassets */; };
14D570B62C5E961A0011E668 /* NotchShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570B52C5E961A0011E668 /* NotchShape.swift */; };
14D570B92C5E98A20011E668 /* drop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570B82C5E98A20011E668 /* drop.swift */; };
14D570BC2C5E98EB0011E668 /* generic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570BB2C5E98EB0011E668 /* generic.swift */; };
14D570BE2C5EA0270011E668 /* PlaybackManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570BD2C5EA0270011E668 /* PlaybackManager.swift */; };
14D570C02C5EA5870011E668 /* AnimatedFace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570BF2C5EA5870011E668 /* AnimatedFace.swift */; };
14D570C22C5EAFBF0011E668 /* EmptyState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570C12C5EAFBF0011E668 /* EmptyState.swift */; };
14D570C42C5EBE170011E668 /* BuyMeCoffee.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14D570C32C5EBE170011E668 /* BuyMeCoffee.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
147163972C5D35B70068B555 /* MusicVisualizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicVisualizer.swift; sourceTree = "<group>"; };
147163992C5D35FF0068B555 /* MusicManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicManager.swift; sourceTree = "<group>"; };
1471639C2C5D364F0068B555 /* BottomRoundedRectangle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomRoundedRectangle.swift; sourceTree = "<group>"; };
1471639E2C5D368B0068B555 /* BoringNotch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoringNotch.swift; sourceTree = "<group>"; };
147163AB2C5D752E0068B555 /* NowPlaying.scpt */ = {isa = PBXFileReference; lastKnownFileType = file; path = NowPlaying.scpt; sourceTree = "<group>"; };
14CEF4122C5CAED300855D72 /* boringNotch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = boringNotch.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -30,6 +35,13 @@
14CEF4192C5CAED400855D72 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
14CEF41C2C5CAED400855D72 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
14CEF41E2C5CAED400855D72 /* boringNotch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = boringNotch.entitlements; sourceTree = "<group>"; };
14D570B52C5E961A0011E668 /* NotchShape.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchShape.swift; sourceTree = "<group>"; };
14D570B82C5E98A20011E668 /* drop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = drop.swift; sourceTree = "<group>"; };
14D570BB2C5E98EB0011E668 /* generic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = generic.swift; sourceTree = "<group>"; };
14D570BD2C5EA0270011E668 /* PlaybackManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaybackManager.swift; sourceTree = "<group>"; };
14D570BF2C5EA5870011E668 /* AnimatedFace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedFace.swift; sourceTree = "<group>"; };
14D570C12C5EAFBF0011E668 /* EmptyState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyState.swift; sourceTree = "<group>"; };
14D570C32C5EBE170011E668 /* BuyMeCoffee.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuyMeCoffee.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -47,15 +59,19 @@
isa = PBXGroup;
children = (
147163972C5D35B70068B555 /* MusicVisualizer.swift */,
1471639C2C5D364F0068B555 /* BottomRoundedRectangle.swift */,
1471639E2C5D368B0068B555 /* BoringNotch.swift */,
14D570B52C5E961A0011E668 /* NotchShape.swift */,
14D570BF2C5EA5870011E668 /* AnimatedFace.swift */,
14D570C12C5EAFBF0011E668 /* EmptyState.swift */,
14D570C32C5EBE170011E668 /* BuyMeCoffee.swift */,
);
path = components;
sourceTree = "<group>";
};
147163B52C5D804B0068B555 /* managers */ = {
isa = PBXGroup;
children = (
14D570BD2C5EA0270011E668 /* PlaybackManager.swift */,
147163992C5D35FF0068B555 /* MusicManager.swift */,
);
path = managers;
Expand All @@ -81,6 +97,8 @@
14CEF4142C5CAED300855D72 /* boringNotch */ = {
isa = PBXGroup;
children = (
14D570BA2C5E98E30011E668 /* enums */,
14D570B72C5E98960011E668 /* animations */,
147163B52C5D804B0068B555 /* managers */,
1471639B2C5D362F0068B555 /* components */,
14CEF4152C5CAED300855D72 /* boringNotchApp.swift */,
Expand All @@ -100,6 +118,22 @@
path = "Preview Content";
sourceTree = "<group>";
};
14D570B72C5E98960011E668 /* animations */ = {
isa = PBXGroup;
children = (
14D570B82C5E98A20011E668 /* drop.swift */,
);
path = animations;
sourceTree = "<group>";
};
14D570BA2C5E98E30011E668 /* enums */ = {
isa = PBXGroup;
children = (
14D570BB2C5E98EB0011E668 /* generic.swift */,
);
path = enums;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -171,12 +205,18 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1471639D2C5D364F0068B555 /* BottomRoundedRectangle.swift in Sources */,
147163982C5D35B70068B555 /* MusicVisualizer.swift in Sources */,
14D570C02C5EA5870011E668 /* AnimatedFace.swift in Sources */,
14D570B92C5E98A20011E668 /* drop.swift in Sources */,
14D570BE2C5EA0270011E668 /* PlaybackManager.swift in Sources */,
1471639A2C5D35FF0068B555 /* MusicManager.swift in Sources */,
14D570BC2C5E98EB0011E668 /* generic.swift in Sources */,
14D570C42C5EBE170011E668 /* BuyMeCoffee.swift in Sources */,
1471639F2C5D368B0068B555 /* BoringNotch.swift in Sources */,
14CEF4182C5CAED300855D72 /* ContentView.swift in Sources */,
14D570B62C5E961A0011E668 /* NotchShape.swift in Sources */,
14CEF4162C5CAED300855D72 /* boringNotchApp.swift in Sources */,
14D570C22C5EAFBF0011E668 /* EmptyState.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
11 changes: 1 addition & 10 deletions boringNotch/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,11 @@ import SwiftUI
import AVFoundation
import Combine

// MARK: - Data Models

struct Song: Identifiable {
let id = UUID()
let title: String
let artist: String
let albumArt: String
}

struct ContentView: View {
let onHover: () -> Void
var body: some View {
BoringNotch(onHover: onHover)
.frame(maxWidth: .infinity, maxHeight: 200)
.frame(maxWidth: .infinity, maxHeight: 250)
.background(Color.clear)
.edgesIgnoringSafeArea(.top)
}
Expand Down
8 changes: 8 additions & 0 deletions boringNotch/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppleEventsUsageDescription</key>
<string>Read current playing music from system events</string>
</dict>
</plist>
29 changes: 29 additions & 0 deletions boringNotch/animations/drop.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// drop.swift
// boringNotch
//
// Created by Harsh Vardhan Goswami on 04/08/24.
//

import Foundation
import SwiftUI


public class BoringAnimations {
@Published var notchStyle: Style = .notch

init() {
self.notchStyle = .notch
}

var animation: Animation {
if #available(macOS 14.0, *), notchStyle == .notch {
Animation.spring(.bouncy(duration: 0.4))
} else {
Animation.timingCurve(0.16, 1, 0.3, 1, duration: 0.7)
}
}

// TODO: Move all animations to this file

}
82 changes: 82 additions & 0 deletions boringNotch/components/AnimatedFace.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// AnimatedFace.swift
//
// Created by Harsh Vardhan Goswami on 04/08/24.
//

import SwiftUI

struct MinimalFaceFeatures: View {
@State private var isBlinking = false
@State var height:CGFloat = 20;
@State var width:CGFloat = 30;

var body: some View {
VStack(spacing: 4) { // Adjusted spacing to fit within 30x30
// Eyes
HStack(spacing: 4) { // Adjusted spacing to fit within 30x30
Eye(isBlinking: $isBlinking)
Eye(isBlinking: $isBlinking)
}

// Nose and mouth combined
VStack(spacing: 2) { // Adjusted spacing to fit within 30x30
// Nose
RoundedRectangle(cornerRadius: 2)
.fill(Color.white)
.frame(width: 3, height: 10)

// Mouth (happy)
GeometryReader { geometry in
Path { path in
let width = geometry.size.width
let height = geometry.size.height
path.move(to: CGPoint(x: 0, y: height / 2))
path.addQuadCurve(to: CGPoint(x: width, y: height / 2), control: CGPoint(x: width / 2, y: height))
}
.stroke(Color.white, lineWidth: 2)
}
.frame(width: 18, height: 10)
}
}
.frame(width: self.width, height: self.height) // Maximum size of face
.onAppear {
startBlinking()
}
}

func startBlinking() {
Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { _ in
withAnimation(.easeInOut(duration: 0.1)) {
isBlinking = true
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
withAnimation(.easeInOut(duration: 0.1)) {
isBlinking = false
}
}
}
}
}

struct Eye: View {
@Binding var isBlinking: Bool

var body: some View {
RoundedRectangle(cornerRadius: 10)
.fill(Color.white)
.frame(width: 4, height: isBlinking ? 1 : 4)
.frame(maxWidth: 15, maxHeight: 15) // Adjusted max size
.animation(.easeInOut(duration: 0.1), value: isBlinking)
}
}

struct MinimalFaceFeatures_Previews: PreviewProvider {
static var previews: some View {
ZStack {
Color.black
MinimalFaceFeatures()
}
.previewLayout(.fixed(width: 60, height: 60)) // Adjusted preview size for better visibility
}
}
Loading

0 comments on commit 6646ce9

Please sign in to comment.