Skip to content

Global Notification System #1984

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

Merged
merged 21 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5aac83d
Added global notifications system
austincondiff Feb 11, 2025
779e3a6
Refactored FeatureIcon and notifications to support custom images
austincondiff Feb 11, 2025
6988330
Fixed SwiftLint errors
austincondiff Feb 11, 2025
9b524bd
Fixed SwiftLint errors
austincondiff Feb 12, 2025
99041cf
Deleted unused file
austincondiff Feb 12, 2025
13d3bca
Added sticky notifications. Allowed multiple notifications to overlay…
austincondiff Feb 12, 2025
2471175
Streamlined UI getting rid of the notifications popover in favor of t…
austincondiff Feb 13, 2025
b91877e
Added a close button click state, allows clicking under scroll view.
austincondiff Feb 14, 2025
d3d26d1
Fix SwiftLint errors by splitting up NotificationManager
austincondiff Feb 14, 2025
a4846e9
Fixed SwiftLint errors
austincondiff Feb 15, 2025
8349007
Remove test notification
austincondiff Feb 15, 2025
85f4656
Improve notification handling and workspace panel behavior
austincondiff Feb 18, 2025
721389c
Fixed SwiftLint and PR issues
austincondiff Feb 18, 2025
b839c1a
Added an Internal Development Inspector for debug purposes. This insp…
austincondiff Feb 18, 2025
c292c7d
Fixed animation glitch when taking action on a notification while not…
austincondiff Feb 19, 2025
cd1bf2d
Changed variable name isManuallyShown to isPresented, and notificatio…
austincondiff Feb 19, 2025
d2060e7
SwiftLint error fix
austincondiff Feb 19, 2025
dc33a4e
SwiftLint fixes
austincondiff Feb 19, 2025
4815194
Refactored CENotification to use delegated inits.
austincondiff Feb 19, 2025
749c716
Moved CloseButtonStyle into CodeEditUI and renamed it OverlayButtonStyle
austincondiff Feb 20, 2025
5e6c608
Using cancelables so workspace cleanup is more concise
austincondiff Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 100 additions & 8 deletions CodeEdit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

46 changes: 30 additions & 16 deletions CodeEdit/Features/About/Views/BlurButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ import SwiftUI

extension ButtonStyle where Self == BlurButtonStyle {
static var blur: BlurButtonStyle { BlurButtonStyle() }
static var secondaryBlur: BlurButtonStyle { BlurButtonStyle(isSecondary: true) }
}

struct BlurButtonStyle: ButtonStyle {
var isSecondary: Bool = false

@Environment(\.controlSize)
var controlSize

@Environment(\.colorScheme)
var colorScheme

var height: CGFloat {
switch controlSize {
case .large:
Expand All @@ -24,32 +30,40 @@ struct BlurButtonStyle: ButtonStyle {
}
}

@Environment(\.colorScheme)
var colorScheme

func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding(.horizontal, 8)
.frame(height: height)
.buttonStyle(.bordered)
.background {
switch colorScheme {
case .dark:
Color
.gray
.opacity(0.001)
.overlay(.regularMaterial.blendMode(.plusLighter))
.overlay(Color.gray.opacity(0.30))
.overlay(Color.white.opacity(configuration.isPressed ? 0.20 : 0.00))
ZStack {
Color.gray.opacity(0.001)
if isSecondary {
Rectangle()
.fill(.regularMaterial)
} else {
Rectangle()
.fill(.regularMaterial)
.blendMode(.plusLighter)
}
Color.gray.opacity(isSecondary ? 0.10 : 0.30)
Color.white.opacity(configuration.isPressed ? 0.10 : 0.00)
}
case .light:
Color
.gray
.opacity(0.001)
.overlay(.regularMaterial.blendMode(.darken))
.overlay(Color.gray.opacity(0.15).blendMode(.plusDarker))
ZStack {
Color.gray.opacity(0.001)
Rectangle()
.fill(.regularMaterial)
.blendMode(.darken)
Color.gray.opacity(isSecondary ? 0.05 : 0.15)
.blendMode(.plusDarker)
Color.gray.opacity(configuration.isPressed ? 0.10 : 0.00)
}
@unknown default:
Color.black
}
}
.clipShape(RoundedRectangle(cornerRadius: 6))
.clipShape(RoundedRectangle(cornerRadius: controlSize == .large ? 6 : 5))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import Combine
/// "id": "uniqueTaskID",
/// "action": "update",
/// "title": "Updated Task Title",
/// "message": "Updated Task Message"
/// "message": "Updated Task Message",
/// "percentage": 0.5,
/// "isLoading": true
/// ]
Expand Down
34 changes: 34 additions & 0 deletions CodeEdit/Features/CodeEditUI/Styles/OverlayButtonStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import SwiftUI

/// A button style for overlay buttons (like close, action buttons in notifications)
struct OverlayButtonStyle: ButtonStyle {
@Environment(\.colorScheme)
private var colorScheme

func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.system(size: 10))
.foregroundColor(.secondary)
.frame(width: 20, height: 20, alignment: .center)
.background(Color.primary.opacity(configuration.isPressed ? colorScheme == .dark ? 0.10 : 0.05 : 0.00))
.background(.regularMaterial)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(nsColor: .separatorColor), lineWidth: 2)
)
.cornerRadius(10)
.shadow(
color: Color(.black.withAlphaComponent(colorScheme == .dark ? 0.2 : 0.1)),
radius: 5,
x: 0,
y: 2
)
}
}

extension ButtonStyle where Self == OverlayButtonStyle {
/// A button style for overlay buttons
static var overlay: OverlayButtonStyle {
OverlayButtonStyle()
}
}
98 changes: 98 additions & 0 deletions CodeEdit/Features/CodeEditUI/Views/FeatureIcon.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// FeatureIcon.swift
// CodeEdit
//
// Created by Austin Condiff on 12/2/24.
//

import SwiftUI
import CodeEditSymbols

struct FeatureIcon: View {
private let content: IconContent
private let color: Color?
private let size: CGFloat

init(
symbol: String,
color: Color? = nil,
size: CGFloat? = nil
) {
self.content = .symbol(symbol)
self.color = color ?? .accentColor
self.size = size ?? 20
}

init(
text: String,
textColor: Color? = nil,
color: Color? = nil,
size: CGFloat? = nil
) {
self.content = .text(text, textColor: textColor)
self.color = color ?? .accentColor
self.size = size ?? 20
}

init(
image: Image,
size: CGFloat? = nil
) {
self.content = .image(image)
self.color = nil
self.size = size ?? 20
}

private func getSafeImage(named: String) -> Image {
if NSImage(systemSymbolName: named, accessibilityDescription: nil) != nil {
return Image(systemName: named)
} else {
return Image(symbol: named)
}
}

var body: some View {
RoundedRectangle(cornerRadius: size / 4, style: .continuous)
.fill(background)
.overlay {
switch content {
case let .symbol(name):
getSafeImage(named: name)
.resizable()
.aspectRatio(contentMode: .fit)
.foregroundColor(.white)
.padding(size / 8)
case let .text(text, textColor):
Text(text)
.font(.system(size: size * 0.65))
.foregroundColor(textColor ?? .primary)
case let .image(image):
image
.resizable()
.aspectRatio(contentMode: .fill)
}
}
.clipShape(RoundedRectangle(cornerRadius: size / 4, style: .continuous))
.shadow(
color: Color(NSColor.black).opacity(0.25),
radius: size / 40,
y: size / 40
)
.frame(width: size, height: size)
}

private var background: AnyShapeStyle {
switch content {
case .symbol, .text:
return AnyShapeStyle((color ?? .accentColor).gradient)
case .image:
return AnyShapeStyle(.regularMaterial)
}
}
}

private enum IconContent {
case symbol(String)
case text(String, textColor: Color?)
case image(Image)
}
10 changes: 10 additions & 0 deletions CodeEdit/Features/CodeEditUI/Views/ScrollOffsetPreferenceKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SwiftUI

/// Tracks scroll offset in scrollable views
struct ScrollOffsetPreferenceKey: PreferenceKey {
typealias Value = CGFloat
static var defaultValue = CGFloat.zero
static func reduce(value: inout Value, nextValue: () -> Value) {
value += nextValue()
}
}
145 changes: 0 additions & 145 deletions CodeEdit/Features/CodeEditUI/Views/SegmentedControlImproved.swift

This file was deleted.

Loading